]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Library/EdkUefiRuntimeLib/Common/RuntimeLib.c
Remove unused library class EdkPeCoffLoaderX64Lib and library instance EdkPeCoffLoade...
[mirror_edk2.git] / EdkModulePkg / Library / EdkUefiRuntimeLib / Common / RuntimeLib.c
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 RuntimeLib.c\r
15\r
878ddf1f 16--*/\r
17\r
18#include <RuntimeLibInternal.h>\r
19\r
20//\r
21// Driver Lib Module Globals\r
22//\r
878ddf1f 23\r
e8a3bee0 24STATIC EFI_EVENT mEfiVirtualNotifyEvent;\r
25STATIC BOOLEAN mEfiGoneVirtual = FALSE;\r
26STATIC BOOLEAN mEfiAtRuntime = FALSE;\r
e8a3bee0 27EFI_RUNTIME_SERVICES *mRT;\r
28\r
878ddf1f 29VOID\r
30EFIAPI\r
31RuntimeDriverExitBootServices (\r
32 IN EFI_EVENT Event,\r
33 IN VOID *Context\r
34 )\r
35/*++\r
36\r
37Routine Description:\r
38\r
39 Set AtRuntime flag as TRUE after ExitBootServices\r
40\r
41Arguments:\r
42\r
43 Event - The Event that is being processed\r
44 \r
45 Context - Event Context\r
46\r
47Returns: \r
48\r
49 None\r
50\r
51--*/\r
52{\r
e8a3bee0 53 //\r
54 // Clear out BootService globals\r
55 //\r
56 gBS = NULL;\r
57\r
878ddf1f 58 mEfiAtRuntime = TRUE;\r
59}\r
60\r
61STATIC\r
62VOID\r
63EFIAPI\r
64RuntimeLibVirtualNotifyEvent (\r
65 IN EFI_EVENT Event,\r
66 IN VOID *Context\r
67 )\r
68/*++\r
69\r
70Routine Description:\r
71\r
72 Fixup internal data so that EFI can be call in virtual mode.\r
73 Call the passed in Child Notify event and convert any pointers in \r
74 lib to virtual mode.\r
75\r
76Arguments:\r
77\r
78 Event - The Event that is being processed\r
79 \r
80 Context - Event Context\r
81\r
82Returns: \r
83\r
84 None\r
85\r
86--*/\r
87{\r
88 UINTN Index;\r
89 EFI_EVENT_NOTIFY ChildNotifyEventHandler;\r
90\r
91 for (Index = 0; \r
92 _gDriverSetVirtualAddressMapEvent[Index] != NULL;\r
93 Index++) {\r
94 ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index];\r
95 ChildNotifyEventHandler (Event, NULL);\r
96 }\r
97\r
98 //\r
99 // Update global for Runtime Services Table and IO\r
100 //\r
e8a3bee0 101 EfiConvertPointer (0, (VOID **) &mRT);\r
878ddf1f 102\r
878ddf1f 103 mEfiGoneVirtual = TRUE;\r
104}\r
105\r
106EFI_STATUS\r
a5e465a7 107EFIAPI\r
878ddf1f 108RuntimeDriverLibConstruct (\r
109 IN EFI_HANDLE ImageHandle,\r
110 IN EFI_SYSTEM_TABLE *SystemTable\r
111 )\r
112/*++\r
113\r
114Routine Description:\r
115\r
116 Intialize runtime Driver Lib if it has not yet been initialized. \r
117\r
118Arguments:\r
119\r
120 ImageHandle - The firmware allocated handle for the EFI image.\r
121 \r
122 SystemTable - A pointer to the EFI System Table.\r
123\r
124 GoVirtualChildEvent - Caller can register a virtual notification event.\r
125\r
126Returns: \r
127\r
128 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
129\r
130--*/\r
131{\r
132 EFI_STATUS Status;\r
133\r
134 mRT = SystemTable->RuntimeServices;\r
135\r
878ddf1f 136 //\r
137 // Register SetVirtualAddressMap () notify function\r
138 // \r
f1cd55fe 139 if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r
878ddf1f 140 Status = gBS->CreateEvent (\r
141 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
142 EFI_TPL_NOTIFY,\r
143 RuntimeLibVirtualNotifyEvent,\r
144 NULL,\r
145 &mEfiVirtualNotifyEvent\r
146 );\r
147\r
148 ASSERT_EFI_ERROR (Status);\r
f1cd55fe 149 }\r
878ddf1f 150\r
151 return EFI_SUCCESS;\r
152}\r
153\r
154EFI_STATUS\r
a5e465a7 155EFIAPI\r
878ddf1f 156RuntimeDriverLibDeconstruct (\r
157 VOID\r
158 )\r
159/*++\r
160\r
161Routine Description:\r
162\r
163 This routine will free some resources which have been allocated in\r
164 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r
165 it must call this routine to free the allocated resource before the exiting.\r
166\r
167Arguments:\r
168\r
169 None\r
170\r
171Returns: \r
172\r
173 EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully\r
174 EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r
175\r
176--*/\r
177{\r
178 EFI_STATUS Status;\r
179\r
878ddf1f 180 //\r
181 // Close SetVirtualAddressMap () notify function\r
182 //\r
f1cd55fe 183 if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r
878ddf1f 184 Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r
185 ASSERT_EFI_ERROR (Status);\r
f1cd55fe 186 }\r
878ddf1f 187\r
188 return EFI_SUCCESS;\r
189}\r
190\r
191BOOLEAN\r
e8a3bee0 192EFIAPI\r
878ddf1f 193EfiAtRuntime (\r
194 VOID\r
195 )\r
196/*++\r
197\r
198Routine Description:\r
199 Return TRUE if ExitBootServices () has been called\r
200\r
201Arguments:\r
202 NONE\r
203\r
204Returns: \r
205 TRUE - If ExitBootServices () has been called\r
206\r
207--*/\r
208{\r
209 return mEfiAtRuntime;\r
210}\r
211\r
212BOOLEAN\r
e8a3bee0 213EFIAPI\r
878ddf1f 214EfiGoneVirtual (\r
215 VOID\r
216 )\r
217/*++\r
218\r
219Routine Description:\r
220 Return TRUE if SetVirtualAddressMap () has been called\r
221\r
222Arguments:\r
223 NONE\r
224\r
225Returns: \r
226 TRUE - If SetVirtualAddressMap () has been called\r
227\r
228--*/\r
229{\r
230 return mEfiGoneVirtual;\r
231}\r
232\r