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