summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/GenFds/FdfParser.py
diff options
context:
space:
mode:
authorYonghong Zhu <yonghong.zhu@intel.com>2016-03-21 19:27:35 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2016-03-27 15:11:52 +0800
commit860992ed70ae4c849239174c154d9a7650eabd6e (patch)
treee5ee2c3a56d7a86341b3b8eda29eeb4d50295cb5 /BaseTools/Source/Python/GenFds/FdfParser.py
parent481b93f7f00feb9bbc9e5a412c5065c0740b20f4 (diff)
downloadedk2-platforms-860992ed70ae4c849239174c154d9a7650eabd6e.tar.xz
BaseTools: Extend the RAW format to support multiple binary files
Current FDF spec updated to support multiple binary files for RAW File in the [FV] and [Capsule] section. For the multiple normal files, it may have the optional FfsAlignment. Example: FILE RAW = 197DB236-F856-4924-91F8-C1F12FB875F3 { Align=16 $(PLATFORM_PACKAGE)/Binaries/File1.pdb Align=16 $(PLATFORM_PACKAGE)/Binaries/File2.pdb Align=16 $(PLATFORM_PACKAGE)/Binaries/File3.pdb } Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/GenFds/FdfParser.py')
-rw-r--r--BaseTools/Source/Python/GenFds/FdfParser.py49
1 files changed, 48 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 788190567e..b86c196067 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1,7 +1,7 @@
## @file
# parse FDF file
#
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.<BR>
#
# This program and the accompanying materials
@@ -2692,6 +2692,11 @@ class FdfParser:
elif self.__Token in ("DEFINE", "APRIORI", "SECTION"):
self.__UndoToken()
self.__GetSectionData( FfsFileObj, MacroDict)
+
+ elif hasattr(FfsFileObj, 'FvFileType') and FfsFileObj.FvFileType == 'RAW':
+ self.__UndoToken()
+ self.__GetRAWData(FfsFileObj, MacroDict)
+
else:
FfsFileObj.CurrentLineNum = self.CurrentLineNumber
FfsFileObj.CurrentLineContent = self.__CurrentLine()
@@ -2701,6 +2706,48 @@ class FdfParser:
if not self.__IsToken( "}"):
raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)
+ ## __GetRAWData() method
+ #
+ # Get RAW data for FILE statement
+ #
+ # @param self The object pointer
+ # @param FfsFileObj for whom section is got
+ # @param MacroDict dictionary used to replace macro
+ #
+ def __GetRAWData(self, FfsFileObj, MacroDict = {}):
+ FfsFileObj.FileName = []
+ FfsFileObj.Alignment = []
+ AlignDict = {"Auto":1, "8":8, "16":16, "32":32, "64":64, "128":128, "512":512, "1K":1024, "4K":4096, "32K":32768, "64K":65536}
+ while True:
+ AlignValue = None
+ if self.__GetAlignment():
+ if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+ raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
+ AlignValue = AlignValue = AlignDict[self.__Token]
+ if not self.__GetNextToken():
+ raise Warning("expected Filename value", self.FileName, self.CurrentLineNumber)
+
+ FileName = self.__Token.replace('$(SPACE)', ' ')
+ if FileName == '}':
+ self.__UndoToken()
+ raise Warning("expected Filename value", self.FileName, self.CurrentLineNumber)
+ elif not os.path.isfile(FileName):
+ raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)
+
+ self.__VerifyFile(FileName)
+ File = PathClass(NormPath(FileName), GenFdsGlobalVariable.WorkSpaceDir)
+ FfsFileObj.FileName.append(File.Path)
+ FfsFileObj.Alignment.append(AlignValue)
+
+ if self.__IsToken( "}"):
+ self.__UndoToken()
+ break
+
+ if len(FfsFileObj.Alignment) == 1:
+ FfsFileObj.Alignment = FfsFileObj.Alignment[0]
+ if len(FfsFileObj.FileName) == 1:
+ FfsFileObj.FileName = FfsFileObj.FileName[0]
+
## __GetFileOpts() method
#
# Get options for FILE statement