2 Library functions that abstract areas of conflict between Tiano an UEFI 2.0.
4 Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the
5 oldconflicts 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 EFI_EVENT_NOTIFY_SIGNAL_ALL is error
30 checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
36 InternalEmptyFuntion (
45 Create a Legacy Boot Event.
47 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
48 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
49 added and now it's possible to not voilate the UEFI specification by
50 declaring a GUID for the legacy boot event class. This library supports
51 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
54 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
56 @retval EFI_SUCCESS Event was created.
57 @retval Other Event was not created.
62 EfiCreateEventLegacyBoot (
63 OUT EFI_EVENT
*LegacyBootEvent
66 return EfiCreateEventLegacyBootEx (
75 Create an EFI event in the Legacy Boot Event Group and allows
76 the caller to specify a notification function.
78 This function abstracts the creation of the Legacy Boot Event.
79 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
80 This library abstracts the caller from how this event is created to prevent
81 to code form having to change with the version of the specification supported.
82 If LegacyBootEvent is NULL, then ASSERT().
84 @param NotifyTpl The task priority level of the event.
85 @param NotifyFunction The notification function to call when the event is signaled.
86 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
87 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
89 @retval EFI_SUCCESS Event was created.
90 @retval Other Event was not created.
95 EfiCreateEventLegacyBootEx (
97 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
98 IN VOID
*NotifyContext
, OPTIONAL
99 OUT EFI_EVENT
*LegacyBootEvent
104 ASSERT (LegacyBootEvent
!= NULL
);
106 if (gST
->Hdr
.Revision
< EFI_2_00_SYSTEM_TABLE_REVISION
) {
107 DEBUG ((EFI_D_ERROR
, "EFI1.1 can't support LegacyBootEvent!"));
110 return EFI_UNSUPPORTED
;
113 // For UEFI 2.0 and the future use an Event Group
115 Status
= gBS
->CreateEventEx (
120 &gEfiEventLegacyBootGuid
,
129 Create a Read to Boot Event.
131 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
132 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
133 added and now it's possible to not voilate the UEFI specification and use
134 the ready to boot event class defined in UEFI 2.0. This library supports
135 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
138 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
140 @retval EFI_SUCCESS Event was created.
141 @retval Other Event was not created.
146 EfiCreateEventReadyToBoot (
147 OUT EFI_EVENT
*ReadyToBootEvent
150 return EfiCreateEventReadyToBootEx (
152 InternalEmptyFuntion
,
159 Create an EFI event in the Ready To Boot Event Group and allows
160 the caller to specify a notification function.
162 This function abstracts the creation of the Ready to Boot Event.
163 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
164 This library abstracts the caller from how this event is created to prevent
165 to code form having to change with the version of the specification supported.
166 If ReadyToBootEvent is NULL, then ASSERT().
168 @param NotifyTpl The task priority level of the event.
169 @param NotifyFunction The notification function to call when the event is signaled.
170 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
171 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
173 @retval EFI_SUCCESS Event was created.
174 @retval Other Event was not created.
179 EfiCreateEventReadyToBootEx (
180 IN EFI_TPL NotifyTpl
,
181 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
182 IN VOID
*NotifyContext
, OPTIONAL
183 OUT EFI_EVENT
*ReadyToBootEvent
188 ASSERT (ReadyToBootEvent
!= NULL
);
190 if (gST
->Hdr
.Revision
< EFI_2_00_SYSTEM_TABLE_REVISION
) {
191 DEBUG ((EFI_D_ERROR
, "EFI1.1 can't support ReadyToBootEvent!"));
194 return EFI_UNSUPPORTED
;
197 // For UEFI 2.0 and the future use an Event Group
199 Status
= gBS
->CreateEventEx (
204 &gEfiEventReadyToBootGuid
,
214 Signal a Ready to Boot Event.
216 Create a Ready to Boot Event. Signal it and close it. This causes other
217 events of the same event group to be signaled in other modules.
222 EfiSignalEventReadyToBoot (
227 EFI_EVENT ReadyToBootEvent
;
229 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
230 if (!EFI_ERROR (Status
)) {
231 gBS
->SignalEvent (ReadyToBootEvent
);
232 gBS
->CloseEvent (ReadyToBootEvent
);
237 Signal a Legacy Boot Event.
239 Create a legacy Boot Event. Signal it and close it. This causes other
240 events of the same event group to be signaled in other modules.
245 EfiSignalEventLegacyBoot (
250 EFI_EVENT LegacyBootEvent
;
252 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
253 if (!EFI_ERROR (Status
)) {
254 gBS
->SignalEvent (LegacyBootEvent
);
255 gBS
->CloseEvent (LegacyBootEvent
);
261 Check to see if the Firmware Volume (FV) Media Device Path is valid
263 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
264 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
265 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
266 device path is defined for Tiano extensions of device path. If the code
267 is compiled to conform with the UEFI 2.0 specification use the new device path
268 else use the old form for backwards compatability. The return value to this
269 function points to a location in FvDevicePathNode and it does not allocate
270 new memory for the GUID pointer that is returned.
272 @param FvDevicePathNode Pointer to FV device path to check.
274 @retval NULL FvDevicePathNode is not valid.
275 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
280 EfiGetNameGuidFromFwVolDevicePathNode (
281 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFileDevicePathNode
284 ASSERT (FvFileDevicePathNode
!= NULL
);
286 if (FvFileDevicePathNode
->Header
.Type
== MEDIA_DEVICE_PATH
&&
287 FvFileDevicePathNode
->Header
.SubType
== MEDIA_PIWG_FW_FILE_DP
289 return (EFI_GUID
*) &FvFileDevicePathNode
->FvFileName
;
297 Initialize a Firmware Volume (FV) Media Device Path node.
299 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
300 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
301 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
302 device path is defined for Tiano extensions of device path. If the code
303 is compiled to conform with the UEFI 2.0 specification use the new device path
304 else use the old form for backwards compatability.
306 @param FvDevicePathNode Pointer to a FV device path node to initialize
307 @param NameGuid FV file name to use in FvDevicePathNode
312 EfiInitializeFwVolDevicepathNode (
313 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFileDevicePathNode
,
314 IN CONST EFI_GUID
*NameGuid
317 ASSERT (FvFileDevicePathNode
!= NULL
);
318 ASSERT (NameGuid
!= NULL
);
321 // Use the new Device path that does not conflict with the UEFI
323 FvFileDevicePathNode
->Header
.Type
= MEDIA_DEVICE_PATH
;
324 FvFileDevicePathNode
->Header
.SubType
= MEDIA_PIWG_FW_FILE_DP
;
325 SetDevicePathNodeLength (&FvFileDevicePathNode
->Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
327 CopyGuid (&FvFileDevicePathNode
->FvFileName
, NameGuid
);