summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Core/Dxe/Event/Event.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Core/Dxe/Event/Event.c')
-rw-r--r--MdeModulePkg/Core/Dxe/Event/Event.c165
1 files changed, 71 insertions, 94 deletions
diff --git a/MdeModulePkg/Core/Dxe/Event/Event.c b/MdeModulePkg/Core/Dxe/Event/Event.c
index 6f96e12815..dc82abb021 100644
--- a/MdeModulePkg/Core/Dxe/Event/Event.c
+++ b/MdeModulePkg/Core/Dxe/Event/Event.c
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "DxeMain.h"
#include "Event.h"
@@ -19,27 +18,27 @@ EFI_TPL gEfiCurrentTpl = TPL_APPLICATION;
///
/// gEventQueueLock - Protects the event queues
///
-EFI_LOCK gEventQueueLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_HIGH_LEVEL);
+EFI_LOCK gEventQueueLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_HIGH_LEVEL);
///
/// gEventQueue - A list of event's to notify for each priority level
///
-LIST_ENTRY gEventQueue[TPL_HIGH_LEVEL + 1];
+LIST_ENTRY gEventQueue[TPL_HIGH_LEVEL + 1];
///
/// gEventPending - A bitmask of the EventQueues that are pending
///
-UINTN gEventPending = 0;
+UINTN gEventPending = 0;
///
/// gEventSignalQueue - A list of events to signal based on EventGroup type
///
-LIST_ENTRY gEventSignalQueue = INITIALIZE_LIST_HEAD_VARIABLE (gEventSignalQueue);
+LIST_ENTRY gEventSignalQueue = INITIALIZE_LIST_HEAD_VARIABLE (gEventSignalQueue);
///
/// Enumerate the valid types
///
-UINT32 mEventTable[] = {
+UINT32 mEventTable[] = {
///
/// 0x80000200 Timer event with a notification function that is
/// queue when the event is signaled with SignalEvent()
@@ -85,8 +84,7 @@ UINT32 mEventTable[] = {
///
/// gIdleLoopEvent - Event which is signalled when the core is idle
///
-EFI_EVENT gIdleLoopEvent = NULL;
-
+EFI_EVENT gIdleLoopEvent = NULL;
/**
Enter critical section by acquiring the lock on gEventQueueLock.
@@ -100,7 +98,6 @@ CoreAcquireEventLock (
CoreAcquireLock (&gEventQueueLock);
}
-
/**
Exit critical section by releasing the lock on gEventQueueLock.
@@ -113,8 +110,6 @@ CoreReleaseEventLock (
CoreReleaseLock (&gEventQueueLock);
}
-
-
/**
Initializes "event" support.
@@ -126,9 +121,9 @@ CoreInitializeEventServices (
VOID
)
{
- UINTN Index;
+ UINTN Index;
- for (Index=0; Index <= TPL_HIGH_LEVEL; Index++) {
+ for (Index = 0; Index <= TPL_HIGH_LEVEL; Index++) {
InitializeListHead (&gEventQueue[Index]);
}
@@ -146,8 +141,6 @@ CoreInitializeEventServices (
return EFI_SUCCESS;
}
-
-
/**
Dispatches all pending events.
@@ -157,11 +150,11 @@ CoreInitializeEventServices (
**/
VOID
CoreDispatchEventNotifies (
- IN EFI_TPL Priority
+ IN EFI_TPL Priority
)
{
- IEVENT *Event;
- LIST_ENTRY *Head;
+ IEVENT *Event;
+ LIST_ENTRY *Head;
CoreAcquireEventLock ();
ASSERT (gEventQueueLock.OwnerTpl == Priority);
@@ -171,7 +164,6 @@ CoreDispatchEventNotifies (
// Dispatch all the pending notifications
//
while (!IsListEmpty (Head)) {
-
Event = CR (Head->ForwardLink, IEVENT, NotifyLink, EVENT_SIGNATURE);
RemoveEntryList (&Event->NotifyLink);
@@ -203,8 +195,6 @@ CoreDispatchEventNotifies (
CoreReleaseEventLock ();
}
-
-
/**
Queues the event's notification function to fire.
@@ -213,10 +203,9 @@ CoreDispatchEventNotifies (
**/
VOID
CoreNotifyEvent (
- IN IEVENT *Event
+ IN IEVENT *Event
)
{
-
//
// Event database must be locked
//
@@ -239,9 +228,6 @@ CoreNotifyEvent (
gEventPending |= (UINTN)(1 << Event->NotifyTpl);
}
-
-
-
/**
Signals all events in the EventGroup.
@@ -250,12 +236,12 @@ CoreNotifyEvent (
**/
VOID
CoreNotifySignalList (
- IN EFI_GUID *EventGroup
+ IN EFI_GUID *EventGroup
)
{
- LIST_ENTRY *Link;
- LIST_ENTRY *Head;
- IEVENT *Event;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *Head;
+ IEVENT *Event;
CoreAcquireEventLock ();
@@ -270,7 +256,6 @@ CoreNotifySignalList (
CoreReleaseEventLock ();
}
-
/**
Creates an event.
@@ -292,18 +277,16 @@ CoreNotifySignalList (
EFI_STATUS
EFIAPI
CoreCreateEvent (
- IN UINT32 Type,
- IN EFI_TPL NotifyTpl,
- IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
- IN VOID *NotifyContext OPTIONAL,
- OUT EFI_EVENT *Event
+ IN UINT32 Type,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
+ IN VOID *NotifyContext OPTIONAL,
+ OUT EFI_EVENT *Event
)
{
return CoreCreateEventEx (Type, NotifyTpl, NotifyFunction, NotifyContext, NULL, Event);
}
-
-
/**
Creates an event in a group.
@@ -327,21 +310,22 @@ CoreCreateEvent (
EFI_STATUS
EFIAPI
CoreCreateEventEx (
- IN UINT32 Type,
- IN EFI_TPL NotifyTpl,
- IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
- IN CONST VOID *NotifyContext OPTIONAL,
- IN CONST EFI_GUID *EventGroup OPTIONAL,
- OUT EFI_EVENT *Event
+ IN UINT32 Type,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
+ IN CONST VOID *NotifyContext OPTIONAL,
+ IN CONST EFI_GUID *EventGroup OPTIONAL,
+ OUT EFI_EVENT *Event
)
{
//
// If it's a notify type of event, check for invalid NotifyTpl
//
if ((Type & (EVT_NOTIFY_WAIT | EVT_NOTIFY_SIGNAL)) != 0) {
- if (NotifyTpl != TPL_APPLICATION &&
- NotifyTpl != TPL_CALLBACK &&
- NotifyTpl != TPL_NOTIFY) {
+ if ((NotifyTpl != TPL_APPLICATION) &&
+ (NotifyTpl != TPL_CALLBACK) &&
+ (NotifyTpl != TPL_NOTIFY))
+ {
return EFI_INVALID_PARAMETER;
}
}
@@ -372,18 +356,17 @@ CoreCreateEventEx (
EFI_STATUS
EFIAPI
CoreCreateEventInternal (
- IN UINT32 Type,
- IN EFI_TPL NotifyTpl,
- IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
- IN CONST VOID *NotifyContext OPTIONAL,
- IN CONST EFI_GUID *EventGroup OPTIONAL,
- OUT EFI_EVENT *Event
+ IN UINT32 Type,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
+ IN CONST VOID *NotifyContext OPTIONAL,
+ IN CONST EFI_GUID *EventGroup OPTIONAL,
+ OUT EFI_EVENT *Event
)
{
- EFI_STATUS Status;
- IEVENT *IEvent;
- INTN Index;
-
+ EFI_STATUS Status;
+ IEVENT *IEvent;
+ INTN Index;
if (Event == NULL) {
return EFI_INVALID_PARAMETER;
@@ -394,12 +377,13 @@ CoreCreateEventInternal (
//
Status = EFI_INVALID_PARAMETER;
for (Index = 0; Index < (sizeof (mEventTable) / sizeof (UINT32)); Index++) {
- if (Type == mEventTable[Index]) {
- Status = EFI_SUCCESS;
- break;
- }
+ if (Type == mEventTable[Index]) {
+ Status = EFI_SUCCESS;
+ break;
+ }
}
- if(EFI_ERROR (Status)) {
+
+ if (EFI_ERROR (Status)) {
return EFI_INVALID_PARAMETER;
}
@@ -414,6 +398,7 @@ CoreCreateEventInternal (
if ((Type == EVT_SIGNAL_EXIT_BOOT_SERVICES) || (Type == EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE)) {
return EFI_INVALID_PARAMETER;
}
+
if (CompareGuid (EventGroup, &gEfiEventExitBootServicesGuid)) {
Type = EVT_SIGNAL_EXIT_BOOT_SERVICES;
} else if (CompareGuid (EventGroup, &gEfiEventVirtualAddressChangeGuid)) {
@@ -439,17 +424,17 @@ CoreCreateEventInternal (
//
if ((NotifyFunction == NULL) ||
(NotifyTpl <= TPL_APPLICATION) ||
- (NotifyTpl >= TPL_HIGH_LEVEL)) {
+ (NotifyTpl >= TPL_HIGH_LEVEL))
+ {
return EFI_INVALID_PARAMETER;
}
-
} else {
//
// No notification needed, zero ignored values
//
- NotifyTpl = 0;
+ NotifyTpl = 0;
NotifyFunction = NULL;
- NotifyContext = NULL;
+ NotifyContext = NULL;
}
//
@@ -460,12 +445,13 @@ CoreCreateEventInternal (
} else {
IEvent = AllocateZeroPool (sizeof (IEVENT));
}
+
if (IEvent == NULL) {
return EFI_OUT_OF_RESOURCES;
}
IEvent->Signature = EVENT_SIGNATURE;
- IEvent->Type = Type;
+ IEvent->Type = Type;
IEvent->NotifyTpl = NotifyTpl;
IEvent->NotifyFunction = NotifyFunction;
@@ -484,7 +470,7 @@ CoreCreateEventInternal (
IEvent->RuntimeData.Type = Type;
IEvent->RuntimeData.NotifyTpl = NotifyTpl;
IEvent->RuntimeData.NotifyFunction = NotifyFunction;
- IEvent->RuntimeData.NotifyContext = (VOID *) NotifyContext;
+ IEvent->RuntimeData.NotifyContext = (VOID *)NotifyContext;
//
// Work around the bug in the Platform Init specification (v1.7), reported
// as Mantis#2017: "EFI_RUNTIME_EVENT_ENTRY.Event" should have type
@@ -493,7 +479,7 @@ CoreCreateEventInternal (
// doesn't match the natural language description. Therefore we need an
// explicit cast here.
//
- IEvent->RuntimeData.Event = (EFI_EVENT *) IEvent;
+ IEvent->RuntimeData.Event = (EFI_EVENT *)IEvent;
InsertTailList (&gRuntime->EventHead, &IEvent->RuntimeData.Link);
}
@@ -514,9 +500,6 @@ CoreCreateEventInternal (
return EFI_SUCCESS;
}
-
-
-
/**
Signals the event. Queues the event to be notified if needed.
@@ -529,10 +512,10 @@ CoreCreateEventInternal (
EFI_STATUS
EFIAPI
CoreSignalEvent (
- IN EFI_EVENT UserEvent
+ IN EFI_EVENT UserEvent
)
{
- IEVENT *Event;
+ IEVENT *Event;
Event = UserEvent;
@@ -565,7 +548,7 @@ CoreSignalEvent (
CoreReleaseEventLock ();
CoreNotifySignalList (&Event->EventGroup);
CoreAcquireEventLock ();
- } else {
+ } else {
CoreNotifyEvent (Event);
}
}
@@ -575,8 +558,6 @@ CoreSignalEvent (
return EFI_SUCCESS;
}
-
-
/**
Check the status of an event.
@@ -590,7 +571,7 @@ CoreSignalEvent (
EFI_STATUS
EFIAPI
CoreCheckEvent (
- IN EFI_EVENT UserEvent
+ IN EFI_EVENT UserEvent
)
{
IEVENT *Event;
@@ -613,7 +594,6 @@ CoreCheckEvent (
Status = EFI_NOT_READY;
if ((Event->SignalCount == 0) && ((Event->Type & EVT_NOTIFY_WAIT) != 0)) {
-
//
// Queue the wait notify function
//
@@ -621,6 +601,7 @@ CoreCheckEvent (
if (Event->SignalCount == 0) {
CoreNotifyEvent (Event);
}
+
CoreReleaseEventLock ();
}
@@ -633,7 +614,7 @@ CoreCheckEvent (
if (Event->SignalCount != 0) {
Event->SignalCount = 0;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
}
CoreReleaseEventLock ();
@@ -642,8 +623,6 @@ CoreCheckEvent (
return Status;
}
-
-
/**
Stops execution until an event is signaled.
@@ -661,13 +640,13 @@ CoreCheckEvent (
EFI_STATUS
EFIAPI
CoreWaitForEvent (
- IN UINTN NumberOfEvents,
- IN EFI_EVENT *UserEvents,
- OUT UINTN *UserIndex
+ IN UINTN NumberOfEvents,
+ IN EFI_EVENT *UserEvents,
+ OUT UINTN *UserIndex
)
{
- EFI_STATUS Status;
- UINTN Index;
+ EFI_STATUS Status;
+ UINTN Index;
//
// Can only WaitForEvent at TPL_APPLICATION
@@ -684,10 +663,8 @@ CoreWaitForEvent (
return EFI_INVALID_PARAMETER;
}
- for(;;) {
-
- for(Index = 0; Index < NumberOfEvents; Index++) {
-
+ for ( ; ;) {
+ for (Index = 0; Index < NumberOfEvents; Index++) {
Status = CoreCheckEvent (UserEvents[Index]);
//
@@ -697,6 +674,7 @@ CoreWaitForEvent (
if (UserIndex != NULL) {
*UserIndex = Index;
}
+
return Status;
}
}
@@ -708,7 +686,6 @@ CoreWaitForEvent (
}
}
-
/**
Closes an event and frees the event structure.
@@ -721,7 +698,7 @@ CoreWaitForEvent (
EFI_STATUS
EFIAPI
CoreCloseEvent (
- IN EFI_EVENT UserEvent
+ IN EFI_EVENT UserEvent
)
{
EFI_STATUS Status;
@@ -776,7 +753,7 @@ CoreCloseEvent (
// clear the Signature of Event before free pool.
//
Event->Signature = 0;
- Status = CoreFreePool (Event);
+ Status = CoreFreePool (Event);
ASSERT_EFI_ERROR (Status);
return Status;