From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 591EB1A1DF8 for ; Mon, 22 Aug 2016 00:23:37 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 22 Aug 2016 00:23:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,558,1464678000"; d="scan'208";a="1029372340" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.144]) by fmsmga001.fm.intel.com with ESMTP; 22 Aug 2016 00:23:36 -0700 From: Yonghong Zhu To: edk2-devel@lists.01.org Cc: Liming Gao Date: Mon, 22 Aug 2016 15:23:33 +0800 Message-Id: <1471850613-93368-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [Patch] BaseTools: add capsule image header for auth FMP capsule file 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: Mon, 22 Aug 2016 07:23:37 -0000 in last commit 91ae29, it missed to add the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER for the auth FMP capsule. 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 | 10 ---------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py index f8af12a..93ecee1 100644 --- a/BaseTools/Source/Python/GenFds/Capsule.py +++ b/BaseTools/Source/Python/GenFds/Capsule.py @@ -139,10 +139,11 @@ class Capsule (CapsuleClassObject) : PreSize += os.path.getsize(FileName) File = open(FileName, 'rb') Content.write(File.read()) File.close() for fmp in self.FmpPayloadList: + Buffer = fmp.GenCapsuleSubItem() if fmp.Certificate_Guid: ExternalTool, ExternalOption = FindExtendTool([], GenFdsGlobalVariable.ArchList, fmp.Certificate_Guid) CmdOption = '' CapInputFile = fmp.ImageFile if not os.path.isabs(fmp.ImageFile): @@ -159,11 +160,11 @@ class Capsule (CapsuleClassObject) : GenFdsGlobalVariable.CallExternalTool(CmdList, "Failed to generate FMP auth capsule") if uuid.UUID(fmp.Certificate_Guid) == EFI_CERT_TYPE_PKCS7_GUID: dwLength = 4 + 2 + 2 + 16 + os.path.getsize(CapOutputTmp) - os.path.getsize(CapInputFile) else: dwLength = 4 + 2 + 2 + 16 + 16 + 256 + 256 - Buffer = pack('Q', fmp.MonotonicCount) + Buffer += pack('Q', fmp.MonotonicCount) Buffer += pack('I', dwLength) Buffer += pack('H', WIN_CERT_REVISION) Buffer += pack('H', WIN_CERT_TYPE_EFI_GUID) Buffer += uuid.UUID(fmp.Certificate_Guid).get_bytes_le() if os.path.exists(CapOutputTmp): @@ -176,14 +177,20 @@ class Capsule (CapsuleClassObject) : VendorFile.close() FwMgrHdr.write(pack('=Q', PreSize)) PreSize += len(Buffer) Content.write(Buffer) else: - payload = fmp.GenCapsuleSubItem() + ImageFile = open(fmp.ImageFile, 'rb') + Buffer += ImageFile.read() + ImageFile.close() + if fmp.VendorCodeFile: + VendorFile = open(fmp.VendorCodeFile, 'rb') + Buffer += VendorFile.read() + VendorFile.close() FwMgrHdr.write(pack('=Q', PreSize)) - PreSize += len(payload) - Content.write(payload) + PreSize += len(Buffer) + Content.write(Buffer) BodySize = len(FwMgrHdr.getvalue()) + len(Content.getvalue()) Header.write(pack('=I', 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 2a5c454..5d5a1e4 100644 --- a/BaseTools/Source/Python/GenFds/CapsuleData.py +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py @@ -214,16 +214,6 @@ class CapsulePayload(CapsuleData): 0, ImageFileSize, VendorFileSize, int(self.HardwareInstance, 16) ) - # - # Append file content to the structure - # - ImageFile = open(self.ImageFile, 'rb') - Buffer += ImageFile.read() - ImageFile.close() - if self.VendorCodeFile: - VendorFile = open(self.VendorCodeFile, 'rb') - Buffer += VendorFile.read() - VendorFile.close() return Buffer -- 2.6.1.windows.1