]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Vlv2TbltDevicePkg/PlatformBootManager: Add capsule/recovery handling.
authorYao, Jiewen <jiewen.yao@intel.com>
Wed, 21 Sep 2016 06:45:23 +0000 (14:45 +0800)
committerdavid wei <david.wei@intel.com>
Thu, 27 Oct 2016 06:26:27 +0000 (14:26 +0800)
Add capsule and recovery boot path handling in platform BDS.

Cc: David Wei <david.wei@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c
Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf

index e1f3524efa1bd73dacbcfb5c3ad4708e159999d8..580d774d293f5d2981b8373e65f3eb6516c278af 100644 (file)
@@ -1,15 +1,15 @@
 /** @file\r
 \r
   Copyright (c) 2004  - 2016, 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
+                                                                                   \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
@@ -45,6 +45,9 @@ Abstract:
 #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
@@ -1585,7 +1588,7 @@ EFIAPI
 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
@@ -1594,11 +1597,8 @@ PlatformBdsPolicyBehavior (
   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
-  BOOLEAN                            SetVariableFlag;\r
   PLATFORM_PCI_DEVICE_PATH           *EmmcBootDevPath;\r
   EFI_GLOBAL_NVS_AREA_PROTOCOL       *GlobalNvsArea;\r
   EFI_HANDLE                         FvProtocolHandle;\r
@@ -1612,13 +1612,14 @@ PlatformBdsPolicyBehavior (
   BOOLEAN                            IsFirstBoot;\r
   UINT16                             *BootOrder;\r
   UINTN                              BootOrderSize;\r
+  ESRT_MANAGEMENT_PROTOCOL           *EsrtManagement;\r
 \r
   Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
   if (Timeout > 10 ) {\r
     //we think the Timeout variable is corrupted\r
     Timeout = 10;\r
   }\r
-       \r
+\r
   VarSize = sizeof(SYSTEM_CONFIGURATION);\r
   Status = gRT->GetVariable(\r
                   NORMAL_SETUP_NAME,\r
@@ -1639,7 +1640,7 @@ PlatformBdsPolicyBehavior (
               &SystemConfiguration\r
               );\r
     ASSERT_EFI_ERROR (Status);\r
-  }  \r
+  }\r
 \r
   //\r
   // Load the driver option as the driver option list\r
@@ -1651,37 +1652,6 @@ PlatformBdsPolicyBehavior (
   //\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
@@ -1733,6 +1703,11 @@ PlatformBdsPolicyBehavior (
     }\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
@@ -1822,13 +1797,18 @@ PlatformBdsPolicyBehavior (
     #ifdef FTPM_ENABLE\r
     TrEEPhysicalPresenceLibProcessRequest(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
     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
@@ -1863,6 +1843,10 @@ PlatformBdsPolicyBehavior (
       }\r
     }\r
 \r
+    if (EsrtManagement != NULL) {\r
+      EsrtManagement->LockEsrtRepository();\r
+    }\r
+\r
     //\r
     // Close boot script and install ready to lock\r
     //\r
@@ -1887,6 +1871,16 @@ PlatformBdsPolicyBehavior (
     //\r
     PlatformBdsConnectConsole (gPlatformConsole);\r
     PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
+\r
+    DEBUG((EFI_D_INFO, "ProcessCapsules Before EndOfDxe......\n"));\r
+    ProcessCapsules ();\r
+    DEBUG((EFI_D_INFO, "ProcessCapsules Done\n"));\r
+\r
+    //\r
+    // Close boot script and install ready to lock\r
+    //\r
+    InstallReadyToLock ();\r
+\r
     BdsLibConnectAll ();\r
 \r
     //\r
@@ -1903,12 +1897,13 @@ PlatformBdsPolicyBehavior (
       }\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
-    ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
+    DEBUG((EFI_D_INFO, "ProcessCapsules After ConnectAll......\n"));\r
+    ProcessCapsules();\r
+    DEBUG((EFI_D_INFO, "ProcessCapsules Done\n"));\r
     break;\r
 \r
   case BOOT_IN_RECOVERY_MODE:\r
@@ -2012,6 +2007,10 @@ FULL_CONFIGURATION:
    #ifdef FTPM_ENABLE\r
    TrEEPhysicalPresenceLibProcessRequest(NULL);\r
    #endif\r
+\r
+    if (EsrtManagement != NULL) {\r
+      EsrtManagement->SyncEsrtFmp();\r
+    }\r
     //\r
     // Close boot script and install ready to lock\r
     //\r
@@ -2029,7 +2028,7 @@ FULL_CONFIGURATION:
     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
@@ -2047,7 +2046,7 @@ FULL_CONFIGURATION:
       return;\r
     }\r
 \r
-    \r
+\r
     break;\r
   }\r
 \r
index c64bab9d52ad57c491748c2bdeb6aba59c83edc2..ce7c42696ccc87984488d4246e25f74d6e7c5498 100644 (file)
@@ -72,6 +72,7 @@
   FileHandleLib\r
   S3BootScriptLib\r
   SerialPortLib\r
+  CapsuleLib\r
 \r
 [Protocols]\r
   gEfiFirmwareVolume2ProtocolGuid\r
@@ -90,6 +91,7 @@
   gEfiMmioDeviceProtocolGuid\r
   gEfiI2cMasterProtocolGuid\r
   gEfiI2cHostProtocolGuid\r
+  gEsrtManagementProtocolGuid\r
 \r
 [Guids]\r
   gEfiMemoryTypeInformationGuid\r