From nobody Sat Apr 27 17:22:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+42749+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42749+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1561386926; cv=none; d=zoho.com; s=zohoarc; b=dxbZ3jZcg+d98LbipG7Xi0zRZPz/RFi2sNcT7ppACLNds/AkcnPDccxKpPD6zEoO7X5cIjaxJ7wWokSA+VJOUyuYpZi6SNZZvx6opVXCCx0Y/gommqNoO4lJ/lzK2mV+YLKZPjWSkthW7BXlj3nGLYf5bJZ+mD/496XeCI4wJ4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561386926; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=RdPSnIxpNWm7JsXG8qIUVGen91q/PSg/010KpeqeW80=; b=AIVDpe88msBXU81pY4MgyQHbsVmQkqzXfKnRlI7PH4l9X/KnadbUcckh6hRqnFjCxASRKXZQjwdKArNzfuqHFOKbKE0hmMLkqNvJI28XXZGUmeBNf0p85A19f2gw12ROc3HD4FMHF/ayq92X/O0yLJT1L6KdH+nhqqP17AFMNNY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42749+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1561386926934440.1008353235711; Mon, 24 Jun 2019 07:35:26 -0700 (PDT) Return-Path: X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by groups.io with SMTP; Mon, 24 Jun 2019 07:35:25 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jun 2019 07:35:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,412,1557212400"; d="scan'208";a="161631992" X-Received: from elinachx-mobl.gar.corp.intel.com (HELO cchiu4-MOBL1.gar.corp.intel.com) ([10.252.191.119]) by fmsmga008.fm.intel.com with ESMTP; 24 Jun 2019 07:35:23 -0700 From: "Chiu, Chasel" To: devel@edk2.groups.io Cc: Maurice Ma , Nate DeSimone , Star Zeng Subject: [edk2-devel] [PATCH] IntelFsp2Pkg: FSP Python scripts to support 3.x. Date: Mon, 24 Jun 2019 22:35:14 +0800 Message-Id: <20190624143514.17168-1-chasel.chiu@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,chasel.chiu@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1561386926; bh=WolNvzSrBx8EggxfdSs9WLntAgZyfHc8YyOk5S+Bhww=; h=Cc:Date:From:Reply-To:Subject:To; b=QbDcfqJNwTacoZXytqTClV9FkLGCiicAf07nOGiOuR4eUbtd5m9fwVZalKKQQ0KioYb swZNjTN9klV5ZBkPIPnQ2rFMS8TR1t9YxP90RWfvtzEP0VTs/zmt4N87sRS54EwmsVVze hxO9crI4hvBXYeHE5txyiHCYc6qfKrULrx0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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/GenCfgOpt= .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 reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -10,6 +10,7 @@ import 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._MacroD= ict[Each]) + print (" $(%s) =3D [ %s ]" % (Each , self._Macro= Dict[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.group= (1), Match.group(2)) + print ("INFO : DEFINE %s =3D [ %s ]" % (Match.grou= p(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 ]" % (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, subi= tem['name']) + print ("Invalid bits offset [%d,%d] for %s" % (start, end, sub= item['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 M= atch.group(2)): - print "Unmatched struct name '%s' and '%s' !" % (Struc= tName, Match.group(1)) + print ("Unmatched struct name '%s' and '%s' !" % (Stru= ctName, 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 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', 'FS= PP', 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' is= 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 rev= ision, 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:]FdFileBaseNameT= oPatch \"Offset, Value\"" +def Usage(): + print ("PatchFv Version 0.50") + print ("Usage: \n\tPatchFv FvBuildDir [FvFileBaseNames:]FdFileBaseName= ToPatch \"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" % of= fset) else: - print "Patched offset 0x%08X:[%08X] with value 0x%08X= # %s" % (offset, oldvalue, value, comment) + print ("Patched offset 0x%08X:[%08X] with value 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 of= fset 0x%08X!" % (src, dest)) else : - print "Copied %d bytes from offset 0x%08X ~ offset 0x= %08X # %s" % (clen, src, dest, comment) + print ("Copied %d bytes from offset 0x%08X ~ offset 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/SplitFs= pBin.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, 'u= tf-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, o= ffset) - 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 + fvh= .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, o= ffset) - if 'FSPH' !=3D fih.Signature: + if b'FSPH' !=3D fih.Signature: continue =20 offset +=3D fih.HeaderLength @@ -532,7 +562,7 @@ class FirmwareDevice: plist =3D [] while True: fch =3D FSP_COMMON_HEADER.from_buffer (self.FdData, of= fset) - 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, sel= f.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.ImageR= evision) firstfv =3D False fv =3D fd.FvList[fsp.FvIdxList[0]] @@ -733,7 +769,7 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, Out= putDir, OutputFile): numcomp =3D len(FspComponent) baselist =3D FspBase if numcomp !=3D len(baselist): - print "ERROR: Required number of base does not match number of FSP= component !" + print ("ERROR: Required number of base does not match number of FS= P component !") return =20 newfspbin =3D fd.FdData[:] @@ -753,7 +789,7 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, Out= putDir, OutputFile): break =20 if not found: - print "ERROR: Could not find FSP_%c component to rebase !" % f= spcomp.upper() + print ("ERROR: Could not find FSP_%c component to rebase !" % = fspcomp.upper()) return =20 fspbase =3D baselist[idx] @@ -763,7 +799,7 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, Out= putDir, 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(),oldb= ase,newbase) + print ("Rebase FSP-%c from 0x%08X to 0x%08X:" % (ftype.upper(),old= base,newbase)) =20 imglist =3D [] for fvidx in fsp.FvIdxList: @@ -782,12 +818,12 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, O= utputDir, OutputFile): pcount +=3D img.Rebase(delta, newfspbin) fcount +=3D 1 =20 - print " Patched %d entries in %d TE/PE32 images." % (pcount, fcou= nt) + print (" Patched %d entries in %d TE/PE32 images." % (pcount, fco= unt)) =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 - applied= )) =20 if OutputFile =3D=3D '': filename =3D os.path.basename(FspBinary) --=20 2.13.3.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#42749): https://edk2.groups.io/g/devel/message/42749 Mute This Topic: https://groups.io/mt/32192683/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-