Revert BaseTools: PYTHON3 migration
This reverts commit 6693f359b3c213513c5096a06c6f67244a44dc52..
678f851312
.
Python3 migration is the fundamental change. It requires every developer
to install Python3. Before this migration, the well communication and wide
verification must be done. But now, most people is not aware of this change,
and not try it. So, Python3 migration is reverted and be moved to edk2-staging
Python3 branch for the edk2 user evaluation.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
@@ -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)))
|
||||
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -15,6 +15,7 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from __future__ import absolute_import
|
||||
from .Ffs import Ffs
|
||||
from . import Section
|
||||
import subprocess
|
||||
|
@@ -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):
|
||||
|
@@ -15,6 +15,7 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from __future__ import absolute_import
|
||||
from . import Section
|
||||
from .GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import subprocess
|
||||
|
@@ -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')
|
||||
|
@@ -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 :
|
||||
|
@@ -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:
|
||||
|
@@ -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]
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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':
|
||||
|
@@ -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)
|
||||
|
@@ -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 = []
|
||||
|
@@ -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)
|
||||
|
@@ -16,6 +16,7 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from __future__ import absolute_import
|
||||
from . import Section
|
||||
import subprocess
|
||||
from .Ffs import Ffs
|
||||
|
@@ -15,6 +15,7 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from __future__ import absolute_import
|
||||
import Common.LongFilePathOs as os
|
||||
|
||||
from .GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
|
@@ -15,6 +15,7 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from __future__ import absolute_import
|
||||
from . import RuleSimpleFile
|
||||
from . import RuleComplexFile
|
||||
from . import Section
|
||||
|
@@ -15,6 +15,7 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from __future__ import absolute_import
|
||||
import Common.LongFilePathOs as os
|
||||
import subprocess
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -15,6 +15,7 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from __future__ import absolute_import
|
||||
from . import Rule
|
||||
from CommonDataClass.FdfClass import RuleComplexFileClassObject
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from __future__ import absolute_import
|
||||
from . import Rule
|
||||
from CommonDataClass.FdfClass import RuleSimpleFileClassObject
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -15,6 +15,7 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from __future__ import absolute_import
|
||||
from . import Section
|
||||
from .Ffs import Ffs
|
||||
import subprocess
|
||||
|
@@ -15,6 +15,7 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from __future__ import absolute_import
|
||||
from .Ffs import Ffs
|
||||
from . import Section
|
||||
import Common.LongFilePathOs as os
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user