From 91ec78241c81a1af766fc5d8cb6c3abf3b0d6b32 Mon Sep 17 00:00:00 2001 From: vanjeff Date: Fri, 28 Oct 2011 06:01:55 +0000 Subject: 1. Introduce the API MtrrGetDefaultMemoryType () in Mtrr Library. 2. Invoke MtrrGetDefaultMemoryType() to get the default memory type instead of the hard code value in module. 3. Add go though for UC attributes. Signed-off-by: vanjeff Reviewed-by: rsun3 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12587 6f19259b-4bc3-4df7-8a09-765794883524 --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'UefiCpuPkg/Library') diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c index 04c6a1c..5f1a22c 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -144,17 +144,21 @@ GetFirmwareVariableMtrrCount ( /** Returns the default MTRR cache type for the system. - @return MTRR default type + @return The default MTRR cache type. **/ -UINT64 -GetMtrrDefaultMemoryType ( +MTRR_MEMORY_CACHE_TYPE +EFIAPI +MtrrGetDefaultMemoryType ( VOID -) + ) { - return (AsmReadMsr64 (MTRR_LIB_IA32_MTRR_DEF_TYPE) & 0xff); -} + if (!IsMtrrSupported ()) { + return CacheUncacheable; + } + return (MTRR_MEMORY_CACHE_TYPE) (AsmReadMsr64 (MTRR_LIB_IA32_MTRR_DEF_TYPE) & 0x7); +} /** Preparation before programming MTRR. @@ -1036,7 +1040,7 @@ MtrrSetMemoryAttribute ( // The memory type is the same with the type specified by // MTRR_LIB_IA32_MTRR_DEF_TYPE. // - if ((!OverwriteExistingMtrr) && (Attribute == GetMtrrDefaultMemoryType ())) { + if ((!OverwriteExistingMtrr) && (Attribute == MtrrGetDefaultMemoryType ())) { // // Invalidate the now-unused MTRRs // -- cgit v1.1