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
,
112 } else if (gST
->Hdr
.Revision
>= 0x00020000 ) {
114 // For UEFI 2.0 and the future use an Event Group
116 Status
= gBS
->CreateEventEx (
121 &gEfiEventLegacyBootGuid
,
126 // For EFI 1.10 with no Tiano extensions return unsupported
128 Status
= EFI_UNSUPPORTED
;
135 Create a Read to Boot Event.
137 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
138 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
139 added and now it's possible to not voilate the UEFI specification and use
140 the ready to boot event class defined in UEFI 2.0. This library supports
141 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
144 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
146 @retval EFI_SUCCESS Event was created.
147 @retval Other Event was not created.
152 EfiCreateEventReadyToBoot (
153 OUT EFI_EVENT
*ReadyToBootEvent
156 return EfiCreateEventReadyToBootEx (
158 InternalEmptyFuntion
,
165 Create an EFI event in the Ready To Boot Event Group and allows
166 the caller to specify a notification function.
168 This function abstracts the creation of the Ready to Boot Event.
169 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
170 This library abstracts the caller from how this event is created to prevent
171 to code form having to change with the version of the specification supported.
172 If ReadyToBootEvent is NULL, then ASSERT().
174 @param NotifyTpl The task priority level of the event.
175 @param NotifyFunction The notification function to call when the event is signaled.
176 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
177 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
179 @retval EFI_SUCCESS Event was created.
180 @retval Other Event was not created.
185 EfiCreateEventReadyToBootEx (
186 IN EFI_TPL NotifyTpl
,
187 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
188 IN VOID
*NotifyContext
, OPTIONAL
189 OUT EFI_EVENT
*ReadyToBootEvent
194 ASSERT (ReadyToBootEvent
!= NULL
);
196 if (gST
->Hdr
.Revision
< 0x00020000) {
198 // prior to UEFI 2.0 use Tiano extension to EFI
200 Status
= gBS
->CreateEvent (
201 EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
207 } else if (gST
->Hdr
.Revision
>= 0x00020000) {
209 // For UEFI 2.0 and the future use an Event Group
211 Status
= gBS
->CreateEventEx (
216 &gEfiEventReadyToBootGuid
,
221 // For EFI 1.10 with no Tiano extensions return unsupported
223 Status
= EFI_UNSUPPORTED
;
231 Signal a Ready to Boot Event.
233 Create a Ready to Boot Event. Signal it and close it. This causes other
234 events of the same event group to be signaled in other modules.
239 EfiSignalEventReadyToBoot (
244 EFI_EVENT ReadyToBootEvent
;
246 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
247 if (!EFI_ERROR (Status
)) {
248 gBS
->SignalEvent (ReadyToBootEvent
);
249 gBS
->CloseEvent (ReadyToBootEvent
);
254 Signal a Legacy Boot Event.
256 Create a legacy Boot Event. Signal it and close it. This causes other
257 events of the same event group to be signaled in other modules.
262 EfiSignalEventLegacyBoot (
267 EFI_EVENT LegacyBootEvent
;
269 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
270 if (!EFI_ERROR (Status
)) {
271 gBS
->SignalEvent (LegacyBootEvent
);
272 gBS
->CloseEvent (LegacyBootEvent
);
278 Check to see if the Firmware Volume (FV) Media Device Path is valid
280 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
281 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
282 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
283 device path is defined for Tiano extensions of device path. If the code
284 is compiled to conform with the UEFI 2.0 specification use the new device path
285 else use the old form for backwards compatability. The return value to this
286 function points to a location in FvDevicePathNode and it does not allocate
287 new memory for the GUID pointer that is returned.
289 @param FvDevicePathNode Pointer to FV device path to check.
291 @retval NULL FvDevicePathNode is not valid.
292 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
297 EfiGetNameGuidFromFwVolDevicePathNode (
298 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
301 ASSERT (FvDevicePathNode
!= NULL
);
304 // Use the new Device path that does not conflict with the UEFI
306 if (FvDevicePathNode
->Tiano
.Header
.Type
== MEDIA_DEVICE_PATH
||
307 FvDevicePathNode
->Tiano
.Header
.SubType
== MEDIA_VENDOR_DP
) {
308 if (CompareGuid (&gEfiFrameworkDevicePathGuid
, &FvDevicePathNode
->Tiano
.TianoSpecificDevicePath
)) {
309 if (FvDevicePathNode
->Tiano
.Type
== TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
) {
310 return (EFI_GUID
*) &FvDevicePathNode
->NameGuid
;
320 Initialize a Firmware Volume (FV) Media Device Path node.
322 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
323 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
324 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
325 device path is defined for Tiano extensions of device path. If the code
326 is compiled to conform with the UEFI 2.0 specification use the new device path
327 else use the old form for backwards compatability.
329 @param FvDevicePathNode Pointer to a FV device path node to initialize
330 @param NameGuid FV file name to use in FvDevicePathNode
335 EfiInitializeFwVolDevicepathNode (
336 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
337 IN CONST EFI_GUID
*NameGuid
340 ASSERT (FvDevicePathNode
!= NULL
);
341 ASSERT (NameGuid
!= NULL
);
344 // Use the new Device path that does not conflict with the UEFI
346 FvDevicePathNode
->Tiano
.Header
.Type
= MEDIA_DEVICE_PATH
;
347 FvDevicePathNode
->Tiano
.Header
.SubType
= MEDIA_VENDOR_DP
;
348 SetDevicePathNodeLength (&FvDevicePathNode
->Tiano
.Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
351 // Add the GUID for generic Tiano device paths
353 CopyGuid (&FvDevicePathNode
->Tiano
.TianoSpecificDevicePath
, &gEfiFrameworkDevicePathGuid
);
356 // Add in the FW Vol File Path Tiano defined information
358 FvDevicePathNode
->Tiano
.Type
= TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
;
360 CopyGuid (&FvDevicePathNode
->NameGuid
, NameGuid
);