2 Library functions that abstract areas of conflict between framework and UEFI 2.0.
4 Help Port Framework code that has conflicts with UEFI 2.0 by hiding the
5 old conflicts with library functions and supporting implementations of the old
6 (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. This module is a DXE driver as
7 it contains DXE enum extensions for EFI event services.
9 Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
10 This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #include "UefiLibInternal.h"
25 An empty function to pass error checking of CreateEventEx ().
27 This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error
28 checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
30 @param Event Event whose notification function is being invoked.
31 @param Context Pointer to the notification function's context,
32 which is implementation-dependent.
37 InternalEmptyFuntion (
46 Create a Legacy Boot Event.
48 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
49 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
50 added and now it's possible to not voilate the UEFI specification by
51 declaring a GUID for the legacy boot event class. This library supports
52 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
55 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
57 @retval EFI_SUCCESS Event was created.
58 @retval Other Event was not created.
63 EfiCreateEventLegacyBoot (
64 OUT EFI_EVENT
*LegacyBootEvent
67 return EfiCreateEventLegacyBootEx (
76 Create an EFI event in the Legacy Boot Event Group and allows
77 the caller to specify a notification function.
79 This function abstracts the creation of the Legacy Boot Event.
80 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
81 This library abstracts the caller from how this event is created to prevent
82 to code form having to change with the version of the specification supported.
83 If LegacyBootEvent is NULL, then ASSERT().
85 @param NotifyTpl The task priority level of the event.
86 @param NotifyFunction The notification function to call when the event is signaled.
87 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
88 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
90 @retval EFI_SUCCESS Event was created.
91 @retval Other Event was not created.
96 EfiCreateEventLegacyBootEx (
98 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
99 IN VOID
*NotifyContext
, OPTIONAL
100 OUT EFI_EVENT
*LegacyBootEvent
105 ASSERT (LegacyBootEvent
!= NULL
);
107 if (gST
->Hdr
.Revision
< 0x00020000) {
109 // prior to UEFI 2.0 use Tiano extension to EFI
111 Status
= gBS
->CreateEvent (
112 EFI_EVENT_SIGNAL_LEGACY_BOOT
| EVT_NOTIFY_SIGNAL
,
120 // For UEFI 2.0 and the future use an Event Group
122 Status
= gBS
->CreateEventEx (
127 &gEfiEventLegacyBootGuid
,
136 Create a Read to Boot Event.
138 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
139 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
140 added and now it's possible to not voilate the UEFI specification and use
141 the ready to boot event class defined in UEFI 2.0. This library supports
142 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
145 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
147 @retval EFI_SUCCESS Event was created.
148 @retval Other Event was not created.
153 EfiCreateEventReadyToBoot (
154 OUT EFI_EVENT
*ReadyToBootEvent
157 return EfiCreateEventReadyToBootEx (
159 InternalEmptyFuntion
,
166 Create an EFI event in the Ready To Boot Event Group and allows
167 the caller to specify a notification function.
169 This function abstracts the creation of the Ready to Boot Event.
170 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
171 This library abstracts the caller from how this event is created to prevent
172 to code form having to change with the version of the specification supported.
173 If ReadyToBootEvent is NULL, then ASSERT().
175 @param NotifyTpl The task priority level of the event.
176 @param NotifyFunction The notification function to call when the event is signaled.
177 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
178 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
180 @retval EFI_SUCCESS Event was created.
181 @retval Other Event was not created.
186 EfiCreateEventReadyToBootEx (
187 IN EFI_TPL NotifyTpl
,
188 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
189 IN VOID
*NotifyContext
, OPTIONAL
190 OUT EFI_EVENT
*ReadyToBootEvent
195 ASSERT (ReadyToBootEvent
!= NULL
);
197 if (gST
->Hdr
.Revision
< 0x00020000) {
199 // prior to UEFI 2.0 use Tiano extension to EFI
201 Status
= gBS
->CreateEvent (
202 EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
210 // For UEFI 2.0 and the future use an Event Group
212 Status
= gBS
->CreateEventEx (
217 &gEfiEventReadyToBootGuid
,
227 Signal a Ready to Boot Event.
229 Create a Ready to Boot Event. Signal it and close it. This causes other
230 events of the same event group to be signaled in other modules.
235 EfiSignalEventReadyToBoot (
240 EFI_EVENT ReadyToBootEvent
;
242 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
243 if (!EFI_ERROR (Status
)) {
244 gBS
->SignalEvent (ReadyToBootEvent
);
245 gBS
->CloseEvent (ReadyToBootEvent
);
250 Signal a Legacy Boot Event.
252 Create a legacy Boot Event. Signal it and close it. This causes other
253 events of the same event group to be signaled in other modules.
258 EfiSignalEventLegacyBoot (
263 EFI_EVENT LegacyBootEvent
;
265 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
266 if (!EFI_ERROR (Status
)) {
267 gBS
->SignalEvent (LegacyBootEvent
);
268 gBS
->CloseEvent (LegacyBootEvent
);
274 Check to see if the Firmware Volume (FV) Media Device Path is valid
276 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
277 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
278 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
279 device path is defined for Tiano extensions of device path. If the code
280 is compiled to conform with the UEFI 2.0 specification use the new device path
281 else use the old form for backwards compatability. The return value to this
282 function points to a location in FvDevicePathNode and it does not allocate
283 new memory for the GUID pointer that is returned.
285 @param FvDevicePathNode Pointer to FV device path to check.
287 @retval NULL FvDevicePathNode is not valid.
288 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
293 EfiGetNameGuidFromFwVolDevicePathNode (
294 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
297 ASSERT (FvDevicePathNode
!= NULL
);
300 // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
301 // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
302 // EFI 1.10 and UEFI 2.10.
304 if (DevicePathType (&FvDevicePathNode
->Header
) == MEDIA_DEVICE_PATH
&&
305 DevicePathSubType (&FvDevicePathNode
->Header
) == MEDIA_PIWG_FW_FILE_DP
) {
306 return (EFI_GUID
*) &FvDevicePathNode
->FvFileName
;
314 Initialize a Firmware Volume (FV) Media Device Path node.
316 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
317 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
318 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
319 device path is defined for Tiano extensions of device path. If the code
320 is compiled to conform with the UEFI 2.0 specification use the new device path
321 else use the old form for backwards compatability.
323 @param FvDevicePathNode Pointer to a FV device path node to initialize
324 @param NameGuid FV file name to use in FvDevicePathNode
329 EfiInitializeFwVolDevicepathNode (
330 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
331 IN CONST EFI_GUID
*NameGuid
334 ASSERT (FvDevicePathNode
!= NULL
);
335 ASSERT (NameGuid
!= NULL
);
338 // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
339 // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
340 // EFI 1.10 and UEFI 2.10.
342 FvDevicePathNode
->Header
.Type
= MEDIA_DEVICE_PATH
;
343 FvDevicePathNode
->Header
.SubType
= MEDIA_PIWG_FW_FILE_DP
;
344 SetDevicePathNodeLength (&FvDevicePathNode
->Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
346 CopyGuid (&FvDevicePathNode
->FvFileName
, NameGuid
);