summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/GenFds
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/Python/GenFds')
-rw-r--r--BaseTools/Source/Python/GenFds/Fd.py9
-rw-r--r--BaseTools/Source/Python/GenFds/FdfParser.py68
-rw-r--r--BaseTools/Source/Python/GenFds/FfsFileStatement.py2
-rw-r--r--BaseTools/Source/Python/GenFds/FfsInfStatement.py5
-rw-r--r--BaseTools/Source/Python/GenFds/GenFds.py2
-rw-r--r--BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py22
-rw-r--r--BaseTools/Source/Python/GenFds/VerSection.py2
7 files changed, 79 insertions, 31 deletions
diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py
index aa4d2e8262..3716549cba 100644
--- a/BaseTools/Source/Python/GenFds/Fd.py
+++ b/BaseTools/Source/Python/GenFds/Fd.py
@@ -113,10 +113,15 @@ class FD(FDClassObject):
PreviousRegionStart = RegionObj.Offset
PreviousRegionSize = RegionObj.Size
#
+ # Verify current region fits within allocated FD section Size
+ #
+ if PreviousRegionStart + PreviousRegionSize > self.Size:
+ EdkLogger.error("GenFds", GENFDS_ERROR,
+ 'FD %s size too small to fit region with offset 0x%X and size 0x%X'
+ % (self.FdUiName, PreviousRegionStart, PreviousRegionSize))
+ #
# Call each region's AddToBuffer function
#
- if PreviousRegionSize > self.Size:
- EdkLogger.error("GenFds", GENFDS_ERROR, 'FD %s size too small' % self.FdUiName)
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
#
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index c9c620d853..a468a5ec99 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1707,6 +1707,38 @@ class FdfParser:
return False
+ ## __CalcRegionExpr(self)
+ #
+ # Calculate expression for offset or size of a region
+ #
+ # @return: None if invalid expression
+ # Calculated number if successfully
+ #
+ def __CalcRegionExpr(self):
+ StartPos = self.GetFileBufferPos()
+ Expr = ''
+ PairCount = 0
+ while not self.__EndOfFile():
+ CurCh = self.__CurrentChar()
+ if CurCh == '(':
+ PairCount += 1
+ elif CurCh == ')':
+ PairCount -= 1
+
+ if CurCh in '|\r\n' and PairCount == 0:
+ break
+ Expr += CurCh
+ self.__GetOneChar()
+ try:
+ return long(
+ ValueExpression(Expr,
+ dict(['%s.%s' % (Pcd[1], Pcd[0]), Val]
+ for Pcd, Val in self.Profile.PcdDict.iteritems())
+ )(True),0)
+ except Exception:
+ self.SetFileBufferPos(StartPos)
+ return None
+
## __GetRegionLayout() method
#
# Get region layout for FD
@@ -1717,19 +1749,21 @@ class FdfParser:
# @retval False Not able to find
#
def __GetRegionLayout(self, Fd):
- if not self.__GetNextHexNumber():
+ Offset = self.__CalcRegionExpr()
+ if Offset == None:
return False
RegionObj = Region.Region()
- RegionObj.Offset = long(self.__Token, 0)
+ RegionObj.Offset = Offset
Fd.RegionList.append(RegionObj)
if not self.__IsToken( "|"):
raise Warning("expected '|'", self.FileName, self.CurrentLineNumber)
- if not self.__GetNextHexNumber():
+ Size = self.__CalcRegionExpr()
+ if Size == None:
raise Warning("expected Region Size", self.FileName, self.CurrentLineNumber)
- RegionObj.Size = long(self.__Token, 0)
+ RegionObj.Size = Size
if not self.__GetNextWord():
return True
@@ -2503,16 +2537,16 @@ class FdfParser:
self.__GetFileOpts( FfsFileObj)
if not self.__IsToken("{"):
-# if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RELOCS_RETAINED'):
-# if self.__FileCouldHaveRelocFlag(FfsFileObj.FvFileType):
-# if self.__Token == 'RELOCS_STRIPPED':
-# FfsFileObj.KeepReloc = False
-# else:
-# FfsFileObj.KeepReloc = True
-# else:
-# raise Warning("File type %s could not have reloc strip flag%d" % (FfsFileObj.FvFileType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
-#
-# if not self.__IsToken("{"):
+ if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RELOCS_RETAINED'):
+ if self.__FileCouldHaveRelocFlag(FfsFileObj.FvFileType):
+ if self.__Token == 'RELOCS_STRIPPED':
+ FfsFileObj.KeepReloc = False
+ else:
+ FfsFileObj.KeepReloc = True
+ else:
+ raise Warning("File type %s could not have reloc strip flag%d" % (FfsFileObj.FvFileType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
+
+ if not self.__IsToken("{"):
raise Warning("expected '{'", self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
@@ -3186,7 +3220,7 @@ class FdfParser:
raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)
Arch = self.__SkippedChars.rstrip(".")
- if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "COMMON"):
+ if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "AARCH64", "COMMON"):
raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.CurrentLineNumber)
ModuleType = self.__GetModuleType()
@@ -3764,7 +3798,7 @@ class FdfParser:
raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)
Arch = self.__SkippedChars.rstrip(".").upper()
- if Arch not in ("IA32", "X64", "IPF", "ARM"):
+ if Arch not in ("IA32", "X64", "IPF", "ARM", "AARCH64"):
raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.CurrentLineNumber)
if not self.__GetNextWord():
@@ -3778,7 +3812,7 @@ class FdfParser:
if self.__IsToken(","):
if not self.__GetNextWord():
raise Warning("expected Arch list", self.FileName, self.CurrentLineNumber)
- if self.__Token.upper() not in ("IA32", "X64", "IPF", "ARM"):
+ if self.__Token.upper() not in ("IA32", "X64", "IPF", "ARM", "AARCH64"):
raise Warning("Unknown Arch '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
VtfObj.ArchList = self.__Token.upper()
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
index 04527fe00f..d0dec380fb 100644
--- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
@@ -110,6 +110,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:
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 96e212cae7..71acd2992c 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -388,6 +388,11 @@ class FfsInfStatement(FfsInfStatementClassObject):
if InfFileKey in (PlatformDataBase.Modules):
DscArchList.append ('EBC')
+ PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'AARCH64', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ if PlatformDataBase != None:
+ if InfFileKey in (PlatformDataBase.Modules):
+ DscArchList.append ('AARCH64')
+
return DscArchList
## GetCurrentArch() method
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index fb86a152b6..400008e815 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -301,7 +301,7 @@ def myOptionParser():
usage = "%prog [options] -f input_file -a arch_list -b build_target -p active_platform -t tool_chain_tag -D \"MacroName [= MacroValue]\""
Parser = OptionParser(usage=usage,description=__copyright__,version="%prog " + str(versionNumber))
Parser.add_option("-f", "--file", dest="filename", type="string", help="Name of FDF file to convert", action="callback", callback=SingleCheckCallback)
- Parser.add_option("-a", "--arch", dest="archList", help="comma separated list containing one or more of: IA32, X64, IPF, ARM or EBC which should be built, overrides target.txt?s TARGET_ARCH")
+ Parser.add_option("-a", "--arch", dest="archList", help="comma separated list containing one or more of: IA32, X64, IPF, ARM, AARCH64 or EBC which should be built, overrides target.txt?s TARGET_ARCH")
Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed.")
Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index b457937628..2fa4cb8c0d 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -345,7 +345,7 @@ class GenFdsGlobalVariable:
@staticmethod
def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None,
- GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None):
+ GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None, BuildNumber=None):
Cmd = ["GenSec"]
if Type not in [None, '']:
Cmd += ["-s", Type]
@@ -364,6 +364,7 @@ class GenFdsGlobalVariable:
for SecAlign in InputAlign:
Cmd += ["--sectionalign", SecAlign]
+ CommandFile = Output + '.txt'
if Ui not in [None, '']:
#Cmd += ["-n", '"' + Ui + '"']
SectionData = array.array('B', [0,0,0,0])
@@ -374,19 +375,20 @@ class GenFdsGlobalVariable:
GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)
SaveFileOnChange(Output, SectionData.tostring())
elif Ver not in [None, '']:
- #Cmd += ["-j", Ver]
- SectionData = array.array('B', [0,0,0,0])
- SectionData.fromstring(Ver.encode("utf_16_le"))
- SectionData.append(0)
- SectionData.append(0)
- Len = len(SectionData)
- GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x14)
- SaveFileOnChange(Output, SectionData.tostring())
+ Cmd += ["-n", Ver]
+ if BuildNumber:
+ Cmd += ["-j", BuildNumber]
+ Cmd += ["-o", Output]
+
+ SaveFileOnChange(CommandFile, ' '.join(Cmd), False)
+ if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
+ return
+
+ GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")
else:
Cmd += ["-o", Output]
Cmd += Input
- CommandFile = Output + '.txt'
SaveFileOnChange(CommandFile, ' '.join(Cmd), False)
if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):
return
diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Source/Python/GenFds/VerSection.py
index 3fca4064f0..8f6da9624f 100644
--- a/BaseTools/Source/Python/GenFds/VerSection.py
+++ b/BaseTools/Source/Python/GenFds/VerSection.py
@@ -76,7 +76,7 @@ class VerSection (VerSectionClassObject):
StringData = ''
GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTION_VERSION',
- Ui=StringData, Ver=self.BuildNum)
+ Ver=StringData, BuildNumber=self.BuildNum)
OutputFileList = []
OutputFileList.append(OutputFile)
return OutputFileList, self.Alignment