]> 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 580d774d293f5d2981b8373e65f3eb6516c278af..e42e82b678b592eb956480a600682b5b62e347ab 100644 (file)
@@ -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
@@ -217,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
@@ -313,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
@@ -430,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
@@ -783,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
@@ -822,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
@@ -869,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
@@ -1571,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
@@ -1795,7 +1795,7 @@ PlatformBdsPolicyBehavior (
     TcgPhysicalPresenceLibProcessRequest();\r
     #endif\r
     #ifdef FTPM_ENABLE\r
     TcgPhysicalPresenceLibProcessRequest();\r
     #endif\r
     #ifdef FTPM_ENABLE\r
-    TrEEPhysicalPresenceLibProcessRequest(NULL);\r
+    Tcg2PhysicalPresenceLibProcessRequest(NULL);\r
     #endif\r
 \r
     if (EsrtManagement != NULL) {\r
     #endif\r
 \r
     if (EsrtManagement != NULL) {\r
@@ -1872,9 +1872,9 @@ PlatformBdsPolicyBehavior (
     PlatformBdsConnectConsole (gPlatformConsole);\r
     PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
 \r
     PlatformBdsConnectConsole (gPlatformConsole);\r
     PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
 \r
-    DEBUG((EFI_D_INFO, "ProcessCapsules Before EndOfDxe......\n"));\r
+    DEBUG((DEBUG_INFO, "ProcessCapsules Before EndOfDxe......\n"));\r
     ProcessCapsules ();\r
     ProcessCapsules ();\r
-    DEBUG((EFI_D_INFO, "ProcessCapsules Done\n"));\r
+    DEBUG((DEBUG_INFO, "ProcessCapsules Done\n"));\r
 \r
     //\r
     // Close boot script and install ready to lock\r
 \r
     //\r
     // Close boot script and install ready to lock\r
@@ -1901,9 +1901,9 @@ PlatformBdsPolicyBehavior (
       EsrtManagement->SyncEsrtFmp();\r
     }\r
 \r
       EsrtManagement->SyncEsrtFmp();\r
     }\r
 \r
-    DEBUG((EFI_D_INFO, "ProcessCapsules After ConnectAll......\n"));\r
+    DEBUG((DEBUG_INFO, "ProcessCapsules After ConnectAll......\n"));\r
     ProcessCapsules();\r
     ProcessCapsules();\r
-    DEBUG((EFI_D_INFO, "ProcessCapsules Done\n"));\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
@@ -2005,7 +2005,7 @@ FULL_CONFIGURATION:
    TcgPhysicalPresenceLibProcessRequest();\r
    #endif\r
    #ifdef FTPM_ENABLE\r
    TcgPhysicalPresenceLibProcessRequest();\r
    #endif\r
    #ifdef FTPM_ENABLE\r
-   TrEEPhysicalPresenceLibProcessRequest(NULL);\r
+   Tcg2PhysicalPresenceLibProcessRequest(NULL);\r
    #endif\r
 \r
     if (EsrtManagement != NULL) {\r
    #endif\r
 \r
     if (EsrtManagement != NULL) {\r
@@ -2411,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
@@ -2434,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
@@ -2838,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