BaseTools: Move ImageBinDict to GenFdsGlobalVariable.py
Move "ImageBinDict" from GenFds.py to GenFdsGlobalVariable.py so that we can remove the requirement to import GenFds.GenFds in Capsule.py, Fd.py and Fv.py. This breaks the following circular imports: * GenFds.FdfParser => GenFds.Capsule => GenFds.GenFds => GenFds.FdfParser * GenFds.FdfParser => GenFds.Fd => GenFds.GenFds => GenFds.FdfParser * GenFds.FdfParser => GenFds.Fd => GenFds.Fv => GenFds.GenFds => GenFds.FdfParser Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Gary Lin <glin@suse.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
This commit is contained in:
@ -201,9 +201,8 @@ class Capsule (CapsuleClassObject) :
|
|||||||
# @retval string Generated Capsule file path
|
# @retval string Generated Capsule file path
|
||||||
#
|
#
|
||||||
def GenCapsule(self):
|
def GenCapsule(self):
|
||||||
from .GenFds import GenFds
|
if self.UiCapsuleName.upper() + 'cap' in GenFdsGlobalVariable.ImageBinDict:
|
||||||
if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict:
|
return GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.upper() + 'cap']
|
||||||
return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap']
|
|
||||||
|
|
||||||
GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCapsuleName)
|
GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCapsuleName)
|
||||||
if ('CAPSULE_GUID' in self.TokensDict and
|
if ('CAPSULE_GUID' in self.TokensDict and
|
||||||
@ -237,7 +236,7 @@ class Capsule (CapsuleClassObject) :
|
|||||||
|
|
||||||
GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s Capsule Successfully" %self.UiCapsuleName)
|
GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s Capsule Successfully" %self.UiCapsuleName)
|
||||||
GenFdsGlobalVariable.SharpCounter = 0
|
GenFdsGlobalVariable.SharpCounter = 0
|
||||||
GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] = CapOutputFile
|
GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] = CapOutputFile
|
||||||
return CapOutputFile
|
return CapOutputFile
|
||||||
|
|
||||||
## Generate inf file for capsule
|
## Generate inf file for capsule
|
||||||
|
@ -47,9 +47,8 @@ class FD(FDClassObject):
|
|||||||
# @retval string Generated FD file name
|
# @retval string Generated FD file name
|
||||||
#
|
#
|
||||||
def GenFd (self, Flag = False):
|
def GenFd (self, Flag = False):
|
||||||
from .GenFds import GenFds
|
if self.FdUiName.upper() + 'fd' in GenFdsGlobalVariable.ImageBinDict:
|
||||||
if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict:
|
return GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper() + 'fd']
|
||||||
return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd']
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Print Information
|
# Print Information
|
||||||
@ -94,7 +93,7 @@ class FD(FDClassObject):
|
|||||||
PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
|
PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
|
||||||
PadRegion.Size = RegionObj.Offset - PadRegion.Offset
|
PadRegion.Size = RegionObj.Offset - PadRegion.Offset
|
||||||
if not Flag:
|
if not Flag:
|
||||||
PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
|
PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
|
||||||
PreviousRegionStart = RegionObj.Offset
|
PreviousRegionStart = RegionObj.Offset
|
||||||
PreviousRegionSize = RegionObj.Size
|
PreviousRegionSize = RegionObj.Size
|
||||||
#
|
#
|
||||||
@ -103,7 +102,7 @@ class FD(FDClassObject):
|
|||||||
if PreviousRegionSize > self.Size:
|
if PreviousRegionSize > self.Size:
|
||||||
pass
|
pass
|
||||||
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
|
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
|
||||||
RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
|
RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
|
||||||
|
|
||||||
FdBuffer = BytesIO('')
|
FdBuffer = BytesIO('')
|
||||||
PreviousRegionStart = -1
|
PreviousRegionStart = -1
|
||||||
@ -124,7 +123,7 @@ class FD(FDClassObject):
|
|||||||
PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
|
PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
|
||||||
PadRegion.Size = RegionObj.Offset - PadRegion.Offset
|
PadRegion.Size = RegionObj.Offset - PadRegion.Offset
|
||||||
if not Flag:
|
if not Flag:
|
||||||
PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
|
PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
|
||||||
PreviousRegionStart = RegionObj.Offset
|
PreviousRegionStart = RegionObj.Offset
|
||||||
PreviousRegionSize = RegionObj.Size
|
PreviousRegionSize = RegionObj.Size
|
||||||
#
|
#
|
||||||
@ -138,7 +137,7 @@ class FD(FDClassObject):
|
|||||||
# Call each region's AddToBuffer function
|
# Call each region's AddToBuffer function
|
||||||
#
|
#
|
||||||
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
|
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
|
||||||
RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict, Flag=Flag)
|
RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict, Flag=Flag)
|
||||||
#
|
#
|
||||||
# Write the buffer contents to Fd file
|
# Write the buffer contents to Fd file
|
||||||
#
|
#
|
||||||
@ -146,7 +145,7 @@ class FD(FDClassObject):
|
|||||||
if not Flag:
|
if not Flag:
|
||||||
SaveFileOnChange(FdFileName, FdBuffer.getvalue())
|
SaveFileOnChange(FdFileName, FdBuffer.getvalue())
|
||||||
FdBuffer.close()
|
FdBuffer.close()
|
||||||
GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] = FdFileName
|
GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper() + 'fd'] = FdFileName
|
||||||
return FdFileName
|
return FdFileName
|
||||||
|
|
||||||
## generate VTF
|
## generate VTF
|
||||||
|
@ -70,9 +70,8 @@ class FV (FvClassObject):
|
|||||||
#
|
#
|
||||||
def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :
|
def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :
|
||||||
|
|
||||||
from .GenFds import GenFds
|
if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFdsGlobalVariable.ImageBinDict:
|
||||||
if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict:
|
return GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv']
|
||||||
return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv']
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check whether FV in Capsule is in FD flash region.
|
# Check whether FV in Capsule is in FD flash region.
|
||||||
@ -85,7 +84,7 @@ class FV (FvClassObject):
|
|||||||
for RegionData in RegionObj.RegionDataList:
|
for RegionData in RegionObj.RegionDataList:
|
||||||
if RegionData.endswith(".fv"):
|
if RegionData.endswith(".fv"):
|
||||||
continue
|
continue
|
||||||
elif RegionData.upper() + 'fv' in GenFds.ImageBinDict:
|
elif RegionData.upper() + 'fv' in GenFdsGlobalVariable.ImageBinDict:
|
||||||
continue
|
continue
|
||||||
elif self.UiFvName.upper() == RegionData.upper():
|
elif self.UiFvName.upper() == RegionData.upper():
|
||||||
GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))
|
GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))
|
||||||
@ -140,7 +139,7 @@ class FV (FvClassObject):
|
|||||||
FvOutputFile = self.CreateFileName
|
FvOutputFile = self.CreateFileName
|
||||||
|
|
||||||
if Flag:
|
if Flag:
|
||||||
GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
|
GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
|
||||||
return FvOutputFile
|
return FvOutputFile
|
||||||
|
|
||||||
FvInfoFileName = os.path.join(GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf')
|
FvInfoFileName = os.path.join(GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf')
|
||||||
@ -220,7 +219,7 @@ class FV (FvClassObject):
|
|||||||
# FvAlignmentValue is less than 1K
|
# FvAlignmentValue is less than 1K
|
||||||
self.FvAlignment = str (FvAlignmentValue)
|
self.FvAlignment = str (FvAlignmentValue)
|
||||||
FvFileObj.close()
|
FvFileObj.close()
|
||||||
GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
|
GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
|
||||||
GenFdsGlobalVariable.LargeFileInFvFlags.pop()
|
GenFdsGlobalVariable.LargeFileInFvFlags.pop()
|
||||||
else:
|
else:
|
||||||
GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV file." %self.UiFvName)
|
GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV file." %self.UiFvName)
|
||||||
|
@ -415,8 +415,6 @@ def myOptionParser():
|
|||||||
#
|
#
|
||||||
class GenFds :
|
class GenFds :
|
||||||
FdfParsef = None
|
FdfParsef = None
|
||||||
# FvName, FdName, CapName in FDF, Image file name
|
|
||||||
ImageBinDict = {}
|
|
||||||
OnlyGenerateThisFd = None
|
OnlyGenerateThisFd = None
|
||||||
OnlyGenerateThisFv = None
|
OnlyGenerateThisFv = None
|
||||||
OnlyGenerateThisCap = None
|
OnlyGenerateThisCap = None
|
||||||
|
@ -91,6 +91,9 @@ class GenFdsGlobalVariable:
|
|||||||
|
|
||||||
SectionHeader = struct.Struct("3B 1B")
|
SectionHeader = struct.Struct("3B 1B")
|
||||||
|
|
||||||
|
# FvName, FdName, CapName in FDF, Image file name
|
||||||
|
ImageBinDict = {}
|
||||||
|
|
||||||
## LoadBuildRule
|
## LoadBuildRule
|
||||||
#
|
#
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Reference in New Issue
Block a user