From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2226D1A1E24 for ; Sat, 8 Oct 2016 19:24:53 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP; 08 Oct 2016 19:24:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,316,1473145200"; d="scan'208";a="888130543" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.144]) by orsmga003.jf.intel.com with ESMTP; 08 Oct 2016 19:24:52 -0700 From: Yonghong Zhu To: edk2-devel@lists.01.org Cc: Liming Gao Date: Sun, 9 Oct 2016 10:24:48 +0800 Message-Id: <1475979888-27736-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [Patch] BaseTools: Extend FMP to support FV statement and FD statement 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: Sun, 09 Oct 2016 02:24:53 -0000 This patch extend the to support and , 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 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/GenFds/Capsule.py | 6 +++ BaseTools/Source/Python/GenFds/CapsuleData.py | 4 +- BaseTools/Source/Python/GenFds/FdfParser.py | 59 ++++++++++++++++++++------- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py index c98c054..d025f0c 100644 --- a/BaseTools/Source/Python/GenFds/Capsule.py +++ b/BaseTools/Source/Python/GenFds/Capsule.py @@ -139,10 +139,16 @@ class Capsule (CapsuleClassObject) : PreSize += os.path.getsize(FileName) File = open(FileName, 'rb') Content.write(File.read()) File.close() 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: ExternalTool, ExternalOption = FindExtendTool([], GenFdsGlobalVariable.ArchList, fmp.Certificate_Guid) CmdOption = '' CapInputFile = fmp.ImageFile if not os.path.isabs(fmp.ImageFile): diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py index 07cc198..d7a6d54 100644 --- a/BaseTools/Source/Python/GenFds/CapsuleData.py +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py @@ -177,12 +177,12 @@ class CapsulePayload(CapsuleData): self.UiName = None self.Version = None self.ImageTypeId = None self.ImageIndex = None self.HardwareInstance = None - self.ImageFile = None - self.VendorCodeFile = None + self.ImageFile = [] + self.VendorCodeFile = [] self.Certificate_Guid = None self.MonotonicCount = None def GenCapsuleSubItem(self, AuthData=[]): if not self.Version: diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 02ae7c9..64f634f 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -3257,19 +3257,16 @@ class FdfParser: FmpKeyList.remove('CERTIFICATE_GUID') if 'MONOTONIC_COUNT' in FmpKeyList: FmpKeyList.remove('MONOTONIC_COUNT') if FmpKeyList: raise Warning("Missing keywords %s in FMP payload section." % ', '.join(FmpKeyList), self.FileName, self.CurrentLineNumber) - ImageFile = self.__ParseRawFileStatement() - if not ImageFile: + # get the Image file and Vendor code file + self.__GetFMPCapsuleData(FmpData) + if not FmpData.ImageFile: raise Warning("Missing image file in FMP payload section.", self.FileName, self.CurrentLineNumber) - FmpData.ImageFile = ImageFile - VendorCodeFile = self.__ParseRawFileStatement() - if VendorCodeFile: - FmpData.VendorCodeFile = VendorCodeFile - AdditionalFile = self.__ParseRawFileStatement() - if AdditionalFile: + # check whether more than one Vendor code file + if len(FmpData.VendorCodeFile) > 1: 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 return True ## __GetCapsule() method @@ -3398,20 +3395,36 @@ class FdfParser: IsAfile = self.__GetAfileStatement(Obj) IsFmp = self.__GetFmpStatement(Obj) if not (IsInf or IsFile or IsFv or IsFd or IsAnyFile or IsAfile or IsFmp): 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 # # Get FV for capsule # # @param self The object pointer # @param CapsuleObj for whom FV is got # @retval True Successfully 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"): return False if not self.__IsToken("="): @@ -3423,11 +3436,17 @@ class FdfParser: if self.__Token.upper() not in self.Profile.FvDict.keys(): raise Warning("FV name does not exist", self.FileName, self.CurrentLineNumber) CapsuleFv = CapsuleData.CapsuleFv() CapsuleFv.FvName = self.__Token - CapsuleObj.CapsuleDataList.append(CapsuleFv) + if FMPCapsule: + if not CapsuleObj.ImageFile: + CapsuleObj.ImageFile.append(CapsuleFv) + else: + CapsuleObj.VendorCodeFile.append(CapsuleFv) + else: + CapsuleObj.CapsuleDataList.append(CapsuleFv) return True ## __GetFdStatement() method # # Get FD for capsule @@ -3435,11 +3454,11 @@ class FdfParser: # @param self The object pointer # @param CapsuleObj for whom FD is got # @retval True Successfully 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"): return False if not self.__IsToken("="): @@ -3451,11 +3470,17 @@ class FdfParser: if self.__Token.upper() not in self.Profile.FdDict.keys(): raise Warning("FD name does not exist", self.FileName, self.CurrentLineNumber) CapsuleFd = CapsuleData.CapsuleFd() CapsuleFd.FdName = self.__Token - CapsuleObj.CapsuleDataList.append(CapsuleFd) + if FMPCapsule: + if not CapsuleObj.ImageFile: + CapsuleObj.ImageFile.append(CapsuleFd) + else: + CapsuleObj.VendorCodeFile.append(CapsuleFd) + else: + CapsuleObj.CapsuleDataList.append(CapsuleFd) return True def __GetFmpStatement(self, CapsuleObj): if not self.__IsKeyword("FMP_PAYLOAD"): if not self.__IsKeyword("FMP"): @@ -3502,18 +3527,24 @@ class FdfParser: # @param self The object pointer # @param CapsuleObj for whom AnyFile is got # @retval True Successfully 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() if not AnyFileName: return False CapsuleAnyFile = CapsuleData.CapsuleAnyFile() CapsuleAnyFile.FileName = AnyFileName - CapsuleObj.CapsuleDataList.append(CapsuleAnyFile) + if FMPCapsule: + if not CapsuleObj.ImageFile: + CapsuleObj.ImageFile.append(CapsuleAnyFile) + else: + CapsuleObj.VendorCodeFile.append(CapsuleAnyFile) + else: + CapsuleObj.CapsuleDataList.append(CapsuleAnyFile) return True ## __GetAfileStatement() method # # Get Afile for capsule -- 2.6.1.windows.1