]>
Commit | Line | Data |
---|---|---|
42eedea9 | 1 | /** @file\r |
60c93673 | 2 | UEFI Runtime Library implementation for non IPF processor types.\r |
ebcc8fb7 | 3 | \r |
363bb1b5 | 4 | This library hides the global variable for the EFI Runtime Services so the\r |
5 | caller does not need to deal with the possibility of being called from an\r | |
6 | OS virtual address space. All pointer values are different for a virtual \r | |
7 | mapping than from the normal physical mapping at boot services time.\r | |
8 | \r | |
19388d29 HT |
9 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r |
10 | This program and the accompanying materials\r | |
ebcc8fb7 | 11 | are licensed and made available under the terms and conditions of the BSD License\r |
12 | which accompanies this distribution. The full text of the license may be found at\r | |
58380e9c | 13 | http://opensource.org/licenses/bsd-license.php.\r |
ebcc8fb7 | 14 | \r |
15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
16 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
17 | \r | |
18 | **/\r | |
19 | \r | |
363bb1b5 | 20 | #include <Uefi.h>\r |
21 | #include <Library/UefiRuntimeLib.h>\r | |
22 | #include <Library/DebugLib.h>\r | |
23 | #include <Library/UefiBootServicesTableLib.h>\r | |
24 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
25 | #include <Guid/EventGroup.h>\r | |
ebcc8fb7 | 26 | \r |
27 | ///\r | |
28 | /// Driver Lib Module Globals\r | |
29 | ///\r | |
fe467413 | 30 | EFI_EVENT mEfiVirtualNotifyEvent;\r |
31 | EFI_EVENT mEfiExitBootServicesEvent;\r | |
32 | BOOLEAN mEfiGoneVirtual = FALSE;\r | |
33 | BOOLEAN mEfiAtRuntime = FALSE;\r | |
363bb1b5 | 34 | EFI_RUNTIME_SERVICES *mInternalRT;\r |
ebcc8fb7 | 35 | \r |
36 | /**\r | |
42eedea9 | 37 | Set AtRuntime flag as TRUE after ExitBootServices.\r |
ebcc8fb7 | 38 | \r |
58380e9c | 39 | @param[in] Event The Event that is being processed.\r |
40 | @param[in] Context The Event Context.\r | |
363bb1b5 | 41 | \r |
ebcc8fb7 | 42 | **/\r |
43 | VOID\r | |
44 | EFIAPI\r | |
21998b67 | 45 | RuntimeLibExitBootServicesEvent (\r |
ebcc8fb7 | 46 | IN EFI_EVENT Event,\r |
47 | IN VOID *Context\r | |
48 | )\r | |
49 | {\r | |
ebcc8fb7 | 50 | mEfiAtRuntime = TRUE;\r |
51 | }\r | |
52 | \r | |
53 | /**\r | |
54 | Fixup internal data so that EFI can be call in virtual mode.\r | |
55 | Call the passed in Child Notify event and convert any pointers in\r | |
56 | lib to virtual mode.\r | |
57 | \r | |
58380e9c | 58 | @param[in] Event The Event that is being processed.\r |
59 | @param[in] Context The Event Context.\r | |
ebcc8fb7 | 60 | **/\r |
ebcc8fb7 | 61 | VOID\r |
62 | EFIAPI\r | |
63 | RuntimeLibVirtualNotifyEvent (\r | |
64 | IN EFI_EVENT Event,\r | |
65 | IN VOID *Context\r | |
66 | )\r | |
67 | {\r | |
ebcc8fb7 | 68 | //\r |
69 | // Update global for Runtime Services Table and IO\r | |
70 | //\r | |
363bb1b5 | 71 | EfiConvertPointer (0, (VOID **) &mInternalRT);\r |
ebcc8fb7 | 72 | \r |
73 | mEfiGoneVirtual = TRUE;\r | |
74 | }\r | |
75 | \r | |
76 | /**\r | |
a9b896f4 | 77 | Initialize runtime Driver Lib if it has not yet been initialized.\r |
60c93673 LG |
78 | It will ASSERT() if gRT is NULL or gBS is NULL.\r |
79 | It will ASSERT() if that operation fails.\r | |
ebcc8fb7 | 80 | \r |
81 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r | |
82 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
83 | \r | |
84 | @return EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r | |
85 | **/\r | |
86 | EFI_STATUS\r | |
87 | EFIAPI\r | |
88 | RuntimeDriverLibConstruct (\r | |
89 | IN EFI_HANDLE ImageHandle,\r | |
90 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
91 | )\r | |
92 | {\r | |
93 | EFI_STATUS Status;\r | |
94 | \r | |
60c93673 LG |
95 | ASSERT (gRT != NULL);\r |
96 | ASSERT (gBS != NULL);\r | |
97 | \r | |
363bb1b5 | 98 | mInternalRT = gRT;\r |
ebcc8fb7 | 99 | //\r |
100 | // Register SetVirtualAddressMap () notify function\r | |
101 | //\r | |
57a31578 | 102 | Status = gBS->CreateEventEx (\r |
103 | EVT_NOTIFY_SIGNAL,\r | |
ebcc8fb7 | 104 | TPL_NOTIFY,\r |
105 | RuntimeLibVirtualNotifyEvent,\r | |
106 | NULL,\r | |
57a31578 | 107 | &gEfiEventVirtualAddressChangeGuid,\r |
ebcc8fb7 | 108 | &mEfiVirtualNotifyEvent\r |
109 | );\r | |
110 | \r | |
111 | ASSERT_EFI_ERROR (Status);\r | |
112 | \r | |
57a31578 | 113 | Status = gBS->CreateEventEx (\r |
114 | EVT_NOTIFY_SIGNAL,\r | |
21998b67 | 115 | TPL_NOTIFY,\r |
116 | RuntimeLibExitBootServicesEvent,\r | |
117 | NULL,\r | |
57a31578 | 118 | &gEfiEventExitBootServicesGuid,\r |
21998b67 | 119 | &mEfiExitBootServicesEvent\r |
120 | );\r | |
121 | \r | |
122 | ASSERT_EFI_ERROR (Status);\r | |
123 | \r | |
ebcc8fb7 | 124 | return Status;\r |
125 | }\r | |
126 | \r | |
127 | /**\r | |
60c93673 LG |
128 | If a runtime driver exits with an error, it must call this routine \r |
129 | to free the allocated resource before the exiting.\r | |
130 | It will ASSERT() if gBS is NULL.\r | |
131 | It will ASSERT() if that operation fails.\r | |
ebcc8fb7 | 132 | \r |
42eedea9 | 133 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r |
134 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
135 | \r | |
58380e9c | 136 | @retval EFI_SUCCESS The Runtime Driver Lib shutdown successfully.\r |
137 | @retval EFI_UNSUPPORTED Runtime Driver lib was not initialized.\r | |
ebcc8fb7 | 138 | **/\r |
139 | EFI_STATUS\r | |
140 | EFIAPI\r | |
141 | RuntimeDriverLibDeconstruct (\r | |
142 | IN EFI_HANDLE ImageHandle,\r | |
143 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
144 | )\r | |
145 | {\r | |
146 | EFI_STATUS Status;\r | |
147 | \r | |
148 | //\r | |
149 | // Close SetVirtualAddressMap () notify function\r | |
150 | //\r | |
151 | ASSERT (gBS != NULL);\r | |
152 | Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r | |
153 | ASSERT_EFI_ERROR (Status);\r | |
154 | \r | |
21998b67 | 155 | Status = gBS->CloseEvent (mEfiExitBootServicesEvent);\r |
156 | ASSERT_EFI_ERROR (Status);\r | |
157 | \r | |
ebcc8fb7 | 158 | return Status;\r |
159 | }\r | |
160 | \r | |
161 | /**\r | |
1d37ab9f | 162 | This function allows the caller to determine if UEFI ExitBootServices() has been called.\r |
163 | \r | |
164 | This function returns TRUE after all the EVT_SIGNAL_EXIT_BOOT_SERVICES functions have\r | |
165 | executed as a result of the OS calling ExitBootServices(). Prior to this time FALSE\r | |
166 | is returned. This function is used by runtime code to decide it is legal to access\r | |
167 | services that go away after ExitBootServices().\r | |
168 | \r | |
169 | @retval TRUE The system has finished executing the EVT_SIGNAL_EXIT_BOOT_SERVICES event.\r | |
170 | @retval FALSE The system has not finished executing the EVT_SIGNAL_EXIT_BOOT_SERVICES event.\r | |
ebcc8fb7 | 171 | \r |
ebcc8fb7 | 172 | **/\r |
173 | BOOLEAN\r | |
174 | EFIAPI\r | |
175 | EfiAtRuntime (\r | |
176 | VOID\r | |
177 | )\r | |
178 | {\r | |
179 | return mEfiAtRuntime;\r | |
180 | }\r | |
181 | \r | |
182 | /**\r | |
1d37ab9f | 183 | This function allows the caller to determine if UEFI SetVirtualAddressMap() has been called. \r |
184 | \r | |
185 | This function returns TRUE after all the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE functions have\r | |
186 | executed as a result of the OS calling SetVirtualAddressMap(). Prior to this time FALSE\r | |
187 | is returned. This function is used by runtime code to decide it is legal to access services\r | |
188 | that go away after SetVirtualAddressMap().\r | |
189 | \r | |
190 | @retval TRUE The system has finished executing the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r | |
191 | @retval FALSE The system has not finished executing the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r | |
ebcc8fb7 | 192 | \r |
ebcc8fb7 | 193 | **/\r |
194 | BOOLEAN\r | |
195 | EFIAPI\r | |
196 | EfiGoneVirtual (\r | |
197 | VOID\r | |
198 | )\r | |
199 | {\r | |
200 | return mEfiGoneVirtual;\r | |
201 | }\r | |
202 | \r | |
363bb1b5 | 203 | \r |
204 | /**\r | |
205 | This service is a wrapper for the UEFI Runtime Service ResetSystem().\r | |
206 | \r | |
207 | The ResetSystem()function resets the entire platform, including all processors and devices,and reboots the system.\r | |
208 | Calling this interface with ResetType of EfiResetCold causes a system-wide reset. This sets all circuitry within\r | |
209 | the system to its initial state. This type of reset is asynchronous to system operation and operates without regard\r | |
210 | to cycle boundaries. EfiResetCold is tantamount to a system power cycle.\r | |
211 | Calling this interface with ResetType of EfiResetWarm causes a system-wide initialization. The processors are set to\r | |
212 | their initial state, and pending cycles are not corrupted. If the system does not support this reset type, then an\r | |
213 | EfiResetCold must be performed.\r | |
214 | Calling this interface with ResetType of EfiResetShutdown causes the system to enter a power state equivalent to the\r | |
215 | ACPI G2/S5 or G3 states. If the system does not support this reset type, then when the system is rebooted, it should\r | |
216 | exhibit the EfiResetCold attributes.\r | |
217 | The platform may optionally log the parameters from any non-normal reset that occurs.\r | |
218 | The ResetSystem() function does not return.\r | |
219 | \r | |
220 | @param ResetType The type of reset to perform.\r | |
221 | @param ResetStatus The status code for the reset. If the system reset is part of a normal operation, the status code\r | |
222 | would be EFI_SUCCESS. If the system reset is due to some type of failure the most appropriate EFI\r | |
223 | Status code would be used.\r | |
224 | @param DataSizeThe size, in bytes, of ResetData.\r | |
225 | @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown the data buffer starts with a\r | |
226 | Null-terminated Unicode string, optionally followed by additional binary data. The string is a\r | |
227 | description that the caller may use to further indicate the reason for the system reset. ResetData\r | |
228 | is only valid if ResetStatus is something other then EFI_SUCCESS. This pointer must be a physical\r | |
229 | address. For a ResetType of EfiRestUpdate the data buffer also starts with a Null-terminated string\r | |
230 | that is followed by a physical VOID * to an EFI_CAPSULE_HEADER.\r | |
231 | \r | |
232 | **/\r | |
233 | VOID\r | |
234 | EFIAPI\r | |
235 | EfiResetSystem (\r | |
236 | IN EFI_RESET_TYPE ResetType,\r | |
237 | IN EFI_STATUS ResetStatus,\r | |
238 | IN UINTN DataSize,\r | |
239 | IN VOID *ResetData OPTIONAL\r | |
240 | )\r | |
241 | {\r | |
242 | mInternalRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r | |
243 | }\r | |
244 | \r | |
245 | \r | |
246 | /**\r | |
247 | This service is a wrapper for the UEFI Runtime Service GetTime().\r | |
248 | \r | |
249 | The GetTime() function returns a time that was valid sometime during the call to the function.\r | |
250 | While the returned EFI_TIME structure contains TimeZone and Daylight savings time information,\r | |
251 | the actual clock does not maintain these values. The current time zone and daylight saving time\r | |
252 | information returned by GetTime() are the values that were last set via SetTime().\r | |
253 | The GetTime() function should take approximately the same amount of time to read the time each\r | |
254 | time it is called. All reported device capabilities are to be rounded up.\r | |
255 | During runtime, if a PC-AT CMOS device is present in the platform the caller must synchronize\r | |
256 | access to the device before calling GetTime().\r | |
257 | \r | |
258 | @param Time A pointer to storage to receive a snapshot of the current time.\r | |
259 | @param Capabilities An optional pointer to a buffer to receive the real time clock device's\r | |
260 | capabilities.\r | |
261 | \r | |
262 | @retval EFI_SUCCESS The operation completed successfully.\r | |
263 | @retval EFI_INVALID_PARAMETER Time is NULL.\r | |
264 | @retval EFI_DEVICE_ERROR The time could not be retrieved due to a hardware error.\r | |
265 | \r | |
266 | **/\r | |
267 | EFI_STATUS\r | |
268 | EFIAPI\r | |
269 | EfiGetTime (\r | |
270 | OUT EFI_TIME *Time,\r | |
271 | OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL\r | |
272 | )\r | |
273 | {\r | |
274 | return mInternalRT->GetTime (Time, Capabilities);\r | |
275 | }\r | |
276 | \r | |
277 | \r | |
278 | /**\r | |
279 | This service is a wrapper for the UEFI Runtime Service SetTime().\r | |
280 | \r | |
281 | The SetTime() function sets the real time clock device to the supplied time, and records the\r | |
282 | current time zone and daylight savings time information. The SetTime() function is not allowed\r | |
283 | to loop based on the current time. For example, if the device does not support a hardware reset\r | |
284 | for the sub-resolution time, the code is not to implement the feature by waiting for the time to\r | |
285 | wrap.\r | |
286 | During runtime, if a PC-AT CMOS device is present in the platform the caller must synchronize\r | |
287 | access to the device before calling SetTime().\r | |
288 | \r | |
289 | @param Time A pointer to the current time. Type EFI_TIME is defined in the GetTime()\r | |
290 | function description. Full error checking is performed on the different\r | |
291 | fields of the EFI_TIME structure (refer to the EFI_TIME definition in the\r | |
292 | GetTime() function description for full details), and EFI_INVALID_PARAMETER\r | |
293 | is returned if any field is out of range.\r | |
294 | \r | |
295 | @retval EFI_SUCCESS The operation completed successfully.\r | |
296 | @retval EFI_INVALID_PARAMETER A time field is out of range.\r | |
297 | @retval EFI_DEVICE_ERROR The time could not be set due to a hardware error.\r | |
298 | \r | |
299 | **/\r | |
300 | EFI_STATUS\r | |
301 | EFIAPI\r | |
302 | EfiSetTime (\r | |
303 | IN EFI_TIME *Time\r | |
304 | )\r | |
305 | {\r | |
306 | return mInternalRT->SetTime (Time);\r | |
307 | }\r | |
308 | \r | |
309 | \r | |
310 | /**\r | |
311 | This service is a wrapper for the UEFI Runtime Service GetWakeupTime().\r | |
312 | \r | |
313 | The alarm clock time may be rounded from the set alarm clock time to be within the resolution\r | |
314 | of the alarm clock device. The resolution of the alarm clock device is defined to be one second.\r | |
315 | During runtime, if a PC-AT CMOS device is present in the platform the caller must synchronize\r | |
316 | access to the device before calling GetWakeupTime().\r | |
317 | \r | |
318 | @param Enabled Indicates if the alarm is currently enabled or disabled.\r | |
319 | @param Pending Indicates if the alarm signal is pending and requires acknowledgement.\r | |
320 | @param Time The current alarm setting. Type EFI_TIME is defined in the GetTime()\r | |
321 | function description.\r | |
322 | \r | |
58380e9c | 323 | @retval EFI_SUCCESS The alarm settings were returned.\r |
363bb1b5 | 324 | @retval EFI_INVALID_PARAMETER Enabled is NULL.\r |
325 | @retval EFI_INVALID_PARAMETER Pending is NULL.\r | |
326 | @retval EFI_INVALID_PARAMETER Time is NULL.\r | |
327 | @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.\r | |
328 | @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r | |
329 | \r | |
330 | **/\r | |
331 | EFI_STATUS\r | |
332 | EFIAPI\r | |
333 | EfiGetWakeupTime (\r | |
334 | OUT BOOLEAN *Enabled,\r | |
335 | OUT BOOLEAN *Pending,\r | |
336 | OUT EFI_TIME *Time\r | |
337 | )\r | |
338 | {\r | |
339 | return mInternalRT->GetWakeupTime (Enabled, Pending, Time);\r | |
340 | }\r | |
341 | \r | |
342 | \r | |
343 | \r | |
344 | /**\r | |
345 | This service is a wrapper for the UEFI Runtime Service SetWakeupTime()\r | |
346 | \r | |
347 | Setting a system wakeup alarm causes the system to wake up or power on at the set time.\r | |
348 | When the alarm fires, the alarm signal is latched until it is acknowledged by calling SetWakeupTime()\r | |
349 | to disable the alarm. If the alarm fires before the system is put into a sleeping or off state,\r | |
350 | since the alarm signal is latched the system will immediately wake up. If the alarm fires while\r | |
351 | the system is off and there is insufficient power to power on the system, the system is powered\r | |
352 | on when power is restored.\r | |
353 | \r | |
354 | @param Enable Enable or disable the wakeup alarm.\r | |
355 | @param Time If Enable is TRUE, the time to set the wakeup alarm for. Type EFI_TIME\r | |
356 | is defined in the GetTime() function description. If Enable is FALSE,\r | |
357 | then this parameter is optional, and may be NULL.\r | |
358 | \r | |
359 | @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled.\r | |
360 | If Enable is FALSE, then the wakeup alarm was disabled.\r | |
361 | @retval EFI_INVALID_PARAMETER A time field is out of range.\r | |
362 | @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.\r | |
363 | @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r | |
364 | \r | |
365 | **/\r | |
366 | EFI_STATUS\r | |
367 | EFIAPI\r | |
368 | EfiSetWakeupTime (\r | |
369 | IN BOOLEAN Enable,\r | |
370 | IN EFI_TIME *Time OPTIONAL\r | |
371 | )\r | |
372 | {\r | |
373 | return mInternalRT->SetWakeupTime (Enable, Time);\r | |
374 | }\r | |
375 | \r | |
376 | \r | |
377 | /**\r | |
378 | This service is a wrapper for the UEFI Runtime Service GetVariable().\r | |
379 | \r | |
380 | Each vendor may create and manage its own variables without the risk of name conflicts by\r | |
381 | using a unique VendorGuid. When a variable is set its Attributes are supplied to indicate\r | |
382 | how the data variable should be stored and maintained by the system. The attributes affect\r | |
383 | when the variable may be accessed and volatility of the data. Any attempts to access a variable\r | |
384 | that does not have the attribute set for runtime access will yield the EFI_NOT_FOUND error.\r | |
385 | If the Data buffer is too small to hold the contents of the variable, the error EFI_BUFFER_TOO_SMALL\r | |
386 | is returned and DataSize is set to the required buffer size to obtain the data.\r | |
387 | \r | |
388 | @param VariableName the name of the vendor's variable, it's a Null-Terminated Unicode String\r | |
389 | @param VendorGuid Unify identifier for vendor.\r | |
390 | @param Attributes Point to memory location to return the attributes of variable. If the point\r | |
391 | is NULL, the parameter would be ignored.\r | |
392 | @param DataSize As input, point to the maximum size of return Data-Buffer.\r | |
393 | As output, point to the actual size of the returned Data-Buffer.\r | |
394 | @param Data Point to return Data-Buffer.\r | |
395 | \r | |
396 | @retval EFI_SUCCESS The function completed successfully.\r | |
397 | @retval EFI_NOT_FOUND The variable was not found.\r | |
398 | @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has\r | |
399 | been updated with the size needed to complete the request.\r | |
400 | @retval EFI_INVALID_PARAMETER VariableName is NULL.\r | |
401 | @retval EFI_INVALID_PARAMETER VendorGuid is NULL.\r | |
402 | @retval EFI_INVALID_PARAMETER DataSize is NULL.\r | |
403 | @retval EFI_INVALID_PARAMETER The DataSize is not too small and Data is NULL.\r | |
404 | @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.\r | |
405 | @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.\r | |
406 | **/\r | |
407 | EFI_STATUS\r | |
408 | EFIAPI\r | |
409 | EfiGetVariable (\r | |
410 | IN CHAR16 *VariableName,\r | |
411 | IN EFI_GUID *VendorGuid,\r | |
412 | OUT UINT32 *Attributes OPTIONAL,\r | |
413 | IN OUT UINTN *DataSize,\r | |
414 | OUT VOID *Data\r | |
415 | )\r | |
416 | {\r | |
417 | return mInternalRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r | |
418 | }\r | |
419 | \r | |
420 | \r | |
421 | /**\r | |
422 | This service is a wrapper for the UEFI Runtime Service GetNextVariableName().\r | |
423 | \r | |
424 | GetNextVariableName() is called multiple times to retrieve the VariableName and VendorGuid of\r | |
425 | all variables currently available in the system. On each call to GetNextVariableName() the\r | |
426 | previous results are passed into the interface, and on output the interface returns the next\r | |
427 | variable name data. When the entire variable list has been returned, the error EFI_NOT_FOUND\r | |
428 | is returned.\r | |
429 | \r | |
430 | @param VariableNameSize As input, point to maximum size of variable name.\r | |
431 | As output, point to actual size of variable name.\r | |
432 | @param VariableName As input, supplies the last VariableName that was returned by\r | |
433 | GetNextVariableName().\r | |
434 | As output, returns the name of variable. The name\r | |
435 | string is Null-Terminated Unicode string.\r | |
436 | @param VendorGuid As input, supplies the last VendorGuid that was returned by\r | |
437 | GetNextVriableName().\r | |
438 | As output, returns the VendorGuid of the current variable.\r | |
439 | \r | |
440 | @retval EFI_SUCCESS The function completed successfully.\r | |
441 | @retval EFI_NOT_FOUND The next variable was not found.\r | |
442 | @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.\r | |
443 | VariableNameSize has been updated with the size needed\r | |
444 | to complete the request.\r | |
445 | @retval EFI_INVALID_PARAMETER VariableNameSize is NULL.\r | |
446 | @retval EFI_INVALID_PARAMETER VariableName is NULL.\r | |
447 | @retval EFI_INVALID_PARAMETER VendorGuid is NULL.\r | |
448 | @retval EFI_DEVICE_ERROR The variable name could not be retrieved due to a hardware error.\r | |
449 | \r | |
450 | **/\r | |
451 | EFI_STATUS\r | |
452 | EFIAPI\r | |
453 | EfiGetNextVariableName (\r | |
454 | IN OUT UINTN *VariableNameSize,\r | |
455 | IN OUT CHAR16 *VariableName,\r | |
456 | IN OUT EFI_GUID *VendorGuid\r | |
457 | )\r | |
458 | {\r | |
459 | return mInternalRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);\r | |
460 | }\r | |
461 | \r | |
462 | \r | |
463 | /**\r | |
464 | This service is a wrapper for the UEFI Runtime Service GetNextVariableName()\r | |
465 | \r | |
466 | Variables are stored by the firmware and may maintain their values across power cycles. Each vendor\r | |
467 | may create and manage its own variables without the risk of name conflicts by using a unique VendorGuid.\r | |
468 | \r | |
58380e9c | 469 | @param VariableName The name of the vendor's variable; it's a Null-Terminated \r |
470 | Unicode String\r | |
363bb1b5 | 471 | @param VendorGuid Unify identifier for vendor.\r |
58380e9c | 472 | @param Attributes Points to a memory location to return the attributes of variable. If the point\r |
363bb1b5 | 473 | is NULL, the parameter would be ignored.\r |
474 | @param DataSize The size in bytes of Data-Buffer.\r | |
58380e9c | 475 | @param Data Points to the content of the variable.\r |
363bb1b5 | 476 | \r |
477 | @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as\r | |
478 | defined by the Attributes.\r | |
479 | @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied, or the\r | |
480 | DataSize exceeds the maximum allowed.\r | |
481 | @retval EFI_INVALID_PARAMETER VariableName is an empty Unicode string.\r | |
482 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r | |
483 | @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure.\r | |
484 | @retval EFI_WRITE_PROTECTED The variable in question is read-only.\r | |
485 | @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.\r | |
486 | @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\r | |
487 | set but the AuthInfo does NOT pass the validation check carried\r | |
488 | out by the firmware.\r | |
489 | @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.\r | |
490 | \r | |
491 | **/\r | |
492 | EFI_STATUS\r | |
493 | EFIAPI\r | |
494 | EfiSetVariable (\r | |
495 | IN CHAR16 *VariableName,\r | |
496 | IN EFI_GUID *VendorGuid,\r | |
497 | IN UINT32 Attributes,\r | |
498 | IN UINTN DataSize,\r | |
499 | IN VOID *Data\r | |
500 | )\r | |
501 | {\r | |
502 | return mInternalRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r | |
503 | }\r | |
504 | \r | |
505 | \r | |
506 | /**\r | |
507 | This service is a wrapper for the UEFI Runtime Service GetNextHighMonotonicCount().\r | |
508 | \r | |
509 | The platform's monotonic counter is comprised of two 32-bit quantities: the high 32 bits and\r | |
510 | the low 32 bits. During boot service time the low 32-bit value is volatile: it is reset to zero\r | |
511 | on every system reset and is increased by 1 on every call to GetNextMonotonicCount(). The high\r | |
512 | 32-bit value is nonvolatile and is increased by 1 whenever the system resets or whenever the low\r | |
513 | 32-bit count (returned by GetNextMonoticCount()) overflows.\r | |
514 | \r | |
2fc59a00 | 515 | @param HighCount The pointer to returned value.\r |
363bb1b5 | 516 | \r |
517 | @retval EFI_SUCCESS The next high monotonic count was returned.\r | |
518 | @retval EFI_DEVICE_ERROR The device is not functioning properly.\r | |
519 | @retval EFI_INVALID_PARAMETER HighCount is NULL.\r | |
520 | \r | |
521 | **/\r | |
522 | EFI_STATUS\r | |
523 | EFIAPI\r | |
524 | EfiGetNextHighMonotonicCount (\r | |
525 | OUT UINT32 *HighCount\r | |
526 | )\r | |
527 | {\r | |
528 | return mInternalRT->GetNextHighMonotonicCount (HighCount);\r | |
529 | }\r | |
530 | \r | |
531 | \r | |
532 | /**\r | |
533 | This service is a wrapper for the UEFI Runtime Service ConvertPointer(). \r | |
534 | \r | |
535 | The ConvertPointer() function is used by an EFI component during the SetVirtualAddressMap() operation.\r | |
536 | ConvertPointer()must be called using physical address pointers during the execution of SetVirtualAddressMap().\r | |
537 | \r | |
538 | @param DebugDisposition Supplies type information for the pointer being converted.\r | |
539 | @param Address The pointer to a pointer that is to be fixed to be the\r | |
540 | value needed for the new virtual address mapping being\r | |
541 | applied.\r | |
542 | \r | |
543 | @retval EFI_SUCCESS The pointer pointed to by Address was modified.\r | |
544 | @retval EFI_NOT_FOUND The pointer pointed to by Address was not found to be part of\r | |
545 | the current memory map. This is normally fatal.\r | |
546 | @retval EFI_INVALID_PARAMETER Address is NULL.\r | |
547 | @retval EFI_INVALID_PARAMETER *Address is NULL and DebugDispositio\r | |
548 | \r | |
549 | **/\r | |
550 | EFI_STATUS\r | |
551 | EFIAPI\r | |
552 | EfiConvertPointer (\r | |
553 | IN UINTN DebugDisposition,\r | |
554 | IN OUT VOID **Address\r | |
555 | )\r | |
556 | {\r | |
557 | return gRT->ConvertPointer (DebugDisposition, Address);\r | |
558 | }\r | |
559 | \r | |
560 | \r | |
561 | /**\r | |
562 | Determines the new virtual address that is to be used on subsequent memory accesses.\r | |
563 | \r | |
564 | For IA32, x64, and EBC, this service is a wrapper for the UEFI Runtime Service\r | |
565 | ConvertPointer(). See the UEFI Specification for details. \r | |
566 | For IPF, this function interprets Address as a pointer to an EFI_PLABEL structure\r | |
567 | and both the EntryPoint and GP fields of an EFI_PLABEL are converted from physical\r | |
568 | to virtiual addressing. Since IPF allows the GP to point to an address outside\r | |
569 | a PE/COFF image, the physical to virtual offset for the EntryPoint field is used\r | |
570 | to adjust the GP field. The UEFI Runtime Service ConvertPointer() is used to convert\r | |
571 | EntryPoint and the status code for this conversion is always returned. If the convertion\r | |
572 | of EntryPoint fails, then neither EntryPoint nor GP are modified. See the UEFI\r | |
573 | Specification for details on the UEFI Runtime Service ConvertPointer().\r | |
574 | \r | |
575 | @param DebugDisposition Supplies type information for the pointer being converted.\r | |
576 | @param Address The pointer to a pointer that is to be fixed to be the\r | |
577 | value needed for the new virtual address mapping being\r | |
578 | applied.\r | |
579 | \r | |
580 | @return EFI_STATUS value from EfiConvertPointer().\r | |
581 | \r | |
582 | **/\r | |
583 | EFI_STATUS\r | |
584 | EFIAPI\r | |
585 | EfiConvertFunctionPointer (\r | |
586 | IN UINTN DebugDisposition,\r | |
587 | IN OUT VOID **Address\r | |
588 | )\r | |
589 | {\r | |
590 | return EfiConvertPointer (DebugDisposition, Address);\r | |
591 | }\r | |
592 | \r | |
593 | \r | |
594 | /**\r | |
595 | Convert the standard Lib double linked list to a virtual mapping.\r | |
596 | \r | |
597 | This service uses EfiConvertPointer() to walk a double linked list and convert all the link\r | |
598 | pointers to their virtual mappings. This function is only guaranteed to work during the\r | |
599 | EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event and calling it at other times has undefined results.\r | |
600 | \r | |
601 | @param DebugDisposition Supplies type information for the pointer being converted.\r | |
602 | @param ListHead Head of linked list to convert.\r | |
603 | \r | |
604 | @retval EFI_SUCCESS Success to execute the function.\r | |
605 | @retval !EFI_SUCCESS Failed to e3xecute the function.\r | |
606 | \r | |
607 | **/\r | |
608 | EFI_STATUS\r | |
609 | EFIAPI\r | |
610 | EfiConvertList (\r | |
611 | IN UINTN DebugDisposition,\r | |
612 | IN OUT LIST_ENTRY *ListHead\r | |
613 | )\r | |
614 | {\r | |
615 | LIST_ENTRY *Link;\r | |
616 | LIST_ENTRY *NextLink;\r | |
617 | \r | |
618 | //\r | |
619 | // For NULL List, return EFI_SUCCESS\r | |
620 | //\r | |
621 | if (ListHead == NULL) {\r | |
622 | return EFI_SUCCESS;\r | |
623 | }\r | |
624 | \r | |
625 | //\r | |
626 | // Convert all the ForwardLink & BackLink pointers in the list\r | |
627 | //\r | |
628 | Link = ListHead;\r | |
629 | do {\r | |
630 | NextLink = Link->ForwardLink;\r | |
631 | \r | |
632 | EfiConvertPointer (\r | |
633 | Link->ForwardLink == ListHead ? DebugDisposition : 0,\r | |
634 | (VOID **) &Link->ForwardLink\r | |
635 | );\r | |
636 | \r | |
637 | EfiConvertPointer (\r | |
638 | Link->BackLink == ListHead ? DebugDisposition : 0,\r | |
639 | (VOID **) &Link->BackLink\r | |
640 | );\r | |
641 | \r | |
642 | Link = NextLink;\r | |
643 | } while (Link != ListHead);\r | |
644 | return EFI_SUCCESS;\r | |
645 | }\r | |
646 | \r | |
647 | \r | |
648 | /**\r | |
649 | This service is a wrapper for the UEFI Runtime Service SetVirtualAddressMap().\r | |
650 | \r | |
651 | The SetVirtualAddressMap() function is used by the OS loader. The function can only be called\r | |
652 | at runtime, and is called by the owner of the system's memory map. I.e., the component which\r | |
653 | called ExitBootServices(). All events of type EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE must be signaled\r | |
654 | before SetVirtualAddressMap() returns.\r | |
655 | \r | |
656 | @param MemoryMapSize The size in bytes of VirtualMap.\r | |
657 | @param DescriptorSize The size in bytes of an entry in the VirtualMap.\r | |
658 | @param DescriptorVersion The version of the structure entries in VirtualMap.\r | |
659 | @param VirtualMap An array of memory descriptors which contain new virtual\r | |
660 | address mapping information for all runtime ranges. Type\r | |
661 | EFI_MEMORY_DESCRIPTOR is defined in the\r | |
662 | GetMemoryMap() function description.\r | |
663 | \r | |
664 | @retval EFI_SUCCESS The virtual address map has been applied.\r | |
665 | @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in\r | |
666 | virtual address mapped mode.\r | |
667 | @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is\r | |
668 | invalid.\r | |
669 | @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory\r | |
670 | map that requires a mapping.\r | |
671 | @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found\r | |
672 | in the memory map.\r | |
673 | **/\r | |
674 | EFI_STATUS\r | |
675 | EFIAPI\r | |
676 | EfiSetVirtualAddressMap (\r | |
677 | IN UINTN MemoryMapSize,\r | |
678 | IN UINTN DescriptorSize,\r | |
679 | IN UINT32 DescriptorVersion,\r | |
680 | IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap\r | |
681 | )\r | |
682 | {\r | |
683 | return mInternalRT->SetVirtualAddressMap (\r | |
684 | MemoryMapSize,\r | |
685 | DescriptorSize,\r | |
686 | DescriptorVersion,\r | |
687 | (EFI_MEMORY_DESCRIPTOR *) VirtualMap\r | |
688 | );\r | |
689 | }\r | |
690 | \r | |
691 | \r | |
692 | /**\r | |
693 | This service is a wrapper for the UEFI Runtime Service UpdateCapsule().\r | |
694 | \r | |
695 | Passes capsules to the firmware with both virtual and physical mapping. Depending on the intended\r | |
696 | consumption, the firmware may process the capsule immediately. If the payload should persist across a\r | |
697 | system reset, the reset value returned from EFI_QueryCapsuleCapabilities must be passed into ResetSystem()\r | |
698 | and will cause the capsule to be processed by the firmware as part of the reset process.\r | |
699 | \r | |
700 | @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules\r | |
701 | being passed into update capsule. Each capsules is assumed to\r | |
702 | stored in contiguous virtual memory. The capsules in the\r | |
703 | CapsuleHeaderArray must be the same capsules as the\r | |
704 | ScatterGatherList. The CapsuleHeaderArray must\r | |
705 | have the capsules in the same order as the ScatterGatherList.\r | |
2fc59a00 | 706 | @param CapsuleCount The number of pointers to EFI_CAPSULE_HEADER in\r |
363bb1b5 | 707 | CaspuleHeaderArray.\r |
708 | @param ScatterGatherList Physical pointer to a set of\r | |
709 | EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the\r | |
710 | location in physical memory of a set of capsules. See Related\r | |
711 | Definitions for an explanation of how more than one capsule is\r | |
712 | passed via this interface. The capsules in the\r | |
713 | ScatterGatherList must be in the same order as the\r | |
714 | CapsuleHeaderArray. This parameter is only referenced if\r | |
715 | the capsules are defined to persist across system reset.\r | |
716 | \r | |
717 | @retval EFI_SUCCESS Valid capsule was passed. If CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set,\r | |
718 | the capsule has been successfully processed by the firmware.\r | |
719 | @retval EFI_INVALID_PARAMETER CapsuleSize or HeaderSize is NULL.\r | |
720 | @retval EFI_INVALID_PARAMETER CapsuleCount is 0\r | |
721 | @retval EFI_DEVICE_ERROR The capsule update was started, but failed due to a device error.\r | |
722 | @retval EFI_UNSUPPORTED The capsule type is not supported on this platform.\r | |
723 | @retval EFI_OUT_OF_RESOURCES There were insufficient resources to process the capsule.\r | |
724 | \r | |
725 | **/\r | |
726 | EFI_STATUS\r | |
727 | EFIAPI\r | |
728 | EfiUpdateCapsule (\r | |
729 | IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,\r | |
730 | IN UINTN CapsuleCount,\r | |
731 | IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL\r | |
732 | )\r | |
733 | {\r | |
734 | return mInternalRT->UpdateCapsule (\r | |
735 | CapsuleHeaderArray,\r | |
736 | CapsuleCount,\r | |
737 | ScatterGatherList\r | |
738 | );\r | |
739 | }\r | |
740 | \r | |
741 | \r | |
742 | /**\r | |
743 | This service is a wrapper for the UEFI Runtime Service QueryCapsuleCapabilities().\r | |
744 | \r | |
745 | The QueryCapsuleCapabilities() function allows a caller to test to see if a capsule or\r | |
746 | capsules can be updated via UpdateCapsule(). The Flags values in the capsule header and\r | |
747 | size of the entire capsule is checked.\r | |
748 | If the caller needs to query for generic capsule capability a fake EFI_CAPSULE_HEADER can be\r | |
749 | constructed where CapsuleImageSize is equal to HeaderSize that is equal to sizeof\r | |
750 | (EFI_CAPSULE_HEADER). To determine reset requirements,\r | |
751 | CAPSULE_FLAGS_PERSIST_ACROSS_RESET should be set in the Flags field of the\r | |
752 | EFI_CAPSULE_HEADER.\r | |
753 | The firmware must support any capsule that has the\r | |
754 | CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set in EFI_CAPSULE_HEADER. The\r | |
755 | firmware sets the policy for what capsules are supported that do not have the\r | |
756 | CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set.\r | |
757 | \r | |
758 | @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules\r | |
759 | being passed into update capsule. The capsules are assumed to\r | |
760 | stored in contiguous virtual memory.\r | |
2fc59a00 | 761 | @param CapsuleCount The number of pointers to EFI_CAPSULE_HEADER in\r |
363bb1b5 | 762 | CaspuleHeaderArray.\r |
763 | @param MaximumCapsuleSize On output the maximum size that UpdateCapsule() can\r | |
764 | support as an argument to UpdateCapsule() via\r | |
765 | CapsuleHeaderArray and ScatterGatherList.\r | |
766 | Undefined on input.\r | |
767 | @param ResetType Returns the type of reset required for the capsule update.\r | |
768 | \r | |
58380e9c | 769 | @retval EFI_SUCCESS A valid answer was returned.\r |
363bb1b5 | 770 | @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL.\r |
771 | @retval EFI_UNSUPPORTED The capsule type is not supported on this platform, and\r | |
772 | MaximumCapsuleSize and ResetType are undefined.\r | |
773 | @retval EFI_OUT_OF_RESOURCES There were insufficient resources to process the query request.\r | |
774 | \r | |
775 | **/\r | |
776 | EFI_STATUS\r | |
777 | EFIAPI\r | |
778 | EfiQueryCapsuleCapabilities (\r | |
779 | IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,\r | |
780 | IN UINTN CapsuleCount,\r | |
781 | OUT UINT64 *MaximumCapsuleSize,\r | |
782 | OUT EFI_RESET_TYPE *ResetType\r | |
783 | )\r | |
784 | {\r | |
785 | return mInternalRT->QueryCapsuleCapabilities (\r | |
786 | CapsuleHeaderArray,\r | |
787 | CapsuleCount,\r | |
788 | MaximumCapsuleSize,\r | |
789 | ResetType\r | |
790 | );\r | |
791 | }\r | |
792 | \r | |
793 | \r | |
794 | /**\r | |
795 | This service is a wrapper for the UEFI Runtime Service QueryVariableInfo().\r | |
796 | \r | |
797 | The QueryVariableInfo() function allows a caller to obtain the information about the\r | |
798 | maximum size of the storage space available for the EFI variables, the remaining size of the storage\r | |
799 | space available for the EFI variables and the maximum size of each individual EFI variable,\r | |
800 | associated with the attributes specified.\r | |
801 | The returned MaximumVariableStorageSize, RemainingVariableStorageSize,\r | |
802 | MaximumVariableSize information may change immediately after the call based on other\r | |
803 | runtime activities including asynchronous error events. Also, these values associated with different\r | |
804 | attributes are not additive in nature.\r | |
805 | \r | |
806 | @param Attributes Attributes bitmask to specify the type of variables on\r | |
807 | which to return information. Refer to the\r | |
808 | GetVariable() function description.\r | |
809 | @param MaximumVariableStorageSize\r | |
810 | On output the maximum size of the storage space\r | |
811 | available for the EFI variables associated with the\r | |
812 | attributes specified.\r | |
813 | @param RemainingVariableStorageSize\r | |
814 | Returns the remaining size of the storage space\r | |
815 | available for the EFI variables associated with the\r | |
816 | attributes specified..\r | |
817 | @param MaximumVariableSize Returns the maximum size of the individual EFI\r | |
818 | variables associated with the attributes specified.\r | |
819 | \r | |
58380e9c | 820 | @retval EFI_SUCCESS A valid answer was returned.\r |
363bb1b5 | 821 | @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.\r |
822 | @retval EFI_UNSUPPORTED EFI_UNSUPPORTED The attribute is not supported on this platform, and the\r | |
823 | MaximumVariableStorageSize,\r | |
824 | RemainingVariableStorageSize, MaximumVariableSize\r | |
825 | are undefined.\r | |
826 | \r | |
827 | **/\r | |
828 | EFI_STATUS\r | |
829 | EFIAPI\r | |
830 | EfiQueryVariableInfo (\r | |
831 | IN UINT32 Attributes,\r | |
832 | OUT UINT64 *MaximumVariableStorageSize,\r | |
833 | OUT UINT64 *RemainingVariableStorageSize,\r | |
834 | OUT UINT64 *MaximumVariableSize\r | |
835 | )\r | |
836 | {\r | |
837 | return mInternalRT->QueryVariableInfo (\r | |
838 | Attributes,\r | |
839 | MaximumVariableStorageSize,\r | |
840 | RemainingVariableStorageSize,\r | |
841 | MaximumVariableSize\r | |
842 | );\r | |
843 | }\r |