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