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 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include "UefiLibInternal.h"
17 Creates an EFI event in the Legacy Boot Event Group.
19 Prior to UEFI 2.0 this was done via a non blessed UEFI extensions and this library
20 abstracts the implementation mechanism of this event from the caller. This function
21 abstracts the creation of the Legacy Boot Event. The Framework moved from a proprietary
22 to UEFI 2.0 based mechanism. This library abstracts the caller from how this event
23 is created to prevent to code form having to change with the version of the
24 specification supported.
25 If LegacyBootEvent is NULL, then ASSERT().
27 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
29 @retval EFI_SUCCESS Event was created.
30 @retval Other Event was not created.
35 EfiCreateEventLegacyBoot (
36 OUT EFI_EVENT
*LegacyBootEvent
39 return EfiCreateEventLegacyBootEx (
41 EfiEventEmptyFunction
,
48 Create an EFI event in the Legacy Boot Event Group and allows
49 the caller to specify a notification function.
51 This function abstracts the creation of the Legacy Boot Event.
52 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
53 This library abstracts the caller from how this event is created to prevent
54 to code form having to change with the version of the specification supported.
55 If LegacyBootEvent is NULL, then ASSERT().
57 @param NotifyTpl The task priority level of the event.
58 @param NotifyFunction The notification function to call when the event is signaled.
59 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
60 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
62 @retval EFI_SUCCESS Event was created.
63 @retval Other Event was not created.
68 EfiCreateEventLegacyBootEx (
70 IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL
,
71 IN VOID
*NotifyContext OPTIONAL
,
72 OUT EFI_EVENT
*LegacyBootEvent
76 EFI_EVENT_NOTIFY WorkerNotifyFunction
;
78 ASSERT (LegacyBootEvent
!= NULL
);
80 if (gST
->Hdr
.Revision
< EFI_2_00_SYSTEM_TABLE_REVISION
) {
81 DEBUG ((DEBUG_ERROR
, "EFI1.1 can't support LegacyBootEvent!"));
84 return EFI_UNSUPPORTED
;
87 // For UEFI 2.0 and the future use an Event Group
89 if (NotifyFunction
== NULL
) {
91 // CreateEventEx will check NotifyFunction is NULL or not and return error.
92 // Use dummy routine for the case NotifyFunction is NULL.
94 WorkerNotifyFunction
= EfiEventEmptyFunction
;
96 WorkerNotifyFunction
= NotifyFunction
;
99 Status
= gBS
->CreateEventEx (
102 WorkerNotifyFunction
,
104 &gEfiEventLegacyBootGuid
,
113 Create an EFI event in the Ready To Boot Event Group.
115 Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library
116 abstracts the implementation mechanism of this event from the caller.
117 This function abstracts the creation of the Ready to Boot Event. The Framework
118 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts
119 the caller from how this event is created to prevent the code form having to
120 change with the version of the specification supported.
121 If ReadyToBootEvent is NULL, then ASSERT().
123 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
125 @retval EFI_SUCCESS Event was created.
126 @retval Other Event was not created.
131 EfiCreateEventReadyToBoot (
132 OUT EFI_EVENT
*ReadyToBootEvent
135 return EfiCreateEventReadyToBootEx (
137 EfiEventEmptyFunction
,
144 Create an EFI event in the Ready To Boot Event Group and allows
145 the caller to specify a notification function.
147 This function abstracts the creation of the Ready to Boot Event.
148 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
149 This library abstracts the caller from how this event is created to prevent
150 to code form having to change with the version of the specification supported.
151 If ReadyToBootEvent is NULL, then ASSERT().
153 @param NotifyTpl The task priority level of the event.
154 @param NotifyFunction The notification function to call when the event is signaled.
155 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
156 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
158 @retval EFI_SUCCESS Event was created.
159 @retval Other Event was not created.
164 EfiCreateEventReadyToBootEx (
165 IN EFI_TPL NotifyTpl
,
166 IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL
,
167 IN VOID
*NotifyContext OPTIONAL
,
168 OUT EFI_EVENT
*ReadyToBootEvent
172 EFI_EVENT_NOTIFY WorkerNotifyFunction
;
174 ASSERT (ReadyToBootEvent
!= NULL
);
176 if (gST
->Hdr
.Revision
< EFI_2_00_SYSTEM_TABLE_REVISION
) {
177 DEBUG ((DEBUG_ERROR
, "EFI1.1 can't support ReadyToBootEvent!"));
180 return EFI_UNSUPPORTED
;
183 // For UEFI 2.0 and the future use an Event Group
185 if (NotifyFunction
== NULL
) {
187 // CreateEventEx will check NotifyFunction is NULL or not and return error.
188 // Use dummy routine for the case NotifyFunction is NULL.
190 WorkerNotifyFunction
= EfiEventEmptyFunction
;
192 WorkerNotifyFunction
= NotifyFunction
;
195 Status
= gBS
->CreateEventEx (
198 WorkerNotifyFunction
,
200 &gEfiEventReadyToBootGuid
,
209 Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().
211 This function abstracts the signaling of the Ready to Boot Event. The Framework moved
212 from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller
213 from how this event is created to prevent to code form having to change with the
214 version of the specification supported.
219 EfiSignalEventReadyToBoot (
224 EFI_EVENT ReadyToBootEvent
;
226 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
227 if (!EFI_ERROR (Status
)) {
228 gBS
->SignalEvent (ReadyToBootEvent
);
229 gBS
->CloseEvent (ReadyToBootEvent
);
234 Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().
236 This function abstracts the signaling of the Legacy Boot Event. The Framework moved from
237 a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how
238 this event is created to prevent to code form having to change with the version of the
239 specification supported.
244 EfiSignalEventLegacyBoot (
249 EFI_EVENT LegacyBootEvent
;
251 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
252 if (!EFI_ERROR (Status
)) {
253 gBS
->SignalEvent (LegacyBootEvent
);
254 gBS
->CloseEvent (LegacyBootEvent
);
259 Check to see if the Firmware Volume (FV) Media Device Path is valid
261 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
262 This library function abstracts validating a device path node.
263 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.
264 If it is valid, then return the GUID file name from the device path node. Otherwise,
265 return NULL. This device path changed in the DXE CIS version 0.92 in a non back ward
266 compatible way to not conflict with the UEFI 2.0 specification. This function abstracts
267 the differences from the caller.
268 If FvDevicePathNode is NULL, then ASSERT().
270 @param FvDevicePathNode The pointer to FV device path to check.
272 @retval NULL FvDevicePathNode is not valid.
273 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
278 EfiGetNameGuidFromFwVolDevicePathNode (
279 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
282 ASSERT (FvDevicePathNode
!= NULL
);
284 if ((DevicePathType (&FvDevicePathNode
->Header
) == MEDIA_DEVICE_PATH
) &&
285 (DevicePathSubType (&FvDevicePathNode
->Header
) == MEDIA_PIWG_FW_FILE_DP
))
287 return (EFI_GUID
*)&FvDevicePathNode
->FvFileName
;
294 Initialize a Firmware Volume (FV) Media Device Path node.
296 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
297 This library function abstracts initializing a device path node.
298 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device
299 path changed in the DXE CIS version 0.92 in a non back ward compatible way to
300 not conflict with the UEFI 2.0 specification. This function abstracts the
301 differences from the caller.
302 If FvDevicePathNode is NULL, then ASSERT().
303 If NameGuid is NULL, then ASSERT().
305 @param FvDevicePathNode The pointer to a FV device path node to initialize
306 @param NameGuid FV file name to use in FvDevicePathNode
311 EfiInitializeFwVolDevicepathNode (
312 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
313 IN CONST EFI_GUID
*NameGuid
316 ASSERT (FvDevicePathNode
!= NULL
);
317 ASSERT (NameGuid
!= NULL
);
320 // Use the new Device path that does not conflict with the UEFI
322 FvDevicePathNode
->Header
.Type
= MEDIA_DEVICE_PATH
;
323 FvDevicePathNode
->Header
.SubType
= MEDIA_PIWG_FW_FILE_DP
;
324 SetDevicePathNodeLength (&FvDevicePathNode
->Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
326 CopyGuid (&FvDevicePathNode
->FvFileName
, NameGuid
);