3 Copyright (c) 2004 - 2011, 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 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
);
193 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
198 EventNotifySignalAllNullEvent (
204 // This null event is a size efficent way to enusre that
205 // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly.
206 // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into
207 // CreateEventEx() and this function is used to make the
208 // old error checking in CreateEvent() for Tiano extensions
218 EfiCreateEventLegacyBoot (
219 IN EFI_TPL NotifyTpl
,
220 IN EFI_EVENT_NOTIFY NotifyFunction
,
221 IN VOID
*NotifyContext
,
222 OUT EFI_EVENT
*LegacyBootEvent
227 Create a Legacy Boot Event.
228 Tiano extended the CreateEvent Type enum to add a legacy boot event type.
229 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
230 added and now it's possible to not voilate the UEFI specification by
231 declaring a GUID for the legacy boot event class. This library supports
232 the EFI 1.10 form and UEFI 2.0 form and allows common code to
236 LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
239 EFI_SUCCESS Event was created.
240 Other Event was not created.
246 EFI_EVENT_NOTIFY WorkerNotifyFunction
;
248 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
250 if (NotifyFunction
== NULL
) {
251 EventType
= EFI_EVENT_SIGNAL_LEGACY_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
;
253 EventType
= EFI_EVENT_SIGNAL_LEGACY_BOOT
;
255 WorkerNotifyFunction
= NotifyFunction
;
258 // prior to UEFI 2.0 use Tiano extension to EFI
260 Status
= gBS
->CreateEvent (
263 WorkerNotifyFunction
,
269 EventType
= EFI_EVENT_NOTIFY_SIGNAL
;
270 if (NotifyFunction
== NULL
) {
272 // CreatEventEx will check NotifyFunction is NULL or not
274 WorkerNotifyFunction
= EventNotifySignalAllNullEvent
;
276 WorkerNotifyFunction
= NotifyFunction
;
280 // For UEFI 2.0 and the future use an Event Group
282 Status
= gBS
->CreateEventEx (
285 WorkerNotifyFunction
,
287 &gEfiEventLegacyBootGuid
,
296 EfiCreateEventReadyToBoot (
297 IN EFI_TPL NotifyTpl
,
298 IN EFI_EVENT_NOTIFY NotifyFunction
,
299 IN VOID
*NotifyContext
,
300 OUT EFI_EVENT
*ReadyToBootEvent
305 Create a Read to Boot Event.
307 Tiano extended the CreateEvent Type enum to add a ready to boot event type.
308 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
309 added and now it's possible to not voilate the UEFI specification and use
310 the ready to boot event class defined in UEFI 2.0. This library supports
311 the EFI 1.10 form and UEFI 2.0 form and allows common code to
315 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
318 EFI_SUCCESS - Event was created.
319 Other - Event was not created.
325 EFI_EVENT_NOTIFY WorkerNotifyFunction
;
327 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
329 if (NotifyFunction
== NULL
) {
330 EventType
= EFI_EVENT_SIGNAL_READY_TO_BOOT
| EFI_EVENT_NOTIFY_SIGNAL_ALL
;
332 EventType
= EFI_EVENT_SIGNAL_READY_TO_BOOT
;
334 WorkerNotifyFunction
= NotifyFunction
;
337 // prior to UEFI 2.0 use Tiano extension to EFI
339 Status
= gBS
->CreateEvent (
342 WorkerNotifyFunction
,
348 EventType
= EFI_EVENT_NOTIFY_SIGNAL
;
349 if (NotifyFunction
== NULL
) {
351 // CreatEventEx will check NotifyFunction is NULL or not
353 WorkerNotifyFunction
= EventNotifySignalAllNullEvent
;
355 WorkerNotifyFunction
= NotifyFunction
;
359 // For UEFI 2.0 and the future use an Event Group
361 Status
= gBS
->CreateEventEx (
364 WorkerNotifyFunction
,
366 &gEfiEventReadyToBootGuid
,