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 "EfiDriverLib.h"
26 EfiLibCreateProtocolNotifyEvent (
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.
65 Status
= gBS
->CreateEvent (
66 EFI_EVENT_NOTIFY_SIGNAL
,
72 ASSERT (!EFI_ERROR (Status
));
75 // Register for protocol notifactions on this event
78 Status
= gBS
->RegisterProtocolNotify (
84 ASSERT (!EFI_ERROR (Status
));
87 // Kick the event so we will perform an initial pass of
88 // current installed drivers
91 gBS
->SignalEvent (Event
);
96 EfiLibNamedEventListen (
99 IN EFI_EVENT_NOTIFY NotifyFunction
,
100 IN VOID
*NotifyContext
105 Listenes to signals on the name.
106 EfiLibNamedEventSignal() signals the event.
108 NOTE: For now, the named listening/signalling is implemented
109 on a protocol interface being installed and uninstalled.
110 In the future, this maybe implemented based on a dedicated mechanism.
113 Name - Name to register the listener on.
114 NotifyTpl - Maximum TPL to singnal the NotifyFunction.
115 NotifyFunction - The listener routine.
116 NotifyContext - Context passed into the listener routine.
119 EFI_SUCCESS if successful.
125 VOID
*RegistrationLocal
;
130 Status
= gBS
->CreateEvent (
131 EFI_EVENT_NOTIFY_SIGNAL
,
137 ASSERT_EFI_ERROR (Status
);
139 Status
= gBS
->RegisterProtocolNotify (
144 ASSERT_EFI_ERROR (Status
);
150 EfiLibNamedEventSignal (
156 Signals a named event. All registered listeners will run.
157 The listeners should register using EfiLibNamedEventListen() function.
159 NOTE: For now, the named listening/signalling is implemented
160 on a protocol interface being installed and uninstalled.
161 In the future, this maybe implemented based on a dedicated mechanism.
164 Name - Name to perform the signaling on. The name is a GUID.
167 EFI_SUCCESS if successfull.
175 Status
= gBS
->InstallProtocolInterface (
178 EFI_NATIVE_INTERFACE
,
181 ASSERT_EFI_ERROR (Status
);
183 Status
= gBS
->UninstallProtocolInterface (
188 ASSERT_EFI_ERROR (Status
);
196 EventNotifySignalAllNullEvent (
202 // This null event is a size efficent way to enusre that
203 // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly.
204 // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into
205 // CreateEventEx() and this function is used to make the
206 // old error checking in CreateEvent() for Tiano extensions
216 EfiCreateEventLegacyBoot (
217 IN EFI_TPL NotifyTpl
,
218 IN EFI_EVENT_NOTIFY NotifyFunction
,
219 IN VOID
*NotifyContext
,
220 OUT EFI_EVENT
*LegacyBootEvent
225 Create a Legacy Boot Event.
226 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
227 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
228 added and now it's possible to not voilate the UEFI specification by
229 declaring a GUID for the legacy boot event class. This library supports
230 the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
234 LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
237 EFI_SUCCESS Event was created.
238 Other Event was not created.
244 EFI_EVENT_NOTIFY WorkerNotifyFunction
;
246 if (gST
->Hdr
.Revision
< 0x00020000) {
248 if (NotifyFunction
== NULL
) {
249 EventType
= EFI_EVENT_SIGNAL_LEGACY_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
;
251 EventType
= EFI_EVENT_SIGNAL_LEGACY_BOOT
;
253 WorkerNotifyFunction
= NotifyFunction
;
256 // prior to UEFI 2.0 use Tiano extension to EFI
258 Status
= gBS
->CreateEvent (
261 WorkerNotifyFunction
,
267 EventType
= EFI_EVENT_NOTIFY_SIGNAL
;
268 if (NotifyFunction
== NULL
) {
270 // CreatEventEx will check NotifyFunction is NULL or not
272 WorkerNotifyFunction
= EventNotifySignalAllNullEvent
;
274 WorkerNotifyFunction
= NotifyFunction
;
278 // For UEFI 2.0 and the future use an Event Group
280 Status
= gBS
->CreateEventEx (
283 WorkerNotifyFunction
,
285 &gEfiEventLegacyBootGuid
,
295 EfiCreateEventReadyToBoot (
296 IN EFI_TPL NotifyTpl
,
297 IN EFI_EVENT_NOTIFY NotifyFunction
,
298 IN VOID
*NotifyContext
,
299 OUT EFI_EVENT
*ReadyToBootEvent
304 Create a Read to Boot Event.
306 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
307 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
308 added and now it's possible to not voilate the UEFI specification and use
309 the ready to boot event class defined in UEFI 2.0. This library supports
310 the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
314 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
317 EFI_SUCCESS - Event was created.
318 Other - Event was not created.
324 EFI_EVENT_NOTIFY WorkerNotifyFunction
;
326 if (gST
->Hdr
.Revision
< 0x00020000) {
328 if (NotifyFunction
== NULL
) {
329 EventType
= EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
;
331 EventType
= EFI_EVENT_SIGNAL_READY_TO_BOOT
;
333 WorkerNotifyFunction
= NotifyFunction
;
336 // prior to UEFI 2.0 use Tiano extension to EFI
338 Status
= gBS
->CreateEvent (
341 WorkerNotifyFunction
,
347 EventType
= EFI_EVENT_NOTIFY_SIGNAL
;
348 if (NotifyFunction
== NULL
) {
350 // CreatEventEx will check NotifyFunction is NULL or not
352 WorkerNotifyFunction
= EventNotifySignalAllNullEvent
;
354 WorkerNotifyFunction
= NotifyFunction
;
358 // For UEFI 2.0 and the future use an Event Group
360 Status
= gBS
->CreateEventEx (
363 WorkerNotifyFunction
,
365 &gEfiEventReadyToBootGuid
,