BaseTools: add capsule image header for auth FMP capsule file

in last commit 91ae29, it missed to add the
EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER for the auth FMP capsule.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Yonghong Zhu 2016-08-22 15:08:24 +08:00
parent 4977810b0f
commit a07901418a
2 changed files with 11 additions and 14 deletions

View File

@ -141,6 +141,7 @@ class Capsule (CapsuleClassObject) :
Content.write(File.read()) Content.write(File.read())
File.close() File.close()
for fmp in self.FmpPayloadList: for fmp in self.FmpPayloadList:
Buffer = fmp.GenCapsuleSubItem()
if fmp.Certificate_Guid: if fmp.Certificate_Guid:
ExternalTool, ExternalOption = FindExtendTool([], GenFdsGlobalVariable.ArchList, fmp.Certificate_Guid) ExternalTool, ExternalOption = FindExtendTool([], GenFdsGlobalVariable.ArchList, fmp.Certificate_Guid)
CmdOption = '' CmdOption = ''
@ -161,7 +162,7 @@ class Capsule (CapsuleClassObject) :
dwLength = 4 + 2 + 2 + 16 + os.path.getsize(CapOutputTmp) - os.path.getsize(CapInputFile) dwLength = 4 + 2 + 2 + 16 + os.path.getsize(CapOutputTmp) - os.path.getsize(CapInputFile)
else: else:
dwLength = 4 + 2 + 2 + 16 + 16 + 256 + 256 dwLength = 4 + 2 + 2 + 16 + 16 + 256 + 256
Buffer = pack('Q', fmp.MonotonicCount) Buffer += pack('Q', fmp.MonotonicCount)
Buffer += pack('I', dwLength) Buffer += pack('I', dwLength)
Buffer += pack('H', WIN_CERT_REVISION) Buffer += pack('H', WIN_CERT_REVISION)
Buffer += pack('H', WIN_CERT_TYPE_EFI_GUID) Buffer += pack('H', WIN_CERT_TYPE_EFI_GUID)
@ -178,10 +179,16 @@ class Capsule (CapsuleClassObject) :
PreSize += len(Buffer) PreSize += len(Buffer)
Content.write(Buffer) Content.write(Buffer)
else: 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)) FwMgrHdr.write(pack('=Q', PreSize))
PreSize += len(payload) PreSize += len(Buffer)
Content.write(payload) Content.write(Buffer)
BodySize = len(FwMgrHdr.getvalue()) + len(Content.getvalue()) BodySize = len(FwMgrHdr.getvalue()) + len(Content.getvalue())
Header.write(pack('=I', HdrSize + BodySize)) Header.write(pack('=I', HdrSize + BodySize))
# #

View File

@ -216,14 +216,4 @@ class CapsulePayload(CapsuleData):
VendorFileSize, VendorFileSize,
int(self.HardwareInstance, 16) 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 return Buffer