TianoCore EDK2 master
|
#include <PiSmm.h>
#include <Protocol/SmmPeriodicTimerDispatch2.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/SynchronizationLib.h>
#include <Library/DebugLib.h>
#include <Library/TimerLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/SmmServicesTableLib.h>
#include <Library/SmmPeriodicSmiLib.h>
Go to the source code of this file.
Data Structures | |
struct | PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT |
Macros | |
#define | PERIODIC_SMI_LIBRARY_ALLOCATE_SIZE 0x08 |
#define | PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_SIGNATURE SIGNATURE_32 ('P', 'S', 'M', 'I') |
#define | PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_LINK(a) |
SMM Periodic SMI Library.
Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file SmmPeriodicSmiLib.c.
#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.
Definition at line 27 of file SmmPeriodicSmiLib.c.
#define PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_LINK | ( | a | ) |
Macro that returns a pointer to a PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure based on a pointer to a Link field.
Definition at line 146 of file SmmPeriodicSmiLib.c.
#define PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_SIGNATURE SIGNATURE_32 ('P', 'S', 'M', 'I') |
Signature for a PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure
Definition at line 32 of file SmmPeriodicSmiLib.c.
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. |
Definition at line 328 of file SmmPeriodicSmiLib.c.
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. |
Definition at line 361 of file SmmPeriodicSmiLib.c.
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. |
Definition at line 198 of file SmmPeriodicSmiLib.c.
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT * LookupPeriodicSmiLibraryHandler | ( | IN EFI_HANDLE DispatchHandle | OPTIONAL | ) |
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. |
Definition at line 228 of file SmmPeriodicSmiLib.c.
BOOLEAN EFIAPI PeriodicSmiDisable | ( | IN EFI_HANDLE DispatchHandle | OPTIONAL | ) |
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. |
Definition at line 1015 of file SmmPeriodicSmiLib.c.
EFI_STATUS EFIAPI PeriodicSmiDispatchFunction | ( | IN EFI_HANDLE | DispatchHandle, |
IN CONST VOID *Context | OPTIONAL, | ||
IN OUT VOID *CommBuffer | OPTIONAL, | ||
IN OUT UINTN *CommBufferSize | OPTIONAL | ||
) |
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. |
Definition at line 777 of file SmmPeriodicSmiLib.c.
VOID EFIAPI PeriodicSmiDispatchFunctionOnCpu | ( | PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT * | PeriodicSmiLibraryHandler | ) |
Internal worker function that transfers control to an enabled periodic SMI handler on the specified logical 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. |
Definition at line 654 of file SmmPeriodicSmiLib.c.
VOID EFIAPI PeriodicSmiDispatchFunctionSwitchStack | ( | IN VOID *Context1 | OPTIONAL, |
IN VOID *Context2 | OPTIONAL | ||
) |
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(). |
Definition at line 612 of file SmmPeriodicSmiLib.c.
Internal worker function that transfers control to an enabled periodic SMI handler on the specified logical 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. |
Definition at line 731 of file SmmPeriodicSmiLib.c.
EFI_STATUS EFIAPI PeriodicSmiEnable | ( | IN OUT EFI_HANDLE *DispatchHandle | OPTIONAL, |
IN PERIODIC_SMI_LIBRARY_HANDLER | DispatchFunction, | ||
IN CONST VOID *Context | OPTIONAL, | ||
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 given 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 specified by StackSize. |
EFI_SUCCESS | The periodic SMI handler was enabled. |
Definition at line 905 of file SmmPeriodicSmiLib.c.
UINT64 EFIAPI PeriodicSmiExecutionTime | ( | VOID | ) |
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.
Definition at line 422 of file SmmPeriodicSmiLib.c.
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.
Definition at line 498 of file SmmPeriodicSmiLib.c.
UINT64 *EFIAPI PeriodicSmiSupportedTickPeriod | ( | VOID | ) |
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.
Definition at line 399 of file SmmPeriodicSmiLib.c.
UINT64 EFIAPI PeriodicSmiYield | ( | VOID | ) |
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 separate 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.
Definition at line 544 of file SmmPeriodicSmiLib.c.
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. |
Definition at line 302 of file SmmPeriodicSmiLib.c.
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT * SetActivePeriodicSmiLibraryHandler | ( | IN EFI_HANDLE DispatchHandle | OPTIONAL | ) |
Internal worker function that sets that active periodic SMI handler based on the DispatchHandle that was returned when the periodic SMI handler was enabled with PeriodicSmiEnable(). If DispatchHandle 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.
[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 state is updated to show that there is not active periodic SMI handler. |
NULL | DispatchHandle is NULL. |
other | Pointer to the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT associated with DispatchHandle. |
Definition at line 282 of file SmmPeriodicSmiLib.c.
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. |
Definition at line 1067 of file SmmPeriodicSmiLib.c.
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. |
Definition at line 1145 of file SmmPeriodicSmiLib.c.
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.
Definition at line 184 of file SmmPeriodicSmiLib.c.
LIST_ENTRY gFreePeriodicSmiLibraryHandlers |
Linked list of free periodic SMI handlers that this library can use.
Definition at line 171 of file SmmPeriodicSmiLib.c.
LIST_ENTRY gPeriodicSmiLibraryHandlers |
Linked list of periodic SMI handlers that this library is currently managing.
Definition at line 177 of file SmmPeriodicSmiLib.c.
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().
Definition at line 166 of file SmmPeriodicSmiLib.c.
EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL* gSmmPeriodicTimerDispatch2 = NULL |
Pointer to the SMM Periodic Timer Dispatch Protocol that was located in the constructor.
Definition at line 157 of file SmmPeriodicSmiLib.c.