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 Conver the standard Lib double linked list to a virtual mapping.
266 @param DebugDisposition Supplies type information for the pointer being converted.
267 @param ListHead Head of linked list to convert.
269 @retval EFI_SUCCESS Success to execute the function.
270 @retval !EFI_SUCCESS Failed to execute the function.
276 IN UINTN DebugDisposition
,
277 IN OUT LIST_ENTRY
*ListHead
281 LIST_ENTRY
*NextLink
;
284 // For NULL List, return EFI_SUCCESS
286 if (ListHead
== NULL
) {
291 // Convert all the ForwardLink & BackLink pointers in the list
295 NextLink
= Link
->ForwardLink
;
298 Link
->ForwardLink
== ListHead
? DebugDisposition
: 0,
299 (VOID
**) &Link
->ForwardLink
303 Link
->BackLink
== ListHead
? DebugDisposition
: 0,
304 (VOID
**) &Link
->BackLink
308 } while (Link
!= ListHead
);
314 Change the runtime addressing mode of EFI firmware from physical to virtual.
316 @param MemoryMapSize The size in bytes of VirtualMap.
317 @param DescriptorSize The size in bytes of an entry in the VirtualMap.
318 @param DescriptorVersion The version of the structure entries in VirtualMap.
319 @param VirtualMap An array of memory descriptors which contain new virtual
320 address mapping information for all runtime ranges. Type
321 EFI_MEMORY_DESCRIPTOR is defined in the
322 GetMemoryMap() function description.
324 @retval EFI_SUCCESS The virtual address map has been applied.
325 @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in
326 virtual address mapped mode.
327 @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is
329 @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory
330 map that requires a mapping.
331 @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found
336 EfiSetVirtualAddressMap (
337 IN UINTN MemoryMapSize
,
338 IN UINTN DescriptorSize
,
339 IN UINT32 DescriptorVersion
,
340 IN CONST EFI_MEMORY_DESCRIPTOR
*VirtualMap
343 return mRT
->SetVirtualAddressMap (
347 (EFI_MEMORY_DESCRIPTOR
*) VirtualMap
353 Passes capsules to the firmware with both virtual and physical mapping.
354 Depending on the intended consumption, the firmware may
355 process the capsule immediately. If the payload should persist across a
356 system reset, the reset value returned from EFI_QueryCapsuleCapabilities must
357 be passed into ResetSystem() and will cause the capsule to be processed by
358 the firmware as part of the reset process.
360 @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules
361 being passed into update capsule. Each capsules is assumed to
362 stored in contiguous virtual memory. The capsules in the
363 CapsuleHeaderArray must be the same capsules as the
364 ScatterGatherList. The CapsuleHeaderArray must
365 have the capsules in the same order as the ScatterGatherList.
366 @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in
368 @param ScatterGatherList Physical pointer to a set of
369 EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the
370 location in physical memory of a set of capsules. See Related
371 Definitions for an explanation of how more than one capsule is
372 passed via this interface. The capsules in the
373 ScatterGatherList must be in the same order as the
374 CapsuleHeaderArray. This parameter is only referenced if
375 the capsules are defined to persist across system reset.
377 @retval EFI_SUCCESS Valid capsule was passed. I Valid capsule was passed. If
378 CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the
379 capsule has been successfully processed by the firmware.
380 @retval EFI_INVALID_PARAMETER CapsuleSize is NULL or ResetTye is NULL.
381 @retval EFI_DEVICE_ERROR The capsule update was started, but failed due to a device error.
387 IN EFI_CAPSULE_HEADER
**CapsuleHeaderArray
,
388 IN UINTN CapsuleCount
,
389 IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
392 return mRT
->UpdateCapsule (
401 The QueryCapsuleCapabilities() function allows a caller to test to see if a capsule or
402 capsules can be updated via UpdateCapsule(). The Flags values in the capsule header and
403 size of the entire capsule is checked.
404 If the caller needs to query for generic capsule capability a fake EFI_CAPSULE_HEADER can be
405 constructed where CapsuleImageSize is equal to HeaderSize that is equal to sizeof
406 (EFI_CAPSULE_HEADER). To determine reset requirements,
407 CAPSULE_FLAGS_PERSIST_ACROSS_RESET should be set in the Flags field of the
409 The firmware must support any capsule that has the
410 CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set in EFI_CAPSULE_HEADER. The
411 firmware sets the policy for what capsules are supported that do not have the
412 CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set.
414 @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules
415 being passed into update capsule. The capsules are assumed to
416 stored in contiguous virtual memory.
417 @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in
419 @param MaximumCapsuleSize On output the maximum size that UpdateCapsule() can
420 support as an argument to UpdateCapsule() via
421 CapsuleHeaderArray and ScatterGatherList.
423 @param ResetType Returns the type of reset required for the capsule update.
425 @retval EFI_SUCCESS Valid answer returned..
426 @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL.
427 @retval EFI_UNSUPPORTED The capsule type is not supported on this platform, and
428 MaximumCapsuleSize and ResetType are undefined.
433 EfiQueryCapsuleCapabilities (
434 IN EFI_CAPSULE_HEADER
**CapsuleHeaderArray
,
435 IN UINTN CapsuleCount
,
436 OUT UINT64
*MaximumCapsuleSize
,
437 OUT EFI_RESET_TYPE
*ResetType
440 return mRT
->QueryCapsuleCapabilities (
450 The QueryVariableInfo() function allows a caller to obtain the information about the
451 maximum size of the storage space available for the EFI variables, the remaining size of the storage
452 space available for the EFI variables and the maximum size of each individual EFI variable,
453 associated with the attributes specified.
454 The returned MaximumVariableStorageSize, RemainingVariableStorageSize,
455 MaximumVariableSize information may change immediately after the call based on other
456 runtime activities including asynchronous error events. Also, these values associated with different
457 attributes are not additive in nature.
459 @param Attributes Attributes bitmask to specify the type of variables on
460 which to return information. Refer to the
461 GetVariable() function description.
462 @param MaximumVariableStorageSize
463 On output the maximum size of the storage space
464 available for the EFI variables associated with the
465 attributes specified.
466 @param RemainingVariableStorageSize
467 Returns the remaining size of the storage space
468 available for the EFI variables associated with the
469 attributes specified..
470 @param MaximumVariableSize Returns the maximum size of the individual EFI
471 variables associated with the attributes specified.
473 @retval EFI_SUCCESS Valid answer returned.
474 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
475 @retval EFI_UNSUPPORTED EFI_UNSUPPORTED The attribute is not supported on this platform, and the
476 MaximumVariableStorageSize,
477 RemainingVariableStorageSize, MaximumVariableSize
482 EfiQueryVariableInfo (
483 IN UINT32 Attributes
,
484 OUT UINT64
*MaximumVariableStorageSize
,
485 OUT UINT64
*RemainingVariableStorageSize
,
486 OUT UINT64
*MaximumVariableSize
489 return mRT
->QueryVariableInfo (
491 MaximumVariableStorageSize
,
492 RemainingVariableStorageSize
,