diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py index d025f0c2b3..e03d789957 100644 --- a/BaseTools/Source/Python/GenFds/Capsule.py +++ b/BaseTools/Source/Python/GenFds/Capsule.py @@ -1,7 +1,7 @@ ## @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 @@ -141,6 +141,11 @@ class Capsule (CapsuleClassObject) : Content.write(File.read()) File.close() for fmp in self.FmpPayloadList: + if fmp.Existed: + FwMgrHdr.write(pack('=Q', PreSize)) + PreSize += len(fmp.Buffer) + Content.write(fmp.Buffer) + continue if fmp.ImageFile: for Obj in fmp.ImageFile: fmp.ImageFile = Obj.GenCapsuleSubItem() @@ -169,12 +174,12 @@ class Capsule (CapsuleClassObject) : dwLength = 4 + 2 + 2 + 16 + 16 + 256 + 256 fmp.ImageFile = CapOutputTmp AuthData = [fmp.MonotonicCount, dwLength, WIN_CERT_REVISION, WIN_CERT_TYPE_EFI_GUID, fmp.Certificate_Guid] - Buffer = fmp.GenCapsuleSubItem(AuthData) + fmp.Buffer = fmp.GenCapsuleSubItem(AuthData) else: - Buffer = fmp.GenCapsuleSubItem() + fmp.Buffer = fmp.GenCapsuleSubItem() FwMgrHdr.write(pack('=Q', PreSize)) - PreSize += len(Buffer) - Content.write(Buffer) + PreSize += len(fmp.Buffer) + Content.write(fmp.Buffer) BodySize = len(FwMgrHdr.getvalue()) + len(Content.getvalue()) Header.write(pack('=I', HdrSize + BodySize)) # diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py index 24c210d964..5b806d9e44 100644 --- a/BaseTools/Source/Python/GenFds/CapsuleData.py +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py @@ -183,6 +183,8 @@ class CapsulePayload(CapsuleData): self.VendorCodeFile = [] self.Certificate_Guid = None self.MonotonicCount = None + self.Existed = False + self.Buffer = None def GenCapsuleSubItem(self, AuthData=[]): if not self.Version: @@ -239,4 +241,5 @@ class CapsulePayload(CapsuleData): VendorFile = open(self.VendorCodeFile, 'rb') Buffer += VendorFile.read() VendorFile.close() + self.Existed = True return Buffer