]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Event/Event.c
Merge the global data in ExecData.c to Event.c
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Event / Event.c
index 5e0b9c70abf6598bccaeef006d4d6e264bfd4f61..0e32aa4b6646adad50d9d0fb0d39aa3df871ccb4 100644 (file)
@@ -13,51 +13,76 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 \r
-#include <DxeMain.h>\r
-\r
-//\r
-// Enumerate the valid types\r
-//\r
+#include "DxeMain.h"\r
+\r
+///\r
+/// gEfiCurrentTpl - Current Task priority level\r
+///\r
+EFI_TPL  gEfiCurrentTpl = TPL_APPLICATION;\r
+\r
+///\r
+/// gEventQueueLock - Protects the event queus\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
@@ -90,8 +115,7 @@ CoreReleaseEventLock (
 \r
 \r
 /**\r
-  Initializes "event" support and populates parts of the System and Runtime Table.\r
-\r
+  Initializes "event" support.\r
 \r
   @retval EFI_SUCCESS            Always return success\r
 \r
@@ -117,7 +141,7 @@ CoreInitializeEventServices (
 /**\r
   Dispatches all pending events.\r
 \r
-  @param  Priority               The task priority level of event notifications \r
+  @param  Priority               The task priority level of event notifications\r
                                  to dispatch\r
 \r
 **/\r
@@ -240,18 +264,18 @@ CoreNotifySignalList (
 /**\r
   Creates a general-purpose event structure.\r
 \r
-  @param  Type                   The type of event to create and its mode and \r
-                                 attributes \r
-  @param  NotifyTpl              The task priority level of event notifications \r
-  @param  NotifyFunction         Pointer to the events notification function \r
-  @param  NotifyContext          Pointer to the notification functions context; \r
-                                 corresponds to parameter "Context" in the \r
-                                 notification function \r
-  @param  Event                  Pointer to the newly created event if the call \r
-                                 succeeds; undefined otherwise \r
-\r
-  @retval EFI_SUCCESS            The event structure was created \r
-  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value \r
+  @param  Type                   The type of event to create and its mode and\r
+                                 attributes\r
+  @param  NotifyTpl              The task priority level of event notifications\r
+  @param  NotifyFunction         Pointer to the events notification function\r
+  @param  NotifyContext          Pointer to the notification functions context;\r
+                                 corresponds to parameter "Context" in the\r
+                                 notification function\r
+  @param  Event                  Pointer to the newly created event if the call\r
+                                 succeeds; undefined otherwise\r
+\r
+  @retval EFI_SUCCESS            The event structure was created\r
+  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value\r
   @retval EFI_OUT_OF_RESOURCES   The event could not be allocated\r
 \r
 **/\r
@@ -273,20 +297,20 @@ CoreCreateEvent (
 /**\r
   Creates a general-purpose event structure\r
 \r
-  @param  Type                   The type of event to create and its mode and \r
-                                 attributes \r
-  @param  NotifyTpl              The task priority level of event notifications \r
-  @param  NotifyFunction         Pointer to the events notification function \r
-  @param  NotifyContext          Pointer to the notification functions context; \r
-                                 corresponds to parameter "Context" in the \r
-                                 notification function \r
-  @param  EventGroup             GUID for EventGroup if NULL act the same as \r
-                                 gBS->CreateEvent(). \r
-  @param  Event                  Pointer to the newly created event if the call \r
-                                 succeeds; undefined otherwise \r
-\r
-  @retval EFI_SUCCESS            The event structure was created \r
-  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value \r
+  @param  Type                   The type of event to create and its mode and\r
+                                 attributes\r
+  @param  NotifyTpl              The task priority level of event notifications\r
+  @param  NotifyFunction         Pointer to the events notification function\r
+  @param  NotifyContext          Pointer to the notification functions context;\r
+                                 corresponds to parameter "Context" in the\r
+                                 notification function\r
+  @param  EventGroup             GUID for EventGroup if NULL act the same as\r
+                                 gBS->CreateEvent().\r
+  @param  Event                  Pointer to the newly created event if the call\r
+                                 succeeds; undefined otherwise\r
+\r
+  @retval EFI_SUCCESS            The event structure was created\r
+  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value\r
   @retval EFI_OUT_OF_RESOURCES   The event could not be allocated\r
 \r
 **/\r
@@ -306,7 +330,7 @@ CoreCreateEventEx (
   INTN            Index;\r
 \r
 \r
-  if ((Event == NULL) || (NotifyTpl == TPL_APPLICATION)) {\r
+  if (Event == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -359,7 +383,7 @@ CoreCreateEventEx (
     // Check for an invalid NotifyFunction or NotifyTpl\r
     //\r
     if ((NotifyFunction == NULL) ||\r
-        (NotifyTpl < TPL_APPLICATION) ||\r
+        (NotifyTpl <= TPL_APPLICATION) ||\r
        (NotifyTpl >= TPL_HIGH_LEVEL)) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
@@ -385,7 +409,7 @@ CoreCreateEventEx (
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  SetMem (IEvent, sizeof (IEVENT), 0);\r
+  ZeroMem (IEvent, sizeof (IEVENT));\r
 \r
   IEvent->Signature = EVENT_SIGNATURE;\r
   IEvent->Type = Type;\r
@@ -433,11 +457,11 @@ CoreCreateEventEx (
 \r
 \r
 /**\r
-  Signals the event.  Queues the event to be notified if needed\r
+  Signals the event.  Queues the event to be notified if needed.\r
 \r
-  @param  UserEvent              The event to signal \r
+  @param  UserEvent              The event to signal .\r
 \r
-  @retval EFI_INVALID_PARAMETER  Parameters are not valid. \r
+  @retval EFI_INVALID_PARAMETER  Parameters are not valid.\r
   @retval EFI_SUCCESS            The event was signaled.\r
 \r
 **/\r
@@ -495,10 +519,10 @@ CoreSignalEvent (
 /**\r
   Check the status of an event.\r
 \r
-  @param  UserEvent              The event to check \r
+  @param  UserEvent              The event to check\r
 \r
-  @retval EFI_SUCCESS            The event is in the signaled state \r
-  @retval EFI_NOT_READY          The event is not in the signaled state \r
+  @retval EFI_SUCCESS            The event is in the signaled state\r
+  @retval EFI_NOT_READY          The event is not in the signaled state\r
   @retval EFI_INVALID_PARAMETER  Event is of type EVT_NOTIFY_SIGNAL\r
 \r
 **/\r
@@ -521,7 +545,7 @@ CoreCheckEvent (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (Event->Type & EVT_NOTIFY_SIGNAL) {\r
+  if ((Event->Type & EVT_NOTIFY_SIGNAL) != 0) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -532,7 +556,6 @@ CoreCheckEvent (
     //\r
     // Queue the wait notify function\r
     //\r
-\r
     CoreAcquireEventLock ();\r
     if (!Event->SignalCount) {\r
       CoreNotifyEvent (Event);\r
@@ -560,18 +583,17 @@ CoreCheckEvent (
 \r
 \r
 \r
-\r
 /**\r
   Stops execution until an event is signaled.\r
 \r
-  @param  NumberOfEvents         The number of events in the UserEvents array \r
-  @param  UserEvents             An array of EFI_EVENT \r
-  @param  UserIndex              Pointer to the index of the event which \r
-                                 satisfied the wait condition \r
+  @param  NumberOfEvents         The number of events in the UserEvents array\r
+  @param  UserEvents             An array of EFI_EVENT\r
+  @param  UserIndex              Pointer to the index of the event which\r
+                                 satisfied the wait condition\r
 \r
-  @retval EFI_SUCCESS            The event indicated by Index was signaled. \r
-  @retval EFI_INVALID_PARAMETER  The event indicated by Index has a notification \r
-                                 function or Event was not a valid type \r
+  @retval EFI_SUCCESS            The event indicated by Index was signaled.\r
+  @retval EFI_INVALID_PARAMETER  The event indicated by Index has a notification\r
+                                 function or Event was not a valid type\r
   @retval EFI_UNSUPPORTED        The current TPL is not TPL_APPLICATION\r
 \r
 **/\r
@@ -616,13 +638,12 @@ CoreWaitForEvent (
 }\r
 \r
 \r
-\r
 /**\r
   Closes an event and frees the event structure.\r
 \r
-  @param  UserEvent              Event to close \r
+  @param  UserEvent              Event to close\r
 \r
-  @retval EFI_INVALID_PARAMETER  Parameters are not valid. \r
+  @retval EFI_INVALID_PARAMETER  Parameters are not valid.\r
   @retval EFI_SUCCESS            The event has been closed\r
 \r
 **/\r
@@ -648,7 +669,7 @@ CoreCloseEvent (
   //\r
   // If it's a timer event, make sure it's not pending\r
   //\r
-  if (Event->Type & EVT_TIMER) {\r
+  if ((Event->Type & EVT_TIMER) != 0) {\r
     CoreSetTimer (Event, TimerCancel, 0);\r
   }\r
 \r