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/FdfParser.py20
-rw-r--r--BaseTools/Source/Python/GenFds/FfsInfStatement.py8
-rw-r--r--BaseTools/Source/Python/GenFds/GenFds.py13
-rw-r--r--BaseTools/Source/Python/GenFds/Region.py109
4 files changed, 99 insertions, 51 deletions
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index d11af6c134..52d32a9e98 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -565,9 +565,9 @@ class FdfParser:
self.Rewind()
- ## PreprocessIncludeFile() method
+ ## PreprocessConditionalStatement() method
#
- # Preprocess file contents, replace !include statements with file contents.
+ # Preprocess conditional statement.
# In the end, rewind the file buffer pointer to the beginning
#
# @param self The object pointer
@@ -1264,6 +1264,12 @@ class FdfParser:
raise Warning("expected ']'", self.FileName, self.CurrentLineNumber)
while self.__GetNextWord():
+ # handle the SET statement
+ if self.__Token == 'SET':
+ self.__UndoToken()
+ self.__GetSetStatement(None)
+ continue
+
Macro = self.__Token
if not self.__IsToken("="):
@@ -1489,7 +1495,7 @@ class FdfParser:
for Item in Obj.BlockSizeList:
if Item[0] == None or Item[1] == None:
- raise Warning("expected block statement for Fd Section", self.FileName, self.CurrentLineNumber)
+ raise Warning("expected block statement", self.FileName, self.CurrentLineNumber)
## __GetBlockStatement() method
#
@@ -1508,7 +1514,7 @@ class FdfParser:
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
if not self.__GetNextHexNumber() and not self.__GetNextDecimalNumber():
- raise Warning("expected Hex block size", self.FileName, self.CurrentLineNumber)
+ raise Warning("expected Hex or Integer block size", self.FileName, self.CurrentLineNumber)
BlockSize = self.__Token
BlockSizePcd = None
@@ -1609,7 +1615,8 @@ class FdfParser:
raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)
Value += self.__SkippedChars
- Obj.SetVarDict[PcdPair] = Value
+ if Obj:
+ Obj.SetVarDict[PcdPair] = Value
self.Profile.PcdDict[PcdPair] = Value
return True
@@ -1904,7 +1911,8 @@ class FdfParser:
self.__GetAddressStatements(FvObj)
- self.__GetBlockStatement(FvObj)
+ while self.__GetBlockStatement(FvObj):
+ pass
self.__GetSetStatements(FvObj)
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 47521e08c5..d2397e07da 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -161,6 +161,14 @@ class FfsInfStatement(FfsInfStatementClassObject):
#
self.__InfParse__(Dict)
+
+ #
+ # Allow binary type module not specify override rule in FDF file.
+ #
+ if len(self.BinFileList) >0 and not self.InDsc:
+ if self.Rule == None or self.Rule == "":
+ self.Rule = "BINARY"
+
#
# Get the rule of how to generate Ffs file
#
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 48fe4983f8..04af6e2c67 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -351,16 +351,14 @@ class GenFds :
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(GenFds.OnlyGenerateThisFv.upper())
if FvObj != None:
Buffer = StringIO.StringIO()
- # Get FV base Address
- FvObj.AddToBuffer(Buffer, None, GenFds.GetFvBlockSize(FvObj))
+ FvObj.AddToBuffer(Buffer)
Buffer.close()
return
elif GenFds.OnlyGenerateThisFv == None:
for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
Buffer = StringIO.StringIO('')
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]
- # Get FV base Address
- FvObj.AddToBuffer(Buffer, None, GenFds.GetFvBlockSize(FvObj))
+ FvObj.AddToBuffer(Buffer)
Buffer.close()
if GenFds.OnlyGenerateThisFv == None and GenFds.OnlyGenerateThisFd == None:
@@ -453,7 +451,12 @@ class GenFds :
TotalSizeValue = long(FvSpaceInfo[1], 0)
UsedSizeValue = long(FvSpaceInfo[2], 0)
FreeSizeValue = long(FvSpaceInfo[3], 0)
- GenFdsGlobalVariable.InfLogger(Name + ' ' + '[' + str((UsedSizeValue+0.0)/TotalSizeValue)[0:4].lstrip('0.') + '%Full] ' + str(TotalSizeValue) + ' total, ' + str(UsedSizeValue) + ' used, ' + str(FreeSizeValue) + ' free')
+ if UsedSizeValue == TotalSizeValue:
+ Percentage = '100'
+ else:
+ Percentage = str((UsedSizeValue+0.0)/TotalSizeValue)[0:4].lstrip('0.')
+
+ GenFdsGlobalVariable.InfLogger(Name + ' ' + '[' + Percentage + '%Full] ' + str(TotalSizeValue) + ' total, ' + str(UsedSizeValue) + ' used, ' + str(FreeSizeValue) + ' free')
## PreprocessImage()
#
diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py
index 09971b3cd0..bfa65c8054 100644
--- a/BaseTools/Source/Python/GenFds/Region.py
+++ b/BaseTools/Source/Python/GenFds/Region.py
@@ -1,7 +1,7 @@
## @file
# process FD Region generation
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2010, 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
@@ -62,9 +62,6 @@ class Region(RegionClassObject):
#
# Get Fv from FvDict
#
- RegionBlockSize = self.BlockSizeOfRegion(BlockSizeList)
- RegionBlockNum = self.BlockNumOfRegion(RegionBlockSize)
-
self.FvAddress = int(BaseAddress, 16) + self.Offset
FvBaseAddress = '0x%X' %self.FvAddress
FvOffset = 0
@@ -95,13 +92,7 @@ class Region(RegionClassObject):
#
# Call GenFv tool
#
- BlockSize = RegionBlockSize
- BlockNum = RegionBlockNum
- if FvObj.BlockSizeList != []:
- if FvObj.BlockSizeList[0][0] != None:
- BlockSize = FvObj.BlockSizeList[0][0]
- if FvObj.BlockSizeList[0][1] != None:
- BlockNum = FvObj.BlockSizeList[0][1]
+ self.BlockInfoOfRegion(BlockSizeList, FvObj)
self.FvAddress = self.FvAddress + FvOffset
FvAlignValue = self.GetFvAlignValue(FvObj.FvAlignment)
if self.FvAddress % FvAlignValue != 0:
@@ -109,6 +100,8 @@ class Region(RegionClassObject):
"FV (%s) is NOT %s Aligned!" % (FvObj.UiFvName, FvObj.FvAlignment))
FvBuffer = StringIO.StringIO('')
FvBaseAddress = '0x%X' %self.FvAddress
+ BlockSize = None
+ BlockNum = None
FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSize, BlockNum, ErasePolarity, vtfDict)
if FvBuffer.len > Size:
FvBuffer.close()
@@ -288,38 +281,74 @@ class Region(RegionClassObject):
AlignValue = int(Str)*Granu
return AlignValue
+
## BlockSizeOfRegion()
#
# @param BlockSizeList List of block information
- # @retval int Block size of region
+ # @param FvObj The object for FV
#
- def BlockSizeOfRegion(self, BlockSizeList):
- Offset = 0x00
- BlockSize = 0
- for item in BlockSizeList:
- Offset = Offset + item[0] * item[1]
- GenFdsGlobalVariable.VerboseLogger ("Offset = 0x%X" %Offset)
- GenFdsGlobalVariable.VerboseLogger ("self.Offset 0x%X" %self.Offset)
-
- if self.Offset < Offset :
- if Offset - self.Offset < self.Size:
- EdkLogger.error("GenFds", GENFDS_ERROR,
- "Region at Offset 0x%X can NOT fit into Block array with BlockSize %X" \
- % (self.Offset, item[0]))
- BlockSize = item[0]
- GenFdsGlobalVariable.VerboseLogger ("BlockSize = %X" %BlockSize)
- return BlockSize
- return BlockSize
+ def BlockInfoOfRegion(self, BlockSizeList, FvObj):
+ Start = 0
+ End = 0
+ RemindingSize = self.Size
+ ExpectedList = []
+ for (BlockSize, BlockNum, pcd) in BlockSizeList:
+ End = Start + BlockSize * BlockNum
+ # region not started yet
+ if self.Offset >= End:
+ Start = End
+ continue
+ # region located in current blocks
+ else:
+ # region ended within current blocks
+ if self.Offset + self.Size <= End:
+ ExpectedList.append((BlockSize, (RemindingSize + BlockSize - 1)/BlockSize))
+ break
+ # region not ended yet
+ else:
+ # region not started in middle of current blocks
+ if self.Offset <= Start:
+ UsedBlockNum = BlockNum
+ # region started in middle of current blocks
+ else:
+ UsedBlockNum = (End - self.Offset)/BlockSize
+ Start = End
+ ExpectedList.append((BlockSize, UsedBlockNum))
+ RemindingSize -= BlockSize * UsedBlockNum
+
+ if FvObj.BlockSizeList == []:
+ FvObj.BlockSizeList = ExpectedList
+ else:
+ # first check whether FvObj.BlockSizeList items have only "BlockSize" or "NumBlocks",
+ # if so, use ExpectedList
+ for Item in FvObj.BlockSizeList:
+ if Item[0] == None or Item[1] == None:
+ FvObj.BlockSizeList = ExpectedList
+ break
+ # make sure region size is no smaller than the summed block size in FV
+ Sum = 0
+ for Item in FvObj.BlockSizeList:
+ Sum += Item[0] * Item[1]
+ if self.Size < Sum:
+ EdkLogger.error("GenFds", GENFDS_ERROR, "Total Size of FV %s 0x%x is larger than Region Size 0x%x "
+ %(FvObj.UiFvName, Sum, self.Size))
+ # check whether the BlockStatements in FV section is appropriate
+ ExpectedListData = ''
+ for Item in ExpectedList:
+ ExpectedListData += "BlockSize = 0x%x\n\tNumBlocks = 0x%x\n\t"%Item
+ Index = 0
+ for Item in FvObj.BlockSizeList:
+ if Item[0] != ExpectedList[Index][0]:
+ EdkLogger.error("GenFds", GENFDS_ERROR, "BlockStatements of FV %s are not align with FD's, suggested FV BlockStatement"
+ %FvObj.UiFvName, ExtraData = ExpectedListData)
+ elif Item[1] != ExpectedList[Index][1]:
+ if (Item[1] < ExpectedList[Index][1]) and (Index == len(FvObj.BlockSizeList) - 1):
+ break;
+ else:
+ EdkLogger.error("GenFds", GENFDS_ERROR, "BlockStatements of FV %s are not align with FD's, suggested FV BlockStatement"
+ %FvObj.UiFvName, ExtraData = ExpectedListData)
+ else:
+ Index += 1
- ## BlockNumOfRegion()
- #
- # @param BlockSize block size of region
- # @retval int Block number of region
- #
- def BlockNumOfRegion (self, BlockSize):
- if BlockSize == 0 :
- EdkLogger.error("GenFds", GENFDS_ERROR, "Region: %s is not in the FD address scope!" % self.Offset)
- BlockNum = self.Size / BlockSize
- GenFdsGlobalVariable.VerboseLogger ("BlockNum = 0x%X" %BlockNum)
- return BlockNum
+