[edk2] [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.

Eric Dong posted 7 patches 7 years, 4 months ago
[edk2] [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.
Posted by Eric Dong 7 years, 4 months ago
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
 .../QuarkNorthCluster/Library/MtrrLib/MtrrLib.c    | 26 +++++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
index 2760427..fe00b37 100644
--- a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
+++ b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
@@ -23,6 +23,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 #define QUARK_SOC_CPUID_FAMILY_MODEL_STEPPING         0x590
 
+#define CACHE_MTRR_ENABLED                            0x800
+#define CACHE_FIXED_MTRR_ENABLED                      0x400
+#define IA32_MTRR_CAP_VCNT_MASK                       0xFF
+
 //
 // Context to save and restore when MTRRs are programmed
 //
@@ -121,7 +125,7 @@ GetVariableMtrrCountWorker (
 {
   UINT32  VariableMtrrCount;
 
-  VariableMtrrCount = (UINT32)(MtrrRegisterRead (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) & MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);
+  VariableMtrrCount = (UINT32)(MtrrRegisterRead (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) & IA32_MTRR_CAP_VCNT_MASK);
   ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
   return VariableMtrrCount;
 }
@@ -558,7 +562,7 @@ MtrrGetMemoryAttributeInVariableMtrrWorker (
 
   ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) * MTRR_NUMBER_OF_VARIABLE_MTRR);
   for (Index = 0, UsedMtrr = 0; Index < FirmwareVariableMtrrCount; Index++) {
-    if ((VariableSettings->Mtrr[Index].Mask & MTRR_LIB_CACHE_MTRR_ENABLED) != 0) {
+    if ((VariableSettings->Mtrr[Index].Mask & CACHE_MTRR_ENABLED) != 0) {
       VariableMtrr[Index].Msr         = (UINT32)Index;
       VariableMtrr[Index].BaseAddress = (VariableSettings->Mtrr[Index].Base & MtrrValidAddressMask);
       VariableMtrr[Index].Length      = ((~(VariableSettings->Mtrr[Index].Mask & MtrrValidAddressMask)) & MtrrValidBitsMask) + 1;
@@ -969,7 +973,7 @@ ProgramVariableMtrr (
   // MTRR Physical Mask
   //
   TempQword = ~(Length - 1);
-  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword & MtrrValidAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword & MtrrValidAddressMask) | CACHE_MTRR_ENABLED;
 }
 
 
@@ -1157,7 +1161,7 @@ MtrrGetMemoryAttributeByAddressWorker (
   }
   MtrrType = MTRR_CACHE_INVALID_TYPE;
 
-  if ((TempQword & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
+  if ((TempQword & CACHE_MTRR_ENABLED) == 0) {
     return CacheUncacheable;
   }
 
@@ -1165,7 +1169,7 @@ MtrrGetMemoryAttributeByAddressWorker (
   // If address is less than 1M, then try to go through the fixed MTRR
   //
   if (Address < BASE_1MB) {
-    if ((TempQword & MTRR_LIB_CACHE_FIXED_MTRR_ENABLED) != 0) {
+    if ((TempQword & CACHE_FIXED_MTRR_ENABLED) != 0) {
       //
       // Go through the fixed MTRR
       //
@@ -1539,7 +1543,7 @@ MtrrSetMemoryAttributeWorker (
       }
       if (MtrrSetting != NULL) {
         MtrrSetting->Fixed.Mtrr[MsrNum] = (MtrrSetting->Fixed.Mtrr[MsrNum] & ~ClearMask) | OrMask;
-        MtrrSetting->MtrrDefType |= MTRR_LIB_CACHE_FIXED_MTRR_ENABLED;
+        MtrrSetting->MtrrDefType |= CACHE_FIXED_MTRR_ENABLED;
       } else {
         if (!FixedSettingsValid[MsrNum]) {
           WorkingFixedSettings.Mtrr[MsrNum] = MtrrRegisterRead (mMtrrLibFixedMtrrTable[MsrNum].Msr);
@@ -1654,7 +1658,7 @@ MtrrSetMemoryAttributeWorker (
   // Find first unused MTRR
   //
   for (MsrNum = 0; MsrNum < VariableMtrrCount; MsrNum++) {
-    if ((VariableSettings->Mtrr[MsrNum].Mask & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
+    if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED) == 0) {
       break;
     }
   }
@@ -1674,7 +1678,7 @@ MtrrSetMemoryAttributeWorker (
       // Find unused MTRR
       //
       for (; MsrNum < VariableMtrrCount; MsrNum++) {
-        if ((VariableSettings->Mtrr[MsrNum].Mask & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
+        if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED) == 0) {
           break;
         }
       }
@@ -1705,7 +1709,7 @@ MtrrSetMemoryAttributeWorker (
     // Find unused MTRR
     //
     for (; MsrNum < VariableMtrrCount; MsrNum++) {
-      if ((VariableSettings->Mtrr[MsrNum].Mask & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
+      if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED) == 0) {
         break;
       }
     }
@@ -1728,7 +1732,7 @@ MtrrSetMemoryAttributeWorker (
     // Find unused MTRR
     //
     for (; MsrNum < VariableMtrrCount; MsrNum++) {
-      if ((VariableSettings->Mtrr[MsrNum].Mask & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
+      if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED) == 0) {
         break;
       }
     }
@@ -1801,7 +1805,7 @@ Done:
   DEBUG((DEBUG_CACHE, "  Status = %r\n", Status));
   if (!RETURN_ERROR (Status)) {
     if (MtrrSetting != NULL) {
-      MtrrSetting->MtrrDefType |= MTRR_LIB_CACHE_MTRR_ENABLED;
+      MtrrSetting->MtrrDefType |= CACHE_MTRR_ENABLED;
     }
     MtrrDebugPrintAllMtrrsWorker (MtrrSetting);
   }
-- 
2.7.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.
Posted by Ni, Ruiyu 7 years, 4 months ago
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Thanks/Ray

> -----Original Message-----
> From: Dong, Eric
> Sent: Thursday, August 3, 2017 5:32 PM
> To: edk2-devel@lists.01.org
> Cc: Fan, Jeff <jeff.fan@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Kinney,
> Michael D <michael.d.kinney@intel.com>
> Subject: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated
> macro.
> 
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>  .../QuarkNorthCluster/Library/MtrrLib/MtrrLib.c    | 26 +++++++++++++------
> ---
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> index 2760427..fe00b37 100644
> --- a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> +++ b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> @@ -23,6 +23,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
> 
>  #define QUARK_SOC_CPUID_FAMILY_MODEL_STEPPING         0x590
> 
> +#define CACHE_MTRR_ENABLED                            0x800
> +#define CACHE_FIXED_MTRR_ENABLED                      0x400
> +#define IA32_MTRR_CAP_VCNT_MASK                       0xFF
> +
>  //
>  // Context to save and restore when MTRRs are programmed  // @@ -121,7
> +125,7 @@ GetVariableMtrrCountWorker (  {
>    UINT32  VariableMtrrCount;
> 
> -  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) &
> MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);
> +  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> + (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) &
> IA32_MTRR_CAP_VCNT_MASK);
>    ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
>    return VariableMtrrCount;
>  }
> @@ -558,7 +562,7 @@ MtrrGetMemoryAttributeInVariableMtrrWorker (
> 
>    ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) *
> MTRR_NUMBER_OF_VARIABLE_MTRR);
>    for (Index = 0, UsedMtrr = 0; Index < FirmwareVariableMtrrCount; Index++)
> {
> -    if ((VariableSettings->Mtrr[Index].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) != 0) {
> +    if ((VariableSettings->Mtrr[Index].Mask & CACHE_MTRR_ENABLED) != 0)
> + {
>        VariableMtrr[Index].Msr         = (UINT32)Index;
>        VariableMtrr[Index].BaseAddress = (VariableSettings->Mtrr[Index].Base
> & MtrrValidAddressMask);
>        VariableMtrr[Index].Length      = ((~(VariableSettings->Mtrr[Index].Mask
> & MtrrValidAddressMask)) & MtrrValidBitsMask) + 1;
> @@ -969,7 +973,7 @@ ProgramVariableMtrr (
>    // MTRR Physical Mask
>    //
>    TempQword = ~(Length - 1);
> -  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> MtrrValidAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
> +  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> + MtrrValidAddressMask) | CACHE_MTRR_ENABLED;
>  }
> 
> 
> @@ -1157,7 +1161,7 @@ MtrrGetMemoryAttributeByAddressWorker (
>    }
>    MtrrType = MTRR_CACHE_INVALID_TYPE;
> 
> -  if ((TempQword & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +  if ((TempQword & CACHE_MTRR_ENABLED) == 0) {
>      return CacheUncacheable;
>    }
> 
> @@ -1165,7 +1169,7 @@ MtrrGetMemoryAttributeByAddressWorker (
>    // If address is less than 1M, then try to go through the fixed MTRR
>    //
>    if (Address < BASE_1MB) {
> -    if ((TempQword & MTRR_LIB_CACHE_FIXED_MTRR_ENABLED) != 0) {
> +    if ((TempQword & CACHE_FIXED_MTRR_ENABLED) != 0) {
>        //
>        // Go through the fixed MTRR
>        //
> @@ -1539,7 +1543,7 @@ MtrrSetMemoryAttributeWorker (
>        }
>        if (MtrrSetting != NULL) {
>          MtrrSetting->Fixed.Mtrr[MsrNum] = (MtrrSetting->Fixed.Mtrr[MsrNum]
> & ~ClearMask) | OrMask;
> -        MtrrSetting->MtrrDefType |=
> MTRR_LIB_CACHE_FIXED_MTRR_ENABLED;
> +        MtrrSetting->MtrrDefType |= CACHE_FIXED_MTRR_ENABLED;
>        } else {
>          if (!FixedSettingsValid[MsrNum]) {
>            WorkingFixedSettings.Mtrr[MsrNum] = MtrrRegisterRead
> (mMtrrLibFixedMtrrTable[MsrNum].Msr);
> @@ -1654,7 +1658,7 @@ MtrrSetMemoryAttributeWorker (
>    // Find first unused MTRR
>    //
>    for (MsrNum = 0; MsrNum < VariableMtrrCount; MsrNum++) {
> -    if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +    if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> ==
> + 0) {
>        break;
>      }
>    }
> @@ -1674,7 +1678,7 @@ MtrrSetMemoryAttributeWorker (
>        // Find unused MTRR
>        //
>        for (; MsrNum < VariableMtrrCount; MsrNum++) {
> -        if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +        if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> + == 0) {
>            break;
>          }
>        }
> @@ -1705,7 +1709,7 @@ MtrrSetMemoryAttributeWorker (
>      // Find unused MTRR
>      //
>      for (; MsrNum < VariableMtrrCount; MsrNum++) {
> -      if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +      if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> ==
> + 0) {
>          break;
>        }
>      }
> @@ -1728,7 +1732,7 @@ MtrrSetMemoryAttributeWorker (
>      // Find unused MTRR
>      //
>      for (; MsrNum < VariableMtrrCount; MsrNum++) {
> -      if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +      if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> ==
> + 0) {
>          break;
>        }
>      }
> @@ -1801,7 +1805,7 @@ Done:
>    DEBUG((DEBUG_CACHE, "  Status = %r\n", Status));
>    if (!RETURN_ERROR (Status)) {
>      if (MtrrSetting != NULL) {
> -      MtrrSetting->MtrrDefType |= MTRR_LIB_CACHE_MTRR_ENABLED;
> +      MtrrSetting->MtrrDefType |= CACHE_MTRR_ENABLED;
>      }
>      MtrrDebugPrintAllMtrrsWorker (MtrrSetting);
>    }
> --
> 2.7.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.
Posted by Ni, Ruiyu 7 years, 4 months ago
Eric,
Please refer to the below code sample to avoid defining local macros.

 MSR_IA32_MTRR_DEF_TYPE_REGISTER  DefType;
  //
  // Enable Cache MTRR
  //
  DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE);
  DefType.Bits.E = 1;
  DefType.Bits.FE = 1;
  AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64);

Thanks/Ray

> -----Original Message-----
> From: Dong, Eric
> Sent: Thursday, August 3, 2017 5:32 PM
> To: edk2-devel@lists.01.org
> Cc: Fan, Jeff <jeff.fan@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Kinney,
> Michael D <michael.d.kinney@intel.com>
> Subject: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated
> macro.
> 
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>  .../QuarkNorthCluster/Library/MtrrLib/MtrrLib.c    | 26 +++++++++++++------
> ---
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> index 2760427..fe00b37 100644
> --- a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> +++ b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> @@ -23,6 +23,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
> 
>  #define QUARK_SOC_CPUID_FAMILY_MODEL_STEPPING         0x590
> 
> +#define CACHE_MTRR_ENABLED                            0x800
> +#define CACHE_FIXED_MTRR_ENABLED                      0x400
> +#define IA32_MTRR_CAP_VCNT_MASK                       0xFF
> +
>  //
>  // Context to save and restore when MTRRs are programmed  // @@ -121,7
> +125,7 @@ GetVariableMtrrCountWorker (  {
>    UINT32  VariableMtrrCount;
> 
> -  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) &
> MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);
> +  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> + (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) &
> IA32_MTRR_CAP_VCNT_MASK);
>    ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
>    return VariableMtrrCount;
>  }
> @@ -558,7 +562,7 @@ MtrrGetMemoryAttributeInVariableMtrrWorker (
> 
>    ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) *
> MTRR_NUMBER_OF_VARIABLE_MTRR);
>    for (Index = 0, UsedMtrr = 0; Index < FirmwareVariableMtrrCount; Index++)
> {
> -    if ((VariableSettings->Mtrr[Index].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) != 0) {
> +    if ((VariableSettings->Mtrr[Index].Mask & CACHE_MTRR_ENABLED) != 0)
> + {
>        VariableMtrr[Index].Msr         = (UINT32)Index;
>        VariableMtrr[Index].BaseAddress = (VariableSettings->Mtrr[Index].Base
> & MtrrValidAddressMask);
>        VariableMtrr[Index].Length      = ((~(VariableSettings->Mtrr[Index].Mask
> & MtrrValidAddressMask)) & MtrrValidBitsMask) + 1;
> @@ -969,7 +973,7 @@ ProgramVariableMtrr (
>    // MTRR Physical Mask
>    //
>    TempQword = ~(Length - 1);
> -  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> MtrrValidAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
> +  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> + MtrrValidAddressMask) | CACHE_MTRR_ENABLED;
>  }
> 
> 
> @@ -1157,7 +1161,7 @@ MtrrGetMemoryAttributeByAddressWorker (
>    }
>    MtrrType = MTRR_CACHE_INVALID_TYPE;
> 
> -  if ((TempQword & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +  if ((TempQword & CACHE_MTRR_ENABLED) == 0) {
>      return CacheUncacheable;
>    }
> 
> @@ -1165,7 +1169,7 @@ MtrrGetMemoryAttributeByAddressWorker (
>    // If address is less than 1M, then try to go through the fixed MTRR
>    //
>    if (Address < BASE_1MB) {
> -    if ((TempQword & MTRR_LIB_CACHE_FIXED_MTRR_ENABLED) != 0) {
> +    if ((TempQword & CACHE_FIXED_MTRR_ENABLED) != 0) {
>        //
>        // Go through the fixed MTRR
>        //
> @@ -1539,7 +1543,7 @@ MtrrSetMemoryAttributeWorker (
>        }
>        if (MtrrSetting != NULL) {
>          MtrrSetting->Fixed.Mtrr[MsrNum] = (MtrrSetting->Fixed.Mtrr[MsrNum]
> & ~ClearMask) | OrMask;
> -        MtrrSetting->MtrrDefType |=
> MTRR_LIB_CACHE_FIXED_MTRR_ENABLED;
> +        MtrrSetting->MtrrDefType |= CACHE_FIXED_MTRR_ENABLED;
>        } else {
>          if (!FixedSettingsValid[MsrNum]) {
>            WorkingFixedSettings.Mtrr[MsrNum] = MtrrRegisterRead
> (mMtrrLibFixedMtrrTable[MsrNum].Msr);
> @@ -1654,7 +1658,7 @@ MtrrSetMemoryAttributeWorker (
>    // Find first unused MTRR
>    //
>    for (MsrNum = 0; MsrNum < VariableMtrrCount; MsrNum++) {
> -    if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +    if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> ==
> + 0) {
>        break;
>      }
>    }
> @@ -1674,7 +1678,7 @@ MtrrSetMemoryAttributeWorker (
>        // Find unused MTRR
>        //
>        for (; MsrNum < VariableMtrrCount; MsrNum++) {
> -        if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +        if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> + == 0) {
>            break;
>          }
>        }
> @@ -1705,7 +1709,7 @@ MtrrSetMemoryAttributeWorker (
>      // Find unused MTRR
>      //
>      for (; MsrNum < VariableMtrrCount; MsrNum++) {
> -      if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +      if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> ==
> + 0) {
>          break;
>        }
>      }
> @@ -1728,7 +1732,7 @@ MtrrSetMemoryAttributeWorker (
>      // Find unused MTRR
>      //
>      for (; MsrNum < VariableMtrrCount; MsrNum++) {
> -      if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +      if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> ==
> + 0) {
>          break;
>        }
>      }
> @@ -1801,7 +1805,7 @@ Done:
>    DEBUG((DEBUG_CACHE, "  Status = %r\n", Status));
>    if (!RETURN_ERROR (Status)) {
>      if (MtrrSetting != NULL) {
> -      MtrrSetting->MtrrDefType |= MTRR_LIB_CACHE_MTRR_ENABLED;
> +      MtrrSetting->MtrrDefType |= CACHE_MTRR_ENABLED;
>      }
>      MtrrDebugPrintAllMtrrsWorker (MtrrSetting);
>    }
> --
> 2.7.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.
Posted by Dong, Eric 7 years, 4 months ago
Ray,

I check the spec, found the Quark definition has some small difference with normal MSR. So I prefer not do this change for Quark.

Thanks,
Eric
-----Original Message-----
From: Ni, Ruiyu 
Sent: Thursday, August 3, 2017 6:22 PM
To: Dong, Eric <eric.dong@intel.com>; edk2-devel@lists.01.org
Cc: Fan, Jeff <jeff.fan@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.

Eric,
Please refer to the below code sample to avoid defining local macros.

 MSR_IA32_MTRR_DEF_TYPE_REGISTER  DefType;
  //
  // Enable Cache MTRR
  //
  DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE);
  DefType.Bits.E = 1;
  DefType.Bits.FE = 1;
  AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64);

Thanks/Ray

> -----Original Message-----
> From: Dong, Eric
> Sent: Thursday, August 3, 2017 5:32 PM
> To: edk2-devel@lists.01.org
> Cc: Fan, Jeff <jeff.fan@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; 
> Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated 
> macro.
> 
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>  .../QuarkNorthCluster/Library/MtrrLib/MtrrLib.c    | 26 +++++++++++++------
> ---
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> index 2760427..fe00b37 100644
> --- a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> +++ b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> @@ -23,6 +23,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, 
> EITHER EXPRESS OR IMPLIED.
> 
>  #define QUARK_SOC_CPUID_FAMILY_MODEL_STEPPING         0x590
> 
> +#define CACHE_MTRR_ENABLED                            0x800
> +#define CACHE_FIXED_MTRR_ENABLED                      0x400
> +#define IA32_MTRR_CAP_VCNT_MASK                       0xFF
> +
>  //
>  // Context to save and restore when MTRRs are programmed  // @@ 
> -121,7
> +125,7 @@ GetVariableMtrrCountWorker (  {
>    UINT32  VariableMtrrCount;
> 
> -  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) & 
> MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);
> +  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> + (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) &
> IA32_MTRR_CAP_VCNT_MASK);
>    ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
>    return VariableMtrrCount;
>  }
> @@ -558,7 +562,7 @@ MtrrGetMemoryAttributeInVariableMtrrWorker (
> 
>    ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) * 
> MTRR_NUMBER_OF_VARIABLE_MTRR);
>    for (Index = 0, UsedMtrr = 0; Index < FirmwareVariableMtrrCount; 
> Index++) {
> -    if ((VariableSettings->Mtrr[Index].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) != 0) {
> +    if ((VariableSettings->Mtrr[Index].Mask & CACHE_MTRR_ENABLED) != 
> + 0) {
>        VariableMtrr[Index].Msr         = (UINT32)Index;
>        VariableMtrr[Index].BaseAddress = 
> (VariableSettings->Mtrr[Index].Base
> & MtrrValidAddressMask);
>        VariableMtrr[Index].Length      = ((~(VariableSettings->Mtrr[Index].Mask
> & MtrrValidAddressMask)) & MtrrValidBitsMask) + 1; @@ -969,7 +973,7 @@ 
> ProgramVariableMtrr (
>    // MTRR Physical Mask
>    //
>    TempQword = ~(Length - 1);
> -  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> MtrrValidAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
> +  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> + MtrrValidAddressMask) | CACHE_MTRR_ENABLED;
>  }
> 
> 
> @@ -1157,7 +1161,7 @@ MtrrGetMemoryAttributeByAddressWorker (
>    }
>    MtrrType = MTRR_CACHE_INVALID_TYPE;
> 
> -  if ((TempQword & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +  if ((TempQword & CACHE_MTRR_ENABLED) == 0) {
>      return CacheUncacheable;
>    }
> 
> @@ -1165,7 +1169,7 @@ MtrrGetMemoryAttributeByAddressWorker (
>    // If address is less than 1M, then try to go through the fixed MTRR
>    //
>    if (Address < BASE_1MB) {
> -    if ((TempQword & MTRR_LIB_CACHE_FIXED_MTRR_ENABLED) != 0) {
> +    if ((TempQword & CACHE_FIXED_MTRR_ENABLED) != 0) {
>        //
>        // Go through the fixed MTRR
>        //
> @@ -1539,7 +1543,7 @@ MtrrSetMemoryAttributeWorker (
>        }
>        if (MtrrSetting != NULL) {
>          MtrrSetting->Fixed.Mtrr[MsrNum] = 
> (MtrrSetting->Fixed.Mtrr[MsrNum] & ~ClearMask) | OrMask;
> -        MtrrSetting->MtrrDefType |=
> MTRR_LIB_CACHE_FIXED_MTRR_ENABLED;
> +        MtrrSetting->MtrrDefType |= CACHE_FIXED_MTRR_ENABLED;
>        } else {
>          if (!FixedSettingsValid[MsrNum]) {
>            WorkingFixedSettings.Mtrr[MsrNum] = MtrrRegisterRead 
> (mMtrrLibFixedMtrrTable[MsrNum].Msr);
> @@ -1654,7 +1658,7 @@ MtrrSetMemoryAttributeWorker (
>    // Find first unused MTRR
>    //
>    for (MsrNum = 0; MsrNum < VariableMtrrCount; MsrNum++) {
> -    if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +    if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> ==
> + 0) {
>        break;
>      }
>    }
> @@ -1674,7 +1678,7 @@ MtrrSetMemoryAttributeWorker (
>        // Find unused MTRR
>        //
>        for (; MsrNum < VariableMtrrCount; MsrNum++) {
> -        if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +        if ((VariableSettings->Mtrr[MsrNum].Mask & 
> + CACHE_MTRR_ENABLED) == 0) {
>            break;
>          }
>        }
> @@ -1705,7 +1709,7 @@ MtrrSetMemoryAttributeWorker (
>      // Find unused MTRR
>      //
>      for (; MsrNum < VariableMtrrCount; MsrNum++) {
> -      if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +      if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> ==
> + 0) {
>          break;
>        }
>      }
> @@ -1728,7 +1732,7 @@ MtrrSetMemoryAttributeWorker (
>      // Find unused MTRR
>      //
>      for (; MsrNum < VariableMtrrCount; MsrNum++) {
> -      if ((VariableSettings->Mtrr[MsrNum].Mask &
> MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> +      if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> ==
> + 0) {
>          break;
>        }
>      }
> @@ -1801,7 +1805,7 @@ Done:
>    DEBUG((DEBUG_CACHE, "  Status = %r\n", Status));
>    if (!RETURN_ERROR (Status)) {
>      if (MtrrSetting != NULL) {
> -      MtrrSetting->MtrrDefType |= MTRR_LIB_CACHE_MTRR_ENABLED;
> +      MtrrSetting->MtrrDefType |= CACHE_MTRR_ENABLED;
>      }
>      MtrrDebugPrintAllMtrrsWorker (MtrrSetting);
>    }
> --
> 2.7.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.
Posted by Ni, Ruiyu 7 years, 4 months ago
I agree.

Thanks/Ray

> -----Original Message-----
> From: Dong, Eric
> Sent: Friday, August 4, 2017 12:53 PM
> To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org
> Cc: Fan, Jeff <jeff.fan@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: RE: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated
> macro.
> 
> Ray,
> 
> I check the spec, found the Quark definition has some small difference with
> normal MSR. So I prefer not do this change for Quark.
> 
> Thanks,
> Eric
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Thursday, August 3, 2017 6:22 PM
> To: Dong, Eric <eric.dong@intel.com>; edk2-devel@lists.01.org
> Cc: Fan, Jeff <jeff.fan@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: RE: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated
> macro.
> 
> Eric,
> Please refer to the below code sample to avoid defining local macros.
> 
>  MSR_IA32_MTRR_DEF_TYPE_REGISTER  DefType;
>   //
>   // Enable Cache MTRR
>   //
>   DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE);
>   DefType.Bits.E = 1;
>   DefType.Bits.FE = 1;
>   AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64);
> 
> Thanks/Ray
> 
> > -----Original Message-----
> > From: Dong, Eric
> > Sent: Thursday, August 3, 2017 5:32 PM
> > To: edk2-devel@lists.01.org
> > Cc: Fan, Jeff <jeff.fan@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>;
> > Kinney, Michael D <michael.d.kinney@intel.com>
> > Subject: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated
> > macro.
> >
> > Cc: Jeff Fan <jeff.fan@intel.com>
> > Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Eric Dong <eric.dong@intel.com>
> > ---
> >  .../QuarkNorthCluster/Library/MtrrLib/MtrrLib.c    | 26 +++++++++++++----
> --
> > ---
> >  1 file changed, 15 insertions(+), 11 deletions(-)
> >
> > diff --git a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> > b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> > index 2760427..fe00b37 100644
> > --- a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> > +++ b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> > @@ -23,6 +23,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF
> ANY KIND,
> > EITHER EXPRESS OR IMPLIED.
> >
> >  #define QUARK_SOC_CPUID_FAMILY_MODEL_STEPPING         0x590
> >
> > +#define CACHE_MTRR_ENABLED                            0x800
> > +#define CACHE_FIXED_MTRR_ENABLED                      0x400
> > +#define IA32_MTRR_CAP_VCNT_MASK                       0xFF
> > +
> >  //
> >  // Context to save and restore when MTRRs are programmed  // @@
> > -121,7
> > +125,7 @@ GetVariableMtrrCountWorker (  {
> >    UINT32  VariableMtrrCount;
> >
> > -  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> > (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) &
> > MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);
> > +  VariableMtrrCount = (UINT32)(MtrrRegisterRead
> > + (QUARK_NC_HOST_BRIDGE_IA32_MTRR_CAP) &
> > IA32_MTRR_CAP_VCNT_MASK);
> >    ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
> >    return VariableMtrrCount;
> >  }
> > @@ -558,7 +562,7 @@ MtrrGetMemoryAttributeInVariableMtrrWorker (
> >
> >    ZeroMem (VariableMtrr, sizeof (VARIABLE_MTRR) *
> > MTRR_NUMBER_OF_VARIABLE_MTRR);
> >    for (Index = 0, UsedMtrr = 0; Index < FirmwareVariableMtrrCount;
> > Index++) {
> > -    if ((VariableSettings->Mtrr[Index].Mask &
> > MTRR_LIB_CACHE_MTRR_ENABLED) != 0) {
> > +    if ((VariableSettings->Mtrr[Index].Mask & CACHE_MTRR_ENABLED) !=
> > + 0) {
> >        VariableMtrr[Index].Msr         = (UINT32)Index;
> >        VariableMtrr[Index].BaseAddress =
> > (VariableSettings->Mtrr[Index].Base
> > & MtrrValidAddressMask);
> >        VariableMtrr[Index].Length      = ((~(VariableSettings-
> >Mtrr[Index].Mask
> > & MtrrValidAddressMask)) & MtrrValidBitsMask) + 1; @@ -969,7 +973,7
> @@
> > ProgramVariableMtrr (
> >    // MTRR Physical Mask
> >    //
> >    TempQword = ~(Length - 1);
> > -  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> > MtrrValidAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
> > +  VariableSettings->Mtrr[MtrrNumber].Mask = (TempQword &
> > + MtrrValidAddressMask) | CACHE_MTRR_ENABLED;
> >  }
> >
> >
> > @@ -1157,7 +1161,7 @@ MtrrGetMemoryAttributeByAddressWorker (
> >    }
> >    MtrrType = MTRR_CACHE_INVALID_TYPE;
> >
> > -  if ((TempQword & MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> > +  if ((TempQword & CACHE_MTRR_ENABLED) == 0) {
> >      return CacheUncacheable;
> >    }
> >
> > @@ -1165,7 +1169,7 @@ MtrrGetMemoryAttributeByAddressWorker (
> >    // If address is less than 1M, then try to go through the fixed MTRR
> >    //
> >    if (Address < BASE_1MB) {
> > -    if ((TempQword & MTRR_LIB_CACHE_FIXED_MTRR_ENABLED) != 0) {
> > +    if ((TempQword & CACHE_FIXED_MTRR_ENABLED) != 0) {
> >        //
> >        // Go through the fixed MTRR
> >        //
> > @@ -1539,7 +1543,7 @@ MtrrSetMemoryAttributeWorker (
> >        }
> >        if (MtrrSetting != NULL) {
> >          MtrrSetting->Fixed.Mtrr[MsrNum] =
> > (MtrrSetting->Fixed.Mtrr[MsrNum] & ~ClearMask) | OrMask;
> > -        MtrrSetting->MtrrDefType |=
> > MTRR_LIB_CACHE_FIXED_MTRR_ENABLED;
> > +        MtrrSetting->MtrrDefType |= CACHE_FIXED_MTRR_ENABLED;
> >        } else {
> >          if (!FixedSettingsValid[MsrNum]) {
> >            WorkingFixedSettings.Mtrr[MsrNum] = MtrrRegisterRead
> > (mMtrrLibFixedMtrrTable[MsrNum].Msr);
> > @@ -1654,7 +1658,7 @@ MtrrSetMemoryAttributeWorker (
> >    // Find first unused MTRR
> >    //
> >    for (MsrNum = 0; MsrNum < VariableMtrrCount; MsrNum++) {
> > -    if ((VariableSettings->Mtrr[MsrNum].Mask &
> > MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> > +    if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> > ==
> > + 0) {
> >        break;
> >      }
> >    }
> > @@ -1674,7 +1678,7 @@ MtrrSetMemoryAttributeWorker (
> >        // Find unused MTRR
> >        //
> >        for (; MsrNum < VariableMtrrCount; MsrNum++) {
> > -        if ((VariableSettings->Mtrr[MsrNum].Mask &
> > MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> > +        if ((VariableSettings->Mtrr[MsrNum].Mask &
> > + CACHE_MTRR_ENABLED) == 0) {
> >            break;
> >          }
> >        }
> > @@ -1705,7 +1709,7 @@ MtrrSetMemoryAttributeWorker (
> >      // Find unused MTRR
> >      //
> >      for (; MsrNum < VariableMtrrCount; MsrNum++) {
> > -      if ((VariableSettings->Mtrr[MsrNum].Mask &
> > MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> > +      if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> > ==
> > + 0) {
> >          break;
> >        }
> >      }
> > @@ -1728,7 +1732,7 @@ MtrrSetMemoryAttributeWorker (
> >      // Find unused MTRR
> >      //
> >      for (; MsrNum < VariableMtrrCount; MsrNum++) {
> > -      if ((VariableSettings->Mtrr[MsrNum].Mask &
> > MTRR_LIB_CACHE_MTRR_ENABLED) == 0) {
> > +      if ((VariableSettings->Mtrr[MsrNum].Mask & CACHE_MTRR_ENABLED)
> > ==
> > + 0) {
> >          break;
> >        }
> >      }
> > @@ -1801,7 +1805,7 @@ Done:
> >    DEBUG((DEBUG_CACHE, "  Status = %r\n", Status));
> >    if (!RETURN_ERROR (Status)) {
> >      if (MtrrSetting != NULL) {
> > -      MtrrSetting->MtrrDefType |= MTRR_LIB_CACHE_MTRR_ENABLED;
> > +      MtrrSetting->MtrrDefType |= CACHE_MTRR_ENABLED;
> >      }
> >      MtrrDebugPrintAllMtrrsWorker (MtrrSetting);
> >    }
> > --
> > 2.7.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel