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