]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiRuntimeLib/RuntimeService.c
Fixed comments to follow coding standard.
[mirror_edk2.git] / MdePkg / Library / UefiRuntimeLib / RuntimeService.c
CommitLineData
bf231ea6
A
1/** @file\r
2 UEFI Runtime Library implementation for non IPF processor types.\r
ebcc8fb7 3\r
bf231ea6
A
4 This library hides the global variable for the EFI Runtime Services so the\r
5 caller does not need to deal with the possiblitly 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
ebcc8fb7 8\r
bf231ea6
A
9 Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r
10 All rights reserved. This program and the accompanying materials \r
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
13 http://opensource.org/licenses/bsd-license.php \r
ebcc8fb7 14\r
bf231ea6
A
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
ebcc8fb7 19\r
20#include <PiDxe.h>\r
ebcc8fb7 21\r
22#include <RuntimeLibInternal.h>\r
23\r
bf231ea6
A
24\r
25/**\r
26 Resets the entire platform.\r
27\r
28 @param ResetType The type of reset to perform.\r
29 @param ResetStatus The status code for reset.\r
30 @param DataSize The size in bytes of reset data.\r
31 @param ResetData Pointer to data buffer that includes\r
32 Null-Terminated Unicode string.\r
33\r
34**/\r
ebcc8fb7 35VOID\r
36EFIAPI\r
37EfiResetSystem (\r
38 IN EFI_RESET_TYPE ResetType,\r
39 IN EFI_STATUS ResetStatus,\r
40 IN UINTN DataSize,\r
41 IN CHAR16 *ResetData\r
42 )\r
bf231ea6
A
43{\r
44 mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r
45}\r
ebcc8fb7 46\r
ebcc8fb7 47\r
bf231ea6
A
48/**\r
49 Return current time and date information, and time-keeping\r
50 capabilities of hardware platform.\r
ebcc8fb7 51\r
bf231ea6
A
52 @param Time A pointer to storage to receive a snapshot of the current time.\r
53 @param Capabilities An optional pointer to a buffer to receive the real time clock device's\r
54 capabilities.\r
ebcc8fb7 55\r
bf231ea6
A
56 @retval EFI_SUCCESS Success to execute the function.\r
57 @retval !EFI_SUCCESS Failed to e3xecute the function.\r
ebcc8fb7 58\r
bf231ea6 59**/\r
ebcc8fb7 60EFI_STATUS\r
61EFIAPI\r
62EfiGetTime (\r
63 OUT EFI_TIME *Time,\r
64 OUT EFI_TIME_CAPABILITIES *Capabilities\r
65 )\r
bf231ea6
A
66{\r
67 return mRT->GetTime (Time, Capabilities);\r
68}\r
ebcc8fb7 69\r
ebcc8fb7 70\r
bf231ea6
A
71/**\r
72 Set current time and date information.\r
ebcc8fb7 73\r
bf231ea6 74 @param Time A pointer to cache of time setting.\r
ebcc8fb7 75\r
bf231ea6
A
76 @retval EFI_SUCCESS Success to execute the function.\r
77 @retval !EFI_SUCCESS Failed to execute the function.\r
ebcc8fb7 78\r
bf231ea6 79**/\r
ebcc8fb7 80EFI_STATUS\r
81EFIAPI\r
82EfiSetTime (\r
83 IN EFI_TIME *Time\r
84 )\r
bf231ea6
A
85{\r
86 return mRT->SetTime (Time);\r
87}\r
ebcc8fb7 88\r
ebcc8fb7 89\r
bf231ea6
A
90/**\r
91 Return current wakeup alarm clock setting.\r
ebcc8fb7 92\r
bf231ea6
A
93 @param Enabled Indicate if the alarm clock is enabled or disabled.\r
94 @param Pending Indicate if the alarm signal is pending and requires acknowledgement.\r
95 @param Time Current alarm clock setting.\r
ebcc8fb7 96\r
bf231ea6
A
97 @retval EFI_SUCCESS Success to execute the function.\r
98 @retval !EFI_SUCCESS Failed to e3xecute the function.\r
ebcc8fb7 99\r
bf231ea6 100**/\r
ebcc8fb7 101EFI_STATUS\r
102EFIAPI\r
103EfiGetWakeupTime (\r
104 OUT BOOLEAN *Enabled,\r
105 OUT BOOLEAN *Pending,\r
106 OUT EFI_TIME *Time\r
107 )\r
bf231ea6
A
108{\r
109 return mRT->GetWakeupTime (Enabled, Pending, Time);\r
110}\r
ebcc8fb7 111\r
ebcc8fb7 112\r
ebcc8fb7 113\r
bf231ea6
A
114/**\r
115 Set current wakeup alarm clock.\r
ebcc8fb7 116\r
bf231ea6
A
117 @param Enable Enable or disable current alarm clock..\r
118 @param Time Point to alarm clock setting.\r
ebcc8fb7 119\r
bf231ea6
A
120 @retval EFI_SUCCESS Success to execute the function.\r
121 @retval !EFI_SUCCESS Failed to e3xecute the function.\r
ebcc8fb7 122\r
bf231ea6 123**/\r
ebcc8fb7 124EFI_STATUS\r
125EFIAPI\r
126EfiSetWakeupTime (\r
127 IN BOOLEAN Enable,\r
128 IN EFI_TIME *Time\r
129 )\r
ebcc8fb7 130{\r
131 return mRT->SetWakeupTime (Enable, Time);\r
132}\r
133\r
134\r
bf231ea6
A
135/**\r
136 Return value of variable.\r
137\r
138 @param VariableName the name of the vendor's variable, it's a\r
139 Null-Terminated Unicode String\r
140 @param VendorGuid Unify identifier for vendor.\r
141 @param Attributes Point to memory location to return the attributes of variable. If the point\r
142 is NULL, the parameter would be ignored.\r
143 @param DataSize As input, point to the maxinum size of return Data-Buffer.\r
144 As output, point to the actual size of the returned Data-Buffer.\r
145 @param Data Point to return Data-Buffer.\r
ebcc8fb7 146\r
bf231ea6
A
147 @retval EFI_SUCCESS Success to execute the function.\r
148 @retval !EFI_SUCCESS Failed to e3xecute the function.\r
ebcc8fb7 149\r
bf231ea6 150**/\r
ebcc8fb7 151EFI_STATUS\r
152EFIAPI\r
153EfiGetVariable (\r
154 IN CHAR16 *VariableName,\r
155 IN EFI_GUID * VendorGuid,\r
156 OUT UINT32 *Attributes OPTIONAL,\r
157 IN OUT UINTN *DataSize,\r
158 OUT VOID *Data\r
159 )\r
bf231ea6
A
160{\r
161 return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
162}\r
ebcc8fb7 163\r
ebcc8fb7 164\r
bf231ea6
A
165/**\r
166 Enumerates variable's name.\r
ebcc8fb7 167\r
bf231ea6
A
168 @param VariableNameSize As input, point to maxinum size of variable name.\r
169 As output, point to actual size of varaible name.\r
170 @param VariableName As input, supplies the last VariableName that was returned by\r
171 GetNextVariableName().\r
172 As output, returns the name of variable. The name\r
173 string is Null-Terminated Unicode string.\r
174 @param VendorGuid As input, supplies the last VendorGuid that was returned by\r
175 GetNextVriableName().\r
176 As output, returns the VendorGuid of the current variable.\r
ebcc8fb7 177\r
bf231ea6
A
178 @retval EFI_SUCCESS Success to execute the function.\r
179 @retval !EFI_SUCCESS Failed to e3xecute the function.\r
ebcc8fb7 180\r
bf231ea6 181**/\r
ebcc8fb7 182EFI_STATUS\r
183EFIAPI\r
184EfiGetNextVariableName (\r
185 IN OUT UINTN *VariableNameSize,\r
186 IN OUT CHAR16 *VariableName,\r
187 IN OUT EFI_GUID *VendorGuid\r
188 )\r
bf231ea6
A
189{\r
190 return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);\r
191}\r
ebcc8fb7 192\r
ebcc8fb7 193\r
bf231ea6
A
194/**\r
195 Sets value of variable.\r
ebcc8fb7 196\r
bf231ea6
A
197 @param VariableName the name of the vendor's variable, it's a\r
198 Null-Terminated Unicode String\r
199 @param VendorGuid Unify identifier for vendor.\r
200 @param Attributes Point to memory location to return the attributes of variable. If the point\r
201 is NULL, the parameter would be ignored.\r
202 @param DataSize The size in bytes of Data-Buffer.\r
203 @param Data Point to the content of the variable.\r
ebcc8fb7 204\r
bf231ea6
A
205 @retval EFI_SUCCESS Success to execute the function.\r
206 @retval !EFI_SUCCESS Failed to e3xecute the function.\r
ebcc8fb7 207\r
bf231ea6 208**/\r
ebcc8fb7 209EFI_STATUS\r
210EFIAPI\r
211EfiSetVariable (\r
212 IN CHAR16 *VariableName,\r
213 IN EFI_GUID *VendorGuid,\r
214 IN UINT32 Attributes,\r
215 IN UINTN DataSize,\r
216 IN VOID *Data\r
217 )\r
bf231ea6
A
218{\r
219 return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
220}\r
ebcc8fb7 221\r
ebcc8fb7 222\r
bf231ea6
A
223/**\r
224 Returns the next high 32 bits of platform's monotonic counter.\r
ebcc8fb7 225\r
bf231ea6 226 @param HighCount Pointer to returned value.\r
ebcc8fb7 227\r
bf231ea6
A
228 @retval EFI_SUCCESS Success to execute the function.\r
229 @retval !EFI_SUCCESS Failed to e3xecute the function.\r
ebcc8fb7 230\r
bf231ea6 231**/\r
ebcc8fb7 232EFI_STATUS\r
233EFIAPI\r
234EfiGetNextHighMonotonicCount (\r
235 OUT UINT32 *HighCount\r
236 )\r
bf231ea6
A
237{\r
238 return mRT->GetNextHighMonotonicCount (HighCount);\r
239}\r
ebcc8fb7 240\r
ebcc8fb7 241\r
bf231ea6
A
242/**\r
243 Determines the new virtual address that is to be used on subsequent memory accesses.\r
ebcc8fb7 244\r
bf231ea6
A
245 @param DebugDisposition Supplies type information for the pointer being converted.\r
246 @param Address The pointer to a pointer that is to be fixed to be the\r
247 value needed for the new virtual address mapping being\r
248 applied.\r
ebcc8fb7 249\r
bf231ea6
A
250 @retval EFI_SUCCESS Success to execute the function.\r
251 @retval !EFI_SUCCESS Failed to e3xecute the function.\r
ebcc8fb7 252\r
bf231ea6 253**/\r
ebcc8fb7 254EFI_STATUS\r
255EFIAPI\r
256EfiConvertPointer (\r
257 IN UINTN DebugDisposition,\r
258 IN OUT VOID **Address\r
259 )\r
bf231ea6
A
260{\r
261 return mRT->ConvertPointer (DebugDisposition, Address);\r
262}\r
ebcc8fb7 263\r
ebcc8fb7 264\r
bf231ea6
A
265/**\r
266 Conver the standard Lib double linked list to a virtual mapping.\r
ebcc8fb7 267\r
bf231ea6
A
268 @param DebugDisposition Supplies type information for the pointer being converted.\r
269 @param ListHead Head of linked list to convert.\r
ebcc8fb7 270\r
bf231ea6
A
271 @retval EFI_SUCCESS Success to execute the function.\r
272 @retval !EFI_SUCCESS Failed to e3xecute the function.\r
ebcc8fb7 273\r
bf231ea6 274**/\r
ebcc8fb7 275EFI_STATUS\r
276EFIAPI\r
277EfiConvertList (\r
278 IN UINTN DebugDisposition,\r
279 IN OUT LIST_ENTRY *ListHead\r
280 )\r
ebcc8fb7 281{\r
282 LIST_ENTRY *Link;\r
283 LIST_ENTRY *NextLink;\r
284\r
285 //\r
286 // Convert all the ForwardLink & BackLink pointers in the list\r
287 //\r
288 Link = ListHead;\r
289 do {\r
290 NextLink = Link->ForwardLink;\r
291\r
292 EfiConvertPointer (\r
293 Link->ForwardLink == ListHead ? DebugDisposition : 0,\r
294 (VOID **) &Link->ForwardLink\r
295 );\r
296\r
297 EfiConvertPointer (\r
298 Link->BackLink == ListHead ? DebugDisposition : 0,\r
299 (VOID **) &Link->BackLink\r
300 );\r
301\r
302 Link = NextLink;\r
303 } while (Link != ListHead);\r
304 return EFI_SUCCESS;\r
305}\r
306\r
307\r
308/**\r
309 Change the runtime addressing mode of EFI firmware from physical to virtual.\r
310\r
311 @param MemoryMapSize The size in bytes of VirtualMap.\r
312 @param DescriptorSize The size in bytes of an entry in the VirtualMap.\r
313 @param DescriptorVersion The version of the structure entries in VirtualMap.\r
314 @param VirtualMap An array of memory descriptors which contain new virtual\r
315 address mapping information for all runtime ranges. Type\r
316 EFI_MEMORY_DESCRIPTOR is defined in the\r
317 GetMemoryMap() function description.\r
318\r
319 @retval EFI_SUCCESS The virtual address map has been applied.\r
320 @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in\r
321 virtual address mapped mode.\r
322 @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is\r
323 invalid.\r
324 @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory\r
325 map that requires a mapping.\r
326 @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found\r
327 in the memory map.\r
328**/\r
329EFI_STATUS\r
330EFIAPI\r
331EfiSetVirtualAddressMap (\r
332 IN UINTN MemoryMapSize,\r
333 IN UINTN DescriptorSize,\r
334 IN UINT32 DescriptorVersion,\r
335 IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap\r
336 )\r
337{\r
338 return mRT->SetVirtualAddressMap (\r
339 MemoryMapSize,\r
340 DescriptorSize,\r
341 DescriptorVersion,\r
342 (EFI_MEMORY_DESCRIPTOR *) VirtualMap\r
343 );\r
344}\r
345\r
346\r
bf231ea6
A
347/**\r
348 Passes capsules to the firmware with both virtual and physical mapping.\r
349 Depending on the intended consumption, the firmware may\r
350 process the capsule immediately. If the payload should persist across a\r
351 system reset, the reset value returned from EFI_QueryCapsuleCapabilities must\r
352 be passed into ResetSystem() and will cause the capsule to be processed by\r
353 the firmware as part of the reset process.\r
354\r
355 @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules\r
356 being passed into update capsule. Each capsules is assumed to\r
357 stored in contiguous virtual memory. The capsules in the\r
358 CapsuleHeaderArray must be the same capsules as the\r
359 ScatterGatherList. The CapsuleHeaderArray must\r
360 have the capsules in the same order as the ScatterGatherList.\r
361 @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in\r
362 CaspuleHeaderArray.\r
363 @param ScatterGatherList Physical pointer to a set of\r
364 EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the\r
365 location in physical memory of a set of capsules. See Related\r
366 Definitions for an explanation of how more than one capsule is\r
367 passed via this interface. The capsules in the\r
368 ScatterGatherList must be in the same order as the\r
369 CapsuleHeaderArray. This parameter is only referenced if\r
370 the capsules are defined to persist across system reset.\r
371\r
372 @retval EFI_SUCCESS Valid capsule was passed. I Valid capsule was passed. If\r
373 CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the\r
374 capsule has been successfully processed by the firmware.\r
375 @retval EFI_INVALID_PARAMETER CapsuleSize is NULL or ResetTye is NULL.\r
376 @retval EFI_DEVICE_ERROR The capsule update was started, but failed due to a device error.\r
377\r
378**/\r
ebcc8fb7 379EFI_STATUS\r
380EFIAPI\r
381EfiUpdateCapsule (\r
b67d6130 382 IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,\r
383 IN UINTN CapsuleCount,\r
384 IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL\r
ebcc8fb7 385 )\r
386{\r
387 return mRT->UpdateCapsule (\r
388 CapsuleHeaderArray,\r
389 CapsuleCount,\r
390 ScatterGatherList\r
391 );\r
392}\r
393\r
bf231ea6
A
394\r
395/**\r
396 The QueryCapsuleCapabilities() function allows a caller to test to see if a capsule or\r
397 capsules can be updated via UpdateCapsule(). The Flags values in the capsule header and\r
398 size of the entire capsule is checked.\r
399 If the caller needs to query for generic capsule capability a fake EFI_CAPSULE_HEADER can be\r
400 constructed where CapsuleImageSize is equal to HeaderSize that is equal to sizeof\r
401 (EFI_CAPSULE_HEADER). To determine reset requirements,\r
402 CAPSULE_FLAGS_PERSIST_ACROSS_RESET should be set in the Flags field of the\r
403 EFI_CAPSULE_HEADER.\r
404 The firmware must support any capsule that has the\r
405 CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set in EFI_CAPSULE_HEADER. The\r
406 firmware sets the policy for what capsules are supported that do not have the\r
407 CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set.\r
408\r
409 @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules\r
410 being passed into update capsule. The capsules are assumed to\r
411 stored in contiguous virtual memory.\r
412 @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in\r
413 CaspuleHeaderArray.\r
414 @param MaxiumCapsuleSize On output the maximum size that UpdateCapsule() can\r
415 support as an argument to UpdateCapsule() via\r
416 CapsuleHeaderArray and ScatterGatherList.\r
417 Undefined on input.\r
418 @param ResetType Returns the type of reset required for the capsule update.\r
419\r
420 @retval EFI_SUCCESS Valid answer returned..\r
421 @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL.\r
422 @retval EFI_UNSUPPORTED The capsule type is not supported on this platform, and\r
423 MaximumCapsuleSize and ResetType are undefined.\r
424\r
425**/\r
ebcc8fb7 426EFI_STATUS\r
427EFIAPI\r
428EfiQueryCapsuleCapabilities (\r
b67d6130 429 IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,\r
430 IN UINTN CapsuleCount,\r
431 OUT UINT64 *MaximumCapsuleSize,\r
432 OUT EFI_RESET_TYPE *ResetType\r
ebcc8fb7 433 )\r
434{\r
435 return mRT->QueryCapsuleCapabilities (\r
436 CapsuleHeaderArray,\r
437 CapsuleCount,\r
438 MaximumCapsuleSize,\r
439 ResetType\r
440 );\r
441}\r
442\r
443\r
bf231ea6
A
444/**\r
445 The QueryVariableInfo() function allows a caller to obtain the information about the\r
446 maximum size of the storage space available for the EFI variables, the remaining size of the storage\r
447 space available for the EFI variables and the maximum size of each individual EFI variable,\r
448 associated with the attributes specified.\r
449 The returned MaximumVariableStorageSize, RemainingVariableStorageSize,\r
450 MaximumVariableSize information may change immediately after the call based on other\r
451 runtime activities including asynchronous error events. Also, these values associated with different\r
452 attributes are not additive in nature.\r
453\r
454 @param Attributes Attributes bitmask to specify the type of variables on\r
455 which to return information. Refer to the\r
456 GetVariable() function description.\r
457 @param MaximumVariableStorageSize\r
458 On output the maximum size of the storage space\r
459 available for the EFI variables associated with the\r
460 attributes specified.\r
461 @param RemainingVariableStorageSize\r
462 Returns the remaining size of the storage space\r
463 available for the EFI variables associated with the\r
464 attributes specified..\r
465 @param MaximumVariableSize Returns the maximum size of the individual EFI\r
466 variables associated with the attributes specified.\r
467\r
468 @retval EFI_SUCCESS Valid answer returned.\r
469 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.\r
470 @retval EFI_UNSUPPORTED EFI_UNSUPPORTED The attribute is not supported on this platform, and the\r
471 MaximumVariableStorageSize,\r
472 RemainingVariableStorageSize, MaximumVariableSize\r
473 are undefined.\r
474**/\r
ebcc8fb7 475EFI_STATUS\r
476EFIAPI\r
477EfiQueryVariableInfo (\r
b67d6130 478 IN UINT32 Attributes,\r
479 OUT UINT64 *MaximumVariableStorageSize,\r
480 OUT UINT64 *RemainingVariableStorageSize,\r
481 OUT UINT64 *MaximumVariableSize\r
ebcc8fb7 482 )\r
483{\r
484 return mRT->QueryVariableInfo (\r
485 Attributes,\r
486 MaximumVariableStorageSize,\r
487 RemainingVariableStorageSize,\r
488 MaximumVariableSize\r
489 );\r
490}\r