There's currently two library instances:
1. SmmCpuFeaturesLib
2. SmmCpuFeaturesLibStm
There's two constructor functions:
1. SmmCpuFeaturesLibConstructor()
2. SmmCpuFeaturesLibStmConstructor()
SmmCpuFeaturesLibConstructor() is called by
SmmCpuFeaturesLibStmConstructor() since the functionality in that
function is required by both library instances.
The declaration for SmmCpuFeaturesLibConstructor() is embedded in
"SmmStm.c" instead of being declared in a header file. Further,
that constructor function is called by the STM specific constructor.
This change moves the common code to a function called
CpuFeaturesLibInitialization() which is declared in an internal
library header file "CpuFeaturesLib.h". Each constructor simply
calls this function to perform the common functionality.
Additionally, SmmCpuFeaturesLibConstructor() is moved from
SmmCpuFeaturesLibNoStm.c into a instance-specific file allowing
SmmCpuFeaturesLibNoStm.c to contain no STM implementation agnostic
to a particular library instance.
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <
20210217213227.1277-4-mikuback@linux.microsoft.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
#ifndef CPU_FEATURES_LIB_H_\r
#define CPU_FEATURES_LIB_H_\r
\r
+/**\r
+ Performs library initialization.\r
+\r
+ This initialization function contains common functionality shared betwen all\r
+ library instance constructors.\r
+\r
+**/\r
+VOID\r
+CpuFeaturesLibInitialization (\r
+ VOID\r
+ );\r
+\r
/**\r
Internal worker function that is called to complete CPU initialization at the\r
end of SmmCpuFeaturesInitializeProcessor().\r
--- /dev/null
+/** @file\r
+Implementation specific to the SmmCpuFeatureLib library instance.\r
+\r
+Copyright (c) Microsoft Corporation.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <PiSmm.h>\r
+#include "CpuFeaturesLib.h"\r
+\r
+/**\r
+ The constructor function for the Traditional MM library instance without STM.\r
+\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmCpuFeaturesLibConstructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ CpuFeaturesLibInitialization ();\r
+\r
+ return EFI_SUCCESS;\r
+}\r
\r
[Sources]\r
CpuFeaturesLib.h\r
+ SmmCpuFeaturesLib.c\r
SmmCpuFeaturesLibCommon.c\r
SmmCpuFeaturesLibNoStm.c\r
\r
Implementation shared across all library instances.\r
\r
Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) Microsoft Corporation.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
BOOLEAN *mSmrrEnabled;\r
\r
/**\r
- The constructor function\r
+ Performs library initialization.\r
\r
- @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
- @param[in] SystemTable A pointer to the EFI System Table.\r
-\r
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
+ This initialization function contains common functionality shared betwen all\r
+ library instance constructors.\r
\r
**/\r
-EFI_STATUS\r
-EFIAPI\r
-SmmCpuFeaturesLibConstructor (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
+VOID\r
+CpuFeaturesLibInitialization (\r
+ VOID\r
)\r
{\r
UINT32 RegEax;\r
//\r
mSmrrEnabled = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * PcdGet32 (PcdCpuMaxLogicalProcessorNumber));\r
ASSERT (mSmrrEnabled != NULL);\r
-\r
- return EFI_SUCCESS;\r
}\r
\r
/**\r
#define RDWR_ACCS 3\r
#define FULL_ACCS 7\r
\r
-/**\r
- The constructor function\r
-\r
- @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
- @param[in] SystemTable A pointer to the EFI System Table.\r
-\r
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SmmCpuFeaturesLibConstructor (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- );\r
-\r
EFI_HANDLE mStmSmmCpuHandle = NULL;\r
\r
BOOLEAN mLockLoadMonitor = FALSE;\r
BOOLEAN mStmConfigurationTableInitialized = FALSE;\r
\r
/**\r
- The constructor function\r
+ The constructor function for the Traditional MM library instance with STM.\r
\r
@param[in] ImageHandle The firmware allocated handle for the EFI image.\r
@param[in] SystemTable A pointer to the EFI System Table.\r
SmmCpuFeaturesLibStmSmiEntryFixupAddress ();\r
\r
//\r
- // Call the common constructor function\r
+ // Perform library initialization common across all instances\r
//\r
- Status = SmmCpuFeaturesLibConstructor (ImageHandle, SystemTable);\r
- ASSERT_EFI_ERROR (Status);\r
+ CpuFeaturesLibInitialization ();\r
\r
//\r
// Lookup the MP Services Protocol\r