]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Event/Event.c
MdeModulePkg DxeCore: Fix issue to print GUID value %g without pointer
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Event / Event.c
index 1a25b171786f1b5f6910327df47fc59ba6ab7447..86ca369d56ffad1a9f728138e1b18bc38dfb9c06 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   UEFI Event support functions implemented in this file.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<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
@@ -142,7 +143,7 @@ CoreInitializeEventServices (
   CoreCreateEventEx (\r
     EVT_NOTIFY_SIGNAL,\r
     TPL_NOTIFY,\r
-    CoreEmptyCallbackFunction,\r
+    EfiEventEmptyFunction,\r
     NULL,\r
     &gIdleLoopEventGuid,\r
     &gIdleLoopEvent\r
@@ -204,7 +205,7 @@ CoreDispatchEventNotifies (
     CoreAcquireEventLock ();\r
   }\r
 \r
-  gEventPending &= ~(1 << Priority);\r
+  gEventPending &= ~(UINTN)(1 << Priority);\r
   CoreReleaseEventLock ();\r
 }\r
 \r
@@ -477,7 +478,7 @@ CoreCreateEventInternal (
   IEvent->NotifyContext  = (VOID *)NotifyContext;\r
   if (EventGroup != NULL) {\r
     CopyGuid (&IEvent->EventGroup, EventGroup);\r
-    IEvent->ExFlag = TRUE;\r
+    IEvent->ExFlag |= EVT_EXFLAG_EVENT_GROUP;\r
   }\r
 \r
   *Event = IEvent;\r
@@ -554,7 +555,7 @@ CoreSignalEvent (
     // If signalling type is a notify function, queue it\r
     //\r
     if ((Event->Type & EVT_NOTIFY_SIGNAL) != 0) {\r
-      if (Event->ExFlag) {\r
+      if ((Event->ExFlag & EVT_EXFLAG_EVENT_GROUP) != 0) {\r
         //\r
         // The CreateEventEx() style requires all members of the Event Group\r
         //  to be signaled.\r
@@ -673,6 +674,14 @@ CoreWaitForEvent (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
+  if (NumberOfEvents == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (UserEvents == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   for(;;) {\r
 \r
     for(Index = 0; Index < NumberOfEvents; Index++) {\r
@@ -683,7 +692,9 @@ CoreWaitForEvent (
       // provide index of event that caused problem\r
       //\r
       if (Status != EFI_NOT_READY) {\r
-        *UserIndex = Index;\r
+        if (UserIndex != NULL) {\r
+          *UserIndex = Index;\r
+        }\r
         return Status;\r
       }\r
     }\r
@@ -754,8 +765,15 @@ CoreCloseEvent (
   //\r
   // If the event is registered on a protocol notify, then remove it from the protocol database\r
   //\r
-  CoreUnregisterProtocolNotify (Event);\r
+  if ((Event->ExFlag & EVT_EXFLAG_EVENT_PROTOCOL_NOTIFICATION) != 0) {\r
+    CoreUnregisterProtocolNotify (Event);\r
+  }\r
 \r
+  //\r
+  // To avoid the Event to be signalled wrongly after closed,\r
+  // clear the Signature of Event before free pool.\r
+  //\r
+  Event->Signature = 0;\r
   Status = CoreFreePool (Event);\r
   ASSERT_EFI_ERROR (Status);\r
 \r