From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.11197.1636460058942227753 for ; Tue, 09 Nov 2021 04:14:19 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=ghLha+2N; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: eric.dong@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10162"; a="318631846" X-IronPort-AV: E=Sophos;i="5.87,220,1631602800"; d="scan'208";a="318631846" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2021 04:14:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,220,1631602800"; d="scan'208";a="451873054" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga006.jf.intel.com with ESMTP; 09 Nov 2021 04:14:17 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Tue, 9 Nov 2021 04:14:17 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Tue, 9 Nov 2021 04:14:17 -0800 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.41) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Tue, 9 Nov 2021 04:14:17 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fmmis9aheEVdTfLmTezCYEkJlN/cdoiIumCB9ox63i+4oV48Q+rtLV3/uMvBxJrQr7G186OSvwQAxOc3JqibwtEThMpmgYONf2DNV1lJGYp/yrkeF5z6rEy5EnV0ADfIa2mhFXvakqo0V3B+X2gmrTe1E/BGptNl0kZvo2wHCj9n1qI0GnaxFQVeqApvKiB+sxoKQNt1BmLHqiTyqoTFcQByegHEH+hSzlJEQhw2YeH0ArAB9Ha40xF7ES9lXZN8ECefwq8fxBwBihZ4cF0GzAGzB6Hli1LBd0+lWU0EWjbugPUq3xwVYA9bEuLLVqRwY3QBzHEy9q0XQZ9lRf/8yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rcnBXDepPi8q1W1pxvTT0chHEC8Jj5Z2T3oAsYxMEUc=; b=HChhKlnPbikVDLUIwdd4+yqf7keOQiBCoioUhUc6gF5OORW7AMf257LPC4606Y6ya8C/4E1NEFj0jyGbh2C4Ar0zP9dqX95j3PBdQ9QHlEr7Gtt+HhMCI1lA1LU8sBxA7MtGsUxjUliubLB0Tt3YCLUzoaAkMp+lofirxog/44i6DwcG+8NdvilIV/GtvWrx6PqxUFBk39Nwwmynhmq1SV6MDsjWiGbMpyDgyelvBexdfGfF9zCI4RpPAKRJq5y3b/Cew23d/o1lsztfhj7I+WYvhxfuBkqHtjAPYbmatfU1J+NAW5mDRyq/GKqiEf0b5kka1aVGOid9vdXA2oFUKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rcnBXDepPi8q1W1pxvTT0chHEC8Jj5Z2T3oAsYxMEUc=; b=ghLha+2NwVp0usaJ4B5iTeV3HsYWdmlK7Yn22k9yqqBIZr1f2XjTbDDjg+CqOvNpib+Naw50xNgnVXLiEJQhoAfTTIt39XAxc4pVKYNhic6qjrOE4D9gKxgw+/rJeI2iYwQ3ciD9xZvR10bKc86ewlz8tgvZQihfZwYgFxqvZ50= Received: from BN9PR11MB5258.namprd11.prod.outlook.com (2603:10b6:408:133::13) by BN6PR1101MB2067.namprd11.prod.outlook.com (2603:10b6:405:58::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15; Tue, 9 Nov 2021 12:14:15 +0000 Received: from BN9PR11MB5258.namprd11.prod.outlook.com ([fe80::9530:7d09:938f:6437]) by BN9PR11MB5258.namprd11.prod.outlook.com ([fe80::9530:7d09:938f:6437%3]) with mapi id 15.20.4690.015; Tue, 9 Nov 2021 12:14:15 +0000 From: "Dong, Eric" To: "Ni, Ray" , "devel@edk2.groups.io" CC: "Kumar, Rahul1" Subject: Re: [PATCH] UefiCpuPkg/UefiCpuLib: Add GetCpuFamilyModel and GetCpuSteppingId Thread-Topic: [PATCH] UefiCpuPkg/UefiCpuLib: Add GetCpuFamilyModel and GetCpuSteppingId Thread-Index: AQHXxLR735bmjG/+dUOSRGgzaYKxKqv7PRkA Date: Tue, 9 Nov 2021 12:14:15 +0000 Message-ID: References: <20211019064221.705-1-ray.ni@intel.com> In-Reply-To: <20211019064221.705-1-ray.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.200.16 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 37915630-180c-44de-0bab-08d9a37a72ef x-ms-traffictypediagnostic: BN6PR1101MB2067: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cEE+1m4aWqH4u2+kWCV+jbgdvg7dt9ah9Nib96O7l76SnsLHNZz+qPoUhzHb7i9Dz8N5mLiIaba6HGOAjVmmlaPrOXJUq9SzYgRQ09YpOiMGuZVhcDR8wYNBizWEJIV8lvnyjJVPoHMaTIXDySpjQmnvkGo7Yud9RHKjDLxRdpXKRbHi1IQZEyZLfvX+AHEP4DRI17IwHDqZFOSdS6kldm8bB5dLEBvbvapP/ghsFPyvjivqkbZZ+ZwMBHvDWYPghXWHpwyxA59Fkmjday1WRT8j39xV6ZGeEjVS/5kn+j4K4wl4U0o4YQ6mg5Nb3Jc1sEn6mn8bcmtTEJD//Z0BGeHOrZFjZK2FdB5Vkmz7XF4dxXszX4EXKkPxGhS9FBXdjF7DQFG7LaiLtZvgYBq1v29/NazObUTlBH0ZMjRLe1AyrK83fRZD0eeuRQDT7J34OtAuO0IuZitN4IiNRKTfuXkVzuvAaIVgpnR2Xnvjogqr4jB/jkqLbWmsOwdF0adXaxyTy0tiPysG76BME58uFoJk35KFUd5OdIm+3GiHEjNdy4raaOruGNnedtU0LSUsJDSlbXw95h3cUY5Dl2H1s6D3DFshdgBDJFhoFDvOQ2hn1uHV+oOsuOfvYHtxqrVcrrYoaU3piojvNj78Tu3tbxkDIZ4Mf1o6FkA4ZCB93tevWrpZMuV+RvrLAaEVTuvd+XbB9o2awjV35N5ORlw+QAy6MH4mtUE1NXYX0pxFeb2ZMmffKukgU75r04LT0hZ1IsksKqtHgxhKX5PcEhSzEmOv53riTdJIKMmvnT9Gjb0= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR11MB5258.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(38070700005)(66476007)(64756008)(9686003)(316002)(26005)(66556008)(5660300002)(508600001)(38100700002)(122000001)(8936002)(76116006)(110136005)(8676002)(186003)(52536014)(66946007)(82960400001)(19627235002)(53546011)(966005)(83380400001)(107886003)(7696005)(71200400001)(33656002)(4326008)(6506007)(86362001)(66446008)(2906002)(55016002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?KqTZKY2oUekvAlx8WDPX8XP/+ihOpz/Kxg5GQsT1efBXnlXoTA3aGfHPW2un?= =?us-ascii?Q?1Q+l0El4OedF+HSBD/I4nZXlnalYC+E7yyPEIfWN9OaWRX3vhNXcOAyCg+6U?= =?us-ascii?Q?UevTofIr4ZoJ6Ztuje96xQuEfcPHNIkiHhsz4EgjP4xtyi7UxPEMa+E1mMx6?= =?us-ascii?Q?ufwhKf0RDEW84mgSj0O2kAF9ruJPuhHxZwr5BzrWbutLOupJGEEmFlvcc8Dp?= =?us-ascii?Q?W7PPoi4VR4md/rh4rbbxAedeyFvCa5vNLUpYkv3SDij/UNPd43Khokz4Y9tg?= =?us-ascii?Q?cjozZUNPc8S/t6LSakWeNtNsaR7Zm63f/QS2+eOaWI+ss5pmEwYXW6v66y6g?= =?us-ascii?Q?K/B/hLDt7c2GONBkp5MCsscgqnBZb6ZPZB5jGHPKkhpvSP+mO9O1whDOQBBu?= =?us-ascii?Q?JKuHCffWSeAatJCyTSTTUXFHB7zohsVwQebWhNtFW0ocb982+niDTrU75olt?= =?us-ascii?Q?zBcmZUPHElBfFyz+ALhBKdPH9peCyJLsG8p5xCchadl3tss2KffrtGgi05KC?= =?us-ascii?Q?0JkSGy705wX0K+o1N4f/5UNdKmoH9/O+x3US69TAzTuTSU/wRTzb4lVCDe/m?= =?us-ascii?Q?Qm9wG5dRK6vKCReCvKYvttS3NfPSWuAfU3T+QqEWZWmzmeiZXiY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gtpCuH1eaaZB6c1x0L1vpf6FgSsNStvPI?= =?us-ascii?Q?euvYwAlgdWdCTsPbMeR7czWAAYNLBpSpRyY4L7HbtztL+OiyNSv+JDTt5rgj?= =?us-ascii?Q?8K/NRTgM952W3OSlSbXqQZ0=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5258.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37915630-180c-44de-0bab-08d9a37a72ef X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2021 12:14:15.7788 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GM0fuDIz0h0vATr1rlgM9ZzXnjUjo1Yc5mwN87qeUqk2+i6o3PCd1Ht5G2q+ozdIu53T626ylH2HrgpMfLK++g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1101MB2067 Return-Path: eric.dong@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong -----Original Message----- From: Ni, Ray =20 Sent: Tuesday, October 19, 2021 2:42 PM To: devel@edk2.groups.io Cc: Dong, Eric ; Kumar, Rahul1 Subject: [PATCH] UefiCpuPkg/UefiCpuLib: Add GetCpuFamilyModel and GetCpuSte= ppingId 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 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