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.
22 Create a Legacy Boot Event.
24 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
25 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
26 added and now it's possible to not voilate the UEFI specification by
27 declaring a GUID for the legacy boot event class. This library supports
28 the R8.5/EFI 1.10 form and R9/UEFI 2.0 form and allows common code to
31 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
33 @retval EFI_SUCCESS Event was created.
34 @retval Other Event was not created.
39 EfiCreateEventLegacyBoot (
40 OUT EFI_EVENT
*LegacyBootEvent
45 ASSERT (LegacyBootEvent
!= NULL
);
47 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
49 // prior to UEFI 2.0 use Tiano extension to EFI
51 Status
= gBS
->CreateEvent (
52 EFI_EVENT_SIGNAL_LEGACY_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
60 // For UEFI 2.0 and the future use an Event Group
62 Status
= gBS
->CreateEventEx (
67 &gEfiEventLegacyBootGuid
,
77 Create a Read to Boot Event.
79 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
80 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
81 added and now it's possible to not voilate the UEFI specification and use
82 the ready to boot event class defined in UEFI 2.0. This library supports
83 the R8.5/EFI 1.10 form and R9/UEFI 2.0 form and allows common code to
86 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
88 @retval EFI_SUCCESS Event was created.
89 @retval Other Event was not created.
94 EfiCreateEventReadyToBoot (
95 OUT EFI_EVENT
*ReadyToBootEvent
100 ASSERT (ReadyToBootEvent
!= NULL
);
102 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
104 // prior to UEFI 2.0 use Tiano extension to EFI
106 Status
= gBS
->CreateEvent (
107 EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
115 // For UEFI 2.0 and the future use an Event Group
117 Status
= gBS
->CreateEventEx (
122 &gEfiEventReadyToBootGuid
,
132 Signal a Ready to Boot Event.
134 Create a Ready to Boot Event. Signal it and close it. This causes other
135 events of the same event group to be signaled in other modules.
140 EfiSignalEventReadyToBoot (
145 EFI_EVENT ReadyToBootEvent
;
147 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
148 if (!EFI_ERROR (Status
)) {
149 gBS
->SignalEvent (ReadyToBootEvent
);
150 gBS
->CloseEvent (ReadyToBootEvent
);
155 Signal a Legacy Boot Event.
157 Create a legacy Boot Event. Signal it and close it. This causes other
158 events of the same event group to be signaled in other modules.
163 EfiSignalEventLegacyBoot (
168 EFI_EVENT LegacyBootEvent
;
170 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
171 if (!EFI_ERROR (Status
)) {
172 gBS
->SignalEvent (LegacyBootEvent
);
173 gBS
->CloseEvent (LegacyBootEvent
);
179 Check to see if the Firmware Volume (FV) Media Device Path is valid
181 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
182 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
183 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
184 device path is defined for PIWG extensions of device path. If the code
185 is compiled to conform with the UEFI 2.0 specification use the new device path
186 else use the old form for backwards compatability. The return value to this
187 function points to a location in FvDevicePathNode and it does not allocate
188 new memory for the GUID pointer that is returned.
190 @param FvDevicePathNode Pointer to FV device path to check.
192 @retval NULL FvDevicePathNode is not valid.
193 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
198 EfiGetNameGuidFromFwVolDevicePathNode (
199 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
202 ASSERT (FvDevicePathNode
!= NULL
);
204 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
206 // Use old Device Path that conflicts with UEFI
208 if (DevicePathType (&FvDevicePathNode
->Header
) == MEDIA_DEVICE_PATH
||
209 DevicePathSubType (&FvDevicePathNode
->Header
) == MEDIA_FV_FILEPATH_DP
) {
210 return (EFI_GUID
*) &FvDevicePathNode
->NameGuid
;
215 // Use the new Device path that does not conflict with the UEFI
217 if (FvDevicePathNode
->Piwg
.Header
.Type
== MEDIA_DEVICE_PATH
||
218 FvDevicePathNode
->Piwg
.Header
.SubType
== MEDIA_VENDOR_DP
) {
219 if (CompareGuid (&gEfiFrameworkDevicePathGuid
, &FvDevicePathNode
->Piwg
.PiwgSpecificDevicePath
)) {
220 if (FvDevicePathNode
->Piwg
.Type
== PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
) {
221 return (EFI_GUID
*) &FvDevicePathNode
->NameGuid
;
231 Initialize a Firmware Volume (FV) Media Device Path node.
233 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
234 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
235 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
236 device path is defined for PIWG extensions of device path. If the code
237 is compiled to conform with the UEFI 2.0 specification use the new device path
238 else use the old form for backwards compatability.
240 @param FvDevicePathNode Pointer to a FV device path node to initialize
241 @param NameGuid FV file name to use in FvDevicePathNode
246 EfiInitializeFwVolDevicepathNode (
247 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
248 IN CONST EFI_GUID
*NameGuid
251 ASSERT (FvDevicePathNode
!= NULL
);
252 ASSERT (NameGuid
!= NULL
);
254 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
256 // Use old Device Path that conflicts with UEFI
258 FvDevicePathNode
->Header
.Type
= MEDIA_DEVICE_PATH
;
259 FvDevicePathNode
->Header
.SubType
= MEDIA_FV_FILEPATH_DP
;
260 SetDevicePathNodeLength (&FvDevicePathNode
->Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
264 // Use the new Device path that does not conflict with the UEFI
266 FvDevicePathNode
->Piwg
.Header
.Type
= MEDIA_DEVICE_PATH
;
267 FvDevicePathNode
->Piwg
.Header
.SubType
= MEDIA_VENDOR_DP
;
268 SetDevicePathNodeLength (&FvDevicePathNode
->Piwg
.Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
271 // Add the GUID for generic PIWG device paths
273 CopyGuid (&FvDevicePathNode
->Piwg
.PiwgSpecificDevicePath
, &gEfiFrameworkDevicePathGuid
);
276 // Add in the FW Vol File Path PIWG defined inforation
278 FvDevicePathNode
->Piwg
.Type
= PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
;
282 CopyGuid (&FvDevicePathNode
->NameGuid
, NameGuid
);