3 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Library functions that abstract areas of conflict between Tiano an UEFI 2.0.
20 Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the
21 oldconflicts with library functions and supporting implementations of the old
22 (R8.5/EFI 1.10) and new (EdkII/UEFI 2.0) way.
26 #include "EdkIIGlueUefi.h"
29 An empty function to pass error checking of CreateEventEx ().
31 This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error
32 checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
38 InternalEmptyFuntion (
47 Create a Legacy Boot Event.
49 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
50 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
51 added and now it's possible to not voilate the UEFI specification by
52 declaring a GUID for the legacy boot event class. This library supports
53 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
56 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
58 @retval EFI_SUCCESS Event was created.
59 @retval Other Event was not created.
64 GlueEfiCreateEventLegacyBoot (
65 OUT EFI_EVENT
*LegacyBootEvent
68 return EfiCreateEventLegacyBootEx (
77 Create an EFI event in the Legacy Boot Event Group and allows
78 the caller to specify a notification function.
80 This function abstracts the creation of the Legacy Boot Event.
81 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
82 This library abstracts the caller from how this event is created to prevent
83 to code form having to change with the version of the specification supported.
84 If LegacyBootEvent is NULL, then ASSERT().
86 @param NotifyTpl The task priority level of the event.
87 @param NotifyFunction The notification function to call when the event is signaled.
88 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
89 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
91 @retval EFI_SUCCESS Event was created.
92 @retval Other Event was not created.
97 EfiCreateEventLegacyBootEx (
99 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
100 IN VOID
*NotifyContext
, OPTIONAL
101 OUT EFI_EVENT
*LegacyBootEvent
106 EFI_EVENT_NOTIFY WorkerNotifyFunction
;
108 ASSERT (LegacyBootEvent
!= NULL
);
110 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
112 if (NotifyFunction
== NULL
) {
113 EventType
= EFI_EVENT_SIGNAL_LEGACY_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
;
115 EventType
= EFI_EVENT_SIGNAL_LEGACY_BOOT
;
117 WorkerNotifyFunction
= NotifyFunction
;
120 // prior to UEFI 2.0 use Tiano extension to EFI
122 Status
= gBS
->CreateEvent (
125 WorkerNotifyFunction
,
131 EventType
= EVENT_NOTIFY_SIGNAL
;
132 if (NotifyFunction
== NULL
) {
134 // CreatEventEx will check NotifyFunction is NULL or not
136 WorkerNotifyFunction
= InternalEmptyFuntion
;
138 WorkerNotifyFunction
= NotifyFunction
;
142 // For UEFI 2.0 and the future use an Event Group
144 Status
= gBS
->CreateEventEx (
147 WorkerNotifyFunction
,
149 &gEfiEventLegacyBootGuid
,
158 Create a Read to Boot Event.
160 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
161 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
162 added and now it's possible to not voilate the UEFI specification and use
163 the ready to boot event class defined in UEFI 2.0. This library supports
164 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
167 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
169 @retval EFI_SUCCESS Event was created.
170 @retval Other Event was not created.
175 GlueEfiCreateEventReadyToBoot (
176 OUT EFI_EVENT
*ReadyToBootEvent
179 return EfiCreateEventReadyToBootEx (
188 Create an EFI event in the Ready To Boot Event Group and allows
189 the caller to specify a notification function.
191 This function abstracts the creation of the Ready to Boot Event.
192 The Framework moved from a proprietary to UEFI 2.0 based mechanism.
193 This library abstracts the caller from how this event is created to prevent
194 to code form having to change with the version of the specification supported.
195 If ReadyToBootEvent is NULL, then ASSERT().
197 @param NotifyTpl The task priority level of the event.
198 @param NotifyFunction The notification function to call when the event is signaled.
199 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
200 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
202 @retval EFI_SUCCESS Event was created.
203 @retval Other Event was not created.
208 EfiCreateEventReadyToBootEx (
209 IN EFI_TPL NotifyTpl
,
210 IN EFI_EVENT_NOTIFY NotifyFunction
, OPTIONAL
211 IN VOID
*NotifyContext
, OPTIONAL
212 OUT EFI_EVENT
*ReadyToBootEvent
217 EFI_EVENT_NOTIFY WorkerNotifyFunction
;
219 ASSERT (ReadyToBootEvent
!= NULL
);
221 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
223 if (NotifyFunction
== NULL
) {
224 EventType
= EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
;
226 EventType
= EFI_EVENT_SIGNAL_READY_TO_BOOT
;
228 WorkerNotifyFunction
= NotifyFunction
;
231 // prior to UEFI 2.0 use Tiano extension to EFI
233 Status
= gBS
->CreateEvent (
236 WorkerNotifyFunction
,
242 EventType
= EVENT_NOTIFY_SIGNAL
;
244 if (NotifyFunction
== NULL
) {
246 // CreatEventEx will check NotifyFunction is NULL or not
248 WorkerNotifyFunction
= InternalEmptyFuntion
;
250 WorkerNotifyFunction
= NotifyFunction
;
254 // For UEFI 2.0 and the future use an Event Group
256 Status
= gBS
->CreateEventEx (
259 WorkerNotifyFunction
,
261 &gEfiEventReadyToBootGuid
,
271 Signal a Ready to Boot Event.
273 Create a Ready to Boot Event. Signal it and close it. This causes other
274 events of the same event group to be signaled in other modules.
279 EfiSignalEventReadyToBoot (
284 EFI_EVENT ReadyToBootEvent
;
286 Status
= EfiCreateEventReadyToBoot (&ReadyToBootEvent
);
287 if (!EFI_ERROR (Status
)) {
288 gBS
->SignalEvent (ReadyToBootEvent
);
289 gBS
->CloseEvent (ReadyToBootEvent
);
294 Signal a Legacy Boot Event.
296 Create a legacy Boot Event. Signal it and close it. This causes other
297 events of the same event group to be signaled in other modules.
302 EfiSignalEventLegacyBoot (
307 EFI_EVENT LegacyBootEvent
;
309 Status
= EfiCreateEventLegacyBoot (&LegacyBootEvent
);
310 if (!EFI_ERROR (Status
)) {
311 gBS
->SignalEvent (LegacyBootEvent
);
312 gBS
->CloseEvent (LegacyBootEvent
);
318 Check to see if the Firmware Volume (FV) Media Device Path is valid
320 @param FvDevicePathNode Pointer to FV device path to check.
322 @retval NULL FvDevicePathNode is not valid.
323 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
328 GlueEfiGetNameGuidFromFwVolDevicePathNode (
329 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
332 ASSERT (FvDevicePathNode
!= NULL
);
334 if (DevicePathType (&FvDevicePathNode
->Header
) == MEDIA_DEVICE_PATH
&&
335 DevicePathSubType (&FvDevicePathNode
->Header
) == MEDIA_FV_FILEPATH_DP
) {
336 return (EFI_GUID
*) &FvDevicePathNode
->NameGuid
;
344 Initialize a Firmware Volume (FV) Media Device Path node.
346 @param FvDevicePathNode Pointer to a FV device path node to initialize
347 @param NameGuid FV file name to use in FvDevicePathNode
352 GlueEfiInitializeFwVolDevicepathNode (
353 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvDevicePathNode
,
354 IN CONST EFI_GUID
*NameGuid
357 ASSERT (FvDevicePathNode
!= NULL
);
358 ASSERT (NameGuid
!= NULL
);
360 FvDevicePathNode
->Header
.Type
= MEDIA_DEVICE_PATH
;
361 FvDevicePathNode
->Header
.SubType
= MEDIA_FV_FILEPATH_DP
;
362 SetDevicePathNodeLength (&FvDevicePathNode
->Header
, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
));
364 CopyGuid (&FvDevicePathNode
->NameGuid
, NameGuid
);