From nobody Tue May 7 15:30:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82298+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82298+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1634625744; cv=none; d=zohomail.com; s=zohoarc; b=FODGZWIQ31sYvZbcHZqsqnfxgX2zGm/R3giyZrxKbkBaHKo1Idt/SbLbbLOnFYe7HqYQivUi3vB2WLrdgbMYPTpmORpt4E9dsUrMNUBhcbc4uqAVyhNQatNK48C+VIx7OyCT2cynTtiVjRKzrxXd6MDiAFzKmOYKdL7Je15HZxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634625744; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=dllr+nz+z6NXR1kN8wx/JlGT4KruTe6NKZP+ojB+SzE=; b=Dw2pvhEuvX2a/5uX4lHgF+3LY0pqhuPKR4miZbrkJlqpV2zMZiUnN/h5ADim0JwDAEEo4p/3pjyrFNVLs2Lsg1pVLNwRwFigwyLrAO6wyWn8rLE3ly2fCkaC6+3f/MYsAxChJwKhI2anYyHAx8uC5TdDxJR4k7Dso4OLKpD4QQg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82298+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634625744737219.40663594895773; Mon, 18 Oct 2021 23:42:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SzauYY1788612xD3YYw63D4d; Mon, 18 Oct 2021 23:42:24 -0700 X-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 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" X-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" X-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: [edk2-devel] [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> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com X-Gm-Message-State: pkmIj1OOxQQPgtBCkmTPbN4cx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634625744; bh=yDsAIKAawNan21BEckRp/yuK0PWTXkCq8CzEfXmJVj0=; h=Cc:Date:From:Reply-To:Subject:To; b=fkf0lzvf/wWmbsv3odheE4hYK75W00vb0b4guD72PNMJwkJRNxlTc1xPfUU3d36h3dL XvibHNlVw4t3kh1/vlfxctebpJiY2ykShERxD/YlSCIJXPHOYs67Iwoh8JCoWQYSbpNdW 2Y7icvgB7iAWw4oM/EV7cBgRMdxwbe9uWvA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634625745981100002 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Eric Dong --- 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 to be UEFI specification compliant. =20 - Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
Copyright (c) 2020, AMD Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -43,4 +43,25 @@ StandardSignatureIsAuthenticAMD ( VOID ); =20 +/** + Return the 32bit CPU family and model value. + + @return CPUID[01h].EAX with Processor Type and Stepping ID cleared. +**/ +UINT32 +EFIAPI +GetCpuFamilyModel ( + VOID + ); + +/** + Return the CPU stepping ID. + @return CPU stepping ID value in CPUID[01h].EAX. +**/ +UINT8 +EFIAPI +GetCpuSteppingId ( + VOID + ); + #endif 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. =20 Copyright (c) 2020, AMD Inc. All rights reserved.
+ Copyright (c) 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -36,3 +37,45 @@ StandardSignatureIsAuthenticAMD ( RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && RegEdx =3D=3D 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 =3D 0; + Eax.Bits.ProcessorType =3D 0; + Eax.Bits.Reserved1 =3D 0; + Eax.Bits.Reserved2 =3D 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; +} --=20 2.32.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#82298): https://edk2.groups.io/g/devel/message/82298 Mute This Topic: https://groups.io/mt/86434196/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-