]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c
Vlv2TbltDevicePkg/Bds: use Tcg2 instead of TrEE.
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / PlatformBdsLib / BdsPlatform.c
index 903b46d583853f157e085a77241fe9497c42e6a7..e42e82b678b592eb956480a600682b5b62e347ab 100644 (file)
@@ -1,15 +1,15 @@
 /** @file\r
 \r
 /** @file\r
 \r
-  Copyright (c) 2004  - 2014, Intel Corporation. All rights reserved.<BR>\r
-                                                                                   \r\r
-  This program and the accompanying materials are licensed and made available under\r\r
-  the terms and conditions of the BSD License that accompanies this distribution.  \r\r
-  The full text of the license may be found at                                     \r\r
-  http://opensource.org/licenses/bsd-license.php.                                  \r\r
-                                                                                   \r\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,            \r\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r\r
-                                                                                   \r\r
+  Copyright (c) 2004  - 2016, Intel Corporation. All rights reserved.<BR>\r
+                                                                                   \r
+  This program and the accompanying materials are licensed and made available under\r
+  the terms and conditions of the BSD License that accompanies this distribution.  \r
+  The full text of the license may be found at                                     \r
+  http://opensource.org/licenses/bsd-license.php.                                  \r
+                                                                                   \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,            \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+                                                                                   \r
 \r
 \r
 Module Name:\r
 \r
 \r
 Module Name:\r
@@ -27,7 +27,7 @@ Abstract:
 #include "SetupMode.h"\r
 #include <Guid/SetupVariable.h>\r
 #include <Library/TcgPhysicalPresenceLib.h>\r
 #include "SetupMode.h"\r
 #include <Guid/SetupVariable.h>\r
 #include <Library/TcgPhysicalPresenceLib.h>\r
-#include <Library/TrEEPhysicalPresenceLib.h>\r
+#include <Library/Tcg2PhysicalPresenceLib.h>\r
 #include <Protocol/I2cMasterMcg.h>\r
 #include <TianoApi.h>\r
 #include <PlatformBaseAddresses.h>\r
 #include <Protocol/I2cMasterMcg.h>\r
 #include <TianoApi.h>\r
 #include <PlatformBaseAddresses.h>\r
@@ -45,6 +45,9 @@ Abstract:
 #include <Library/GenericBdsLib/String.h>\r
 #include <Library/NetLib.h>\r
 \r
 #include <Library/GenericBdsLib/String.h>\r
 #include <Library/NetLib.h>\r
 \r
+#include <Library/CapsuleLib.h>\r
+#include <Protocol/EsrtManagement.h>\r
+\r
 EFI_GUID *ConnectDriverTable[] = {\r
   &gEfiMmioDeviceProtocolGuid,\r
   &gEfiI2cMasterProtocolGuid,\r
 EFI_GUID *ConnectDriverTable[] = {\r
   &gEfiMmioDeviceProtocolGuid,\r
   &gEfiI2cMasterProtocolGuid,\r
@@ -181,6 +184,11 @@ InstallReadyToLock (
                     );\r
     ASSERT_EFI_ERROR (Status);\r
 \r
                     );\r
     ASSERT_EFI_ERROR (Status);\r
 \r
+    //\r
+    // Signal EndOfDxe PI Event\r
+    //\r
+    EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);\r
+\r
     Handle = NULL;\r
     Status = gBS->InstallProtocolInterface (\r
                     &Handle,\r
     Handle = NULL;\r
     Status = gBS->InstallProtocolInterface (\r
                     &Handle,\r
@@ -209,7 +217,7 @@ ShellImageCallback (
 // BDS Platform Functions\r
 //\r
 /**\r
 // BDS Platform Functions\r
 //\r
 /**\r
-  Platform Bds init. Incude the platform firmware vendor, revision\r
+  Platform Bds init. Include the platform firmware vendor, revision\r
   and so crc check.\r
 \r
   @param VOID\r
   and so crc check.\r
 \r
   @param VOID\r
@@ -305,7 +313,7 @@ GetGopDevicePath (
   }\r
 \r
   //\r
   }\r
 \r
   //\r
-  // Try to connect this handle, so that GOP dirver could start on this\r
+  // Try to connect this handle, so that GOP driver could start on this\r
   // device and create child handles with GraphicsOutput Protocol installed\r
   // on them, then we get device paths of these child handles and select\r
   // them as possible console device.\r
   // device and create child handles with GraphicsOutput Protocol installed\r
   // on them, then we get device paths of these child handles and select\r
   // them as possible console device.\r
@@ -322,7 +330,18 @@ GetGopDevicePath (
                   &VarSize,\r
                   &mSystemConfiguration\r
                   );\r
                   &VarSize,\r
                   &mSystemConfiguration\r
                   );\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {\r
+    //The setup variable is corrupted\r
+    VarSize = sizeof(SYSTEM_CONFIGURATION);\r
+    Status = gRT->GetVariable(\r
+              L"SetupRecovery",\r
+              &gEfiNormalSetupGuid,\r
+              NULL,\r
+              &VarSize,\r
+              &mSystemConfiguration\r
+              );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }    \r
 \r
   if(mSystemConfiguration.BootDisplayDevice != 0x0)\r
   {\r
 \r
   if(mSystemConfiguration.BootDisplayDevice != 0x0)\r
   {\r
@@ -411,7 +430,7 @@ GetGopDevicePath (
         // In current implementation, we only enable one of the child handles\r
         // as console device, i.e. sotre one of the child handle's device\r
         // path to variable "ConOut"\r
         // In current implementation, we only enable one of the child handles\r
         // as console device, i.e. sotre one of the child handle's device\r
         // path to variable "ConOut"\r
-        // In futhure, we could select all child handles to be console device\r
+        // In future, we could select all child handles to be console device\r
         //\r
         *GopDevicePath = TempDevicePath;\r
       }\r
         //\r
         *GopDevicePath = TempDevicePath;\r
       }\r
@@ -624,7 +643,18 @@ PlatformBdsForceActiveVga (
                   &VarSize,\r
                   &mSystemConfiguration\r
                   );\r
                   &VarSize,\r
                   &mSystemConfiguration\r
                   );\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {\r
+    //The setup variable is corrupted\r
+    VarSize = sizeof(SYSTEM_CONFIGURATION);\r
+    Status = gRT->GetVariable(\r
+              L"SetupRecovery",\r
+              &gEfiNormalSetupGuid,\r
+              NULL,\r
+              &VarSize,\r
+              &mSystemConfiguration\r
+              );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }    \r
 \r
 \r
   if ((PlugInPciVgaDevicePath == NULL && OnboardPciVgaDevicePath != NULL) ) {\r
 \r
 \r
   if ((PlugInPciVgaDevicePath == NULL && OnboardPciVgaDevicePath != NULL) ) {\r
@@ -680,7 +710,18 @@ UpdateConsoleResolution(
                   &VarSize,\r
                   &SystemConfiguration\r
                   );\r
                   &VarSize,\r
                   &SystemConfiguration\r
                   );\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {\r
+    //The setup variable is corrupted\r
+    VarSize = sizeof(SYSTEM_CONFIGURATION);\r
+    Status = gRT->GetVariable(\r
+              L"SetupRecovery",\r
+              &gEfiNormalSetupGuid,\r
+              NULL,\r
+              &VarSize,\r
+              &SystemConfiguration\r
+              );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }  \r
 \r
   switch (SystemConfiguration.IgdFlatPanel) {\r
 \r
 \r
   switch (SystemConfiguration.IgdFlatPanel) {\r
 \r
@@ -742,7 +783,7 @@ UpdateConsoleResolution(
   Connect the predefined platform default console device. Always try to find\r
   and enable the vga device if have.\r
 \r
   Connect the predefined platform default console device. Always try to find\r
   and enable the vga device if have.\r
 \r
-  @param PlatformConsole    Predfined platform default console device array.\r
+  @param PlatformConsole    Predefined platform default console device array.\r
 \r
   @retval EFI_SUCCESS       Success connect at least one ConIn and ConOut\r
                             device, there must have one ConOut device is\r
 \r
   @retval EFI_SUCCESS       Success connect at least one ConIn and ConOut\r
                             device, there must have one ConOut device is\r
@@ -781,7 +822,7 @@ PlatformBdsConnectConsole (
   if (VarConout == NULL || VarConin == NULL) {\r
     //\r
     // Have chance to connect the platform default console,\r
   if (VarConout == NULL || VarConin == NULL) {\r
     //\r
     // Have chance to connect the platform default console,\r
-    // the platform default console is the minimue device group\r
+    // the platform default console is the minimum device group\r
     // the platform should support\r
     //\r
     while (PlatformConsole[Index].DevicePath != NULL) {\r
     // the platform should support\r
     //\r
     while (PlatformConsole[Index].DevicePath != NULL) {\r
@@ -828,7 +869,7 @@ PlatformBdsConnectConsole (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Connect with predeined platform connect sequence,\r
+  Connect with predefined platform connect sequence,\r
   the OEM/IBV can customize with their own connect sequence.\r
 \r
   @param None.\r
   the OEM/IBV can customize with their own connect sequence.\r
 \r
   @param None.\r
@@ -1530,7 +1571,7 @@ PlatformBdsLibEnumerateAllBootOption (
 \r
 /**\r
 \r
 \r
 /**\r
 \r
-  The function will excute with as the platform policy, current policy\r
+  The function will execute with as the platform policy, current policy\r
   is driven by boot mode. IBV/OEM can customize this code for their specific\r
   policy action.\r
 \r
   is driven by boot mode. IBV/OEM can customize this code for their specific\r
   policy action.\r
 \r
@@ -1547,7 +1588,7 @@ EFIAPI
 PlatformBdsPolicyBehavior (\r
   IN OUT LIST_ENTRY                  *DriverOptionList,\r
   IN OUT LIST_ENTRY                  *BootOptionList,\r
 PlatformBdsPolicyBehavior (\r
   IN OUT LIST_ENTRY                  *DriverOptionList,\r
   IN OUT LIST_ENTRY                  *BootOptionList,\r
-  IN PROCESS_CAPSULES                ProcessCapsules,\r
+  IN PROCESS_CAPSULES                BdsProcessCapsules,\r
   IN BASEM_MEMORY_TEST               BaseMemoryTest\r
   )\r
 {\r
   IN BASEM_MEMORY_TEST               BaseMemoryTest\r
   )\r
 {\r
@@ -1556,11 +1597,8 @@ PlatformBdsPolicyBehavior (
   EFI_BOOT_MODE                      BootMode;\r
   BOOLEAN                            DeferredImageExist;\r
   UINTN                              Index;\r
   EFI_BOOT_MODE                      BootMode;\r
   BOOLEAN                            DeferredImageExist;\r
   UINTN                              Index;\r
-  CHAR16                             CapsuleVarName[36];\r
-  CHAR16                             *TempVarName;\r
   SYSTEM_CONFIGURATION               SystemConfiguration;\r
   UINTN                              VarSize;\r
   SYSTEM_CONFIGURATION               SystemConfiguration;\r
   UINTN                              VarSize;\r
-  BOOLEAN                            SetVariableFlag;\r
   PLATFORM_PCI_DEVICE_PATH           *EmmcBootDevPath;\r
   EFI_GLOBAL_NVS_AREA_PROTOCOL       *GlobalNvsArea;\r
   EFI_HANDLE                         FvProtocolHandle;\r
   PLATFORM_PCI_DEVICE_PATH           *EmmcBootDevPath;\r
   EFI_GLOBAL_NVS_AREA_PROTOCOL       *GlobalNvsArea;\r
   EFI_HANDLE                         FvProtocolHandle;\r
@@ -1574,8 +1612,14 @@ PlatformBdsPolicyBehavior (
   BOOLEAN                            IsFirstBoot;\r
   UINT16                             *BootOrder;\r
   UINTN                              BootOrderSize;\r
   BOOLEAN                            IsFirstBoot;\r
   UINT16                             *BootOrder;\r
   UINTN                              BootOrderSize;\r
+  ESRT_MANAGEMENT_PROTOCOL           *EsrtManagement;\r
 \r
   Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
 \r
   Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
+  if (Timeout > 10 ) {\r
+    //we think the Timeout variable is corrupted\r
+    Timeout = 10;\r
+  }\r
+\r
   VarSize = sizeof(SYSTEM_CONFIGURATION);\r
   Status = gRT->GetVariable(\r
                   NORMAL_SETUP_NAME,\r
   VarSize = sizeof(SYSTEM_CONFIGURATION);\r
   Status = gRT->GetVariable(\r
                   NORMAL_SETUP_NAME,\r
@@ -1584,8 +1628,18 @@ PlatformBdsPolicyBehavior (
                   &VarSize,\r
                   &SystemConfiguration\r
                   );\r
                   &VarSize,\r
                   &SystemConfiguration\r
                   );\r
-  if (EFI_ERROR (Status)) {\r
-    return;\r
+\r
+  if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {\r
+    //The setup variable is corrupted\r
+    VarSize = sizeof(SYSTEM_CONFIGURATION);\r
+    Status = gRT->GetVariable(\r
+              L"SetupRecovery",\r
+              &gEfiNormalSetupGuid,\r
+              NULL,\r
+              &VarSize,\r
+              &SystemConfiguration\r
+              );\r
+    ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
   //\r
   }\r
 \r
   //\r
@@ -1598,37 +1652,6 @@ PlatformBdsPolicyBehavior (
   //\r
   BootMode = GetBootModeHob();\r
 \r
   //\r
   BootMode = GetBootModeHob();\r
 \r
-  //\r
-  // Clear all the capsule variables CapsuleUpdateData, CapsuleUpdateData1, CapsuleUpdateData2...\r
-  // as early as possible which will avoid the next time boot after the capsule update\r
-  // will still into the capsule loop\r
-  //\r
-  StrCpy (CapsuleVarName, EFI_CAPSULE_VARIABLE_NAME);\r
-  TempVarName = CapsuleVarName + StrLen (CapsuleVarName);\r
-  Index = 0;\r
-  SetVariableFlag = TRUE;\r
-  while (SetVariableFlag) {\r
-    if (Index > 0) {\r
-      UnicodeValueToString (TempVarName, 0, Index, 0);\r
-    }\r
-    Status = gRT->SetVariable (\r
-                    CapsuleVarName,\r
-                    &gEfiCapsuleVendorGuid,\r
-                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS |\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-                    0,\r
-                    (VOID *)NULL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // There is no capsule variables, quit\r
-      //\r
-      SetVariableFlag = FALSE;\r
-      continue;\r
-    }\r
-    Index++;\r
-  }\r
-\r
   //\r
   // No deferred images exist by default\r
   //\r
   //\r
   // No deferred images exist by default\r
   //\r
@@ -1680,6 +1703,11 @@ PlatformBdsPolicyBehavior (
     }\r
   }\r
 \r
     }\r
   }\r
 \r
+  Status = gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtManagement);\r
+  if (EFI_ERROR(Status)) {\r
+    EsrtManagement = NULL;\r
+  }\r
+\r
   switch (BootMode) {\r
 \r
   case BOOT_WITH_MINIMAL_CONFIGURATION:\r
   switch (BootMode) {\r
 \r
   case BOOT_WITH_MINIMAL_CONFIGURATION:\r
@@ -1763,9 +1791,16 @@ PlatformBdsPolicyBehavior (
     }\r
 \r
 \r
     }\r
 \r
 \r
-#ifdef TPM_ENABLED\r
-       TcgPhysicalPresenceLibProcessRequest();\r
-#endif\r
+    #ifdef TPM_ENABLED\r
+    TcgPhysicalPresenceLibProcessRequest();\r
+    #endif\r
+    #ifdef FTPM_ENABLE\r
+    Tcg2PhysicalPresenceLibProcessRequest(NULL);\r
+    #endif\r
+\r
+    if (EsrtManagement != NULL) {\r
+      EsrtManagement->LockEsrtRepository();\r
+    }\r
 \r
     //\r
     // Close boot script and install ready to lock\r
 \r
     //\r
     // Close boot script and install ready to lock\r
@@ -1773,7 +1808,7 @@ PlatformBdsPolicyBehavior (
     InstallReadyToLock ();\r
 \r
     //\r
     InstallReadyToLock ();\r
 \r
     //\r
-    // Give one chance to enter the setup if we \r
+    // Give one chance to enter the setup if we\r
     // select Gummiboot "Reboot Into Firmware Interface" and Fast Boot is enabled.\r
     //\r
     BootIntoFirmwareInterface();\r
     // select Gummiboot "Reboot Into Firmware Interface" and Fast Boot is enabled.\r
     //\r
     BootIntoFirmwareInterface();\r
@@ -1808,6 +1843,10 @@ PlatformBdsPolicyBehavior (
       }\r
     }\r
 \r
       }\r
     }\r
 \r
+    if (EsrtManagement != NULL) {\r
+      EsrtManagement->LockEsrtRepository();\r
+    }\r
+\r
     //\r
     // Close boot script and install ready to lock\r
     //\r
     //\r
     // Close boot script and install ready to lock\r
     //\r
@@ -1832,6 +1871,16 @@ PlatformBdsPolicyBehavior (
     //\r
     PlatformBdsConnectConsole (gPlatformConsole);\r
     PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
     //\r
     PlatformBdsConnectConsole (gPlatformConsole);\r
     PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
+\r
+    DEBUG((DEBUG_INFO, "ProcessCapsules Before EndOfDxe......\n"));\r
+    ProcessCapsules ();\r
+    DEBUG((DEBUG_INFO, "ProcessCapsules Done\n"));\r
+\r
+    //\r
+    // Close boot script and install ready to lock\r
+    //\r
+    InstallReadyToLock ();\r
+\r
     BdsLibConnectAll ();\r
 \r
     //\r
     BdsLibConnectAll ();\r
 \r
     //\r
@@ -1848,12 +1897,13 @@ PlatformBdsPolicyBehavior (
       }\r
     }\r
 \r
       }\r
     }\r
 \r
-    //\r
-    // Close boot script and install ready to lock\r
-    //\r
-    InstallReadyToLock ();\r
+    if (EsrtManagement != NULL) {\r
+      EsrtManagement->SyncEsrtFmp();\r
+    }\r
 \r
 \r
-    ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
+    DEBUG((DEBUG_INFO, "ProcessCapsules After ConnectAll......\n"));\r
+    ProcessCapsules();\r
+    DEBUG((DEBUG_INFO, "ProcessCapsules Done\n"));\r
     break;\r
 \r
   case BOOT_IN_RECOVERY_MODE:\r
     break;\r
 \r
   case BOOT_IN_RECOVERY_MODE:\r
@@ -1951,10 +2001,16 @@ FULL_CONFIGURATION:
         PlatformBdsConnectSequence ();\r
       }\r
     }\r
         PlatformBdsConnectSequence ();\r
       }\r
     }\r
-#ifdef TPM_ENABLED\r
+   #ifdef TPM_ENABLED\r
    TcgPhysicalPresenceLibProcessRequest();\r
    TcgPhysicalPresenceLibProcessRequest();\r
-#endif\r
+   #endif\r
+   #ifdef FTPM_ENABLE\r
+   Tcg2PhysicalPresenceLibProcessRequest(NULL);\r
+   #endif\r
 \r
 \r
+    if (EsrtManagement != NULL) {\r
+      EsrtManagement->SyncEsrtFmp();\r
+    }\r
     //\r
     // Close boot script and install ready to lock\r
     //\r
     //\r
     // Close boot script and install ready to lock\r
     //\r
@@ -1972,7 +2028,7 @@ FULL_CONFIGURATION:
     PlatformBdsEnterFrontPageWithHotKey (Timeout, FALSE);\r
 \r
        //\r
     PlatformBdsEnterFrontPageWithHotKey (Timeout, FALSE);\r
 \r
        //\r
-       // Give one chance to enter the setup if we \r
+       // Give one chance to enter the setup if we\r
        // select Gummiboot "Reboot Into Firmware Interface"\r
        //\r
        BootIntoFirmwareInterface();\r
        // select Gummiboot "Reboot Into Firmware Interface"\r
        //\r
        BootIntoFirmwareInterface();\r
@@ -1990,7 +2046,7 @@ FULL_CONFIGURATION:
       return;\r
     }\r
 \r
       return;\r
     }\r
 \r
-    \r
+\r
     break;\r
   }\r
 \r
     break;\r
   }\r
 \r
@@ -2106,7 +2162,6 @@ BdsLockFv (
   EFI_FV_BLOCK_MAP_ENTRY      *BlockMap;\r
   EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
   EFI_PHYSICAL_ADDRESS        BaseAddress;\r
   EFI_FV_BLOCK_MAP_ENTRY      *BlockMap;\r
   EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
   EFI_PHYSICAL_ADDRESS        BaseAddress;\r
-  UINT8                       Data;\r
   UINT32                      BlockLength;\r
   UINTN                       Index;\r
 \r
   UINT32                      BlockLength;\r
   UINTN                       Index;\r
 \r
@@ -2117,7 +2172,7 @@ BdsLockFv (
   while ((BlockMap->NumBlocks != 0) && (BlockMap->Length != 0)) {\r
     BlockLength = BlockMap->Length;\r
     for (Index = 0; Index < BlockMap->NumBlocks; Index++) {\r
   while ((BlockMap->NumBlocks != 0) && (BlockMap->Length != 0)) {\r
     BlockLength = BlockMap->Length;\r
     for (Index = 0; Index < BlockMap->NumBlocks; Index++) {\r
-      Data = MmioOr8 ((UINTN) BaseAddress, 0x03);\r
+      MmioOr8 ((UINTN) BaseAddress, 0x03);\r
       BaseAddress += BlockLength;\r
     }\r
     BlockMap++;\r
       BaseAddress += BlockLength;\r
     }\r
     BlockMap++;\r
@@ -2356,6 +2411,12 @@ ShowProgressHotKey (
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;\r
   UINT32                        GpioValue;\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;\r
   UINT32                        GpioValue;\r
+  CHAR16                        *TmpStr1;\r
+  CHAR16                        *TmpStr2;\r
+  CHAR16                        *TmpStr3;\r
+  UINTN                         TmpStrSize;\r
+  VOID                          *Buffer;\r
+  UINTN                         Size;\r
 \r
   if (TimeoutDefault == 0) {\r
     return EFI_TIMEOUT;\r
 \r
   if (TimeoutDefault == 0) {\r
     return EFI_TIMEOUT;\r
@@ -2379,10 +2440,76 @@ ShowProgressHotKey (
   SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
   SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
 \r
   SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
   SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
 \r
+  TmpStr2 = NULL;\r
+  TmpStr3 = NULL;\r
+\r
+  //\r
+  // Check if the platform is using test key.\r
+  //\r
+  Status = GetSectionFromAnyFv(\r
+             PcdGetPtr(PcdEdkiiRsa2048Sha256TestPublicKeyFileGuid),\r
+             EFI_SECTION_RAW,\r
+             0,\r
+             &Buffer,\r
+             &Size\r
+             );\r
+  if (!EFI_ERROR(Status)) {\r
+    if ((Size == PcdGetSize(PcdRsa2048Sha256PublicKeyBuffer)) &&\r
+        (CompareMem(Buffer, PcdGetPtr(PcdRsa2048Sha256PublicKeyBuffer), Size) == 0)) {\r
+      TmpStr2 = L"WARNING: Recovery Test Key is used.\r\n";\r
+      if (DebugAssertEnabled()) {\r
+        DEBUG ((DEBUG_INFO, "\n\nWARNING: Recovery Test Key is used.\n"));\r
+      } else {\r
+        SerialPortWrite((UINT8 *)"\n\nWARNING: Recovery Test Key is used.", sizeof("\n\nWARNING: Recovery Test Key is used."));\r
+      }\r
+      PcdSetBoolS(PcdTestKeyUsed, TRUE);\r
+    }\r
+    FreePool(Buffer);\r
+  }\r
+  Status = GetSectionFromAnyFv(\r
+             PcdGetPtr(PcdEdkiiPkcs7TestPublicKeyFileGuid),\r
+             EFI_SECTION_RAW,\r
+             0,\r
+             &Buffer,\r
+             &Size\r
+             );\r
+  if (!EFI_ERROR(Status)) {\r
+    if ((Size == PcdGetSize(PcdPkcs7CertBuffer)) &&\r
+        (CompareMem(Buffer, PcdGetPtr(PcdPkcs7CertBuffer), Size) == 0)) {\r
+      TmpStr3 = L"WARNING: Capsule Test Key is used.\r\n";\r
+      if (DebugAssertEnabled()) {\r
+        DEBUG ((DEBUG_INFO, "\n\nWARNING: Capsule Test Key is used.\r\n"));\r
+      } else {\r
+        SerialPortWrite((UINT8 *)"\n\nWARNING: Capsule Test Key is used.", sizeof("\n\nWARNING: Capsule Test Key is used."));\r
+      }\r
+      PcdSetBoolS(PcdTestKeyUsed, TRUE);\r
+    }\r
+    FreePool(Buffer);\r
+  }\r
+\r
   //\r
   // Clear the progress status bar first\r
   //\r
   //\r
   // Clear the progress status bar first\r
   //\r
-  TmpStr = L"Start boot option, Press <F2> or <DEL> to enter setup page.";\r
+  TmpStr1 = L"Start boot option, Press <F2> or <DEL> to enter setup page.\r\n";\r
+  TmpStrSize = StrSize(TmpStr1);\r
+  if (TmpStr2 != NULL) {\r
+    TmpStrSize += StrSize(TmpStr2);\r
+  }\r
+  if (TmpStr3 != NULL) {\r
+    TmpStrSize += StrSize(TmpStr3);\r
+  }\r
+  TmpStr = AllocatePool (TmpStrSize);\r
+  if (TmpStr == NULL) {\r
+    TmpStr = TmpStr1;\r
+  } else {\r
+    StrCpyS(TmpStr, TmpStrSize/sizeof(CHAR16), TmpStr1);\r
+    if (TmpStr2 != NULL) {\r
+      StrCatS(TmpStr, TmpStrSize/sizeof(CHAR16), TmpStr2);\r
+    }\r
+    if (TmpStr3 != NULL) {\r
+      StrCatS(TmpStr, TmpStrSize/sizeof(CHAR16), TmpStr3);\r
+    }\r
+  }\r
   PlatformBdsShowProgress (Foreground, Background, TmpStr, Color, 0, 0);\r
 \r
   TimeoutRemain = TimeoutDefault;\r
   PlatformBdsShowProgress (Foreground, Background, TmpStr, Color, 0, 0);\r
 \r
   TimeoutRemain = TimeoutDefault;\r
@@ -2783,7 +2910,7 @@ PlatformBdsConnectSimpleConsole (
   if (VarConout == NULL || VarConin == NULL) {\r
     //\r
     // Have chance to connect the platform default console,\r
   if (VarConout == NULL || VarConin == NULL) {\r
     //\r
     // Have chance to connect the platform default console,\r
-    // the platform default console is the minimue device group\r
+    // the platform default console is the minimum device group\r
     // the platform should support\r
     //\r
     while (PlatformConsole[Index].DevicePath != NULL) {\r
     // the platform should support\r
     //\r
     while (PlatformConsole[Index].DevicePath != NULL) {\r