From bb8ffffd1c0ff0ee697c26d377fd9767097cc02b Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Thu, 14 Feb 2008 02:47:49 +0000 Subject: [PATCH] Fix a conformance issue in gBS->CreateEvent() & gBS->CreateEventEx(): 1. gBS->CreateEventEx() with EventGroup = NULL should behavior like gBS->CreateEvent() 2. EVT_SIGNAL_EXIT_BOOT_SERVICES & EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE are invalid parameters for gBS->CreateEventEx() if the EventGroup is not NULL. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4692 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/Event/event.c | 46 ++++++++++++++++++----------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Event/event.c b/MdeModulePkg/Core/Dxe/Event/event.c index c4d6eeb553..81f0b1af10 100644 --- a/MdeModulePkg/Core/Dxe/Event/event.c +++ b/MdeModulePkg/Core/Dxe/Event/event.c @@ -323,22 +323,7 @@ Returns: --*/ { - EFI_GUID *GuidPtr; - EFI_EVENT_NOTIFY Function; - - GuidPtr = NULL; - Function = NotifyFunction; - - // - // Convert EFI 1.10 Events to their UEFI 2.0 CreateEventEx mapping - // - if (Type == EVT_SIGNAL_EXIT_BOOT_SERVICES) { - GuidPtr = &gEfiEventExitBootServicesGuid; - } else if (Type == EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) { - GuidPtr = &gEfiEventVirtualAddressChangeGuid; - } - - return CoreCreateEventEx (Type, NotifyTpl, Function, NotifyContext, GuidPtr, Event); + return CoreCreateEventEx (Type, NotifyTpl, NotifyFunction, NotifyContext, NULL, Event); } @@ -363,7 +348,7 @@ Arguments: NotifyFunction - Pointer to the events notification function NotifyContext - Pointer to the notification functions context; corresponds to parameter "Context" in the notification function - EventGrout - GUID for EventGroup if NULL act the same as gBS->CreateEvent(). + EventGroup - GUID for EventGroup if NULL act the same as gBS->CreateEvent(). Event - Pointer to the newly created event if the call succeeds; undefined otherwise Returns: @@ -396,6 +381,33 @@ Returns: return EFI_INVALID_PARAMETER; } + // + // Convert Event type for pre-defined Event groups + // + if (EventGroup != NULL) { + // + // For event group, type EVT_SIGNAL_EXIT_BOOT_SERVICES and EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE + // are not valid + // + 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)) { + Type = EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE; + } + } else { + // + // Convert EFI 1.10 Events to their UEFI 2.0 CreateEventEx mapping + // + if (Type == EVT_SIGNAL_EXIT_BOOT_SERVICES) { + EventGroup = &gEfiEventExitBootServicesGuid; + } else if (Type == EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) { + EventGroup = &gEfiEventVirtualAddressChangeGuid; + } + } + // // If it's a notify type of event, check its parameters //