3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. 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 Support for Event lib fucntions.
23 #include "EfiRuntimeLib.h"
26 RtEfiLibCreateProtocolNotifyEvent (
27 IN EFI_GUID
*ProtocolGuid
,
29 IN EFI_EVENT_NOTIFY NotifyFunction
,
30 IN VOID
*NotifyContext
,
31 OUT VOID
**Registration
37 Create a protocol notification event and return it.
41 ProtocolGuid - Protocol to register notification event on.
43 NotifyTpl - Maximum TPL to single the NotifyFunction.
45 NotifyFunction - EFI notification routine.
47 NotifyContext - Context passed into Event when it is created.
49 Registration - Registration key returned from RegisterProtocolNotify().
53 The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
54 is added to the system.
64 Status
= gBS
->CreateEvent (
65 EFI_EVENT_NOTIFY_SIGNAL
,
71 ASSERT (!EFI_ERROR (Status
));
74 // Register for protocol notifactions on this event
76 Status
= gBS
->RegisterProtocolNotify (
82 ASSERT (!EFI_ERROR (Status
));
85 // Kick the event so we will perform an initial pass of
86 // current installed drivers
88 gBS
->SignalEvent (Event
);
93 EfiLibGetSystemConfigurationTable (
94 IN EFI_GUID
*TableGuid
,
101 Return the EFI 1.0 System Tabl entry with TableGuid
105 TableGuid - Name of entry to return in the system table
106 Table - Pointer in EFI system table associated with TableGuid
110 EFI_SUCCESS - Table returned;
111 EFI_NOT_FOUND - TableGuid not in EFI system table
117 for (Index
= 0; Index
< gST
->NumberOfTableEntries
; Index
++) {
118 if (EfiCompareGuid (TableGuid
, &(gST
->ConfigurationTable
[Index
].VendorGuid
))) {
119 *Table
= gST
->ConfigurationTable
[Index
].VendorTable
;
124 return EFI_NOT_FOUND
;
129 IN UINTN DebugDisposition
,
130 IN OUT EFI_LIST_ENTRY
*ListHead
136 Conver the standard Lib double linked list to a virtual mapping.
140 DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)
142 ListHead - Head of linked list to convert
150 EFI_LIST_ENTRY
*Link
;
151 EFI_LIST_ENTRY
*NextLink
;
154 // Convert all the ForwardLink & BackLink pointers in the list
158 NextLink
= Link
->ForwardLink
;
161 Link
->ForwardLink
== ListHead
? DebugDisposition
: 0,
162 (VOID
**) &Link
->ForwardLink
166 Link
->BackLink
== ListHead
? DebugDisposition
: 0,
167 (VOID
**) &Link
->BackLink
171 } while (Link
!= ListHead
);
175 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
180 EventNotifySignalAllNullEvent (
186 // This null event is a size efficent way to enusre that
187 // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly.
188 // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into
189 // CreateEventEx() and this function is used to make the
190 // old error checking in CreateEvent() for Tiano extensions
200 RtEfiCreateEventLegacyBoot (
201 IN EFI_TPL NotifyTpl
,
202 IN EFI_EVENT_NOTIFY NotifyFunction
,
203 IN VOID
*NotifyContext
,
204 OUT EFI_EVENT
*LegacyBootEvent
209 Create a Legacy Boot Event.
210 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
211 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
212 added and now it's possible to not voilate the UEFI specification by
213 declaring a GUID for the legacy boot event class. This library supports
214 the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
218 LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
221 EFI_SUCCESS Event was created.
222 Other Event was not created.
228 EFI_EVENT_NOTIFY WorkerNotifyFunction
;
230 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
232 if (NotifyFunction
== NULL
) {
233 EventType
= EFI_EVENT_SIGNAL_LEGACY_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
;
235 EventType
= EFI_EVENT_SIGNAL_LEGACY_BOOT
;
237 WorkerNotifyFunction
= NotifyFunction
;
240 // prior to UEFI 2.0 use Tiano extension to EFI
242 Status
= gBS
->CreateEvent (
245 WorkerNotifyFunction
,
251 EventType
= EFI_EVENT_NOTIFY_SIGNAL
;
252 if (NotifyFunction
== NULL
) {
254 // CreatEventEx will check NotifyFunction is NULL or not
256 WorkerNotifyFunction
= EventNotifySignalAllNullEvent
;
258 WorkerNotifyFunction
= NotifyFunction
;
262 // For UEFI 2.0 and the future use an Event Group
264 Status
= gBS
->CreateEventEx (
267 WorkerNotifyFunction
,
269 &gEfiEventLegacyBootGuid
,
278 RtEfiCreateEventReadyToBoot (
279 IN EFI_TPL NotifyTpl
,
280 IN EFI_EVENT_NOTIFY NotifyFunction
,
281 IN VOID
*NotifyContext
,
282 OUT EFI_EVENT
*ReadyToBootEvent
287 Create a Read to Boot Event.
289 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
290 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
291 added and now it's possible to not voilate the UEFI specification and use
292 the ready to boot event class defined in UEFI 2.0. This library supports
293 the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
297 ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
300 EFI_SUCCESS - Event was created.
301 Other - Event was not created.
307 EFI_EVENT_NOTIFY WorkerNotifyFunction
;
309 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
311 if (NotifyFunction
== NULL
) {
312 EventType
= EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
;
314 EventType
= EFI_EVENT_SIGNAL_READY_TO_BOOT
;
316 WorkerNotifyFunction
= NotifyFunction
;
319 // prior to UEFI 2.0 use Tiano extension to EFI
321 Status
= gBS
->CreateEvent (
324 WorkerNotifyFunction
,
330 EventType
= EFI_EVENT_NOTIFY_SIGNAL
;
331 if (NotifyFunction
== NULL
) {
333 // CreatEventEx will check NotifyFunction is NULL or not
335 WorkerNotifyFunction
= EventNotifySignalAllNullEvent
;
337 WorkerNotifyFunction
= NotifyFunction
;
341 // For UEFI 2.0 and the future use an Event Group
343 Status
= gBS
->CreateEventEx (
346 WorkerNotifyFunction
,
348 &gEfiEventReadyToBootGuid
,