Copyright (c) 2011, 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 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.
#define PERIODIC_SMI_LIBRARY_ALLOCATE_SIZE 0x08 |
Define the number of periodic SMI handler entries that should be allocated to the list of free periodic SMI handlers when the list of free periodic SMI handlers is empty.
Referenced by EnlargeFreePeriodicSmiLibraryHandlerList().
#define PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_LINK | ( | a | ) |
Value:
CR ( \ a, \ PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT, \ Link, \ PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_SIGNATURE \ )
Referenced by FindFreePeriodicSmiLibraryHandler(), LookupPeriodicSmiLibraryHandler(), and SmmPeriodicSmiLibDestructor().
#define PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_REGISTER_CONTEXT | ( | a | ) |
Value:
CR ( \ a, \ PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT, \ RegisterContext, \ PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_SIGNATURE \ )
Referenced by SetActivePeriodicSmiLibraryHandler().
#define PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_SIGNATURE SIGNATURE_32 ('P', 'S', 'M', 'I') |
Signature for a PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure
Referenced by EnlargeFreePeriodicSmiLibraryHandlerList().
BOOLEAN EnlargeFreePeriodicSmiLibraryHandlerList | ( | VOID | ) |
Add the additional entries to the list of free periodic SMI handlers. The function is assumed to be called only when the list of free periodic SMI handlers is empty.
TRUE | The additional entries were added. | |
FALSE | There was no available resource for the additional entries. |
References AllocatePool(), InsertHeadList(), NULL, PERIODIC_SMI_LIBRARY_ALLOCATE_SIZE, and PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_SIGNATURE.
Referenced by FindFreePeriodicSmiLibraryHandler(), and SmmPeriodicSmiLibConstructor().
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT* FindFreePeriodicSmiLibraryHandler | ( | VOID | ) |
Internal worker function that returns a free entry for a new periodic SMI handler. If no free entries are available, then additional entries are allocated.
NULL | There are not enough resources available to to allocate a free entry. | |
other | Pointer to a free PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure. |
References EnlargeFreePeriodicSmiLibraryHandlerList(), GetFirstNode(), InsertTailList(), IsListEmpty(), NULL, PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_LINK, and RemoveEntryList().
Referenced by PeriodicSmiEnable().
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT* GetActivePeriodicSmiLibraryHandler | ( | VOID | ) |
Internal worker function that returns a pointer to the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure associated with the periodic SMI handler that is currently being executed. If a periodic SMI handler is not currently being executed, the NULL is returned.
NULL | A periodic SMI handler is not currently being executed. | |
other | Pointer to the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT associated with the active periodic SMI handler. |
References gActivePeriodicSmiLibraryHandler.
Referenced by LookupPeriodicSmiLibraryHandler(), PeriodicSmiDisable(), PeriodicSmiExecutionTime(), PeriodicSmiExit(), and PeriodicSmiYield().
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT* LookupPeriodicSmiLibraryHandler | ( | IN EFI_HANDLE | DispatchHandle | ) |
Internal worker function that returns a pointer to the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure associated with the DispatchHandle that was returned when the periodic SMI handler was enabled with PeriodicSmiEnable(). If DispatchHandle is NULL, then the active periodic SMI handler is returned. If DispatchHandle is NULL and there is no active periodic SMI handler, then NULL is returned.
[in] | DispatchHandle | DispatchHandle that was returned when the periodic SMI handler was enabled with PeriodicSmiEnable(). This is an optional parameter that may be NULL. If this parameter is NULL, then the active periodic SMI handler is returned. |
NULL | DispatchHandle is NULL and there is no active periodic SMI handler. | |
NULL | DispatchHandle does not match any of the periodic SMI handlers that have been enabled with PeriodicSmiEnable(). | |
other | Pointer to the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT associated with the DispatchHandle. |
References GetActivePeriodicSmiLibraryHandler(), GetFirstNode(), GetNextNode(), IsNull(), NULL, and PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_LINK.
Referenced by PeriodicSmiDisable().
BOOLEAN EFIAPI PeriodicSmiDisable | ( | IN EFI_HANDLE | DispatchHandle | ) |
This function disables a periodic SMI handler that has been previously enabled with PeriodicSmiEnable().
[in] | DispatchHandle | A handle associated with a previously enabled periodic SMI handler. This is an optional parameter that may be NULL. If it is NULL, then the active periodic SMI handlers is disabled. |
FALSE | DispatchHandle is NULL and there is no active periodic SMI handler. | |
FALSE | The periodic SMI handler specified by DispatchHandle has not been enabled with PeriodicSmiEnable(). | |
TRUE | The periodic SMI handler specified by DispatchHandle has been disabled. If DispatchHandle is NULL, then the active periodic SMI handler has been disabled. |
References EFI_ERROR, FALSE, GetActivePeriodicSmiLibraryHandler(), LookupPeriodicSmiLibraryHandler(), NULL, ReclaimPeriodicSmiLibraryHandler(), TRUE, and _EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL::UnRegister.
Referenced by SmmPeriodicSmiLibDestructor().
EFI_STATUS EFIAPI PeriodicSmiDispatchFunction | ( | IN EFI_HANDLE | DispatchHandle, | |
IN CONST VOID * | Context, | |||
IN OUT VOID * | CommBuffer, | |||
IN OUT UINTN * | CommBufferSize | |||
) |
Internal worker function that transfers control to a periodic SMI handler that was enabled using PeriodicSmiEnable().
[in] | DispatchHandle | The unique handle assigned to this handler by SmiHandlerRegister(). |
[in] | Context | Points to an optional handler context which was specified when the handler was registered. |
[in,out] | CommBuffer | A pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment. |
[in,out] | CommBufferSize | The size of the CommBuffer. |
EFI_SUCCESS | The interrupt was handled and quiesced. No other handlers should still be called. | |
EFI_WARN_INTERRUPT_SOURCE_QUIESCED | The interrupt has been quiesced but other handlers should still be called. | |
EFI_WARN_INTERRUPT_SOURCE_PENDING | The interrupt is still pending and other handlers should still be called. | |
EFI_INTERRUPT_PENDING | The interrupt could not be quiesced. |
References AcquireSpinLock(), AcquireSpinLockOrFail(), CpuPause(), _EFI_SMM_SYSTEM_TABLE2::CurrentlyExecutingCpu, EFI_ERROR, EFI_NOT_FOUND, EFI_SUCCESS, EFI_SMM_PERIODIC_TIMER_CONTEXT::ElapsedTime, gSmst, NULL, PERIODIC_SMI_LIBRARY_ANY_CPU, PeriodicSmiDispatchFunctionOnCpu(), PeriodicSmiDispatchFunctionWithLock(), ReclaimPeriodicSmiLibraryHandler(), ReleaseSpinLock(), SetActivePeriodicSmiLibraryHandler(), and _EFI_SMM_SYSTEM_TABLE2::SmmStartupThisAp.
Referenced by PeriodicSmiEnable().
VOID EFIAPI PeriodicSmiDispatchFunctionOnCpu | ( | PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT * | PeriodicSmiLibraryHandler | ) |
Internal worker function that transfers control to an enabled periodic SMI handler on the specified logial CPU. This function determines if the periodic SMI handler yielded and needs to be resumed. It also and switches to an allocated stack if one was allocated in PeriodicSmiEnable().
[in] | PeriodicSmiLibraryHandler | A pointer to the context for the periodic SMI handler to execute. |
References ASSERT, CpuDeadLoop(), FALSE, GetPerformanceCounter(), LongJump(), NULL, PeriodicSmiDispatchFunctionSwitchStack(), PeriodicSmiExit(), SetJump(), and SwitchStack().
Referenced by PeriodicSmiDispatchFunction(), and PeriodicSmiDispatchFunctionWithLock().
VOID EFIAPI PeriodicSmiDispatchFunctionSwitchStack | ( | IN VOID * | Context1, | |
IN VOID * | Context2 | |||
) |
Internal worker function that transfers control to an enabled periodic SMI handler. If the enabled periodic SMI handler was allocated its own stack, then this function is called on that allocated stack through the BaseLin function SwitchStack().
[in] | Context1 | Context1 parameter passed into SwitchStack(). |
[in] | Context2 | Context2 parameter passed into SwitchStack(). |
References PeriodicSmiExit().
Referenced by PeriodicSmiDispatchFunctionOnCpu().
VOID EFIAPI PeriodicSmiDispatchFunctionWithLock | ( | IN OUT VOID * | Buffer | ) |
Internal worker function that transfers control to an enabled periodic SMI handler on the specified logial CPU. This worker function is only called using the SMM Services Table function SmmStartupThisAp() to execute the periodic SMI handler on a logical CPU that is different than the one that is running the SMM Foundation. When the periodic SMI handler returns, a lock is released to notify the CPU that is running the SMM Foundation that the periodic SMI handler execution has finished its execution.
[in,out] | Buffer | A pointer to the context for the periodic SMI handler. |
References PeriodicSmiDispatchFunctionOnCpu(), and ReleaseSpinLock().
Referenced by PeriodicSmiDispatchFunction().
EFI_STATUS EFIAPI PeriodicSmiEnable | ( | IN OUT EFI_HANDLE * | DispatchHandle, | |
IN PERIODIC_SMI_LIBRARY_HANDLER | DispatchFunction, | |||
IN CONST VOID * | Context, | |||
IN UINT64 | TickPeriod, | |||
IN UINTN | Cpu, | |||
IN UINTN | StackSize | |||
) |
This function enables a periodic SMI handler.
[in,out] | DispatchHandle | A pointer to the handle associated with the enabled periodic SMI handler. This is an optional parameter that may be NULL. If it is NULL, then the handle will not be returned, which means that the periodic SMI handler can never be disabled. |
[in] | DispatchFunction | A pointer to a periodic SMI handler function. |
[in] | Context | Optional content to pass into DispatchFunction. |
[in] | TickPeriod | The requested tick period in 100ns units that control should be givien to the periodic SMI handler. Must be one of the supported values returned by PeriodicSmiSupportedPickPeriod(). |
[in] | Cpu | Specifies the CPU that is required to execute the periodic SMI handler. If Cpu is PERIODIC_SMI_LIBRARY_ANY_CPU, then the periodic SMI handler will always be executed on the SMST CurrentlyExecutingCpu, which may vary across periodic SMIs. If Cpu is between 0 and the SMST NumberOfCpus, then the periodic SMI will always be executed on the requested CPU. |
[in] | StackSize | The size, in bytes, of the stack to allocate for use by the periodic SMI handler. If 0, then the default stack will be used. |
EFI_INVALID_PARAMETER | DispatchFunction is NULL. | |
EFI_UNSUPPORTED | TickPeriod is not a supported tick period. The supported tick periods can be retrieved using PeriodicSmiSupportedTickPeriod(). | |
EFI_INVALID_PARAMETER | Cpu is not PERIODIC_SMI_LIBRARY_ANY_CPU or in the range 0 to SMST NumberOfCpus. | |
EFI_OUT_OF_RESOURCES | There are not enough resources to enable the periodic SMI handler. | |
EFI_OUT_OF_RESOURCES | There are not enough resources to allocate the stack speficied by StackSize. | |
EFI_SUCCESS | The periodic SMI handler was enabled. |
References ALIGN_VALUE, AllocatePages(), EFI_ERROR, EFI_INVALID_PARAMETER, EFI_OUT_OF_RESOURCES, EFI_PAGE_SIZE, EFI_SIZE_TO_PAGES, EFI_SUCCESS, EFI_UNSUPPORTED, FALSE, FindFreePeriodicSmiLibraryHandler(), GetPerformanceCounterProperties(), gSmiTickPeriodTable, gSmst, InitializeSpinLock(), NULL, _EFI_SMM_SYSTEM_TABLE2::NumberOfCpus, PERIODIC_SMI_LIBRARY_ANY_CPU, PeriodicSmiDispatchFunction(), ReclaimPeriodicSmiLibraryHandler(), _EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL::Register, VOID, and ZeroMem().
This function returns the time in 100ns units since the periodic SMI handler function was called. If the periodic SMI handler was resumed through PeriodicSmiYield(), then the time returned is the time in 100ns units since PeriodicSmiYield() returned.
References DivU64x64Remainder(), GetActivePeriodicSmiLibraryHandler(), GetPerformanceCounter(), MultU64x32(), and NULL.
VOID EFIAPI PeriodicSmiExit | ( | VOID | ) |
This function returns control back to the SMM Foundation. When the next periodic SMI for the currently executing handler is triggered, the periodic SMI handler will restarted from its registered DispatchFunction entry point. If this function is not called from within an enabled periodic SMI handler, then control is returned to the calling function.
References ASSERT, CpuDeadLoop(), FALSE, GetActivePeriodicSmiLibraryHandler(), LongJump(), and NULL.
Referenced by PeriodicSmiDispatchFunctionOnCpu(), PeriodicSmiDispatchFunctionSwitchStack(), and PeriodicSmiYield().
This function returns a pointer to a table of supported periodic SMI tick periods in 100 ns units sorted from largest to smallest. The table contains a array of UINT64 values terminated by a tick period value of 0. The returned table must be treated as read-only data and must not be freed.
References gSmiTickPeriodTable.
This function yields control back to the SMM Foundation. When the next periodic SMI for the currently executing handler is triggered, the periodic SMI handler will be resumed and this function will return. Use of this function requires a seperate stack for the periodic SMI handler. A non zero stack size must be specified in PeriodicSmiEnable() for this function to be used.
If the stack size passed into PeriodicSmiEnable() was zero, the 0 is returned.
If this function is not called from within an enabled periodic SMI handler, then 0 is returned.
References FALSE, GetActivePeriodicSmiLibraryHandler(), NULL, PeriodicSmiExit(), SetJump(), and TRUE.
VOID ReclaimPeriodicSmiLibraryHandler | ( | PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT * | PeriodicSmiLibraryHandler | ) |
Internal worker function that moves the specified periodic SMI handler from the list of managed periodic SMI handlers to the list of free periodic SMI handlers.
[in] | PeriodicSmiLibraryHandler | Pointer to the periodic SMI handler to be reclaimed. |
References ASSERT, EFI_SIZE_TO_PAGES, FreePages(), InsertHeadList(), NULL, and RemoveEntryList().
Referenced by PeriodicSmiDisable(), PeriodicSmiDispatchFunction(), and PeriodicSmiEnable().
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT* SetActivePeriodicSmiLibraryHandler | ( | IN CONST VOID * | Context | ) |
Internal worker function that sets that active periodic SMI handler based on the Context used when the periodic SMI handler was registered with the SMM Periodic Timer Dispatch 2 Protocol. If Context is NULL, then the state is updated to show that there is not active periodic SMI handler. A pointer to the active PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure is returned.
NULL | Context is NULL. | |
other | Pointer to the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT associated with Context. |
References gActivePeriodicSmiLibraryHandler, NULL, and PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_REGISTER_CONTEXT.
Referenced by PeriodicSmiDispatchFunction().
EFI_STATUS EFIAPI SmmPeriodicSmiLibConstructor | ( | IN EFI_HANDLE | ImageHandle, | |
IN EFI_SYSTEM_TABLE * | SystemTable | |||
) |
This constructor function caches the pointer to the SMM Periodic Timer Dispatch 2 Protocol and collects the list SMI tick rates that the hardware supports.
[in] | ImageHandle | The firmware allocated handle for the EFI image. |
[in] | SystemTable | A pointer to the EFI System Table. |
EFI_SUCCESS | The constructor always returns EFI_SUCCESS. |
References AllocateZeroPool(), ASSERT, ASSERT_EFI_ERROR, EFI_SUCCESS, EnlargeFreePeriodicSmiLibraryHandlerList(), gEfiSmmPeriodicTimerDispatch2ProtocolGuid, gSmiTickPeriodTable, gSmst, NULL, _EFI_SMM_SYSTEM_TABLE2::SmmLocateProtocol, and VOID.
EFI_STATUS EFIAPI SmmPeriodicSmiLibDestructor | ( | IN EFI_HANDLE | ImageHandle, | |
IN EFI_SYSTEM_TABLE * | SystemTable | |||
) |
The constructor function caches the pointer to the SMM Periodic Timer Dispatch 2 Protocol and collects the list SMI tick rates that the hardware supports.
[in] | ImageHandle | The firmware allocated handle for the EFI image. |
[in] | SystemTable | A pointer to the EFI System Table. |
EFI_SUCCESS | The constructor always returns EFI_SUCCESS. |
References EFI_SUCCESS, FreePool(), GetFirstNode(), GetNextNode(), gSmiTickPeriodTable, IsNull(), NULL, PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_LINK, PeriodicSmiDisable(), and RemoveEntryList().
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT* gActivePeriodicSmiLibraryHandler = NULL |
Pointer to the periodic SMI handler that is currently being executed. Is set to NULL if no periodic SMI handler is currently being executed.
Referenced by GetActivePeriodicSmiLibraryHandler(), and SetActivePeriodicSmiLibraryHandler().
Initial value:
Linked list of free periodic SMI handlers that this library can use.Initial value:
Linked list of periodic SMI handlers that this library is currently managing.UINT64* gSmiTickPeriodTable = NULL |
Pointer to a table of supported periodic SMI tick periods in 100 ns units sorted from largest to smallest terminated by a tick period value of 0. This table is allocated using AllocatePool() in the constructor and filled in based on the values returned from the SMM Periodic Timer Dispatch 2 Protocol function GetNextShorterInterval().
Referenced by PeriodicSmiEnable(), PeriodicSmiSupportedTickPeriod(), SmmPeriodicSmiLibConstructor(), and SmmPeriodicSmiLibDestructor().
Pointer to the SMM Periodic Timer Disatch Protocol that was located in the constuctor.