From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 452131A1EC7 for ; Wed, 21 Sep 2016 19:40:59 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP; 21 Sep 2016 19:40:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,376,1470726000"; d="scan'208";a="1043979409" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga001.fm.intel.com with ESMTP; 21 Sep 2016 19:40:58 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 21 Sep 2016 19:40:58 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 21 Sep 2016 19:40:58 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.118]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.96]) with mapi id 14.03.0248.002; Thu, 22 Sep 2016 10:40:54 +0800 From: "Wei, David" To: "Yao, Jiewen" , "edk2-devel@lists.01.org" CC: "Tian, Feng" , "Zeng, Star" , "Kinney, Michael D" , "Gao, Liming" , "Zhang, Chao B" , "Wei, David" Thread-Topic: [PATCH 42/45] Vlv2TbltDevicePkg/PlatformBootManager: Add capsule/recovery handling. Thread-Index: AQHSE9QhzIJvGlQmpUGAtj6Aub/53KCEw28A Date: Thu, 22 Sep 2016 02:40:54 +0000 Message-ID: <89954A0B46707A448411A627AD4EEE3466379ED2@SHSMSX101.ccr.corp.intel.com> References: <1474440326-9292-1-git-send-email-jiewen.yao@intel.com> <1474440326-9292-43-git-send-email-jiewen.yao@intel.com> In-Reply-To: <1474440326-9292-43-git-send-email-jiewen.yao@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDgyNjc4NWEtZWE3NS00YzlkLTk1NmMtMjI5YzRiOWZiMDUyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InNRRHpQeFY2SXd1a1BKbmV1em9WZWRrTElyM01DYXhXTFlwYk4zbUtMcE09In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 42/45] Vlv2TbltDevicePkg/PlatformBootManager: Add capsule/recovery handling. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Sep 2016 02:40:59 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: David Wei =20 Thanks, David Wei =20 -----Original Message----- From: Yao, Jiewen=20 Sent: Wednesday, September 21, 2016 2:45 PM To: edk2-devel@lists.01.org Cc: Wei, David ; Tian, Feng ; Zen= g, Star ; Kinney, Michael D ; Gao, Liming ; Zhang, Chao B Subject: [PATCH 42/45] Vlv2TbltDevicePkg/PlatformBootManager: Add capsule/r= ecovery handling. Add capsule and recovery boot path handling in platform BDS. Cc: David Wei Cc: Feng Tian Cc: Star Zeng Cc: Michael D Kinney Cc: Liming Gao Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao --- Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c | 117 ++++++++= ++---------- Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf | 2 + 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c b/Vlv2T= bltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c index 02e4616..580d774 100644 --- a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c +++ b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c @@ -1,15 +1,15 @@ /** @file =20 Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
- = =20 - This program and the accompanying materials are licensed and made availa= ble under - the terms and conditions of the BSD License that accompanies this distri= bution. =20 - The full text of the license may be found at = =20 - http://opensource.org/licenses/bsd-license.php. = =20 - = =20 - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, = =20 - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. =20 - = =20 + = =20 + This program and the accompanying materials are licensed and made availa= ble under + the terms and conditions of the BSD License that accompanies this distri= bution. =20 + The full text of the license may be found at = =20 + http://opensource.org/licenses/bsd-license.php. = =20 + = =20 + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, = =20 + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. =20 + = =20 =20 =20 Module Name: @@ -45,6 +45,9 @@ Abstract: #include #include =20 +#include +#include + EFI_GUID *ConnectDriverTable[] =3D { &gEfiMmioDeviceProtocolGuid, &gEfiI2cMasterProtocolGuid, @@ -181,6 +184,11 @@ InstallReadyToLock ( ); ASSERT_EFI_ERROR (Status); =20 + // + // Signal EndOfDxe PI Event + // + EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid); + Handle =3D NULL; Status =3D gBS->InstallProtocolInterface ( &Handle, @@ -226,11 +234,6 @@ PlatformBdsInit ( EFI_STATUS Status; EFI_EVENT ShellImageEvent; EFI_GUID ShellEnvProtocol =3D SHELL_ENVIRONMENT_INTERFACE_PROTOCOL; - =20 - // - // Signal EndOfDxe PI Event - // - EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid); =20 #ifdef __GNUC__ SerialPortWrite((UINT8 *)">>>>BdsEntry[GCC]\r\n", 19); @@ -1585,7 +1588,7 @@ EFIAPI PlatformBdsPolicyBehavior ( IN OUT LIST_ENTRY *DriverOptionList, IN OUT LIST_ENTRY *BootOptionList, - IN PROCESS_CAPSULES ProcessCapsules, + IN PROCESS_CAPSULES BdsProcessCapsules, IN BASEM_MEMORY_TEST BaseMemoryTest ) { @@ -1594,11 +1597,8 @@ PlatformBdsPolicyBehavior ( EFI_BOOT_MODE BootMode; BOOLEAN DeferredImageExist; UINTN Index; - CHAR16 CapsuleVarName[36]; - CHAR16 *TempVarName; SYSTEM_CONFIGURATION SystemConfiguration; UINTN VarSize; - BOOLEAN SetVariableFlag; PLATFORM_PCI_DEVICE_PATH *EmmcBootDevPath; EFI_GLOBAL_NVS_AREA_PROTOCOL *GlobalNvsArea; EFI_HANDLE FvProtocolHandle; @@ -1612,13 +1612,14 @@ PlatformBdsPolicyBehavior ( BOOLEAN IsFirstBoot; UINT16 *BootOrder; UINTN BootOrderSize; + ESRT_MANAGEMENT_PROTOCOL *EsrtManagement; =20 Timeout =3D PcdGet16 (PcdPlatformBootTimeOut); if (Timeout > 10 ) { //we think the Timeout variable is corrupted Timeout =3D 10; } - =09 + VarSize =3D sizeof(SYSTEM_CONFIGURATION); Status =3D gRT->GetVariable( NORMAL_SETUP_NAME, @@ -1639,7 +1640,7 @@ PlatformBdsPolicyBehavior ( &SystemConfiguration ); ASSERT_EFI_ERROR (Status); - } =20 + } =20 // // Load the driver option as the driver option list @@ -1652,37 +1653,6 @@ PlatformBdsPolicyBehavior ( BootMode =3D GetBootModeHob(); =20 // - // Clear all the capsule variables CapsuleUpdateData, CapsuleUpdateData1= , CapsuleUpdateData2... - // as early as possible which will avoid the next time boot after the ca= psule update - // will still into the capsule loop - // - StrCpy (CapsuleVarName, EFI_CAPSULE_VARIABLE_NAME); - TempVarName =3D CapsuleVarName + StrLen (CapsuleVarName); - Index =3D 0; - SetVariableFlag =3D TRUE; - while (SetVariableFlag) { - if (Index > 0) { - UnicodeValueToString (TempVarName, 0, Index, 0); - } - Status =3D gRT->SetVariable ( - CapsuleVarName, - &gEfiCapsuleVendorGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCES= S | - EFI_VARIABLE_BOOTSERVICE_ACCESS, - 0, - (VOID *)NULL - ); - if (EFI_ERROR (Status)) { - // - // There is no capsule variables, quit - // - SetVariableFlag =3D FALSE; - continue; - } - Index++; - } - - // // No deferred images exist by default // DeferredImageExist =3D FALSE; @@ -1733,6 +1703,11 @@ PlatformBdsPolicyBehavior ( } } =20 + Status =3D gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID= **)&EsrtManagement); + if (EFI_ERROR(Status)) { + EsrtManagement =3D NULL; + } + switch (BootMode) { =20 case BOOT_WITH_MINIMAL_CONFIGURATION: @@ -1822,13 +1797,18 @@ PlatformBdsPolicyBehavior ( #ifdef FTPM_ENABLE TrEEPhysicalPresenceLibProcessRequest(NULL); #endif + + if (EsrtManagement !=3D NULL) { + EsrtManagement->LockEsrtRepository(); + } + // // Close boot script and install ready to lock // InstallReadyToLock (); =20 // - // Give one chance to enter the setup if we=20 + // Give one chance to enter the setup if we // select Gummiboot "Reboot Into Firmware Interface" and Fast Boot is = enabled. // BootIntoFirmwareInterface(); @@ -1863,6 +1843,10 @@ PlatformBdsPolicyBehavior ( } } =20 + if (EsrtManagement !=3D NULL) { + EsrtManagement->LockEsrtRepository(); + } + // // Close boot script and install ready to lock // @@ -1887,6 +1871,16 @@ PlatformBdsPolicyBehavior ( // PlatformBdsConnectConsole (gPlatformConsole); PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest); + + DEBUG((EFI_D_INFO, "ProcessCapsules Before EndOfDxe......\n")); + ProcessCapsules (); + DEBUG((EFI_D_INFO, "ProcessCapsules Done\n")); + + // + // Close boot script and install ready to lock + // + InstallReadyToLock (); + BdsLibConnectAll (); =20 // @@ -1903,12 +1897,13 @@ PlatformBdsPolicyBehavior ( } } =20 - // - // Close boot script and install ready to lock - // - InstallReadyToLock (); + if (EsrtManagement !=3D NULL) { + EsrtManagement->SyncEsrtFmp(); + } =20 - ProcessCapsules (BOOT_ON_FLASH_UPDATE); + DEBUG((EFI_D_INFO, "ProcessCapsules After ConnectAll......\n")); + ProcessCapsules(); + DEBUG((EFI_D_INFO, "ProcessCapsules Done\n")); break; =20 case BOOT_IN_RECOVERY_MODE: @@ -2012,6 +2007,10 @@ FULL_CONFIGURATION: #ifdef FTPM_ENABLE TrEEPhysicalPresenceLibProcessRequest(NULL); #endif + + if (EsrtManagement !=3D NULL) { + EsrtManagement->SyncEsrtFmp(); + } // // Close boot script and install ready to lock // @@ -2029,7 +2028,7 @@ FULL_CONFIGURATION: PlatformBdsEnterFrontPageWithHotKey (Timeout, FALSE); =20 // - // Give one chance to enter the setup if we=20 + // Give one chance to enter the setup if we // select Gummiboot "Reboot Into Firmware Interface" // BootIntoFirmwareInterface(); @@ -2047,7 +2046,7 @@ FULL_CONFIGURATION: return; } =20 - =20 + break; } =20 diff --git a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf b/= Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf index c64bab9..ce7c426 100644 --- a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf +++ b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf @@ -72,6 +72,7 @@ FileHandleLib S3BootScriptLib SerialPortLib + CapsuleLib =20 [Protocols] gEfiFirmwareVolume2ProtocolGuid @@ -90,6 +91,7 @@ gEfiMmioDeviceProtocolGuid gEfiI2cMasterProtocolGuid gEfiI2cHostProtocolGuid + gEsrtManagementProtocolGuid =20 [Guids] gEfiMemoryTypeInformationGuid --=20 2.7.4.windows.1