diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h index 106e070cb8..c18521fd9c 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h @@ -9,6 +9,18 @@ #ifndef CPU_FEATURES_LIB_H_ #define CPU_FEATURES_LIB_H_ +/** + Performs library initialization. + + This initialization function contains common functionality shared betwen all + library instance constructors. + +**/ +VOID +CpuFeaturesLibInitialization ( + VOID + ); + /** Internal worker function that is called to complete CPU initialization at the end of SmmCpuFeaturesInitializeProcessor(). diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c new file mode 100644 index 0000000000..00948a191f --- /dev/null +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -0,0 +1,31 @@ +/** @file +Implementation specific to the SmmCpuFeatureLib library instance. + +Copyright (c) Microsoft Corporation.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include "CpuFeaturesLib.h" + +/** + The constructor function for the Traditional MM library instance without STM. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +SmmCpuFeaturesLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + CpuFeaturesLibInitialization (); + + return EFI_SUCCESS; +} diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index 7ebb0b0ef0..ddd00eeceb 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -18,6 +18,7 @@ [Sources] CpuFeaturesLib.h + SmmCpuFeaturesLib.c SmmCpuFeaturesLibCommon.c SmmCpuFeaturesLibNoStm.c diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c index 36c48310c3..7a919c5ee7 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c @@ -2,6 +2,7 @@ Implementation shared across all library instances. Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -63,19 +64,15 @@ BOOLEAN mNeedConfigureMtrrs = TRUE; BOOLEAN *mSmrrEnabled; /** - The constructor function + Performs library initialization. - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + This initialization function contains common functionality shared betwen all + library instance constructors. **/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +VOID +CpuFeaturesLibInitialization ( + VOID ) { UINT32 RegEax; @@ -162,8 +159,6 @@ SmmCpuFeaturesLibConstructor ( // mSmrrEnabled = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); ASSERT (mSmrrEnabled != NULL); - - return EFI_SUCCESS; } /** diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c index b5aad41fdb..dcc2e9f9a0 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c @@ -30,22 +30,6 @@ #define RDWR_ACCS 3 #define FULL_ACCS 7 -/** - The constructor function - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - EFI_HANDLE mStmSmmCpuHandle = NULL; BOOLEAN mLockLoadMonitor = FALSE; @@ -112,7 +96,7 @@ UINTN mMsegSize = 0; BOOLEAN mStmConfigurationTableInitialized = FALSE; /** - The constructor function + The constructor function for the Traditional MM library instance with STM. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @@ -138,10 +122,9 @@ SmmCpuFeaturesLibStmConstructor ( SmmCpuFeaturesLibStmSmiEntryFixupAddress (); // - // Call the common constructor function + // Perform library initialization common across all instances // - Status = SmmCpuFeaturesLibConstructor (ImageHandle, SystemTable); - ASSERT_EFI_ERROR (Status); + CpuFeaturesLibInitialization (); // // Lookup the MP Services Protocol