]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MtrrLib: Add MtrrDebugPrintAllMtrrsWorker()
authorMichael Kinney <michael.d.kinney@intel.com>
Tue, 8 Dec 2015 05:25:48 +0000 (05:25 +0000)
committervanjeff <vanjeff@Edk2>
Tue, 8 Dec 2015 05:25:48 +0000 (05:25 +0000)
MtrrDebugPrintAllMtrrsWorker() provides the capability to dump the MTRR setting
from MTRRs or the input MTRR settings buffer.

Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19161 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/Library/MtrrLib/MtrrLib.c

index 4c76abf9eb38258a6f0d8bb36c2bd10786977451..a5bfa88016155352df18dabcb33e8ecc180b3361 100644 (file)
@@ -1248,18 +1248,23 @@ MtrrGetMemoryAttribute (
   return MtrrGetMemoryAttributeByAddressWorker (NULL, Address);\r
 }\r
 \r
-\r
 /**\r
-  This function prints all MTRRs for debugging.\r
+  Worker function prints all MTRRs for debugging.\r
+\r
+  If MtrrSetting is not NULL, print MTRR settings from from input MTRR\r
+  settings buffer.\r
+  If MtrrSetting is NULL, print MTRR settings from MTRRs.\r
+\r
+  @param  MtrrSetting    A buffer holding all MTRRs content.\r
 **/\r
 VOID\r
-EFIAPI\r
-MtrrDebugPrintAllMtrrs (\r
-  VOID\r
+MtrrDebugPrintAllMtrrsWorker (\r
+  IN MTRR_SETTINGS    *MtrrSetting\r
   )\r
 {\r
   DEBUG_CODE (\r
-    MTRR_SETTINGS  MtrrSettings;\r
+    MTRR_SETTINGS  LocalMtrrs;\r
+    MTRR_SETTINGS  *Mtrrs;\r
     UINTN          Index;\r
     UINTN          Index1;\r
     UINTN          VariableMtrrCount;\r
@@ -1283,18 +1288,24 @@ MtrrDebugPrintAllMtrrs (
     DEBUG((DEBUG_CACHE, "MTRR Settings\n"));\r
     DEBUG((DEBUG_CACHE, "=============\n"));\r
 \r
-    MtrrGetAllMtrrs (&MtrrSettings);\r
-    DEBUG((DEBUG_CACHE, "MTRR Default Type: %016lx\n", MtrrSettings.MtrrDefType));\r
+    if (MtrrSetting != NULL) {\r
+      Mtrrs = MtrrSetting;\r
+    } else {\r
+      MtrrGetAllMtrrs (&LocalMtrrs);\r
+      Mtrrs = &LocalMtrrs;\r
+    }\r
+\r
+    DEBUG((DEBUG_CACHE, "MTRR Default Type: %016lx\n", Mtrrs->MtrrDefType));\r
     for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) {\r
-      DEBUG((DEBUG_CACHE, "Fixed MTRR[%02d]   : %016lx\n", Index, MtrrSettings.Fixed.Mtrr[Index]));\r
+      DEBUG((DEBUG_CACHE, "Fixed MTRR[%02d]   : %016lx\n", Index, Mtrrs->Fixed.Mtrr[Index]));\r
     }\r
 \r
     VariableMtrrCount = GetVariableMtrrCount ();\r
     for (Index = 0; Index < VariableMtrrCount; Index++) {\r
       DEBUG((DEBUG_CACHE, "Variable MTRR[%02d]: Base=%016lx Mask=%016lx\n",\r
         Index,\r
-        MtrrSettings.Variables.Mtrr[Index].Base,\r
-        MtrrSettings.Variables.Mtrr[Index].Mask\r
+        Mtrrs->Variables.Mtrr[Index].Base,\r
+        Mtrrs->Variables.Mtrr[Index].Mask\r
         ));\r
     }\r
     DEBUG((DEBUG_CACHE, "\n"));\r
@@ -1306,7 +1317,7 @@ MtrrDebugPrintAllMtrrs (
     for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) {\r
       Base = mMtrrLibFixedMtrrTable[Index].BaseAddress;\r
       for (Index1 = 0; Index1 < 8; Index1++) {\r
-      MemoryType = (UINTN)(RShiftU64 (MtrrSettings.Fixed.Mtrr[Index], Index1 * 8) & 0xff);\r
+      MemoryType = (UINTN)(RShiftU64 (Mtrrs->Fixed.Mtrr[Index], Index1 * 8) & 0xff);\r
         if (MemoryType > CacheWriteBack) {\r
           MemoryType = MTRR_CACHE_INVALID_TYPE;\r
         }\r
@@ -1333,7 +1344,7 @@ MtrrDebugPrintAllMtrrs (
     Base = BASE_1MB;\r
     PreviousMemoryType = MTRR_CACHE_INVALID_TYPE;\r
     do {\r
-      MemoryType = MtrrGetMemoryAttribute (Base);\r
+      MemoryType = MtrrGetMemoryAttributeByAddressWorker (Mtrrs, Base);\r
       if (MemoryType > CacheWriteBack) {\r
         MemoryType = MTRR_CACHE_INVALID_TYPE;\r
       }\r
@@ -1352,14 +1363,14 @@ MtrrDebugPrintAllMtrrs (
       NoRangeLimit = Limit;\r
 \r
       for (Index = 0, Found = FALSE; Index < VariableMtrrCount; Index++) {\r
-        if ((MtrrSettings.Variables.Mtrr[Index].Mask & BIT11) == 0) {\r
+        if ((Mtrrs->Variables.Mtrr[Index].Mask & BIT11) == 0) {\r
           //\r
           // If mask is not valid, then do not display range\r
           //\r
           continue;\r
         }\r
-        MtrrBase  = (MtrrSettings.Variables.Mtrr[Index].Base & (~(SIZE_4KB - 1)));\r
-        MtrrLimit = MtrrBase + ((~(MtrrSettings.Variables.Mtrr[Index].Mask & (~(SIZE_4KB - 1)))) & Limit);\r
+        MtrrBase  = (Mtrrs->Variables.Mtrr[Index].Base & (~(SIZE_4KB - 1)));\r
+        MtrrLimit = MtrrBase + ((~(Mtrrs->Variables.Mtrr[Index].Mask & (~(SIZE_4KB - 1)))) & Limit);\r
 \r
         if (Base >= MtrrBase && Base < MtrrLimit) {\r
           Found = TRUE;\r
@@ -1395,8 +1406,23 @@ MtrrDebugPrintAllMtrrs (
     DEBUG((DEBUG_CACHE, "%016lx\n\n", Base - 1));\r
   );\r
 }\r
+\r
+\r
+/**\r
+  This function prints all MTRRs for debugging.\r
+**/\r
+VOID\r
+EFIAPI\r
+MtrrDebugPrintAllMtrrs (\r
+  VOID\r
+  )\r
+{\r
+  MtrrDebugPrintAllMtrrsWorker (NULL);\r
+}\r
+\r
+\r
 /**\r
-  This function attempts to set the attributes for a memory range.\r
+  Worker function attempts to set the attributes for a memory range.\r
 \r
   @param[in]       BaseAddress       The physical address that is the start\r
                                      address of a memory region.\r