/** @file\r
UEFI Event support functions implemented in this file.\r
\r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
http://opensource.org/licenses/bsd-license.php\r
\r
\r
#include "DxeMain.h"\r
-\r
-//\r
-// Enumerate the valid types\r
-//\r
+#include "Event.h"\r
+\r
+///\r
+/// gEfiCurrentTpl - Current Task priority level\r
+///\r
+EFI_TPL gEfiCurrentTpl = TPL_APPLICATION;\r
+\r
+///\r
+/// gEventQueueLock - Protects the event queues\r
+///\r
+EFI_LOCK gEventQueueLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_HIGH_LEVEL);\r
+\r
+///\r
+/// gEventQueue - A list of event's to notify for each priority level\r
+///\r
+LIST_ENTRY gEventQueue[TPL_HIGH_LEVEL + 1];\r
+\r
+///\r
+/// gEventPending - A bitmask of the EventQueues that are pending\r
+///\r
+UINTN gEventPending = 0;\r
+\r
+///\r
+/// gEventSignalQueue - A list of events to signal based on EventGroup type\r
+///\r
+LIST_ENTRY gEventSignalQueue = INITIALIZE_LIST_HEAD_VARIABLE (gEventSignalQueue);\r
+\r
+///\r
+/// Enumerate the valid types\r
+///\r
UINT32 mEventTable[] = {\r
- //\r
- // 0x80000200 Timer event with a notification function that is\r
- // queue when the event is signaled with SignalEvent()\r
- //\r
+ ///\r
+ /// 0x80000200 Timer event with a notification function that is\r
+ /// queue when the event is signaled with SignalEvent()\r
+ ///\r
EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
- //\r
- // 0x80000000 Timer event without a notification function. It can be\r
- // signaled with SignalEvent() and checked with CheckEvent() or WaitForEvent().\r
- //\r
+ ///\r
+ /// 0x80000000 Timer event without a notification function. It can be\r
+ /// signaled with SignalEvent() and checked with CheckEvent() or WaitForEvent().\r
+ ///\r
EVT_TIMER,\r
- //\r
- // 0x00000100 Generic event with a notification function that\r
- // can be waited on with CheckEvent() or WaitForEvent()\r
- //\r
+ ///\r
+ /// 0x00000100 Generic event with a notification function that\r
+ /// can be waited on with CheckEvent() or WaitForEvent()\r
+ ///\r
EVT_NOTIFY_WAIT,\r
- //\r
- // 0x00000200 Generic event with a notification function that\r
- // is queue when the event is signaled with SignalEvent()\r
- //\r
+ ///\r
+ /// 0x00000200 Generic event with a notification function that\r
+ /// is queue when the event is signaled with SignalEvent()\r
+ ///\r
EVT_NOTIFY_SIGNAL,\r
- //\r
- // 0x00000201 ExitBootServicesEvent.\r
- //\r
+ ///\r
+ /// 0x00000201 ExitBootServicesEvent.\r
+ ///\r
EVT_SIGNAL_EXIT_BOOT_SERVICES,\r
- //\r
- // 0x60000202 SetVirtualAddressMapEvent.\r
- //\r
+ ///\r
+ /// 0x60000202 SetVirtualAddressMapEvent.\r
+ ///\r
EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
\r
- //\r
- // 0x00000000 Generic event without a notification function.\r
- // It can be signaled with SignalEvent() and checked with CheckEvent()\r
- // or WaitForEvent().\r
- //\r
+ ///\r
+ /// 0x00000000 Generic event without a notification function.\r
+ /// It can be signaled with SignalEvent() and checked with CheckEvent()\r
+ /// or WaitForEvent().\r
+ ///\r
0x00000000,\r
- //\r
- // 0x80000100 Timer event with a notification function that can be\r
- // waited on with CheckEvent() or WaitForEvent()\r
- //\r
+ ///\r
+ /// 0x80000100 Timer event with a notification function that can be\r
+ /// waited on with CheckEvent() or WaitForEvent()\r
+ ///\r
EVT_TIMER | EVT_NOTIFY_WAIT,\r
};\r
\r
\r
\r
/**\r
- Initializes "event" support and populates parts of the System and Runtime Table.\r
+ Initializes "event" support.\r
\r
@retval EFI_SUCCESS Always return success\r
\r
// Only clear the SIGNAL status if it is a SIGNAL type event.\r
// WAIT type events are only cleared in CheckEvent()\r
//\r
- if (Event->Type & EVT_NOTIFY_SIGNAL) {\r
+ if ((Event->Type & EVT_NOTIFY_SIGNAL) != 0) {\r
Event->SignalCount = 0;\r
}\r
\r
}\r
\r
//\r
- // Allcoate and initialize a new event structure.\r
+ // Allocate and initialize a new event structure.\r
//\r
- Status = CoreAllocatePool (\r
- ((Type & EVT_RUNTIME) != 0) ? EfiRuntimeServicesData: EfiBootServicesData,\r
- sizeof (IEVENT),\r
- (VOID **)&IEvent\r
- );\r
- if (EFI_ERROR (Status)) {\r
+ if ((Type & EVT_RUNTIME) != 0) {\r
+ IEvent = AllocateRuntimeZeroPool (sizeof (IEVENT));\r
+ } else {\r
+ IEvent = AllocateZeroPool (sizeof (IEVENT));\r
+ }\r
+ if (IEvent == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- ZeroMem (IEvent, sizeof (IEVENT));\r
-\r
IEvent->Signature = EVENT_SIGNATURE;\r
IEvent->Type = Type;\r
\r
//\r
// If signalling type is a notify function, queue it\r
//\r
- if (Event->Type & EVT_NOTIFY_SIGNAL) {\r
+ if ((Event->Type & EVT_NOTIFY_SIGNAL) != 0) {\r
if (Event->ExFlag) {\r
//\r
// The CreateEventEx() style requires all members of the Event Group\r
\r
Status = EFI_NOT_READY;\r
\r
- if (!Event->SignalCount && (Event->Type & EVT_NOTIFY_WAIT)) {\r
+ if ((Event->SignalCount == 0) && ((Event->Type & EVT_NOTIFY_WAIT) != 0)) {\r
\r
//\r
// Queue the wait notify function\r
//\r
CoreAcquireEventLock ();\r
- if (!Event->SignalCount) {\r
+ if (Event->SignalCount == 0) {\r
CoreNotifyEvent (Event);\r
}\r
CoreReleaseEventLock ();\r
// If the even looks signalled, get the lock and clear it\r
//\r
\r
- if (Event->SignalCount) {\r
+ if (Event->SignalCount != 0) {\r
CoreAcquireEventLock ();\r
\r
- if (Event->SignalCount) {\r
+ if (Event->SignalCount != 0) {\r
Event->SignalCount = 0;\r
Status = EFI_SUCCESS;\r
}\r