3 Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Library functions that abstract areas of conflict between Tiano an UEFI 2.0.
20 Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the
21 oldconflicts with library functions and supporting implementations of the old
22 (R8.5/EFI 1.10) and new (EdkII/UEFI 2.0) way.
26 #include "EdkIIGlueUefi.h"
29 An empty function to pass error checking of CreateEventEx ().
31 This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error
32 checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
38 InternalEmptyFuntion (
47 Create a Legacy Boot Event.
49 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
50 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
51 added and now it's possible to not voilate the UEFI specification by
52 declaring a GUID for the legacy boot event class. This library supports
53 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
56 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
58 @retval EFI_SUCCESS Event was created.
59 @retval Other Event was not created.
64 GlueEfiCreateEventLegacyBoot (
65 OUT EFI_EVENT
*LegacyBootEvent
68 return EfiCreateEventLegacyBootEx (
77 Create an EFI event in the Legacy Boot Event Group and allows
78 the caller to specify a notification function.
80 This function abstracts the creation of the Legacy Boot Event.
81 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
82 This library abstracts the caller from how this event is created to prevent
83 to code form having to change with the version of the specification supported.
84 If LegacyBootEvent is NULL, then ASSERT().
86 @param NotifyTpl The task priority level of the event.
87 @param NotifyFunction The notification function to call when the event is signaled.
88 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
89 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
91 @retval EFI_SUCCESS Event was created.
92 @retval Other Event was not created.
97 EfiCreateEventLegacyBootEx (
99 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
100 IN VOID
*NotifyContext
, OPTIONAL
101 OUT EFI_EVENT
*LegacyBootEvent
106 ASSERT (LegacyBootEvent
!= NULL
);
108 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
110 // prior to UEFI 2.0 use Tiano extension to EFI
112 Status
= gBS
->CreateEvent (
113 EFI_EVENT_SIGNAL_LEGACY_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
121 // For UEFI 2.0 and the future use an Event Group
123 Status
= gBS
->CreateEventEx (
128 &gEfiEventLegacyBootGuid
,
137 Create a Read to Boot Event.
139 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
140 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
141 added and now it's possible to not voilate the UEFI specification and use
142 the ready to boot event class defined in UEFI 2.0. This library supports
143 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
146 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
148 @retval EFI_SUCCESS Event was created.
149 @retval Other Event was not created.
154 GlueEfiCreateEventReadyToBoot (
155 OUT EFI_EVENT
*ReadyToBootEvent
158 return EfiCreateEventReadyToBootEx (
160 InternalEmptyFuntion
,
167 Create an EFI event in the Ready To Boot Event Group and allows
168 the caller to specify a notification function.
170 This function abstracts the creation of the Ready to Boot Event.
171 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
172 This library abstracts the caller from how this event is created to prevent
173 to code form having to change with the version of the specification supported.
174 If ReadyToBootEvent is NULL, then ASSERT().
176 @param NotifyTpl The task priority level of the event.
177 @param NotifyFunction The notification function to call when the event is signaled.
178 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
179 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
181 @retval EFI_SUCCESS Event was created.
182 @retval Other Event was not created.
187 EfiCreateEventReadyToBootEx (
188 IN EFI_TPL NotifyTpl
,
189 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
190 IN VOID
*NotifyContext
, OPTIONAL
191 OUT EFI_EVENT
*ReadyToBootEvent
196 ASSERT (ReadyToBootEvent
!= NULL
);
198 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
200 // prior to UEFI 2.0 use Tiano extension to EFI
202 Status
= gBS
->CreateEvent (
203 EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
211 // For UEFI 2.0 and the future use an Event Group
213 Status
= gBS
->CreateEventEx (
218 &gEfiEventReadyToBootGuid
,
228 Signal a Ready to Boot Event.
230 Create a Ready to Boot Event. Signal it and close it. This causes other
231 events of the same event group to be signaled in other modules.
236 EfiSignalEventReadyToBoot (
241 EFI_EVENT ReadyToBootEvent
;
243 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
244 if (!EFI_ERROR (Status
)) {
245 gBS
->SignalEvent (ReadyToBootEvent
);
246 gBS
->CloseEvent (ReadyToBootEvent
);
251 Signal a Legacy Boot Event.
253 Create a legacy Boot Event. Signal it and close it. This causes other
254 events of the same event group to be signaled in other modules.
259 EfiSignalEventLegacyBoot (
264 EFI_EVENT LegacyBootEvent
;
266 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
267 if (!EFI_ERROR (Status
)) {
268 gBS
->SignalEvent (LegacyBootEvent
);
269 gBS
->CloseEvent (LegacyBootEvent
);
275 Check to see if the Firmware Volume (FV) Media Device Path is valid
277 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
278 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
279 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
280 device path is defined for PIWG extensions of device path. If the code
281 is compiled to conform with the UEFI 2.0 specification use the new device path
282 else use the old form for backwards compatability. The return value to this
283 function points to a location in FvDevicePathNode and it does not allocate
284 new memory for the GUID pointer that is returned.
286 @param FvDevicePathNode Pointer to FV device path to check.
288 @retval NULL FvDevicePathNode is not valid.
289 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
294 GlueEfiGetNameGuidFromFwVolDevicePathNode (
295 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
298 ASSERT (FvDevicePathNode
!= NULL
);
301 // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
302 // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
303 // EFI 1.10 and UEFI 2.10.
305 if (DevicePathType (&FvDevicePathNode
->Header
) == MEDIA_DEVICE_PATH
&&
306 DevicePathSubType (&FvDevicePathNode
->Header
) == MEDIA_FV_FILEPATH_DP
) {
307 return (EFI_GUID
*) &FvDevicePathNode
->NameGuid
;
315 Initialize a Firmware Volume (FV) Media Device Path node.
317 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
318 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
319 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
320 device path is defined for PIWG extensions of device path. If the code
321 is compiled to conform with the UEFI 2.0 specification use the new device path
322 else use the old form for backwards compatability.
324 @param FvDevicePathNode Pointer to a FV device path node to initialize
325 @param NameGuid FV file name to use in FvDevicePathNode
330 GlueEfiInitializeFwVolDevicepathNode (
331 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
332 IN CONST EFI_GUID
*NameGuid
335 ASSERT (FvDevicePathNode
!= NULL
);
336 ASSERT (NameGuid
!= NULL
);
339 // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
340 // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
341 // EFI 1.10 and UEFI 2.10.
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
));
347 CopyGuid (&FvDevicePathNode
->NameGuid
, NameGuid
);