summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/GenFds/Region.py
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/Python/GenFds/Region.py')
-rw-r--r--BaseTools/Source/Python/GenFds/Region.py44
1 files changed, 22 insertions, 22 deletions
diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py
index feb56cb60f..01e998e54c 100644
--- a/BaseTools/Source/Python/GenFds/Region.py
+++ b/BaseTools/Source/Python/GenFds/Region.py
@@ -54,10 +54,10 @@ class Region(RegionClassObject):
# @retval string Generated FV file path
#
- def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, ImageBinDict, vtfDict = None, MacroDict = {}):
+ def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, ImageBinDict, vtfDict=None, MacroDict={}):
Size = self.Size
GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' % self.Offset)
- GenFdsGlobalVariable.InfLogger(" Region Size = 0x%X" %Size)
+ GenFdsGlobalVariable.InfLogger(" Region Size = 0x%X" % Size)
GenFdsGlobalVariable.SharpCounter = 0
if self.RegionType == 'FV':
@@ -65,13 +65,13 @@ class Region(RegionClassObject):
# Get Fv from FvDict
#
self.FvAddress = int(BaseAddress, 16) + self.Offset
- FvBaseAddress = '0x%X' %self.FvAddress
- FvOffset = 0
+ FvBaseAddress = '0x%X' % self.FvAddress
+ FvOffset = 0
for RegionData in self.RegionDataList:
FileName = None
if RegionData.endswith(".fv"):
RegionData = GenFdsGlobalVariable.MacroExtend(RegionData, MacroDict)
- GenFdsGlobalVariable.InfLogger(' Region FV File Name = .fv : %s'%RegionData)
+ GenFdsGlobalVariable.InfLogger(' Region FV File Name = .fv : %s' % RegionData)
if RegionData[1] != ':' :
RegionData = os.path.join (GenFdsGlobalVariable.WorkSpaceDir, RegionData)
if not os.path.exists(RegionData):
@@ -101,7 +101,7 @@ class Region(RegionClassObject):
EdkLogger.error("GenFds", GENFDS_ERROR,
"FV (%s) is NOT %s Aligned!" % (FvObj.UiFvName, FvObj.FvAlignment))
FvBuffer = StringIO.StringIO('')
- FvBaseAddress = '0x%X' %self.FvAddress
+ FvBaseAddress = '0x%X' % self.FvAddress
BlockSize = None
BlockNum = None
FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSize, BlockNum, ErasePolarity, vtfDict)
@@ -128,7 +128,7 @@ class Region(RegionClassObject):
EdkLogger.error("GenFds", GENFDS_ERROR,
"Size of FV File (%s) is larger than Region Size 0x%X specified." \
% (RegionData, Size))
- BinFile = open (FileName, 'r+b')
+ BinFile = open(FileName, 'r+b')
Buffer.write(BinFile.read())
BinFile.close()
Size = Size - FileLength
@@ -150,7 +150,7 @@ class Region(RegionClassObject):
for RegionData in self.RegionDataList:
if RegionData.endswith(".cap"):
RegionData = GenFdsGlobalVariable.MacroExtend(RegionData, MacroDict)
- GenFdsGlobalVariable.InfLogger(' Region CAPSULE Image Name = .cap : %s'%RegionData)
+ GenFdsGlobalVariable.InfLogger(' Region CAPSULE Image Name = .cap : %s' % RegionData)
if RegionData[1] != ':' :
RegionData = os.path.join (GenFdsGlobalVariable.WorkSpaceDir, RegionData)
if not os.path.exists(RegionData):
@@ -187,7 +187,7 @@ class Region(RegionClassObject):
EdkLogger.error("GenFds", GENFDS_ERROR,
"Size 0x%X of Capsule File (%s) is larger than Region Size 0x%X specified." \
% (FileLength, RegionData, Size))
- BinFile = open (FileName, 'r+b')
+ BinFile = open(FileName, 'r+b')
Buffer.write(BinFile.read())
BinFile.close()
Size = Size - FileLength
@@ -217,8 +217,8 @@ class Region(RegionClassObject):
EdkLogger.error("GenFds", GENFDS_ERROR,
"Size of File (%s) is larger than Region Size 0x%X specified." \
% (RegionData, Size))
- GenFdsGlobalVariable.InfLogger(' Region File Name = %s'%RegionData)
- BinFile = open (RegionData, 'rb')
+ GenFdsGlobalVariable.InfLogger(' Region File Name = %s' % RegionData)
+ BinFile = open(RegionData, 'rb')
Buffer.write(BinFile.read())
BinFile.close()
Size = Size - FileLength
@@ -273,17 +273,17 @@ class Region(RegionClassObject):
Granu = 1024
Str = Str[:-1]
elif Str.endswith('M'):
- Granu = 1024*1024
+ Granu = 1024 * 1024
Str = Str[:-1]
elif Str.endswith('G'):
- Granu = 1024*1024*1024
+ Granu = 1024 * 1024 * 1024
Str = Str[:-1]
else:
pass
- AlignValue = int(Str)*Granu
+ AlignValue = int(Str) * Granu
return AlignValue
-
+
## BlockSizeOfRegion()
#
# @param BlockSizeList List of block information
@@ -304,7 +304,7 @@ class Region(RegionClassObject):
else:
# region ended within current blocks
if self.Offset + self.Size <= End:
- ExpectedList.append((BlockSize, (RemindingSize + BlockSize - 1)/BlockSize))
+ ExpectedList.append((BlockSize, (RemindingSize + BlockSize - 1) / BlockSize))
break
# region not ended yet
else:
@@ -313,11 +313,11 @@ class Region(RegionClassObject):
UsedBlockNum = BlockNum
# region started in middle of current blocks
else:
- UsedBlockNum = (End - self.Offset)/BlockSize
+ UsedBlockNum = (End - self.Offset) / BlockSize
Start = End
ExpectedList.append((BlockSize, UsedBlockNum))
RemindingSize -= BlockSize * UsedBlockNum
-
+
if FvObj.BlockSizeList == []:
FvObj.BlockSizeList = ExpectedList
else:
@@ -333,22 +333,22 @@ class Region(RegionClassObject):
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))
+ % (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
+ 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)
+ % 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)
+ % FvObj.UiFvName, ExtraData=ExpectedListData)
else:
Index += 1