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