summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/Library/MtrrLib
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2016-09-02 10:27:29 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2017-03-31 13:57:31 +0800
commit3bb13d35d6b9255f5a2ed4f05a91b98d3486aed3 (patch)
tree3abe35d36aba754780e6e250e09c718e32a407fd /UefiCpuPkg/Library/MtrrLib
parent78c4992529c3954417068ee165a072c096d0b186 (diff)
downloadedk2-3bb13d35d6b9255f5a2ed4f05a91b98d3486aed3.tar.gz
edk2-3bb13d35d6b9255f5a2ed4f05a91b98d3486aed3.tar.bz2
edk2-3bb13d35d6b9255f5a2ed4f05a91b98d3486aed3.zip
UefiCpuPkg/MtrrLib: IsMtrrSupported uses definitions in Msr.h
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Diffstat (limited to 'UefiCpuPkg/Library/MtrrLib')
-rw-r--r--UefiCpuPkg/Library/MtrrLib/MtrrLib.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index 547f827e50..b80519ba6d 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -18,6 +18,9 @@
#include <Base.h>
+#include <Register/Cpuid.h>
+#include <Register/Msr.h>
+
#include <Library/MtrrLib.h>
#include <Library/BaseLib.h>
#include <Library/CpuLib.h>
@@ -2124,26 +2127,25 @@ IsMtrrSupported (
VOID
)
{
- UINT32 RegEdx;
- UINT64 MtrrCap;
+ CPUID_VERSION_INFO_EDX Edx;
+ MSR_IA32_MTRRCAP_REGISTER MtrrCap;
//
// Check CPUID(1).EDX[12] for MTRR capability
//
- AsmCpuid (1, NULL, NULL, NULL, &RegEdx);
- if (BitFieldRead32 (RegEdx, 12, 12) == 0) {
+ AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &Edx.Uint32);
+ if (Edx.Bits.MTRR == 0) {
return FALSE;
}
//
- // Check IA32_MTRRCAP.[0..7] for number of variable MTRRs and IA32_MTRRCAP[8] for
- // fixed MTRRs existence. If number of variable MTRRs is zero, or fixed MTRRs do not
+ // Check number of variable MTRRs and fixed MTRRs existence.
+ // If number of variable MTRRs is zero, or fixed MTRRs do not
// exist, return false.
//
- MtrrCap = AsmReadMsr64 (MTRR_LIB_IA32_MTRR_CAP);
- if ((BitFieldRead64 (MtrrCap, 0, 7) == 0) || (BitFieldRead64 (MtrrCap, 8, 8) == 0)) {
+ MtrrCap.Uint64 = AsmReadMsr64 (MSR_IA32_MTRRCAP);
+ if ((MtrrCap.Bits.VCNT == 0) || (MtrrCap.Bits.FIX == 0)) {
return FALSE;
}
-
return TRUE;
}