]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Event/event.c
Change the file name case to follow coding style: The first character should be capital.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Event / event.c
index b3ba71de810bc1de2089c7c8466f130156c264ea..834ace59e792d0960fb515850ece434d2d999589 100644 (file)
@@ -1,6 +1,8 @@
-/*++\r
+/** @file \r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+  UEFI Event support functions implemented in this file.\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
 All rights reserved. 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
@@ -9,15 +11,7 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-    event.c\r
-\r
-Abstract:\r
-\r
-    EFI Event support\r
-\r
---*/\r
+**/\r
 \r
 \r
 #include <DxeMain.h>\r
@@ -68,74 +62,47 @@ UINT32 mEventTable[] = {
   EVT_TIMER | EVT_NOTIFY_WAIT,\r
 };\r
 \r
+\r
+/**\r
+  Enter critical section by acquiring the lock on gEventQueueLock.\r
+\r
+**/\r
 STATIC\r
 VOID\r
 CoreAcquireEventLock (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Enter critical section by acquiring the lock on gEventQueueLock.\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
 {\r
   CoreAcquireLock (&gEventQueueLock);\r
 }\r
 \r
+\r
+/**\r
+  Exit critical section by releasing the lock on gEventQueueLock.\r
+\r
+**/\r
 STATIC\r
 VOID\r
 CoreReleaseEventLock (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Exit critical section by releasing the lock on gEventQueueLock.\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
 {\r
   CoreReleaseLock (&gEventQueueLock);\r
 }\r
 \r
 \r
-EFI_STATUS\r
-CoreInitializeEventServices (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
 \r
+/**\r
   Initializes "event" support and populates parts of the System and Runtime Table.\r
 \r
-Arguments:\r
-\r
-  None\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS            Always return success\r
 \r
-  EFI_SUCCESS - Always return success\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+CoreInitializeEventServices (\r
+  VOID\r
+  )\r
 {\r
   UINTN        Index;\r
 \r
@@ -149,25 +116,18 @@ Returns:
 }\r
 \r
 \r
-VOID\r
-CoreDispatchEventNotifies (\r
-  IN EFI_TPL      Priority\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
 \r
+/**\r
   Dispatches all pending events.\r
 \r
-Arguments:\r
-\r
-  Priority - The task priority level of event notifications to dispatch\r
+  @param  Priority               The task priority level of event notifications \r
+                                 to dispatch\r
 \r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
+**/\r
+VOID\r
+CoreDispatchEventNotifies (\r
+  IN EFI_TPL      Priority\r
+  )\r
 {\r
   IEVENT          *Event;\r
   LIST_ENTRY      *Head;\r
@@ -213,26 +173,18 @@ Returns:
 }\r
 \r
 \r
+\r
+/**\r
+  Queues the event's notification function to fire.\r
+\r
+  @param  Event                  The Event to notify\r
+\r
+**/\r
 STATIC\r
 VOID\r
 CoreNotifyEvent (\r
   IN  IEVENT      *Event\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Queues the event's notification function to fire\r
-\r
-Arguments:\r
-\r
-  Event       - The Event to notify\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
 {\r
 \r
   //\r
@@ -259,23 +211,17 @@ Returns:
 \r
 \r
 \r
+\r
+/**\r
+  Signals all events in the EventGroup.\r
+\r
+  @param  EventGroup             The list to signal\r
+\r
+**/\r
 VOID\r
 CoreNotifySignalList (\r
   IN EFI_GUID     *EventGroup\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Signals all events in the EventGroup\r
-\r
-Arguments:\r
-  EventGroup - The list to signal\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
 {\r
   LIST_ENTRY              *Link;\r
   LIST_ENTRY              *Head;\r
@@ -294,6 +240,25 @@ Returns:
   CoreReleaseEventLock ();\r
 }\r
 \r
+\r
+/**\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
+  @retval EFI_OUT_OF_RESOURCES   The event could not be allocated\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 CoreCreateEvent (\r
@@ -303,45 +268,32 @@ CoreCreateEvent (
   IN VOID                     *NotifyContext, OPTIONAL\r
   OUT EFI_EVENT               *Event\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Creates a general-purpose event structure\r
-\r
-Arguments:\r
-  Type                - The type of event to create and its mode and attributes\r
-  NotifyTpl           - The task priority level of event notifications\r
-  NotifyFunction      - Pointer to the events notification function\r
-  NotifyContext       - Pointer to the notification functions context; corresponds to\r
-                        parameter "Context" in the notification function\r
-  Event               - Pointer to the newly created event if the call succeeds; undefined otherwise\r
-\r
-Returns:\r
-  EFI_SUCCESS           - The event structure was created\r
-  EFI_INVALID_PARAMETER - One of the parameters has an invalid value\r
-  EFI_OUT_OF_RESOURCES  - The event could not be allocated\r
-\r
---*/\r
 {\r
-  EFI_GUID            *GuidPtr;\r
-  EFI_EVENT_NOTIFY    Function;\r
-\r
-  GuidPtr = NULL;\r
-  Function = NotifyFunction;\r
+  return CoreCreateEventEx (Type, NotifyTpl, NotifyFunction, NotifyContext, NULL, Event);\r
+}\r
 \r
-  //\r
-  // Convert EFI 1.10 Events to thier UEFI 2.0 CreateEventEx mapping\r
-  //\r
-  if (Type == EVT_SIGNAL_EXIT_BOOT_SERVICES) {\r
-    GuidPtr = &gEfiEventExitBootServicesGuid;\r
-  } else if (Type == EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) {\r
-    GuidPtr = &gEfiEventVirtualAddressChangeGuid;\r
-  }\r
 \r
-  return CoreCreateEventEx (Type, NotifyTpl, Function, NotifyContext, GuidPtr, Event);\r
-}\r
 \r
+/**\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
+  @retval EFI_OUT_OF_RESOURCES   The event could not be allocated\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 CoreCreateEventEx (\r
@@ -352,26 +304,6 @@ CoreCreateEventEx (
   IN CONST EFI_GUID           *EventGroup,    OPTIONAL\r
   OUT EFI_EVENT               *Event\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Creates a general-purpose event structure\r
-\r
-Arguments:\r
-  Type                - The type of event to create and its mode and attributes\r
-  NotifyTpl           - The task priority level of event notifications\r
-  NotifyFunction      - Pointer to the events notification function\r
-  NotifyContext       - Pointer to the notification functions context; corresponds to\r
-                        parameter "Context" in the notification function\r
-  EventGrout          - GUID for EventGroup if NULL act the same as gBS->CreateEvent().\r
-  Event               - Pointer to the newly created event if the call succeeds; undefined otherwise\r
-\r
-Returns:\r
-  EFI_SUCCESS           - The event structure was created\r
-  EFI_INVALID_PARAMETER - One of the parameters has an invalid value\r
-  EFI_OUT_OF_RESOURCES  - The event could not be allocated\r
-\r
---*/\r
 {\r
   EFI_STATUS      Status;\r
   IEVENT          *IEvent;\r
@@ -396,10 +328,37 @@ Returns:
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  //\r
+  // Convert Event type for pre-defined Event groups\r
+  //\r
+  if (EventGroup != NULL) {\r
+    //\r
+    // For event group, type EVT_SIGNAL_EXIT_BOOT_SERVICES and EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE\r
+    // are not valid\r
+    //\r
+    if ((Type == EVT_SIGNAL_EXIT_BOOT_SERVICES) || (Type == EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE)) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+    if (CompareGuid (EventGroup, &gEfiEventExitBootServicesGuid)) {\r
+      Type = EVT_SIGNAL_EXIT_BOOT_SERVICES;\r
+    } else if (CompareGuid (EventGroup, &gEfiEventVirtualAddressChangeGuid)) {\r
+      Type = EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE;\r
+    }\r
+  } else {\r
+    //\r
+    // Convert EFI 1.10 Events to their UEFI 2.0 CreateEventEx mapping\r
+    //\r
+    if (Type == EVT_SIGNAL_EXIT_BOOT_SERVICES) {\r
+      EventGroup = &gEfiEventExitBootServicesGuid;\r
+    } else if (Type == EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) {\r
+      EventGroup = &gEfiEventVirtualAddressChangeGuid;\r
+    }\r
+  }\r
+\r
   //\r
   // If it's a notify type of event, check its parameters\r
   //\r
-  if ((Type & (EVT_NOTIFY_WAIT | EVT_NOTIFY_SIGNAL))) {\r
+  if ((Type & (EVT_NOTIFY_WAIT | EVT_NOTIFY_SIGNAL)) != 0) {\r
     //\r
     // Check for an invalid NotifyFunction or NotifyTpl\r
     //\r
@@ -422,7 +381,7 @@ Returns:
   // Allcoate and initialize a new event structure.\r
   //\r
   Status = CoreAllocatePool (\r
-             (Type & EVT_RUNTIME) ? EfiRuntimeServicesData: EfiBootServicesData,\r
+             ((Type & EVT_RUNTIME) != 0) ? EfiRuntimeServicesData: EfiBootServicesData,\r
              sizeof (IEVENT),\r
              (VOID **)&IEvent\r
              );\r
@@ -445,7 +404,7 @@ Returns:
 \r
   *Event = IEvent;\r
 \r
-  if (Type & EVT_RUNTIME) {\r
+  if ((Type & EVT_RUNTIME) != 0) {\r
     //\r
     // Keep a list of all RT events so we can tell the RT AP.\r
     //\r
@@ -476,28 +435,21 @@ Returns:
 \r
 \r
 \r
-EFI_STATUS\r
-EFIAPI\r
-CoreSignalEvent (\r
-  IN EFI_EVENT    UserEvent\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
 \r
+/**\r
   Signals the event.  Queues the event to be notified if needed\r
 \r
-Arguments:\r
-\r
-  UserEvent - The event to signal\r
+  @param  UserEvent              The event to signal \r
 \r
-Returns:\r
+  @retval EFI_INVALID_PARAMETER  Parameters are not valid. \r
+  @retval EFI_SUCCESS            The event was signaled.\r
 \r
-  EFI_INVALID_PARAMETER - Parameters are not valid.\r
-\r
-  EFI_SUCCESS - The event was signaled.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreSignalEvent (\r
+  IN EFI_EVENT    UserEvent\r
+  )\r
 {\r
   IEVENT          *Event;\r
 \r
@@ -543,29 +495,22 @@ Returns:
 }\r
 \r
 \r
+\r
+/**\r
+  Check the status of an event.\r
+\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_INVALID_PARAMETER  Event is of type EVT_NOTIFY_SIGNAL\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 CoreCheckEvent (\r
   IN EFI_EVENT        UserEvent\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Check the status of an event\r
-\r
-Arguments:\r
-\r
-  UserEvent - The event to check\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The event is in the signaled state\r
-  EFI_NOT_READY         - The event is not in the signaled state\r
-  EFI_INVALID_PARAMETER - Event is of type EVT_NOTIFY_SIGNAL\r
-\r
---*/\r
-\r
 {\r
   IEVENT      *Event;\r
   EFI_STATUS  Status;\r
@@ -619,6 +564,21 @@ Returns:
 \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
+\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
 EFI_STATUS\r
 EFIAPI\r
 CoreWaitForEvent (\r
@@ -626,27 +586,6 @@ CoreWaitForEvent (
   IN EFI_EVENT    *UserEvents,\r
   OUT UINTN       *UserIndex\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Stops execution until an event is signaled.\r
-\r
-Arguments:\r
-\r
-  NumberOfEvents  - The number of events in the UserEvents array\r
-  UserEvents      - An array of EFI_EVENT\r
-  UserIndex       - Pointer to the index of the event which satisfied the wait condition\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The event indicated by Index was signaled.\r
-  EFI_INVALID_PARAMETER - The event indicated by Index has a notification function or\r
-                          Event was not a valid type\r
-  EFI_UNSUPPORTED       - The current TPL is not TPL_APPLICATION\r
-\r
---*/\r
-\r
 {\r
   EFI_STATUS      Status;\r
   UINTN           Index;\r
@@ -681,29 +620,21 @@ Returns:
 }\r
 \r
 \r
-EFI_STATUS\r
-EFIAPI\r
-CoreCloseEvent (\r
-  IN EFI_EVENT    UserEvent\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
 \r
+/**\r
   Closes an event and frees the event structure.\r
 \r
-Arguments:\r
+  @param  UserEvent              Event to close \r
 \r
-  UserEvent - Event to close\r
-\r
-Returns:\r
-\r
-  EFI_INVALID_PARAMETER - Parameters are not valid.\r
-\r
-  EFI_SUCCESS - The event has been closed\r
-\r
---*/\r
+  @retval EFI_INVALID_PARAMETER  Parameters are not valid. \r
+  @retval EFI_SUCCESS            The event has been closed\r
 \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreCloseEvent (\r
+  IN EFI_EVENT    UserEvent\r
+  )\r
 {\r
   EFI_STATUS  Status;\r
   IEVENT      *Event;\r