X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FCapsule.py;h=9332f016f7da8db4d4727fa650f82cafd2269751;hb=1563349a967d7e02c43492ba853babb9c660a083;hp=93ecee10c63f254e7bc5b71e6a3f1892c06f1a78;hpb=a07901418affc8d357ad319c6dec993cc00d6915;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py
index 93ecee10c6..9332f016f7 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,7 +141,17 @@ class Capsule (CapsuleClassObject) :
Content.write(File.read())
File.close()
for fmp in self.FmpPayloadList:
- Buffer = fmp.GenCapsuleSubItem()
+ 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()
+ if fmp.VendorCodeFile:
+ for Obj in fmp.VendorCodeFile:
+ fmp.VendorCodeFile = Obj.GenCapsuleSubItem()
if fmp.Certificate_Guid:
ExternalTool, ExternalOption = FindExtendTool([], GenFdsGlobalVariable.ArchList, fmp.Certificate_Guid)
CmdOption = ''
@@ -149,7 +159,7 @@ class Capsule (CapsuleClassObject) :
if not os.path.isabs(fmp.ImageFile):
CapInputFile = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, fmp.ImageFile)
CapOutputTmp = os.path.join(GenFdsGlobalVariable.FvDir, self.UiCapsuleName) + '.tmp'
- if ExternalTool == None:
+ if ExternalTool is None:
EdkLogger.error("GenFds", GENFDS_ERROR, "No tool found with GUID %s" % fmp.Certificate_Guid)
else:
CmdOption += ExternalTool
@@ -162,33 +172,14 @@ class Capsule (CapsuleClassObject) :
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('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):
- TmpFile = open(CapOutputTmp, 'rb')
- Buffer += TmpFile.read()
- TmpFile.close()
- if fmp.VendorCodeFile:
- VendorFile = open(fmp.VendorCodeFile, 'rb')
- Buffer += VendorFile.read()
- VendorFile.close()
- FwMgrHdr.write(pack('=Q', PreSize))
- PreSize += len(Buffer)
- Content.write(Buffer)
+ fmp.ImageFile = CapOutputTmp
+ AuthData = [fmp.MonotonicCount, dwLength, WIN_CERT_REVISION, WIN_CERT_TYPE_EFI_GUID, fmp.Certificate_Guid]
+ fmp.Buffer = fmp.GenCapsuleSubItem(AuthData)
else:
- 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(Buffer)
- Content.write(Buffer)
+ fmp.Buffer = fmp.GenCapsuleSubItem()
+ FwMgrHdr.write(pack('=Q', PreSize))
+ PreSize += len(fmp.Buffer)
+ Content.write(fmp.Buffer)
BodySize = len(FwMgrHdr.getvalue()) + len(Content.getvalue())
Header.write(pack('=I', HdrSize + BodySize))
#