2 Library functions that abstract areas of conflict between Tiano an UEFI 2.1.
4 Help Port Framework/Tinao code that has conflicts with UEFI 2.1 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.1) way. This module is a DXE driver as
7 it contains DXE enum extensions for EFI event services.
9 Copyright (c) 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.
20 #include "UefiLibFramework.h"
23 An empty function to pass error checking of CreateEventEx ().
25 This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error
26 checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
32 InternalEmptyFuntion (
41 Create a Legacy Boot Event.
43 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
44 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
45 added and now it's possible to not voilate the UEFI specification by
46 declaring a GUID for the legacy boot event class. This library supports
47 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
50 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
52 @retval EFI_SUCCESS Event was created.
53 @retval Other Event was not created.
58 EfiCreateEventLegacyBoot (
59 OUT EFI_EVENT
*LegacyBootEvent
62 return EfiCreateEventLegacyBootEx (
71 Create an EFI event in the Legacy Boot Event Group and allows
72 the caller to specify a notification function.
74 This function abstracts the creation of the Legacy Boot Event.
75 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
76 This library abstracts the caller from how this event is created to prevent
77 to code form having to change with the version of the specification supported.
78 If LegacyBootEvent is NULL, then ASSERT().
80 @param NotifyTpl The task priority level of the event.
81 @param NotifyFunction The notification function to call when the event is signaled.
82 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
83 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
85 @retval EFI_SUCCESS Event was created.
86 @retval Other Event was not created.
91 EfiCreateEventLegacyBootEx (
93 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
94 IN VOID
*NotifyContext
, OPTIONAL
95 OUT EFI_EVENT
*LegacyBootEvent
100 ASSERT (LegacyBootEvent
!= NULL
);
102 if (gST
->Hdr
.Revision
< 0x00020000) {
104 // prior to UEFI 2.0 use Tiano extension to EFI
106 Status
= gBS
->CreateEvent (
107 EFI_EVENT_SIGNAL_LEGACY_BOOT
| EVT_NOTIFY_SIGNAL
,
115 // For UEFI 2.0 and the future use an Event Group
117 Status
= gBS
->CreateEventEx (
122 &gEfiEventLegacyBootGuid
,
131 Create a Read to Boot Event.
133 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
134 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
135 added and now it's possible to not voilate the UEFI specification and use
136 the ready to boot event class defined in UEFI 2.0. This library supports
137 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
140 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
142 @retval EFI_SUCCESS Event was created.
143 @retval Other Event was not created.
148 EfiCreateEventReadyToBoot (
149 OUT EFI_EVENT
*ReadyToBootEvent
152 return EfiCreateEventReadyToBootEx (
154 InternalEmptyFuntion
,
161 Create an EFI event in the Ready To Boot Event Group and allows
162 the caller to specify a notification function.
164 This function abstracts the creation of the Ready to Boot Event.
165 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
166 This library abstracts the caller from how this event is created to prevent
167 to code form having to change with the version of the specification supported.
168 If ReadyToBootEvent is NULL, then ASSERT().
170 @param NotifyTpl The task priority level of the event.
171 @param NotifyFunction The notification function to call when the event is signaled.
172 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
173 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
175 @retval EFI_SUCCESS Event was created.
176 @retval Other Event was not created.
181 EfiCreateEventReadyToBootEx (
182 IN EFI_TPL NotifyTpl
,
183 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
184 IN VOID
*NotifyContext
, OPTIONAL
185 OUT EFI_EVENT
*ReadyToBootEvent
190 ASSERT (ReadyToBootEvent
!= NULL
);
192 if (gST
->Hdr
.Revision
< 0x00020000) {
194 // prior to UEFI 2.0 use Tiano extension to EFI
196 Status
= gBS
->CreateEvent (
197 EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
,
205 // For UEFI 2.0 and the future use an Event Group
207 Status
= gBS
->CreateEventEx (
212 &gEfiEventReadyToBootGuid
,
222 Signal a Ready to Boot Event.
224 Create a Ready to Boot Event. Signal it and close it. This causes other
225 events of the same event group to be signaled in other modules.
230 EfiSignalEventReadyToBoot (
235 EFI_EVENT ReadyToBootEvent
;
237 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
238 if (!EFI_ERROR (Status
)) {
239 gBS
->SignalEvent (ReadyToBootEvent
);
240 gBS
->CloseEvent (ReadyToBootEvent
);
245 Signal a Legacy Boot Event.
247 Create a legacy Boot Event. Signal it and close it. This causes other
248 events of the same event group to be signaled in other modules.
253 EfiSignalEventLegacyBoot (
258 EFI_EVENT LegacyBootEvent
;
260 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
261 if (!EFI_ERROR (Status
)) {
262 gBS
->SignalEvent (LegacyBootEvent
);
263 gBS
->CloseEvent (LegacyBootEvent
);
269 Check to see if the Firmware Volume (FV) Media Device Path is valid
271 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
272 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
273 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
274 device path is defined for Tiano extensions of device path. If the code
275 is compiled to conform with the UEFI 2.0 specification use the new device path
276 else use the old form for backwards compatability. The return value to this
277 function points to a location in FvDevicePathNode and it does not allocate
278 new memory for the GUID pointer that is returned.
280 @param FvDevicePathNode Pointer to FV device path to check.
282 @retval NULL FvDevicePathNode is not valid.
283 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
288 EfiGetNameGuidFromFwVolDevicePathNode (
289 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
292 FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FrameworkFvDevicePathNode
;
294 ASSERT (FvDevicePathNode
!= NULL
);
296 FrameworkFvDevicePathNode
= (FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) FvDevicePathNode
;
298 // Use the new Device path that does not conflict with the UEFI
300 if (FrameworkFvDevicePathNode
->Tiano
.Header
.Type
== MEDIA_DEVICE_PATH
||
301 FrameworkFvDevicePathNode
->Tiano
.Header
.SubType
== MEDIA_VENDOR_DP
) {
302 if (CompareGuid (&gEfiFrameworkDevicePathGuid
, &FrameworkFvDevicePathNode
->Tiano
.TianoSpecificDevicePath
)) {
303 if (FrameworkFvDevicePathNode
->Tiano
.Type
== TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
) {
304 return (EFI_GUID
*) &FrameworkFvDevicePathNode
->NameGuid
;
314 Initialize a Firmware Volume (FV) Media Device Path node.
316 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
317 so as we move to UEFI 2.0 support we must use a mechanism that conforms with
318 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
319 device path is defined for Tiano extensions of device path. If the code
320 is compiled to conform with the UEFI 2.0 specification use the new device path
321 else use the old form for backwards compatability.
323 @param FvDevicePathNode Pointer to a FV device path node to initialize
324 @param NameGuid FV file name to use in FvDevicePathNode
329 EfiInitializeFwVolDevicepathNode (
330 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
331 IN CONST EFI_GUID
*NameGuid
334 FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FrameworkFvDevicePathNode
;
336 ASSERT (FvDevicePathNode
!= NULL
);
337 ASSERT (NameGuid
!= NULL
);
339 FrameworkFvDevicePathNode
= (FRAMEWORK_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) FvDevicePathNode
;
342 // Use the new Device path that does not conflict with the UEFI
344 FrameworkFvDevicePathNode
->Tiano
.Header
.Type
= MEDIA_DEVICE_PATH
;
345 FrameworkFvDevicePathNode
->Tiano
.Header
.SubType
= MEDIA_VENDOR_DP
;
346 SetDevicePathNodeLength (&FrameworkFvDevicePathNode
->Tiano
.Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
349 // Add the GUID for generic Tiano device paths
351 CopyGuid (&FrameworkFvDevicePathNode
->Tiano
.TianoSpecificDevicePath
, &gEfiFrameworkDevicePathGuid
);
354 // Add in the FW Vol File Path Tiano defined information
356 FrameworkFvDevicePathNode
->Tiano
.Type
= TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE
;
358 CopyGuid (&FrameworkFvDevicePathNode
->NameGuid
, NameGuid
);