]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
3e99020d | 3 | Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r |
2c7e5c2f | 4 | This program and the accompanying materials \r |
3eb9473e | 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 | UefiNotTiano.c\r | |
15 | \r | |
16 | Abstract: \r | |
17 | \r | |
18 | Library functions that abstract areas of conflict between Tiano an UEFI 2.0.\r | |
19 | \r | |
20 | Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the\r | |
21 | oldconflicts with library functions and supporting implementations of the old \r | |
22 | (R8.5/EFI 1.10) and new (EdkII/UEFI 2.0) way.\r | |
23 | \r | |
24 | --*/\r | |
25 | \r | |
26 | #include "EdkIIGlueUefi.h"\r | |
27 | \r | |
28 | /**\r | |
29 | An empty function to pass error checking of CreateEventEx (). \r | |
30 | \r | |
31 | This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error\r | |
32 | checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.\r | |
33 | \r | |
34 | **/\r | |
35 | STATIC\r | |
36 | VOID\r | |
37 | EFIAPI\r | |
38 | InternalEmptyFuntion (\r | |
39 | IN EFI_EVENT Event,\r | |
40 | IN VOID *Context\r | |
41 | )\r | |
42 | {\r | |
43 | return;\r | |
44 | }\r | |
45 | \r | |
46 | /**\r | |
47 | Create a Legacy Boot Event. \r | |
48 | \r | |
49 | Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r | |
50 | This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r | |
51 | added and now it's possible to not voilate the UEFI specification by \r | |
52 | declaring a GUID for the legacy boot event class. This library supports\r | |
53 | the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r | |
54 | work both ways.\r | |
55 | \r | |
56 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
57 | \r | |
58 | @retval EFI_SUCCESS Event was created.\r | |
59 | @retval Other Event was not created.\r | |
60 | \r | |
61 | **/\r | |
62 | EFI_STATUS\r | |
63 | EFIAPI\r | |
64 | GlueEfiCreateEventLegacyBoot (\r | |
65 | OUT EFI_EVENT *LegacyBootEvent\r | |
66 | )\r | |
67 | {\r | |
68 | return EfiCreateEventLegacyBootEx (\r | |
69 | EFI_TPL_CALLBACK,\r | |
3e99020d | 70 | NULL,\r |
3eb9473e | 71 | NULL,\r |
72 | LegacyBootEvent\r | |
73 | );\r | |
74 | }\r | |
75 | \r | |
76 | /**\r | |
77 | Create an EFI event in the Legacy Boot Event Group and allows\r | |
78 | the caller to specify a notification function. \r | |
79 | \r | |
80 | This function abstracts the creation of the Legacy Boot Event.\r | |
81 | The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r | |
82 | This library abstracts the caller from how this event is created to prevent\r | |
83 | to code form having to change with the version of the specification supported.\r | |
84 | If LegacyBootEvent is NULL, then ASSERT().\r | |
85 | \r | |
86 | @param NotifyTpl The task priority level of the event.\r | |
87 | @param NotifyFunction The notification function to call when the event is signaled.\r | |
88 | @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r | |
89 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
90 | \r | |
91 | @retval EFI_SUCCESS Event was created.\r | |
92 | @retval Other Event was not created.\r | |
93 | \r | |
94 | **/\r | |
95 | EFI_STATUS\r | |
96 | EFIAPI\r | |
97 | EfiCreateEventLegacyBootEx (\r | |
98 | IN EFI_TPL NotifyTpl,\r | |
99 | IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r | |
100 | IN VOID *NotifyContext, OPTIONAL\r | |
101 | OUT EFI_EVENT *LegacyBootEvent\r | |
102 | )\r | |
103 | {\r | |
3e99020d LG |
104 | EFI_STATUS Status;\r |
105 | UINT32 EventType;\r | |
106 | EFI_EVENT_NOTIFY WorkerNotifyFunction;\r | |
3eb9473e | 107 | \r |
108 | ASSERT (LegacyBootEvent != NULL);\r | |
109 | \r | |
110 | #if (EFI_SPECIFICATION_VERSION < 0x00020000) \r | |
3e99020d LG |
111 | \r |
112 | if (NotifyFunction == NULL) {\r | |
113 | EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;\r | |
114 | } else {\r | |
115 | EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT;\r | |
116 | }\r | |
117 | WorkerNotifyFunction = NotifyFunction;\r | |
118 | \r | |
3eb9473e | 119 | //\r |
120 | // prior to UEFI 2.0 use Tiano extension to EFI\r | |
121 | //\r | |
122 | Status = gBS->CreateEvent (\r | |
3e99020d | 123 | EventType,\r |
3eb9473e | 124 | NotifyTpl,\r |
3e99020d | 125 | WorkerNotifyFunction,\r |
3eb9473e | 126 | NotifyContext,\r |
127 | LegacyBootEvent\r | |
128 | );\r | |
129 | #else\r | |
3e99020d LG |
130 | \r |
131 | EventType = EVENT_NOTIFY_SIGNAL;\r | |
132 | if (NotifyFunction == NULL) {\r | |
133 | //\r | |
134 | // CreatEventEx will check NotifyFunction is NULL or not\r | |
135 | //\r | |
136 | WorkerNotifyFunction = InternalEmptyFuntion;\r | |
137 | } else {\r | |
138 | WorkerNotifyFunction = NotifyFunction;\r | |
139 | }\r | |
140 | \r | |
3eb9473e | 141 | //\r |
142 | // For UEFI 2.0 and the future use an Event Group\r | |
143 | //\r | |
144 | Status = gBS->CreateEventEx (\r | |
3e99020d | 145 | EventType,\r |
3eb9473e | 146 | NotifyTpl,\r |
3e99020d | 147 | WorkerNotifyFunction,\r |
3eb9473e | 148 | NotifyContext,\r |
149 | &gEfiEventLegacyBootGuid,\r | |
150 | LegacyBootEvent\r | |
151 | );\r | |
152 | #endif\r | |
153 | \r | |
154 | return Status;\r | |
155 | }\r | |
156 | \r | |
157 | /**\r | |
158 | Create a Read to Boot Event. \r | |
159 | \r | |
160 | Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r | |
161 | This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r | |
162 | added and now it's possible to not voilate the UEFI specification and use \r | |
163 | the ready to boot event class defined in UEFI 2.0. This library supports\r | |
164 | the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r | |
165 | work both ways.\r | |
166 | \r | |
167 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
168 | \r | |
169 | @retval EFI_SUCCESS Event was created.\r | |
170 | @retval Other Event was not created.\r | |
171 | \r | |
172 | **/\r | |
173 | EFI_STATUS\r | |
174 | EFIAPI\r | |
175 | GlueEfiCreateEventReadyToBoot (\r | |
176 | OUT EFI_EVENT *ReadyToBootEvent\r | |
177 | )\r | |
178 | {\r | |
179 | return EfiCreateEventReadyToBootEx (\r | |
180 | EFI_TPL_CALLBACK,\r | |
3e99020d | 181 | NULL,\r |
3eb9473e | 182 | NULL,\r |
183 | ReadyToBootEvent\r | |
184 | );\r | |
185 | }\r | |
186 | \r | |
187 | /**\r | |
188 | Create an EFI event in the Ready To Boot Event Group and allows\r | |
189 | the caller to specify a notification function. \r | |
190 | \r | |
191 | This function abstracts the creation of the Ready to Boot Event.\r | |
192 | The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r | |
193 | This library abstracts the caller from how this event is created to prevent\r | |
194 | to code form having to change with the version of the specification supported.\r | |
195 | If ReadyToBootEvent is NULL, then ASSERT().\r | |
196 | \r | |
197 | @param NotifyTpl The task priority level of the event.\r | |
198 | @param NotifyFunction The notification function to call when the event is signaled.\r | |
199 | @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r | |
200 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
201 | \r | |
202 | @retval EFI_SUCCESS Event was created.\r | |
203 | @retval Other Event was not created.\r | |
204 | \r | |
205 | **/\r | |
206 | EFI_STATUS\r | |
207 | EFIAPI\r | |
208 | EfiCreateEventReadyToBootEx (\r | |
209 | IN EFI_TPL NotifyTpl,\r | |
210 | IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r | |
211 | IN VOID *NotifyContext, OPTIONAL\r | |
212 | OUT EFI_EVENT *ReadyToBootEvent\r | |
213 | )\r | |
214 | {\r | |
3e99020d LG |
215 | EFI_STATUS Status;\r |
216 | UINT32 EventType;\r | |
217 | EFI_EVENT_NOTIFY WorkerNotifyFunction;\r | |
3eb9473e | 218 | \r |
219 | ASSERT (ReadyToBootEvent != NULL);\r | |
220 | \r | |
3e99020d LG |
221 | #if (EFI_SPECIFICATION_VERSION < 0x00020000)\r |
222 | \r | |
223 | if (NotifyFunction == NULL) {\r | |
224 | EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;\r | |
225 | } else {\r | |
226 | EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT;\r | |
227 | }\r | |
228 | WorkerNotifyFunction = NotifyFunction;\r | |
229 | \r | |
3eb9473e | 230 | //\r |
231 | // prior to UEFI 2.0 use Tiano extension to EFI\r | |
232 | //\r | |
233 | Status = gBS->CreateEvent (\r | |
3e99020d | 234 | EventType,\r |
3eb9473e | 235 | NotifyTpl,\r |
3e99020d | 236 | WorkerNotifyFunction,\r |
3eb9473e | 237 | NotifyContext,\r |
238 | ReadyToBootEvent\r | |
239 | );\r | |
240 | #else\r | |
3e99020d LG |
241 | \r |
242 | EventType = EVENT_NOTIFY_SIGNAL;\r | |
243 | \r | |
244 | if (NotifyFunction == NULL) {\r | |
245 | //\r | |
246 | // CreatEventEx will check NotifyFunction is NULL or not\r | |
247 | //\r | |
248 | WorkerNotifyFunction = InternalEmptyFuntion;\r | |
249 | } else {\r | |
250 | WorkerNotifyFunction = NotifyFunction;\r | |
251 | }\r | |
252 | \r | |
3eb9473e | 253 | //\r |
254 | // For UEFI 2.0 and the future use an Event Group\r | |
255 | //\r | |
256 | Status = gBS->CreateEventEx (\r | |
3e99020d | 257 | EventType,\r |
3eb9473e | 258 | NotifyTpl,\r |
3e99020d | 259 | WorkerNotifyFunction,\r |
3eb9473e | 260 | NotifyContext,\r |
261 | &gEfiEventReadyToBootGuid,\r | |
262 | ReadyToBootEvent\r | |
263 | );\r | |
264 | #endif\r | |
265 | \r | |
266 | return Status;\r | |
267 | }\r | |
268 | \r | |
269 | \r | |
270 | /**\r | |
271 | Signal a Ready to Boot Event. \r | |
272 | \r | |
273 | Create a Ready to Boot Event. Signal it and close it. This causes other \r | |
274 | events of the same event group to be signaled in other modules. \r | |
275 | \r | |
276 | **/\r | |
277 | VOID\r | |
278 | EFIAPI\r | |
279 | EfiSignalEventReadyToBoot (\r | |
280 | VOID\r | |
281 | )\r | |
282 | {\r | |
283 | EFI_STATUS Status;\r | |
284 | EFI_EVENT ReadyToBootEvent;\r | |
285 | \r | |
286 | Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r | |
287 | if (!EFI_ERROR (Status)) {\r | |
288 | gBS->SignalEvent (ReadyToBootEvent);\r | |
289 | gBS->CloseEvent (ReadyToBootEvent);\r | |
290 | }\r | |
291 | }\r | |
292 | \r | |
293 | /**\r | |
294 | Signal a Legacy Boot Event. \r | |
295 | \r | |
296 | Create a legacy Boot Event. Signal it and close it. This causes other \r | |
297 | events of the same event group to be signaled in other modules. \r | |
298 | \r | |
299 | **/\r | |
300 | VOID\r | |
301 | EFIAPI\r | |
302 | EfiSignalEventLegacyBoot (\r | |
303 | VOID\r | |
304 | )\r | |
305 | {\r | |
306 | EFI_STATUS Status;\r | |
307 | EFI_EVENT LegacyBootEvent;\r | |
308 | \r | |
309 | Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);\r | |
310 | if (!EFI_ERROR (Status)) {\r | |
311 | gBS->SignalEvent (LegacyBootEvent);\r | |
312 | gBS->CloseEvent (LegacyBootEvent);\r | |
313 | }\r | |
314 | }\r | |
315 | \r | |
316 | \r | |
317 | /**\r | |
318 | Check to see if the Firmware Volume (FV) Media Device Path is valid \r | |
319 | \r | |
3eb9473e | 320 | @param FvDevicePathNode Pointer to FV device path to check.\r |
321 | \r | |
322 | @retval NULL FvDevicePathNode is not valid.\r | |
323 | @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r | |
324 | \r | |
325 | **/\r | |
326 | EFI_GUID *\r | |
327 | EFIAPI\r | |
328 | GlueEfiGetNameGuidFromFwVolDevicePathNode (\r | |
329 | IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r | |
330 | )\r | |
331 | {\r | |
332 | ASSERT (FvDevicePathNode != NULL);\r | |
333 | \r | |
3eb9473e | 334 | if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r |
335 | DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r | |
336 | return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r | |
337 | }\r | |
338 | \r | |
3eb9473e | 339 | return NULL;\r |
340 | }\r | |
341 | \r | |
342 | \r | |
343 | /**\r | |
344 | Initialize a Firmware Volume (FV) Media Device Path node.\r | |
345 | \r | |
3eb9473e | 346 | @param FvDevicePathNode Pointer to a FV device path node to initialize\r |
347 | @param NameGuid FV file name to use in FvDevicePathNode\r | |
348 | \r | |
349 | **/\r | |
350 | VOID\r | |
351 | EFIAPI\r | |
352 | GlueEfiInitializeFwVolDevicepathNode (\r | |
353 | IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r | |
354 | IN CONST EFI_GUID *NameGuid\r | |
355 | )\r | |
356 | {\r | |
357 | ASSERT (FvDevicePathNode != NULL);\r | |
358 | ASSERT (NameGuid != NULL);\r | |
359 | \r | |
3eb9473e | 360 | FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;\r |
361 | FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;\r | |
362 | SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r | |
3eb9473e | 363 | \r |
3e99020d | 364 | CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);\r |
3eb9473e | 365 | }\r |
366 | \r |