diff options
author | Liming Gao <liming.gao@intel.com> | 2013-08-23 02:18:16 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-08-23 02:18:16 +0000 |
commit | 4afd3d042215afe68d00b9ab8c32f063a3a1c03f (patch) | |
tree | b5190bd11547ac22fe35eeceee85ef42bfe6eea5 /BaseTools/Source/Python/GenFds/FdfParser.py | |
parent | a365eed476687881ce0ed49af7d483fd3cb0c491 (diff) | |
download | edk2-platforms-4afd3d042215afe68d00b9ab8c32f063a3a1c03f.tar.xz |
Sync BaseTool trunk (version r2599) into EDKII BaseTools.
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Heshen Chen <chen.heshen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14591 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/GenFds/FdfParser.py')
-rw-r--r-- | BaseTools/Source/Python/GenFds/FdfParser.py | 68 |
1 files changed, 51 insertions, 17 deletions
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()
|