summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/GenFds/FfsFileStatement.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/FfsFileStatement.py
parent481b93f7f00feb9bbc9e5a412c5065c0740b20f4 (diff)
downloadedk2-860992ed70ae4c849239174c154d9a7650eabd6e.tar.gz
edk2-860992ed70ae4c849239174c154d9a7650eabd6e.tar.bz2
edk2-860992ed70ae4c849239174c154d9a7650eabd6e.zip
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/FfsFileStatement.py')
-rw-r--r--BaseTools/Source/Python/GenFds/FfsFileStatement.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
index cd099196d0..506789e979 100644
--- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
@@ -1,7 +1,7 @@
## @file
# process FFS generation from FILE statement
#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -28,6 +28,8 @@ from Common.BuildToolError import *
from Common.Misc import GuidStructureByteArrayToGuidString
from GuidSection import GuidSection
from FvImageSection import FvImageSection
+from Common.Misc import SaveFileOnChange
+from struct import *
## generate FFS from FILE
#
@@ -91,6 +93,33 @@ class FileStatement (FileStatementClassObject) :
SectionFiles = [FileName]
elif self.FileName != None:
+ if hasattr(self, 'FvFileType') and self.FvFileType == 'RAW':
+ if isinstance(self.FileName, list) and isinstance(self.Alignment, list) and len(self.FileName) == len(self.Alignment):
+ FileContent = ''
+ for Index, File in enumerate(self.FileName):
+ try:
+ f = open(File, 'r+b')
+ except:
+ GenFdsGlobalVariable.ErrorLogger("Error opening RAW file %s." % (File))
+ Content = f.read()
+ f.close()
+ AlignValue = self.Alignment[Index]
+ if AlignValue == None:
+ AlignValue = 1
+ FileContent += Content
+ if len(FileContent) % AlignValue != 0:
+ Size = AlignValue - len(FileContent) % AlignValue
+ for i in range(0, Size):
+ FileContent += pack('B', 0xFF)
+
+ if FileContent:
+ OutputRAWFile = os.path.join(GenFdsGlobalVariable.FfsDir, self.NameGuid, self.NameGuid + '.raw')
+ SaveFileOnChange(OutputRAWFile, FileContent, True)
+ self.FileName = OutputRAWFile
+ if max(self.Alignment):
+ self.Alignment = str(max(self.Alignment))
+ else:
+ self.Alignment = None
self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
#Replace $(SAPCE) with real space
self.FileName = self.FileName.replace('$(SPACE)', ' ')