summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-02-17 13:32:26 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-03-08 18:07:32 +0000
commite542e05d4fc2e4aeae752db5d429e2f4650cd5ee (patch)
treeea6fb3e71e6c5aa9f81dd160513a74a09f9b4e30 /UefiCpuPkg
parent2002e950eafa62eb9ba28b5e4ed62f0d7d22b88c (diff)
downloadedk2-e542e05d4fc2e4aeae752db5d429e2f4650cd5ee.tar.gz
edk2-e542e05d4fc2e4aeae752db5d429e2f4650cd5ee.tar.bz2
edk2-e542e05d4fc2e4aeae752db5d429e2f4650cd5ee.zip
UefiCpuPkg/SmmCpuFeaturesLib: Abstract PcdCpuMaxLogicalProcessorNumber
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3218 Adds a new function called GetCpuMaxLogicalProcessorNumber() to return the number of maximum CPU logical processors (currently gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber). This allows the the mechanism used to retrieve the CPU maximum logical processor number to be abstracted from the logic that needs the value. 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-5-mikuback@linux.microsoft.com> Reviewed-by: Eric Dong <eric.dong@intel.com>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r--UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h14
-rw-r--r--UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf1
-rw-r--r--UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c2
-rw-r--r--UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf1
-rw-r--r--UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c28
5 files changed, 45 insertions, 1 deletions
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h
index c18521fd9c..8a1c2adc5c 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h
@@ -31,4 +31,18 @@ FinishSmmCpuFeaturesInitializeProcessor (
VOID
);
+/**
+ Gets the maximum number of logical processors from the PCD PcdCpuMaxLogicalProcessorNumber.
+
+ This access is abstracted from the PCD services to enforce that the PCD be
+ FixedAtBuild in the Standalone MM build of this driver.
+
+ @return The value of PcdCpuMaxLogicalProcessorNumber.
+
+**/
+UINT32
+GetCpuMaxLogicalProcessorNumber (
+ VOID
+ );
+
#endif
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
index ddd00eeceb..35292dac31 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
@@ -21,6 +21,7 @@
SmmCpuFeaturesLib.c
SmmCpuFeaturesLibCommon.c
SmmCpuFeaturesLibNoStm.c
+ TraditionalMmCpuFeaturesLib.c
[Packages]
MdePkg/MdePkg.dec
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c
index 7a919c5ee7..50379f3aea 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c
@@ -157,7 +157,7 @@ CpuFeaturesLibInitialization (
//
// Allocate array for state of SMRR enable on all CPUs
//
- mSmrrEnabled = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
+ mSmrrEnabled = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * GetCpuMaxLogicalProcessorNumber ());
ASSERT (mSmrrEnabled != NULL);
}
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
index 78f8e4b42c..022351f593 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
@@ -22,6 +22,7 @@
SmmCpuFeaturesLibCommon.c
SmmStm.c
SmmStm.h
+ TraditionalMmCpuFeaturesLib.c
[Sources.Ia32]
Ia32/SmmStmSupport.c
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c
new file mode 100644
index 0000000000..b7a5c1926e
--- /dev/null
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c
@@ -0,0 +1,28 @@
+/** @file
+ Traditional MM CPU specific programming.
+
+ Copyright (c) Microsoft Corporation.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/PcdLib.h>
+#include "CpuFeaturesLib.h"
+
+/**
+ Gets the maximum number of logical processors from the PCD PcdCpuMaxLogicalProcessorNumber.
+
+ This access is abstracted from the PCD services to enforce that the PCD be
+ FixedAtBuild in the Standalone MM build of this driver.
+
+ @return The value of PcdCpuMaxLogicalProcessorNumber.
+
+**/
+UINT32
+GetCpuMaxLogicalProcessorNumber (
+ VOID
+ )
+{
+ return PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
+}