From nobody Fri May 10 00:56:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111773+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111773+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1701133444; cv=none; d=zohomail.com; s=zohoarc; b=Jf5WZQveP2GV3oojipe2UZsRZfxtRiA/XenXjqWhzMN+KvIAvGACWMwWFam2mTSUAaff+faq4/49IVd/UiSEMh2d5OnFfG+teWyXsN0c7h6xd+CiA7NeEQZLHk69rvMzLcjzR+OZ7Ugmbz96bQor4odeZSQKMUHKsb3sQcfJNAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701133444; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=O2Ga6jZXX01ZzAtEpjOPEnbwQZB8vKowvoZXjqBXLvQ=; b=Vm03I/uIoQmDNhI9jtXAcACc82iHGS6IJPOXdH+gvkFWubxwbTBkk8EvypnQmCR0hPfZCRRnb2DxPjASACIoT888BnIbDgSOo3CKr+7tO3EOEdG2L8e2PYtKJcWzzgTWJgbpUPXvx27K5SNGsgJ3YbnCgBT3P7Eq1W86zou3BAU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111773+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1701133444269505.230811997803; Mon, 27 Nov 2023 17:04:04 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=80aI9D+OhDNsdSwYD4OmPcP3CHQlKkTHs4aKkfeFfk8=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1701133443; v=1; b=JpnbSvbvtMTVYkqwM4Em9TFgEpL6yx8TdPzEkTvvKCTKb/egpv4VTURPOSdWhg03oJCTnlV1 TcpxiOu+6s17eM0f1ru56958vXp6xLAjuJ0u/lRs76/CneyIpsNWrNX6zdl/PgvG6ykhsrIj7+q 9Rcy8DS6D0Zr1tnMWY5AaTjA= X-Received: by 127.0.0.2 with SMTP id ei5oYY1788612x0DgU7NKmox; Mon, 27 Nov 2023 17:04:03 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.5492.1701133441440565922 for ; Mon, 27 Nov 2023 17:04:02 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="383208390" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="383208390" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 17:04:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="859243510" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="859243510" X-Received: from nldesimo-desk.amr.corp.intel.com ([10.241.240.67]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 17:03:59 -0800 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Liming Gao , Eric Dong Subject: [edk2-devel] [edk2-platforms][PATCH v1] MinPlatformPkg: Update PatchFv Tools for Python 3.x Date: Mon, 27 Nov 2023 17:03:37 -0800 Message-Id: <20231128010339.1954-2-nathaniel.l.desimone@intel.com> In-Reply-To: <20231128010339.1954-1-nathaniel.l.desimone@intel.com> References: <20231128010339.1954-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: 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,nathaniel.l.desimone@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Wux4t57r1jvTnDMj4PqgBtbkx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1701133445423000011 Content-Type: text/plain; charset="utf-8" PatchFv tools now run on Python 3.x Cc: Chasel Chiu Cc: Liming Gao Cc: Eric Dong Signed-off-by: Nate DeSimone Reviewed-by: Chasel Chiu --- .../MinPlatformPkg/Tools/PatchFv/PatchBfv.py | 35 ++++---- .../Tools/PatchFv/PatchBinFv.py | 69 ++++++++-------- .../Tools/PatchFv/RebaseBinFv.py | 82 +++++++++---------- 3 files changed, 92 insertions(+), 94 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBfv.py b/Plat= form/Intel/MinPlatformPkg/Tools/PatchFv/PatchBfv.py index 1312bfc328..f05480b91f 100644 --- a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBfv.py +++ b/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBfv.py @@ -1,6 +1,6 @@ ## @ PatchBfv.py # -# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -11,8 +11,7 @@ import sys import time import shutil import struct -import binascii -from ctypes import * +from ctypes import * =20 class FileChecker: def __init__(self): @@ -21,17 +20,17 @@ class FileChecker: self.pcd =3D ["", "", ""] =20 def PrintPcd(self): - print "PCD: " + self.pcd[0] + "|" + self.pcd[1] + "(" + self.pcd[2= ] + ")" + print("PCD: {0}|{1}({2})".format(*(self.pcd))) =20 def ProcessReport(self): try : file =3D open(self.reportFile) except Exception: - print "fail to open " + self.reportFile + print("fail to open " + self.reportFile) return try: file.seek(0) - print "checking - " + self.pcd[0] + print("checking - " + self.pcd[0]) ValuePair =3D self.GetPcdFromReport (file, self.pcd[0]) self.pcd[1] =3D ValuePair[0] self.pcd[2] =3D ValuePair[1] @@ -42,12 +41,12 @@ class FileChecker: =20 def PatchFd(self): fileName =3D self.fdName - print "patching BFV - " + fileName + print("patching BFV - " + fileName) =20 try : file =3D open(fileName, "rb") except Exception: - print "fail to open " + fileName + print("fail to open " + fileName) return try: buffer =3D file.read() @@ -57,7 +56,7 @@ class FileChecker: offset =3D -4 =20 l =3D struct.pack("L", int(self.pcd[1],16)) - print " [" + hex(offset) + "] " + binascii.hexlify(data[-4:])= + " <=3D " + binascii.hexlify(l) + print(" [" + hex(offset) + "] " + bytes(data[-4:]).hex() + " = <=3D " + bytes(l).hex()) data[-4:] =3D l =20 file =3D open(fileName, "wb") @@ -77,36 +76,36 @@ class FileChecker: =20 newline =3D line[:-1] =20 - if (cmp (newline, TargetPkg) =3D=3D 0): + if newline =3D=3D TargetPkg: FoundPkg =3D True continue =20 - if (cmp (newline, "") =3D=3D 0) or ((cmp (newline[0], " ") != =3D 0) and (cmp (newline[0], "0") !=3D 0)): + if newline =3D=3D "" or (newline[0] !=3D " " and newline[0] != =3D "0"): FoundPkg =3D False =20 if (FoundPkg =3D=3D True) : newline =3D newline.strip() splitLine =3D newline.split(" ", 2) - if (cmp (splitLine[0], "*F") =3D=3D 0) or (cmp (splitLine[= 0], "*P") =3D=3D 0) : - if (cmp (splitLine[1], TargetPcd) =3D=3D 0): - print "found - " + TargetPkg + "." + TargetPcd + if splitLine[0] =3D=3D "*F" or splitLine[0] =3D=3D "*P": + if splitLine[1] =3D=3D TargetPcd: + print("found - " + TargetPkg + "." + TargetPcd) =20 splitLine =3D splitLine[2].strip()[1:].strip().spl= it(" ", 1) - if (cmp (splitLine[0], "FIXED") =3D=3D 0) or (cmp = (splitLine[0], "PATCH") =3D=3D 0): + if splitLine[0] =3D=3D "FIXED" or splitLine[0] =3D= =3D "PATCH": SplitLine =3D splitLine[1].strip()[1:].split("= )", 1) Type =3D SplitLine[0] Value =3D SplitLine[1].strip()[1:].strip().spl= it()[0] - print " Type - (" + Type + "), Value - (" + V= alue + ")" + print(" Type - (" + Type + "), Value - (" + V= alue + ")") return [Value, Type] return ["", ""] - =20 + def main(): global FileChecker =20 fileChecker =3D FileChecker() =20 if (len(sys.argv) !=3D 4) : - print "usage: PatchBfv " + print("usage: PatchBfv ") return 0 =20 fileChecker.fdName =3D sys.argv[1] diff --git a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBinFv.py b/Pl= atform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBinFv.py index b98c951b45..78576a3029 100644 --- a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBinFv.py +++ b/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBinFv.py @@ -1,6 +1,6 @@ ## @ PatchBinFv.py # -# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -11,7 +11,6 @@ import sys import time import shutil import struct -import binascii from ctypes import * =20 class FileChecker: @@ -30,20 +29,20 @@ class FileChecker: def IsSyncSection(self, line): name =3D self.GetSectionName(line) for sectionName in self.SyncSectionList: - if (cmp (sectionName, name) =3D=3D 0) : + if sectionName =3D=3D name: return True return False =20 def PrintPcdList(self, pcdList): for pcd in pcdList: - print "PCD: " + pcd[0] + "|" + pcd[1] + "|" + pcd[2] + " <=3D= =3D " + pcd[3] + "(" + pcd[4] + ")" + print(("PCD: {0} | {1} | {2} <=3D=3D {3}({4})".format(*pcd))) =20 def GetInfFileGuid(self, fileName): guid =3D "" try : file =3D open(fileName) except Exception: - print "fail to open " + fileName + print("fail to open " + fileName) return try: while 1: @@ -53,7 +52,7 @@ class FileChecker: =20 newline =3D line[:-1] =20 - if cmp (line[:11], " FILE_GUID") =3D=3D 0: + if line[:11] =3D=3D " FILE_GUID": splitLine =3D line.split("=3D") templine =3D splitLine[1] guid =3D templine[1:1+36] @@ -66,7 +65,7 @@ class FileChecker: try : file =3D open(fileName) except Exception: - print "fail to open " + fileName + print("fail to open " + fileName) return try: while 1: @@ -76,23 +75,23 @@ class FileChecker: =20 newline =3D line[:-1] =20 - if cmp (line[0], "#") =3D=3D 0: + if line[0] =3D=3D "#": continue =20 =20 - if cmp (line[0], "[") =3D=3D 0: + if line[0] =3D=3D "[": SyncToDest =3D self.IsSyncSection(line) PatchOffset =3D False =20 - if (cmp (self.GetSectionName(line), "PatchPcd") =3D=3D 0) : + if (self.GetSectionName(line) =3D=3D "PatchPcd"): PatchOffset =3D True continue =20 if SyncToDest =3D=3D True : line =3D line.strip() - if (cmp (line, "") =3D=3D 0) : + if line =3D=3D "": continue - if (cmp (line[0], "#") =3D=3D 0) : + if line[0] =3D=3D "#": continue =20 splitLine =3D line.split(" ") @@ -108,9 +107,9 @@ class FileChecker: =20 def ProcessFvInf(self, fvName): sourceFileName =3D os.path.join(self.sourceRoot,fvName,self.target= ,fvName+".inf") - print "\nprocessing - " + sourceFileName + print("\nprocessing - " + sourceFileName) fileGuid =3D self.GetInfFileGuid (sourceFileName) - print "FV NAME GUID - " + fileGuid + print("FV NAME GUID - " + fileGuid) =20 self.InfPcdList =3D [] self.ParseInfFile(sourceFileName) @@ -122,12 +121,12 @@ class FileChecker: try : file =3D open(self.reportFile) except Exception: - print "fail to open " + self.reportFile + print("fail to open " + self.reportFile) return try: for pcd in self.InfPcdList: file.seek(0) - print "checking - " + pcd[0] + print("checking - " + pcd[0]) ValuePair =3D self.GetPcdFromReport (file, pcd[0]) pcd[3] =3D ValuePair[0] pcd[4] =3D ValuePair[1] @@ -138,12 +137,12 @@ class FileChecker: =20 def PatchFv(self, fvName): sourceFileName =3D os.path.join(self.sourceRoot,fvName,self.target= ,fvName+".Fv") - print "patching - " + sourceFileName + print("patching - " + sourceFileName) =20 try : file =3D open(sourceFileName, "rb") except Exception: - print "fail to open " + sourceFileName + print("fail to open " + sourceFileName) return try: buffer =3D file.read() @@ -152,21 +151,21 @@ class FileChecker: =20 for pcd in self.InfPcdList: offset =3D int(pcd[2], 16) - if (cmp (pcd[4], "BOOLEAN") =3D=3D 0) or (cmp (pcd[4], "UI= NT8") =3D=3D 0): + if (pcd[4] =3D=3D "BOOLEAN") or (pcd[4] =3D=3D "UINT8"): b =3D struct.pack("B", int(pcd[3],16)) - print " [" + hex(offset) + "] " + binascii.hexlify(da= ta[offset:offset+1]) + " <=3D " + binascii.hexlify(b) + print(" [" + hex(offset) + "] " + bytes(data[offset:o= ffset+1]).hex() + " <=3D " + bytes(b).hex()) data[offset:offset+1] =3D b - elif (cmp (pcd[4], "UINT16") =3D=3D 0): + elif (pcd[4] =3D=3D "UINT16"): h =3D struct.pack("H", int(pcd[3],16)) - print " [" + hex(offset) + "] " + binascii.hexlify(da= ta[offset:offset+2]) + " <=3D " + binascii.hexlify(h) + print(" [" + hex(offset) + "] " + bytes(data[offset:o= ffset+2]).hex() + " <=3D " + bytes(h).hex()) data[offset:offset+2] =3D h - elif (cmp (pcd[4], "UINT32") =3D=3D 0): + elif (pcd[4] =3D=3D "UINT32"): l =3D struct.pack("I", int(pcd[3],16)) - print " [" + hex(offset) + "] " + binascii.hexlify(da= ta[offset:offset+4]) + " <=3D " + binascii.hexlify(l) + print(" [" + hex(offset) + "] " + bytes(data[offset:o= ffset+4]).hex() + " <=3D " + bytes(l).hex()) data[offset:offset+4] =3D l - elif (cmp (pcd[4], "UINT64") =3D=3D 0): + elif (pcd[4] =3D=3D "UINT64"): q =3D struct.pack("Q", int(pcd[3],16)) - print " [" + hex(offset) + "] " + binascii.hexlify(da= ta[offset:offset+8]) + " <=3D " + binascii.hexlify(q) + print(" [" + hex(offset) + "] " + bytes(data[offset:o= ffset+8]).hex() + " <=3D " + bytes(q).hex()) data[offset:offset+8] =3D q file =3D open(sourceFileName, "wb") file.write(data) @@ -185,36 +184,36 @@ class FileChecker: =20 newline =3D line[:-1] =20 - if (cmp (newline, TargetPkg) =3D=3D 0): + if (newline =3D=3D TargetPkg): FoundPkg =3D True continue =20 - if (cmp (newline, "") =3D=3D 0) or ((cmp (newline[0], " ") != =3D 0) and (cmp (newline[0], "0") !=3D 0)): + if (newline =3D=3D "") or ((newline[0] !=3D " ") and (newline[= 0] !=3D "0")): FoundPkg =3D False =20 if (FoundPkg =3D=3D True) : newline =3D newline.strip() splitLine =3D newline.split(" ", 2) - if (cmp (splitLine[0], "*F") =3D=3D 0) or (cmp (splitLine[= 0], "*P") =3D=3D 0): - if (cmp (splitLine[1], TargetPcd) =3D=3D 0): - print "found - " + TargetPkg + "." + TargetPcd + if (splitLine[0] =3D=3D "*F") or (splitLine[0] =3D=3D "*P"= ): + if (splitLine[1] =3D=3D TargetPcd): + print("found - " + TargetPkg + "." + TargetPcd) =20 splitLine =3D splitLine[2].strip()[1:].strip().spl= it(" ", 1) - if (cmp (splitLine[0], "FIXED") =3D=3D 0) or (cmp = (splitLine[0], "PATCH") =3D=3D 0): + if (splitLine[0] =3D=3D "FIXED") or (splitLine[0] = =3D=3D "PATCH"): SplitLine =3D splitLine[1].strip()[1:].split("= )", 1) Type =3D SplitLine[0] Value =3D SplitLine[1].strip()[1:].strip().spl= it()[0] - print " Type - (" + Type + "), Value - (" + V= alue + ")" + print(" Type - (" + Type + "), Value - (" + V= alue + ")") return [Value, Type] return ["", ""] - =20 + def main(): global FileChecker =20 fileChecker =3D FileChecker() =20 if (len(sys.argv) !=3D 5) : - print "usage: PatchBinFv " + print("usage: PatchBinFv ") return 0 =20 fileChecker.target =3D sys.argv[1] diff --git a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/RebaseBinFv.py b/P= latform/Intel/MinPlatformPkg/Tools/PatchFv/RebaseBinFv.py index 149630e4ef..2cea491f41 100644 --- a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/RebaseBinFv.py +++ b/Platform/Intel/MinPlatformPkg/Tools/PatchFv/RebaseBinFv.py @@ -1,6 +1,6 @@ ## @ PatchBinFv.py # -# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # =20 @@ -10,8 +10,8 @@ import sys import time import shutil import struct -import binascii -from ctypes import * +from ctypes import * +from functools import reduce =20 class GUID(Structure): _fields_ =3D [ @@ -380,9 +380,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': # PE32 image + elif tehdr.Signature =3D=3D b'MZ': # PE32 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) @@ -397,7 +397,7 @@ class PeTeImage: self.RelocList =3D [] =20 def IsTeImage(self): - return self.TeHdr is not None + return self.TeHdr is not None =20 def ParseReloc(self): if self.IsTeImage(): @@ -415,7 +415,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 rlen // sizeof(c_uint16) rdata =3D (c_uint16 * rnum).from_buffer(self.Data, offset) for each in rdata: roff =3D each & 0xfff @@ -532,21 +532,21 @@ class FileChecker: def IsSyncSection(self, line): name =3D self.GetSectionName(line) for sectionName in self.SyncSectionList: - if (cmp (sectionName, name) =3D=3D 0) : + if sectionName =3D=3D name: return True return False =20 def PrintRebasePcd(self, pcd): - print "PCD: " + pcd[0] + "|" + pcd[3] + " <=3D=3D " + pcd[1] + "("= + pcd[2] + ")" + print("PCD: {0} | {3} <=3D=3D {1}({2})".format(*pcd)) =20 def RebaseFv(self, fvName, rebasePcd): sourceFileName =3D os.path.join(self.sourceRoot,fvName,self.target= ,fvName+".Fv") - print "rebasing(FV) - " + sourceFileName + print("rebasing(FV) - " + sourceFileName) =20 try : file =3D open(sourceFileName, "rb") except Exception: - print "fail to open " + sourceFileName + print("fail to open " + sourceFileName) return try: buffer =3D file.read() @@ -554,15 +554,15 @@ class FileChecker: file.close() =20 FvHeader =3D EFI_FIRMWARE_VOLUME_HEADER.from_buffer (data, 0) - print "HeaderLength - " + hex(FvHeader.HeaderLength) - print "ExtHeaderOffset - " + hex(FvHeader.ExtHeaderOffset) + print("HeaderLength - " + hex(FvHeader.HeaderLength)) + print("ExtHeaderOffset - " + hex(FvHeader.ExtHeaderOffset)) =20 if (FvHeader.ExtHeaderOffset =3D=3D 0): Offset =3D FvHeader.HeaderLength else: FvExHeader =3D EFI_FIRMWARE_VOLUME_EXT_HEADER.from_buffer(= data, FvHeader.ExtHeaderOffset) - print " FvName - %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02= x%02x%02x" % (FvExHeader.FvName.Guid1, FvExHeader.FvName.Guid2, FvExHeader.= FvName.Guid3, FvExHeader.FvName.Guid4[0], FvExHeader.FvName.Guid4[1], FvExH= eader.FvName.Guid4[2], FvExHeader.FvName.Guid4[3], FvExHeader.FvName.Guid4[= 4], FvExHeader.FvName.Guid4[5], FvExHeader.FvName.Guid4[6], FvExHeader.FvNa= me.Guid4[7]) - print " ExtHeaderSize - " + hex(FvExHeader.ExtHeaderSize) + print(" FvName - %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02= x%02x%02x" % (FvExHeader.FvName.Guid1, FvExHeader.FvName.Guid2, FvExHeader.= FvName.Guid3, FvExHeader.FvName.Guid4[0], FvExHeader.FvName.Guid4[1], FvExH= eader.FvName.Guid4[2], FvExHeader.FvName.Guid4[3], FvExHeader.FvName.Guid4[= 4], FvExHeader.FvName.Guid4[5], FvExHeader.FvName.Guid4[6], FvExHeader.FvNa= me.Guid4[7])) + print(" ExtHeaderSize - " + hex(FvExHeader.ExtHeaderSize)) Offset =3D FvHeader.ExtHeaderOffset + FvExHeader.ExtHeader= Size Offset =3D (Offset + 0x7) & ~0x7 =20 @@ -576,20 +576,20 @@ class FileChecker: if (FfsHeader.Type =3D=3D 0xFF) or (FfsHeader.Type =3D=3D = EFI_FV_FILETYPE_FFS_PAD) : Offset =3D (FfsOffset + FfsSize + 7) & ~0x7 continue - print "Ffs - %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%= 02x" % (FfsHeader.Name.Guid1, FfsHeader.Name.Guid2, FfsHeader.Name.Guid3, F= fsHeader.Name.Guid4[0], FfsHeader.Name.Guid4[1], FfsHeader.Name.Guid4[2], F= fsHeader.Name.Guid4[3], FfsHeader.Name.Guid4[4], FfsHeader.Name.Guid4[5], F= fsHeader.Name.Guid4[6], FfsHeader.Name.Guid4[7]) + print("Ffs - %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%= 02x" % (FfsHeader.Name.Guid1, FfsHeader.Name.Guid2, FfsHeader.Name.Guid3, F= fsHeader.Name.Guid4[0], FfsHeader.Name.Guid4[1], FfsHeader.Name.Guid4[2], F= fsHeader.Name.Guid4[3], FfsHeader.Name.Guid4[4], FfsHeader.Name.Guid4[5], F= fsHeader.Name.Guid4[6], FfsHeader.Name.Guid4[7])) Offset =3D Offset + sizeof(EFI_FFS_FILE_HEADER) while (Offset < FfsOffset + FfsSize) : SectionHeader =3D EFI_COMMON_SECTION_HEADER.from_buffe= r (data, Offset) #print " Section - " + hex(Offset) if (SectionHeader.Type =3D=3D EFI_SECTION_PE32) or (Se= ctionHeader.Type =3D=3D EFI_SECTION_TE) : PeOffset =3D Offset + sizeof(EFI_COMMON_SECTION_HE= ADER) - print " PE - " + hex(PeOffset) + "(" + binascii= .hexlify(data[PeOffset:PeOffset+2]) + ")" + print(" PE - " + hex(PeOffset) + "(" + bytes(da= ta[PeOffset:PeOffset+2]).hex() + ")") =20 newbase =3D int(rebasePcd[1],16) oldbase =3D int(rebasePcd[3],16) =20 delta =3D newbase - oldbase - print " delta - " + hex(delta) + "(" + hex(oldb= ase) + " <=3D=3D " + hex(newbase) + ")" + print(" delta - " + hex(delta) + "(" + hex(oldb= ase) + " <=3D=3D " + hex(newbase) + ")") =20 PeLength =3D FfsSize-sizeof(EFI_FFS_FILE_HEADER); =20 @@ -618,26 +618,26 @@ class FileChecker: =20 newline =3D line[:-1].replace('\r','') =20 - if (cmp (newline, TargetPkg) =3D=3D 0): + if newline =3D=3D TargetPkg: FoundPkg =3D True continue =20 - if (cmp (newline, "") =3D=3D 0) or ((cmp (newline[0], " ") != =3D 0) and (cmp (newline[0], "0") !=3D 0)): + if newline =3D=3D "" or (newline[0] !=3D " " and newline[0] != =3D "0"): FoundPkg =3D False =20 if (FoundPkg =3D=3D True) : newline =3D newline.strip() splitLine =3D newline.split(" ", 2) - if (cmp (splitLine[0], "*F") =3D=3D 0) or (cmp (splitLine[= 0], "*P") =3D=3D 0): - if (cmp (splitLine[1], TargetPcd) =3D=3D 0): - print "found - " + TargetPkg + "." + TargetPcd + if (splitLine[0] =3D=3D "*F") or (splitLine[0] =3D=3D "*P"= ): + if splitLine[1] =3D=3D TargetPcd: + print("found - " + TargetPkg + "." + TargetPcd) =20 splitLine =3D splitLine[2].strip()[1:].strip().spl= it(" ", 1) - if (cmp (splitLine[0], "FIXED") =3D=3D 0) or (cmp = (splitLine[0], "PATCH") =3D=3D 0): + if splitLine[0] =3D=3D "FIXED" or splitLine[0] =3D= =3D "PATCH": SplitLine =3D splitLine[1].strip()[1:].split("= )", 1) Type =3D SplitLine[0] Value =3D SplitLine[1].strip()[1:].strip().spl= it()[0] - print " Type - (" + Type + "), Value - (" + V= alue + ")" + print(" Type - (" + Type + "), Value - (" + V= alue + ")") return [Value, Type] return ["", ""] =20 @@ -648,7 +648,7 @@ class FileChecker: try : file =3D open(fileName) except Exception: - print "fail to open " + fileName + print("fail to open " + fileName) return try: while 1: @@ -658,21 +658,21 @@ class FileChecker: =20 newline =3D line[:-1].replace('\r','') =20 - if cmp (newline, "") =3D=3D 0: + if newline =3D=3D "": continue =20 - if cmp (newline, "#![Pcd]") =3D=3D 0: + if newline =3D=3D "#![Pcd]": ParseBase =3D True continue =20 if ParseBase =3D=3D True : - if (cmp (line[0:2], "#!") !=3D 0) : + if line[0:2] !=3D "#!": ParseBase =3D False continue newline =3D newline[2:].strip() =20 splitLine =3D newline.split("|") - if cmp (PcdName, splitLine[0]) =3D=3D 0: + if PcdName =3D=3D splitLine[0]: Value =3D splitLine[1] finally: file.close() @@ -681,11 +681,11 @@ class FileChecker: =20 def SetNewFvBase (self, fvName, PcdName, OldFvBase, NewFvBase): fileName =3D os.path.join(self.sourceRoot,fvName,self.target,fvNam= e+".inf") - print "update - " + fileName + print("update - " + fileName) try : file =3D open(fileName, "r") except Exception: - print "fail to open " + fileName + print("fail to open " + fileName) return try: lines =3D file.readlines() @@ -699,23 +699,23 @@ class FileChecker: =20 newline =3D line[:-1].strip() =20 - if cmp (newline, "") =3D=3D 0: + if newline =3D=3D "": continue =20 - if cmp (newline, "#![Pcd]") =3D=3D 0: + if newline =3D=3D "#![Pcd]": ParseBase =3D True continue =20 if ParseBase =3D=3D True : - if (cmp (line[0:2], "#!") !=3D 0) : + if line[0:2] !=3D "#!": ParseBase =3D False continue newline =3D newline[2:].strip() =20 splitLine =3D newline.split("|") - if cmp (PcdName, splitLine[0]) =3D=3D 0: - if cmp (OldFvBase, splitLine[1]) !=3D 0: - print "ERROR: OldFvBase mismatch!" + if PcdName =3D=3D splitLine[0]: + if OldFvBase !=3D splitLine[1]: + print("ERROR: OldFvBase mismatch!") else: lines[index] =3D "#! " + PcdName + "|" + NewF= vBase + "\n" break @@ -730,11 +730,11 @@ class FileChecker: try : file =3D open(self.reportFile) except Exception: - print "fail to open " + self.reportFile + print("fail to open " + self.reportFile) return try: file.seek(0) - print "checking - " + self.RebasePcd[0] + print("checking - " + self.RebasePcd[0]) ValuePair =3D self.GetPcdFromReport (file, self.RebasePcd[0]) self.RebasePcd[1] =3D ValuePair[0] self.RebasePcd[2] =3D ValuePair[1] @@ -747,7 +747,7 @@ def main(): fileChecker =3D FileChecker() =20 if (len(sys.argv) !=3D 6) : - print "usage: RebaseBinFv " + print("usage: RebaseBinFv ") return 0 =20 fileChecker.target =3D sys.argv[1] --=20 2.39.2.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 (#111773): https://edk2.groups.io/g/devel/message/111773 Mute This Topic: https://groups.io/mt/102842751/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-