]>
Commit | Line | Data |
---|---|---|
d6de6452 ZG |
1 | /** @file\r |
2 | DXE Reset System Library instance that calls gRT->ResetSystem().\r | |
3 | \r | |
4 | Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>\r | |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
d6de6452 ZG |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include <PiDxe.h>\r | |
10 | #include <Library/ResetSystemLib.h>\r | |
11 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
12 | #include <Library/UefiBootServicesTableLib.h>\r | |
13 | #include <Library/DebugLib.h>\r | |
14 | \r | |
15 | EFI_EVENT mRuntimeResetSystemLibVirtualAddressChangeEvent;\r | |
16 | EFI_RUNTIME_SERVICES *mInternalRT;\r | |
17 | \r | |
18 | /**\r | |
19 | This function causes a system-wide reset (cold reset), in which\r | |
20 | all circuitry within the system returns to its initial state. This type of reset\r | |
21 | is asynchronous to system operation and operates without regard to\r | |
22 | cycle boundaries.\r | |
23 | \r | |
24 | If this function returns, it means that the system does not support cold reset.\r | |
25 | **/\r | |
26 | VOID\r | |
27 | EFIAPI\r | |
28 | ResetCold (\r | |
29 | VOID\r | |
30 | )\r | |
31 | {\r | |
32 | mInternalRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r | |
33 | }\r | |
34 | \r | |
35 | /**\r | |
36 | This function causes a system-wide initialization (warm reset), in which all processors\r | |
37 | are set to their initial state. Pending cycles are not corrupted.\r | |
38 | \r | |
39 | If this function returns, it means that the system does not support warm reset.\r | |
40 | **/\r | |
41 | VOID\r | |
42 | EFIAPI\r | |
43 | ResetWarm (\r | |
44 | VOID\r | |
45 | )\r | |
46 | {\r | |
47 | mInternalRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r | |
48 | }\r | |
49 | \r | |
50 | /**\r | |
51 | This function causes the system to enter a power state equivalent\r | |
52 | to the ACPI G2/S5 or G3 states.\r | |
53 | \r | |
54 | If this function returns, it means that the system does not support shut down reset.\r | |
55 | **/\r | |
56 | VOID\r | |
57 | EFIAPI\r | |
58 | ResetShutdown (\r | |
59 | VOID\r | |
60 | )\r | |
61 | {\r | |
62 | mInternalRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL);\r | |
63 | }\r | |
64 | \r | |
65 | /**\r | |
66 | This function causes the system to enter S3 and then wake up immediately.\r | |
67 | \r | |
68 | If this function returns, it means that the system does not support S3 feature.\r | |
69 | **/\r | |
70 | VOID\r | |
71 | EFIAPI\r | |
72 | EnterS3WithImmediateWake (\r | |
73 | VOID\r | |
74 | )\r | |
75 | {\r | |
76 | }\r | |
77 | \r | |
78 | /**\r | |
79 | This function causes a systemwide reset. The exact type of the reset is\r | |
80 | defined by the EFI_GUID that follows the Null-terminated Unicode string passed\r | |
81 | into ResetData. If the platform does not recognize the EFI_GUID in ResetData\r | |
82 | the platform must pick a supported reset type to perform.The platform may\r | |
83 | optionally log the parameters from any non-normal reset that occurs.\r | |
84 | \r | |
85 | @param[in] DataSize The size, in bytes, of ResetData.\r | |
86 | @param[in] ResetData The data buffer starts with a Null-terminated string,\r | |
87 | followed by the EFI_GUID.\r | |
88 | **/\r | |
89 | VOID\r | |
90 | EFIAPI\r | |
91 | ResetPlatformSpecific (\r | |
92 | IN UINTN DataSize,\r | |
93 | IN VOID *ResetData\r | |
94 | )\r | |
95 | {\r | |
96 | mInternalRT->ResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData);\r | |
97 | }\r | |
98 | \r | |
99 | /**\r | |
100 | The ResetSystem function resets the entire platform.\r | |
101 | \r | |
102 | @param[in] ResetType The type of reset to perform.\r | |
103 | @param[in] ResetStatus The status code for the reset.\r | |
104 | @param[in] DataSize The size, in bytes, of ResetData.\r | |
105 | @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r | |
106 | the data buffer starts with a Null-terminated string, optionally\r | |
107 | followed by additional binary data. The string is a description\r | |
108 | that the caller may use to further indicate the reason for the\r | |
109 | system reset. ResetData is only valid if ResetStatus is something\r | |
110 | other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific\r | |
111 | where a minimum amount of ResetData is always required.\r | |
112 | **/\r | |
113 | VOID\r | |
114 | EFIAPI\r | |
115 | ResetSystem (\r | |
116 | IN EFI_RESET_TYPE ResetType,\r | |
117 | IN EFI_STATUS ResetStatus,\r | |
118 | IN UINTN DataSize,\r | |
119 | IN VOID *ResetData OPTIONAL\r | |
120 | )\r | |
121 | {\r | |
122 | mInternalRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r | |
123 | }\r | |
124 | \r | |
125 | /**\r | |
126 | Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r | |
127 | \r | |
128 | @param Event Event whose notification function is being invoked.\r | |
129 | @param Context Pointer to the notification function's context\r | |
130 | \r | |
131 | **/\r | |
132 | VOID\r | |
133 | EFIAPI\r | |
134 | RuntimeResetSystemLibVirtualAddressChange (\r | |
135 | IN EFI_EVENT Event,\r | |
136 | IN VOID *Context\r | |
137 | )\r | |
138 | {\r | |
139 | mInternalRT->ConvertPointer (0, (VOID **) &mInternalRT);\r | |
140 | }\r | |
141 | \r | |
142 | /**\r | |
143 | The constructor function of Runtime Reset System Lib.\r | |
144 | \r | |
145 | This function allocates memory for extended status code data, caches\r | |
146 | the report status code service, and registers events.\r | |
147 | \r | |
148 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
149 | @param SystemTable A pointer to the EFI System Table.\r | |
150 | \r | |
151 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
152 | \r | |
153 | **/\r | |
154 | EFI_STATUS\r | |
155 | EFIAPI\r | |
156 | RuntimeResetSystemLibConstruct (\r | |
157 | IN EFI_HANDLE ImageHandle,\r | |
158 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
159 | )\r | |
160 | {\r | |
161 | EFI_STATUS Status;\r | |
162 | \r | |
163 | //\r | |
164 | // Library should not use the gRT directly, for it may be converted by other library instance.\r | |
165 | //\r | |
166 | mInternalRT = gRT;\r | |
167 | \r | |
168 | //\r | |
169 | // Register notify function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE\r | |
170 | //\r | |
171 | Status = gBS->CreateEventEx (\r | |
172 | EVT_NOTIFY_SIGNAL,\r | |
173 | TPL_NOTIFY,\r | |
174 | RuntimeResetSystemLibVirtualAddressChange,\r | |
175 | NULL,\r | |
176 | &gEfiEventVirtualAddressChangeGuid,\r | |
177 | &mRuntimeResetSystemLibVirtualAddressChangeEvent\r | |
178 | );\r | |
179 | ASSERT_EFI_ERROR (Status);\r | |
180 | \r | |
181 | return EFI_SUCCESS;\r | |
182 | }\r | |
183 | \r | |
184 | /**\r | |
185 | The Deconstructor function of Runtime Reset System Lib.\r | |
186 | \r | |
187 | The destructor function frees memory allocated by constructor, and closes related events.\r | |
188 | It will ASSERT() if that related operation fails and it will always return EFI_SUCCESS.\r | |
189 | \r | |
190 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
191 | @param SystemTable A pointer to the EFI System Table.\r | |
192 | \r | |
193 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
194 | \r | |
195 | **/\r | |
196 | EFI_STATUS\r | |
197 | EFIAPI\r | |
198 | RuntimeResetSystemLibDeconstruct (\r | |
199 | IN EFI_HANDLE ImageHandle,\r | |
200 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
201 | )\r | |
202 | {\r | |
203 | EFI_STATUS Status;\r | |
204 | \r | |
205 | ASSERT (gBS != NULL);\r | |
206 | Status = gBS->CloseEvent (mRuntimeResetSystemLibVirtualAddressChangeEvent);\r | |
207 | ASSERT_EFI_ERROR (Status);\r | |
208 | \r | |
209 | return EFI_SUCCESS;\r | |
210 | }\r |