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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 319D820082E60 for ; Tue, 6 Jun 2017 19:49:27 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2017 19:50:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,309,1493708400"; d="scan'208";a="1138721739" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 06 Jun 2017 19:50:33 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 6 Jun 2017 19:50:33 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.146]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0319.002; Wed, 7 Jun 2017 10:50:32 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] BaseTools: Fix the bug use same FMP_PAYLOAD in different capsule file Thread-Index: AQHS3swsa9K3XL3qgE2HIE9E+Lms7KIYtAuw Date: Wed, 7 Jun 2017 02:50:31 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D7467A8@shsmsx102.ccr.corp.intel.com> References: <1496757143-14088-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1496757143-14088-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Fix the bug use same FMP_PAYLOAD in different capsule file X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jun 2017 02:49:27 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Zhu, Yonghong >Sent: Tuesday, June 06, 2017 9:52 PM >To: edk2-devel@lists.01.org >Cc: Gao, Liming >Subject: [Patch] BaseTools: Fix the bug use same FMP_PAYLOAD in different >capsule file > >Fix the bug that use same FMP_PAYLOAD in different capsule file. Because >in previous FMP generation, the FMP already be generated, so we don't >need to regenerate again. > >Cc: Liming Gao >Contributed-under: TianoCore Contribution Agreement 1.0 >Signed-off-by: Yonghong Zhu >--- > BaseTools/Source/Python/GenFds/Capsule.py | 15 ++++++++++----- > BaseTools/Source/Python/GenFds/CapsuleData.py | 3 +++ > 2 files changed, 13 insertions(+), 5 deletions(-) > >diff --git a/BaseTools/Source/Python/GenFds/Capsule.py >b/BaseTools/Source/Python/GenFds/Capsule.py >index d025f0c..e03d789 100644 >--- a/BaseTools/Source/Python/GenFds/Capsule.py >+++ b/BaseTools/Source/Python/GenFds/Capsule.py >@@ -1,9 +1,9 @@ > ## @file > # generate capsule > # >-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
>+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
> # > # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the = BSD >License > # which accompanies this distribution. The full text of the license may= be >found at > # http://opensource.org/licenses/bsd-license.php >@@ -139,10 +139,15 @@ class Capsule (CapsuleClassObject) : > PreSize +=3D os.path.getsize(FileName) > File =3D open(FileName, 'rb') > Content.write(File.read()) > File.close() > for fmp in self.FmpPayloadList: >+ if fmp.Existed: >+ FwMgrHdr.write(pack('=3DQ', PreSize)) >+ PreSize +=3D len(fmp.Buffer) >+ Content.write(fmp.Buffer) >+ continue > if fmp.ImageFile: > for Obj in fmp.ImageFile: > fmp.ImageFile =3D Obj.GenCapsuleSubItem() > if fmp.VendorCodeFile: > for Obj in fmp.VendorCodeFile: >@@ -167,16 +172,16 @@ class Capsule (CapsuleClassObject) : > dwLength =3D 4 + 2 + 2 + 16 + os.path.getsize(CapOutp= utTmp) - >os.path.getsize(CapInputFile) > else: > dwLength =3D 4 + 2 + 2 + 16 + 16 + 256 + 256 > fmp.ImageFile =3D CapOutputTmp > AuthData =3D [fmp.MonotonicCount, dwLength, WIN_CERT_REVI= SION, >WIN_CERT_TYPE_EFI_GUID, fmp.Certificate_Guid] >- Buffer =3D fmp.GenCapsuleSubItem(AuthData) >+ fmp.Buffer =3D fmp.GenCapsuleSubItem(AuthData) > else: >- Buffer =3D fmp.GenCapsuleSubItem() >+ fmp.Buffer =3D fmp.GenCapsuleSubItem() > FwMgrHdr.write(pack('=3DQ', PreSize)) >- PreSize +=3D len(Buffer) >- Content.write(Buffer) >+ PreSize +=3D len(fmp.Buffer) >+ Content.write(fmp.Buffer) > BodySize =3D len(FwMgrHdr.getvalue()) + len(Content.getvalue()) > Header.write(pack('=3DI', HdrSize + BodySize)) > # > # The real capsule header structure is 28 bytes > # >diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py >b/BaseTools/Source/Python/GenFds/CapsuleData.py >index 24c210d..5b806d9 100644 >--- a/BaseTools/Source/Python/GenFds/CapsuleData.py >+++ b/BaseTools/Source/Python/GenFds/CapsuleData.py >@@ -181,10 +181,12 @@ class CapsulePayload(CapsuleData): > self.HardwareInstance =3D None > self.ImageFile =3D [] > self.VendorCodeFile =3D [] > self.Certificate_Guid =3D None > self.MonotonicCount =3D None >+ self.Existed =3D False >+ self.Buffer =3D None > > def GenCapsuleSubItem(self, AuthData=3D[]): > if not self.Version: > self.Version =3D '0x00000002' > if not self.ImageIndex: >@@ -237,6 +239,7 @@ class CapsulePayload(CapsuleData): > ImageFile.close() > if self.VendorCodeFile: > VendorFile =3D open(self.VendorCodeFile, 'rb') > Buffer +=3D VendorFile.read() > VendorFile.close() >+ self.Existed =3D True > return Buffer >-- >2.6.1.windows.1