summaryrefslogtreecommitdiff
path: root/UefiCpuPkg/Library
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2011-10-28 06:01:55 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2011-10-28 06:01:55 +0000
commit91ec78241c81a1af766fc5d8cb6c3abf3b0d6b32 (patch)
tree0f9c5cc208bc67e2c93e64a04fb8ac2c8dcc0e46 /UefiCpuPkg/Library
parentbeda2356f5128efa4461046f882b6516ece6afc7 (diff)
downloadedk2-91ec78241c81a1af766fc5d8cb6c3abf3b0d6b32.zip
edk2-91ec78241c81a1af766fc5d8cb6c3abf3b0d6b32.tar.gz
edk2-91ec78241c81a1af766fc5d8cb6c3abf3b0d6b32.tar.bz2
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
Diffstat (limited to 'UefiCpuPkg/Library')
-rw-r--r--UefiCpuPkg/Library/MtrrLib/MtrrLib.c18
1 files changed, 11 insertions, 7 deletions
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
//