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 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
< EFI_2_00_SYSTEM_TABLE_REVISION
) {
108 DEBUG ((EFI_D_ERROR
, "EFI1.1 can't support LegacyBootEvent!"));
111 return EFI_UNSUPPORTED
;
114 // For UEFI 2.0 and the future use an Event Group
116 Status
= gBS
->CreateEventEx (
121 &gEfiEventLegacyBootGuid
,
130 Create a "Ready to Boot" Event.
132 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
133 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
134 added and now it's possible to not voilate the UEFI specification and use
135 the ready to boot event class defined in UEFI 2.0. This library supports
136 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
139 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
141 @retval EFI_SUCCESS Event was created.
142 @retval Other Event was not created.
147 EfiCreateEventReadyToBoot (
148 OUT EFI_EVENT
*ReadyToBootEvent
151 return EfiCreateEventReadyToBootEx (
153 InternalEmptyFuntion
,
160 Create an EFI event in the Ready To Boot Event Group and allows
161 the caller to specify a notification function.
163 This function abstracts the creation of the Ready to Boot Event.
164 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
165 This library abstracts the caller from how this event is created to prevent
166 to code form having to change with the version of the specification supported.
167 If ReadyToBootEvent is NULL, then ASSERT().
169 @param NotifyTpl The task priority level of the event.
170 @param NotifyFunction The notification function to call when the event is signaled.
171 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
172 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
174 @retval EFI_SUCCESS Event was created.
175 @retval Other Event was not created.
180 EfiCreateEventReadyToBootEx (
181 IN EFI_TPL NotifyTpl
,
182 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
183 IN VOID
*NotifyContext
, OPTIONAL
184 OUT EFI_EVENT
*ReadyToBootEvent
189 ASSERT (ReadyToBootEvent
!= NULL
);
191 if (gST
->Hdr
.Revision
< EFI_2_00_SYSTEM_TABLE_REVISION
) {
192 DEBUG ((EFI_D_ERROR
, "EFI1.1 can't support ReadyToBootEvent!"));
195 return EFI_UNSUPPORTED
;
198 // For UEFI 2.0 and the future use an Event Group
200 Status
= gBS
->CreateEventEx (
205 &gEfiEventReadyToBootGuid
,
215 Signal a Ready to Boot Event.
217 Create a Ready to Boot Event. Signal it and close it. This causes other
218 events of the same event group to be signaled in other modules.
223 EfiSignalEventReadyToBoot (
228 EFI_EVENT ReadyToBootEvent
;
230 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
231 if (!EFI_ERROR (Status
)) {
232 gBS
->SignalEvent (ReadyToBootEvent
);
233 gBS
->CloseEvent (ReadyToBootEvent
);
238 Signal a Legacy Boot Event.
240 Create a legacy Boot Event. Signal it and close it. This causes other
241 events of the same event group to be signaled in other modules.
246 EfiSignalEventLegacyBoot (
251 EFI_EVENT LegacyBootEvent
;
253 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
254 if (!EFI_ERROR (Status
)) {
255 gBS
->SignalEvent (LegacyBootEvent
);
256 gBS
->CloseEvent (LegacyBootEvent
);
262 Check to see if the Firmware Volume (FV) Media Device Path is valid
264 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
265 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
266 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
267 device path is defined for Tiano extensions of device path. If the code
268 is compiled to conform with the UEFI 2.0 specification use the new device path
269 else use the old form for backwards compatability. The return value to this
270 function points to a location in FvDevicePathNode and it does not allocate
271 new memory for the GUID pointer that is returned.
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 Initialize a Firmware Volume (FV) Media Device Path node.
300 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
301 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
302 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
303 device path is defined for Tiano extensions of device path. If the code
304 is compiled to conform with the UEFI 2.0 specification use the new device path
305 else use the old form for backwards compatability.
306 If FvDevicePathNode is NULL, then ASSERT().
307 If NameGuid is NULL, then ASSERT().
309 @param FvFileDevicePathNode Pointer to a FV device path node to initialize
310 @param NameGuid FV file name to use in FvDevicePathNode
315 EfiInitializeFwVolDevicepathNode (
316 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFileDevicePathNode
,
317 IN CONST EFI_GUID
*NameGuid
320 ASSERT (FvFileDevicePathNode
!= NULL
);
321 ASSERT (NameGuid
!= NULL
);
324 // Use the new Device path that does not conflict with the UEFI
326 FvFileDevicePathNode
->Header
.Type
= MEDIA_DEVICE_PATH
;
327 FvFileDevicePathNode
->Header
.SubType
= MEDIA_PIWG_FW_FILE_DP
;
328 SetDevicePathNodeLength (&FvFileDevicePathNode
->Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
330 CopyGuid (&FvFileDevicePathNode
->FvFileName
, NameGuid
);