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 An empty function to pass error checking of CreateEventEx ().
24 This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error
25 checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
31 InternalEmptyFuntion (
40 Create a Legacy Boot Event.
42 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
43 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
44 added and now it's possible to not voilate the UEFI specification by
45 declaring a GUID for the legacy boot event class. This library supports
46 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
49 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
51 @retval EFI_SUCCESS Event was created.
52 @retval Other Event was not created.
57 EfiCreateEventLegacyBoot (
58 OUT EFI_EVENT
*LegacyBootEvent
61 return EfiCreateEventLegacyBootEx (
70 Create an EFI event in the Legacy Boot Event Group and allows
71 the caller to specify a notification function.
73 This function abstracts the creation of the Legacy Boot Event.
74 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
75 This library abstracts the caller from how this event is created to prevent
76 to code form having to change with the version of the specification supported.
77 If LegacyBootEvent is NULL, then ASSERT().
79 @param NotifyTpl The task priority level of the event.
80 @param NotifyFunction The notification function to call when the event is signaled.
81 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
82 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
84 @retval EFI_SUCCESS Event was created.
85 @retval Other Event was not created.
90 EfiCreateEventLegacyBootEx (
92 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
93 IN VOID
*NotifyContext
, OPTIONAL
94 OUT EFI_EVENT
*LegacyBootEvent
99 ASSERT (LegacyBootEvent
!= NULL
);
101 if (gST
->Hdr
.Revision
< 0x00020000) {
103 // prior to UEFI 2.0 use Tiano extension to EFI
105 Status
= gBS
->CreateEvent (
106 EFI_EVENT_SIGNAL_LEGACY_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
114 // For UEFI 2.0 and the future use an Event Group
116 Status
= gBS
->CreateEventEx (
121 &gEfiEventLegacyBootGuid
,
130 Create a Read 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 LegacyBootEvent 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 LegacyBootEvent 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
< 0x00020000) {
193 // prior to UEFI 2.0 use Tiano extension to EFI
195 Status
= gBS
->CreateEvent (
196 EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
204 // For UEFI 2.0 and the future use an Event Group
206 Status
= gBS
->CreateEventEx (
211 &gEfiEventReadyToBootGuid
,
221 Signal a Ready to Boot Event.
223 Create a Ready to Boot Event. Signal it and close it. This causes other
224 events of the same event group to be signaled in other modules.
229 EfiSignalEventReadyToBoot (
234 EFI_EVENT ReadyToBootEvent
;
236 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
237 if (!EFI_ERROR (Status
)) {
238 gBS
->SignalEvent (ReadyToBootEvent
);
239 gBS
->CloseEvent (ReadyToBootEvent
);
244 Signal a Legacy Boot Event.
246 Create a legacy Boot Event. Signal it and close it. This causes other
247 events of the same event group to be signaled in other modules.
252 EfiSignalEventLegacyBoot (
257 EFI_EVENT LegacyBootEvent
;
259 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
260 if (!EFI_ERROR (Status
)) {
261 gBS
->SignalEvent (LegacyBootEvent
);
262 gBS
->CloseEvent (LegacyBootEvent
);
268 Check to see if the Firmware Volume (FV) Media Device Path is valid
270 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
271 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
272 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
273 device path is defined for Tiano extensions of device path. If the code
274 is compiled to conform with the UEFI 2.0 specification use the new device path
275 else use the old form for backwards compatability. The return value to this
276 function points to a location in FvDevicePathNode and it does not allocate
277 new memory for the GUID pointer that is returned.
279 @param FvDevicePathNode Pointer to FV device path to check.
281 @retval NULL FvDevicePathNode is not valid.
282 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
287 EfiGetNameGuidFromFwVolDevicePathNode (
288 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
291 ASSERT (FvDevicePathNode
!= NULL
);
294 // Use the new Device path that does not conflict with the UEFI
296 if (FvDevicePathNode
->Tiano
.Header
.Type
== MEDIA_DEVICE_PATH
||
297 FvDevicePathNode
->Tiano
.Header
.SubType
== MEDIA_VENDOR_DP
) {
298 if (CompareGuid (&gEfiFrameworkDevicePathGuid
, &FvDevicePathNode
->Tiano
.TianoSpecificDevicePath
)) {
299 if (FvDevicePathNode
->Tiano
.Type
== TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
) {
300 return (EFI_GUID
*) &FvDevicePathNode
->NameGuid
;
310 Initialize a Firmware Volume (FV) Media Device Path node.
312 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
313 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
314 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
315 device path is defined for Tiano extensions of device path. If the code
316 is compiled to conform with the UEFI 2.0 specification use the new device path
317 else use the old form for backwards compatability.
319 @param FvDevicePathNode Pointer to a FV device path node to initialize
320 @param NameGuid FV file name to use in FvDevicePathNode
325 EfiInitializeFwVolDevicepathNode (
326 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
327 IN CONST EFI_GUID
*NameGuid
330 ASSERT (FvDevicePathNode
!= NULL
);
331 ASSERT (NameGuid
!= NULL
);
334 // Use the new Device path that does not conflict with the UEFI
336 FvDevicePathNode
->Tiano
.Header
.Type
= MEDIA_DEVICE_PATH
;
337 FvDevicePathNode
->Tiano
.Header
.SubType
= MEDIA_VENDOR_DP
;
338 SetDevicePathNodeLength (&FvDevicePathNode
->Tiano
.Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
341 // Add the GUID for generic Tiano device paths
343 CopyGuid (&FvDevicePathNode
->Tiano
.TianoSpecificDevicePath
, &gEfiFrameworkDevicePathGuid
);
346 // Add in the FW Vol File Path Tiano defined information
348 FvDevicePathNode
->Tiano
.Type
= TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
;
350 CopyGuid (&FvDevicePathNode
->NameGuid
, NameGuid
);