]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MtrrLib/MtrrLib.c
UefiCpuPkg/MtrrLib: Add worker functions not invoke IsMtrrSupported()
[mirror_edk2.git] / UefiCpuPkg / Library / MtrrLib / MtrrLib.c
index d9449bcca5d99f334451ee099f41e4f3f5ff02dc..b1c12aa32e01026a4a2765b9f08a4bd13d51c39f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   MTRR setting library\r
 \r
-  Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -86,7 +86,7 @@ CONST FIXED_MTRR  mMtrrLibFixedMtrrTable[] = {
     MTRR_LIB_IA32_MTRR_FIX4K_F8000,\r
     0xF8000,\r
     SIZE_4KB\r
-  },\r
+  }\r
 };\r
 \r
 //\r
@@ -103,6 +103,24 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mMtrrMemoryCacheTypeShortName[] = {
   "R*"   // Invalid\r
 };\r
 \r
+/**\r
+  Worker function returns the variable MTRR count for the CPU.\r
+\r
+  @return Variable MTRR count\r
+\r
+**/\r
+UINT32\r
+GetVariableMtrrCountWorker (\r
+  VOID\r
+  )\r
+{\r
+  UINT32  VariableMtrrCount;\r
+\r
+  VariableMtrrCount = (UINT32)(AsmReadMsr64 (MTRR_LIB_IA32_MTRR_CAP) & MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);\r
+  ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);\r
+  return VariableMtrrCount;\r
+}\r
+\r
 /**\r
   Returns the variable MTRR count for the CPU.\r
 \r
@@ -115,16 +133,33 @@ GetVariableMtrrCount (
   VOID\r
   )\r
 {\r
-  UINT32  VariableMtrrCount;\r
-\r
   if (!IsMtrrSupported ()) {\r
     return 0;\r
   }\r
+  return GetVariableMtrrCountWorker ();\r
+}\r
 \r
-  VariableMtrrCount = (UINT32)(AsmReadMsr64 (MTRR_LIB_IA32_MTRR_CAP) & MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);\r
-  ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);\r
+/**\r
+  Worker function returns the firmware usable variable MTRR count for the CPU.\r
 \r
-  return VariableMtrrCount;\r
+  @return Firmware usable variable MTRR count\r
+\r
+**/\r
+UINT32\r
+GetFirmwareVariableMtrrCountWorker (\r
+  VOID\r
+  )\r
+{\r
+  UINT32  VariableMtrrCount;\r
+  UINT32  ReservedMtrrNumber;\r
+\r
+  VariableMtrrCount = GetVariableMtrrCountWorker ();\r
+  ReservedMtrrNumber = PcdGet32 (PcdCpuNumberOfReservedVariableMtrrs);\r
+  if (VariableMtrrCount < ReservedMtrrNumber) {\r
+    return 0;\r
+  }\r
+\r
+  return VariableMtrrCount - ReservedMtrrNumber;\r
 }\r
 \r
 /**\r
@@ -139,16 +174,27 @@ GetFirmwareVariableMtrrCount (
   VOID\r
   )\r
 {\r
-  UINT32  VariableMtrrCount;\r
-\r
-  VariableMtrrCount = GetVariableMtrrCount ();\r
-  if (VariableMtrrCount < RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER) {\r
+  if (!IsMtrrSupported ()) {\r
     return 0;\r
   }\r
+  return GetFirmwareVariableMtrrCountWorker ();\r
+}\r
+\r
+/**\r
+  Worker function returns the default MTRR cache type for the system.\r
+\r
+  @return  The default MTRR cache type.\r
 \r
-  return VariableMtrrCount - RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER;\r
+**/\r
+MTRR_MEMORY_CACHE_TYPE\r
+MtrrGetDefaultMemoryTypeWorker (\r
+  VOID\r
+  )\r
+{\r
+  return (MTRR_MEMORY_CACHE_TYPE) (AsmReadMsr64 (MTRR_LIB_IA32_MTRR_DEF_TYPE) & 0x7);\r
 }\r
 \r
+\r
 /**\r
   Returns the default MTRR cache type for the system.\r
 \r
@@ -164,8 +210,7 @@ MtrrGetDefaultMemoryType (
   if (!IsMtrrSupported ()) {\r
     return CacheUncacheable;\r
   }\r
-\r
-  return (MTRR_MEMORY_CACHE_TYPE) (AsmReadMsr64 (MTRR_LIB_IA32_MTRR_DEF_TYPE) & 0x7);\r
+  return MtrrGetDefaultMemoryTypeWorker ();\r
 }\r
 \r
 /**\r
@@ -186,7 +231,7 @@ PreMtrrChange (
   // Disable interrupts and save current interrupt state\r
   //\r
   MtrrContext->InterruptState = SaveAndDisableInterrupts();\r
-  \r
+\r
   //\r
   // Enter no fill cache mode, CD=1(Bit30), NW=0 (Bit29)\r
   //\r
@@ -204,7 +249,7 @@ PreMtrrChange (
   CpuFlushTlb ();\r
 \r
   //\r
-  // Disable Mtrrs\r
+  // Disable MTRRs\r
   //\r
   AsmMsrBitFieldWrite64 (MTRR_LIB_IA32_MTRR_DEF_TYPE, 10, 11, 0);\r
 }\r
@@ -224,7 +269,7 @@ PostMtrrChangeEnableCache (
   )\r
 {\r
   //\r
-  // Flush all TLBs \r
+  // Flush all TLBs\r
   //\r
   CpuFlushTlb ();\r
 \r
@@ -237,7 +282,7 @@ PostMtrrChangeEnableCache (
   // Restore original CR4 value\r
   //\r
   AsmWriteCr4 (MtrrContext->Cr4);\r
-  \r
+\r
   //\r
   // Restore original interrupt state\r
   //\r
@@ -270,9 +315,9 @@ PostMtrrChange (
 /**\r
   Programs fixed MTRRs registers.\r
 \r
-  @param  MemoryCacheType  The memory type to set.\r
-  @param  Base             The base address of memory range.\r
-  @param  Length           The length of memory range.\r
+  @param[in]      MemoryCacheType  The memory type to set.\r
+  @param[in, out] Base             The base address of memory range.\r
+  @param[in, out] Length           The length of memory range.\r
 \r
   @retval RETURN_SUCCESS      The cache type was updated successfully\r
   @retval RETURN_UNSUPPORTED  The requested range or cache type was invalid\r
@@ -354,14 +399,14 @@ ProgramFixedMtrr (
 \r
 \r
 /**\r
-  Get the attribute of variable MTRRs.\r
+  Gets the attribute of variable MTRRs.\r
 \r
   This function shadows the content of variable MTRRs into an\r
   internal array: VariableMtrr.\r
 \r
-  @param  MtrrValidBitsMask     The mask for the valid bit of the MTRR\r
-  @param  MtrrValidAddressMask  The valid address mask for MTRR\r
-  @param  VariableMtrr          The array to shadow variable MTRRs content\r
+  @param[in]   MtrrValidBitsMask     The mask for the valid bit of the MTRR\r
+  @param[in]   MtrrValidAddressMask  The valid address mask for MTRR\r
+  @param[out]  VariableMtrr          The array to shadow variable MTRRs content\r
 \r
   @return                       The return value of this paramter indicates the\r
                                 number of MTRRs which has been used.\r
@@ -421,9 +466,9 @@ MtrrGetMemoryAttributeInVariableMtrr (
 /**\r
   Checks overlap between given memory range and MTRRs.\r
 \r
-  @param  Start            The start address of memory range.\r
-  @param  End              The end address of memory range.\r
-  @param  VariableMtrr     The array to shadow variable MTRRs content\r
+  @param[in]  Start                      The start address of memory range.\r
+  @param[in]  End                        The end address of memory range.\r
+  @param[in]  VariableMtrr               The array to shadow variable MTRRs content\r
 \r
   @retval TRUE             Overlap exists.\r
   @retval FALSE            No overlap.\r
@@ -459,9 +504,9 @@ CheckMemoryAttributeOverlap (
 /**\r
   Marks a variable MTRR as non-valid.\r
 \r
-  @param  Index         The index of the array VariableMtrr to be invalidated\r
-  @param  VariableMtrr  The array to shadow variable MTRRs content\r
-  @param  UsedMtrr      The number of MTRRs which has already been used\r
+  @param[in]   Index         The index of the array VariableMtrr to be invalidated\r
+  @param[in]   VariableMtrr  The array to shadow variable MTRRs content\r
+  @param[out]  UsedMtrr      The number of MTRRs which has already been used\r
 \r
 **/\r
 VOID\r
@@ -477,16 +522,16 @@ InvalidateShadowMtrr (
 \r
 \r
 /**\r
-  Combine memory attributes.\r
+  Combines memory attributes.\r
 \r
   If overlap exists between given memory range and MTRRs, try to combine them.\r
 \r
-  @param  Attributes             The memory type to set.\r
-  @param  Base                   The base address of memory range.\r
-  @param  Length                 The length of memory range.\r
-  @param  VariableMtrr           The array to shadow variable MTRRs content\r
-  @param  UsedMtrr               The number of MTRRs which has already been used\r
-  @param  OverwriteExistingMtrr  Returns whether an existing MTRR was used\r
+  @param[in]       Attributes                 The memory type to set.\r
+  @param[in, out]  Base                       The base address of memory range.\r
+  @param[in, out]  Length                     The length of memory range.\r
+  @param[in]       VariableMtrr               The array to shadow variable MTRRs content\r
+  @param[in, out]  UsedMtrr                   The number of MTRRs which has already been used\r
+  @param[out]      OverwriteExistingMtrr      Returns whether an existing MTRR was used\r
 \r
   @retval EFI_SUCCESS            Memory region successfully combined.\r
   @retval EFI_ACCESS_DENIED      Memory region cannot be combined.\r
@@ -534,7 +579,7 @@ CombineMemoryAttribute (
     //\r
     if (Attributes == VariableMtrr[Index].Type) {\r
       //\r
-      // if the Mtrr range contain the request range, set a flag, then continue to \r
+      // if the MTRR range contain the request range, set a flag, then continue to\r
       // invalidate any MTRR of the same request range with higher priority cache type.\r
       //\r
       if (VariableMtrr[Index].BaseAddress <= *Base && MtrrEnd >= EndAddress) {\r
@@ -595,9 +640,10 @@ CombineMemoryAttribute (
 \r
 \r
 /**\r
-  Calculate the maximum value which is a power of 2, but less the MemoryLength.\r
+  Calculates the maximum value which is a power of 2, but less the MemoryLength.\r
+\r
+  @param[in]  MemoryLength        The number to pass in.\r
 \r
-  @param  MemoryLength        The number to pass in.\r
   @return The maximum value which is align to power of 2 and less the MemoryLength\r
 \r
 **/\r
@@ -624,21 +670,22 @@ Power2MaxMemory (
 \r
 \r
 /**\r
-  Determine the MTRR numbers used to program a memory range.\r
+  Determines the MTRR numbers used to program a memory range.\r
 \r
-  This function first checks the alignment of the base address. If the alignment of the base address <= Length,\r
-  cover the memory range (BaseAddress, alignment) by a MTRR, then BaseAddress += alignment and Length -= alignment.\r
-  Repeat the step until alignment > Length.\r
+  This function first checks the alignment of the base address.\r
+  If the alignment of the base address <= Length, cover the memory range\r
+ (BaseAddress, alignment) by a MTRR, then BaseAddress += alignment and\r
+  Length -= alignment. Repeat the step until alignment > Length.\r
 \r
-  Then this function determines which direction of programming the variable MTRRs for the remaining length\r
-  will use fewer MTRRs.\r
+  Then this function determines which direction of programming the variable\r
+  MTRRs for the remaining length will use fewer MTRRs.\r
 \r
-  @param  BaseAddress Length of Memory to program MTRR\r
-  @param  Length      Length of Memory to program MTRR\r
-  @param  MtrrNumber  Pointer to the number of necessary MTRRs\r
+  @param[in]  BaseAddress Length of Memory to program MTRR\r
+  @param[in]  Length      Length of Memory to program MTRR\r
+  @param[in]  MtrrNumber  Pointer to the number of necessary MTRRs\r
 \r
   @retval TRUE        Positive direction is better.\r
-          FALSE       Negtive direction is better.\r
+          FALSE       Negative direction is better.\r
 \r
 **/\r
 BOOLEAN\r
@@ -707,13 +754,13 @@ GetMtrrNumberAndDirection (
   This function programs MTRRs according to the values specified\r
   in the shadow array.\r
 \r
-  @param  VariableMtrr   The array to shadow variable MTRRs content\r
+  @param[in, out]  VariableMtrr       Shadow of variable MTRR contents\r
 \r
 **/\r
 VOID\r
 InvalidateMtrr (\r
-   IN     VARIABLE_MTRR      *VariableMtrr\r
-   )\r
+  IN OUT VARIABLE_MTRR           *VariableMtrr\r
+  )\r
 {\r
   UINTN         Index;\r
   UINTN         VariableMtrrCount;\r
@@ -739,11 +786,11 @@ InvalidateMtrr (
 \r
   This function programs variable MTRRs\r
 \r
-  @param  MtrrNumber            Index of MTRR to program.\r
-  @param  BaseAddress           Base address of memory region.\r
-  @param  Length                Length of memory region.\r
-  @param  MemoryCacheType       Memory type to set.\r
-  @param  MtrrValidAddressMask  The valid address mask for MTRR\r
+  @param[in]       MtrrNumber            Index of MTRR to program.\r
+  @param[in]       BaseAddress           Base address of memory region.\r
+  @param[in]       Length                Length of memory region.\r
+  @param[in]       MemoryCacheType       Memory type to set.\r
+  @param[in]       MtrrValidAddressMask  The valid address mask for MTRR\r
 \r
 **/\r
 VOID\r
@@ -780,9 +827,9 @@ ProgramVariableMtrr (
 \r
 \r
 /**\r
-  Convert the Memory attibute value to MTRR_MEMORY_CACHE_TYPE.\r
+  Converts the Memory attribute value to MTRR_MEMORY_CACHE_TYPE.\r
 \r
-  @param  MtrrType  MTRR memory type\r
+  @param[in]  MtrrType           MTRR memory type\r
 \r
   @return The enum item in MTRR_MEMORY_CACHE_TYPE\r
 \r
@@ -806,7 +853,7 @@ GetMemoryCacheTypeFromMtrrType (
   default:\r
     //\r
     // MtrrType is MTRR_CACHE_INVALID_TYPE, that means\r
-    // no mtrr covers the range\r
+    // no MTRR covers the range\r
     //\r
     return MtrrGetDefaultMemoryType ();\r
   }\r
@@ -817,8 +864,8 @@ GetMemoryCacheTypeFromMtrrType (
 \r
   This function initializes the valid bits mask and valid address mask for MTRRs.\r
 \r
-  @param  MtrrValidBitsMask     The mask for the valid bit of the MTRR\r
-  @param  MtrrValidAddressMask  The valid address mask for the MTRR\r
+  @param[out]  MtrrValidBitsMask     The mask for the valid bit of the MTRR\r
+  @param[out]  MtrrValidAddressMask  The valid address mask for the MTRR\r
 \r
 **/\r
 VOID\r
@@ -840,28 +887,28 @@ MtrrLibInitializeMtrrMask (
     *MtrrValidBitsMask    = LShiftU64 (1, PhysicalAddressBits) - 1;\r
     *MtrrValidAddressMask = *MtrrValidBitsMask & 0xfffffffffffff000ULL;\r
   } else {\r
-    *MtrrValidBitsMask    = MTRR_LIB_CACHE_VALID_ADDRESS;\r
-    *MtrrValidAddressMask = 0xFFFFFFFF;\r
+    *MtrrValidBitsMask    = MTRR_LIB_MSR_VALID_MASK;\r
+    *MtrrValidAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS;\r
   }\r
 }\r
 \r
 \r
 /**\r
-  Determing the real attribute of a memory range.\r
+  Determines the real attribute of a memory range.\r
 \r
   This function is to arbitrate the real attribute of the memory when\r
-  there are 2 MTRR covers the same memory range.  For further details,\r
+  there are 2 MTRRs covers the same memory range.  For further details,\r
   please refer the IA32 Software Developer's Manual, Volume 3,\r
   Section 10.11.4.1.\r
 \r
-  @param  MtrrType1    the first kind of Memory type\r
-  @param  MtrrType2    the second kind of memory type\r
+  @param[in]  MtrrType1    The first kind of Memory type\r
+  @param[in]  MtrrType2    The second kind of memory type\r
 \r
 **/\r
 UINT64\r
 MtrrPrecedence (\r
-  UINT64    MtrrType1,\r
-  UINT64    MtrrType2\r
+  IN UINT64    MtrrType1,\r
+  IN UINT64    MtrrType2\r
   )\r
 {\r
   UINT64 MtrrType;\r
@@ -921,11 +968,11 @@ MtrrPrecedence (
 /**\r
   This function attempts to set the attributes for a memory range.\r
 \r
-  @param  BaseAddress            The physical address that is the start\r
-                                 address of a memory region.\r
-  @param  Length                 The size in bytes of the memory region.\r
-  @param  Attributes             The bit mask of attributes to set for the\r
-                                 memory region.\r
+  @param[in]       BaseAddress       The physical address that is the start\r
+                                     address of a memory region.\r
+  @param[in]       Length            The size in bytes of the memory region.\r
+  @param[in]       Attribute         The bit mask of attributes to set for the\r
+                                     memory region.\r
 \r
   @retval RETURN_SUCCESS            The attributes were set for the memory\r
                                     region.\r
@@ -1196,9 +1243,9 @@ Done:
 \r
   This function is mainly for debug purpose.\r
 \r
-  @param  Address   The specific address\r
+  @param[in]  Address            The specific address\r
 \r
-  @return Memory cache type of the sepcific address\r
+  @return Memory cache type of the specific address\r
 \r
 **/\r
 MTRR_MEMORY_CACHE_TYPE\r
@@ -1286,26 +1333,21 @@ MtrrGetMemoryAttribute (
 \r
 \r
 /**\r
-  This function will get the raw value in variable MTRRs\r
+  Worker function will get the raw value in variable MTRRs\r
 \r
-  @param  VariableSettings   A buffer to hold variable MTRRs content.\r
+  @param[out] VariableSettings   A buffer to hold variable MTRRs content.\r
 \r
   @return The VariableSettings input pointer\r
 \r
 **/\r
 MTRR_VARIABLE_SETTINGS*\r
-EFIAPI\r
-MtrrGetVariableMtrr (\r
-  OUT MTRR_VARIABLE_SETTINGS         *VariableSettings\r
+MtrrGetVariableMtrrWorker (\r
+  OUT MTRR_VARIABLE_SETTINGS  *VariableSettings\r
   )\r
 {\r
   UINT32  Index;\r
   UINT32  VariableMtrrCount;\r
 \r
-  if (!IsMtrrSupported ()) {\r
-    return VariableSettings;\r
-  }\r
-\r
   VariableMtrrCount = GetVariableMtrrCount ();\r
   ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);\r
 \r
@@ -1319,11 +1361,34 @@ MtrrGetVariableMtrr (
   return  VariableSettings;\r
 }\r
 \r
+/**\r
+  This function will get the raw value in variable MTRRs\r
+\r
+  @param[out]  VariableSettings   A buffer to hold variable MTRRs content.\r
+\r
+  @return The VariableSettings input pointer\r
+\r
+**/\r
+MTRR_VARIABLE_SETTINGS*\r
+EFIAPI\r
+MtrrGetVariableMtrr (\r
+  OUT MTRR_VARIABLE_SETTINGS         *VariableSettings\r
+  )\r
+{\r
+  if (!IsMtrrSupported ()) {\r
+    return VariableSettings;\r
+  }\r
+\r
+  return MtrrGetVariableMtrrWorker (\r
+           VariableSettings\r
+           );\r
+}\r
+\r
 \r
 /**\r
   Worker function setting variable MTRRs\r
 \r
-  @param  VariableSettings   A buffer to hold variable MTRRs content.\r
+  @param[in]  VariableSettings   A buffer to hold variable MTRRs content.\r
 \r
 **/\r
 VOID\r
@@ -1353,7 +1418,7 @@ MtrrSetVariableMtrrWorker (
 /**\r
   This function sets variable MTRRs\r
 \r
-  @param  VariableSettings   A buffer to hold variable MTRRs content.\r
+  @param[in]  VariableSettings   A buffer to hold variable MTRRs content.\r
 \r
   @return The pointer of VariableSettings\r
 \r
@@ -1376,11 +1441,34 @@ MtrrSetVariableMtrr (
   return  VariableSettings;\r
 }\r
 \r
+/**\r
+  Worker function gets the content in fixed MTRRs\r
+\r
+  @param[out]  FixedSettings  A buffer to hold fixed MTRRs content.\r
+\r
+  @retval The pointer of FixedSettings\r
+\r
+**/\r
+MTRR_FIXED_SETTINGS*\r
+MtrrGetFixedMtrrWorker (\r
+  OUT MTRR_FIXED_SETTINGS         *FixedSettings\r
+  )\r
+{\r
+  UINT32  Index;\r
+\r
+  for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) {\r
+      FixedSettings->Mtrr[Index] =\r
+        AsmReadMsr64 (mMtrrLibFixedMtrrTable[Index].Msr);\r
+  }\r
+\r
+  return FixedSettings;\r
+}\r
+\r
 \r
 /**\r
   This function gets the content in fixed MTRRs\r
 \r
-  @param  FixedSettings  A buffer to hold fixed Mtrrs content.\r
+  @param[out]  FixedSettings  A buffer to hold fixed MTRRs content.\r
 \r
   @retval The pointer of FixedSettings\r
 \r
@@ -1391,24 +1479,17 @@ MtrrGetFixedMtrr (
   OUT MTRR_FIXED_SETTINGS         *FixedSettings\r
   )\r
 {\r
-  UINT32  Index;\r
-\r
   if (!IsMtrrSupported ()) {\r
     return FixedSettings;\r
   }\r
 \r
-  for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) {\r
-      FixedSettings->Mtrr[Index] =\r
-        AsmReadMsr64 (mMtrrLibFixedMtrrTable[Index].Msr);\r
-  };\r
-\r
-  return FixedSettings;\r
+  return MtrrGetFixedMtrrWorker (FixedSettings);\r
 }\r
 \r
 /**\r
   Worker function setting fixed MTRRs\r
 \r
-  @param  FixedSettings  A buffer to hold fixed Mtrrs content.\r
+  @param[in]  FixedSettings  A buffer to hold fixed Mtrrs content.\r
 \r
 **/\r
 VOID\r
@@ -1430,7 +1511,7 @@ MtrrSetFixedMtrrWorker (
 /**\r
   This function sets fixed MTRRs\r
 \r
-  @param  FixedSettings  A buffer to hold fixed Mtrrs content.\r
+  @param[in]  FixedSettings  A buffer to hold fixed Mtrrs content.\r
 \r
   @retval The pointer of FixedSettings\r
 \r
@@ -1458,7 +1539,7 @@ MtrrSetFixedMtrr (
 /**\r
   This function gets the content in all MTRRs (variable and fixed)\r
 \r
-  @param  MtrrSetting  A buffer to hold all Mtrrs content.\r
+  @param[out]  MtrrSetting  A buffer to hold all Mtrrs content.\r
 \r
   @retval the pointer of MtrrSetting\r
 \r
@@ -1495,7 +1576,7 @@ MtrrGetAllMtrrs (
 /**\r
   This function sets all MTRRs (variable and fixed)\r
 \r
-  @param  MtrrSetting  A buffer holding all MTRRs content.\r
+  @param[in]  MtrrSetting  A buffer holding all MTRRs content.\r
 \r
   @retval The pointer of MtrrSetting\r
 \r
@@ -1567,7 +1648,7 @@ MtrrDebugPrintAllMtrrs (
 \r
     DEBUG((DEBUG_CACHE, "MTRR Settings\n"));\r
     DEBUG((DEBUG_CACHE, "=============\n"));\r
-    \r
+\r
     MtrrGetAllMtrrs (&MtrrSettings);\r
     DEBUG((DEBUG_CACHE, "MTRR Default Type: %016lx\n", MtrrSettings.MtrrDefType));\r
     for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) {\r
@@ -1594,7 +1675,7 @@ MtrrDebugPrintAllMtrrs (
       MemoryType = (UINTN)(RShiftU64 (MtrrSettings.Fixed.Mtrr[Index], Index1 * 8) & 0xff);\r
         if (MemoryType > CacheWriteBack) {\r
           MemoryType = MTRR_CACHE_INVALID_TYPE;\r
-        }            \r
+        }\r
         if (MemoryType != PreviousMemoryType) {\r
           if (PreviousMemoryType != MTRR_CACHE_INVALID_TYPE) {\r
             DEBUG((DEBUG_CACHE, "%016lx\n", Base - 1));\r
@@ -1630,12 +1711,12 @@ MtrrDebugPrintAllMtrrs (
         PreviousMemoryType = MemoryType;\r
         DEBUG((DEBUG_CACHE, "%a:%016lx-", mMtrrMemoryCacheTypeShortName[MemoryType], Base));\r
       }\r
-      \r
-      RangeBase    = BASE_1MB;        \r
+\r
+      RangeBase    = BASE_1MB;\r
       NoRangeBase  = BASE_1MB;\r
       RangeLimit   = Limit;\r
       NoRangeLimit = Limit;\r
-      \r
+\r
       for (Index = 0, Found = FALSE; Index < VariableMtrrCount; Index++) {\r
         if ((MtrrSettings.Variables.Mtrr[Index].Mask & BIT11) == 0) {\r
           //\r
@@ -1649,7 +1730,7 @@ MtrrDebugPrintAllMtrrs (
         if (Base >= MtrrBase && Base < MtrrLimit) {\r
           Found = TRUE;\r
         }\r
-        \r
+\r
         if (Base >= MtrrBase && MtrrBase > RangeBase) {\r
           RangeBase = MtrrBase;\r
         }\r
@@ -1662,7 +1743,7 @@ MtrrDebugPrintAllMtrrs (
         if (Base < MtrrLimit && MtrrLimit <= RangeLimit) {\r
           RangeLimit = MtrrLimit;\r
         }\r
-        \r
+\r
         if (Base > MtrrLimit && NoRangeBase < MtrrLimit) {\r
           NoRangeBase = MtrrLimit + 1;\r
         }\r
@@ -1670,7 +1751,7 @@ MtrrDebugPrintAllMtrrs (
           NoRangeLimit = MtrrBase - 1;\r
         }\r
       }\r
-      \r
+\r
       if (Found) {\r
         Base = RangeLimit + 1;\r
       } else {\r