MdePkg: Clean up source files
1. Do not use tab characters 2. No trailing white space in one line 3. All files must end with CRLF Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
@@ -62,13 +62,13 @@ typedef struct {
|
||||
///
|
||||
UINT64 TickPeriod;
|
||||
///
|
||||
/// The Cpu number that is required to execute DispatchFunction. If Cpu is
|
||||
/// set to PERIODIC_SMI_LIBRARY_ANY_CPU, then DispatchFunction may be executed
|
||||
/// The Cpu number that is required to execute DispatchFunction. If Cpu is
|
||||
/// set to PERIODIC_SMI_LIBRARY_ANY_CPU, then DispatchFunction may be executed
|
||||
/// on any CPU.
|
||||
///
|
||||
UINTN Cpu;
|
||||
///
|
||||
/// The size, in bytes, of the stack allocated for a periodic SMI handler.
|
||||
/// The size, in bytes, of the stack allocated for a periodic SMI handler.
|
||||
/// This value must be a multiple of EFI_PAGE_SIZE.
|
||||
///
|
||||
UINTN StackSize;
|
||||
@@ -82,27 +82,27 @@ typedef struct {
|
||||
///
|
||||
SPIN_LOCK DispatchLock;
|
||||
///
|
||||
/// The rate in Hz of the performance counter that is used to measure the
|
||||
/// The rate in Hz of the performance counter that is used to measure the
|
||||
/// amount of time that a periodic SMI handler executes.
|
||||
///
|
||||
UINT64 PerfomanceCounterRate;
|
||||
///
|
||||
/// The start count value of the performance counter that is used to measure
|
||||
/// The start count value of the performance counter that is used to measure
|
||||
/// the amount of time that a periodic SMI handler executes.
|
||||
///
|
||||
UINT64 PerfomanceCounterStartValue;
|
||||
///
|
||||
/// The end count value of the performance counter that is used to measure
|
||||
/// The end count value of the performance counter that is used to measure
|
||||
/// the amount of time that a periodic SMI handler executes.
|
||||
///
|
||||
UINT64 PerfomanceCounterEndValue;
|
||||
///
|
||||
/// The context record passed into the Register() function of the SMM Periodic
|
||||
/// The context record passed into the Register() function of the SMM Periodic
|
||||
/// Timer Dispatch Protocol when a periodic SMI handler is enabled.
|
||||
///
|
||||
EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT RegisterContext;
|
||||
///
|
||||
/// The handle returned from the Register() function of the SMM Periodic
|
||||
/// The handle returned from the Register() function of the SMM Periodic
|
||||
/// Timer Dispatch Protocol when a periodic SMI handler is enabled.
|
||||
///
|
||||
EFI_HANDLE DispatchHandle;
|
||||
@@ -112,7 +112,7 @@ typedef struct {
|
||||
///
|
||||
UINT64 DispatchTotalTime;
|
||||
///
|
||||
/// The performance counter value that was captured the last time that the
|
||||
/// The performance counter value that was captured the last time that the
|
||||
/// periodic SMI handler called PeriodcSmiExecutionTime(). This allows the
|
||||
/// time value returned by PeriodcSmiExecutionTime() to be accurate even when
|
||||
/// the performance counter rolls over.
|
||||
@@ -120,19 +120,19 @@ typedef struct {
|
||||
UINT64 DispatchCheckPointTime;
|
||||
///
|
||||
/// Buffer used to save the context when control is transfer from this library
|
||||
/// to an enabled periodic SMI handler. This saved context is used when the
|
||||
/// periodic SMI handler exits or yields.
|
||||
/// to an enabled periodic SMI handler. This saved context is used when the
|
||||
/// periodic SMI handler exits or yields.
|
||||
///
|
||||
BASE_LIBRARY_JUMP_BUFFER DispatchJumpBuffer;
|
||||
///
|
||||
/// Flag that is set to TRUE when a periodic SMI handler requests to yield
|
||||
/// using PeriodicSmiYield(). When this flag IS TRUE, YieldJumpBuffer is
|
||||
/// Flag that is set to TRUE when a periodic SMI handler requests to yield
|
||||
/// using PeriodicSmiYield(). When this flag IS TRUE, YieldJumpBuffer is
|
||||
/// valid. When this flag is FALSE, YieldJumpBuffer is not valid.
|
||||
///
|
||||
BOOLEAN YieldFlag;
|
||||
///
|
||||
/// Buffer used to save the context when a periodic SMI handler requests to
|
||||
/// yield using PeriodicSmiYield(). This context is used to resume the
|
||||
/// Buffer used to save the context when a periodic SMI handler requests to
|
||||
/// yield using PeriodicSmiYield(). This context is used to resume the
|
||||
/// execution of a periodic SMI handler the next time control is transferd
|
||||
/// to the periodic SMI handler that yielded.
|
||||
///
|
||||
@@ -145,7 +145,7 @@ typedef struct {
|
||||
} PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT;
|
||||
|
||||
/**
|
||||
Macro that returns a pointer to a PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT
|
||||
Macro that returns a pointer to a PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT
|
||||
structure based on a pointer to a Link field.
|
||||
|
||||
**/
|
||||
@@ -163,10 +163,10 @@ typedef struct {
|
||||
EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL *gSmmPeriodicTimerDispatch2 = NULL;
|
||||
|
||||
///
|
||||
/// Pointer to a table of supported periodic SMI tick periods in 100 ns units
|
||||
/// 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
|
||||
/// 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().
|
||||
///
|
||||
UINT64 *gSmiTickPeriodTable = NULL;
|
||||
@@ -190,15 +190,15 @@ LIST_ENTRY gPeriodicSmiLibraryHandlers
|
||||
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *gActivePeriodicSmiLibraryHandler = NULL;
|
||||
|
||||
/**
|
||||
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
|
||||
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.
|
||||
|
||||
|
||||
@retval NULL A periodic SMI handler is not currently being executed.
|
||||
@retval other Pointer to the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT
|
||||
associated with the active periodic SMI handler.
|
||||
|
||||
|
||||
**/
|
||||
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *
|
||||
GetActivePeriodicSmiLibraryHandler (
|
||||
@@ -209,26 +209,26 @@ GetActivePeriodicSmiLibraryHandler (
|
||||
}
|
||||
|
||||
/**
|
||||
Internal worker function that returns a pointer to the
|
||||
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure associated with the
|
||||
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
|
||||
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.
|
||||
|
||||
@param[in] DispatchHandle DispatchHandle that was returned when the periodic
|
||||
SMI handler was enabled with PeriodicSmiEnable().
|
||||
|
||||
@param[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.
|
||||
|
||||
@retval NULL DispatchHandle is NULL and there is no active periodic SMI
|
||||
|
||||
@retval NULL DispatchHandle is NULL and there is no active periodic SMI
|
||||
handler.
|
||||
@retval NULL DispatchHandle does not match any of the periodic SMI handlers
|
||||
that have been enabled with PeriodicSmiEnable().
|
||||
@retval other Pointer to the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT
|
||||
associated with the DispatchHandle.
|
||||
|
||||
|
||||
**/
|
||||
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *
|
||||
LookupPeriodicSmiLibraryHandler (
|
||||
@@ -258,7 +258,7 @@ LookupPeriodicSmiLibraryHandler (
|
||||
return PeriodicSmiLibraryHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// No entries match DispatchHandle, so return NULL
|
||||
//
|
||||
@@ -266,11 +266,11 @@ LookupPeriodicSmiLibraryHandler (
|
||||
}
|
||||
|
||||
/**
|
||||
Internal worker function that sets that active periodic SMI handler based on
|
||||
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
|
||||
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
|
||||
A pointer to the active PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure
|
||||
is returned.
|
||||
|
||||
@param [in] DispatchHandle DispatchHandle that was returned when the periodic
|
||||
@@ -281,7 +281,7 @@ LookupPeriodicSmiLibraryHandler (
|
||||
@retval NULL DispatchHandle is NULL.
|
||||
@retval other Pointer to the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT
|
||||
associated with DispatchHandle.
|
||||
|
||||
|
||||
**/
|
||||
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *
|
||||
SetActivePeriodicSmiLibraryHandler (
|
||||
@@ -354,10 +354,10 @@ EnlargeFreePeriodicSmiLibraryHandlerList (
|
||||
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.
|
||||
|
||||
|
||||
@retval NULL There are not enough resources available to to allocate a free entry.
|
||||
@retval other Pointer to a free PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure.
|
||||
|
||||
|
||||
**/
|
||||
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *
|
||||
FindFreePeriodicSmiLibraryHandler (
|
||||
@@ -365,7 +365,7 @@ FindFreePeriodicSmiLibraryHandler (
|
||||
)
|
||||
{
|
||||
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *PeriodicSmiLibraryHandler;
|
||||
|
||||
|
||||
if (IsListEmpty (&gFreePeriodicSmiLibraryHandlers)) {
|
||||
if (!EnlargeFreePeriodicSmiLibraryHandlerList ()) {
|
||||
return NULL;
|
||||
@@ -386,15 +386,15 @@ FindFreePeriodicSmiLibraryHandler (
|
||||
|
||||
/**
|
||||
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
|
||||
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.
|
||||
|
||||
@return A pointer to a table of UINT64 tick period values in
|
||||
100ns units sorted from largest to smallest terminated
|
||||
|
||||
@return A pointer to a table of UINT64 tick period values in
|
||||
100ns units sorted from largest to smallest terminated
|
||||
by a tick period of 0.
|
||||
|
||||
|
||||
**/
|
||||
UINT64 *
|
||||
EFIAPI
|
||||
@@ -430,21 +430,21 @@ PeriodicSmiExecutionTime (
|
||||
UINT64 Count;
|
||||
|
||||
//
|
||||
// If there is no active periodic SMI handler, then return 0
|
||||
// If there is no active periodic SMI handler, then return 0
|
||||
//
|
||||
PeriodicSmiLibraryHandler = GetActivePeriodicSmiLibraryHandler ();
|
||||
if (PeriodicSmiLibraryHandler == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Get the current performance counter value
|
||||
//
|
||||
Current = GetPerformanceCounter ();
|
||||
|
||||
|
||||
//
|
||||
// Count the number of performance counter ticks since the periodic SMI handler
|
||||
// was dispatched or the last time this function was called.
|
||||
// Count the number of performance counter ticks since the periodic SMI handler
|
||||
// was dispatched or the last time this function was called.
|
||||
//
|
||||
if (PeriodicSmiLibraryHandler->PerfomanceCounterEndValue > PeriodicSmiLibraryHandler->PerfomanceCounterStartValue) {
|
||||
//
|
||||
@@ -465,58 +465,58 @@ PeriodicSmiExecutionTime (
|
||||
Count = (PeriodicSmiLibraryHandler->DispatchCheckPointTime - PeriodicSmiLibraryHandler->PerfomanceCounterEndValue) + (PeriodicSmiLibraryHandler->PerfomanceCounterStartValue - Current);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Accumulate the total number of performance counter ticks since the periodic
|
||||
// Accumulate the total number of performance counter ticks since the periodic
|
||||
// SMI handler was dispatched or resumed.
|
||||
//
|
||||
PeriodicSmiLibraryHandler->DispatchTotalTime += Count;
|
||||
|
||||
|
||||
//
|
||||
// Update the checkpoint value to the current performance counter value
|
||||
//
|
||||
PeriodicSmiLibraryHandler->DispatchCheckPointTime = Current;
|
||||
|
||||
|
||||
//
|
||||
// Convert the total number of performance counter ticks to 100 ns units
|
||||
//
|
||||
return DivU64x64Remainder (
|
||||
MultU64x32 (PeriodicSmiLibraryHandler->DispatchTotalTime, 10000000),
|
||||
PeriodicSmiLibraryHandler->PerfomanceCounterRate,
|
||||
MultU64x32 (PeriodicSmiLibraryHandler->DispatchTotalTime, 10000000),
|
||||
PeriodicSmiLibraryHandler->PerfomanceCounterRate,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
This function returns control back to the SMM Foundation. When the next
|
||||
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,
|
||||
If this function is not called from within an enabled periodic SMI handler,
|
||||
then control is returned to the calling function.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
EFIAPI
|
||||
PeriodicSmiExit (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *PeriodicSmiLibraryHandler;
|
||||
|
||||
|
||||
//
|
||||
// If there is no active periodic SMI handler, then return
|
||||
// If there is no active periodic SMI handler, then return
|
||||
//
|
||||
PeriodicSmiLibraryHandler = GetActivePeriodicSmiLibraryHandler ();
|
||||
if (PeriodicSmiLibraryHandler == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Perform a long jump back to the point when the currently executing dispatch
|
||||
// Perform a long jump back to the point when the currently executing dispatch
|
||||
// function was dispatched.
|
||||
//
|
||||
LongJump (&PeriodicSmiLibraryHandler->DispatchJumpBuffer, 1);
|
||||
|
||||
|
||||
//
|
||||
// Must never return
|
||||
//
|
||||
@@ -525,16 +525,16 @@ PeriodicSmiExit (
|
||||
}
|
||||
|
||||
/**
|
||||
This function yields control back to the SMM Foundation. When the next
|
||||
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
|
||||
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.
|
||||
|
||||
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,
|
||||
|
||||
If this function is not called from within an enabled periodic SMI handler,
|
||||
then 0 is returned.
|
||||
|
||||
@return The actual time in 100ns units elapsed since this function was
|
||||
@@ -542,7 +542,7 @@ PeriodicSmiExit (
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
EFIAPI
|
||||
PeriodicSmiYield (
|
||||
VOID
|
||||
)
|
||||
@@ -551,30 +551,30 @@ PeriodicSmiYield (
|
||||
UINTN SetJumpFlag;
|
||||
|
||||
//
|
||||
// If there is no active periodic SMI handler, then return
|
||||
// If there is no active periodic SMI handler, then return
|
||||
//
|
||||
PeriodicSmiLibraryHandler = GetActivePeriodicSmiLibraryHandler ();
|
||||
if (PeriodicSmiLibraryHandler == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// If PeriodicSmiYield() is called without an allocated stack, then just return
|
||||
// If PeriodicSmiYield() is called without an allocated stack, then just return
|
||||
// immediately with an elapsed time of 0.
|
||||
//
|
||||
if (PeriodicSmiLibraryHandler->Stack == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Set a flag so the next periodic SMI event will resume at where SetJump()
|
||||
// Set a flag so the next periodic SMI event will resume at where SetJump()
|
||||
// is called below.
|
||||
//
|
||||
PeriodicSmiLibraryHandler->YieldFlag = TRUE;
|
||||
|
||||
//
|
||||
// Save context in YieldJumpBuffer
|
||||
//
|
||||
//
|
||||
SetJumpFlag = SetJump (&PeriodicSmiLibraryHandler->YieldJumpBuffer);
|
||||
if (SetJumpFlag == 0) {
|
||||
//
|
||||
@@ -583,10 +583,10 @@ PeriodicSmiYield (
|
||||
//
|
||||
PeriodicSmiExit ();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// We get here when a LongJump is performed from PeriodicSmiDispatchFunctionOnCpu()
|
||||
// to resume a periodic SMI handler that called PeriodicSmiYield() on the
|
||||
// to resume a periodic SMI handler that called PeriodicSmiYield() on the
|
||||
// previous time this periodic SMI handler was dispatched.
|
||||
//
|
||||
// Clear the flag so the next periodic SMI dispatch will not resume.
|
||||
@@ -595,14 +595,14 @@ PeriodicSmiYield (
|
||||
|
||||
//
|
||||
// Return the amount elapsed time that occured while yielded
|
||||
//
|
||||
//
|
||||
return PeriodicSmiLibraryHandler->ElapsedTime;
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
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().
|
||||
|
||||
@param[in] Context1 Context1 parameter passed into SwitchStack().
|
||||
@@ -619,37 +619,37 @@ PeriodicSmiDispatchFunctionSwitchStack (
|
||||
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *PeriodicSmiLibraryHandler;
|
||||
|
||||
//
|
||||
// Convert Context1 to PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *
|
||||
//
|
||||
// Convert Context1 to PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *
|
||||
//
|
||||
PeriodicSmiLibraryHandler = (PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *)Context1;
|
||||
|
||||
//
|
||||
// Dispatch the registered handler passing in the context that was registered
|
||||
// and the amount of time that has elapsed since the previous time this
|
||||
// and the amount of time that has elapsed since the previous time this
|
||||
// periodic SMI handler was dispacthed.
|
||||
//
|
||||
//
|
||||
PeriodicSmiLibraryHandler->DispatchFunction (
|
||||
PeriodicSmiLibraryHandler->Context,
|
||||
PeriodicSmiLibraryHandler->ElapsedTime
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// If this DispatchFunction() returns, then unconditially call PeriodicSmiExit()
|
||||
// to perform a LongJump() back to PeriodicSmiDispatchFunctionOnCpu(). The
|
||||
// to perform a LongJump() back to PeriodicSmiDispatchFunctionOnCpu(). The
|
||||
// LongJump() will resume exection on the original stack.
|
||||
//
|
||||
//
|
||||
PeriodicSmiExit ();
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
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().
|
||||
|
||||
@param[in] PeriodicSmiLibraryHandler A pointer to the context for the periodic
|
||||
SMI handler to execute.
|
||||
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
@@ -658,44 +658,44 @@ PeriodicSmiDispatchFunctionOnCpu (
|
||||
)
|
||||
{
|
||||
//
|
||||
// Save context in DispatchJumpBuffer. The intial call to SetJump() always
|
||||
// returns 0. If this is the initial call, then either resume from a prior
|
||||
// call to PeriodicSmiYield() or call the DispatchFunction registerd in
|
||||
// Save context in DispatchJumpBuffer. The intial call to SetJump() always
|
||||
// returns 0. If this is the initial call, then either resume from a prior
|
||||
// call to PeriodicSmiYield() or call the DispatchFunction registerd in
|
||||
// PeriodicSmiEnable() using an allocated stack if one was specified.
|
||||
//
|
||||
//
|
||||
if (SetJump (&PeriodicSmiLibraryHandler->DispatchJumpBuffer) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Capture the performance counter value just before the periodic SMI handler
|
||||
// is resumed so the amount of time the periodic SMI handler executes can be
|
||||
// Capture the performance counter value just before the periodic SMI handler
|
||||
// is resumed so the amount of time the periodic SMI handler executes can be
|
||||
// calculated.
|
||||
//
|
||||
PeriodicSmiLibraryHandler->DispatchTotalTime = 0;
|
||||
PeriodicSmiLibraryHandler->DispatchCheckPointTime = GetPerformanceCounter();
|
||||
|
||||
|
||||
if (PeriodicSmiLibraryHandler->YieldFlag) {
|
||||
//
|
||||
// Perform a long jump back to the point where the previously dispatched
|
||||
// function called PeriodicSmiYield().
|
||||
// Perform a long jump back to the point where the previously dispatched
|
||||
// function called PeriodicSmiYield().
|
||||
//
|
||||
LongJump (&PeriodicSmiLibraryHandler->YieldJumpBuffer, 1);
|
||||
} else if (PeriodicSmiLibraryHandler->Stack == NULL) {
|
||||
//
|
||||
// If Stack is NULL then call DispatchFunction using current stack passing
|
||||
// in the context that was registered and the amount of time that has
|
||||
// If Stack is NULL then call DispatchFunction using current stack passing
|
||||
// in the context that was registered and the amount of time that has
|
||||
// elapsed since the previous time this periodic SMI handler was dispacthed.
|
||||
//
|
||||
//
|
||||
PeriodicSmiLibraryHandler->DispatchFunction (
|
||||
PeriodicSmiLibraryHandler->Context,
|
||||
PeriodicSmiLibraryHandler->ElapsedTime
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// If this DispatchFunction() returns, then unconditially call PeriodicSmiExit()
|
||||
// to perform a LongJump() back to this function.
|
||||
//
|
||||
//
|
||||
PeriodicSmiExit ();
|
||||
} else {
|
||||
//
|
||||
@@ -707,7 +707,7 @@ PeriodicSmiDispatchFunctionOnCpu (
|
||||
NULL,
|
||||
(UINT8 *)PeriodicSmiLibraryHandler->Stack + PeriodicSmiLibraryHandler->StackSize
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Must never return
|
||||
@@ -717,10 +717,10 @@ PeriodicSmiDispatchFunctionOnCpu (
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
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.
|
||||
@@ -735,17 +735,17 @@ PeriodicSmiDispatchFunctionWithLock (
|
||||
)
|
||||
{
|
||||
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *PeriodicSmiLibraryHandler;
|
||||
|
||||
|
||||
//
|
||||
// Get context
|
||||
//
|
||||
//
|
||||
PeriodicSmiLibraryHandler = (PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *)Buffer;
|
||||
|
||||
//
|
||||
// Execute dispatch function on the currently excuting logical CPU
|
||||
//
|
||||
//
|
||||
PeriodicSmiDispatchFunctionOnCpu (PeriodicSmiLibraryHandler);
|
||||
|
||||
|
||||
//
|
||||
// Release the dispatch spin lock
|
||||
//
|
||||
@@ -756,12 +756,12 @@ PeriodicSmiDispatchFunctionWithLock (
|
||||
Internal worker function that transfers control to a periodic SMI handler that
|
||||
was enabled using PeriodicSmiEnable().
|
||||
|
||||
@param[in] DispatchHandle The unique handle assigned to this handler by
|
||||
@param[in] DispatchHandle The unique handle assigned to this handler by
|
||||
SmiHandlerRegister().
|
||||
@param[in] Context Points to an optional handler context which was
|
||||
@param[in] Context Points to an optional handler context which was
|
||||
specified when the handler was registered.
|
||||
@param[in, out] CommBuffer A pointer to a collection of data in memory that
|
||||
will be conveyed from a non-SMM environment into
|
||||
will be conveyed from a non-SMM environment into
|
||||
an SMM environment.
|
||||
@param[in, out] CommBufferSize The size of the CommBuffer.
|
||||
|
||||
@@ -772,7 +772,7 @@ PeriodicSmiDispatchFunctionWithLock (
|
||||
@retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other
|
||||
handlers should still be called.
|
||||
@retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.
|
||||
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@@ -786,15 +786,15 @@ PeriodicSmiDispatchFunction (
|
||||
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *PeriodicSmiLibraryHandler;
|
||||
EFI_SMM_PERIODIC_TIMER_CONTEXT *TimerContext;
|
||||
EFI_STATUS Status;
|
||||
|
||||
|
||||
//
|
||||
// Set the active periodic SMI handler
|
||||
//
|
||||
//
|
||||
PeriodicSmiLibraryHandler = SetActivePeriodicSmiLibraryHandler (DispatchHandle);
|
||||
if (PeriodicSmiLibraryHandler == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Retrieve the elapsed time since the last time this periodic SMI handler was called
|
||||
//
|
||||
@@ -821,9 +821,9 @@ PeriodicSmiDispatchFunction (
|
||||
// spin lock when it is done executing the periodic SMI handler.
|
||||
//
|
||||
AcquireSpinLock (&PeriodicSmiLibraryHandler->DispatchLock);
|
||||
|
||||
|
||||
//
|
||||
// Execute the periodic SMI handler on the CPU that was specified in
|
||||
// Execute the periodic SMI handler on the CPU that was specified in
|
||||
// PeriodicSmiEnable().
|
||||
//
|
||||
Status = gSmst->SmmStartupThisAp (
|
||||
@@ -839,7 +839,7 @@ PeriodicSmiDispatchFunction (
|
||||
CpuPause ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Release the spin lock for the periodic SMI handler.
|
||||
//
|
||||
@@ -852,56 +852,56 @@ PeriodicSmiDispatchFunction (
|
||||
if (PeriodicSmiLibraryHandler->DispatchHandle == NULL) {
|
||||
ReclaimPeriodicSmiLibraryHandler (PeriodicSmiLibraryHandler);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Update state to show that there is no active periodic SMI handler
|
||||
//
|
||||
//
|
||||
SetActivePeriodicSmiLibraryHandler (NULL);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function enables a periodic SMI handler.
|
||||
|
||||
@param[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
|
||||
|
||||
@param[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.
|
||||
@param[in] DispatchFunction A pointer to a periodic SMI handler function.
|
||||
@param[in] Context Optional content to pass into DispatchFunction.
|
||||
@param[in] TickPeriod The requested tick period in 100ns units that
|
||||
@param[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().
|
||||
@param[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
|
||||
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.
|
||||
@param[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.
|
||||
|
||||
|
||||
@retval EFI_INVALID_PARAMETER DispatchFunction is NULL.
|
||||
@retval EFI_UNSUPPORTED TickPeriod is not a supported tick period. The
|
||||
supported tick periods can be retrieved using
|
||||
@retval EFI_UNSUPPORTED TickPeriod is not a supported tick period. The
|
||||
supported tick periods can be retrieved using
|
||||
PeriodicSmiSupportedTickPeriod().
|
||||
@retval EFI_INVALID_PARAMETER Cpu is not PERIODIC_SMI_LIBRARY_ANY_CPU or in
|
||||
@retval EFI_INVALID_PARAMETER Cpu is not PERIODIC_SMI_LIBRARY_ANY_CPU or in
|
||||
the range 0 to SMST NumberOfCpus.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources to enable the
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources to enable the
|
||||
periodic SMI handler.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the
|
||||
stack speficied by StackSize.
|
||||
@retval EFI_SUCCESS The periodic SMI handler was enabled.
|
||||
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeriodicSmiEnable (
|
||||
IN OUT EFI_HANDLE *DispatchHandle, OPTIONAL
|
||||
@@ -918,27 +918,27 @@ PeriodicSmiEnable (
|
||||
|
||||
//
|
||||
// Make sure all the input parameters are valid
|
||||
//
|
||||
//
|
||||
if (DispatchFunction == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
for (Index = 0; gSmiTickPeriodTable[Index] != 0; Index++) {
|
||||
if (gSmiTickPeriodTable[Index] == TickPeriod) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gSmiTickPeriodTable[Index] == 0) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
if (Cpu != PERIODIC_SMI_LIBRARY_ANY_CPU && Cpu >= gSmst->NumberOfCpus) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Find a free periodic SMI handler entry
|
||||
//
|
||||
//
|
||||
PeriodicSmiLibraryHandler = FindFreePeriodicSmiLibraryHandler();
|
||||
if (PeriodicSmiLibraryHandler == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@@ -980,34 +980,34 @@ PeriodicSmiEnable (
|
||||
ReclaimPeriodicSmiLibraryHandler (PeriodicSmiLibraryHandler);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Return the registered handle if the optional DispatchHandle parameter is not NULL
|
||||
//
|
||||
if (DispatchHandle != NULL) {
|
||||
*DispatchHandle = PeriodicSmiLibraryHandler->DispatchHandle;
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
This function disables a periodic SMI handler that has been previously
|
||||
enabled with PeriodicSmiEnable().
|
||||
|
||||
@param[in] DispatchHandle A handle associated with a previously enabled periodic
|
||||
|
||||
@param[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.
|
||||
|
||||
@retval FALSE DispatchHandle is NULL and there is no active periodic SMI handler.
|
||||
@retval FALSE The periodic SMI handler specified by DispatchHandle has
|
||||
@retval FALSE The periodic SMI handler specified by DispatchHandle has
|
||||
not been enabled with PeriodicSmiEnable().
|
||||
@retval TRUE The periodic SMI handler specified by DispatchHandle has
|
||||
@retval TRUE The periodic SMI handler specified by DispatchHandle has
|
||||
been disabled. If DispatchHandle is NULL, then the active
|
||||
periodic SMI handler has been disabled.
|
||||
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
PeriodicSmiDisable (
|
||||
IN EFI_HANDLE DispatchHandle OPTIONAL
|
||||
@@ -1023,7 +1023,7 @@ PeriodicSmiDisable (
|
||||
if (PeriodicSmiLibraryHandler == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Unregister the periodic SMI handler from the SMM Periodic Timer Dispatch 2 Protocol
|
||||
//
|
||||
@@ -1049,7 +1049,7 @@ PeriodicSmiDisable (
|
||||
}
|
||||
|
||||
/**
|
||||
This constructor function caches the pointer to the SMM Periodic Timer
|
||||
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.
|
||||
|
||||
@@ -1082,7 +1082,7 @@ SmmPeriodicSmiLibConstructor (
|
||||
ASSERT (gSmmPeriodicTimerDispatch2 != NULL);
|
||||
|
||||
//
|
||||
// Count the number of periodic SMI tick intervals that the SMM Periodic Timer
|
||||
// Count the number of periodic SMI tick intervals that the SMM Periodic Timer
|
||||
// Dipatch 2 Protocol supports.
|
||||
//
|
||||
SmiTickInterval = NULL;
|
||||
@@ -1092,15 +1092,15 @@ SmmPeriodicSmiLibConstructor (
|
||||
gSmmPeriodicTimerDispatch2,
|
||||
&SmiTickInterval
|
||||
);
|
||||
Count++;
|
||||
} while (SmiTickInterval != NULL);
|
||||
Count++;
|
||||
} while (SmiTickInterval != NULL);
|
||||
|
||||
//
|
||||
// Allocate a buffer for the table of supported periodic SMI tick periods.
|
||||
//
|
||||
//
|
||||
gSmiTickPeriodTable = AllocateZeroPool (Count * sizeof (UINT64));
|
||||
ASSERT (gSmiTickPeriodTable != NULL);
|
||||
|
||||
|
||||
//
|
||||
// Fill in the table of supported periodic SMI tick periods.
|
||||
//
|
||||
@@ -1127,7 +1127,7 @@ SmmPeriodicSmiLibConstructor (
|
||||
}
|
||||
|
||||
/**
|
||||
The constructor function caches the pointer to the SMM Periodic Timer Dispatch 2
|
||||
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.
|
||||
|
||||
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||
@@ -1165,7 +1165,7 @@ SmmPeriodicSmiLibDestructor (
|
||||
//
|
||||
// Free all the periodic SMI handler entries
|
||||
//
|
||||
for (Link = GetFirstNode (&gFreePeriodicSmiLibraryHandlers); !IsNull (&gFreePeriodicSmiLibraryHandlers, Link);) {
|
||||
for (Link = GetFirstNode (&gFreePeriodicSmiLibraryHandlers); !IsNull (&gFreePeriodicSmiLibraryHandlers, Link);) {
|
||||
PeriodicSmiLibraryHandler = PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_LINK (Link);
|
||||
Link = RemoveEntryList (Link);
|
||||
FreePool (PeriodicSmiLibraryHandler);
|
||||
|
Reference in New Issue
Block a user