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