2 Library functions that abstract areas of conflict between Tiano an UEFI 2.0.
4 Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the
5 oldconflicts with library functions and supporting implementations of the old
6 (R8.5/EFI 1.10) and new (R9/UEFI 2.0) way.
8 Copyright (c) 2006, Intel Corporation<BR>
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 An empty function to pass error checking of CreateEventEx ().
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.
27 InternalEmptyFuntion (
36 Create a Legacy Boot Event.
38 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
39 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
40 added and now it's possible to not voilate the UEFI specification by
41 declaring a GUID for the legacy boot event class. This library supports
42 the R8.5/EFI 1.10 form and R9/UEFI 2.0 form and allows common code to
45 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
47 @retval EFI_SUCCESS Event was created.
48 @retval Other Event was not created.
53 EfiCreateEventLegacyBoot (
54 OUT EFI_EVENT
*LegacyBootEvent
57 return EfiCreateEventLegacyBootEx (
66 Create an EFI event in the Legacy Boot Event Group and allows
67 the caller to specify a notification function.
69 This function abstracts the creation of the Legacy Boot Event.
70 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
71 This library abstracts the caller from how this event is created to prevent
72 to code form having to change with the version of the specification supported.
73 If LegacyBootEvent is NULL, then ASSERT().
75 @param NotifyTpl The task priority level of the event.
76 @param NotifyFunction The notification function to call when the event is signaled.
77 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
78 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
80 @retval EFI_SUCCESS Event was created.
81 @retval Other Event was not created.
86 EfiCreateEventLegacyBootEx (
88 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
89 IN VOID
*NotifyContext
, OPTIONAL
90 OUT EFI_EVENT
*LegacyBootEvent
95 ASSERT (LegacyBootEvent
!= NULL
);
97 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
99 // prior to UEFI 2.0 use Tiano extension to EFI
101 Status
= gBS
->CreateEvent (
102 EFI_EVENT_SIGNAL_LEGACY_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
110 // For UEFI 2.0 and the future use an Event Group
112 Status
= gBS
->CreateEventEx (
117 &gEfiEventLegacyBootGuid
,
126 Create a Read to Boot Event.
128 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
129 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
130 added and now it's possible to not voilate the UEFI specification and use
131 the ready to boot event class defined in UEFI 2.0. This library supports
132 the R8.5/EFI 1.10 form and R9/UEFI 2.0 form and allows common code to
135 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
137 @retval EFI_SUCCESS Event was created.
138 @retval Other Event was not created.
143 EfiCreateEventReadyToBoot (
144 OUT EFI_EVENT
*ReadyToBootEvent
147 return EfiCreateEventReadyToBootEx (
149 InternalEmptyFuntion
,
156 Create an EFI event in the Ready To Boot Event Group and allows
157 the caller to specify a notification function.
159 This function abstracts the creation of the Ready to Boot Event.
160 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
161 This library abstracts the caller from how this event is created to prevent
162 to code form having to change with the version of the specification supported.
163 If ReadyToBootEvent is NULL, then ASSERT().
165 @param NotifyTpl The task priority level of the event.
166 @param NotifyFunction The notification function to call when the event is signaled.
167 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
168 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
170 @retval EFI_SUCCESS Event was created.
171 @retval Other Event was not created.
176 EfiCreateEventReadyToBootEx (
177 IN EFI_TPL NotifyTpl
,
178 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
179 IN VOID
*NotifyContext
, OPTIONAL
180 OUT EFI_EVENT
*ReadyToBootEvent
185 ASSERT (ReadyToBootEvent
!= NULL
);
187 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
189 // prior to UEFI 2.0 use Tiano extension to EFI
191 Status
= gBS
->CreateEvent (
192 EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
200 // For UEFI 2.0 and the future use an Event Group
202 Status
= gBS
->CreateEventEx (
207 &gEfiEventReadyToBootGuid
,
217 Signal a Ready to Boot Event.
219 Create a Ready to Boot Event. Signal it and close it. This causes other
220 events of the same event group to be signaled in other modules.
225 EfiSignalEventReadyToBoot (
230 EFI_EVENT ReadyToBootEvent
;
232 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
233 if (!EFI_ERROR (Status
)) {
234 gBS
->SignalEvent (ReadyToBootEvent
);
235 gBS
->CloseEvent (ReadyToBootEvent
);
240 Signal a Legacy Boot Event.
242 Create a legacy Boot Event. Signal it and close it. This causes other
243 events of the same event group to be signaled in other modules.
248 EfiSignalEventLegacyBoot (
253 EFI_EVENT LegacyBootEvent
;
255 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
256 if (!EFI_ERROR (Status
)) {
257 gBS
->SignalEvent (LegacyBootEvent
);
258 gBS
->CloseEvent (LegacyBootEvent
);
264 Check to see if the Firmware Volume (FV) Media Device Path is valid
266 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
267 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
268 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
269 device path is defined for PIWG extensions of device path. If the code
270 is compiled to conform with the UEFI 2.0 specification use the new device path
271 else use the old form for backwards compatability. The return value to this
272 function points to a location in FvDevicePathNode and it does not allocate
273 new memory for the GUID pointer that is returned.
275 @param FvDevicePathNode Pointer to FV device path to check.
277 @retval NULL FvDevicePathNode is not valid.
278 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
283 EfiGetNameGuidFromFwVolDevicePathNode (
284 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
287 ASSERT (FvDevicePathNode
!= NULL
);
289 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
291 // Use old Device Path that conflicts with UEFI
293 if (DevicePathType (&FvDevicePathNode
->Header
) == MEDIA_DEVICE_PATH
||
294 DevicePathSubType (&FvDevicePathNode
->Header
) == MEDIA_FV_FILEPATH_DP
) {
295 return (EFI_GUID
*) &FvDevicePathNode
->NameGuid
;
300 // Use the new Device path that does not conflict with the UEFI
302 if (FvDevicePathNode
->Piwg
.Header
.Type
== MEDIA_DEVICE_PATH
||
303 FvDevicePathNode
->Piwg
.Header
.SubType
== MEDIA_VENDOR_DP
) {
304 if (CompareGuid (&gEfiFrameworkDevicePathGuid
, &FvDevicePathNode
->Piwg
.PiwgSpecificDevicePath
)) {
305 if (FvDevicePathNode
->Piwg
.Type
== PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
) {
306 return (EFI_GUID
*) &FvDevicePathNode
->NameGuid
;
316 Initialize a Firmware Volume (FV) Media Device Path node.
318 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
319 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
320 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
321 device path is defined for PIWG extensions of device path. If the code
322 is compiled to conform with the UEFI 2.0 specification use the new device path
323 else use the old form for backwards compatability.
325 @param FvDevicePathNode Pointer to a FV device path node to initialize
326 @param NameGuid FV file name to use in FvDevicePathNode
331 EfiInitializeFwVolDevicepathNode (
332 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
333 IN CONST EFI_GUID
*NameGuid
336 ASSERT (FvDevicePathNode
!= NULL
);
337 ASSERT (NameGuid
!= NULL
);
339 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
341 // Use old Device Path that conflicts with UEFI
343 FvDevicePathNode
->Header
.Type
= MEDIA_DEVICE_PATH
;
344 FvDevicePathNode
->Header
.SubType
= MEDIA_FV_FILEPATH_DP
;
345 SetDevicePathNodeLength (&FvDevicePathNode
->Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
349 // Use the new Device path that does not conflict with the UEFI
351 FvDevicePathNode
->Piwg
.Header
.Type
= MEDIA_DEVICE_PATH
;
352 FvDevicePathNode
->Piwg
.Header
.SubType
= MEDIA_VENDOR_DP
;
353 SetDevicePathNodeLength (&FvDevicePathNode
->Piwg
.Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
356 // Add the GUID for generic PIWG device paths
358 CopyGuid (&FvDevicePathNode
->Piwg
.PiwgSpecificDevicePath
, &gEfiFrameworkDevicePathGuid
);
361 // Add in the FW Vol File Path PIWG defined inforation
363 FvDevicePathNode
->Piwg
.Type
= PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
;
367 CopyGuid (&FvDevicePathNode
->NameGuid
, NameGuid
);