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 68DA11A1E34 for ; Sun, 9 Oct 2016 19:36:46 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP; 09 Oct 2016 19:36:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,470,1473145200"; d="scan'208";a="1051587853" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga001.fm.intel.com with ESMTP; 09 Oct 2016 19:36:46 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 9 Oct 2016 19:36:45 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 9 Oct 2016 19:36:45 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.15]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.118]) with mapi id 14.03.0248.002; Mon, 10 Oct 2016 10:36:44 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] BaseTools: Extend FMP to support FV statement and FD statement Thread-Index: AQHSIdRTWOAxCd2nPkStbtTCtp4OhKCg+osg Date: Mon, 10 Oct 2016 02:36:43 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14B482789@shsmsx102.ccr.corp.intel.com> References: <1475979888-27736-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1475979888-27736-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Mon, 10 Oct 2016 02:36:46 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Zhu, Yonghong > Sent: Sunday, October 09, 2016 10:25 AM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [Patch] BaseTools: Extend FMP to support FV statement and FD > statement >=20 > 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=3D= 132 >=20 > 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(-) >=20 > 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 +=3D os.path.getsize(FileName) > File =3D open(FileName, 'rb') > Content.write(File.read()) > File.close() > for fmp in self.FmpPayloadList: > + if fmp.ImageFile: > + for Obj in fmp.ImageFile: > + fmp.ImageFile =3D Obj.GenCapsuleSubItem() > + if fmp.VendorCodeFile: > + for Obj in fmp.VendorCodeFile: > + fmp.VendorCodeFile =3D Obj.GenCapsuleSubItem() > if fmp.Certificate_Guid: > ExternalTool, ExternalOption =3D FindExtendTool([], > GenFdsGlobalVariable.ArchList, fmp.Certificate_Guid) > CmdOption =3D '' > CapInputFile =3D 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 =3D None > self.Version =3D None > self.ImageTypeId =3D None > self.ImageIndex =3D None > self.HardwareInstance =3D None > - self.ImageFile =3D None > - self.VendorCodeFile =3D None > + self.ImageFile =3D [] > + self.VendorCodeFile =3D [] > self.Certificate_Guid =3D None > self.MonotonicCount =3D None >=20 > def GenCapsuleSubItem(self, AuthData=3D[]): > 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 =3D 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 =3D ImageFile > - VendorCodeFile =3D self.__ParseRawFileStatement() > - if VendorCodeFile: > - FmpData.VendorCodeFile =3D VendorCodeFile > - AdditionalFile =3D 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 fi= le are > allowed in FMP payload section.", self.FileName, self.CurrentLineNumber) > self.Profile.FmpPayloadDict[FmpUiName] =3D FmpData > return True >=20 > ## __GetCapsule() method > @@ -3398,20 +3395,36 @@ class FdfParser: > IsAfile =3D self.__GetAfileStatement(Obj) > IsFmp =3D self.__GetFmpStatement(Obj) > if not (IsInf or IsFile or IsFv or IsFd or IsAnyFile or IsAf= ile or IsFmp): > break >=20 > + ## __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 =3D self.__GetFvStatement(Obj, True) > + IsFd =3D self.__GetFdStatement(Obj, True) > + IsAnyFile =3D 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 =3D False): >=20 > if not self.__IsKeyword("FV"): > return False >=20 > if not self.__IsToken("=3D"): > @@ -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) >=20 > CapsuleFv =3D CapsuleData.CapsuleFv() > CapsuleFv.FvName =3D 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 >=20 > ## __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 =3D False): >=20 > if not self.__IsKeyword("FD"): > return False >=20 > if not self.__IsToken("=3D"): > @@ -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) >=20 > CapsuleFd =3D CapsuleData.CapsuleFd() > CapsuleFd.FdName =3D 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 >=20 > 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 =3D False): > AnyFileName =3D self.__ParseRawFileStatement() > if not AnyFileName: > return False >=20 > CapsuleAnyFile =3D CapsuleData.CapsuleAnyFile() > CapsuleAnyFile.FileName =3D 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 >=20 > ## __GetAfileStatement() method > # > # Get Afile for capsule > -- > 2.6.1.windows.1