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, 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.
30 InternalEmptyFuntion (
39 Create a Legacy Boot Event.
41 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
42 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
43 added and now it's possible to not voilate the UEFI specification by
44 declaring a GUID for the legacy boot event class. This library supports
45 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
48 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
50 @retval EFI_SUCCESS Event was created.
51 @retval Other Event was not created.
56 EfiCreateEventLegacyBoot (
57 OUT EFI_EVENT
*LegacyBootEvent
60 return EfiCreateEventLegacyBootEx (
69 Create an EFI event in the Legacy Boot Event Group and allows
70 the caller to specify a notification function.
72 This function abstracts the creation of the Legacy Boot Event.
73 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
74 This library abstracts the caller from how this event is created to prevent
75 to code form having to change with the version of the specification supported.
76 If LegacyBootEvent is NULL, then ASSERT().
78 @param NotifyTpl The task priority level of the event.
79 @param NotifyFunction The notification function to call when the event is signaled.
80 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
81 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
83 @retval EFI_SUCCESS Event was created.
84 @retval Other Event was not created.
89 EfiCreateEventLegacyBootEx (
91 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
92 IN VOID
*NotifyContext
, OPTIONAL
93 OUT EFI_EVENT
*LegacyBootEvent
98 ASSERT (LegacyBootEvent
!= NULL
);
100 #if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))
102 // prior to UEFI 2.0 use Tiano extension to EFI
104 Status
= gBS
->CreateEvent (
105 EFI_EVENT_SIGNAL_LEGACY_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
111 #elif (EFI_SPECIFICATION_VERSION >= 0x00020000)
113 // For UEFI 2.0 and the future use an Event Group
115 Status
= gBS
->CreateEventEx (
120 &gEfiEventLegacyBootGuid
,
125 // For EFI 1.10 with no Tiano extensions return unsupported
127 Status
= EFI_UNSUPORTED
;
134 Create a Read to Boot Event.
136 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
137 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
138 added and now it's possible to not voilate the UEFI specification and use
139 the ready to boot event class defined in UEFI 2.0. This library supports
140 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
143 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
145 @retval EFI_SUCCESS Event was created.
146 @retval Other Event was not created.
151 EfiCreateEventReadyToBoot (
152 OUT EFI_EVENT
*ReadyToBootEvent
155 return EfiCreateEventReadyToBootEx (
157 InternalEmptyFuntion
,
164 Create an EFI event in the Ready To Boot Event Group and allows
165 the caller to specify a notification function.
167 This function abstracts the creation of the Ready to Boot Event.
168 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
169 This library abstracts the caller from how this event is created to prevent
170 to code form having to change with the version of the specification supported.
171 If ReadyToBootEvent is NULL, then ASSERT().
173 @param NotifyTpl The task priority level of the event.
174 @param NotifyFunction The notification function to call when the event is signaled.
175 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
176 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
178 @retval EFI_SUCCESS Event was created.
179 @retval Other Event was not created.
184 EfiCreateEventReadyToBootEx (
185 IN EFI_TPL NotifyTpl
,
186 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
187 IN VOID
*NotifyContext
, OPTIONAL
188 OUT EFI_EVENT
*ReadyToBootEvent
193 ASSERT (ReadyToBootEvent
!= NULL
);
195 #if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))
197 // prior to UEFI 2.0 use Tiano extension to EFI
199 Status
= gBS
->CreateEvent (
200 EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
206 #elif (EFI_SPECIFICATION_VERSION >= 0x00020000)
208 // For UEFI 2.0 and the future use an Event Group
210 Status
= gBS
->CreateEventEx (
215 &gEfiEventReadyToBootGuid
,
220 // For EFI 1.10 with no Tiano extensions return unsupported
222 Status
= EFI_UNSUPORTED
;
230 Signal a Ready to Boot Event.
232 Create a Ready to Boot Event. Signal it and close it. This causes other
233 events of the same event group to be signaled in other modules.
238 EfiSignalEventReadyToBoot (
243 EFI_EVENT ReadyToBootEvent
;
245 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
246 if (!EFI_ERROR (Status
)) {
247 gBS
->SignalEvent (ReadyToBootEvent
);
248 gBS
->CloseEvent (ReadyToBootEvent
);
253 Signal a Legacy Boot Event.
255 Create a legacy Boot Event. Signal it and close it. This causes other
256 events of the same event group to be signaled in other modules.
261 EfiSignalEventLegacyBoot (
266 EFI_EVENT LegacyBootEvent
;
268 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
269 if (!EFI_ERROR (Status
)) {
270 gBS
->SignalEvent (LegacyBootEvent
);
271 gBS
->CloseEvent (LegacyBootEvent
);
277 Check to see if the Firmware Volume (FV) Media Device Path is valid
279 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
280 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
281 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
282 device path is defined for Tiano extensions of device path. If the code
283 is compiled to conform with the UEFI 2.0 specification use the new device path
284 else use the old form for backwards compatability. The return value to this
285 function points to a location in FvDevicePathNode and it does not allocate
286 new memory for the GUID pointer that is returned.
288 @param FvDevicePathNode Pointer to FV device path to check.
290 @retval NULL FvDevicePathNode is not valid.
291 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
296 EfiGetNameGuidFromFwVolDevicePathNode (
297 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
300 ASSERT (FvDevicePathNode
!= NULL
);
302 #if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))
304 // Use old Device Path that conflicts with UEFI
306 if (DevicePathType (&FvDevicePathNode
->Header
) == MEDIA_DEVICE_PATH
||
307 DevicePathSubType (&FvDevicePathNode
->Header
) == MEDIA_FV_FILEPATH_DP
) {
308 return (EFI_GUID
*) &FvDevicePathNode
->NameGuid
;
311 #elif ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION >= 0x00020000))
313 // Use the new Device path that does not conflict with the UEFI
315 if (FvDevicePathNode
->Tiano
.Header
.Type
== MEDIA_DEVICE_PATH
||
316 FvDevicePathNode
->Tiano
.Header
.SubType
== MEDIA_VENDOR_DP
) {
317 if (CompareGuid (&gEfiFrameworkDevicePathGuid
, &FvDevicePathNode
->Tiano
.TianoSpecificDevicePath
)) {
318 if (FvDevicePathNode
->Tiano
.Type
== TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
) {
319 return (EFI_GUID
*) &FvDevicePathNode
->NameGuid
;
329 Initialize a Firmware Volume (FV) Media Device Path node.
331 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
332 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
333 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
334 device path is defined for Tiano extensions of device path. If the code
335 is compiled to conform with the UEFI 2.0 specification use the new device path
336 else use the old form for backwards compatability.
338 @param FvDevicePathNode Pointer to a FV device path node to initialize
339 @param NameGuid FV file name to use in FvDevicePathNode
344 EfiInitializeFwVolDevicepathNode (
345 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
346 IN CONST EFI_GUID
*NameGuid
349 ASSERT (FvDevicePathNode
!= NULL
);
350 ASSERT (NameGuid
!= NULL
);
352 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
354 // Use old Device Path that conflicts with UEFI
356 FvDevicePathNode
->Header
.Type
= MEDIA_DEVICE_PATH
;
357 FvDevicePathNode
->Header
.SubType
= MEDIA_FV_FILEPATH_DP
;
358 SetDevicePathNodeLength (&FvDevicePathNode
->Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
362 // Use the new Device path that does not conflict with the UEFI
364 FvDevicePathNode
->Tiano
.Header
.Type
= MEDIA_DEVICE_PATH
;
365 FvDevicePathNode
->Tiano
.Header
.SubType
= MEDIA_VENDOR_DP
;
366 SetDevicePathNodeLength (&FvDevicePathNode
->Tiano
.Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
369 // Add the GUID for generic Tiano device paths
371 CopyGuid (&FvDevicePathNode
->Tiano
.TianoSpecificDevicePath
, &gEfiFrameworkDevicePathGuid
);
374 // Add in the FW Vol File Path Tiano defined information
376 FvDevicePathNode
->Tiano
.Type
= TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
;
380 CopyGuid (&FvDevicePathNode
->NameGuid
, NameGuid
);