TianoCore EDK2 master
Loading...
Searching...
No Matches
RuntimeLib.c
Go to the documentation of this file.
1
14#include <Uefi.h>
16#include <Library/DebugLib.h>
19#include <Guid/EventGroup.h>
20
25EFI_EVENT mEfiExitBootServicesEvent;
26BOOLEAN mEfiGoneVirtual = FALSE;
27BOOLEAN mEfiAtRuntime = FALSE;
28EFI_RUNTIME_SERVICES *mInternalRT;
29
37VOID
38EFIAPI
40 IN EFI_EVENT Event,
41 IN VOID *Context
42 )
43{
44 mEfiAtRuntime = TRUE;
45}
46
55VOID
56EFIAPI
58 IN EFI_EVENT Event,
59 IN VOID *Context
60 )
61{
62 //
63 // Update global for Runtime Services Table and IO
64 //
65 EfiConvertPointer (0, (VOID **)&mInternalRT);
66
67 mEfiGoneVirtual = TRUE;
68}
69
81EFIAPI
83 IN EFI_HANDLE ImageHandle,
84 IN EFI_SYSTEM_TABLE *SystemTable
85 )
86{
87 EFI_STATUS Status;
88
89 ASSERT (gRT != NULL);
90 ASSERT (gBS != NULL);
91
92 mInternalRT = gRT;
93 //
94 // Register SetVirtualAddressMap () notify function
95 //
96 Status = gBS->CreateEvent (
97 EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
98 TPL_NOTIFY,
100 NULL,
102 );
103
104 ASSERT_EFI_ERROR (Status);
105
106 Status = gBS->CreateEvent (
107 EVT_SIGNAL_EXIT_BOOT_SERVICES,
108 TPL_NOTIFY,
110 NULL,
111 &mEfiExitBootServicesEvent
112 );
113
114 ASSERT_EFI_ERROR (Status);
115
116 return Status;
117}
118
132EFIAPI
134 IN EFI_HANDLE ImageHandle,
135 IN EFI_SYSTEM_TABLE *SystemTable
136 )
137{
138 EFI_STATUS Status;
139
140 //
141 // Close SetVirtualAddressMap () notify function
142 //
143 ASSERT (gBS != NULL);
144 Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);
145 ASSERT_EFI_ERROR (Status);
146
147 Status = gBS->CloseEvent (mEfiExitBootServicesEvent);
148 ASSERT_EFI_ERROR (Status);
149
150 return Status;
151}
152
165BOOLEAN
166EFIAPI
168 VOID
169 )
170{
171 return mEfiAtRuntime;
172}
173
186BOOLEAN
187EFIAPI
189 VOID
190 )
191{
192 return mEfiGoneVirtual;
193}
194
224VOID
225EFIAPI
227 IN EFI_RESET_TYPE ResetType,
228 IN EFI_STATUS ResetStatus,
229 IN UINTN DataSize,
230 IN VOID *ResetData OPTIONAL
231 )
232{
233 mInternalRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
234}
235
261EFIAPI
263 OUT EFI_TIME *Time,
264 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
265 )
266{
267 return mInternalRT->GetTime (Time, Capabilities);
268}
269
296EFIAPI
298 IN EFI_TIME *Time
299 )
300{
301 return mInternalRT->SetTime (Time);
302}
303
328EFIAPI
330 OUT BOOLEAN *Enabled,
331 OUT BOOLEAN *Pending,
332 OUT EFI_TIME *Time
333 )
334{
335 return mInternalRT->GetWakeupTime (Enabled, Pending, Time);
336}
337
363EFIAPI
365 IN BOOLEAN Enable,
366 IN EFI_TIME *Time OPTIONAL
367 )
368{
369 return mInternalRT->SetWakeupTime (Enable, Time);
370}
371
407EFIAPI
409 IN CHAR16 *VariableName,
410 IN EFI_GUID *VendorGuid,
411 OUT UINT32 *Attributes OPTIONAL,
412 IN OUT UINTN *DataSize,
413 OUT VOID *Data
414 )
415{
416 return mInternalRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
417}
418
454EFIAPI
456 IN OUT UINTN *VariableNameSize,
457 IN OUT CHAR16 *VariableName,
458 IN OUT EFI_GUID *VendorGuid
459 )
460{
461 return mInternalRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);
462}
463
497EFIAPI
499 IN CHAR16 *VariableName,
500 IN EFI_GUID *VendorGuid,
501 IN UINT32 Attributes,
502 IN UINTN DataSize,
503 IN VOID *Data
504 )
505{
506 return mInternalRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
507}
508
529EFIAPI
531 OUT UINT32 *HighCount
532 )
533{
534 return mInternalRT->GetNextHighMonotonicCount (HighCount);
535}
536
560EFIAPI
562 IN UINTN DebugDisposition,
563 IN OUT VOID **Address
564 )
565{
566 return gRT->ConvertPointer (DebugDisposition, Address);
567}
568
592EFIAPI
594 IN UINTN DebugDisposition,
595 IN OUT VOID **Address
596 )
597{
598 return EfiConvertPointer (DebugDisposition, Address);
599}
600
616EFIAPI
618 IN UINTN DebugDisposition,
619 IN OUT LIST_ENTRY *ListHead
620 )
621{
622 LIST_ENTRY *Link;
623 LIST_ENTRY *NextLink;
624
625 //
626 // For NULL List, return EFI_SUCCESS
627 //
628 if (ListHead == NULL) {
629 return EFI_SUCCESS;
630 }
631
632 //
633 // Convert all the ForwardLink & BackLink pointers in the list
634 //
635 Link = ListHead;
636 do {
637 NextLink = Link->ForwardLink;
638
640 Link->ForwardLink == ListHead ? DebugDisposition : 0,
641 (VOID **)&Link->ForwardLink
642 );
643
645 Link->BackLink == ListHead ? DebugDisposition : 0,
646 (VOID **)&Link->BackLink
647 );
648
649 Link = NextLink;
650 } while (Link != ListHead);
651
652 return EFI_SUCCESS;
653}
654
685EFIAPI
687 IN UINTN MemoryMapSize,
688 IN UINTN DescriptorSize,
689 IN UINT32 DescriptorVersion,
690 IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap
691 )
692{
693 return mInternalRT->SetVirtualAddressMap (
694 MemoryMapSize,
695 DescriptorSize,
696 DescriptorVersion,
697 (EFI_MEMORY_DESCRIPTOR *)VirtualMap
698 );
699}
700
739EFIAPI
741 IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,
742 IN UINTN CapsuleCount,
743 IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
744 )
745{
746 return mInternalRT->UpdateCapsule (
747 CapsuleHeaderArray,
748 CapsuleCount,
749 ScatterGatherList
750 );
751}
752
791EFIAPI
793 IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,
794 IN UINTN CapsuleCount,
795 OUT UINT64 *MaximumCapsuleSize,
796 OUT EFI_RESET_TYPE *ResetType
797 )
798{
799 return mInternalRT->QueryCapsuleCapabilities (
800 CapsuleHeaderArray,
801 CapsuleCount,
802 MaximumCapsuleSize,
803 ResetType
804 );
805}
806
842EFIAPI
844 IN UINT32 Attributes,
845 OUT UINT64 *MaximumVariableStorageSize,
846 OUT UINT64 *RemainingVariableStorageSize,
847 OUT UINT64 *MaximumVariableSize
848 )
849{
850 return mInternalRT->QueryVariableInfo (
851 Attributes,
852 MaximumVariableStorageSize,
853 RemainingVariableStorageSize,
854 MaximumVariableSize
855 );
856}
UINT64 UINTN
EFI_RUNTIME_SERVICES * gRT
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
EFI_STATUS EFIAPI EfiGetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data)
Definition: RuntimeLib.c:408
EFI_STATUS EFIAPI EfiGetNextVariableName(IN OUT UINTN *VariableNameSize, IN OUT CHAR16 *VariableName, IN OUT EFI_GUID *VendorGuid)
Definition: RuntimeLib.c:455
BOOLEAN EFIAPI EfiAtRuntime(VOID)
Definition: RuntimeLib.c:167
EFI_STATUS EFIAPI EfiGetTime(OUT EFI_TIME *Time, OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL)
Definition: RuntimeLib.c:262
VOID EFIAPI EfiResetSystem(IN EFI_RESET_TYPE ResetType, IN EFI_STATUS ResetStatus, IN UINTN DataSize, IN VOID *ResetData OPTIONAL)
Definition: RuntimeLib.c:226
VOID EFIAPI RuntimeLibExitBootServicesEvent(IN EFI_EVENT Event, IN VOID *Context)
Definition: RuntimeLib.c:39
EFI_STATUS EFIAPI RuntimeDriverLibConstruct(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: RuntimeLib.c:82
EFI_STATUS EFIAPI RuntimeDriverLibDeconstruct(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: RuntimeLib.c:133
EFI_STATUS EFIAPI EfiSetTime(IN EFI_TIME *Time)
Definition: RuntimeLib.c:297
EFI_EVENT mEfiVirtualNotifyEvent
Definition: RuntimeLib.c:24
VOID EFIAPI RuntimeLibVirtualNotifyEvent(IN EFI_EVENT Event, IN VOID *Context)
Definition: RuntimeLib.c:57
EFI_STATUS EFIAPI EfiConvertPointer(IN UINTN DebugDisposition, IN OUT VOID **Address)
Definition: RuntimeLib.c:561
EFI_STATUS EFIAPI EfiGetWakeupTime(OUT BOOLEAN *Enabled, OUT BOOLEAN *Pending, OUT EFI_TIME *Time)
Definition: RuntimeLib.c:329
EFI_STATUS EFIAPI EfiGetNextHighMonotonicCount(OUT UINT32 *HighCount)
Definition: RuntimeLib.c:530
EFI_STATUS EFIAPI EfiUpdateCapsule(IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, IN UINTN CapsuleCount, IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL)
Definition: RuntimeLib.c:740
EFI_STATUS EFIAPI EfiSetVirtualAddressMap(IN UINTN MemoryMapSize, IN UINTN DescriptorSize, IN UINT32 DescriptorVersion, IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap)
Definition: RuntimeLib.c:686
EFI_STATUS EFIAPI EfiSetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
Definition: RuntimeLib.c:498
EFI_STATUS EFIAPI EfiConvertList(IN UINTN DebugDisposition, IN OUT LIST_ENTRY *ListHead)
Definition: RuntimeLib.c:617
EFI_STATUS EFIAPI EfiQueryCapsuleCapabilities(IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, IN UINTN CapsuleCount, OUT UINT64 *MaximumCapsuleSize, OUT EFI_RESET_TYPE *ResetType)
Definition: RuntimeLib.c:792
BOOLEAN EFIAPI EfiGoneVirtual(VOID)
Definition: RuntimeLib.c:188
EFI_STATUS EFIAPI EfiQueryVariableInfo(IN UINT32 Attributes, OUT UINT64 *MaximumVariableStorageSize, OUT UINT64 *RemainingVariableStorageSize, OUT UINT64 *MaximumVariableSize)
Definition: RuntimeLib.c:843
EFI_STATUS EFIAPI EfiConvertFunctionPointer(IN UINTN DebugDisposition, IN OUT VOID **Address)
Definition: RuntimeLib.c:593
EFI_STATUS EFIAPI EfiSetWakeupTime(IN BOOLEAN Enable, IN EFI_TIME *Time OPTIONAL)
Definition: RuntimeLib.c:364
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_RESET_TYPE
Definition: Base.h:213