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 - 2018, 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 Create a Legacy Boot Event.
27 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
28 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
29 added and now it's possible to not voilate the UEFI specification by
30 declaring a GUID for the legacy boot event class. This library supports
31 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
34 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
36 @retval EFI_SUCCESS Event was created.
37 @retval Other Event was not created.
42 EfiCreateEventLegacyBoot (
43 OUT EFI_EVENT
*LegacyBootEvent
46 return EfiCreateEventLegacyBootEx (
48 EfiEventEmptyFunction
,
55 Create an EFI event in the Legacy Boot Event Group and allows
56 the caller to specify a notification function.
58 This function abstracts the creation of the Legacy Boot Event.
59 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
60 This library abstracts the caller from how this event is created to prevent
61 to code form having to change with the version of the specification supported.
62 If LegacyBootEvent is NULL, then ASSERT().
64 @param NotifyTpl The task priority level of the event.
65 @param NotifyFunction The notification function to call when the event is signaled.
66 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
67 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
69 @retval EFI_SUCCESS Event was created.
70 @retval Other Event was not created.
75 EfiCreateEventLegacyBootEx (
77 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
78 IN VOID
*NotifyContext
, OPTIONAL
79 OUT EFI_EVENT
*LegacyBootEvent
84 ASSERT (LegacyBootEvent
!= NULL
);
86 if (gST
->Hdr
.Revision
< 0x00020000) {
88 // prior to UEFI 2.0 use Tiano extension to EFI
90 Status
= gBS
->CreateEvent (
91 EFI_EVENT_SIGNAL_LEGACY_BOOT
| EVT_NOTIFY_SIGNAL
,
99 // For UEFI 2.0 and the future use an Event Group
101 Status
= gBS
->CreateEventEx (
106 &gEfiEventLegacyBootGuid
,
115 Create a Read to Boot Event.
117 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
118 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
119 added and now it's possible to not voilate the UEFI specification and use
120 the ready to boot event class defined in UEFI 2.0. This library supports
121 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
124 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
126 @retval EFI_SUCCESS Event was created.
127 @retval Other Event was not created.
132 EfiCreateEventReadyToBoot (
133 OUT EFI_EVENT
*ReadyToBootEvent
136 return EfiCreateEventReadyToBootEx (
138 EfiEventEmptyFunction
,
145 Create an EFI event in the Ready To Boot Event Group and allows
146 the caller to specify a notification function.
148 This function abstracts the creation of the Ready to Boot Event.
149 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
150 This library abstracts the caller from how this event is created to prevent
151 to code form having to change with the version of the specification supported.
152 If ReadyToBootEvent is NULL, then ASSERT().
154 @param NotifyTpl The task priority level of the event.
155 @param NotifyFunction The notification function to call when the event is signaled.
156 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
157 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
159 @retval EFI_SUCCESS Event was created.
160 @retval Other Event was not created.
165 EfiCreateEventReadyToBootEx (
166 IN EFI_TPL NotifyTpl
,
167 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
168 IN VOID
*NotifyContext
, OPTIONAL
169 OUT EFI_EVENT
*ReadyToBootEvent
174 ASSERT (ReadyToBootEvent
!= NULL
);
176 if (gST
->Hdr
.Revision
< 0x00020000) {
178 // prior to UEFI 2.0 use Tiano extension to EFI
180 Status
= gBS
->CreateEvent (
181 EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
189 // For UEFI 2.0 and the future use an Event Group
191 Status
= gBS
->CreateEventEx (
196 &gEfiEventReadyToBootGuid
,
206 Signal a Ready to Boot Event.
208 Create a Ready to Boot Event. Signal it and close it. This causes other
209 events of the same event group to be signaled in other modules.
214 EfiSignalEventReadyToBoot (
219 EFI_EVENT ReadyToBootEvent
;
221 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
222 if (!EFI_ERROR (Status
)) {
223 gBS
->SignalEvent (ReadyToBootEvent
);
224 gBS
->CloseEvent (ReadyToBootEvent
);
229 Signal a Legacy Boot Event.
231 Create a legacy Boot Event. Signal it and close it. This causes other
232 events of the same event group to be signaled in other modules.
237 EfiSignalEventLegacyBoot (
242 EFI_EVENT LegacyBootEvent
;
244 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
245 if (!EFI_ERROR (Status
)) {
246 gBS
->SignalEvent (LegacyBootEvent
);
247 gBS
->CloseEvent (LegacyBootEvent
);
253 Check to see if the Firmware Volume (FV) Media Device Path is valid
255 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
256 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
257 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
258 device path is defined for Tiano extensions of device path. If the code
259 is compiled to conform with the UEFI 2.0 specification use the new device path
260 else use the old form for backwards compatability. The return value to this
261 function points to a location in FvDevicePathNode and it does not allocate
262 new memory for the GUID pointer that is returned.
264 @param FvDevicePathNode Pointer to FV device path to check.
266 @retval NULL FvDevicePathNode is not valid.
267 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
272 EfiGetNameGuidFromFwVolDevicePathNode (
273 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
276 ASSERT (FvDevicePathNode
!= NULL
);
279 // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
280 // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
281 // EFI 1.10 and UEFI 2.10.
283 if (DevicePathType (&FvDevicePathNode
->Header
) == MEDIA_DEVICE_PATH
&&
284 DevicePathSubType (&FvDevicePathNode
->Header
) == MEDIA_PIWG_FW_FILE_DP
) {
285 return (EFI_GUID
*) &FvDevicePathNode
->FvFileName
;
293 Initialize a Firmware Volume (FV) Media Device Path node.
295 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
296 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
297 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
298 device path is defined for Tiano extensions of device path. If the code
299 is compiled to conform with the UEFI 2.0 specification use the new device path
300 else use the old form for backwards compatability.
302 @param FvDevicePathNode Pointer to a FV device path node to initialize
303 @param NameGuid FV file name to use in FvDevicePathNode
308 EfiInitializeFwVolDevicepathNode (
309 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
310 IN CONST EFI_GUID
*NameGuid
313 ASSERT (FvDevicePathNode
!= NULL
);
314 ASSERT (NameGuid
!= NULL
);
317 // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
318 // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
319 // EFI 1.10 and UEFI 2.10.
321 FvDevicePathNode
->Header
.Type
= MEDIA_DEVICE_PATH
;
322 FvDevicePathNode
->Header
.SubType
= MEDIA_PIWG_FW_FILE_DP
;
323 SetDevicePathNodeLength (&FvDevicePathNode
->Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
325 CopyGuid (&FvDevicePathNode
->FvFileName
, NameGuid
);