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<BR>
10 All rights reserved. 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 Creates an EFI event in the Legacy Boot Event Group. Prior to UEFI 2.0 this
47 was done via a non blessed UEFI extensions and this library abstracts the
48 implementation mechanism of this event from the caller.
50 This function abstracts the creation of the Legacy Boot Event. The Framework
51 moved from a proprietary to UEFI 2.0 based mechanism. This library abstracts
52 the caller from how this event is created to prevent to code form having to
53 change with the version of the specification supported.
54 If LegacyBootEvent is NULL, then ASSERT().
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 EfiCreateEventLegacyBoot (
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 (gST
->Hdr
.Revision
< EFI_2_00_SYSTEM_TABLE_REVISION
) {
109 DEBUG ((EFI_D_ERROR
, "EFI1.1 can't support LegacyBootEvent!"));
112 return EFI_UNSUPPORTED
;
115 // For UEFI 2.0 and the future use an Event Group
117 Status
= gBS
->CreateEventEx (
122 &gEfiEventLegacyBootGuid
,
131 Create an EFI event in the Ready To Boot Event Group. Prior to UEFI 2.0 this
132 was done via a non-standard UEFI extension, and this library abstracts the
133 implementation mechanism of this event from the caller.
135 This function abstracts the creation of the Ready to Boot Event. The Framework
136 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts
137 the caller from how this event is created to prevent the code form having to
138 change with the version of the specification supported.
139 If ReadyToBootEvent is NULL, then ASSERT().
141 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
143 @retval EFI_SUCCESS Event was created.
144 @retval Other Event was not created.
149 EfiCreateEventReadyToBoot (
150 OUT EFI_EVENT
*ReadyToBootEvent
153 return EfiCreateEventReadyToBootEx (
155 InternalEmptyFuntion
,
162 Create an EFI event in the Ready To Boot Event Group and allows
163 the caller to specify a notification function.
165 This function abstracts the creation of the Ready to Boot Event.
166 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
167 This library abstracts the caller from how this event is created to prevent
168 to code form having to change with the version of the specification supported.
169 If ReadyToBootEvent is NULL, then ASSERT().
171 @param NotifyTpl The task priority level of the event.
172 @param NotifyFunction The notification function to call when the event is signaled.
173 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
174 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
176 @retval EFI_SUCCESS Event was created.
177 @retval Other Event was not created.
182 EfiCreateEventReadyToBootEx (
183 IN EFI_TPL NotifyTpl
,
184 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
185 IN VOID
*NotifyContext
, OPTIONAL
186 OUT EFI_EVENT
*ReadyToBootEvent
191 ASSERT (ReadyToBootEvent
!= NULL
);
193 if (gST
->Hdr
.Revision
< EFI_2_00_SYSTEM_TABLE_REVISION
) {
194 DEBUG ((EFI_D_ERROR
, "EFI1.1 can't support ReadyToBootEvent!"));
197 return EFI_UNSUPPORTED
;
200 // For UEFI 2.0 and the future use an Event Group
202 Status
= gBS
->CreateEventEx (
207 &gEfiEventReadyToBootGuid
,
217 Signal a Ready to Boot Event.
219 Create a Ready to Boot Event. Signal it and close it. This causes other
220 events of the same event group to be signaled in other modules.
225 EfiSignalEventReadyToBoot (
230 EFI_EVENT ReadyToBootEvent
;
232 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
233 if (!EFI_ERROR (Status
)) {
234 gBS
->SignalEvent (ReadyToBootEvent
);
235 gBS
->CloseEvent (ReadyToBootEvent
);
240 Signal a Legacy Boot Event.
242 Create a legacy Boot Event. Signal it and close it. This causes other
243 events of the same event group to be signaled in other modules.
248 EfiSignalEventLegacyBoot (
253 EFI_EVENT LegacyBootEvent
;
255 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
256 if (!EFI_ERROR (Status
)) {
257 gBS
->SignalEvent (LegacyBootEvent
);
258 gBS
->CloseEvent (LegacyBootEvent
);
264 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
265 This library function abstracts validating a device path node.
267 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.
268 If it is valid, then return the GUID file name from the device path node.
269 Otherwise, return NULL. This device path changed in the DXE CIS version 0.92
270 in a non back ward compatible way to not conflict with the UEFI 2.0 specification.
271 This function abstracts the differences from the caller.
272 If FvDevicePathNode is NULL, then ASSERT().
274 @param FvFileDevicePathNode Pointer to FV device path to check.
276 @retval NULL FvDevicePathNode is not valid.
277 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
282 EfiGetNameGuidFromFwVolDevicePathNode (
283 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFileDevicePathNode
286 ASSERT (FvFileDevicePathNode
!= NULL
);
288 if (DevicePathType (&FvFileDevicePathNode
->Header
) == MEDIA_DEVICE_PATH
&&
289 DevicePathSubType (&FvFileDevicePathNode
->Header
) == MEDIA_PIWG_FW_FILE_DP
) {
290 return (EFI_GUID
*) &FvFileDevicePathNode
->FvFileName
;
298 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.
299 This library function abstracts initializing a device path node.
301 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device
302 path changed in the DXE CIS version 0.92 in a non back ward compatible way to
303 not conflict with the UEFI 2.0 specification. This function abstracts the
304 differences from the caller.
305 If FvDevicePathNode is NULL, then ASSERT().
306 If NameGuid is NULL, then ASSERT().
308 @param FvFileDevicePathNode Pointer to a FV device path node to initialize
309 @param NameGuid FV file name to use in FvDevicePathNode
314 EfiInitializeFwVolDevicepathNode (
315 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFileDevicePathNode
,
316 IN CONST EFI_GUID
*NameGuid
319 ASSERT (FvFileDevicePathNode
!= NULL
);
320 ASSERT (NameGuid
!= NULL
);
323 // Use the new Device path that does not conflict with the UEFI
325 FvFileDevicePathNode
->Header
.Type
= MEDIA_DEVICE_PATH
;
326 FvFileDevicePathNode
->Header
.SubType
= MEDIA_PIWG_FW_FILE_DP
;
327 SetDevicePathNodeLength (&FvFileDevicePathNode
->Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
329 CopyGuid (&FvFileDevicePathNode
->FvFileName
, NameGuid
);