]> git.proxmox.com Git - mirror_edk2.git/commitdiff
QuarkPlatformPkg/PlatformInit: Fix recovery detection issues
authorMichael Kinney <michael.d.kinney@intel.com>
Mon, 3 Oct 2016 18:13:42 +0000 (11:13 -0700)
committerMichael Kinney <michael.d.kinney@intel.com>
Fri, 7 Oct 2016 22:00:21 +0000 (15:00 -0700)
https://bugzilla.tianocore.org/show_bug.cgi?id=137
https://bugzilla.tianocore.org/show_bug.cgi?id=139

There are four supported methods to generate a boot mode of
BOOT_IN_RECOVERY_MODE on the Galileo platforms:

* Detect a corrupt FV
* Detect a forced recovery from the ForceRecovery UEFI application
  that sets a bit in a sticky R/W register
* The RESET button for the Arduino shield is held while the system
  is powered up
* The RESET button for the Arduino shield is held while the system
  is rebooted using the REBOOT button.

The logic in the PlatformInit module is cleaned up and updated to
support all three of the recovery detection methods.  The clean
ups include:

* Remove extra debug messages
* Remove user input from serial port

In addition, once one of the recovery methods is detected and a
boot mode of BOOT_IN_RECOVERY_MODE is set, the Galileo platforms
would get an error attempting to use the USB host controller to
detect and read a recovery image from a USB drive.  The issue is
the IMR protection registers are programmed to prevent DMA to
memory owned by the PEI Core. The IMR register programming is
updated to allow DMA to memory that is allocated by the recovery
modules using the PEI AllocatePages() service.

Cc: Kelly Steele <kelly.steele@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Kelly Steele <kelly.steele@intel.com>
QuarkPlatformPkg/Platform/Pei/PlatformInit/BootMode.c
QuarkPlatformPkg/Platform/Pei/PlatformInit/CommonHeader.h
QuarkPlatformPkg/Platform/Pei/PlatformInit/MrcWrapper.c
QuarkPlatformPkg/Platform/Pei/PlatformInit/MrcWrapper.h
QuarkPlatformPkg/Platform/Pei/PlatformInit/PlatformEarlyInit.c
QuarkPlatformPkg/Platform/Pei/PlatformInit/PlatformEarlyInit.inf

index 0dd3d24cf37d2274ebbf8d9edbfb7077e9afecd5..215f8f03b32c123b4c28145bc90353b893019ef8 100644 (file)
@@ -119,19 +119,6 @@ ValidateFvHeader (
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-\r
-  Check whether go to recovery path\r
-  @retval TRUE  Go to recovery path\r
-  @retval FALSE Go to normal path\r
-\r
-**/\r
-BOOLEAN\r
-OemRecoveryBootMode ()\r
-{\r
-  return PlatformIsBootWithRecoveryStage1 ();\r
-}\r
-\r
 /**\r
   Peform the boot mode determination logic\r
   If the box is closed, then\r
 /**\r
   Peform the boot mode determination logic\r
   If the box is closed, then\r
@@ -154,31 +141,35 @@ UpdateBootMode (
   EFI_STATUS          Status;\r
   EFI_BOOT_MODE       NewBootMode;\r
   PEI_CAPSULE_PPI     *Capsule;\r
   EFI_STATUS          Status;\r
   EFI_BOOT_MODE       NewBootMode;\r
   PEI_CAPSULE_PPI     *Capsule;\r
-  CHAR8               UserSelection;\r
-  UINT32              Straps32;\r
+  UINT32              RegValue;\r
+\r
+  NewBootMode = *BootMode;\r
 \r
   //\r
 \r
   //\r
-  // Read Straps. Used later if recovery boot.\r
+  // Read Sticky R/W Bits\r
   //\r
   //\r
-  Straps32 = QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID, QUARK_SCSS_SOC_UNIT_STPDDRCFG);\r
+  RegValue = QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID, QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW);\r
+  DEBUG ((EFI_D_ERROR, "RegValue = %08x\n", RegValue));\r
 \r
   //\r
   // Check if we need to boot in recovery mode\r
   //\r
 \r
   //\r
   // Check if we need to boot in recovery mode\r
   //\r
-  if ((ValidateFvHeader (BootMode) != EFI_SUCCESS)) {\r
-    DEBUG ((EFI_D_INFO, "Force Boot mode recovery\n"));\r
+  if ((RegValue & B_CFG_STICKY_RW_FORCE_RECOVERY) != 0) {\r
     NewBootMode = BOOT_IN_RECOVERY_MODE;\r
     NewBootMode = BOOT_IN_RECOVERY_MODE;\r
-    Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);\r
-    ASSERT_EFI_ERROR (Status);\r
-    if (OemRecoveryBootMode () == FALSE) {\r
-      DEBUG ((EFI_D_INFO, "Recovery stage1 not Active, reboot to activate recovery stage1 image\n"));\r
-      OemInitiateRecoveryAndWait ();\r
-    }\r
-  } else if (OemRecoveryBootMode ()) {\r
-    DEBUG ((EFI_D_INFO, "Boot mode recovery\n"));\r
+    DEBUG ((EFI_D_ERROR, "RECOVERY from sticky bit\n"));;\r
+\r
+    //\r
+    // Clear force recovery sticky bit\r
+    //\r
+    QNCAltPortWrite (\r
+      QUARK_SCSS_SOC_UNIT_SB_PORT_ID,\r
+      QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW,\r
+      RegValue &(~B_CFG_STICKY_RW_FORCE_RECOVERY)\r
+      );\r
+\r
+  } else if (ValidateFvHeader (BootMode) != EFI_SUCCESS) {\r
     NewBootMode = BOOT_IN_RECOVERY_MODE;\r
     NewBootMode = BOOT_IN_RECOVERY_MODE;\r
-    Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);\r
-    ASSERT_EFI_ERROR (Status);\r
+    DEBUG ((EFI_D_ERROR, "RECOVERY from corrupt FV\n"));;\r
   } else if (QNCCheckS3AndClearState ()) {\r
     //\r
     // Determine if we're in capsule update mode\r
   } else if (QNCCheckS3AndClearState ()) {\r
     //\r
     // Determine if we're in capsule update mode\r
@@ -217,41 +208,17 @@ UpdateBootMode (
       NewBootMode = BOOT_WITH_FULL_CONFIGURATION;\r
     }\r
   }\r
       NewBootMode = BOOT_WITH_FULL_CONFIGURATION;\r
     }\r
   }\r
-  *BootMode = NewBootMode;\r
-  Status = PeiServicesSetBootMode (NewBootMode);\r
-  ASSERT_EFI_ERROR (Status);\r
 \r
 \r
-  //\r
-  // If Recovery Boot then prompt the user to insert a USB key with recovery nodule and\r
-  // continue with the recovery. Also give the user a chance to retry a normal boot.\r
-  //\r
   if (NewBootMode == BOOT_IN_RECOVERY_MODE) {\r
   if (NewBootMode == BOOT_IN_RECOVERY_MODE) {\r
-    if ((Straps32 & B_STPDDRCFG_FORCE_RECOVERY) == 0) {\r
-      DEBUG ((EFI_D_ERROR, "*****************************************************************\n"));\r
-      DEBUG ((EFI_D_ERROR, "*****           Force Recovery Jumper Detected.             *****\n"));\r
-      DEBUG ((EFI_D_ERROR, "*****      Attempting auto recovery of system flash.        *****\n"));\r
-      DEBUG ((EFI_D_ERROR, "*****   Expecting USB key with recovery module connected.   *****\n"));\r
-      DEBUG ((EFI_D_ERROR, "*****         PLEASE REMOVE FORCE RECOVERY JUMPER.          *****\n"));\r
-      DEBUG ((EFI_D_ERROR, "*****************************************************************\n"));\r
-    } else {\r
-      DEBUG ((EFI_D_ERROR, "*****************************************************************\n"));\r
-      DEBUG ((EFI_D_ERROR, "*****           ERROR: System boot failure!!!!!!!           *****\n"));\r
-      DEBUG ((EFI_D_ERROR, "***** - Press 'R' if you wish to force system recovery      *****\n"));\r
-      DEBUG ((EFI_D_ERROR, "*****     (connect USB key with recovery module first)      *****\n"));\r
-      DEBUG ((EFI_D_ERROR, "***** - Press any other key to attempt another boot         *****\n"));\r
-      DEBUG ((EFI_D_ERROR, "*****************************************************************\n"));\r
-\r
-      UserSelection = PlatformDebugPortGetChar8 ();\r
-      if ((UserSelection != 'R') && (UserSelection != 'r')) {\r
-        DEBUG ((EFI_D_ERROR, "New boot attempt selected........\n"));\r
-        //\r
-        // Initialte the cold reset\r
-        //\r
-        ResetCold ();\r
-      }\r
-      DEBUG ((EFI_D_ERROR, "Recovery boot selected..........\n"));\r
-    }\r
+    DEBUG ((EFI_D_INFO, "Boot mode recovery\n"));\r
+    Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);\r
+    ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
   }\r
 \r
+  Status = PeiServicesSetBootMode (NewBootMode);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  *BootMode = NewBootMode;\r
+\r
   return EFI_SUCCESS;\r
 }\r
   return EFI_SUCCESS;\r
 }\r
index 98284958a4151eced3235d5c655753489cea42fc..983095a8d18b2c97afbce9681f91db8a8038b5e0 100644 (file)
@@ -67,7 +67,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/IntelQNCLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/SmbusLib.h>\r
 #include <Library/IntelQNCLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/SmbusLib.h>\r
-#include <Library/RecoveryOemHookLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/ResetSystemLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/ResetSystemLib.h>\r
@@ -82,4 +81,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Register/Cpuid.h>\r
 \r
 \r
 #include <Register/Cpuid.h>\r
 \r
+#include <Pcal9555.h>\r
+#include <QNCAccess.h>\r
+\r
 #endif\r
 #endif\r
index 6b07d7829328b5abed4d47679ece7b3f9585d7e1..7b7ca61817e94fec66b57484e694cf3aceb8a816 100644 (file)
@@ -554,7 +554,6 @@ InstallEfiMemory (
   UINT64                                PeiMemoryLength;\r
   UINTN                                 BufferSize;\r
   UINTN                                 PeiMemoryIndex;\r
   UINT64                                PeiMemoryLength;\r
   UINTN                                 BufferSize;\r
   UINTN                                 PeiMemoryIndex;\r
-  UINTN                                 RequiredMemSize;\r
   EFI_RESOURCE_ATTRIBUTE_TYPE           Attribute;\r
   EFI_PHYSICAL_ADDRESS                  BadMemoryAddress;\r
   EFI_SMRAM_DESCRIPTOR                  DescriptorAcpiVariable;\r
   EFI_RESOURCE_ATTRIBUTE_TYPE           Attribute;\r
   EFI_PHYSICAL_ADDRESS                  BadMemoryAddress;\r
   EFI_SMRAM_DESCRIPTOR                  DescriptorAcpiVariable;\r
@@ -613,12 +612,6 @@ InstallEfiMemory (
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  //\r
-  // Get required memory size for ACPI use. This helps to put ACPI memory on the topest\r
-  //\r
-  RequiredMemSize = 0;\r
-  RetriveRequiredMemorySize (PeiServices, &RequiredMemSize);\r
-\r
   //\r
   // Detect MOR request by the OS.\r
   //\r
   //\r
   // Detect MOR request by the OS.\r
   //\r
@@ -735,15 +728,14 @@ InstallEfiMemory (
   //\r
   Status = SetPlatformImrPolicy (\r
               PeiMemoryBaseAddress,\r
   //\r
   Status = SetPlatformImrPolicy (\r
               PeiMemoryBaseAddress,\r
-              PeiMemoryLength,\r
-              RequiredMemSize\r
+              PeiMemoryLength\r
               );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   // Carve out the top memory reserved for ACPI\r
   //\r
               );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   // Carve out the top memory reserved for ACPI\r
   //\r
-  Status        = PeiServicesInstallPeiMemory (PeiMemoryBaseAddress, (PeiMemoryLength - RequiredMemSize));\r
+  Status        = PeiServicesInstallPeiMemory (PeiMemoryBaseAddress, PeiMemoryLength);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   BuildResourceDescriptorHob (\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   BuildResourceDescriptorHob (\r
@@ -1073,69 +1065,6 @@ InstallS3Memory (
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-\r
-  This function returns the size, in bytes, required for the DXE phase.\r
-\r
-  @param  PeiServices    PEI Services table.\r
-  @param  Size           Pointer to the size, in bytes, required for the DXE phase.\r
-\r
-  @return  None\r
-\r
-**/\r
-VOID\r
-RetriveRequiredMemorySize (\r
-  IN      EFI_PEI_SERVICES                  **PeiServices,\r
-  OUT     UINTN                             *Size\r
-  )\r
-{\r
-  EFI_PEI_HOB_POINTERS           Hob;\r
-  EFI_MEMORY_TYPE_INFORMATION    *MemoryData;\r
-  UINT8                          Index;\r
-  UINTN                          TempPageNum;\r
-\r
-  MemoryData  = NULL;\r
-  TempPageNum = 0;\r
-  Index       = 0;\r
-\r
-  PeiServicesGetHobList ((VOID **)&Hob.Raw);\r
-  while (!END_OF_HOB_LIST (Hob)) {\r
-    if (Hob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION &&\r
-        CompareGuid (&Hob.Guid->Name, &gEfiMemoryTypeInformationGuid)\r
-          ) {\r
-      MemoryData = (EFI_MEMORY_TYPE_INFORMATION *) (Hob.Raw + sizeof (EFI_HOB_GENERIC_HEADER) + sizeof (EFI_GUID));\r
-      break;\r
-    }\r
-\r
-    Hob.Raw = GET_NEXT_HOB (Hob);\r
-  }\r
-  //\r
-  // Platform PEIM should supply such a information. Generic PEIM doesn't assume any default value\r
-  //\r
-  if (!MemoryData) {\r
-    return ;\r
-  }\r
-\r
-  while (MemoryData[Index].Type != EfiMaxMemoryType) {\r
-    //\r
-    // Accumulate default memory size requirements\r
-    //\r
-    TempPageNum += MemoryData[Index].NumberOfPages;\r
-    Index++;\r
-  }\r
-\r
-  if (TempPageNum == 0) {\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Add additional pages used by DXE memory manager\r
-  //\r
-  (*Size) = (TempPageNum + EDKII_DXE_MEM_SIZE_PAGES) * EFI_PAGE_SIZE;\r
-\r
-  return ;\r
-}\r
-\r
 /**\r
 \r
   This function returns the memory ranges to be enabled, along with information\r
 /**\r
 \r
   This function returns the memory ranges to be enabled, along with information\r
@@ -1481,7 +1410,6 @@ Done:
 \r
   @param  PeiMemoryBaseAddress  Base address of memory allocated for PEI.\r
   @param  PeiMemoryLength       Length in bytes of the PEI memory (includes ACPI memory).\r
 \r
   @param  PeiMemoryBaseAddress  Base address of memory allocated for PEI.\r
   @param  PeiMemoryLength       Length in bytes of the PEI memory (includes ACPI memory).\r
-  @param  RequiredMemSize       Size in bytes of the ACPI/Runtime memory\r
 \r
   @return EFI_SUCCESS           The function completed successfully.\r
           EFI_ACCESS_DENIED     Access to IMRs failed.\r
 \r
   @return EFI_SUCCESS           The function completed successfully.\r
           EFI_ACCESS_DENIED     Access to IMRs failed.\r
@@ -1490,8 +1418,7 @@ Done:
 EFI_STATUS\r
 SetPlatformImrPolicy (\r
   IN      EFI_PHYSICAL_ADDRESS    PeiMemoryBaseAddress,\r
 EFI_STATUS\r
 SetPlatformImrPolicy (\r
   IN      EFI_PHYSICAL_ADDRESS    PeiMemoryBaseAddress,\r
-  IN      UINT64                  PeiMemoryLength,\r
-  IN      UINTN                   RequiredMemSize\r
+  IN      UINT64                  PeiMemoryLength\r
   )\r
 {\r
   UINT8         Index;\r
   )\r
 {\r
   UINT8         Index;\r
@@ -1514,17 +1441,6 @@ SetPlatformImrPolicy (
     }\r
   }\r
 \r
     }\r
   }\r
 \r
-  //\r
-  // Add IMR0 protection for the 'PeiMemory'\r
-  //\r
-  QncImrWrite (\r
-            QUARK_NC_MEMORY_MANAGER_IMR0,\r
-            (UINT32)(((RShiftU64(PeiMemoryBaseAddress, 8)) & IMRL_MASK) | IMR_EN),\r
-            (UINT32)((RShiftU64((PeiMemoryBaseAddress+PeiMemoryLength-RequiredMemSize + EFI_PAGES_TO_SIZE(EDKII_DXE_MEM_SIZE_PAGES-1) - 1), 8)) & IMRL_MASK),\r
-            (UINT32)(CPU_SNOOP + CPU0_NON_SMM),\r
-            (UINT32)(CPU_SNOOP + CPU0_NON_SMM)\r
-        );\r
-\r
   //\r
   // Add IMR2 protection for shadowed RMU binary.\r
   //\r
   //\r
   // Add IMR2 protection for shadowed RMU binary.\r
   //\r
@@ -1547,28 +1463,6 @@ SetPlatformImrPolicy (
             (UINT32)(CPU_SNOOP + CPU0_NON_SMM)\r
         );\r
 \r
             (UINT32)(CPU_SNOOP + CPU0_NON_SMM)\r
         );\r
 \r
-  //\r
-  // Add IMR5 protection for the legacy S3 and AP Startup Vector region (below 1MB).\r
-  //\r
-  QncImrWrite (\r
-            QUARK_NC_MEMORY_MANAGER_IMR5,\r
-            (UINT32)(((RShiftU64(AP_STARTUP_VECTOR, 8)) & IMRL_MASK) | IMR_EN),\r
-            (UINT32)((RShiftU64((AP_STARTUP_VECTOR + EFI_PAGE_SIZE - 1), 8)) & IMRH_MASK),\r
-            (UINT32)(CPU_SNOOP + CPU0_NON_SMM),\r
-            (UINT32)(CPU_SNOOP + CPU0_NON_SMM)\r
-        );\r
-\r
-  //\r
-  // Add IMR6 protection for the ACPI Reclaim/ACPI/Runtime Services.\r
-  //\r
-  QncImrWrite (\r
-            QUARK_NC_MEMORY_MANAGER_IMR6,\r
-            (UINT32)(((RShiftU64((PeiMemoryBaseAddress+PeiMemoryLength-RequiredMemSize+EFI_PAGES_TO_SIZE(EDKII_DXE_MEM_SIZE_PAGES-1)), 8)) & IMRL_MASK) | IMR_EN),\r
-            (UINT32)((RShiftU64((PeiMemoryBaseAddress+PeiMemoryLength-EFI_PAGE_SIZE-1), 8)) & IMRH_MASK),\r
-            (UINT32)(CPU_SNOOP + CPU0_NON_SMM),\r
-            (UINT32)(CPU_SNOOP + CPU0_NON_SMM)\r
-        );\r
-\r
   //\r
   // Enable IMR4 protection of eSRAM.\r
   //\r
   //\r
   // Enable IMR4 protection of eSRAM.\r
   //\r
index d2bcf5728e89c19b51efce787f1eed5dcdf6215d..2bb845f763a6c94936979de1ac161d74083a3825 100644 (file)
@@ -29,8 +29,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define ACPI_RECLAIM_SIZE_PAGES           0x20\r
 #define EDKII_DXE_MEM_SIZE_PAGES          0x20\r
 \r
 #define ACPI_RECLAIM_SIZE_PAGES           0x20\r
 #define EDKII_DXE_MEM_SIZE_PAGES          0x20\r
 \r
-#define AP_STARTUP_VECTOR                 0x00097000\r
-\r
 //\r
 // Maximum number of "Socket Sets", where a "Socket Set is a set of matching\r
 // DIMM's from the various channels\r
 //\r
 // Maximum number of "Socket Sets", where a "Socket Set is a set of matching\r
 // DIMM's from the various channels\r
@@ -185,12 +183,6 @@ SaveConfig (
   IN      MRCParams_t                      *MrcData\r
   );\r
 \r
   IN      MRCParams_t                      *MrcData\r
   );\r
 \r
-VOID\r
-RetriveRequiredMemorySize (\r
-  IN      EFI_PEI_SERVICES                  **PeiServices,\r
-  OUT     UINTN                             *Size\r
-  );\r
-\r
 EFI_STATUS\r
 GetMemoryMap (\r
   IN     EFI_PEI_SERVICES                                    **PeiServices,\r
 EFI_STATUS\r
 GetMemoryMap (\r
   IN     EFI_PEI_SERVICES                                    **PeiServices,\r
@@ -225,8 +217,7 @@ BaseMemoryTest (
 EFI_STATUS\r
 SetPlatformImrPolicy (\r
   IN      EFI_PHYSICAL_ADDRESS    PeiMemoryBaseAddress,\r
 EFI_STATUS\r
 SetPlatformImrPolicy (\r
   IN      EFI_PHYSICAL_ADDRESS    PeiMemoryBaseAddress,\r
-  IN      UINT64                  PeiMemoryLength,\r
-  IN      UINTN                   RequiredMemSize\r
+  IN      UINT64                  PeiMemoryLength\r
   );\r
 \r
 VOID\r
   );\r
 \r
 VOID\r
index 756cc4a7a33337e0d50600c972588fbcd6ffe256..0f71b1fda21d9e18bfd688d568bf372474170f03 100644 (file)
@@ -200,7 +200,8 @@ SetLanControllerMacAddr (
 **/\r
 EFI_STATUS\r
 EarlyPlatformConfigGpioExpanders (\r
 **/\r
 EFI_STATUS\r
 EarlyPlatformConfigGpioExpanders (\r
-  IN CONST EFI_PLATFORM_TYPE              PlatformType\r
+  IN CONST EFI_PLATFORM_TYPE              PlatformType,\r
+  EFI_BOOT_MODE                           BootMode\r
   )\r
 {\r
   EFI_STATUS              Status;\r
   )\r
 {\r
   EFI_STATUS              Status;\r
@@ -266,6 +267,30 @@ EarlyPlatformConfigGpioExpanders (
       GALILEO_GEN2_IOEXP2_7BIT_SLAVE_ADDR,  // IO Expander 2.\r
       15                                    // P1-7.\r
       );\r
       GALILEO_GEN2_IOEXP2_7BIT_SLAVE_ADDR,  // IO Expander 2.\r
       15                                    // P1-7.\r
       );\r
+\r
+    if (BootMode != BOOT_IN_RECOVERY_MODE) {\r
+      //\r
+      // Read state of Reset Button - EXP2.P1_7\r
+      // This GPIO is pulled high when the button is not pressed\r
+      // This GPIO reads low when button is pressed\r
+      //\r
+      if (!PlatformPcal9555GpioGetState (\r
+             GALILEO_GEN2_IOEXP2_7BIT_SLAVE_ADDR,  // IO Expander 2\r
+             15                                    // P1-7\r
+             )) {\r
+        DEBUG ((EFI_D_INFO, "  Force Recovery mode and reset\n"));\r
+\r
+        //\r
+        // Set 'B_CFG_STICKY_RW_FORCE_RECOVERY' sticky bit so we know we need to do a recovery following warm reset\r
+        //\r
+        QNCAltPortWrite (\r
+          QUARK_SCSS_SOC_UNIT_SB_PORT_ID,\r
+          QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW,\r
+          QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID, QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW) | B_CFG_STICKY_RW_FORCE_RECOVERY\r
+          );\r
+        ResetWarm();\r
+      }\r
+    }\r
   }\r
 \r
   //\r
   }\r
 \r
   //\r
@@ -393,6 +418,40 @@ EarlyPlatformConfigGpioExpanders (
       &Buffer\r
       );\r
     ASSERT_EFI_ERROR (Status);\r
       &Buffer\r
       );\r
     ASSERT_EFI_ERROR (Status);\r
+\r
+    if (BootMode != BOOT_IN_RECOVERY_MODE) {\r
+      //\r
+      // Read state of RESET_N_SHLD (GPORT5_BIT0)\r
+      //\r
+      Buffer[1] = 5;\r
+      Length = 1;\r
+      ReadLength = 1;\r
+      Status = I2cReadMultipleByte (\r
+                 I2CSlaveAddress,\r
+                 EfiI2CSevenBitAddrMode,\r
+                 &Length,\r
+                 &ReadLength,\r
+                 &Buffer[1]\r
+                 );\r
+      ASSERT_EFI_ERROR (Status);\r
+\r
+      //\r
+      // Return the state of GPORT5_BIT0\r
+      //\r
+      if ((Buffer[1] & BIT0) == 0) {\r
+        DEBUG ((EFI_D_INFO, "  Force Recovery mode and reset\n"));\r
+\r
+        //\r
+        // Set 'B_CFG_STICKY_RW_FORCE_RECOVERY' sticky bit so we know we need to do a recovery following warm reset\r
+        //\r
+        QNCAltPortWrite (\r
+          QUARK_SCSS_SOC_UNIT_SB_PORT_ID,\r
+          QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW,\r
+          QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID, QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW) | B_CFG_STICKY_RW_FORCE_RECOVERY\r
+          );\r
+        ResetWarm();\r
+      }\r
+    }\r
   }\r
 \r
   return EFI_SUCCESS;\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -514,7 +573,7 @@ PeiInitPlatform (
   //\r
   //\r
   DEBUG ((EFI_D_INFO, "EarlyPlatformConfigGpioExpanders ()\n"));\r
   //\r
   //\r
   DEBUG ((EFI_D_INFO, "EarlyPlatformConfigGpioExpanders ()\n"));\r
-  EarlyPlatformConfigGpioExpanders (PlatformType);\r
+  EarlyPlatformConfigGpioExpanders (PlatformType, BootMode);\r
 \r
   //\r
   // Now that all of the pre-permanent memory activities have\r
 \r
   //\r
   // Now that all of the pre-permanent memory activities have\r
@@ -791,8 +850,8 @@ EarlyPlatformInit (
   //\r
   if (CheckForResetDueToErrors (TRUE)) {\r
     if(FeaturePcdGet (WaitIfResetDueToError)) {\r
   //\r
   if (CheckForResetDueToErrors (TRUE)) {\r
     if(FeaturePcdGet (WaitIfResetDueToError)) {\r
-      DEBUG ((EFI_D_ERROR, "Press any key to continue.\n"));\r
-      PlatformDebugPortGetChar8 ();\r
+      DEBUG ((EFI_D_ERROR, "Wait 10 seconds.\n"));\r
+      MicroSecondDelay(10000000);\r
     }\r
   }\r
 \r
     }\r
   }\r
 \r
index 1de8efd33e1f411e076099d8b2176c7dce0af69b..5fc85d352e42e6c0165a0316546b99e1d2ab4e18 100644 (file)
@@ -88,7 +88,6 @@
   ResetSystemLib\r
   PrintLib\r
   TimerLib\r
   ResetSystemLib\r
   PrintLib\r
   TimerLib\r
-  RecoveryOemHookLib\r
   PcdLib\r
   IntelQNCLib\r
   ReportStatusCodeLib\r
   PcdLib\r
   IntelQNCLib\r
   ReportStatusCodeLib\r