public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 0/7] Remove deprecated macro.
@ 2017-08-03  9:31 Eric Dong
  2017-08-03  9:32 ` [Patch 1/7] QuarkSocPkg MtrrLib: Enhance get mtrr mask logic Eric Dong
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Eric Dong @ 2017-08-03  9:31 UTC (permalink / raw)
  To: edk2-devel

Remove the deprecated macro and change code which use the macro.

Eric Dong (7):
  QuarkSocPkg MtrrLib: Enhance get mtrr mask logic.
  Vlv2TbltDevicePkg: Enhance get mtrr mask logic.
  UefiCpuPkg CpuDxe: Enhance get mtrr mask logic.
  QuarkSocPkg MtrrLib: Remove reference deprecated macro.
  Vlv2TbltDevicePkg: Remove reference deprecated macro.
  UefiCpuPkg CpuDxe: Remove reference deprecated macro.
  UefiCpuPkg MtrrLib: Remove deprecated micro.

 .../QuarkNorthCluster/Library/MtrrLib/MtrrLib.c    | 35 ++++++++--------
 UefiCpuPkg/CpuDxe/CpuDxe.c                         | 35 ++++++++--------
 UefiCpuPkg/CpuDxe/CpuDxe.h                         |  1 +
 UefiCpuPkg/Include/Library/MtrrLib.h               | 27 -------------
 Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c     | 47 ++++++++++++++++++----
 5 files changed, 77 insertions(+), 68 deletions(-)

-- 
2.7.0.windows.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Patch 1/7] QuarkSocPkg MtrrLib: Enhance get mtrr mask logic.
  2017-08-03  9:31 [Patch 0/7] Remove deprecated macro Eric Dong
@ 2017-08-03  9:32 ` Eric Dong
  2017-08-07  6:28   ` Ni, Ruiyu
  2017-08-03  9:32 ` [Patch 2/7] Vlv2TbltDevicePkg: " Eric Dong
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Eric Dong @ 2017-08-03  9:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jeff Fan, Ruiyu Ni, Michael D Kinney

In order to not use the deprecated macro, refine
get mtrr mask value logic.

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>
---
 QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
index 58d8c0d..2760427 100644
--- a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
+++ b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
@@ -1036,13 +1036,12 @@ MtrrLibInitializeMtrrMask (
     AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
 
     PhysicalAddressBits = (UINT8) RegEax;
-
-    *MtrrValidBitsMask    = LShiftU64 (1, PhysicalAddressBits) - 1;
-    *MtrrValidAddressMask = *MtrrValidBitsMask & 0xfffffffffffff000ULL;
   } else {
-    *MtrrValidBitsMask    = MTRR_LIB_MSR_VALID_MASK;
-    *MtrrValidAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS;
+    PhysicalAddressBits = 36;
   }
+
+  *MtrrValidBitsMask    = LShiftU64 (1, PhysicalAddressBits) - 1;
+  *MtrrValidAddressMask = *MtrrValidBitsMask & 0xfffffffffffff000ULL;
 }
 
 
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Patch 2/7] Vlv2TbltDevicePkg: Enhance get mtrr mask logic.
  2017-08-03  9:31 [Patch 0/7] Remove deprecated macro Eric Dong
  2017-08-03  9:32 ` [Patch 1/7] QuarkSocPkg MtrrLib: Enhance get mtrr mask logic Eric Dong
@ 2017-08-03  9:32 ` Eric Dong
  2017-08-07  6:29   ` Ni, Ruiyu
  2017-08-03  9:32 ` [Patch 3/7] UefiCpuPkg CpuDxe: " Eric Dong
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Eric Dong @ 2017-08-03  9:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jeff Fan, Ruiyu Ni, David Wei

In order to not use the deprecated macro, refine
get mtrr mask value logic.

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: David Wei <david.wei@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
 Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c | 45 ++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
index 99bdeb1..5a18a3f 100644
--- a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
+++ b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
@@ -70,6 +70,34 @@ GetMemorySize (
   );
 
 
+/**
+  Initializes the valid address mask for MTRRs.
+
+  This function initializes the valid bits mask and valid address mask for MTRRs.
+
+**/
+UINT64
+InitializeAddressMtrrMask (
+  VOID
+  )
+{
+  UINT32                    RegEax;
+  UINT8                     PhysicalAddressBits; 
+  UINT64                    ValidMtrrBitsMask;
+
+  AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
+
+  if (RegEax >= 0x80000008) {
+    AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
+
+    PhysicalAddressBits = (UINT8) RegEax;
+  } else {
+    PhysicalAddressBits = 36;
+  }
+
+  ValidMtrrBitsMask    = LShiftU64 (1, PhysicalAddressBits) - 1;
+  return (ValidMtrrBitsMask & 0xfffffffffffff000ULL);
+}
 
 EFI_STATUS
 EFIAPI
@@ -89,6 +117,7 @@ SetPeiCacheMode (
   UINT64                  HighMemoryLength;
   UINT8                   Index;
   MTRR_SETTINGS           MtrrSetting;
+  UINT64                  ValidMtrrAddressMask;
 
   //
   // Load Cache PPI
@@ -124,6 +153,8 @@ SetPeiCacheMode (
                              &BootMode
                              );
 
+  ValidMtrrAddressMask = InitializeAddressMtrrMask ();
+
   //
   // Determine memory usage
   //
@@ -166,15 +197,15 @@ SetPeiCacheMode (
   //
   Index = 0;
   MtrrSetting.Variables.Mtrr[0].Base = (FixedPcdGet32 (PcdFlashAreaBaseAddress) | CacheWriteProtected);
-  MtrrSetting.Variables.Mtrr[0].Mask = ((~((UINT64)(FixedPcdGet32 (PcdFlashAreaSize) - 1))) & MTRR_LIB_CACHE_VALID_ADDRESS) | MTRR_LIB_CACHE_MTRR_ENABLED;
+  MtrrSetting.Variables.Mtrr[0].Mask = ((~((UINT64)(FixedPcdGet32 (PcdFlashAreaSize) - 1))) & ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
   Index ++;
 
   MemOverflow =0;
   while (MaxMemoryLength > MemOverflow){
-    MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & MTRR_LIB_CACHE_VALID_ADDRESS) | CacheWriteBack;
+    MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & ValidMtrrAddressMask) | CacheWriteBack;
     MemoryLength = MaxMemoryLength - MemOverflow;
     MemoryLength = GetPowerOfTwo64 (MemoryLength);
-    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & MTRR_LIB_CACHE_VALID_ADDRESS) | MTRR_LIB_CACHE_MTRR_ENABLED;
+    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
 
     MemOverflow += MemoryLength;
     Index++;
@@ -185,15 +216,15 @@ SetPeiCacheMode (
   while (MaxMemoryLength != MemoryLength) {
     MemoryLengthUc = GetPowerOfTwo64 (MaxMemoryLength - MemoryLength);
 
-    MtrrSetting.Variables.Mtrr[Index].Base = ((MaxMemoryLength - MemoryLengthUc) & MTRR_LIB_CACHE_VALID_ADDRESS) | CacheUncacheable;
-    MtrrSetting.Variables.Mtrr[Index].Mask= ((~(MemoryLengthUc   - 1)) & MTRR_LIB_CACHE_VALID_ADDRESS) | MTRR_LIB_CACHE_MTRR_ENABLED;
+    MtrrSetting.Variables.Mtrr[Index].Base = ((MaxMemoryLength - MemoryLengthUc) & ValidMtrrAddressMask) | CacheUncacheable;
+    MtrrSetting.Variables.Mtrr[Index].Mask= ((~(MemoryLengthUc   - 1)) & ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
     MaxMemoryLength -= MemoryLengthUc;
     Index++;
   }
 
   MemOverflow =0x100000000;
   while (HighMemoryLength > 0) {
-    MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & MTRR_LIB_CACHE_VALID_ADDRESS) | CacheWriteBack;
+    MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & ValidMtrrAddressMask) | CacheWriteBack;
     MemoryLength = HighMemoryLength;
     MemoryLength = GetPowerOfTwo64 (MemoryLength);
 
@@ -201,7 +232,7 @@ SetPeiCacheMode (
       MemoryLength = MemOverflow;
     }
 
-    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & MTRR_LIB_CACHE_VALID_ADDRESS) | MTRR_LIB_CACHE_MTRR_ENABLED;
+    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
 
     MemOverflow += MemoryLength;
     HighMemoryLength -= MemoryLength;
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Patch 3/7] UefiCpuPkg CpuDxe: Enhance get mtrr mask logic.
  2017-08-03  9:31 [Patch 0/7] Remove deprecated macro Eric Dong
  2017-08-03  9:32 ` [Patch 1/7] QuarkSocPkg MtrrLib: Enhance get mtrr mask logic Eric Dong
  2017-08-03  9:32 ` [Patch 2/7] Vlv2TbltDevicePkg: " Eric Dong
@ 2017-08-03  9:32 ` Eric Dong
  2017-08-07  6:29   ` Ni, Ruiyu
  2017-08-03  9:32 ` [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro Eric Dong
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Eric Dong @ 2017-08-03  9:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jeff Fan, Ruiyu Ni

In order to not use the deprecated macro, refine
get mtrr mask value logic.

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
 UefiCpuPkg/CpuDxe/CpuDxe.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
index 8680656..6218670 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -25,8 +25,8 @@
 BOOLEAN                   InterruptState = FALSE;
 EFI_HANDLE                mCpuHandle = NULL;
 BOOLEAN                   mIsFlushingGCD;
-UINT64                    mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS;
-UINT64                    mValidMtrrBitsMask    = MTRR_LIB_MSR_VALID_MASK;
+UINT64                    mValidMtrrAddressMask;
+UINT64                    mValidMtrrBitsMask;
 UINT64                    mTimerPeriod = 0;
 
 FIXED_MTRR    mFixedMtrrTable[] = {
@@ -510,13 +510,12 @@ InitializeMtrrMask (
     AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
 
     PhysicalAddressBits = (UINT8) RegEax;
-
-    mValidMtrrBitsMask    = LShiftU64 (1, PhysicalAddressBits) - 1;
-    mValidMtrrAddressMask = mValidMtrrBitsMask & 0xfffffffffffff000ULL;
   } else {
-    mValidMtrrBitsMask    = MTRR_LIB_MSR_VALID_MASK;
-    mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS;
+    PhysicalAddressBits = 36;
   }
+
+  mValidMtrrBitsMask    = LShiftU64 (1, PhysicalAddressBits) - 1;
+  mValidMtrrAddressMask = mValidMtrrBitsMask & 0xfffffffffffff000ULL;
 }
 
 /**
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.
  2017-08-03  9:31 [Patch 0/7] Remove deprecated macro Eric Dong
                   ` (2 preceding siblings ...)
  2017-08-03  9:32 ` [Patch 3/7] UefiCpuPkg CpuDxe: " Eric Dong
@ 2017-08-03  9:32 ` Eric Dong
  2017-08-03 10:21   ` Ni, Ruiyu
  2017-08-07  6:31   ` Ni, Ruiyu
  2017-08-03  9:32 ` [Patch 5/7] Vlv2TbltDevicePkg: " Eric Dong
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: Eric Dong @ 2017-08-03  9:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jeff Fan, Ruiyu Ni, Michael D Kinney

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



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Patch 5/7] Vlv2TbltDevicePkg: Remove reference deprecated macro.
  2017-08-03  9:31 [Patch 0/7] Remove deprecated macro Eric Dong
                   ` (3 preceding siblings ...)
  2017-08-03  9:32 ` [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro Eric Dong
@ 2017-08-03  9:32 ` Eric Dong
  2017-08-03  9:32 ` [Patch 6/7] UefiCpuPkg CpuDxe: " Eric Dong
  2017-08-03  9:32 ` [Patch 7/7] UefiCpuPkg MtrrLib: Remove deprecated micro Eric Dong
  6 siblings, 0 replies; 18+ messages in thread
From: Eric Dong @ 2017-08-03  9:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jeff Fan, Ruiyu Ni, David Wei

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: David Wei <david.wei@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
 Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
index 5a18a3f..53d5802 100644
--- a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
+++ b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
@@ -31,6 +31,8 @@ Abstract:
 #define  PEI_MIN_MEMORY_SIZE               (6 * 0x800000)
 #define  PEI_RECOVERY_MIN_MEMORY_SIZE      (6 * 0x800000)
 
+#define  CACHE_MTRR_ENABLED                 0x800
+
 //
 // This is the memory needed for PEI to start up DXE.
 //
@@ -197,7 +199,7 @@ SetPeiCacheMode (
   //
   Index = 0;
   MtrrSetting.Variables.Mtrr[0].Base = (FixedPcdGet32 (PcdFlashAreaBaseAddress) | CacheWriteProtected);
-  MtrrSetting.Variables.Mtrr[0].Mask = ((~((UINT64)(FixedPcdGet32 (PcdFlashAreaSize) - 1))) & ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+  MtrrSetting.Variables.Mtrr[0].Mask = ((~((UINT64)(FixedPcdGet32 (PcdFlashAreaSize) - 1))) & ValidMtrrAddressMask) | CACHE_MTRR_ENABLED;
   Index ++;
 
   MemOverflow =0;
@@ -205,7 +207,7 @@ SetPeiCacheMode (
     MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow & ValidMtrrAddressMask) | CacheWriteBack;
     MemoryLength = MaxMemoryLength - MemOverflow;
     MemoryLength = GetPowerOfTwo64 (MemoryLength);
-    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & ValidMtrrAddressMask) | CACHE_MTRR_ENABLED;
 
     MemOverflow += MemoryLength;
     Index++;
@@ -217,7 +219,7 @@ SetPeiCacheMode (
     MemoryLengthUc = GetPowerOfTwo64 (MaxMemoryLength - MemoryLength);
 
     MtrrSetting.Variables.Mtrr[Index].Base = ((MaxMemoryLength - MemoryLengthUc) & ValidMtrrAddressMask) | CacheUncacheable;
-    MtrrSetting.Variables.Mtrr[Index].Mask= ((~(MemoryLengthUc   - 1)) & ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+    MtrrSetting.Variables.Mtrr[Index].Mask= ((~(MemoryLengthUc   - 1)) & ValidMtrrAddressMask) | CACHE_MTRR_ENABLED;
     MaxMemoryLength -= MemoryLengthUc;
     Index++;
   }
@@ -232,7 +234,7 @@ SetPeiCacheMode (
       MemoryLength = MemOverflow;
     }
 
-    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
+    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) & ValidMtrrAddressMask) | CACHE_MTRR_ENABLED;
 
     MemOverflow += MemoryLength;
     HighMemoryLength -= MemoryLength;
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Patch 6/7] UefiCpuPkg CpuDxe: Remove reference deprecated macro.
  2017-08-03  9:31 [Patch 0/7] Remove deprecated macro Eric Dong
                   ` (4 preceding siblings ...)
  2017-08-03  9:32 ` [Patch 5/7] Vlv2TbltDevicePkg: " Eric Dong
@ 2017-08-03  9:32 ` Eric Dong
  2017-08-07  6:30   ` Ni, Ruiyu
  2017-08-03  9:32 ` [Patch 7/7] UefiCpuPkg MtrrLib: Remove deprecated micro Eric Dong
  6 siblings, 1 reply; 18+ messages in thread
From: Eric Dong @ 2017-08-03  9:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jeff Fan, Ruiyu Ni

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
 UefiCpuPkg/CpuDxe/CpuDxe.c | 22 +++++++++++-----------
 UefiCpuPkg/CpuDxe/CpuDxe.h |  1 +
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
index 6218670..b386f3b 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -31,57 +31,57 @@ UINT64                    mTimerPeriod = 0;
 
 FIXED_MTRR    mFixedMtrrTable[] = {
   {
-    MTRR_LIB_IA32_MTRR_FIX64K_00000,
+    MSR_IA32_MTRR_FIX64K_00000,
     0,
     0x10000
   },
   {
-    MTRR_LIB_IA32_MTRR_FIX16K_80000,
+    MSR_IA32_MTRR_FIX16K_80000,
     0x80000,
     0x4000
   },
   {
-    MTRR_LIB_IA32_MTRR_FIX16K_A0000,
+    MSR_IA32_MTRR_FIX16K_A0000,
     0xA0000,
     0x4000
   },
   {
-    MTRR_LIB_IA32_MTRR_FIX4K_C0000,
+    MSR_IA32_MTRR_FIX4K_C0000,
     0xC0000,
     0x1000
   },
   {
-    MTRR_LIB_IA32_MTRR_FIX4K_C8000,
+    MSR_IA32_MTRR_FIX4K_C8000,
     0xC8000,
     0x1000
   },
   {
-    MTRR_LIB_IA32_MTRR_FIX4K_D0000,
+    MSR_IA32_MTRR_FIX4K_D0000,
     0xD0000,
     0x1000
   },
   {
-    MTRR_LIB_IA32_MTRR_FIX4K_D8000,
+    MSR_IA32_MTRR_FIX4K_D8000,
     0xD8000,
     0x1000
   },
   {
-    MTRR_LIB_IA32_MTRR_FIX4K_E0000,
+    MSR_IA32_MTRR_FIX4K_E0000,
     0xE0000,
     0x1000
   },
   {
-    MTRR_LIB_IA32_MTRR_FIX4K_E8000,
+    MSR_IA32_MTRR_FIX4K_E8000,
     0xE8000,
     0x1000
   },
   {
-    MTRR_LIB_IA32_MTRR_FIX4K_F0000,
+    MSR_IA32_MTRR_FIX4K_F0000,
     0xF0000,
     0x1000
   },
   {
-    MTRR_LIB_IA32_MTRR_FIX4K_F8000,
+    MSR_IA32_MTRR_FIX4K_F8000,
     0xF8000,
     0x1000
   },
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h
index 27ad45b..4861abe 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.h
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.h
@@ -19,6 +19,7 @@
 
 #include <Protocol/Cpu.h>
 #include <Protocol/MpService.h>
+#include <Register/Msr.h>
 
 #include <Ppi/SecPlatformInformation.h>
 #include <Ppi/SecPlatformInformation2.h>
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Patch 7/7] UefiCpuPkg MtrrLib: Remove deprecated micro.
  2017-08-03  9:31 [Patch 0/7] Remove deprecated macro Eric Dong
                   ` (5 preceding siblings ...)
  2017-08-03  9:32 ` [Patch 6/7] UefiCpuPkg CpuDxe: " Eric Dong
@ 2017-08-03  9:32 ` Eric Dong
  2017-08-07  6:30   ` Ni, Ruiyu
  2017-08-24 11:07   ` Laszlo Ersek
  6 siblings, 2 replies; 18+ messages in thread
From: Eric Dong @ 2017-08-03  9:32 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jeff Fan, Ruiyu Ni

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
 UefiCpuPkg/Include/Library/MtrrLib.h | 27 ---------------------------
 1 file changed, 27 deletions(-)

diff --git a/UefiCpuPkg/Include/Library/MtrrLib.h b/UefiCpuPkg/Include/Library/MtrrLib.h
index a63da4d..6120526 100644
--- a/UefiCpuPkg/Include/Library/MtrrLib.h
+++ b/UefiCpuPkg/Include/Library/MtrrLib.h
@@ -31,33 +31,6 @@
 #define  RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER  2
 
 #define  MTRR_NUMBER_OF_FIXED_MTRR      11
-//
-// Below macro is deprecated, and should not be used.
-//
-#define  FIRMWARE_VARIABLE_MTRR_NUMBER  6
-#define  MTRR_LIB_IA32_MTRR_CAP                      0x0FE
-#define  MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK            0x0FF
-#define  MTRR_LIB_IA32_MTRR_FIX64K_00000             0x250
-#define  MTRR_LIB_IA32_MTRR_FIX16K_80000             0x258
-#define  MTRR_LIB_IA32_MTRR_FIX16K_A0000             0x259
-#define  MTRR_LIB_IA32_MTRR_FIX4K_C0000              0x268
-#define  MTRR_LIB_IA32_MTRR_FIX4K_C8000              0x269
-#define  MTRR_LIB_IA32_MTRR_FIX4K_D0000              0x26A
-#define  MTRR_LIB_IA32_MTRR_FIX4K_D8000              0x26B
-#define  MTRR_LIB_IA32_MTRR_FIX4K_E0000              0x26C
-#define  MTRR_LIB_IA32_MTRR_FIX4K_E8000              0x26D
-#define  MTRR_LIB_IA32_MTRR_FIX4K_F0000              0x26E
-#define  MTRR_LIB_IA32_MTRR_FIX4K_F8000              0x26F
-#define  MTRR_LIB_IA32_VARIABLE_MTRR_BASE            0x200
-//
-// Below macro is deprecated, and should not be used.
-//
-#define  MTRR_LIB_IA32_VARIABLE_MTRR_END             0x20F
-#define  MTRR_LIB_IA32_MTRR_DEF_TYPE                 0x2FF
-#define  MTRR_LIB_MSR_VALID_MASK                     0xFFFFFFFFFULL
-#define  MTRR_LIB_CACHE_VALID_ADDRESS                0xFFFFFF000ULL
-#define  MTRR_LIB_CACHE_MTRR_ENABLED                 0x800
-#define  MTRR_LIB_CACHE_FIXED_MTRR_ENABLED           0x400
 
 //
 // Structure to describe a fixed MTRR
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.
  2017-08-03  9:32 ` [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro Eric Dong
@ 2017-08-03 10:21   ` Ni, Ruiyu
  2017-08-04  4:52     ` Dong, Eric
  2017-08-07  6:31   ` Ni, Ruiyu
  1 sibling, 1 reply; 18+ messages in thread
From: Ni, Ruiyu @ 2017-08-03 10:21 UTC (permalink / raw)
  To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Fan, Jeff, Kinney, Michael D

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



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.
  2017-08-03 10:21   ` Ni, Ruiyu
@ 2017-08-04  4:52     ` Dong, Eric
  2017-08-04  6:53       ` Ni, Ruiyu
  0 siblings, 1 reply; 18+ messages in thread
From: Dong, Eric @ 2017-08-04  4:52 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Fan, Jeff, Kinney, Michael D

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



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.
  2017-08-04  4:52     ` Dong, Eric
@ 2017-08-04  6:53       ` Ni, Ruiyu
  0 siblings, 0 replies; 18+ messages in thread
From: Ni, Ruiyu @ 2017-08-04  6:53 UTC (permalink / raw)
  To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Fan, Jeff, Kinney, Michael D

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



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Patch 1/7] QuarkSocPkg MtrrLib: Enhance get mtrr mask logic.
  2017-08-03  9:32 ` [Patch 1/7] QuarkSocPkg MtrrLib: Enhance get mtrr mask logic Eric Dong
@ 2017-08-07  6:28   ` Ni, Ruiyu
  0 siblings, 0 replies; 18+ messages in thread
From: Ni, Ruiyu @ 2017-08-07  6:28 UTC (permalink / raw)
  To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Kinney, Michael D, Fan, Jeff

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Thanks/Ray

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Eric Dong
> Sent: Thursday, August 3, 2017 5:32 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Fan, Jeff <jeff.fan@intel.com>
> Subject: [edk2] [Patch 1/7] QuarkSocPkg MtrrLib: Enhance get mtrr mask
> logic.
> 
> In order to not use the deprecated macro, refine get mtrr mask value logic.
> 
> 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>
> ---
>  QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> index 58d8c0d..2760427 100644
> --- a/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> +++ b/QuarkSocPkg/QuarkNorthCluster/Library/MtrrLib/MtrrLib.c
> @@ -1036,13 +1036,12 @@ MtrrLibInitializeMtrrMask (
>      AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
> 
>      PhysicalAddressBits = (UINT8) RegEax;
> -
> -    *MtrrValidBitsMask    = LShiftU64 (1, PhysicalAddressBits) - 1;
> -    *MtrrValidAddressMask = *MtrrValidBitsMask & 0xfffffffffffff000ULL;
>    } else {
> -    *MtrrValidBitsMask    = MTRR_LIB_MSR_VALID_MASK;
> -    *MtrrValidAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS;
> +    PhysicalAddressBits = 36;
>    }
> +
> +  *MtrrValidBitsMask    = LShiftU64 (1, PhysicalAddressBits) - 1;
> +  *MtrrValidAddressMask = *MtrrValidBitsMask & 0xfffffffffffff000ULL;
>  }
> 
> 
> --
> 2.7.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Patch 3/7] UefiCpuPkg CpuDxe: Enhance get mtrr mask logic.
  2017-08-03  9:32 ` [Patch 3/7] UefiCpuPkg CpuDxe: " Eric Dong
@ 2017-08-07  6:29   ` Ni, Ruiyu
  0 siblings, 0 replies; 18+ messages in thread
From: Ni, Ruiyu @ 2017-08-07  6:29 UTC (permalink / raw)
  To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Fan, Jeff

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>
> Subject: [Patch 3/7] UefiCpuPkg CpuDxe: Enhance get mtrr mask logic.
> 
> In order to not use the deprecated macro, refine get mtrr mask value logic.
> 
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>  UefiCpuPkg/CpuDxe/CpuDxe.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
> index 8680656..6218670 100644
> --- a/UefiCpuPkg/CpuDxe/CpuDxe.c
> +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
> @@ -25,8 +25,8 @@
>  BOOLEAN                   InterruptState = FALSE;
>  EFI_HANDLE                mCpuHandle = NULL;
>  BOOLEAN                   mIsFlushingGCD;
> -UINT64                    mValidMtrrAddressMask =
> MTRR_LIB_CACHE_VALID_ADDRESS;
> -UINT64                    mValidMtrrBitsMask    = MTRR_LIB_MSR_VALID_MASK;
> +UINT64                    mValidMtrrAddressMask;
> +UINT64                    mValidMtrrBitsMask;
>  UINT64                    mTimerPeriod = 0;
> 
>  FIXED_MTRR    mFixedMtrrTable[] = {
> @@ -510,13 +510,12 @@ InitializeMtrrMask (
>      AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
> 
>      PhysicalAddressBits = (UINT8) RegEax;
> -
> -    mValidMtrrBitsMask    = LShiftU64 (1, PhysicalAddressBits) - 1;
> -    mValidMtrrAddressMask = mValidMtrrBitsMask & 0xfffffffffffff000ULL;
>    } else {
> -    mValidMtrrBitsMask    = MTRR_LIB_MSR_VALID_MASK;
> -    mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS;
> +    PhysicalAddressBits = 36;
>    }
> +
> +  mValidMtrrBitsMask    = LShiftU64 (1, PhysicalAddressBits) - 1;
> +  mValidMtrrAddressMask = mValidMtrrBitsMask & 0xfffffffffffff000ULL;
>  }
> 
>  /**
> --
> 2.7.0.windows.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Patch 2/7] Vlv2TbltDevicePkg: Enhance get mtrr mask logic.
  2017-08-03  9:32 ` [Patch 2/7] Vlv2TbltDevicePkg: " Eric Dong
@ 2017-08-07  6:29   ` Ni, Ruiyu
  0 siblings, 0 replies; 18+ messages in thread
From: Ni, Ruiyu @ 2017-08-07  6:29 UTC (permalink / raw)
  To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Fan, Jeff, Wei, David

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>; Wei,
> David <david.wei@intel.com>
> Subject: [Patch 2/7] Vlv2TbltDevicePkg: Enhance get mtrr mask logic.
> 
> In order to not use the deprecated macro, refine get mtrr mask value logic.
> 
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: David Wei <david.wei@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>  Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c | 45
> ++++++++++++++++++++++----
>  1 file changed, 38 insertions(+), 7 deletions(-)
> 
> diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
> b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
> index 99bdeb1..5a18a3f 100644
> --- a/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
> +++ b/Vlv2TbltDevicePkg/PlatformInitPei/MemoryPeim.c
> @@ -70,6 +70,34 @@ GetMemorySize (
>    );
> 
> 
> +/**
> +  Initializes the valid address mask for MTRRs.
> +
> +  This function initializes the valid bits mask and valid address mask for
> MTRRs.
> +
> +**/
> +UINT64
> +InitializeAddressMtrrMask (
> +  VOID
> +  )
> +{
> +  UINT32                    RegEax;
> +  UINT8                     PhysicalAddressBits;
> +  UINT64                    ValidMtrrBitsMask;
> +
> +  AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
> +
> +  if (RegEax >= 0x80000008) {
> +    AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
> +
> +    PhysicalAddressBits = (UINT8) RegEax;  } else {
> +    PhysicalAddressBits = 36;
> +  }
> +
> +  ValidMtrrBitsMask    = LShiftU64 (1, PhysicalAddressBits) - 1;
> +  return (ValidMtrrBitsMask & 0xfffffffffffff000ULL); }
> 
>  EFI_STATUS
>  EFIAPI
> @@ -89,6 +117,7 @@ SetPeiCacheMode (
>    UINT64                  HighMemoryLength;
>    UINT8                   Index;
>    MTRR_SETTINGS           MtrrSetting;
> +  UINT64                  ValidMtrrAddressMask;
> 
>    //
>    // Load Cache PPI
> @@ -124,6 +153,8 @@ SetPeiCacheMode (
>                               &BootMode
>                               );
> 
> +  ValidMtrrAddressMask = InitializeAddressMtrrMask ();
> +
>    //
>    // Determine memory usage
>    //
> @@ -166,15 +197,15 @@ SetPeiCacheMode (
>    //
>    Index = 0;
>    MtrrSetting.Variables.Mtrr[0].Base = (FixedPcdGet32
> (PcdFlashAreaBaseAddress) | CacheWriteProtected);
> -  MtrrSetting.Variables.Mtrr[0].Mask = ((~((UINT64)(FixedPcdGet32
> (PcdFlashAreaSize) - 1))) & MTRR_LIB_CACHE_VALID_ADDRESS) |
> MTRR_LIB_CACHE_MTRR_ENABLED;
> +  MtrrSetting.Variables.Mtrr[0].Mask = ((~((UINT64)(FixedPcdGet32
> + (PcdFlashAreaSize) - 1))) & ValidMtrrAddressMask) |
> + MTRR_LIB_CACHE_MTRR_ENABLED;
>    Index ++;
> 
>    MemOverflow =0;
>    while (MaxMemoryLength > MemOverflow){
> -    MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow &
> MTRR_LIB_CACHE_VALID_ADDRESS) | CacheWriteBack;
> +    MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow &
> + ValidMtrrAddressMask) | CacheWriteBack;
>      MemoryLength = MaxMemoryLength - MemOverflow;
>      MemoryLength = GetPowerOfTwo64 (MemoryLength);
> -    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) &
> MTRR_LIB_CACHE_VALID_ADDRESS) | MTRR_LIB_CACHE_MTRR_ENABLED;
> +    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) &
> + ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
> 
>      MemOverflow += MemoryLength;
>      Index++;
> @@ -185,15 +216,15 @@ SetPeiCacheMode (
>    while (MaxMemoryLength != MemoryLength) {
>      MemoryLengthUc = GetPowerOfTwo64 (MaxMemoryLength -
> MemoryLength);
> 
> -    MtrrSetting.Variables.Mtrr[Index].Base = ((MaxMemoryLength -
> MemoryLengthUc) & MTRR_LIB_CACHE_VALID_ADDRESS) |
> CacheUncacheable;
> -    MtrrSetting.Variables.Mtrr[Index].Mask= ((~(MemoryLengthUc   - 1)) &
> MTRR_LIB_CACHE_VALID_ADDRESS) | MTRR_LIB_CACHE_MTRR_ENABLED;
> +    MtrrSetting.Variables.Mtrr[Index].Base = ((MaxMemoryLength -
> MemoryLengthUc) & ValidMtrrAddressMask) | CacheUncacheable;
> +    MtrrSetting.Variables.Mtrr[Index].Mask= ((~(MemoryLengthUc   - 1)) &
> ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
>      MaxMemoryLength -= MemoryLengthUc;
>      Index++;
>    }
> 
>    MemOverflow =0x100000000;
>    while (HighMemoryLength > 0) {
> -    MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow &
> MTRR_LIB_CACHE_VALID_ADDRESS) | CacheWriteBack;
> +    MtrrSetting.Variables.Mtrr[Index].Base = (MemOverflow &
> + ValidMtrrAddressMask) | CacheWriteBack;
>      MemoryLength = HighMemoryLength;
>      MemoryLength = GetPowerOfTwo64 (MemoryLength);
> 
> @@ -201,7 +232,7 @@ SetPeiCacheMode (
>        MemoryLength = MemOverflow;
>      }
> 
> -    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) &
> MTRR_LIB_CACHE_VALID_ADDRESS) | MTRR_LIB_CACHE_MTRR_ENABLED;
> +    MtrrSetting.Variables.Mtrr[Index].Mask = ((~(MemoryLength - 1)) &
> + ValidMtrrAddressMask) | MTRR_LIB_CACHE_MTRR_ENABLED;
> 
>      MemOverflow += MemoryLength;
>      HighMemoryLength -= MemoryLength;
> --
> 2.7.0.windows.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Patch 6/7] UefiCpuPkg CpuDxe: Remove reference deprecated macro.
  2017-08-03  9:32 ` [Patch 6/7] UefiCpuPkg CpuDxe: " Eric Dong
@ 2017-08-07  6:30   ` Ni, Ruiyu
  0 siblings, 0 replies; 18+ messages in thread
From: Ni, Ruiyu @ 2017-08-07  6:30 UTC (permalink / raw)
  To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Fan, Jeff

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>
> Subject: [Patch 6/7] UefiCpuPkg CpuDxe: Remove reference deprecated
> macro.
> 
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>  UefiCpuPkg/CpuDxe/CpuDxe.c | 22 +++++++++++-----------
> UefiCpuPkg/CpuDxe/CpuDxe.h |  1 +
>  2 files changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
> index 6218670..b386f3b 100644
> --- a/UefiCpuPkg/CpuDxe/CpuDxe.c
> +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
> @@ -31,57 +31,57 @@ UINT64                    mTimerPeriod = 0;
> 
>  FIXED_MTRR    mFixedMtrrTable[] = {
>    {
> -    MTRR_LIB_IA32_MTRR_FIX64K_00000,
> +    MSR_IA32_MTRR_FIX64K_00000,
>      0,
>      0x10000
>    },
>    {
> -    MTRR_LIB_IA32_MTRR_FIX16K_80000,
> +    MSR_IA32_MTRR_FIX16K_80000,
>      0x80000,
>      0x4000
>    },
>    {
> -    MTRR_LIB_IA32_MTRR_FIX16K_A0000,
> +    MSR_IA32_MTRR_FIX16K_A0000,
>      0xA0000,
>      0x4000
>    },
>    {
> -    MTRR_LIB_IA32_MTRR_FIX4K_C0000,
> +    MSR_IA32_MTRR_FIX4K_C0000,
>      0xC0000,
>      0x1000
>    },
>    {
> -    MTRR_LIB_IA32_MTRR_FIX4K_C8000,
> +    MSR_IA32_MTRR_FIX4K_C8000,
>      0xC8000,
>      0x1000
>    },
>    {
> -    MTRR_LIB_IA32_MTRR_FIX4K_D0000,
> +    MSR_IA32_MTRR_FIX4K_D0000,
>      0xD0000,
>      0x1000
>    },
>    {
> -    MTRR_LIB_IA32_MTRR_FIX4K_D8000,
> +    MSR_IA32_MTRR_FIX4K_D8000,
>      0xD8000,
>      0x1000
>    },
>    {
> -    MTRR_LIB_IA32_MTRR_FIX4K_E0000,
> +    MSR_IA32_MTRR_FIX4K_E0000,
>      0xE0000,
>      0x1000
>    },
>    {
> -    MTRR_LIB_IA32_MTRR_FIX4K_E8000,
> +    MSR_IA32_MTRR_FIX4K_E8000,
>      0xE8000,
>      0x1000
>    },
>    {
> -    MTRR_LIB_IA32_MTRR_FIX4K_F0000,
> +    MSR_IA32_MTRR_FIX4K_F0000,
>      0xF0000,
>      0x1000
>    },
>    {
> -    MTRR_LIB_IA32_MTRR_FIX4K_F8000,
> +    MSR_IA32_MTRR_FIX4K_F8000,
>      0xF8000,
>      0x1000
>    },
> diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h
> index 27ad45b..4861abe 100644
> --- a/UefiCpuPkg/CpuDxe/CpuDxe.h
> +++ b/UefiCpuPkg/CpuDxe/CpuDxe.h
> @@ -19,6 +19,7 @@
> 
>  #include <Protocol/Cpu.h>
>  #include <Protocol/MpService.h>
> +#include <Register/Msr.h>
> 
>  #include <Ppi/SecPlatformInformation.h>  #include
> <Ppi/SecPlatformInformation2.h>
> --
> 2.7.0.windows.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Patch 7/7] UefiCpuPkg MtrrLib: Remove deprecated micro.
  2017-08-03  9:32 ` [Patch 7/7] UefiCpuPkg MtrrLib: Remove deprecated micro Eric Dong
@ 2017-08-07  6:30   ` Ni, Ruiyu
  2017-08-24 11:07   ` Laszlo Ersek
  1 sibling, 0 replies; 18+ messages in thread
From: Ni, Ruiyu @ 2017-08-07  6:30 UTC (permalink / raw)
  To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Fan, Jeff

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>
> Subject: [Patch 7/7] UefiCpuPkg MtrrLib: Remove deprecated micro.
> 
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>  UefiCpuPkg/Include/Library/MtrrLib.h | 27 ---------------------------
>  1 file changed, 27 deletions(-)
> 
> diff --git a/UefiCpuPkg/Include/Library/MtrrLib.h
> b/UefiCpuPkg/Include/Library/MtrrLib.h
> index a63da4d..6120526 100644
> --- a/UefiCpuPkg/Include/Library/MtrrLib.h
> +++ b/UefiCpuPkg/Include/Library/MtrrLib.h
> @@ -31,33 +31,6 @@
>  #define  RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER  2
> 
>  #define  MTRR_NUMBER_OF_FIXED_MTRR      11
> -//
> -// Below macro is deprecated, and should not be used.
> -//
> -#define  FIRMWARE_VARIABLE_MTRR_NUMBER  6
> -#define  MTRR_LIB_IA32_MTRR_CAP                      0x0FE
> -#define  MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK            0x0FF
> -#define  MTRR_LIB_IA32_MTRR_FIX64K_00000             0x250
> -#define  MTRR_LIB_IA32_MTRR_FIX16K_80000             0x258
> -#define  MTRR_LIB_IA32_MTRR_FIX16K_A0000             0x259
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_C0000              0x268
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_C8000              0x269
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_D0000              0x26A
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_D8000              0x26B
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_E0000              0x26C
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_E8000              0x26D
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_F0000              0x26E
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_F8000              0x26F
> -#define  MTRR_LIB_IA32_VARIABLE_MTRR_BASE            0x200
> -//
> -// Below macro is deprecated, and should not be used.
> -//
> -#define  MTRR_LIB_IA32_VARIABLE_MTRR_END             0x20F
> -#define  MTRR_LIB_IA32_MTRR_DEF_TYPE                 0x2FF
> -#define  MTRR_LIB_MSR_VALID_MASK                     0xFFFFFFFFFULL
> -#define  MTRR_LIB_CACHE_VALID_ADDRESS                0xFFFFFF000ULL
> -#define  MTRR_LIB_CACHE_MTRR_ENABLED                 0x800
> -#define  MTRR_LIB_CACHE_FIXED_MTRR_ENABLED           0x400
> 
>  //
>  // Structure to describe a fixed MTRR
> --
> 2.7.0.windows.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro.
  2017-08-03  9:32 ` [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro Eric Dong
  2017-08-03 10:21   ` Ni, Ruiyu
@ 2017-08-07  6:31   ` Ni, Ruiyu
  1 sibling, 0 replies; 18+ messages in thread
From: Ni, Ruiyu @ 2017-08-07  6:31 UTC (permalink / raw)
  To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Fan, Jeff, Kinney, Michael D

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



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Patch 7/7] UefiCpuPkg MtrrLib: Remove deprecated micro.
  2017-08-03  9:32 ` [Patch 7/7] UefiCpuPkg MtrrLib: Remove deprecated micro Eric Dong
  2017-08-07  6:30   ` Ni, Ruiyu
@ 2017-08-24 11:07   ` Laszlo Ersek
  1 sibling, 0 replies; 18+ messages in thread
From: Laszlo Ersek @ 2017-08-24 11:07 UTC (permalink / raw)
  To: Eric Dong, edk2-devel; +Cc: Ruiyu Ni, Jeff Fan

On 08/03/17 11:32, Eric Dong wrote:
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>  UefiCpuPkg/Include/Library/MtrrLib.h | 27 ---------------------------
>  1 file changed, 27 deletions(-)
> 
> diff --git a/UefiCpuPkg/Include/Library/MtrrLib.h b/UefiCpuPkg/Include/Library/MtrrLib.h
> index a63da4d..6120526 100644
> --- a/UefiCpuPkg/Include/Library/MtrrLib.h
> +++ b/UefiCpuPkg/Include/Library/MtrrLib.h
> @@ -31,33 +31,6 @@
>  #define  RESERVED_FIRMWARE_VARIABLE_MTRR_NUMBER  2
>  
>  #define  MTRR_NUMBER_OF_FIXED_MTRR      11
> -//
> -// Below macro is deprecated, and should not be used.
> -//
> -#define  FIRMWARE_VARIABLE_MTRR_NUMBER  6
> -#define  MTRR_LIB_IA32_MTRR_CAP                      0x0FE
> -#define  MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK            0x0FF
> -#define  MTRR_LIB_IA32_MTRR_FIX64K_00000             0x250
> -#define  MTRR_LIB_IA32_MTRR_FIX16K_80000             0x258
> -#define  MTRR_LIB_IA32_MTRR_FIX16K_A0000             0x259
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_C0000              0x268
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_C8000              0x269
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_D0000              0x26A
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_D8000              0x26B
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_E0000              0x26C
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_E8000              0x26D
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_F0000              0x26E
> -#define  MTRR_LIB_IA32_MTRR_FIX4K_F8000              0x26F
> -#define  MTRR_LIB_IA32_VARIABLE_MTRR_BASE            0x200
> -//
> -// Below macro is deprecated, and should not be used.
> -//
> -#define  MTRR_LIB_IA32_VARIABLE_MTRR_END             0x20F
> -#define  MTRR_LIB_IA32_MTRR_DEF_TYPE                 0x2FF
> -#define  MTRR_LIB_MSR_VALID_MASK                     0xFFFFFFFFFULL
> -#define  MTRR_LIB_CACHE_VALID_ADDRESS                0xFFFFFF000ULL
> -#define  MTRR_LIB_CACHE_MTRR_ENABLED                 0x800
> -#define  MTRR_LIB_CACHE_FIXED_MTRR_ENABLED           0x400
>  
>  //
>  // Structure to describe a fixed MTRR
> 

I think this patch broke "AppPkg/Applications/Sockets/WebServer":

> AppPkg/Applications/Sockets/WebServer/Mtrr.c: In function 'MemoryTypeRegistersPage':
> AppPkg/Applications/Sockets/WebServer/Mtrr.c:305:37: error: 'MTRR_LIB_IA32_MTRR_CAP' undeclared (first use in this function)
>        Capabilities = AsmReadMsr64 ( MTRR_LIB_IA32_MTRR_CAP );
>                                      ^
> AppPkg/Applications/Sockets/WebServer/Mtrr.c:305:37: note: each undeclared identifier is reported only once for each function it appears in
> AppPkg/Applications/Sockets/WebServer/Mtrr.c:306:33: error: 'MTRR_LIB_IA32_MTRR_DEF_TYPE' undeclared (first use in this function)
>        DefType =  AsmReadMsr64 ( MTRR_LIB_IA32_MTRR_DEF_TYPE );
>                                  ^
> AppPkg/Applications/Sockets/WebServer/Mtrr.c:353:56: error: 'MTRR_LIB_CACHE_MTRR_ENABLED' undeclared (first use in this function)
>                                      ( 0 != ( DefType & MTRR_LIB_CACHE_MTRR_ENABLED ))
>                                                         ^
> AppPkg/Applications/Sockets/WebServer/Mtrr.c:367:56: error: 'MTRR_LIB_CACHE_FIXED_MTRR_ENABLED' undeclared (first use in this function)
>                                      ( 0 != ( DefType & MTRR_LIB_CACHE_FIXED_MTRR_ENABLED ))
>                                                         ^
> AppPkg/Applications/Sockets/WebServer/Mtrr.c:618:35: error: 'MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK' undeclared (first use in this function)
>          MaxMtrrs = Capabilities & MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK;

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-08-24 11:05 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-03  9:31 [Patch 0/7] Remove deprecated macro Eric Dong
2017-08-03  9:32 ` [Patch 1/7] QuarkSocPkg MtrrLib: Enhance get mtrr mask logic Eric Dong
2017-08-07  6:28   ` Ni, Ruiyu
2017-08-03  9:32 ` [Patch 2/7] Vlv2TbltDevicePkg: " Eric Dong
2017-08-07  6:29   ` Ni, Ruiyu
2017-08-03  9:32 ` [Patch 3/7] UefiCpuPkg CpuDxe: " Eric Dong
2017-08-07  6:29   ` Ni, Ruiyu
2017-08-03  9:32 ` [Patch 4/7] QuarkSocPkg MtrrLib: Remove reference deprecated macro Eric Dong
2017-08-03 10:21   ` Ni, Ruiyu
2017-08-04  4:52     ` Dong, Eric
2017-08-04  6:53       ` Ni, Ruiyu
2017-08-07  6:31   ` Ni, Ruiyu
2017-08-03  9:32 ` [Patch 5/7] Vlv2TbltDevicePkg: " Eric Dong
2017-08-03  9:32 ` [Patch 6/7] UefiCpuPkg CpuDxe: " Eric Dong
2017-08-07  6:30   ` Ni, Ruiyu
2017-08-03  9:32 ` [Patch 7/7] UefiCpuPkg MtrrLib: Remove deprecated micro Eric Dong
2017-08-07  6:30   ` Ni, Ruiyu
2017-08-24 11:07   ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox