BaseTools: change the Division Operator in the expression

PEP 238 -- Changing the Division Operator
x/y to return a reasonable approximation of the mathematical result
    of the division ("true division")
x//y to return the floor ("floor division")

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Yunhua Feng
2018-08-14 15:57:47 +08:00
committed by Yonghong Zhu
parent 00fcce9153
commit 2e300969ae
14 changed files with 49 additions and 42 deletions

View File

@ -3729,7 +3729,7 @@ class ModuleAutoGen(AutoGen):
Padding = '0x00, ' Padding = '0x00, '
if Unicode: if Unicode:
Padding = Padding * 2 Padding = Padding * 2
ArraySize = ArraySize / 2 ArraySize = ArraySize // 2
if ArraySize < (len(PcdValue) + 1): if ArraySize < (len(PcdValue) + 1):
if Pcd.MaxSizeUserSet: if Pcd.MaxSizeUserSet:
EdkLogger.error("build", AUTOGEN_ERROR, EdkLogger.error("build", AUTOGEN_ERROR,

View File

@ -1050,7 +1050,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
else: else:
NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ', ' NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ', '
if Unicode: if Unicode:
ArraySize = ArraySize / 2 ArraySize = ArraySize // 2
Value = NewValue + '0 }' Value = NewValue + '0 }'
if ArraySize < ValueSize: if ArraySize < ValueSize:
if Pcd.MaxSizeUserSet: if Pcd.MaxSizeUserSet:
@ -1060,7 +1060,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
else: else:
ArraySize = Pcd.GetPcdSize() ArraySize = Pcd.GetPcdSize()
if Unicode: if Unicode:
ArraySize = ArraySize / 2 ArraySize = ArraySize // 2
Array = '[%d]' % ArraySize Array = '[%d]' % ArraySize
# #
# skip casting for fixed at build since it breaks ARM assembly. # skip casting for fixed at build since it breaks ARM assembly.
@ -1919,7 +1919,7 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, TransParent):
else: else:
ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_1BIT) ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_1BIT)
ImageBuffer += pack('B', PaletteIndex) ImageBuffer += pack('B', PaletteIndex)
Width = (BmpHeader.biWidth + 7)/8 Width = (BmpHeader.biWidth + 7)//8
if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2: if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2:
PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : BmpHeader.bfOffBits] PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : BmpHeader.bfOffBits]
elif BmpHeader.biBitCount == 4: elif BmpHeader.biBitCount == 4:
@ -1928,7 +1928,7 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, TransParent):
else: else:
ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_4BIT) ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_4BIT)
ImageBuffer += pack('B', PaletteIndex) ImageBuffer += pack('B', PaletteIndex)
Width = (BmpHeader.biWidth + 1)/2 Width = (BmpHeader.biWidth + 1)//2
if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2: if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2:
PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : BmpHeader.bfOffBits] PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : BmpHeader.bfOffBits]
elif BmpHeader.biBitCount == 8: elif BmpHeader.biBitCount == 8:

View File

@ -430,7 +430,7 @@ class GenVPD :
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, 'The offset value of PCD %s should be %s-byte aligned.' % (PCD.PcdCName, Alignment)) EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, 'The offset value of PCD %s should be %s-byte aligned.' % (PCD.PcdCName, Alignment))
else: else:
if PCD.PcdOccupySize % Alignment != 0: if PCD.PcdOccupySize % Alignment != 0:
PCD.PcdOccupySize = (PCD.PcdOccupySize / Alignment + 1) * Alignment PCD.PcdOccupySize = (PCD.PcdOccupySize // Alignment + 1) * Alignment
PackSize = PCD.PcdOccupySize PackSize = PCD.PcdOccupySize
if PCD._IsBoolean(PCD.PcdValue, PCD.PcdSize): if PCD._IsBoolean(PCD.PcdValue, PCD.PcdSize):
@ -508,7 +508,7 @@ class GenVPD :
NowOffset = 0 NowOffset = 0
for Pcd in self.PcdUnknownOffsetList : for Pcd in self.PcdUnknownOffsetList :
if NowOffset % Pcd.Alignment != 0: if NowOffset % Pcd.Alignment != 0:
NowOffset = (NowOffset/ Pcd.Alignment + 1) * Pcd.Alignment NowOffset = (NowOffset // Pcd.Alignment + 1) * Pcd.Alignment
Pcd.PcdBinOffset = NowOffset Pcd.PcdBinOffset = NowOffset
Pcd.PcdOffset = str(hex(Pcd.PcdBinOffset)) Pcd.PcdOffset = str(hex(Pcd.PcdBinOffset))
NowOffset += Pcd.PcdOccupySize NowOffset += Pcd.PcdOccupySize
@ -572,7 +572,7 @@ class GenVPD :
# Not been fixed # Not been fixed
if eachUnfixedPcd.PcdOffset == '*' : if eachUnfixedPcd.PcdOffset == '*' :
if LastOffset % eachUnfixedPcd.Alignment != 0: if LastOffset % eachUnfixedPcd.Alignment != 0:
LastOffset = (LastOffset / eachUnfixedPcd.Alignment + 1) * eachUnfixedPcd.Alignment LastOffset = (LastOffset // eachUnfixedPcd.Alignment + 1) * eachUnfixedPcd.Alignment
# The offset un-fixed pcd can write into this free space # The offset un-fixed pcd can write into this free space
if needFixPcdSize <= (NowOffset - LastOffset) : if needFixPcdSize <= (NowOffset - LastOffset) :
# Change the offset value of un-fixed pcd # Change the offset value of un-fixed pcd
@ -626,7 +626,7 @@ class GenVPD :
NeedFixPcd.PcdBinOffset = LastPcd.PcdBinOffset + LastPcd.PcdOccupySize NeedFixPcd.PcdBinOffset = LastPcd.PcdBinOffset + LastPcd.PcdOccupySize
if NeedFixPcd.PcdBinOffset % NeedFixPcd.Alignment != 0: if NeedFixPcd.PcdBinOffset % NeedFixPcd.Alignment != 0:
NeedFixPcd.PcdBinOffset = (NeedFixPcd.PcdBinOffset / NeedFixPcd.Alignment + 1) * NeedFixPcd.Alignment NeedFixPcd.PcdBinOffset = (NeedFixPcd.PcdBinOffset // NeedFixPcd.Alignment + 1) * NeedFixPcd.Alignment
NeedFixPcd.PcdOffset = str(hex(NeedFixPcd.PcdBinOffset)) NeedFixPcd.PcdOffset = str(hex(NeedFixPcd.PcdBinOffset))

View File

@ -425,6 +425,13 @@ class ValueExpression(BaseExpression):
else: else:
Val = Val3 Val = Val3
continue continue
#
# PEP 238 -- Changing the Division Operator
# x/y to return a reasonable approximation of the mathematical result of the division ("true division")
# x//y to return the floor ("floor division")
#
if Op == '/':
Op = '//'
try: try:
Val = self.Eval(Op, Val, EvalFunc()) Val = self.Eval(Op, Val, EvalFunc())
except WrnExpression as Warn: except WrnExpression as Warn:
@ -898,7 +905,7 @@ class ValueExpressionEx(ValueExpression):
if TmpValue.bit_length() == 0: if TmpValue.bit_length() == 0:
PcdValue = '{0x00}' PcdValue = '{0x00}'
else: else:
for I in range((TmpValue.bit_length() + 7) / 8): for I in range((TmpValue.bit_length() + 7) // 8):
TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff)) TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff))
PcdValue = '{' + ', '.join(TmpList) + '}' PcdValue = '{' + ', '.join(TmpList) + '}'
except: except:

View File

@ -1310,7 +1310,7 @@ def ParseDevPathValue (Value):
def ParseFieldValue (Value): def ParseFieldValue (Value):
if isinstance(Value, type(0)): if isinstance(Value, type(0)):
return Value, (Value.bit_length() + 7) / 8 return Value, (Value.bit_length() + 7) // 8
if not isinstance(Value, type('')): if not isinstance(Value, type('')):
raise BadExpression('Type %s is %s' %(Value, type(Value))) raise BadExpression('Type %s is %s' %(Value, type(Value)))
Value = Value.strip() Value = Value.strip()
@ -1431,12 +1431,12 @@ def ParseFieldValue (Value):
raise BadExpression("invalid hex value: %s" % Value) raise BadExpression("invalid hex value: %s" % Value)
if Value == 0: if Value == 0:
return 0, 1 return 0, 1
return Value, (Value.bit_length() + 7) / 8 return Value, (Value.bit_length() + 7) // 8
if Value[0].isdigit(): if Value[0].isdigit():
Value = int(Value, 10) Value = int(Value, 10)
if Value == 0: if Value == 0:
return 0, 1 return 0, 1
return Value, (Value.bit_length() + 7) / 8 return Value, (Value.bit_length() + 7) // 8
if Value.lower() == 'true': if Value.lower() == 'true':
return 1, 1 return 1, 1
if Value.lower() == 'false': if Value.lower() == 'false':

View File

@ -87,9 +87,9 @@ class DataSection (DataSectionClassObject):
if ImageObj.SectionAlignment < 0x400: if ImageObj.SectionAlignment < 0x400:
self.Alignment = str (ImageObj.SectionAlignment) self.Alignment = str (ImageObj.SectionAlignment)
elif ImageObj.SectionAlignment < 0x100000: elif ImageObj.SectionAlignment < 0x100000:
self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K' self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'
else: else:
self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M' self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'
NoStrip = True NoStrip = True
if self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32): if self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):

View File

@ -247,9 +247,9 @@ class EfiSection (EfiSectionClassObject):
if ImageObj.SectionAlignment < 0x400: if ImageObj.SectionAlignment < 0x400:
Align = str (ImageObj.SectionAlignment) Align = str (ImageObj.SectionAlignment)
elif ImageObj.SectionAlignment < 0x100000: elif ImageObj.SectionAlignment < 0x100000:
Align = str (ImageObj.SectionAlignment / 0x400) + 'K' Align = str (ImageObj.SectionAlignment // 0x400) + 'K'
else: else:
Align = str (ImageObj.SectionAlignment / 0x100000) + 'M' Align = str (ImageObj.SectionAlignment // 0x100000) + 'M'
if File[(len(File)-4):] == '.efi': if File[(len(File)-4):] == '.efi':
MapFile = File.replace('.efi', '.map') MapFile = File.replace('.efi', '.map')

View File

@ -770,9 +770,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
if ImageObj.SectionAlignment < 0x400: if ImageObj.SectionAlignment < 0x400:
self.Alignment = str (ImageObj.SectionAlignment) self.Alignment = str (ImageObj.SectionAlignment)
elif ImageObj.SectionAlignment < 0x100000: elif ImageObj.SectionAlignment < 0x100000:
self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K' self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'
else: else:
self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M' self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'
if not NoStrip: if not NoStrip:
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc') FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
@ -812,9 +812,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
if ImageObj.SectionAlignment < 0x400: if ImageObj.SectionAlignment < 0x400:
self.Alignment = str (ImageObj.SectionAlignment) self.Alignment = str (ImageObj.SectionAlignment)
elif ImageObj.SectionAlignment < 0x100000: elif ImageObj.SectionAlignment < 0x100000:
self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K' self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'
else: else:
self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M' self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'
if not NoStrip: if not NoStrip:
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc') FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')

View File

@ -212,9 +212,9 @@ class FV (FvClassObject):
#The max alignment supported by FFS is 16M. #The max alignment supported by FFS is 16M.
self.FvAlignment = "16M" self.FvAlignment = "16M"
else: else:
self.FvAlignment = str(FvAlignmentValue / 0x100000) + "M" self.FvAlignment = str(FvAlignmentValue // 0x100000) + "M"
else: else:
self.FvAlignment = str(FvAlignmentValue / 0x400) + "K" self.FvAlignment = str(FvAlignmentValue // 0x400) + "K"
else: else:
# FvAlignmentValue is less than 1K # FvAlignmentValue is less than 1K
self.FvAlignment = str (FvAlignmentValue) self.FvAlignment = str (FvAlignmentValue)

View File

@ -70,7 +70,7 @@ class FvImageSection(FvImageSectionClassObject):
# PI FvHeader is 0x48 byte # PI FvHeader is 0x48 byte
FvHeaderBuffer = FvFileObj.read(0x48) FvHeaderBuffer = FvFileObj.read(0x48)
# FV alignment position. # FV alignment position.
FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F) FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)
FvFileObj.close() FvFileObj.close()
if FvAlignmentValue > MaxFvAlignment: if FvAlignmentValue > MaxFvAlignment:
MaxFvAlignment = FvAlignmentValue MaxFvAlignment = FvAlignmentValue
@ -86,9 +86,9 @@ class FvImageSection(FvImageSectionClassObject):
if MaxFvAlignment >= 0x1000000: if MaxFvAlignment >= 0x1000000:
self.Alignment = "16M" self.Alignment = "16M"
else: else:
self.Alignment = str(MaxFvAlignment / 0x100000) + "M" self.Alignment = str(MaxFvAlignment // 0x100000) + "M"
else: else:
self.Alignment = str (MaxFvAlignment / 0x400) + "K" self.Alignment = str (MaxFvAlignment // 0x400) + "K"
else: else:
# MaxFvAlignment is less than 1K # MaxFvAlignment is less than 1K
self.Alignment = str (MaxFvAlignment) self.Alignment = str (MaxFvAlignment)
@ -126,9 +126,9 @@ class FvImageSection(FvImageSectionClassObject):
if FvAlignmentValue >= 0x1000000: if FvAlignmentValue >= 0x1000000:
self.Alignment = "16M" self.Alignment = "16M"
else: else:
self.Alignment = str(FvAlignmentValue / 0x100000) + "M" self.Alignment = str(FvAlignmentValue // 0x100000) + "M"
else: else:
self.Alignment = str (FvAlignmentValue / 0x400) + "K" self.Alignment = str (FvAlignmentValue // 0x400) + "K"
else: else:
# FvAlignmentValue is less than 1K # FvAlignmentValue is less than 1K
self.Alignment = str (FvAlignmentValue) self.Alignment = str (FvAlignmentValue)

View File

@ -684,7 +684,7 @@ class GenFds :
F.read() F.read()
length = F.tell() length = F.tell()
F.seek(4) 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]) Name = ''.join(chr(c) for c in TmpStr[:-1])
else: else:
FileList = [] FileList = []

View File

@ -296,7 +296,7 @@ class Region(RegionClassObject):
else: else:
# region ended within current blocks # region ended within current blocks
if self.Offset + self.Size <= End: if self.Offset + self.Size <= End:
ExpectedList.append((BlockSize, (RemindingSize + BlockSize - 1) / BlockSize)) ExpectedList.append((BlockSize, (RemindingSize + BlockSize - 1) // BlockSize))
break break
# region not ended yet # region not ended yet
else: else:
@ -305,7 +305,7 @@ class Region(RegionClassObject):
UsedBlockNum = BlockNum UsedBlockNum = BlockNum
# region started in middle of current blocks # region started in middle of current blocks
else: else:
UsedBlockNum = (End - self.Offset) / BlockSize UsedBlockNum = (End - self.Offset) // BlockSize
Start = End Start = End
ExpectedList.append((BlockSize, UsedBlockNum)) ExpectedList.append((BlockSize, UsedBlockNum))
RemindingSize -= BlockSize * UsedBlockNum RemindingSize -= BlockSize * UsedBlockNum

View File

@ -133,7 +133,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
# #
for Index in range(ValueLength): for Index in range(ValueLength):
ByteList[ValueOffset + Index] = ValueNumber % 0x100 ByteList[ValueOffset + Index] = ValueNumber % 0x100
ValueNumber = ValueNumber / 0x100 ValueNumber = ValueNumber // 0x100
elif TypeName == TAB_VOID: elif TypeName == TAB_VOID:
ValueString = SavedStr ValueString = SavedStr
if ValueString.startswith('L"'): if ValueString.startswith('L"'):

View File

@ -724,7 +724,7 @@ class PeImageInfo():
self.OutputDir = OutputDir self.OutputDir = OutputDir
self.DebugDir = DebugDir self.DebugDir = DebugDir
self.Image = ImageClass self.Image = ImageClass
self.Image.Size = (self.Image.Size / 0x1000 + 1) * 0x1000 self.Image.Size = (self.Image.Size // 0x1000 + 1) * 0x1000
## The class implementing the EDK2 build process ## The class implementing the EDK2 build process
# #
@ -1597,7 +1597,7 @@ class Build():
RtModuleList[Module.MetaFile] = ImageInfo RtModuleList[Module.MetaFile] = ImageInfo
#IPF runtime driver needs to be at 2 page alignment. #IPF runtime driver needs to be at 2 page alignment.
if IsIpfPlatform and ImageInfo.Image.Size % 0x2000 != 0: if IsIpfPlatform and ImageInfo.Image.Size % 0x2000 != 0:
ImageInfo.Image.Size = (ImageInfo.Image.Size / 0x2000 + 1) * 0x2000 ImageInfo.Image.Size = (ImageInfo.Image.Size // 0x2000 + 1) * 0x2000
RtSize += ImageInfo.Image.Size RtSize += ImageInfo.Image.Size
elif Module.ModuleType in [SUP_MODULE_SMM_CORE, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]: elif Module.ModuleType in [SUP_MODULE_SMM_CORE, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]:
SmmModuleList[Module.MetaFile] = ImageInfo SmmModuleList[Module.MetaFile] = ImageInfo
@ -1666,21 +1666,21 @@ class Build():
for PcdInfo in PcdTable: for PcdInfo in PcdTable:
ReturnValue = 0 ReturnValue = 0
if PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE: if PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE:
ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE, str (PeiSize / 0x1000)) ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE, str (PeiSize // 0x1000))
elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE: elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE:
ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE, str (BtSize / 0x1000)) ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE, str (BtSize // 0x1000))
elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE: elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE:
ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE, str (RtSize / 0x1000)) ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE, str (RtSize // 0x1000))
elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE and len (SmmModuleList) > 0: elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE and len (SmmModuleList) > 0:
ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE, str (SmmSize / 0x1000)) ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE, str (SmmSize // 0x1000))
if ReturnValue != 0: if ReturnValue != 0:
EdkLogger.error("build", PARAMETER_INVALID, "Patch PCD value failed", ExtraData=ErrorInfo) EdkLogger.error("build", PARAMETER_INVALID, "Patch PCD value failed", ExtraData=ErrorInfo)
MapBuffer.write('PEI_CODE_PAGE_NUMBER = 0x%x\n' % (PeiSize / 0x1000)) MapBuffer.write('PEI_CODE_PAGE_NUMBER = 0x%x\n' % (PeiSize // 0x1000))
MapBuffer.write('BOOT_CODE_PAGE_NUMBER = 0x%x\n' % (BtSize / 0x1000)) MapBuffer.write('BOOT_CODE_PAGE_NUMBER = 0x%x\n' % (BtSize // 0x1000))
MapBuffer.write('RUNTIME_CODE_PAGE_NUMBER = 0x%x\n' % (RtSize / 0x1000)) MapBuffer.write('RUNTIME_CODE_PAGE_NUMBER = 0x%x\n' % (RtSize // 0x1000))
if len (SmmModuleList) > 0: if len (SmmModuleList) > 0:
MapBuffer.write('SMM_CODE_PAGE_NUMBER = 0x%x\n' % (SmmSize / 0x1000)) MapBuffer.write('SMM_CODE_PAGE_NUMBER = 0x%x\n' % (SmmSize // 0x1000))
PeiBaseAddr = TopMemoryAddress - RtSize - BtSize PeiBaseAddr = TopMemoryAddress - RtSize - BtSize
BtBaseAddr = TopMemoryAddress - RtSize BtBaseAddr = TopMemoryAddress - RtSize