]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeLib.c
removing the dependency on EDKDxeSalLib and EdxDxeRuntimeSalLib, instead using DxeExt...
[mirror_edk2.git] / EdkModulePkg / Library / EdkUefiRuntimeLib / Ipf / RuntimeLib.c
CommitLineData
878ddf1f 1/*++\r
2\r
93b0fbc8 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
878ddf1f 11\r
12Module Name:\r
13\r
14 RuntimeLib.c\r
15\r
878ddf1f 16--*/\r
17\r
878ddf1f 18#include <RuntimeLibInternal.h>\r
19\r
20//\r
21// Driver Lib Module Globals\r
22//\r
f1cd55fe 23static EFI_EVENT mEfiVirtualNotifyEvent;\r
24EFI_RUNTIME_SERVICES *mRT;\r
878ddf1f 25\r
878ddf1f 26VOID\r
27EFIAPI\r
28RuntimeDriverExitBootServices (\r
29 IN EFI_EVENT Event,\r
30 IN VOID *Context\r
31 )\r
32/*++\r
33\r
34Routine Description:\r
35\r
36 Set AtRuntime flag as TRUE after ExitBootServices\r
37\r
38Arguments:\r
39\r
40 Event - The Event that is being processed\r
93b0fbc8 41\r
878ddf1f 42 Context - Event Context\r
43\r
93b0fbc8 44Returns:\r
878ddf1f 45\r
46 None\r
47\r
48--*/\r
49{\r
f1cd55fe 50 if (EfiAtRuntime()) {\r
51 return;\r
878ddf1f 52 }\r
53}\r
54\r
1cc8ee78 55STATIC\r
878ddf1f 56VOID\r
57EFIAPI\r
58RuntimeLibVirtualNotifyEvent (\r
59 IN EFI_EVENT Event,\r
60 IN VOID *Context\r
61 )\r
62/*++\r
63\r
64Routine Description:\r
65\r
66 Fixup internal data so that EFI can be call in virtual mode.\r
93b0fbc8 67 Call the passed in Child Notify event and convert any pointers in\r
878ddf1f 68 lib to virtual mode.\r
69\r
70Arguments:\r
71\r
72 Event - The Event that is being processed\r
93b0fbc8 73\r
878ddf1f 74 Context - Event Context\r
75\r
93b0fbc8 76Returns:\r
878ddf1f 77\r
78 None\r
79\r
80--*/\r
81{\r
f1cd55fe 82 UINTN Index;\r
878ddf1f 83 EFI_EVENT_NOTIFY ChildNotifyEventHandler;\r
84\r
85 for (Index = 0; _gDriverSetVirtualAddressMapEvent[Index] != NULL; Index++) {\r
86 ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index];\r
87 ChildNotifyEventHandler (Event, NULL);\r
88 }\r
89\r
c25aaa00 90 //\r
91 // Update global for Runtime Services Table\r
92 //\r
93 EfiConvertPointer (0, (VOID **) &mRT);\r
878ddf1f 94}\r
95\r
96EFI_STATUS\r
a5e465a7 97EFIAPI\r
878ddf1f 98RuntimeDriverLibConstruct (\r
99 IN EFI_HANDLE ImageHandle,\r
100 IN EFI_SYSTEM_TABLE *SystemTable\r
101 )\r
102/*++\r
103\r
104Routine Description:\r
105\r
93b0fbc8 106 Intialize runtime Driver Lib if it has not yet been initialized.\r
878ddf1f 107\r
108Arguments:\r
109\r
110 ImageHandle - The firmware allocated handle for the EFI image.\r
93b0fbc8 111\r
878ddf1f 112 SystemTable - A pointer to the EFI System Table.\r
113\r
114 GoVirtualChildEvent - Caller can register a virtual notification event.\r
115\r
116Returns: \r
117\r
118 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
119\r
120--*/\r
121{\r
878ddf1f 122 EFI_STATUS Status;\r
123\r
124 mRT = SystemTable->RuntimeServices;\r
125\r
878ddf1f 126 //\r
127 // Register SetVirtualAddressMap () notify function\r
128 //\r
f1cd55fe 129 if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r
130 Status = gBS->CreateEvent (\r
93b0fbc8 131 EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
132 TPL_NOTIFY,\r
f1cd55fe 133 RuntimeLibVirtualNotifyEvent,\r
134 NULL,\r
135 &mEfiVirtualNotifyEvent\r
136 );\r
137 ASSERT_EFI_ERROR (Status);\r
138 }\r
878ddf1f 139\r
140 return EFI_SUCCESS;\r
141}\r
142\r
143EFI_STATUS\r
a5e465a7 144EFIAPI\r
878ddf1f 145RuntimeDriverLibDeconstruct (\r
f9081b64 146 IN EFI_HANDLE ImageHandle,\r
147 IN EFI_SYSTEM_TABLE *SystemTable\r
878ddf1f 148 )\r
149/*++\r
150\r
151Routine Description:\r
152\r
153 This routine will free some resources which have been allocated in\r
93b0fbc8 154 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,\r
878ddf1f 155 it must call this routine to free the allocated resource before the exiting.\r
156\r
157Arguments:\r
158\r
159 None\r
160\r
93b0fbc8 161Returns:\r
878ddf1f 162\r
163 EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully\r
164 EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r
165\r
166--*/\r
167{\r
168 EFI_STATUS Status;\r
169\r
878ddf1f 170 //\r
171 // Close SetVirtualAddressMap () notify function\r
172 //\r
f1cd55fe 173 if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r
174 Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r
175 ASSERT_EFI_ERROR (Status);\r
176 }\r
878ddf1f 177\r
178 return EFI_SUCCESS;\r
179}\r
180\r
181BOOLEAN\r
e8a3bee0 182EFIAPI\r
878ddf1f 183EfiAtRuntime (\r
184 VOID\r
185 )\r
186/*++\r
187\r
188Routine Description:\r
189 Return TRUE if ExitBootService () has been called\r
190\r
191Arguments:\r
192 NONE\r
193\r
93b0fbc8 194Returns:\r
878ddf1f 195 TRUE - If ExitBootService () has been called\r
196\r
197--*/\r
198{\r
e8d4831b 199 EFI_GUID Guid;\r
878ddf1f 200 SAL_RETURN_REGS ReturnReg;\r
201\r
e8d4831b 202 *((UINT64 *) &Guid) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_LO;\r
203 *(((UINT64 *)&Guid) + 1) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_HI;\r
204\r
188fe5e8 205 ReturnReg = EsalCall (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0);\r
878ddf1f 206\r
207 return (BOOLEAN) (ReturnReg.r9 == 1);\r
208}\r
209\r
210BOOLEAN\r
e8a3bee0 211EFIAPI\r
878ddf1f 212EfiGoneVirtual (\r
213 VOID\r
214 )\r
215/*++\r
216\r
217Routine Description:\r
218 Return TRUE if SetVirtualAddressMap () has been called\r
219\r
220Arguments:\r
221 NONE\r
222\r
93b0fbc8 223Returns:\r
878ddf1f 224 TRUE - If SetVirtualAddressMap () has been called\r
225\r
226--*/\r
227{\r
e8d4831b 228 EFI_GUID Guid;\r
878ddf1f 229 SAL_RETURN_REGS ReturnReg;\r
230\r
e8d4831b 231 *((UINT64 *) &Guid) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_LO;\r
232 *(((UINT64 *)&Guid) + 1) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_HI;\r
233\r
188fe5e8 234 ReturnReg = EsalCall (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0);\r
878ddf1f 235\r
236 return (BOOLEAN) (ReturnReg.r9 == 1);\r
237}\r
e8a3bee0 238\r