2 UEFI Runtime Library implementation for non IPF processor types.
4 This library hides the global variable for the EFI Runtime Services so the
5 caller does not need to deal with the possiblitly of being called from an
6 OS virtual address space. All pointer values are different for a virtual
7 mapping than from the normal physical mapping at boot services time.
9 Copyright (c) 2006 - 2008, Intel Corporation.<BR>
10 All rights reserved. This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include "RuntimeLibInternal.h"
24 Resets the entire platform.
26 @param ResetType The type of reset to perform.
27 @param ResetStatus The status code for reset.
28 @param DataSize The size in bytes of reset data.
29 @param ResetData Pointer to data buffer that includes
30 Null-Terminated Unicode string.
36 IN EFI_RESET_TYPE ResetType
,
37 IN EFI_STATUS ResetStatus
,
42 mRT
->ResetSystem (ResetType
, ResetStatus
, DataSize
, ResetData
);
47 Return current time and date information, and time-keeping
48 capabilities of hardware platform.
50 @param Time A pointer to storage to receive a snapshot of the current time.
51 @param Capabilities An optional pointer to a buffer to receive the real time clock device's
54 @retval EFI_SUCCESS Success to execute the function.
55 @retval !EFI_SUCCESS Failed to execute the function.
62 OUT EFI_TIME_CAPABILITIES
*Capabilities
65 return mRT
->GetTime (Time
, Capabilities
);
70 Set current time and date information.
72 @param Time A pointer to cache of time setting.
74 @retval EFI_SUCCESS Success to execute the function.
75 @retval !EFI_SUCCESS Failed to execute the function.
84 return mRT
->SetTime (Time
);
89 Return current wakeup alarm clock setting.
91 @param Enabled Indicate if the alarm clock is enabled or disabled.
92 @param Pending Indicate if the alarm signal is pending and requires acknowledgement.
93 @param Time Current alarm clock setting.
95 @retval EFI_SUCCESS Success to execute the function.
96 @retval !EFI_SUCCESS Failed to execute the function.
102 OUT BOOLEAN
*Enabled
,
103 OUT BOOLEAN
*Pending
,
107 return mRT
->GetWakeupTime (Enabled
, Pending
, Time
);
113 Set current wakeup alarm clock.
115 @param Enable Enable or disable current alarm clock..
116 @param Time Point to alarm clock setting.
118 @retval EFI_SUCCESS Success to execute the function.
119 @retval !EFI_SUCCESS Failed to execute the function.
129 return mRT
->SetWakeupTime (Enable
, Time
);
134 Return value of variable.
136 @param VariableName the name of the vendor's variable, it's a
137 Null-Terminated Unicode String
138 @param VendorGuid Unify identifier for vendor.
139 @param Attributes Point to memory location to return the attributes of variable. If the point
140 is NULL, the parameter would be ignored.
141 @param DataSize As input, point to the maxinum size of return Data-Buffer.
142 As output, point to the actual size of the returned Data-Buffer.
143 @param Data Point to return Data-Buffer.
145 @retval EFI_SUCCESS Success to execute the function.
146 @retval !EFI_SUCCESS Failed to execute the function.
152 IN CHAR16
*VariableName
,
153 IN EFI_GUID
* VendorGuid
,
154 OUT UINT32
*Attributes OPTIONAL
,
155 IN OUT UINTN
*DataSize
,
159 return mRT
->GetVariable (VariableName
, VendorGuid
, Attributes
, DataSize
, Data
);
164 Enumerates variable's name.
166 @param VariableNameSize As input, point to maxinum size of variable name.
167 As output, point to actual size of varaible name.
168 @param VariableName As input, supplies the last VariableName that was returned by
169 GetNextVariableName().
170 As output, returns the name of variable. The name
171 string is Null-Terminated Unicode string.
172 @param VendorGuid As input, supplies the last VendorGuid that was returned by
173 GetNextVriableName().
174 As output, returns the VendorGuid of the current variable.
176 @retval EFI_SUCCESS Success to execute the function.
177 @retval !EFI_SUCCESS Failed to execute the function.
182 EfiGetNextVariableName (
183 IN OUT UINTN
*VariableNameSize
,
184 IN OUT CHAR16
*VariableName
,
185 IN OUT EFI_GUID
*VendorGuid
188 return mRT
->GetNextVariableName (VariableNameSize
, VariableName
, VendorGuid
);
193 Sets value of variable.
195 @param VariableName the name of the vendor's variable, it's a
196 Null-Terminated Unicode String
197 @param VendorGuid Unify identifier for vendor.
198 @param Attributes Point to memory location to return the attributes of variable. If the point
199 is NULL, the parameter would be ignored.
200 @param DataSize The size in bytes of Data-Buffer.
201 @param Data Point to the content of the variable.
203 @retval EFI_SUCCESS Success to execute the function.
204 @retval !EFI_SUCCESS Failed to execute the function.
210 IN CHAR16
*VariableName
,
211 IN EFI_GUID
*VendorGuid
,
212 IN UINT32 Attributes
,
217 return mRT
->SetVariable (VariableName
, VendorGuid
, Attributes
, DataSize
, Data
);
222 Returns the next high 32 bits of platform's monotonic counter.
224 @param HighCount Pointer to returned value.
226 @retval EFI_SUCCESS Success to execute the function.
227 @retval !EFI_SUCCESS Failed to execute the function.
232 EfiGetNextHighMonotonicCount (
233 OUT UINT32
*HighCount
236 return mRT
->GetNextHighMonotonicCount (HighCount
);
241 Determines the new virtual address that is to be used on subsequent memory accesses.
243 @param DebugDisposition Supplies type information for the pointer being converted.
244 @param Address The pointer to a pointer that is to be fixed to be the
245 value needed for the new virtual address mapping being
248 @retval EFI_SUCCESS Success to execute the function.
249 @retval !EFI_SUCCESS Failed to execute the function.
255 IN UINTN DebugDisposition
,
256 IN OUT VOID
**Address
259 return gRT
->ConvertPointer (DebugDisposition
, Address
);
264 Determines the new virtual address that is to be used on subsequent memory accesses.
266 For IA32, X64, and EBC, this service is a wrapper for the UEFI Runtime Service
267 ConvertPointer(). See the UEFI Specification for details.
268 For IPF, this function interprets Address as a pointer to an EFI_PLABEL structure
269 and both the EntryPoint and GP fields of an EFI_PLABEL are converted from physical
270 to virtiual addressing. Since IPF allows the GP to point to an address outside
271 a PE/COFF image, the physical to virtual offset for the EntryPoint field is used
272 to adjust the GP field. The UEFI Runtime Service ConvertPointer() is used to convert
273 EntryPoint and the status code for this conversion is always returned. If the convertion
274 of EntryPoint fails, then neither EntryPoint nor GP are modified. See the UEFI
275 Specification for details on the UEFI Runtime Service ConvertPointer().
277 @param DebugDisposition Supplies type information for the pointer being converted.
278 @param Address The pointer to a pointer that is to be fixed to be the
279 value needed for the new virtual address mapping being
282 @retval EFI_SUCCESS Success to execute the function.
283 @retval !EFI_SUCCESS Failed to execute the function.
288 EfiConvertFunctionPointer (
289 IN UINTN DebugDisposition
,
290 IN OUT VOID
**Address
293 return EfiConvertPointer (DebugDisposition
, Address
);
298 Conver the standard Lib double linked list to a virtual mapping.
300 @param DebugDisposition Supplies type information for the pointer being converted.
301 @param ListHead Head of linked list to convert.
303 @retval EFI_SUCCESS Success to execute the function.
304 @retval !EFI_SUCCESS Failed to execute the function.
310 IN UINTN DebugDisposition
,
311 IN OUT LIST_ENTRY
*ListHead
315 LIST_ENTRY
*NextLink
;
318 // For NULL List, return EFI_SUCCESS
320 if (ListHead
== NULL
) {
325 // Convert all the ForwardLink & BackLink pointers in the list
329 NextLink
= Link
->ForwardLink
;
332 Link
->ForwardLink
== ListHead
? DebugDisposition
: 0,
333 (VOID
**) &Link
->ForwardLink
337 Link
->BackLink
== ListHead
? DebugDisposition
: 0,
338 (VOID
**) &Link
->BackLink
342 } while (Link
!= ListHead
);
348 Change the runtime addressing mode of EFI firmware from physical to virtual.
350 @param MemoryMapSize The size in bytes of VirtualMap.
351 @param DescriptorSize The size in bytes of an entry in the VirtualMap.
352 @param DescriptorVersion The version of the structure entries in VirtualMap.
353 @param VirtualMap An array of memory descriptors which contain new virtual
354 address mapping information for all runtime ranges. Type
355 EFI_MEMORY_DESCRIPTOR is defined in the
356 GetMemoryMap() function description.
358 @retval EFI_SUCCESS The virtual address map has been applied.
359 @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in
360 virtual address mapped mode.
361 @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is
363 @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory
364 map that requires a mapping.
365 @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found
370 EfiSetVirtualAddressMap (
371 IN UINTN MemoryMapSize
,
372 IN UINTN DescriptorSize
,
373 IN UINT32 DescriptorVersion
,
374 IN CONST EFI_MEMORY_DESCRIPTOR
*VirtualMap
377 return mRT
->SetVirtualAddressMap (
381 (EFI_MEMORY_DESCRIPTOR
*) VirtualMap
387 Passes capsules to the firmware with both virtual and physical mapping.
388 Depending on the intended consumption, the firmware may
389 process the capsule immediately. If the payload should persist across a
390 system reset, the reset value returned from EFI_QueryCapsuleCapabilities must
391 be passed into ResetSystem() and will cause the capsule to be processed by
392 the firmware as part of the reset process.
394 @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules
395 being passed into update capsule. Each capsules is assumed to
396 stored in contiguous virtual memory. The capsules in the
397 CapsuleHeaderArray must be the same capsules as the
398 ScatterGatherList. The CapsuleHeaderArray must
399 have the capsules in the same order as the ScatterGatherList.
400 @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in
402 @param ScatterGatherList Physical pointer to a set of
403 EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the
404 location in physical memory of a set of capsules. See Related
405 Definitions for an explanation of how more than one capsule is
406 passed via this interface. The capsules in the
407 ScatterGatherList must be in the same order as the
408 CapsuleHeaderArray. This parameter is only referenced if
409 the capsules are defined to persist across system reset.
411 @retval EFI_SUCCESS Valid capsule was passed. I Valid capsule was passed. If
412 CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the
413 capsule has been successfully processed by the firmware.
414 @retval EFI_INVALID_PARAMETER CapsuleSize is NULL or ResetTye is NULL.
415 @retval EFI_DEVICE_ERROR The capsule update was started, but failed due to a device error.
421 IN EFI_CAPSULE_HEADER
**CapsuleHeaderArray
,
422 IN UINTN CapsuleCount
,
423 IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
426 return mRT
->UpdateCapsule (
435 The QueryCapsuleCapabilities() function allows a caller to test to see if a capsule or
436 capsules can be updated via UpdateCapsule(). The Flags values in the capsule header and
437 size of the entire capsule is checked.
438 If the caller needs to query for generic capsule capability a fake EFI_CAPSULE_HEADER can be
439 constructed where CapsuleImageSize is equal to HeaderSize that is equal to sizeof
440 (EFI_CAPSULE_HEADER). To determine reset requirements,
441 CAPSULE_FLAGS_PERSIST_ACROSS_RESET should be set in the Flags field of the
443 The firmware must support any capsule that has the
444 CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set in EFI_CAPSULE_HEADER. The
445 firmware sets the policy for what capsules are supported that do not have the
446 CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set.
448 @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules
449 being passed into update capsule. The capsules are assumed to
450 stored in contiguous virtual memory.
451 @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in
453 @param MaximumCapsuleSize On output the maximum size that UpdateCapsule() can
454 support as an argument to UpdateCapsule() via
455 CapsuleHeaderArray and ScatterGatherList.
457 @param ResetType Returns the type of reset required for the capsule update.
459 @retval EFI_SUCCESS Valid answer returned..
460 @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL.
461 @retval EFI_UNSUPPORTED The capsule type is not supported on this platform, and
462 MaximumCapsuleSize and ResetType are undefined.
467 EfiQueryCapsuleCapabilities (
468 IN EFI_CAPSULE_HEADER
**CapsuleHeaderArray
,
469 IN UINTN CapsuleCount
,
470 OUT UINT64
*MaximumCapsuleSize
,
471 OUT EFI_RESET_TYPE
*ResetType
474 return mRT
->QueryCapsuleCapabilities (
484 The QueryVariableInfo() function allows a caller to obtain the information about the
485 maximum size of the storage space available for the EFI variables, the remaining size of the storage
486 space available for the EFI variables and the maximum size of each individual EFI variable,
487 associated with the attributes specified.
488 The returned MaximumVariableStorageSize, RemainingVariableStorageSize,
489 MaximumVariableSize information may change immediately after the call based on other
490 runtime activities including asynchronous error events. Also, these values associated with different
491 attributes are not additive in nature.
493 @param Attributes Attributes bitmask to specify the type of variables on
494 which to return information. Refer to the
495 GetVariable() function description.
496 @param MaximumVariableStorageSize
497 On output the maximum size of the storage space
498 available for the EFI variables associated with the
499 attributes specified.
500 @param RemainingVariableStorageSize
501 Returns the remaining size of the storage space
502 available for the EFI variables associated with the
503 attributes specified..
504 @param MaximumVariableSize Returns the maximum size of the individual EFI
505 variables associated with the attributes specified.
507 @retval EFI_SUCCESS Valid answer returned.
508 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
509 @retval EFI_UNSUPPORTED EFI_UNSUPPORTED The attribute is not supported on this platform, and the
510 MaximumVariableStorageSize,
511 RemainingVariableStorageSize, MaximumVariableSize
516 EfiQueryVariableInfo (
517 IN UINT32 Attributes
,
518 OUT UINT64
*MaximumVariableStorageSize
,
519 OUT UINT64
*RemainingVariableStorageSize
,
520 OUT UINT64
*MaximumVariableSize
523 return mRT
->QueryVariableInfo (
525 MaximumVariableStorageSize
,
526 RemainingVariableStorageSize
,