mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
78c4992529
commit
3bb13d35d6
|
@ -18,6 +18,9 @@
|
||||||
|
|
||||||
#include <Base.h>
|
#include <Base.h>
|
||||||
|
|
||||||
|
#include <Register/Cpuid.h>
|
||||||
|
#include <Register/Msr.h>
|
||||||
|
|
||||||
#include <Library/MtrrLib.h>
|
#include <Library/MtrrLib.h>
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
#include <Library/CpuLib.h>
|
#include <Library/CpuLib.h>
|
||||||
|
@ -2124,26 +2127,25 @@ IsMtrrSupported (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 RegEdx;
|
CPUID_VERSION_INFO_EDX Edx;
|
||||||
UINT64 MtrrCap;
|
MSR_IA32_MTRRCAP_REGISTER MtrrCap;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check CPUID(1).EDX[12] for MTRR capability
|
// Check CPUID(1).EDX[12] for MTRR capability
|
||||||
//
|
//
|
||||||
AsmCpuid (1, NULL, NULL, NULL, &RegEdx);
|
AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &Edx.Uint32);
|
||||||
if (BitFieldRead32 (RegEdx, 12, 12) == 0) {
|
if (Edx.Bits.MTRR == 0) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check IA32_MTRRCAP.[0..7] for number of variable MTRRs and IA32_MTRRCAP[8] for
|
// Check number of variable MTRRs and fixed MTRRs existence.
|
||||||
// fixed MTRRs existence. If number of variable MTRRs is zero, or fixed MTRRs do not
|
// If number of variable MTRRs is zero, or fixed MTRRs do not
|
||||||
// exist, return false.
|
// exist, return false.
|
||||||
//
|
//
|
||||||
MtrrCap = AsmReadMsr64 (MTRR_LIB_IA32_MTRR_CAP);
|
MtrrCap.Uint64 = AsmReadMsr64 (MSR_IA32_MTRRCAP);
|
||||||
if ((BitFieldRead64 (MtrrCap, 0, 7) == 0) || (BitFieldRead64 (MtrrCap, 8, 8) == 0)) {
|
if ((MtrrCap.Bits.VCNT == 0) || (MtrrCap.Bits.FIX == 0)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue