aboutsummaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/SmmPeriodicSmiLib
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/SmmPeriodicSmiLib')
-rw-r--r--MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c430
-rw-r--r--MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.inf15
-rw-r--r--MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.uni7
3 files changed, 214 insertions, 238 deletions
diff --git a/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c b/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c
index bd7bb3a11e0c..18301c645977 100644
--- a/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c
+++ b/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c
@@ -1,14 +1,8 @@
/** @file
SMM Periodic SMI Library.
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
- 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.
+ Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -62,13 +56,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 +76,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,28 +106,28 @@ typedef struct {
///
UINT64 DispatchTotalTime;
///
- /// 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 value that was captured the last time that the
+ /// periodic SMI handler called PeriodicSmiExecutionTime(). This allows the
+ /// time value returned by PeriodicSmiExecutionTime() to be accurate even when
/// the performance counter rolls over.
///
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
- /// execution of a periodic SMI handler the next time control is transferd
+ /// 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 transferred
/// to the periodic SMI handler that yielded.
///
BASE_LIBRARY_JUMP_BUFFER YieldJumpBuffer;
@@ -145,20 +139,7 @@ typedef struct {
} PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT;
/**
- Macro that returns a pointer to a PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT
- structure based on a pointer to a RegisterContext field.
-
-**/
-#define PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_REGISTER_CONTEXT(a) \
- CR ( \
- a, \
- PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT, \
- RegisterContext, \
- PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_SIGNATURE \
- )
-
-/**
- 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.
**/
@@ -171,15 +152,15 @@ typedef struct {
)
///
-/// Pointer to the SMM Periodic Timer Disatch Protocol that was located in the constuctor.
+/// Pointer to the SMM Periodic Timer Dispatch Protocol that was located in the constructor.
///
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;
@@ -203,15 +184,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 (
@@ -222,26 +203,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 (
@@ -271,7 +252,7 @@ LookupPeriodicSmiLibraryHandler (
return PeriodicSmiLibraryHandler;
}
}
-
+
//
// No entries match DispatchHandle, so return NULL
//
@@ -279,27 +260,32 @@ LookupPeriodicSmiLibraryHandler (
}
/**
- 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
+ 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
+ A pointer to the active PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure
is returned.
-
- @retval NULL Context is NULL.
+
+ @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 state is updated
+ to show that there is not active periodic SMI handler.
+ @retval NULL DispatchHandle is NULL.
@retval other Pointer to the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT
- associated with Context.
-
+ associated with DispatchHandle.
+
**/
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *
SetActivePeriodicSmiLibraryHandler (
- IN CONST VOID *Context OPTIONAL
+ IN EFI_HANDLE DispatchHandle OPTIONAL
)
{
- if (Context == NULL) {
+ if (DispatchHandle == NULL) {
gActivePeriodicSmiLibraryHandler = NULL;
} else {
- gActivePeriodicSmiLibraryHandler = PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_REGISTER_CONTEXT (Context);
+ gActivePeriodicSmiLibraryHandler = LookupPeriodicSmiLibraryHandler (DispatchHandle);
}
return gActivePeriodicSmiLibraryHandler;
}
@@ -362,10 +348,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 (
@@ -373,7 +359,7 @@ FindFreePeriodicSmiLibraryHandler (
)
{
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *PeriodicSmiLibraryHandler;
-
+
if (IsListEmpty (&gFreePeriodicSmiLibraryHandlers)) {
if (!EnlargeFreePeriodicSmiLibraryHandlerList ()) {
return NULL;
@@ -394,15 +380,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
@@ -438,21 +424,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) {
//
@@ -473,58 +459,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
//
@@ -533,16 +519,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
- 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.
-
+ 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,
+
+ 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
@@ -550,7 +536,7 @@ PeriodicSmiExit (
**/
UINT64
-EFIAPI
+EFIAPI
PeriodicSmiYield (
VOID
)
@@ -559,42 +545,42 @@ 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) {
//
- // The intial call to SetJump() always returns 0.
+ // The initial call to SetJump() always returns 0.
// If this is the initial call, then exit the current periodic SMI handler
//
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.
@@ -602,15 +588,15 @@ PeriodicSmiYield (
PeriodicSmiLibraryHandler->YieldFlag = FALSE;
//
- // Return the amount elapsed time that occured while yielded
- //
+ // Return the amount elapsed time that occurred 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().
@@ -627,37 +613,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
- // periodic SMI handler was dispacthed.
- //
+ // and the amount of time that has elapsed since the previous time this
+ // periodic SMI handler was dispatched.
+ //
PeriodicSmiLibraryHandler->DispatchFunction (
PeriodicSmiLibraryHandler->Context,
PeriodicSmiLibraryHandler->ElapsedTime
);
-
+
+ //
+ // If this DispatchFunction() returns, then unconditionally call PeriodicSmiExit()
+ // to perform a LongJump() back to PeriodicSmiDispatchFunctionOnCpu(). The
+ // LongJump() will resume execution on the original stack.
//
- // If this DispatchFunction() returns, then unconditially call PeriodicSmiExit()
- // 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 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().
@param[in] PeriodicSmiLibraryHandler A pointer to the context for the periodic
SMI handler to execute.
-
+
**/
VOID
EFIAPI
@@ -666,44 +652,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 initial 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 registered 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
- // elapsed since the previous time this periodic SMI handler was dispacthed.
- //
+ // 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 dispatched.
+ //
PeriodicSmiLibraryHandler->DispatchFunction (
PeriodicSmiLibraryHandler->Context,
PeriodicSmiLibraryHandler->ElapsedTime
);
-
+
//
- // If this DispatchFunction() returns, then unconditially call PeriodicSmiExit()
+ // If this DispatchFunction() returns, then unconditionally call PeriodicSmiExit()
// to perform a LongJump() back to this function.
- //
+ //
PeriodicSmiExit ();
} else {
//
@@ -715,7 +701,7 @@ PeriodicSmiDispatchFunctionOnCpu (
NULL,
(UINT8 *)PeriodicSmiLibraryHandler->Stack + PeriodicSmiLibraryHandler->StackSize
);
- }
+ }
//
// Must never return
@@ -725,10 +711,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 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.
@@ -743,17 +729,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
- //
+ // Execute dispatch function on the currently executing logical CPU
+ //
PeriodicSmiDispatchFunctionOnCpu (PeriodicSmiLibraryHandler);
-
+
//
// Release the dispatch spin lock
//
@@ -764,12 +750,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.
@@ -780,7 +766,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
@@ -794,15 +780,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 (Context);
+ //
+ PeriodicSmiLibraryHandler = SetActivePeriodicSmiLibraryHandler (DispatchHandle);
if (PeriodicSmiLibraryHandler == NULL) {
return EFI_NOT_FOUND;
}
-
+
//
// Retrieve the elapsed time since the last time this periodic SMI handler was called
//
@@ -819,7 +805,7 @@ PeriodicSmiDispatchFunction (
(PeriodicSmiLibraryHandler->Cpu == gSmst->CurrentlyExecutingCpu) ) {
//
// Dispatch on the currently execution CPU if the CPU specified in PeriodicSmiEnable()
- // was PERIODIC_SMI_LIBARRY_ANY_CPU or the currently executing CPU matches the CPU
+ // was PERIODIC_SMI_LIBRARY_ANY_CPU or the currently executing CPU matches the CPU
// that was specified in PeriodicSmiEnable().
//
PeriodicSmiDispatchFunctionOnCpu (PeriodicSmiLibraryHandler);
@@ -829,9 +815,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 (
@@ -847,7 +833,7 @@ PeriodicSmiDispatchFunction (
CpuPause ();
}
}
-
+
//
// Release the spin lock for the periodic SMI handler.
//
@@ -860,56 +846,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
- control should be givien to the periodic SMI
+ @param[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().
@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
- stack speficied by StackSize.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the
+ stack specified by StackSize.
@retval EFI_SUCCESS The periodic SMI handler was enabled.
-
+
**/
-EFI_STATUS
+EFI_STATUS
EFIAPI
PeriodicSmiEnable (
IN OUT EFI_HANDLE *DispatchHandle, OPTIONAL
@@ -926,27 +912,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;
@@ -988,34 +974,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
@@ -1031,7 +1017,7 @@ PeriodicSmiDisable (
if (PeriodicSmiLibraryHandler == NULL) {
return FALSE;
}
-
+
//
// Unregister the periodic SMI handler from the SMM Periodic Timer Dispatch 2 Protocol
//
@@ -1057,7 +1043,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.
@@ -1090,8 +1076,8 @@ SmmPeriodicSmiLibConstructor (
ASSERT (gSmmPeriodicTimerDispatch2 != NULL);
//
- // Count the number of periodic SMI tick intervals that the SMM Periodic Timer
- // Dipatch 2 Protocol supports.
+ // Count the number of periodic SMI tick intervals that the SMM Periodic Timer
+ // Dispatch 2 Protocol supports.
//
SmiTickInterval = NULL;
Count = 0;
@@ -1100,15 +1086,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.
//
@@ -1135,7 +1121,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.
@@ -1173,7 +1159,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);
diff --git a/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.inf b/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.inf
index 831aed586512..07fac3f0878c 100644
--- a/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.inf
+++ b/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.inf
@@ -1,14 +1,9 @@
## @file
# SMM Periodic SMI Library.
#
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
#
-# 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.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
##
@@ -24,7 +19,7 @@
PI_SPECIFICATION_VERSION = 0x0001000A
CONSTRUCTOR = SmmPeriodicSmiLibConstructor
DESTRUCTOR = SmmPeriodicSmiLibDestructor
-
+
#
# VALID_ARCHITECTURES = IA32 X64
#
@@ -43,10 +38,10 @@
TimerLib
MemoryAllocationLib
SmmServicesTableLib
-
+
[Protocols]
gEfiSmmPeriodicTimerDispatch2ProtocolGuid ## CONSUMES
-
+
[Depex]
gEfiSmmPeriodicTimerDispatch2ProtocolGuid
diff --git a/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.uni b/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.uni
index bc59e9c5b596..2715fea25374 100644
--- a/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.uni
+++ b/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.uni
@@ -5,12 +5,7 @@
//
// Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
//
-// 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.
+// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/