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 common header file for this module.
24 #include "UefiLibInternal.h"
27 An empty function to pass error checking of CreateEventEx ().
29 This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error
30 checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
32 @param Event Event whose notification function is being invoked.
33 @param Context Pointer to the notification function's context,
34 which is implementation-dependent.
39 InternalEmptyFuntion (
48 Create a Legacy Boot Event.
50 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
51 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
52 added and now it's possible to not voilate the UEFI specification by
53 declaring a GUID for the legacy boot event class. This library supports
54 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
57 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
59 @retval EFI_SUCCESS Event was created.
60 @retval Other Event was not created.
65 EfiCreateEventLegacyBoot (
66 OUT EFI_EVENT
*LegacyBootEvent
69 return EfiCreateEventLegacyBootEx (
78 Create an EFI event in the Legacy Boot Event Group and allows
79 the caller to specify a notification function.
81 This function abstracts the creation of the Legacy Boot Event.
82 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
83 This library abstracts the caller from how this event is created to prevent
84 to code form having to change with the version of the specification supported.
85 If LegacyBootEvent is NULL, then ASSERT().
87 @param NotifyTpl The task priority level of the event.
88 @param NotifyFunction The notification function to call when the event is signaled.
89 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
90 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
92 @retval EFI_SUCCESS Event was created.
93 @retval Other Event was not created.
98 EfiCreateEventLegacyBootEx (
100 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
101 IN VOID
*NotifyContext
, OPTIONAL
102 OUT EFI_EVENT
*LegacyBootEvent
107 ASSERT (LegacyBootEvent
!= NULL
);
109 if (gST
->Hdr
.Revision
< EFI_2_00_SYSTEM_TABLE_REVISION
) {
110 DEBUG ((EFI_D_ERROR
, "EFI1.1 can't support LegacyBootEvent!"));
113 return EFI_UNSUPPORTED
;
116 // For UEFI 2.0 and the future use an Event Group
118 Status
= gBS
->CreateEventEx (
123 &gEfiEventLegacyBootGuid
,
132 Create a "Ready to Boot" Event.
134 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
135 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
136 added and now it's possible to not voilate the UEFI specification and use
137 the ready to boot event class defined in UEFI 2.0. This library supports
138 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
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 Check to see if the Firmware Volume (FV) Media Device Path is valid
266 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
267 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
268 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
269 device path is defined for Tiano extensions of device path. If the code
270 is compiled to conform with the UEFI 2.0 specification use the new device path
271 else use the old form for backwards compatability. The return value to this
272 function points to a location in FvDevicePathNode and it does not allocate
273 new memory for the GUID pointer that is returned.
274 If FvDevicePathNode is NULL, then ASSERT().
276 @param FvFileDevicePathNode Pointer to FV device path to check.
278 @retval NULL FvDevicePathNode is not valid.
279 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
284 EfiGetNameGuidFromFwVolDevicePathNode (
285 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFileDevicePathNode
288 ASSERT (FvFileDevicePathNode
!= NULL
);
290 if (DevicePathType (&FvFileDevicePathNode
->Header
) == MEDIA_DEVICE_PATH
&&
291 DevicePathSubType (&FvFileDevicePathNode
->Header
) == MEDIA_PIWG_FW_FILE_DP
) {
292 return (EFI_GUID
*) &FvFileDevicePathNode
->FvFileName
;
300 Initialize a Firmware Volume (FV) Media Device Path node.
302 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
303 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
304 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
305 device path is defined for Tiano extensions of device path. If the code
306 is compiled to conform with the UEFI 2.0 specification use the new device path
307 else use the old form for backwards compatability.
308 If FvDevicePathNode is NULL, then ASSERT().
309 If NameGuid is NULL, then ASSERT().
311 @param FvFileDevicePathNode Pointer to a FV device path node to initialize
312 @param NameGuid FV file name to use in FvDevicePathNode
317 EfiInitializeFwVolDevicepathNode (
318 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFileDevicePathNode
,
319 IN CONST EFI_GUID
*NameGuid
322 ASSERT (FvFileDevicePathNode
!= NULL
);
323 ASSERT (NameGuid
!= NULL
);
326 // Use the new Device path that does not conflict with the UEFI
328 FvFileDevicePathNode
->Header
.Type
= MEDIA_DEVICE_PATH
;
329 FvFileDevicePathNode
->Header
.SubType
= MEDIA_PIWG_FW_FILE_DP
;
330 SetDevicePathNodeLength (&FvFileDevicePathNode
->Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
332 CopyGuid (&FvFileDevicePathNode
->FvFileName
, NameGuid
);