From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.5530.1646212796036188164 for ; Wed, 02 Mar 2022 01:20:01 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=KNZNLowb; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: yu.pu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646212801; x=1677748801; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LLNGGY6bsPUzgoSgOP0g5tdiV8rPRguAniL1NKgQkHU=; b=KNZNLowbGuSy6mZhNQJDO62GPOvKo5b48JhcqgdvSViKjIXFpLs6sqww R+wSdDira8fcWXwhpTZbR8xaHJRzRDELaroyTCKKVQuYybS4m8FpKGcEu gZlHADY3BnWdGYir904N7IogsrApEX4pOcBh/9mCzPbzpLR6Czh2FPxxD jj61Aj5C7sinomeN+Wx6uxbTtT0E66zSgnqn9D3KKYNArV5qBvoLyYAoN kWELxRQIVhdcsAZqyZr61b4Xk/ShXYeubrIpO4RPr63FRXyznxqum6HS+ +rRa5jerVH/phZKj0zXKQDrSjuvUrWgu3Znml7qfV2TYUKgBHk8y4nWW4 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="233324199" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="233324199" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 01:20:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="641630343" Received: from shwdeopenlab704.ccr.corp.intel.com ([10.239.182.239]) by orsmga004.jf.intel.com with ESMTP; 02 Mar 2022 01:20:00 -0800 From: Yu Pu To: devel@edk2.groups.io Cc: Yu Pu , Chasel Chiu Subject: [PATCH v1 3/7] IntelFsp2Pkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Date: Wed, 2 Mar 2022 17:18:55 +0800 Message-Id: <20220302091859.2783-4-yu.pu@intel.com> X-Mailer: git-send-email 2.30.0.windows.2 In-Reply-To: <20220302091859.2783-1-yu.pu@intel.com> References: <20220302091859.2783-1-yu.pu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3394 Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical address mask calculation and remove the duplicated code in edk2\IntelFsp2Pkg\Library\BaseCacheLib\CacheLib.c. Cc: Chasel Chiu Signed-off-by: Yu Pu --- IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c | 10 ++-------- IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf | 2 ++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c b/IntelFsp2Pkg/Li= brary/BaseCacheLib/CacheLib.c index f879c268e7ec..3f8ed122b2be 100644 --- a/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c +++ b/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c @@ -9,6 +9,7 @@ #include =0D #include =0D #include =0D +#include =0D #include "CacheLibInternal.h"=0D =0D /**=0D @@ -388,15 +389,8 @@ SetCacheAttributes ( UINT32 UsedMsrNum;=0D EFI_MEMORY_CACHE_TYPE UsedMemoryCacheType;=0D UINT64 ValidMtrrAddressMask;=0D - UINT32 Cpuid_RegEax;=0D =0D - AsmCpuid (CPUID_EXTENDED_FUNCTION, &Cpuid_RegEax, NULL, NULL, NULL);=0D - if (Cpuid_RegEax >=3D CPUID_VIR_PHY_ADDRESS_SIZE) {=0D - AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &Cpuid_RegEax, NULL, NULL, NULL)= ;=0D - ValidMtrrAddressMask =3D (LShiftU64 ((UINT64)1, (Cpuid_RegEax & 0xFF))= - 1) & (~(UINT64)0x0FFF);=0D - } else {=0D - ValidMtrrAddressMask =3D (LShiftU64 ((UINT64)1, 36) - 1) & (~(UINT64)0= x0FFF);=0D - }=0D + GetPhysicalAddressBits(NULL, &ValidMtrrAddressMask);=0D =0D //=0D // Check for invalid parameter=0D diff --git a/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf b/IntelFsp2= Pkg/Library/BaseCacheLib/BaseCacheLib.inf index 9a513fb6df77..e6b14ae4a802 100644 --- a/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf +++ b/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf @@ -21,9 +21,11 @@ =0D [Packages]=0D MdePkg/MdePkg.dec=0D + UefiCpuPkg/UefiCpuPkg.dec=0D IntelFsp2Pkg/IntelFsp2Pkg.dec=0D =0D [LibraryClasses]=0D BaseMemoryLib=0D CacheAsRamLib=0D + UefiCpuLib=0D =0D --=20 2.30.0.windows.2