BaseTools: Extend FMP to support FV statement and FD statement

This patch extend the <FmpFileData> to support <FvStatements> and
<FdStatenents>, just like the normal [Capsule] section format.
In order to fix the bug https://bugzilla.tianocore.org/show_bug.cgi?id=132

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-10-09 09:30:06 +08:00
parent ac9f5a295c
commit 19e3aa7a8a
3 changed files with 53 additions and 16 deletions

View File

@ -141,6 +141,12 @@ 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:
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: if fmp.Certificate_Guid:
ExternalTool, ExternalOption = FindExtendTool([], GenFdsGlobalVariable.ArchList, fmp.Certificate_Guid) ExternalTool, ExternalOption = FindExtendTool([], GenFdsGlobalVariable.ArchList, fmp.Certificate_Guid)
CmdOption = '' CmdOption = ''

View File

@ -179,8 +179,8 @@ class CapsulePayload(CapsuleData):
self.ImageTypeId = None self.ImageTypeId = None
self.ImageIndex = None self.ImageIndex = None
self.HardwareInstance = None self.HardwareInstance = None
self.ImageFile = None self.ImageFile = []
self.VendorCodeFile = None self.VendorCodeFile = []
self.Certificate_Guid = None self.Certificate_Guid = None
self.MonotonicCount = None self.MonotonicCount = None

View File

@ -3259,15 +3259,12 @@ class FdfParser:
FmpKeyList.remove('MONOTONIC_COUNT') FmpKeyList.remove('MONOTONIC_COUNT')
if FmpKeyList: if FmpKeyList:
raise Warning("Missing keywords %s in FMP payload section." % ', '.join(FmpKeyList), self.FileName, self.CurrentLineNumber) raise Warning("Missing keywords %s in FMP payload section." % ', '.join(FmpKeyList), self.FileName, self.CurrentLineNumber)
ImageFile = self.__ParseRawFileStatement() # get the Image file and Vendor code file
if not ImageFile: self.__GetFMPCapsuleData(FmpData)
if not FmpData.ImageFile:
raise Warning("Missing image file in FMP payload section.", self.FileName, self.CurrentLineNumber) raise Warning("Missing image file in FMP payload section.", self.FileName, self.CurrentLineNumber)
FmpData.ImageFile = ImageFile # check whether more than one Vendor code file
VendorCodeFile = self.__ParseRawFileStatement() if len(FmpData.VendorCodeFile) > 1:
if VendorCodeFile:
FmpData.VendorCodeFile = VendorCodeFile
AdditionalFile = self.__ParseRawFileStatement()
if AdditionalFile:
raise Warning("At most one Image file and one Vendor code file are allowed in FMP payload section.", self.FileName, self.CurrentLineNumber) raise Warning("At most one Image file and one Vendor code file are allowed in FMP payload section.", self.FileName, self.CurrentLineNumber)
self.Profile.FmpPayloadDict[FmpUiName] = FmpData self.Profile.FmpPayloadDict[FmpUiName] = FmpData
return True return True
@ -3400,6 +3397,22 @@ class FdfParser:
if not (IsInf or IsFile or IsFv or IsFd or IsAnyFile or IsAfile or IsFmp): if not (IsInf or IsFile or IsFv or IsFd or IsAnyFile or IsAfile or IsFmp):
break break
## __GetFMPCapsuleData() method
#
# Get capsule data for FMP capsule
#
# @param self The object pointer
# @param Obj for whom capsule data are got
#
def __GetFMPCapsuleData(self, Obj):
while True:
IsFv = self.__GetFvStatement(Obj, True)
IsFd = self.__GetFdStatement(Obj, True)
IsAnyFile = self.__GetAnyFileStatement(Obj, True)
if not (IsFv or IsFd or IsAnyFile):
break
## __GetFvStatement() method ## __GetFvStatement() method
# #
# Get FV for capsule # Get FV for capsule
@ -3409,7 +3422,7 @@ class FdfParser:
# @retval True Successfully find a FV statement # @retval True Successfully find a FV statement
# @retval False Not able to find a FV statement # @retval False Not able to find a FV statement
# #
def __GetFvStatement(self, CapsuleObj): def __GetFvStatement(self, CapsuleObj, FMPCapsule = False):
if not self.__IsKeyword("FV"): if not self.__IsKeyword("FV"):
return False return False
@ -3425,6 +3438,12 @@ class FdfParser:
CapsuleFv = CapsuleData.CapsuleFv() CapsuleFv = CapsuleData.CapsuleFv()
CapsuleFv.FvName = self.__Token CapsuleFv.FvName = self.__Token
if FMPCapsule:
if not CapsuleObj.ImageFile:
CapsuleObj.ImageFile.append(CapsuleFv)
else:
CapsuleObj.VendorCodeFile.append(CapsuleFv)
else:
CapsuleObj.CapsuleDataList.append(CapsuleFv) CapsuleObj.CapsuleDataList.append(CapsuleFv)
return True return True
@ -3437,7 +3456,7 @@ class FdfParser:
# @retval True Successfully find a FD statement # @retval True Successfully find a FD statement
# @retval False Not able to find a FD statement # @retval False Not able to find a FD statement
# #
def __GetFdStatement(self, CapsuleObj): def __GetFdStatement(self, CapsuleObj, FMPCapsule = False):
if not self.__IsKeyword("FD"): if not self.__IsKeyword("FD"):
return False return False
@ -3453,6 +3472,12 @@ class FdfParser:
CapsuleFd = CapsuleData.CapsuleFd() CapsuleFd = CapsuleData.CapsuleFd()
CapsuleFd.FdName = self.__Token CapsuleFd.FdName = self.__Token
if FMPCapsule:
if not CapsuleObj.ImageFile:
CapsuleObj.ImageFile.append(CapsuleFd)
else:
CapsuleObj.VendorCodeFile.append(CapsuleFd)
else:
CapsuleObj.CapsuleDataList.append(CapsuleFd) CapsuleObj.CapsuleDataList.append(CapsuleFd)
return True return True
@ -3504,13 +3529,19 @@ class FdfParser:
# @retval True Successfully find a Anyfile statement # @retval True Successfully find a Anyfile statement
# @retval False Not able to find a AnyFile statement # @retval False Not able to find a AnyFile statement
# #
def __GetAnyFileStatement(self, CapsuleObj): def __GetAnyFileStatement(self, CapsuleObj, FMPCapsule = False):
AnyFileName = self.__ParseRawFileStatement() AnyFileName = self.__ParseRawFileStatement()
if not AnyFileName: if not AnyFileName:
return False return False
CapsuleAnyFile = CapsuleData.CapsuleAnyFile() CapsuleAnyFile = CapsuleData.CapsuleAnyFile()
CapsuleAnyFile.FileName = AnyFileName CapsuleAnyFile.FileName = AnyFileName
if FMPCapsule:
if not CapsuleObj.ImageFile:
CapsuleObj.ImageFile.append(CapsuleAnyFile)
else:
CapsuleObj.VendorCodeFile.append(CapsuleAnyFile)
else:
CapsuleObj.CapsuleDataList.append(CapsuleAnyFile) CapsuleObj.CapsuleDataList.append(CapsuleAnyFile)
return True return True