Re: [edk2] [Patch][edk2-platforms/devel-MinnowBoard3] Enable Mor.

2017-01-19 Thread Wei, David
Reviewed-by: zwei4 

Thanks,
David  Wei 


-Original Message-
From: Lu, ShifeiX A 
Sent: Friday, January 20, 2017 2:16 PM
To: edk2-devel@lists.01.org
Cc: Wei, David 
Subject: [Patch][edk2-platforms/devel-MinnowBoard3] Enable Mor.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: lushifex 
---
 .../Common/Acpi/AcpiTablesPCAT/Platform.asl|  13 ++--
 .../MemoryTest/NullMemoryTestDxe/NullMemoryTest.c  |  72 -
 .../MemoryTest/NullMemoryTestDxe/NullMemoryTest.h  |   2 +-
 .../NullMemoryTestDxe/NullMemoryTestDxe.inf|   4 +-
 .../NullMemoryTestDxe/NullMemoryTestDxe.uni| Bin 2194 -> 2194 bytes
 .../NullMemoryTestDxe/NullMemoryTestDxeExtra.uni   | Bin 1372 -> 1372 bytes
 .../BroxtonPlatformPkg/PlatformDsc/Components.dsc  |   1 +
 Platform/BroxtonPlatformPkg/PlatformPkg.fdf|   1 +
 8 files changed, 40 insertions(+), 53 deletions(-)

diff --git 
a/Platform/BroxtonPlatformPkg/Common/Acpi/AcpiTablesPCAT/Platform.asl 
b/Platform/BroxtonPlatformPkg/Common/Acpi/AcpiTablesPCAT/Platform.asl
index 7847f2f..04ea3ad 100644
--- a/Platform/BroxtonPlatformPkg/Common/Acpi/AcpiTablesPCAT/Platform.asl
+++ b/Platform/BroxtonPlatformPkg/Common/Acpi/AcpiTablesPCAT/Platform.asl
@@ -1,5 +1,5 @@
 /** @file
-  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -19,7 +19,6 @@ External(PDC1)
 External(PDC2)
 External(PDC3)
 External(\_PR.CPU0._PPC, IntObj)
-External(\_SB.PCI0.LPCB.TPM.PTS, MethodObj)
 Name(ECUP, 1)  // EC State indicator: 1- Normal Mode 0- Low Power Mode
 Mutex(EHLD, 0) // EC Hold indicator: 0- No one accessing the EC Power State 1- 
Someone else is accessing the EC Power State
 
@@ -153,10 +152,12 @@ Method(_PTS,1)
   //clear GPE0_STS
   Store(Ones, G0S)
 
-  //
-  // Call TPM PTS method
-  //
-  \_SB.TPM.PTS (Arg0)
+  If (CondRefOf(\_SB.TPM.PTS)) {
+//
+// Call TPM PTS method
+//
+\_SB.TPM.PTS (Arg0)
+  }
 
   //
   // Set GPIO_116 (SOC_CODEC_IRQ) 20k pull-down for device I2S audio codec 
INT343A before enter S3/S4
diff --git 
a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c
 
b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c
index a3f5971..b506f13 100644
--- 
a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c
+++ 
b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c
@@ -2,7 +2,7 @@
   Implementation of Generic Memory Test Protocol which does not perform real 
memory test.
   Also clears memory when the MemoryOverwriteRequest bit is set.
 
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 
 UINT64mTestedSystemMemory = 0;
 UINT64mTotalSystemMemory  = 0;
@@ -151,19 +150,12 @@ BOOLEAN
 IsMemoryOverwriteRequested (
   )
 {
-  BOOLEAN bRetValue = 0;
-  EFI_STATUS Status;
-  UINT64 MemoryOverwriteReq = 0;
-  UINTN  VariableSize;
-  UINT8  CmosRegValue;
-
-  DEBUG((EFI_D_INFO, "+IsMemoryOverwriteRequested\n"));
+  BOOLEAN bRetValue = 0;
+  EFI_STATUS  Status;
+  UINT64  MemoryOverwriteReq = 0;
+  UINTN   VariableSize;
 
-  //
-  // Read the CMOS Register EFI_CMOS_CLEAN_RESET
-  //
-  IoWrite8(CmosIo_72, EFI_CMOS_CLEAN_RESET);
-  CmosRegValue = IoRead8(CmosIo_73);
+  DEBUG ((EFI_D_INFO, "IsMemoryOverwriteRequested\n"));
 
   //
   // Get the MOR variable
@@ -187,25 +179,18 @@ IsMemoryOverwriteRequested (
   
   );
 } else {
+  MemoryOverwriteReq = 0;
   DEBUG ((EFI_D_ERROR, "IsMemoryOverwriteRequested: Failed to Get MOR 
Variable - Status = %r\n", Status));
 }
 goto Exit;
   }
-
-  DEBUG ((EFI_D_INFO, "IsMemoryOverwriteRequested: MOR Control Value = %02x, 
CmosRegValue = %02x\n", MemoryOverwriteReq, CmosRegValue));
-
-  if ((MOR_CLEAR_MEMORY_VALUE(MemoryOverwriteReq)) &&
-(((CmosRegValue != B_MAGIC_CLEAN_RESET_VALUE) && 
(MOR_DISABLE_AUTO_DETECT_VALUE(MemoryOverwriteReq) == 0)) ||
-(MOR_DISABLE_AUTO_DETECT_VALUE(MemoryOverwriteReq) == 1))
-)
-  {
-DEBUG((EFI_D_INFO, "IsMemoryOverwriteRequested: Un-controlled Reset 
detected and hence requesting the Memory Clear\n"));
+   if (MOR_CLEAR_MEMORY_VALUE (MemoryOverwriteReq)) {
+DEBUG 

[edk2] [Patch][edk2-platforms/devel-MinnowBoard3] Enable Mor.

2017-01-19 Thread lushifex
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: lushifex 
---
 .../Common/Acpi/AcpiTablesPCAT/Platform.asl|  13 ++--
 .../MemoryTest/NullMemoryTestDxe/NullMemoryTest.c  |  72 -
 .../MemoryTest/NullMemoryTestDxe/NullMemoryTest.h  |   2 +-
 .../NullMemoryTestDxe/NullMemoryTestDxe.inf|   4 +-
 .../NullMemoryTestDxe/NullMemoryTestDxe.uni| Bin 2194 -> 2194 bytes
 .../NullMemoryTestDxe/NullMemoryTestDxeExtra.uni   | Bin 1372 -> 1372 bytes
 .../BroxtonPlatformPkg/PlatformDsc/Components.dsc  |   1 +
 Platform/BroxtonPlatformPkg/PlatformPkg.fdf|   1 +
 8 files changed, 40 insertions(+), 53 deletions(-)

diff --git 
a/Platform/BroxtonPlatformPkg/Common/Acpi/AcpiTablesPCAT/Platform.asl 
b/Platform/BroxtonPlatformPkg/Common/Acpi/AcpiTablesPCAT/Platform.asl
index 7847f2f..04ea3ad 100644
--- a/Platform/BroxtonPlatformPkg/Common/Acpi/AcpiTablesPCAT/Platform.asl
+++ b/Platform/BroxtonPlatformPkg/Common/Acpi/AcpiTablesPCAT/Platform.asl
@@ -1,5 +1,5 @@
 /** @file
-  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -19,7 +19,6 @@ External(PDC1)
 External(PDC2)
 External(PDC3)
 External(\_PR.CPU0._PPC, IntObj)
-External(\_SB.PCI0.LPCB.TPM.PTS, MethodObj)
 Name(ECUP, 1)  // EC State indicator: 1- Normal Mode 0- Low Power Mode
 Mutex(EHLD, 0) // EC Hold indicator: 0- No one accessing the EC Power State 1- 
Someone else is accessing the EC Power State
 
@@ -153,10 +152,12 @@ Method(_PTS,1)
   //clear GPE0_STS
   Store(Ones, G0S)
 
-  //
-  // Call TPM PTS method
-  //
-  \_SB.TPM.PTS (Arg0)
+  If (CondRefOf(\_SB.TPM.PTS)) {
+//
+// Call TPM PTS method
+//
+\_SB.TPM.PTS (Arg0)
+  }
 
   //
   // Set GPIO_116 (SOC_CODEC_IRQ) 20k pull-down for device I2S audio codec 
INT343A before enter S3/S4
diff --git 
a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c
 
b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c
index a3f5971..b506f13 100644
--- 
a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c
+++ 
b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c
@@ -2,7 +2,7 @@
   Implementation of Generic Memory Test Protocol which does not perform real 
memory test.
   Also clears memory when the MemoryOverwriteRequest bit is set.
 
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 
 UINT64mTestedSystemMemory = 0;
 UINT64mTotalSystemMemory  = 0;
@@ -151,19 +150,12 @@ BOOLEAN
 IsMemoryOverwriteRequested (
   )
 {
-  BOOLEAN bRetValue = 0;
-  EFI_STATUS Status;
-  UINT64 MemoryOverwriteReq = 0;
-  UINTN  VariableSize;
-  UINT8  CmosRegValue;
-
-  DEBUG((EFI_D_INFO, "+IsMemoryOverwriteRequested\n"));
+  BOOLEAN bRetValue = 0;
+  EFI_STATUS  Status;
+  UINT64  MemoryOverwriteReq = 0;
+  UINTN   VariableSize;
 
-  //
-  // Read the CMOS Register EFI_CMOS_CLEAN_RESET
-  //
-  IoWrite8(CmosIo_72, EFI_CMOS_CLEAN_RESET);
-  CmosRegValue = IoRead8(CmosIo_73);
+  DEBUG ((EFI_D_INFO, "IsMemoryOverwriteRequested\n"));
 
   //
   // Get the MOR variable
@@ -187,25 +179,18 @@ IsMemoryOverwriteRequested (
   
   );
 } else {
+  MemoryOverwriteReq = 0;
   DEBUG ((EFI_D_ERROR, "IsMemoryOverwriteRequested: Failed to Get MOR 
Variable - Status = %r\n", Status));
 }
 goto Exit;
   }
-
-  DEBUG ((EFI_D_INFO, "IsMemoryOverwriteRequested: MOR Control Value = %02x, 
CmosRegValue = %02x\n", MemoryOverwriteReq, CmosRegValue));
-
-  if ((MOR_CLEAR_MEMORY_VALUE(MemoryOverwriteReq)) &&
-(((CmosRegValue != B_MAGIC_CLEAN_RESET_VALUE) && 
(MOR_DISABLE_AUTO_DETECT_VALUE(MemoryOverwriteReq) == 0)) ||
-(MOR_DISABLE_AUTO_DETECT_VALUE(MemoryOverwriteReq) == 1))
-)
-  {
-DEBUG((EFI_D_INFO, "IsMemoryOverwriteRequested: Un-controlled Reset 
detected and hence requesting the Memory Clear\n"));
+   if (MOR_CLEAR_MEMORY_VALUE (MemoryOverwriteReq)) {
+DEBUG ((EFI_D_INFO, "IsMemoryOverwriteRequested: Un-controlled Reset 
detected and hence requesting the Memory Clear\n"));
 bRetValue = 1;
   }
 
 Exit:
-  IoWrite8(CmosIo_73, B_MAGIC_INIT_VALUE); // Initialize to a known value
-  DEBUG((EFI_D_INFO, "-IsMemoryOverwriteRequested: bRetValue = %d\n", 
bRetValue));
+