From 670d4d88ac2fdddf7d99d276610b194ce03effee Mon Sep 17 00:00:00 2001 From: lzeng14 Date: Thu, 26 Apr 2012 03:32:53 +0000 Subject: Return EFI_INVALID_PARAMETER when Type has either EVT_NOTIFY_SIGNAL or EVT_NOTIFY_WAIT set and NotifyTpl is not a supported TPL level. Signed-off-by: Star Zeng Reviewed-by: Chao Zhang git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13222 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/DxeMain.h | 33 ++++++++++++++++++++++-- MdeModulePkg/Core/Dxe/Event/Event.c | 51 ++++++++++++++++++++++++++++++++++--- MdeModulePkg/Core/Dxe/Event/Timer.c | 5 ++-- 3 files changed, 82 insertions(+), 7 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 48a57df650..2a8161554a 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -1409,7 +1409,7 @@ CoreExit ( /** - Creates a general-purpose event structure. + Creates an event. @param Type The type of event to create and its mode and attributes @@ -1439,7 +1439,7 @@ CoreCreateEvent ( /** - Creates a general-purpose event structure + Creates an event in a group. @param Type The type of event to create and its mode and attributes @@ -1469,7 +1469,36 @@ CoreCreateEventEx ( OUT EFI_EVENT *Event ); +/** + Creates a general-purpose event structure + + @param Type The type of event to create and its mode and + attributes + @param NotifyTpl The task priority level of event notifications + @param NotifyFunction Pointer to the events notification function + @param NotifyContext Pointer to the notification functions context; + corresponds to parameter "Context" in the + notification function + @param EventGroup GUID for EventGroup if NULL act the same as + gBS->CreateEvent(). + @param Event Pointer to the newly created event if the call + succeeds; undefined otherwise + @retval EFI_SUCCESS The event structure was created + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value + @retval EFI_OUT_OF_RESOURCES The event could not be allocated + +**/ +EFI_STATUS +EFIAPI +CoreCreateEventInternal ( + IN UINT32 Type, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN CONST VOID *NotifyContext, OPTIONAL + IN CONST EFI_GUID *EventGroup, OPTIONAL + OUT EFI_EVENT *Event + ); /** Sets the type of timer and the trigger time for a timer event. diff --git a/MdeModulePkg/Core/Dxe/Event/Event.c b/MdeModulePkg/Core/Dxe/Event/Event.c index d9fc7586a7..1a25b17178 100644 --- a/MdeModulePkg/Core/Dxe/Event/Event.c +++ b/MdeModulePkg/Core/Dxe/Event/Event.c @@ -1,7 +1,7 @@ /** @file UEFI Event support functions implemented in this file. -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -277,7 +277,7 @@ CoreNotifySignalList ( /** - Creates a general-purpose event structure. + Creates an event. @param Type The type of event to create and its mode and attributes @@ -310,7 +310,7 @@ CoreCreateEvent ( /** - Creates a general-purpose event structure + Creates an event in a group. @param Type The type of event to create and its mode and attributes @@ -339,6 +339,51 @@ CoreCreateEventEx ( IN CONST EFI_GUID *EventGroup, OPTIONAL OUT EFI_EVENT *Event ) +{ + // + // If it's a notify type of event, check for invalid NotifyTpl + // + if ((Type & (EVT_NOTIFY_WAIT | EVT_NOTIFY_SIGNAL)) != 0) { + if (NotifyTpl != TPL_APPLICATION && + NotifyTpl != TPL_CALLBACK && + NotifyTpl != TPL_NOTIFY) { + return EFI_INVALID_PARAMETER; + } + } + + return CoreCreateEventInternal (Type, NotifyTpl, NotifyFunction, NotifyContext, EventGroup, Event); +} + +/** + Creates a general-purpose event structure + + @param Type The type of event to create and its mode and + attributes + @param NotifyTpl The task priority level of event notifications + @param NotifyFunction Pointer to the events notification function + @param NotifyContext Pointer to the notification functions context; + corresponds to parameter "Context" in the + notification function + @param EventGroup GUID for EventGroup if NULL act the same as + gBS->CreateEvent(). + @param Event Pointer to the newly created event if the call + succeeds; undefined otherwise + + @retval EFI_SUCCESS The event structure was created + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value + @retval EFI_OUT_OF_RESOURCES The event could not be allocated + +**/ +EFI_STATUS +EFIAPI +CoreCreateEventInternal ( + IN UINT32 Type, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN CONST VOID *NotifyContext, OPTIONAL + IN CONST EFI_GUID *EventGroup, OPTIONAL + OUT EFI_EVENT *Event + ) { EFI_STATUS Status; IEVENT *IEvent; diff --git a/MdeModulePkg/Core/Dxe/Event/Timer.c b/MdeModulePkg/Core/Dxe/Event/Timer.c index b1a5e3cdc8..1b20e327cd 100644 --- a/MdeModulePkg/Core/Dxe/Event/Timer.c +++ b/MdeModulePkg/Core/Dxe/Event/Timer.c @@ -1,7 +1,7 @@ /** @file Core Timer Services -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -172,11 +172,12 @@ CoreInitializeTimer ( { EFI_STATUS Status; - Status = CoreCreateEvent ( + Status = CoreCreateEventInternal ( EVT_NOTIFY_SIGNAL, TPL_HIGH_LEVEL - 1, CoreCheckTimers, NULL, + NULL, &mEfiCheckTimerEvent ); ASSERT_EFI_ERROR (Status); -- cgit v1.2.3