From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: star.zeng@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Thu, 27 Jun 2019 19:28:18 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2019 19:28:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,426,1557212400"; d="scan'208";a="314001807" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga004.jf.intel.com with ESMTP; 27 Jun 2019 19:28:17 -0700 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 27 Jun 2019 19:28:17 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 27 Jun 2019 19:28:17 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.33]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.225]) with mapi id 14.03.0439.000; Fri, 28 Jun 2019 10:28:15 +0800 From: "Zeng, Star" To: "devel@edk2.groups.io" , "Chiu, Chasel" CC: "Ma, Maurice" , "Desimone, Nathaniel L" , "Zeng, Star" Subject: Re: [edk2-devel] [PATCH] IntelFsp2Pkg: FSP Python scripts to support 3.x. Thread-Topic: [edk2-devel] [PATCH] IntelFsp2Pkg: FSP Python scripts to support 3.x. Thread-Index: AQHVKpoS9gqy9zh2eE65AQzsA8WXA6awXNog Date: Fri, 28 Jun 2019 02:28:14 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483104033CAF5@shsmsx102.ccr.corp.intel.com> References: <15AB2922EB6F889D.13745@groups.io> In-Reply-To: <15AB2922EB6F889D.13745@groups.io> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: star.zeng@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable It is ok to directly use below code without python version check? + for loop in range(int(unit)): + bytearray.append("0x%02X" % (value & 0xFF)) + value =3D value >> 8 Thanks, Star -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Chiu= , Chasel Sent: Monday, June 24, 2019 10:35 PM To: devel@edk2.groups.io Cc: Ma, Maurice ; Desimone, Nathaniel L ; Zeng, Star Subject: [edk2-devel] [PATCH] IntelFsp2Pkg: FSP Python scripts to support = 3.x. https://bugzilla.tianocore.org/show_bug.cgi?id=3D1930 Updated FSP Python scripts to support both 2.x and 3.x. Test: . Verified with Python 2.7.12 and 3.6.6. . Verified tool result is the same before the change. . Both py -2 and py -3 built binary can boot. Cc: Maurice Ma Cc: Nate DeSimone Cc: Star Zeng Signed-off-by: Chasel Chiu --- IntelFsp2Pkg/Tools/GenCfgOpt.py | 70 ++++++++++++++++++++++++++++++++++= ++++-------------------------------- IntelFsp2Pkg/Tools/PatchFv.py | 36 +++++++++++++++++++++++-----------= -- IntelFsp2Pkg/Tools/SplitFspBin.py | 74 ++++++++++++++++++++++++++++++++++= +++++++++++++++++++++------------------- 3 files changed, 116 insertions(+), 64 deletions(-) diff --git a/IntelFsp2Pkg/Tools/GenCfgOpt.py b/IntelFsp2Pkg/Tools/GenCfgOp= t.py index 450c4e3eb9..e0441966ac 100644 --- a/IntelFsp2Pkg/Tools/GenCfgOpt.py +++ b/IntelFsp2Pkg/Tools/GenCfgOpt.py @@ -1,6 +1,6 @@ ## @ GenCfgOpt.py # -# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2019, Intel Corporation. All rights=20 +reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -10,6 +10,7 @@ i= mport re import sys import struct from datetime import date +from functools import reduce =20 # Generated file copyright header =20 @@ -90,11 +91,11 @@ class CLogicalExpression: self.string =3D '' =20 def errExit(self, err =3D ''): - print "ERROR: Express parsing for:" - print " %s" % self.string - print " %s^" % (' ' * self.index) + print ("ERROR: Express parsing for:") + print (" %s" % self.string) + print (" %s^" % (' ' * self.index)) if err: - print "INFO : %s" % err + print ("INFO : %s" % err) raise SystemExit =20 def getNonNumber (self, n1, n2): @@ -338,15 +339,15 @@ EndList else: Error =3D 0 if self.Debug: - print "INFO : Macro dictionary:" + print ("INFO : Macro dictionary:") for Each in self._MacroDict: - print " $(%s) =3D [ %s ]" % (Each , self._Macro= Dict[Each]) + print (" $(%s) =3D [ %s ]" % (Each , self._Macr= oDict[Each])) return Error =20 def EvaulateIfdef (self, Macro): Result =3D Macro in self._MacroDict if self.Debug: - print "INFO : Eval Ifdef [%s] : %s" % (Macro, Result) + print ("INFO : Eval Ifdef [%s] : %s" % (Macro, Result)) return Result =20 def ExpandMacros (self, Input): @@ -359,7 +360,7 @@ EndList Line =3D Line.replace(Each, self._MacroDict[Variable]) else: if self.Debug: - print "WARN : %s is not defined" % Each + print ("WARN : %s is not defined" % Each) Line =3D Line.replace(Each, Each[2:-1]) return Line =20 @@ -372,7 +373,7 @@ EndList Line =3D Line.replace(PcdName, self._PcdsDict[PcdName]) else: if self.Debug: - print "WARN : %s is not defined" % PcdName + print ("WARN : %s is not defined" % PcdName) return Line =20 def EvaluateExpress (self, Expr): @@ -381,7 +382,7 @@ EndList LogExpr =3D CLogicalExpression() Result =3D LogExpr.evaluateExpress (ExpExpr) if self.Debug: - print "INFO : Eval Express [%s] : %s" % (Expr, Result) + print ("INFO : Eval Express [%s] : %s" % (Expr, Result)) return Result =20 def FormatListValue(self, ConfigDict): @@ -406,9 +407,14 @@ EndList bytearray =3D [] for each in dataarray: value =3D each - for loop in xrange(unit): - bytearray.append("0x%02X" % (value & 0xFF)) - value =3D value >> 8 + if sys.version_info < (3,0): + for loop in xrange(unit): + bytearray.append("0x%02X" % (value & 0xFF)) + value =3D value >> 8 + else: + for loop in range(int(unit)): + bytearray.append("0x%02X" % (value & 0xFF)) + value =3D value >> 8 newvalue =3D '{' + ','.join(bytearray) + '}' ConfigDict['value'] =3D newvalue return "" @@ -548,7 +554,7 @@ EndList if Match: self._MacroDict[Match.group(1)] =3D Match.group(2) if self.Debug: - print "INFO : DEFINE %s =3D [ %s ]" % (Match.grou= p(1), Match.group(2)) + print ("INFO : DEFINE %s =3D [ %s ]" %=20 + (Match.group(1), Match.group(2))) elif IsPcdSect: #gSiPkgTokenSpaceGuid.PcdTxtEnable|FALSE #gSiPkgTokenSpaceGuid.PcdOverclockEnable|TRUE @@ -556,7 +562,7 @@ EndList if Match: self._PcdsDict[Match.group(1)] =3D Match.group(2) if self.Debug: - print "INFO : PCD %s =3D [ %s ]" % (Match.group(1= ), Match.group(2)) + print ("INFO : PCD %s =3D [ %s ]" %=20 + (Match.group(1), Match.group(2))) i =3D 0 while i < len(BuildOptionPcd): Match =3D re.match("\s*([\w\.]+)\s*\=3D\s*(\w+)",= BuildOptionPcd[i]) @@ -774,7 +780,7 @@ EndList bitsvalue =3D bitsvalue[::-1] bitslen =3D len(bitsvalue) if start > bitslen or end > bitslen: - print "Invalid bits offset [%d,%d] for %s" % (start, end, sub= item['name']) + print ("Invalid bits offset [%d,%d] for %s" % (start, end,=20 + subitem['name'])) raise SystemExit return hex(int(bitsvalue[start:end][::-1], 2)) =20 @@ -1031,7 +1037,7 @@ EndList =20 if Match and Match.group(3) =3D=3D 'END': if (StructName !=3D Match.group(1)) or (VariableName !=3D = Match.group(2)): - print "Unmatched struct name '%s' and '%s' !" % (Stru= ctName, Match.group(1)) + print ("Unmatched struct name '%s' and '%s' !" %=20 + (StructName, Match.group(1))) else: if IsUpdHdrDefined !=3D True or IsUpdHeader !=3D True: NewTextBody.append ('} %s;\n\n' % StructName) @@ -= 1464,11 +1470,11 @@ EndList =20 =20 def Usage(): - print "GenCfgOpt Version 0.53" - print "Usage:" - print " GenCfgOpt UPDTXT PlatformDscFile BuildFvDir = [-D Macros]" - print " GenCfgOpt HEADER PlatformDscFile BuildFvDir InputHFile = [-D Macros]" - print " GenCfgOpt GENBSF PlatformDscFile BuildFvDir BsfOutFile = [-D Macros]" + print ("GenCfgOpt Version 0.54") + print ("Usage:") + print (" GenCfgOpt UPDTXT PlatformDscFile BuildFvDir = [-D Macros]") + print (" GenCfgOpt HEADER PlatformDscFile BuildFvDir InputHFile= [-D Macros]") + print (" GenCfgOpt GENBSF PlatformDscFile BuildFvDir BsfOutFile= [-D Macros]") =20 def Main(): # @@ -1489,7 +1495,7 @@ def Main(): else: DscFile =3D sys.argv[2] if not os.path.exists(DscFile): - print "ERROR: Cannot open DSC file '%s' !" % DscFile + print ("ERROR: Cannot open DSC file '%s' !" % DscFile) return 2 =20 OutFile =3D '' @@ -1501,7 +1507,7 @@ def Main(): Start =3D 5 if argc > Start: if GenCfgOpt.ParseMacros(sys.argv[Start:]) !=3D 0: - print "ERROR: Macro parsing failed !" + print ("ERROR: Macro parsing failed !") return 3 =20 FvDir =3D sys.argv[3] @@ -1509,11 +1515,11 @@ def Main(): os.makedirs(FvDir) =20 if GenCfgOpt.ParseDscFile(DscFile, FvDir) !=3D 0: - print "ERROR: %s !" % GenCfgOpt.Error + print ("ERROR: %s !" % GenCfgOpt.Error) return 5 =20 if GenCfgOpt.UpdateSubRegionDefaultValue() !=3D 0: - print "ERROR: %s !" % GenCfgOpt.Error + print ("ERROR: %s !" % GenCfgOpt.Error) return 7 =20 if sys.argv[1] =3D=3D "UPDTXT": @@ -1521,23 +1527,23 @@ def Main(): if Ret !=3D 0: # No change is detected if Ret =3D=3D 256: - print "INFO: %s !" % (GenCfgOpt.Error) + print ("INFO: %s !" % (GenCfgOpt.Error)) else : - print "ERROR: %s !" % (GenCfgOpt.Error) + print ("ERROR: %s !" % (GenCfgOpt.Error)) return Ret elif sys.argv[1] =3D=3D "HEADER": if GenCfgOpt.CreateHeaderFile(OutFile) !=3D 0: - print "ERROR: %s !" % GenCfgOpt.Error + print ("ERROR: %s !" % GenCfgOpt.Error) return 8 elif sys.argv[1] =3D=3D "GENBSF": if GenCfgOpt.GenerateBsfFile(OutFile) !=3D 0: - print "ERROR: %s !" % GenCfgOpt.Error + print ("ERROR: %s !" % GenCfgOpt.Error) return 9 else: if argc < 5: Usage() return 1 - print "ERROR: Unknown command '%s' !" % sys.argv[1] + print ("ERROR: Unknown command '%s' !" % sys.argv[1]) Usage() return 1 return 0 diff --git a/IntelFsp2Pkg/Tools/PatchFv.py b/IntelFsp2Pkg/Tools/PatchFv.py= index 19bffd146a..2332fa92f2 100644 --- a/IntelFsp2Pkg/Tools/PatchFv.py +++ b/IntelFsp2Pkg/Tools/PatchFv.py @@ -1,6 +1,6 @@ ## @ PatchFv.py # -# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2019, Intel Corporation. All rights=20 +reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -25,7 +25,10 @@ = def readDataFromFile (binfile, offset, len=3D1): if (offval & 0x80000000): offval =3D fsize - (0xFFFFFFFF - offval + 1) fd.seek(offval) - bytearray =3D [ord(b) for b in fd.read(len)] + if sys.version_info < (3,0): + bytearray =3D [ord(b) for b in fd.read(len)] + else: + bytearray =3D [b for b in fd.read(len)] value =3D 0 idx =3D len - 1 while idx >=3D 0: @@ -45,7 +48,7 @@ def IsFspHeaderValid (binfile): fd =3D open (binfile, "rb") bindat =3D fd.read(0x200) # only read first 0x200 bytes fd.close() - HeaderList =3D ['FSPH' , 'FSPP' , 'FSPE'] # Check 'FSPH', 'FSPP= ', and 'FSPE' in the FSP header + HeaderList =3D [b'FSPH' , b'FSPP' , b'FSPE'] # Check 'FSPH', 'F= SPP', and 'FSPE' in the FSP header OffsetList =3D [] for each in HeaderList: if each in bindat: @@ -55,7 +58,10 @@ def IsFspHeaderValid (binfile): OffsetList.append(idx) if not OffsetList[0] or not OffsetList[1]: # If 'FSPH' or 'FSPP' i= s missing, it will return false return False - Revision =3D ord(bindat[OffsetList[0] + 0x0B]) + if sys.version_info < (3,0): + Revision =3D ord(bindat[OffsetList[0] + 0x0B]) + else: + Revision =3D bindat[OffsetList[0] + 0x0B] # # if revision is bigger than 1, it means it is FSP v1.1 or greater re= vision, which must contain 'FSPE'. # @@ -86,7 +92,10 @@ def patchDataInFile (binfile, offset, value, len=3D1): value =3D value >> 8 idx =3D idx + 1 fd.seek(offval) - fd.write("".join(chr(b) for b in bytearray)) + if sys.version_info < (3,0): + fd.write("".join(chr(b) for b in bytearray)) + else: + fd.write(bytes(bytearray)) fd.close() return len =20 @@ -791,7 +800,7 @@ class Symbols: # retval ret # def getSymbols(self, value): - if self.dictSymbolAddress.has_key(value): + if value in self.dictSymbolAddress: # Module:Function ret =3D int (self.dictSymbolAddress[value], 16) else: @@ -827,8 +836,9 @@ class Symbols: # # Print out the usage # -def usage(): - print "Usage: \n\tPatchFv FvBuildDir [FvFileBaseNames:]FdFileBaseName= ToPatch \"Offset, Value\"" +def Usage(): + print ("PatchFv Version 0.50") + print ("Usage: \n\tPatchFv FvBuildDir=20 +[FvFileBaseNames:]FdFileBaseNameToPatch \"Offset, Value\"") =20 def main(): # @@ -847,7 +857,7 @@ def main(): # If it fails to create dictionaries, then return an error. # if symTables.createDicts(sys.argv[1], sys.argv[2]) !=3D 0: - print "ERROR: Failed to create symbol dictionary!!" + print ("ERROR: Failed to create symbol dictionary!!") return 2 =20 # @@ -907,7 +917,7 @@ def main(): if ret: raise Exception ("Patch failed for offset 0x%08X" % o= ffset) else: - print "Patched offset 0x%08X:[%08X] with value 0x%08= X # %s" % (offset, oldvalue, value, comment) + print ("Patched offset 0x%08X:[%08X] with value=20 + 0x%08X # %s" % (offset, oldvalue, value, comment)) =20 elif command =3D=3D "COPY": # @@ -928,13 +938,13 @@ def main(): if ret: raise Exception ("Copy failed from offset 0x%08X to o= ffset 0x%08X!" % (src, dest)) else : - print "Copied %d bytes from offset 0x%08X ~ offset 0= x%08X # %s" % (clen, src, dest, comment) + print ("Copied %d bytes from offset 0x%08X ~ offset= =20 + 0x%08X # %s" % (clen, src, dest, comment)) else: raise Exception ("Unknown command %s!" % command) return 0 =20 - except Exception as (ex): - print "ERROR: %s" % ex + except Exception as ex: + print ("ERROR: %s" % ex) return 1 =20 if __name__ =3D=3D '__main__': diff --git a/IntelFsp2Pkg/Tools/SplitFspBin.py b/IntelFsp2Pkg/Tools/SplitF= spBin.py index 15c8bebee2..28663a853f 100644 --- a/IntelFsp2Pkg/Tools/SplitFspBin.py +++ b/IntelFsp2Pkg/Tools/SplitFspBin.py @@ -12,6 +12,7 @@ import copy import struct import argparse from ctypes import * +from functools import reduce =20 """ This utility supports some operations for Intel FSP 1.x/2.x image. @@ -340,6 +341,31 @@ def Bytes2Val (bytes): def Val2Bytes (value, blen): return [(value>>(i*8) & 0xff) for i in range(blen)] =20 +def IsIntegerType (val): + if sys.version_info < (3,0): + if type(val) in (int, long): + return True + else: + if type(val) is int: + return True + return False + +def IsStrType (val): + if sys.version_info < (3,0): + if type(val) is str: + return True + else: + if type(val) is bytes: + return True + return False + +def HandleNameStr (val): + if sys.version_info < (3,0): + rep =3D "0x%X ('%s')" % (Bytes2Val (bytearray (val)), val) + else: + rep =3D "0x%X ('%s')" % (Bytes2Val (bytearray (val)), str (val, '= utf-8')) + return rep + def OutputStruct (obj, indent =3D 0, plen =3D 0): if indent: body =3D '' @@ -361,15 +387,19 @@ def OutputStruct (obj, indent =3D 0, plen =3D 0): body +=3D OutputStruct (val, indent + 1) plen -=3D sizeof(val) else: - if type(val) is str: - rep =3D "0x%X ('%s')" % (Bytes2Val(bytearray(val)), val) - elif type(val) in (int, long): + if IsStrType (val): + rep =3D HandleNameStr (val) + elif IsIntegerType (val): rep =3D '0x%X' % val elif isinstance(val, c_uint24): rep =3D '0x%X' % val.get_value() elif 'c_ubyte_Array' in str(type(val)): if sizeof(val) =3D=3D 16: - rep =3D str(uuid.UUID(bytes =3D str(bytearray(val))))= .upper() + if sys.version_info < (3,0): + rep =3D str(bytearray(val)) + else: + rep =3D bytes(val) + rep =3D str(uuid.UUID(bytes_le =3D rep)).upper() else: res =3D ['0x%02X'%i for i in bytearray(val)] rep =3D '[%s]' % (','.join(res)) @@ -487,7 +517,7 @@ = class FirmwareDevice: self.FvList =3D [] while offset < fdsize: fvh =3D EFI_FIRMWARE_VOLUME_HEADER.from_buffer (self.FdData, = offset) - if '_FVH' !=3D fvh.Signature: + if b'_FVH' !=3D fvh.Signature: raise Exception("ERROR: Invalid FV header !") fv =3D FirmwareVolume (offset, self.FdData[offset:offset + fv= h.FvLength]) fv.ParseFv () @@ -524,7 +554,7 @@ class FirmwareDevice: fspoffset =3D fv.Offset offset =3D fspoffset + fihoffset fih =3D FSP_INFORMATION_HEADER.from_buffer (self.FdData, = offset) - if 'FSPH' !=3D fih.Signature: + if b'FSPH' !=3D fih.Signature: continue =20 offset +=3D fih.HeaderLength @@ -532,7 +562,7 @@ class Fi= rmwareDevice: plist =3D [] while True: fch =3D FSP_COMMON_HEADER.from_buffer (self.FdData, o= ffset) - if 'FSPP' !=3D fch.Signature: + if b'FSPP' !=3D fch.Signature: offset +=3D fch.HeaderLength offset =3D AlignPtr(offset, 4) else: @@ -557,9 +587,9 @@ class PeTeImage: def __init__(self, offset, data): self.Offset =3D offset tehdr =3D EFI_TE_IMAGE_HEADER.from_buffer (data, 0) - if tehdr.Signature =3D=3D 'VZ': # TE image + if tehdr.Signature =3D=3D b'VZ': # TE image self.TeHdr =3D tehdr - elif tehdr.Signature =3D=3D 'MZ': # PE image + elif tehdr.Signature =3D=3D b'MZ': # PE image self.TeHdr =3D None self.DosHdr =3D EFI_IMAGE_DOS_HEADER.from_buffer (data, 0) self.PeHdr =3D EFI_IMAGE_NT_HEADERS32.from_buffer (data, se= lf.DosHdr.e_lfanew) @@ -604,7 +634,7 @@ class PeTeImage: offset +=3D sizeof(blkhdr) # Read relocation type,offset pairs rlen =3D blkhdr.BlockSize - sizeof(PE_RELOC_BLOCK_HEADER) - rnum =3D rlen/sizeof(c_uint16) + rnum =3D int (rlen/sizeof(c_uint16)) rdata =3D (c_uint16 * rnum).from_buffer(self.Data, offset) for each in rdata: roff =3D each & 0xfff @@ -666,8 +696,11 @@ def ShowFspInfo (fspfile): if not name: name =3D '\xff' * 16 else: - name =3D str(bytearray(name)) - guid =3D uuid.UUID(bytes =3D name) + if sys.version_info < (3,0): + name =3D str(bytearray(name)) + else: + name =3D bytes(name) + guid =3D uuid.UUID(bytes_le =3D name) print ("FV%d:" % idx) print (" GUID : %s" % str(guid).upper()) print (" Offset : 0x%08X" % fv.Offset) @@ -695,7 +728,10 @@ def= GenFspHdr (fspfile, outdir, hfile): for fsp in fd.FspList: fih =3D fsp.Fih if firstfv: - hfsp.write("#define FSP_IMAGE_ID 0x%016X /* '%s' */\n"= % (Bytes2Val(bytearray(fih.ImageId)), fih.ImageId)) + if sys.version_info < (3,0): + hfsp.write("#define FSP_IMAGE_ID 0x%016X /* '%s' *= /\n" % (Bytes2Val(bytearray(fih.ImageId)), fih.ImageId)) + else: + hfsp.write("#define FSP_IMAGE_ID 0x%016X /* '%s' *= /\n" % (Bytes2Val(bytearray(fih.ImageId)), str (fih.ImageId, 'utf-8'))) hfsp.write("#define FSP_IMAGE_REV 0x%08X \n\n" % fih.Image= Revision) firstfv =3D False fv =3D fd.FvList[fsp.FvIdxList[0]] @@ -733,7 +769,7 @@ def Rebase= FspBin (FspBinary, FspComponent, FspBase, OutputDir, OutputFile): numcomp =3D len(FspComponent) baselist =3D FspBase if numcomp !=3D len(baselist): - print "ERROR: Required number of base does not match number of FS= P component !" + print ("ERROR: Required number of base does not match number of= =20 + FSP component !") return =20 newfspbin =3D fd.FdData[:] @@ -753,7 +789,7 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, Ou= tputDir, OutputFile): break =20 if not found: - print "ERROR: Could not find FSP_%c component to rebase !" % = fspcomp.upper() + print ("ERROR: Could not find FSP_%c component to rebase !"= =20 + % fspcomp.upper()) return =20 fspbase =3D baselist[idx] @@ -763,7 +799,7 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, Ou= tputDir, OutputFile): newbase =3D int(fspbase) oldbase =3D fsp.Fih.ImageBase delta =3D newbase - oldbase - print "Rebase FSP-%c from 0x%08X to 0x%08X:" % (ftype.upper(),old= base,newbase) + print ("Rebase FSP-%c from 0x%08X to 0x%08X:" %=20 + (ftype.upper(),oldbase,newbase)) =20 imglist =3D [] for fvidx in fsp.FvIdxList: @@ -782,12 +818,12 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, = OutputDir, OutputFile): pcount +=3D img.Rebase(delta, newfspbin) fcount +=3D 1 =20 - print " Patched %d entries in %d TE/PE32 images." % (pcount, fco= unt) + print (" Patched %d entries in %d TE/PE32 images." % (pcount,=20 + fcount)) =20 (count, applied) =3D fsp.Patch(delta, newfspbin) - print " Patched %d entries using FSP patch table." % applied + print (" Patched %d entries using FSP patch table." % applied) if count !=3D applied: - print " %d invalid entries are ignored !" % (count - applied= ) + print (" %d invalid entries are ignored !" % (count -=20 + applied)) =20 if OutputFile =3D=3D '': filename =3D os.path.basename(FspBinary) -- 2.13.3.windows.1