summaryrefslogtreecommitdiffstats
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/AprioriSection.py5
-rw-r--r--BaseTools/Source/Python/GenFds/Capsule.py6
-rw-r--r--BaseTools/Source/Python/GenFds/CapsuleData.py5
-rw-r--r--BaseTools/Source/Python/GenFds/CompressSection.py1
-rw-r--r--BaseTools/Source/Python/GenFds/DataSection.py5
-rw-r--r--BaseTools/Source/Python/GenFds/DepexSection.py1
-rw-r--r--BaseTools/Source/Python/GenFds/EfiSection.py5
-rw-r--r--BaseTools/Source/Python/GenFds/Fd.py5
-rw-r--r--BaseTools/Source/Python/GenFds/FdfParser.py24
-rw-r--r--BaseTools/Source/Python/GenFds/FfsFileStatement.py15
-rw-r--r--BaseTools/Source/Python/GenFds/FfsInfStatement.py19
-rw-r--r--BaseTools/Source/Python/GenFds/Fv.py14
-rw-r--r--BaseTools/Source/Python/GenFds/FvImageSection.py17
-rw-r--r--BaseTools/Source/Python/GenFds/GenFds.py26
-rw-r--r--BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py5
-rw-r--r--BaseTools/Source/Python/GenFds/GuidSection.py1
-rw-r--r--BaseTools/Source/Python/GenFds/OptRomFileStatement.py1
-rw-r--r--BaseTools/Source/Python/GenFds/OptRomInfStatement.py1
-rw-r--r--BaseTools/Source/Python/GenFds/OptionRom.py1
-rw-r--r--BaseTools/Source/Python/GenFds/Region.py11
-rw-r--r--BaseTools/Source/Python/GenFds/RuleComplexFile.py1
-rw-r--r--BaseTools/Source/Python/GenFds/RuleSimpleFile.py1
-rw-r--r--BaseTools/Source/Python/GenFds/Section.py1
-rw-r--r--BaseTools/Source/Python/GenFds/UiSection.py1
-rw-r--r--BaseTools/Source/Python/GenFds/VerSection.py1
-rw-r--r--BaseTools/Source/Python/GenFds/Vtf.py1
26 files changed, 96 insertions, 78 deletions
diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/Source/Python/GenFds/AprioriSection.py
index 13142ef7c0..7196f7f2c7 100644
--- a/BaseTools/Source/Python/GenFds/AprioriSection.py
+++ b/BaseTools/Source/Python/GenFds/AprioriSection.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from struct import *
import Common.LongFilePathOs as os
from io import BytesIO
@@ -51,7 +52,7 @@ class AprioriSection (AprioriSectionClassObject):
def GenFfs (self, FvName, Dict = {}, IsMakefile = False):
DXE_GUID = "FC510EE7-FFDC-11D4-BD41-0080C73C8881"
PEI_GUID = "1B45CC0A-156A-428A-AF62-49864DA0E6E6"
- Buffer = BytesIO()
+ Buffer = BytesIO('')
AprioriFileGuid = DXE_GUID
if self.AprioriType == "PEI":
AprioriFileGuid = PEI_GUID
@@ -96,7 +97,7 @@ class AprioriSection (AprioriSectionClassObject):
GuidPart = Guid.split('-')
- Buffer.write(pack('I', int(GuidPart[0], 16)))
+ Buffer.write(pack('I', long(GuidPart[0], 16)))
Buffer.write(pack('H', int(GuidPart[1], 16)))
Buffer.write(pack('H', int(GuidPart[2], 16)))
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py
index 1c673949fa..baa6e1dfa2 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -15,13 +15,13 @@
##
# Import Modules
#
+from __future__ import absolute_import
from .GenFdsGlobalVariable import GenFdsGlobalVariable
from .GenFdsGlobalVariable import FindExtendTool
from CommonDataClass.FdfClass import CapsuleClassObject
import Common.LongFilePathOs as os
import subprocess
from io import BytesIO
-from io import StringIO
from Common.Misc import SaveFileOnChange
from Common.Misc import PackRegistryFormatGuid
import uuid
@@ -185,7 +185,7 @@ class Capsule (CapsuleClassObject) :
#
# The real capsule header structure is 28 bytes
#
- Header.write(b'\x00'*(HdrSize-28))
+ Header.write('\x00'*(HdrSize-28))
Header.write(FwMgrHdr.getvalue())
Header.write(Content.getvalue())
#
@@ -247,7 +247,7 @@ class Capsule (CapsuleClassObject) :
def GenCapInf(self):
self.CapInfFileName = os.path.join(GenFdsGlobalVariable.FvDir,
self.UiCapsuleName + "_Cap" + '.inf')
- CapInfFile = StringIO() #open (self.CapInfFileName , 'w+')
+ CapInfFile = BytesIO() #open (self.CapInfFileName , 'w+')
CapInfFile.writelines("[options]" + T_CHAR_LF)
diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py
index 5f93734935..0caba8983d 100644
--- a/BaseTools/Source/Python/GenFds/CapsuleData.py
+++ b/BaseTools/Source/Python/GenFds/CapsuleData.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import Ffs
from .GenFdsGlobalVariable import GenFdsGlobalVariable
from io import BytesIO
@@ -82,7 +83,7 @@ class CapsuleFv (CapsuleData):
if self.FvName.find('.fv') == -1:
if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[self.FvName.upper()]
- FdBuffer = BytesIO()
+ FdBuffer = BytesIO('')
FvObj.CapsuleName = self.CapsuleName
FvFile = FvObj.AddToBuffer(FdBuffer)
FvObj.CapsuleName = None
@@ -229,7 +230,7 @@ class CapsulePayload(CapsuleData):
)
if AuthData:
Buffer += pack('QIHH', AuthData[0], AuthData[1], AuthData[2], AuthData[3])
- Buffer += uuid.UUID(AuthData[4]).bytes_le
+ Buffer += uuid.UUID(AuthData[4]).get_bytes_le()
#
# Append file content to the structure
diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/Source/Python/GenFds/CompressSection.py
index 65f6782275..aaaabf84dc 100644
--- a/BaseTools/Source/Python/GenFds/CompressSection.py
+++ b/BaseTools/Source/Python/GenFds/CompressSection.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from .Ffs import Ffs
from . import Section
import subprocess
diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py
index 3302c14091..a6387b07c5 100644
--- a/BaseTools/Source/Python/GenFds/DataSection.py
+++ b/BaseTools/Source/Python/GenFds/DataSection.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import Section
from .GenFdsGlobalVariable import GenFdsGlobalVariable
import subprocess
@@ -87,9 +88,9 @@ class DataSection (DataSectionClassObject):
if ImageObj.SectionAlignment < 0x400:
self.Alignment = str (ImageObj.SectionAlignment)
elif ImageObj.SectionAlignment < 0x100000:
- self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'
+ self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
else:
- self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'
+ self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
NoStrip = True
if self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Source/Python/GenFds/DepexSection.py
index 1868f0aab7..b2d123bfc0 100644
--- a/BaseTools/Source/Python/GenFds/DepexSection.py
+++ b/BaseTools/Source/Python/GenFds/DepexSection.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import Section
from .GenFdsGlobalVariable import GenFdsGlobalVariable
import subprocess
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 9fe7db3f46..623b77d274 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from struct import *
from . import Section
from .GenFdsGlobalVariable import GenFdsGlobalVariable
@@ -247,9 +248,9 @@ class EfiSection (EfiSectionClassObject):
if ImageObj.SectionAlignment < 0x400:
Align = str (ImageObj.SectionAlignment)
elif ImageObj.SectionAlignment < 0x100000:
- Align = str (ImageObj.SectionAlignment // 0x400) + 'K'
+ Align = str (ImageObj.SectionAlignment / 0x400) + 'K'
else:
- Align = str (ImageObj.SectionAlignment // 0x100000) + 'M'
+ Align = str (ImageObj.SectionAlignment / 0x100000) + 'M'
if File[(len(File)-4):] == '.efi':
MapFile = File.replace('.efi', '.map')
diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py
index 0ba6decc9e..bfae121798 100644
--- a/BaseTools/Source/Python/GenFds/Fd.py
+++ b/BaseTools/Source/Python/GenFds/Fd.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import Region
from . import Fv
import Common.LongFilePathOs as os
@@ -74,7 +75,7 @@ class FD(FDClassObject):
HasCapsuleRegion = True
break
if HasCapsuleRegion:
- TempFdBuffer = BytesIO()
+ TempFdBuffer = BytesIO('')
PreviousRegionStart = -1
PreviousRegionSize = 1
@@ -103,7 +104,7 @@ class FD(FDClassObject):
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
- FdBuffer = BytesIO()
+ FdBuffer = BytesIO('')
PreviousRegionStart = -1
PreviousRegionSize = 1
for RegionObj in self.RegionList :
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index ff8ccf21bd..63687e98bb 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -16,6 +16,8 @@
##
# Import Modules
#
+from __future__ import print_function
+from __future__ import absolute_import
import re
from . import Fd
@@ -155,7 +157,7 @@ class IncludeFileProfile :
self.FileName = FileName
self.FileLinesList = []
try:
- fsock = open(FileName, "r")
+ fsock = open(FileName, "rb", 0)
try:
self.FileLinesList = fsock.readlines()
for index, line in enumerate(self.FileLinesList):
@@ -216,7 +218,7 @@ class FileProfile :
def __init__(self, FileName):
self.FileLinesList = []
try:
- fsock = open(FileName, "r")
+ fsock = open(FileName, "rb", 0)
try:
self.FileLinesList = fsock.readlines()
finally:
@@ -1615,7 +1617,7 @@ class FdfParser:
self.SetPcdLocalation(pcdPair)
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
self.Profile.PcdFileLineDict[pcdPair] = FileLineTuple
- Obj.Size = int(Size, 0)
+ Obj.Size = long(Size, 0)
return True
if self.__IsKeyword( "ErasePolarity"):
@@ -1651,7 +1653,7 @@ class FdfParser:
if not self.__GetNextDecimalNumber() and not self.__GetNextHexNumber():
raise Warning("expected address", self.FileName, self.CurrentLineNumber)
- BsAddress = int(self.__Token, 0)
+ BsAddress = long(self.__Token, 0)
Obj.BsBaseAddress = BsAddress
if self.__IsKeyword("RtBaseAddress"):
@@ -1661,7 +1663,7 @@ class FdfParser:
if not self.__GetNextDecimalNumber() and not self.__GetNextHexNumber():
raise Warning("expected address", self.FileName, self.CurrentLineNumber)
- RtAddress = int(self.__Token, 0)
+ RtAddress = long(self.__Token, 0)
Obj.RtBaseAddress = RtAddress
## __GetBlockStatements() method
@@ -1709,7 +1711,7 @@ class FdfParser:
self.SetPcdLocalation(PcdPair)
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
self.Profile.PcdFileLineDict[PcdPair] = FileLineTuple
- BlockSize = int(BlockSize, 0)
+ BlockSize = long(BlockSize, 0)
BlockNumber = None
if self.__IsKeyword( "NumBlocks"):
@@ -1719,7 +1721,7 @@ class FdfParser:
if not self.__GetNextDecimalNumber() and not self.__GetNextHexNumber():
raise Warning("expected block numbers", self.FileName, self.CurrentLineNumber)
- BlockNumber = int(self.__Token, 0)
+ BlockNumber = long(self.__Token, 0)
Obj.BlockSizeList.append((BlockSize, BlockNumber, BlockSizePcd))
return True
@@ -1828,7 +1830,7 @@ class FdfParser:
Expr += CurCh
self.__GetOneChar()
try:
- return int(
+ return long(
ValueExpression(Expr,
self.__CollectMacroPcd()
)(True), 0)
@@ -1876,7 +1878,7 @@ class FdfParser:
RegionOffsetPcdPattern.match(self.__CurrentLine()[self.CurrentOffsetWithinLine:]))
if IsRegionPcd:
RegionObj.PcdOffset = self.__GetNextPcdSettings()
- self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + int(Fd.BaseAddress, 0))
+ self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + long(Fd.BaseAddress, 0))
self.SetPcdLocalation(RegionObj.PcdOffset)
self.__PcdDict['%s.%s' % (RegionObj.PcdOffset[1], RegionObj.PcdOffset[0])] = "0x%x" % RegionObj.Offset
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
@@ -3231,9 +3233,9 @@ class FdfParser:
if FdfParser.__Verify(Name, Value, 'UINT64'):
FmpData.MonotonicCount = Value
if FmpData.MonotonicCount.upper().startswith('0X'):
- FmpData.MonotonicCount = (int)(FmpData.MonotonicCount, 16)
+ FmpData.MonotonicCount = (long)(FmpData.MonotonicCount, 16)
else:
- FmpData.MonotonicCount = (int)(FmpData.MonotonicCount)
+ FmpData.MonotonicCount = (long)(FmpData.MonotonicCount)
if not self.__GetNextToken():
break
else:
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
index 3daf75b205..4c35aac76a 100644
--- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import Ffs
from . import Rule
import Common.LongFilePathOs as os
@@ -82,7 +83,7 @@ class FileStatement (FileStatementClassObject) :
Dict.update(self.DefineVarDict)
SectionAlignments = None
if self.FvName is not None :
- Buffer = BytesIO()
+ Buffer = BytesIO('')
if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
@@ -99,7 +100,7 @@ class FileStatement (FileStatementClassObject) :
elif self.FileName is not 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 = BytesIO()
+ FileContent = ''
MaxAlignIndex = 0
MaxAlignValue = 1
for Index, File in enumerate(self.FileName):
@@ -115,15 +116,15 @@ class FileStatement (FileStatementClassObject) :
if AlignValue > MaxAlignValue:
MaxAlignIndex = Index
MaxAlignValue = AlignValue
- FileContent.write(Content)
- if len(FileContent.getvalue()) % AlignValue != 0:
+ FileContent += Content
+ if len(FileContent) % AlignValue != 0:
Size = AlignValue - len(FileContent) % AlignValue
for i in range(0, Size):
- FileContent.write(pack('B', 0xFF))
+ FileContent += pack('B', 0xFF)
- if FileContent.getvalue() != b'':
+ if FileContent:
OutputRAWFile = os.path.join(GenFdsGlobalVariable.FfsDir, self.NameGuid, self.NameGuid + '.raw')
- SaveFileOnChange(OutputRAWFile, FileContent.getvalue(), True)
+ SaveFileOnChange(OutputRAWFile, FileContent, True)
self.FileName = OutputRAWFile
self.SubAlignment = self.SubAlignment[MaxAlignIndex]
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 9ef03edecc..6149bc81b4 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -16,6 +16,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import Rule
import Common.LongFilePathOs as os
from io import BytesIO
@@ -770,9 +771,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
if ImageObj.SectionAlignment < 0x400:
self.Alignment = str (ImageObj.SectionAlignment)
elif ImageObj.SectionAlignment < 0x100000:
- self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'
+ self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
else:
- self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'
+ self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
if not NoStrip:
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
@@ -812,9 +813,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
if ImageObj.SectionAlignment < 0x400:
self.Alignment = str (ImageObj.SectionAlignment)
elif ImageObj.SectionAlignment < 0x100000:
- self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'
+ self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
else:
- self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'
+ self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'
if not NoStrip:
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
@@ -1073,7 +1074,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
def __GetBuildOutputMapFileVfrUniInfo(self, VfrUniBaseName):
MapFileName = os.path.join(self.EfiOutputPath, self.BaseName + ".map")
EfiFileName = os.path.join(self.EfiOutputPath, self.BaseName + ".efi")
- return GetVariableOffset(MapFileName, EfiFileName, list(VfrUniBaseName.values()))
+ return GetVariableOffset(MapFileName, EfiFileName, VfrUniBaseName.values())
## __GenUniVfrOffsetFile() method
#
@@ -1086,7 +1087,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
def __GenUniVfrOffsetFile(VfrUniOffsetList, UniVfrOffsetFileName):
# Use a instance of StringIO to cache data
- fStringIO = BytesIO()
+ fStringIO = BytesIO('')
for Item in VfrUniOffsetList:
if (Item[0].find("Strings") != -1):
@@ -1096,7 +1097,8 @@ class FfsInfStatement(FfsInfStatementClassObject):
# { 0x8913c5e0, 0x33f6, 0x4d86, { 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66 } }
#
UniGuid = [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66]
- fStringIO.write(bytes(UniGuid))
+ UniGuid = [chr(ItemGuid) for ItemGuid in UniGuid]
+ fStringIO.write(''.join(UniGuid))
UniValue = pack ('Q', int (Item[1], 16))
fStringIO.write (UniValue)
else:
@@ -1106,7 +1108,8 @@ class FfsInfStatement(FfsInfStatementClassObject):
# { 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } };
#
VfrGuid = [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2]
- fStringIO.write(bytes(VfrGuid))
+ VfrGuid = [chr(ItemGuid) for ItemGuid in VfrGuid]
+ fStringIO.write(''.join(VfrGuid))
type (Item[1])
VfrValue = pack ('Q', int (Item[1], 16))
fStringIO.write (VfrValue)
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index 3c3cd0b308..0d005ebf5b 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
## @file
# process FV generation
#
@@ -18,7 +19,6 @@
import Common.LongFilePathOs as os
import subprocess
from io import BytesIO
-from io import StringIO
from struct import *
from . import Ffs
@@ -205,16 +205,16 @@ class FV (FvClassObject):
# PI FvHeader is 0x48 byte
FvHeaderBuffer = FvFileObj.read(0x48)
# FV alignment position.
- FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)
+ FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F)
if FvAlignmentValue >= 0x400:
if FvAlignmentValue >= 0x100000:
if FvAlignmentValue >= 0x1000000:
#The max alignment supported by FFS is 16M.
self.FvAlignment = "16M"
else:
- self.FvAlignment = str(FvAlignmentValue // 0x100000) + "M"
+ self.FvAlignment = str(FvAlignmentValue / 0x100000) + "M"
else:
- self.FvAlignment = str(FvAlignmentValue // 0x400) + "K"
+ self.FvAlignment = str(FvAlignmentValue / 0x400) + "K"
else:
# FvAlignmentValue is less than 1K
self.FvAlignment = str (FvAlignmentValue)
@@ -265,7 +265,7 @@ class FV (FvClassObject):
#
self.InfFileName = os.path.join(GenFdsGlobalVariable.FvDir,
self.UiFvName + '.inf')
- self.FvInfFile = StringIO()
+ self.FvInfFile = BytesIO()
#
# Add [Options]
@@ -340,7 +340,7 @@ class FV (FvClassObject):
GenFdsGlobalVariable.ErrorLogger("FV Extension Header Entries declared for %s with no FvNameGuid declaration." % (self.UiFvName))
else:
TotalSize = 16 + 4
- Buffer = bytearray()
+ Buffer = ''
if self.UsedSizeEnable:
TotalSize += (4 + 4)
## define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03
@@ -367,7 +367,7 @@ class FV (FvClassObject):
#
Buffer += (pack('HH', (FvUiLen + 16 + 4), 0x0002)
+ PackGUID(Guid)
- + bytes(self.UiFvName, 'utf-8'))
+ + self.UiFvName)
for Index in range (0, len(self.FvExtEntryType)):
if self.FvExtEntryType[Index] == 'FILE':
diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py
index f15df23514..04556fc870 100644
--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import Section
from io import BytesIO
from .Ffs import Ffs
@@ -70,7 +71,7 @@ class FvImageSection(FvImageSectionClassObject):
# PI FvHeader is 0x48 byte
FvHeaderBuffer = FvFileObj.read(0x48)
# FV alignment position.
- FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)
+ FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)
FvFileObj.close()
if FvAlignmentValue > MaxFvAlignment:
MaxFvAlignment = FvAlignmentValue
@@ -86,9 +87,9 @@ class FvImageSection(FvImageSectionClassObject):
if MaxFvAlignment >= 0x1000000:
self.Alignment = "16M"
else:
- self.Alignment = str(MaxFvAlignment // 0x100000) + "M"
+ self.Alignment = str(MaxFvAlignment / 0x100000) + "M"
else:
- self.Alignment = str (MaxFvAlignment // 0x400) + "K"
+ self.Alignment = str (MaxFvAlignment / 0x400) + "K"
else:
# MaxFvAlignment is less than 1K
self.Alignment = str (MaxFvAlignment)
@@ -98,12 +99,10 @@ class FvImageSection(FvImageSectionClassObject):
# Generate Fv
#
if self.FvName is not None:
- Buffer = BytesIO()
+ Buffer = BytesIO('')
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName)
if Fv is not None:
self.Fv = Fv
- if not self.FvAddr and self.Fv.BaseAddress:
- self.FvAddr = self.Fv.BaseAddress
FvFileName = Fv.AddToBuffer(Buffer, self.FvAddr, MacroDict = Dict, Flag=IsMakefile)
if Fv.FvAlignment is not None:
if self.Alignment is None:
@@ -120,7 +119,7 @@ class FvImageSection(FvImageSectionClassObject):
# PI FvHeader is 0x48 byte
FvHeaderBuffer = FvFileObj.read(0x48)
# FV alignment position.
- FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)
+ FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)
# FvAlignmentValue is larger than or equal to 1K
if FvAlignmentValue >= 0x400:
if FvAlignmentValue >= 0x100000:
@@ -128,9 +127,9 @@ class FvImageSection(FvImageSectionClassObject):
if FvAlignmentValue >= 0x1000000:
self.Alignment = "16M"
else:
- self.Alignment = str(FvAlignmentValue // 0x100000) + "M"
+ self.Alignment = str(FvAlignmentValue / 0x100000) + "M"
else:
- self.Alignment = str (FvAlignmentValue // 0x400) + "K"
+ self.Alignment = str (FvAlignmentValue / 0x400) + "K"
else:
# FvAlignmentValue is less than 1K
self.Alignment = str (FvAlignmentValue)
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 32824ae80e..9dec9c5eb5 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -15,6 +15,8 @@
##
# Import Modules
#
+from __future__ import print_function
+from __future__ import absolute_import
from optparse import OptionParser
import sys
import Common.LongFilePathOs as os
@@ -27,7 +29,6 @@ from Workspace.BuildClassObject import PcdClassObject
from . import RuleComplexFile
from .EfiSection import EfiSection
from io import BytesIO
-from io import StringIO
import Common.TargetTxtClassObject as TargetTxtClassObject
import Common.ToolDefClassObject as ToolDefClassObject
from Common.DataType import *
@@ -321,8 +322,6 @@ def main():
continue
for RegionData in RegionObj.RegionDataList:
if FvObj.UiFvName.upper() == RegionData.upper():
- if not FvObj.BaseAddress:
- FvObj.BaseAddress = '0x%x' % (int(FdObj.BaseAddress, 0) + RegionObj.Offset)
if FvObj.FvRegionInFD:
if FvObj.FvRegionInFD != RegionObj.Size:
EdkLogger.error("GenFds", FORMAT_INVALID, "The FV %s's region is specified in multiple FD with different value." %FvObj.UiFvName)
@@ -457,7 +456,7 @@ class GenFds :
return
elif GenFds.OnlyGenerateThisFv is None:
for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values():
- Buffer = BytesIO()
+ Buffer = BytesIO('')
FvObj.AddToBuffer(Buffer)
Buffer.close()
@@ -560,9 +559,9 @@ class GenFds :
GenFdsGlobalVariable.InfLogger('\nFV Space Information')
for FvSpaceInfo in FvSpaceInfoList:
Name = FvSpaceInfo[0]
- TotalSizeValue = int(FvSpaceInfo[1], 0)
- UsedSizeValue = int(FvSpaceInfo[2], 0)
- FreeSizeValue = int(FvSpaceInfo[3], 0)
+ TotalSizeValue = long(FvSpaceInfo[1], 0)
+ UsedSizeValue = long(FvSpaceInfo[2], 0)
+ FreeSizeValue = long(FvSpaceInfo[3], 0)
if UsedSizeValue == TotalSizeValue:
Percentage = '100'
else:
@@ -588,7 +587,7 @@ class GenFds :
if PcdValue == '':
return
- Int64PcdValue = int(PcdValue, 0)
+ Int64PcdValue = long(PcdValue, 0)
if Int64PcdValue == 0 or Int64PcdValue < -1:
return
@@ -603,27 +602,22 @@ class GenFds :
def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):
GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, "Guid.xref")
- GuidXRefFile = StringIO('')
+ GuidXRefFile = BytesIO('')
PkgGuidDict = {}
GuidDict = {}
ModuleList = []
FileGuidList = []
GuidPattern = gGuidPattern
- VariableGuidSet = set()
for Arch in ArchList:
PlatformDataBase = BuildDb.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
PkgList = GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag)
for P in PkgList:
PkgGuidDict.update(P.Guids)
- for Name, Guid in sorted(PlatformDataBase.Pcds):
+ for Name, Guid in PlatformDataBase.Pcds:
Pcd = PlatformDataBase.Pcds[Name, Guid]
if Pcd.Type in [TAB_PCDS_DYNAMIC_HII, TAB_PCDS_DYNAMIC_EX_HII]:
for SkuId in Pcd.SkuInfoList:
Sku = Pcd.SkuInfoList[SkuId]
- if Sku.VariableGuid in VariableGuidSet:
- continue
- else:
- VariableGuidSet.add(Sku.VariableGuid)
if Sku.VariableGuid and Sku.VariableGuid in PkgGuidDict.keys():
GuidDict[Sku.VariableGuid] = PkgGuidDict[Sku.VariableGuid]
for ModuleFile in PlatformDataBase.Modules:
@@ -691,7 +685,7 @@ class GenFds :
F.read()
length = F.tell()
F.seek(4)
- TmpStr = unpack('%dh' % ((length - 4) // 2), F.read())
+ TmpStr = unpack('%dh' % ((length - 4) / 2), F.read())
Name = ''.join(chr(c) for c in TmpStr[:-1])
else:
FileList = []
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 052736b9d8..14578a92a9 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import sys
import subprocess
@@ -720,8 +721,8 @@ class GenFdsGlobalVariable:
return
if PopenObject.returncode != 0 or GenFdsGlobalVariable.VerboseMode or GenFdsGlobalVariable.DebugLevel != -1:
GenFdsGlobalVariable.InfLogger ("Return Value = %d" % PopenObject.returncode)
- GenFdsGlobalVariable.InfLogger (out.decode(encoding='utf-8',errors='ignore'))
- GenFdsGlobalVariable.InfLogger (error.decode(encoding='utf-8', errors='ignore'))
+ GenFdsGlobalVariable.InfLogger (out)
+ GenFdsGlobalVariable.InfLogger (error)
if PopenObject.returncode != 0:
print("###", cmd)
EdkLogger.error("GenFds", COMMAND_FAILURE, errorMess)
diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Source/Python/GenFds/GuidSection.py
index 1f0c87dd7e..fd660737f4 100644
--- a/BaseTools/Source/Python/GenFds/GuidSection.py
+++ b/BaseTools/Source/Python/GenFds/GuidSection.py
@@ -16,6 +16,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import Section
import subprocess
from .Ffs import Ffs
diff --git a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py
index 5d03250158..e56174ec3c 100644
--- a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
from .GenFdsGlobalVariable import GenFdsGlobalVariable
diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
index c5d106fd85..e416b838d1 100644
--- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import RuleSimpleFile
from . import RuleComplexFile
from . import Section
diff --git a/BaseTools/Source/Python/GenFds/OptionRom.py b/BaseTools/Source/Python/GenFds/OptionRom.py
index ebe30fec58..bb7071fa7f 100644
--- a/BaseTools/Source/Python/GenFds/OptionRom.py
+++ b/BaseTools/Source/Python/GenFds/OptionRom.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import subprocess
diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py
index 31c65a32a1..5242b74c9e 100644
--- a/BaseTools/Source/Python/GenFds/Region.py
+++ b/BaseTools/Source/Python/GenFds/Region.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from struct import *
from .GenFdsGlobalVariable import GenFdsGlobalVariable
from io import BytesIO
@@ -57,8 +58,8 @@ class Region(RegionClassObject):
PadByte = pack('B', 0xFF)
else:
PadByte = pack('B', 0)
- for i in range(0, Size):
- Buffer.write(PadByte)
+ PadData = ''.join(PadByte for i in xrange(0, Size))
+ Buffer.write(PadData)
## AddToBuffer()
#
@@ -127,7 +128,7 @@ class Region(RegionClassObject):
if self.FvAddress % FvAlignValue != 0:
EdkLogger.error("GenFds", GENFDS_ERROR,
"FV (%s) is NOT %s Aligned!" % (FvObj.UiFvName, FvObj.FvAlignment))
- FvBuffer = BytesIO()
+ FvBuffer = BytesIO('')
FvBaseAddress = '0x%X' % self.FvAddress
BlockSize = None
BlockNum = None
@@ -296,7 +297,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:
@@ -305,7 +306,7 @@ 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
diff --git a/BaseTools/Source/Python/GenFds/RuleComplexFile.py b/BaseTools/Source/Python/GenFds/RuleComplexFile.py
index 066156a2f6..c357fedbd3 100644
--- a/BaseTools/Source/Python/GenFds/RuleComplexFile.py
+++ b/BaseTools/Source/Python/GenFds/RuleComplexFile.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import Rule
from CommonDataClass.FdfClass import RuleComplexFileClassObject
diff --git a/BaseTools/Source/Python/GenFds/RuleSimpleFile.py b/BaseTools/Source/Python/GenFds/RuleSimpleFile.py
index 4e6b9231a2..7aa184e7d8 100644
--- a/BaseTools/Source/Python/GenFds/RuleSimpleFile.py
+++ b/BaseTools/Source/Python/GenFds/RuleSimpleFile.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import Rule
from CommonDataClass.FdfClass import RuleSimpleFileClassObject
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py
index 61dc32762b..19a70009dc 100644
--- a/BaseTools/Source/Python/GenFds/Section.py
+++ b/BaseTools/Source/Python/GenFds/Section.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from CommonDataClass.FdfClass import SectionClassObject
from .GenFdsGlobalVariable import GenFdsGlobalVariable
import Common.LongFilePathOs as os, glob
diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source/Python/GenFds/UiSection.py
index ba0534fa49..24f2f3ca93 100644
--- a/BaseTools/Source/Python/GenFds/UiSection.py
+++ b/BaseTools/Source/Python/GenFds/UiSection.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from . import Section
from .Ffs import Ffs
import subprocess
diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Source/Python/GenFds/VerSection.py
index eb3e930755..db71fe9653 100644
--- a/BaseTools/Source/Python/GenFds/VerSection.py
+++ b/BaseTools/Source/Python/GenFds/VerSection.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from .Ffs import Ffs
from . import Section
import Common.LongFilePathOs as os
diff --git a/BaseTools/Source/Python/GenFds/Vtf.py b/BaseTools/Source/Python/GenFds/Vtf.py
index 6a8294afb0..5cb2d4acfb 100644
--- a/BaseTools/Source/Python/GenFds/Vtf.py
+++ b/BaseTools/Source/Python/GenFds/Vtf.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from .GenFdsGlobalVariable import GenFdsGlobalVariable
import Common.LongFilePathOs as os
from CommonDataClass.FdfClass import VtfClassObject