]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
UefiCpuPkg/UefiCpuLib: Add GetCpuFamilyModel and GetCpuSteppingId
[mirror_edk2.git] / UefiCpuPkg / Library / BaseUefiCpuLib / BaseUefiCpuLib.c
index c2cc3ff9a7091f1469c0b96a9c530af179e08fb2..50891618c458b3ca8c651577e817ac89aa3fcbb9 100644 (file)
@@ -4,6 +4,7 @@
   The library routines are UEFI specification compliant.\r
 \r
   Copyright (c) 2020, AMD Inc. All rights reserved.<BR>\r
+  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -36,3 +37,45 @@ StandardSignatureIsAuthenticAMD (
           RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&\r
           RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);\r
 }\r
+\r
+/**\r
+  Return the 32bit CPU family and model value.\r
+\r
+  @return CPUID[01h].EAX with Processor Type and Stepping ID cleared.\r
+**/\r
+UINT32\r
+EFIAPI\r
+GetCpuFamilyModel (\r
+  VOID\r
+  )\r
+{\r
+  CPUID_VERSION_INFO_EAX  Eax;\r
+\r
+  AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL);\r
+\r
+  //\r
+  // Mask other fields than Family and Model.\r
+  //\r
+  Eax.Bits.SteppingId    = 0;\r
+  Eax.Bits.ProcessorType = 0;\r
+  Eax.Bits.Reserved1     = 0;\r
+  Eax.Bits.Reserved2     = 0;\r
+  return Eax.Uint32;\r
+}\r
+\r
+/**\r
+  Return the CPU stepping ID.\r
+  @return CPU stepping ID value in CPUID[01h].EAX.\r
+**/\r
+UINT8\r
+EFIAPI\r
+GetCpuSteppingId (\r
+  VOID\r
+  )\r
+{\r
+  CPUID_VERSION_INFO_EAX  Eax;\r
+\r
+  AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL);\r
+\r
+  return (UINT8) Eax.Bits.SteppingId;\r
+}\r