]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeLib.c
Remove commented out inclusion of SalApi.h
[mirror_edk2.git] / EdkModulePkg / Library / EdkUefiRuntimeLib / Ipf / 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
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
41 \r
42 Context - Event Context\r
43\r
44Returns: \r
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
878ddf1f 55VOID\r
56EFIAPI\r
57RuntimeLibVirtualNotifyEvent (\r
58 IN EFI_EVENT Event,\r
59 IN VOID *Context\r
60 )\r
61/*++\r
62\r
63Routine Description:\r
64\r
65 Fixup internal data so that EFI can be call in virtual mode.\r
66 Call the passed in Child Notify event and convert any pointers in \r
67 lib to virtual mode.\r
68\r
69Arguments:\r
70\r
71 Event - The Event that is being processed\r
72 \r
73 Context - Event Context\r
74\r
75Returns: \r
76\r
77 None\r
78\r
79--*/\r
80{\r
f1cd55fe 81 UINTN Index;\r
878ddf1f 82 EFI_EVENT_NOTIFY ChildNotifyEventHandler;\r
83\r
84 for (Index = 0; _gDriverSetVirtualAddressMapEvent[Index] != NULL; Index++) {\r
85 ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index];\r
86 ChildNotifyEventHandler (Event, NULL);\r
87 }\r
88\r
c25aaa00 89 //\r
90 // Update global for Runtime Services Table\r
91 //\r
92 EfiConvertPointer (0, (VOID **) &mRT);\r
878ddf1f 93}\r
94\r
95EFI_STATUS\r
a5e465a7 96EFIAPI\r
878ddf1f 97RuntimeDriverLibConstruct (\r
98 IN EFI_HANDLE ImageHandle,\r
99 IN EFI_SYSTEM_TABLE *SystemTable\r
100 )\r
101/*++\r
102\r
103Routine Description:\r
104\r
105 Intialize runtime Driver Lib if it has not yet been initialized. \r
106\r
107Arguments:\r
108\r
109 ImageHandle - The firmware allocated handle for the EFI image.\r
110 \r
111 SystemTable - A pointer to the EFI System Table.\r
112\r
113 GoVirtualChildEvent - Caller can register a virtual notification event.\r
114\r
115Returns: \r
116\r
117 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
118\r
119--*/\r
120{\r
878ddf1f 121 EFI_STATUS Status;\r
122\r
123 mRT = SystemTable->RuntimeServices;\r
124\r
878ddf1f 125 //\r
126 // Register SetVirtualAddressMap () notify function\r
127 //\r
f1cd55fe 128 if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r
129 Status = gBS->CreateEvent (\r
130 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
131 EFI_TPL_NOTIFY,\r
132 RuntimeLibVirtualNotifyEvent,\r
133 NULL,\r
134 &mEfiVirtualNotifyEvent\r
135 );\r
136 ASSERT_EFI_ERROR (Status);\r
137 }\r
878ddf1f 138\r
139 return EFI_SUCCESS;\r
140}\r
141\r
142EFI_STATUS\r
a5e465a7 143EFIAPI\r
878ddf1f 144RuntimeDriverLibDeconstruct (\r
145 VOID\r
146 )\r
147/*++\r
148\r
149Routine Description:\r
150\r
151 This routine will free some resources which have been allocated in\r
152 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r
153 it must call this routine to free the allocated resource before the exiting.\r
154\r
155Arguments:\r
156\r
157 None\r
158\r
159Returns: \r
160\r
161 EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully\r
162 EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r
163\r
164--*/\r
165{\r
166 EFI_STATUS Status;\r
167\r
878ddf1f 168 //\r
169 // Close SetVirtualAddressMap () notify function\r
170 //\r
f1cd55fe 171 if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r
172 Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r
173 ASSERT_EFI_ERROR (Status);\r
174 }\r
878ddf1f 175\r
176 return EFI_SUCCESS;\r
177}\r
178\r
179BOOLEAN\r
e8a3bee0 180EFIAPI\r
878ddf1f 181EfiAtRuntime (\r
182 VOID\r
183 )\r
184/*++\r
185\r
186Routine Description:\r
187 Return TRUE if ExitBootService () has been called\r
188\r
189Arguments:\r
190 NONE\r
191\r
192Returns: \r
193 TRUE - If ExitBootService () has been called\r
194\r
195--*/\r
196{\r
197 EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r
198 SAL_RETURN_REGS ReturnReg;\r
199\r
200 ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0);\r
201\r
202 return (BOOLEAN) (ReturnReg.r9 == 1);\r
203}\r
204\r
205BOOLEAN\r
e8a3bee0 206EFIAPI\r
878ddf1f 207EfiGoneVirtual (\r
208 VOID\r
209 )\r
210/*++\r
211\r
212Routine Description:\r
213 Return TRUE if SetVirtualAddressMap () has been called\r
214\r
215Arguments:\r
216 NONE\r
217\r
218Returns: \r
219 TRUE - If SetVirtualAddressMap () has been called\r
220\r
221--*/\r
222{\r
223 EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r
224 SAL_RETURN_REGS ReturnReg;\r
225\r
226 ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0);\r
227\r
228 return (BOOLEAN) (ReturnReg.r9 == 1);\r
229}\r
e8a3bee0 230\r