X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FFfsFileStatement.py;h=690826bcb999b672739cea3fdf13188f1b5b11ce;hb=df81077f77f91b43f32f70e06950b86e20f711da;hp=013dbb1f02fb99e335c23fc516847576362de4f1;hpb=40d841f6a8f84e75409178e19e69b95e01bada0f;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
index 013dbb1f02..690826bcb9 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 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -17,7 +17,7 @@
#
import Ffs
import Rule
-import os
+import Common.LongFilePathOs as os
import StringIO
import subprocess
@@ -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
#
@@ -39,6 +41,11 @@ class FileStatement (FileStatementClassObject) :
#
def __init__(self):
FileStatementClassObject.__init__(self)
+ self.CurrentLineNum = None
+ self.CurrentLineContent = None
+ self.FileName = None
+ self.InfFileName = None
+ self.SubAlignment = None
## GenFfs() method
#
@@ -67,7 +74,7 @@ class FileStatement (FileStatementClassObject) :
OutputDir = os.path.join(GenFdsGlobalVariable.FfsDir, self.NameGuid)
if not os.path.exists(OutputDir):
- os.makedirs(OutputDir)
+ os.makedirs(OutputDir)
Dict.update(self.DefineVarDict)
SectionAlignments = None
@@ -87,7 +94,45 @@ 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.SubAlignment, list) and len(self.FileName) == len(self.SubAlignment):
+ FileContent = ''
+ MaxAlignIndex = 0
+ MaxAlignValue = 1
+ 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 = 1
+ if self.SubAlignment[Index] != None:
+ AlignValue = GenFdsGlobalVariable.GetAlignment(self.SubAlignment[Index])
+ if AlignValue > MaxAlignValue:
+ MaxAlignIndex = Index
+ MaxAlignValue = AlignValue
+ 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
+ self.SubAlignment = self.SubAlignment[MaxAlignIndex]
+
+ if self.Alignment and self.SubAlignment:
+ if GenFdsGlobalVariable.GetAlignment (self.Alignment) < GenFdsGlobalVariable.GetAlignment (self.SubAlignment):
+ self.Alignment = self.SubAlignment
+ elif self.SubAlignment:
+ self.Alignment = self.SubAlignment
+
self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
+ #Replace $(SAPCE) with real space
+ self.FileName = self.FileName.replace('$(SPACE)', ' ')
SectionFiles = [GenFdsGlobalVariable.MacroExtend(self.FileName, Dict)]
else:
@@ -106,6 +151,8 @@ class FileStatement (FileStatementClassObject) :
if FvParentAddr != None and isinstance(section, GuidSection):
section.FvParentAddr = FvParentAddr
+ if self.KeepReloc == False:
+ section.KeepReloc = False
sectList, align = section.GenSection(OutputDir, self.NameGuid, SecIndex, self.KeyStringList, None, Dict)
if sectList != []:
for sect in sectList: