summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/Library
diff options
context:
space:
mode:
authorNi, Ray <ray.ni@intel.com>2021-10-19 14:42:21 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-11-10 04:28:08 +0000
commitf826b20811ba6b0a9dbe44ff703b85c2def267df (patch)
treee4ef9067ca7fcd4a33f816b79ec8e911d2a1e57a /UefiCpuPkg/Library
parenta7b35aae13b2d69b9be68874f275f511b1367a5e (diff)
downloadedk2-f826b20811ba6b0a9dbe44ff703b85c2def267df.tar.gz
edk2-f826b20811ba6b0a9dbe44ff703b85c2def267df.tar.bz2
edk2-f826b20811ba6b0a9dbe44ff703b85c2def267df.zip
UefiCpuPkg/UefiCpuLib: Add GetCpuFamilyModel and GetCpuSteppingId
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3698 Lots of code relies on CPU Family/Model/Stepping for different logics. The change adds two APIs for such needs. Signed-off-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Cc: Rahul Kumar <rahul1.kumar@intel.com>
Diffstat (limited to 'UefiCpuPkg/Library')
-rw-r--r--UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
index c2cc3ff9a7..50891618c4 100644
--- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
+++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
@@ -4,6 +4,7 @@
The library routines are UEFI specification compliant.
Copyright (c) 2020, AMD Inc. All rights reserved.<BR>
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -36,3 +37,45 @@ StandardSignatureIsAuthenticAMD (
RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&
RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);
}
+
+/**
+ Return the 32bit CPU family and model value.
+
+ @return CPUID[01h].EAX with Processor Type and Stepping ID cleared.
+**/
+UINT32
+EFIAPI
+GetCpuFamilyModel (
+ VOID
+ )
+{
+ CPUID_VERSION_INFO_EAX Eax;
+
+ AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL);
+
+ //
+ // Mask other fields than Family and Model.
+ //
+ Eax.Bits.SteppingId = 0;
+ Eax.Bits.ProcessorType = 0;
+ Eax.Bits.Reserved1 = 0;
+ Eax.Bits.Reserved2 = 0;
+ return Eax.Uint32;
+}
+
+/**
+ Return the CPU stepping ID.
+ @return CPU stepping ID value in CPUID[01h].EAX.
+**/
+UINT8
+EFIAPI
+GetCpuSteppingId (
+ VOID
+ )
+{
+ CPUID_VERSION_INFO_EAX Eax;
+
+ AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL);
+
+ return (UINT8) Eax.Bits.SteppingId;
+}