From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web08.6171.1634625742651222065 for ; Mon, 18 Oct 2021 23:42:23 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: ray.ni@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10141"; a="225896405" X-IronPort-AV: E=Sophos;i="5.85,383,1624345200"; d="scan'208";a="225896405" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2021 23:42:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,383,1624345200"; d="scan'208";a="526543999" Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.56.147]) by orsmga001.jf.intel.com with ESMTP; 18 Oct 2021 23:42:20 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Rahul Kumar Subject: [PATCH] UefiCpuPkg/UefiCpuLib: Add GetCpuFamilyModel and GetCpuSteppingId Date: Tue, 19 Oct 2021 14:42:21 +0800 Message-Id: <20211019064221.705-1-ray.ni@intel.com> X-Mailer: git-send-email 2.32.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3698 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 Cc: Eric Dong Cc: Rahul Kumar --- UefiCpuPkg/Include/Library/UefiCpuLib.h | 23 +++++++++- .../Library/BaseUefiCpuLib/BaseUefiCpuLib.c | 43 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Include/Library/UefiCpuLib.h b/UefiCpuPkg/Include/L= ibrary/UefiCpuLib.h index 5326e72463..092c1d2116 100644 --- a/UefiCpuPkg/Include/Library/UefiCpuLib.h +++ b/UefiCpuPkg/Include/Library/UefiCpuLib.h @@ -4,7 +4,7 @@ This library class defines some routines that are generic for IA32 famil= y CPU=0D to be UEFI specification compliant.=0D =0D - Copyright (c) 2009, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
=0D Copyright (c) 2020, AMD Inc. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -43,4 +43,25 @@ StandardSignatureIsAuthenticAMD ( VOID=0D );=0D =0D +/**=0D + Return the 32bit CPU family and model value.=0D +=0D + @return CPUID[01h].EAX with Processor Type and Stepping ID cleared.=0D +**/=0D +UINT32=0D +EFIAPI=0D +GetCpuFamilyModel (=0D + VOID=0D + );=0D +=0D +/**=0D + Return the CPU stepping ID.=0D + @return CPU stepping ID value in CPUID[01h].EAX.=0D +**/=0D +UINT8=0D +EFIAPI=0D +GetCpuSteppingId (=0D + VOID=0D + );=0D +=0D #endif=0D diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c b/UefiCpuPk= g/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.=0D =0D Copyright (c) 2020, AMD Inc. All rights reserved.
=0D + Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -36,3 +37,45 @@ StandardSignatureIsAuthenticAMD ( RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&=0D RegEdx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);=0D }=0D +=0D +/**=0D + Return the 32bit CPU family and model value.=0D +=0D + @return CPUID[01h].EAX with Processor Type and Stepping ID cleared.=0D +**/=0D +UINT32=0D +EFIAPI=0D +GetCpuFamilyModel (=0D + VOID=0D + )=0D +{=0D + CPUID_VERSION_INFO_EAX Eax;=0D +=0D + AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL);=0D +=0D + //=0D + // Mask other fields than Family and Model.=0D + //=0D + Eax.Bits.SteppingId =3D 0;=0D + Eax.Bits.ProcessorType =3D 0;=0D + Eax.Bits.Reserved1 =3D 0;=0D + Eax.Bits.Reserved2 =3D 0;=0D + return Eax.Uint32;=0D +}=0D +=0D +/**=0D + Return the CPU stepping ID.=0D + @return CPU stepping ID value in CPUID[01h].EAX.=0D +**/=0D +UINT8=0D +EFIAPI=0D +GetCpuSteppingId (=0D + VOID=0D + )=0D +{=0D + CPUID_VERSION_INFO_EAX Eax;=0D +=0D + AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL);=0D +=0D + return (UINT8) Eax.Bits.SteppingId;=0D +}=0D --=20 2.32.0.windows.1