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