* [Patch] BaseTools: Extend FMP to support FV statement and FD statement
@ 2016-10-09 2:24 Yonghong Zhu
2016-10-10 2:36 ` Gao, Liming
0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2016-10-09 2:24 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch] BaseTools: Extend FMP to support FV statement and FD statement
2016-10-09 2:24 [Patch] BaseTools: Extend FMP to support FV statement and FD statement Yonghong Zhu
@ 2016-10-10 2:36 ` Gao, Liming
0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2016-10-10 2:36 UTC (permalink / raw)
To: Zhu, Yonghong, edk2-devel@lists.01.org
Reviewed-by: Liming Gao <liming.gao@intel.com>
> -----Original Message-----
> From: Zhu, Yonghong
> Sent: Sunday, October 09, 2016 10:25 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [Patch] 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>
> ---
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-10 2:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-09 2:24 [Patch] BaseTools: Extend FMP to support FV statement and FD statement Yonghong Zhu
2016-10-10 2:36 ` Gao, Liming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox