Padding = '0x00, '\r
if Unicode:\r
Padding = Padding * 2\r
- ArraySize = ArraySize / 2\r
+ ArraySize = ArraySize // 2\r
if ArraySize < (len(PcdValue) + 1):\r
if Pcd.MaxSizeUserSet:\r
EdkLogger.error("build", AUTOGEN_ERROR,\r
else:\r
NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ', '\r
if Unicode:\r
- ArraySize = ArraySize / 2\r
+ ArraySize = ArraySize // 2\r
Value = NewValue + '0 }'\r
if ArraySize < ValueSize:\r
if Pcd.MaxSizeUserSet:\r
else:\r
ArraySize = Pcd.GetPcdSize()\r
if Unicode:\r
- ArraySize = ArraySize / 2\r
+ ArraySize = ArraySize // 2\r
Array = '[%d]' % ArraySize\r
#\r
# skip casting for fixed at build since it breaks ARM assembly.\r
else:\r
ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_1BIT)\r
ImageBuffer += pack('B', PaletteIndex)\r
- Width = (BmpHeader.biWidth + 7)/8\r
+ Width = (BmpHeader.biWidth + 7)//8\r
if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2:\r
PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : BmpHeader.bfOffBits]\r
elif BmpHeader.biBitCount == 4:\r
else:\r
ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_4BIT)\r
ImageBuffer += pack('B', PaletteIndex)\r
- Width = (BmpHeader.biWidth + 1)/2\r
+ Width = (BmpHeader.biWidth + 1)//2\r
if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2:\r
PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : BmpHeader.bfOffBits]\r
elif BmpHeader.biBitCount == 8:\r
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, 'The offset value of PCD %s should be %s-byte aligned.' % (PCD.PcdCName, Alignment))\r
else:\r
if PCD.PcdOccupySize % Alignment != 0:\r
- PCD.PcdOccupySize = (PCD.PcdOccupySize / Alignment + 1) * Alignment\r
+ PCD.PcdOccupySize = (PCD.PcdOccupySize // Alignment + 1) * Alignment\r
\r
PackSize = PCD.PcdOccupySize\r
if PCD._IsBoolean(PCD.PcdValue, PCD.PcdSize):\r
NowOffset = 0\r
for Pcd in self.PcdUnknownOffsetList :\r
if NowOffset % Pcd.Alignment != 0:\r
- NowOffset = (NowOffset/ Pcd.Alignment + 1) * Pcd.Alignment\r
+ NowOffset = (NowOffset // Pcd.Alignment + 1) * Pcd.Alignment\r
Pcd.PcdBinOffset = NowOffset\r
Pcd.PcdOffset = str(hex(Pcd.PcdBinOffset))\r
NowOffset += Pcd.PcdOccupySize\r
# Not been fixed\r
if eachUnfixedPcd.PcdOffset == '*' :\r
if LastOffset % eachUnfixedPcd.Alignment != 0:\r
- LastOffset = (LastOffset / eachUnfixedPcd.Alignment + 1) * eachUnfixedPcd.Alignment\r
+ LastOffset = (LastOffset // eachUnfixedPcd.Alignment + 1) * eachUnfixedPcd.Alignment\r
# The offset un-fixed pcd can write into this free space\r
if needFixPcdSize <= (NowOffset - LastOffset) :\r
# Change the offset value of un-fixed pcd\r
\r
NeedFixPcd.PcdBinOffset = LastPcd.PcdBinOffset + LastPcd.PcdOccupySize\r
if NeedFixPcd.PcdBinOffset % NeedFixPcd.Alignment != 0:\r
- NeedFixPcd.PcdBinOffset = (NeedFixPcd.PcdBinOffset / NeedFixPcd.Alignment + 1) * NeedFixPcd.Alignment\r
+ NeedFixPcd.PcdBinOffset = (NeedFixPcd.PcdBinOffset // NeedFixPcd.Alignment + 1) * NeedFixPcd.Alignment\r
\r
NeedFixPcd.PcdOffset = str(hex(NeedFixPcd.PcdBinOffset))\r
\r
else:\r
Val = Val3\r
continue\r
+ #\r
+ # PEP 238 -- Changing the Division Operator\r
+ # x/y to return a reasonable approximation of the mathematical result of the division ("true division")\r
+ # x//y to return the floor ("floor division")\r
+ #\r
+ if Op == '/':\r
+ Op = '//'\r
try:\r
Val = self.Eval(Op, Val, EvalFunc())\r
except WrnExpression as Warn:\r
if TmpValue.bit_length() == 0:\r
PcdValue = '{0x00}'\r
else:\r
- for I in range((TmpValue.bit_length() + 7) / 8):\r
+ for I in range((TmpValue.bit_length() + 7) // 8):\r
TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff))\r
PcdValue = '{' + ', '.join(TmpList) + '}'\r
except:\r
\r
def ParseFieldValue (Value):\r
if isinstance(Value, type(0)):\r
- return Value, (Value.bit_length() + 7) / 8\r
+ return Value, (Value.bit_length() + 7) // 8\r
if not isinstance(Value, type('')):\r
raise BadExpression('Type %s is %s' %(Value, type(Value)))\r
Value = Value.strip()\r
raise BadExpression("invalid hex value: %s" % Value)\r
if Value == 0:\r
return 0, 1\r
- return Value, (Value.bit_length() + 7) / 8\r
+ return Value, (Value.bit_length() + 7) // 8\r
if Value[0].isdigit():\r
Value = int(Value, 10)\r
if Value == 0:\r
return 0, 1\r
- return Value, (Value.bit_length() + 7) / 8\r
+ return Value, (Value.bit_length() + 7) // 8\r
if Value.lower() == 'true':\r
return 1, 1\r
if Value.lower() == 'false':\r
if ImageObj.SectionAlignment < 0x400:\r
self.Alignment = str (ImageObj.SectionAlignment)\r
elif ImageObj.SectionAlignment < 0x100000:\r
- self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'\r
+ self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'\r
else:\r
- self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'\r
+ self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'\r
\r
NoStrip = True\r
if self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):\r
if ImageObj.SectionAlignment < 0x400:\r
Align = str (ImageObj.SectionAlignment)\r
elif ImageObj.SectionAlignment < 0x100000:\r
- Align = str (ImageObj.SectionAlignment / 0x400) + 'K'\r
+ Align = str (ImageObj.SectionAlignment // 0x400) + 'K'\r
else:\r
- Align = str (ImageObj.SectionAlignment / 0x100000) + 'M'\r
+ Align = str (ImageObj.SectionAlignment // 0x100000) + 'M'\r
\r
if File[(len(File)-4):] == '.efi':\r
MapFile = File.replace('.efi', '.map')\r
if ImageObj.SectionAlignment < 0x400:\r
self.Alignment = str (ImageObj.SectionAlignment)\r
elif ImageObj.SectionAlignment < 0x100000:\r
- self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'\r
+ self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'\r
else:\r
- self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'\r
+ self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'\r
\r
if not NoStrip:\r
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')\r
if ImageObj.SectionAlignment < 0x400:\r
self.Alignment = str (ImageObj.SectionAlignment)\r
elif ImageObj.SectionAlignment < 0x100000:\r
- self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'\r
+ self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K'\r
else:\r
- self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'\r
+ self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M'\r
\r
if not NoStrip:\r
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')\r
#The max alignment supported by FFS is 16M.\r
self.FvAlignment = "16M"\r
else:\r
- self.FvAlignment = str(FvAlignmentValue / 0x100000) + "M"\r
+ self.FvAlignment = str(FvAlignmentValue // 0x100000) + "M"\r
else:\r
- self.FvAlignment = str(FvAlignmentValue / 0x400) + "K"\r
+ self.FvAlignment = str(FvAlignmentValue // 0x400) + "K"\r
else:\r
# FvAlignmentValue is less than 1K\r
self.FvAlignment = str (FvAlignmentValue)\r
# PI FvHeader is 0x48 byte\r
FvHeaderBuffer = FvFileObj.read(0x48)\r
# FV alignment position.\r
- FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)\r
+ FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)\r
FvFileObj.close()\r
if FvAlignmentValue > MaxFvAlignment:\r
MaxFvAlignment = FvAlignmentValue\r
if MaxFvAlignment >= 0x1000000:\r
self.Alignment = "16M"\r
else:\r
- self.Alignment = str(MaxFvAlignment / 0x100000) + "M"\r
+ self.Alignment = str(MaxFvAlignment // 0x100000) + "M"\r
else:\r
- self.Alignment = str (MaxFvAlignment / 0x400) + "K"\r
+ self.Alignment = str (MaxFvAlignment // 0x400) + "K"\r
else:\r
# MaxFvAlignment is less than 1K\r
self.Alignment = str (MaxFvAlignment)\r
if FvAlignmentValue >= 0x1000000:\r
self.Alignment = "16M"\r
else:\r
- self.Alignment = str(FvAlignmentValue / 0x100000) + "M"\r
+ self.Alignment = str(FvAlignmentValue // 0x100000) + "M"\r
else:\r
- self.Alignment = str (FvAlignmentValue / 0x400) + "K"\r
+ self.Alignment = str (FvAlignmentValue // 0x400) + "K"\r
else:\r
# FvAlignmentValue is less than 1K\r
self.Alignment = str (FvAlignmentValue)\r
F.read()\r
length = F.tell()\r
F.seek(4)\r
- TmpStr = unpack('%dh' % ((length - 4) / 2), F.read())\r
+ TmpStr = unpack('%dh' % ((length - 4) // 2), F.read())\r
Name = ''.join(chr(c) for c in TmpStr[:-1])\r
else:\r
FileList = []\r
else:\r
# region ended within current blocks\r
if self.Offset + self.Size <= End:\r
- ExpectedList.append((BlockSize, (RemindingSize + BlockSize - 1) / BlockSize))\r
+ ExpectedList.append((BlockSize, (RemindingSize + BlockSize - 1) // BlockSize))\r
break\r
# region not ended yet\r
else:\r
UsedBlockNum = BlockNum\r
# region started in middle of current blocks\r
else:\r
- UsedBlockNum = (End - self.Offset) / BlockSize\r
+ UsedBlockNum = (End - self.Offset) // BlockSize\r
Start = End\r
ExpectedList.append((BlockSize, UsedBlockNum))\r
RemindingSize -= BlockSize * UsedBlockNum\r
#\r
for Index in range(ValueLength):\r
ByteList[ValueOffset + Index] = ValueNumber % 0x100\r
- ValueNumber = ValueNumber / 0x100\r
+ ValueNumber = ValueNumber // 0x100\r
elif TypeName == TAB_VOID:\r
ValueString = SavedStr\r
if ValueString.startswith('L"'):\r
self.OutputDir = OutputDir\r
self.DebugDir = DebugDir\r
self.Image = ImageClass\r
- self.Image.Size = (self.Image.Size / 0x1000 + 1) * 0x1000\r
+ self.Image.Size = (self.Image.Size // 0x1000 + 1) * 0x1000\r
\r
## The class implementing the EDK2 build process\r
#\r
RtModuleList[Module.MetaFile] = ImageInfo\r
#IPF runtime driver needs to be at 2 page alignment.\r
if IsIpfPlatform and ImageInfo.Image.Size % 0x2000 != 0:\r
- ImageInfo.Image.Size = (ImageInfo.Image.Size / 0x2000 + 1) * 0x2000\r
+ ImageInfo.Image.Size = (ImageInfo.Image.Size // 0x2000 + 1) * 0x2000\r
RtSize += ImageInfo.Image.Size\r
elif Module.ModuleType in [SUP_MODULE_SMM_CORE, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]:\r
SmmModuleList[Module.MetaFile] = ImageInfo\r
for PcdInfo in PcdTable:\r
ReturnValue = 0\r
if PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE:\r
- ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE, str (PeiSize / 0x1000))\r
+ ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE, str (PeiSize // 0x1000))\r
elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE:\r
- ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE, str (BtSize / 0x1000))\r
+ ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE, str (BtSize // 0x1000))\r
elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE:\r
- ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE, str (RtSize / 0x1000))\r
+ ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE, str (RtSize // 0x1000))\r
elif PcdInfo[0] == TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE and len (SmmModuleList) > 0:\r
- ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE, str (SmmSize / 0x1000))\r
+ ReturnValue, ErrorInfo = PatchBinaryFile (EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE, str (SmmSize // 0x1000))\r
if ReturnValue != 0:\r
EdkLogger.error("build", PARAMETER_INVALID, "Patch PCD value failed", ExtraData=ErrorInfo)\r
\r
- MapBuffer.write('PEI_CODE_PAGE_NUMBER = 0x%x\n' % (PeiSize / 0x1000))\r
- MapBuffer.write('BOOT_CODE_PAGE_NUMBER = 0x%x\n' % (BtSize / 0x1000))\r
- MapBuffer.write('RUNTIME_CODE_PAGE_NUMBER = 0x%x\n' % (RtSize / 0x1000))\r
+ MapBuffer.write('PEI_CODE_PAGE_NUMBER = 0x%x\n' % (PeiSize // 0x1000))\r
+ MapBuffer.write('BOOT_CODE_PAGE_NUMBER = 0x%x\n' % (BtSize // 0x1000))\r
+ MapBuffer.write('RUNTIME_CODE_PAGE_NUMBER = 0x%x\n' % (RtSize // 0x1000))\r
if len (SmmModuleList) > 0:\r
- MapBuffer.write('SMM_CODE_PAGE_NUMBER = 0x%x\n' % (SmmSize / 0x1000))\r
+ MapBuffer.write('SMM_CODE_PAGE_NUMBER = 0x%x\n' % (SmmSize // 0x1000))\r
\r
PeiBaseAddr = TopMemoryAddress - RtSize - BtSize\r
BtBaseAddr = TopMemoryAddress - RtSize\r