From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1FAECAC0B16 for ; Tue, 28 Nov 2023 03:29:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ffNChzqwGt2lP5KYogwJzXxsmryNtfNcJYMewj5u4L0=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1701142139; v=1; b=V7eCn39rTYSeImyeYdUDnZk5yk65ZqA51g/uXct0gl32wmN2wmBuOtmLSPT7eGIcC/a0kG50 V1BlTSdE6PIx/GxjNoZGrBMZWOR8RwgCjB0paDaW94ag7exQ/vBxtN0n5DeC5k2CauHJzDR+0r4 sSPyckZKuqt4qjzzYBEkjgs8= X-Received: by 127.0.0.2 with SMTP id 8ejZYY7687511x4fCILbxivG; Mon, 27 Nov 2023 19:28:59 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.24597.1701142138479048972 for ; Mon, 27 Nov 2023 19:28:59 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="457172594" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="457172594" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 19:28:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="891944110" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="891944110" X-Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga004.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 27 Nov 2023 19:28:52 -0800 X-Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 27 Nov 2023 19:28:51 -0800 X-Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 27 Nov 2023 19:28:51 -0800 X-Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 27 Nov 2023 19:28:51 -0800 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.100) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Mon, 27 Nov 2023 19:28:51 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cEn+d0iY1fSrCVGMD97uv2PLI/9BDtDg8q5uJMr/eNK5ULCWtJ1i1TAJS7kR9J9KwL9qvXJfp0i5sEGqUCTUoj7RbQmb+jbDA7QrirNppfAF/R3+xPR7RvSL4qfia7QLDo7mKIfkMiuYdwBEKWVXy87m6GXWmfO10r3q/7IlNTK8Tcwwu8w0tQ0y/p1LZVqfGHMrEJmyD//Zg+bVALwS4HiHSA6YJNKmsfpNIlmZPX4CvIl7NujOYV8NuKLHNSj9BpDHMpHsgoOJmIN8K9RhEaMKE0BimnPlkq9ypSg6frEPAWCuDMS8sfR3wwN5u3VwZNwsGr0uShIEamaQ6V8HlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GlI83Q6YAmQby8Ul/Ic4p+qotpYk3URm3RfPewlzues=; b=ELbb8PvcFSJeLyiRPJ2kyW2SrShME7WxonxQCZ5YuCS4rz3PWokX/F12+w6gVe1TOUlz8pqTc3vRqggVSlq/jXsCwk/gSeONPPcmOY09I0H6ySu/GIwuIb3Q7QFosqQerFbtZFmKoYGZzv3K0nmKQpKLruHwhO0BfxIfWEaGcYfLcVDoJ3x+pFPKyMqOF7R0GEKFLFLEfURvK6F/8O8G8n08stH+cuEqgvxTCBcVM7f7zCs9j+mPzd4nqPVM4T8OUAw/e+owJtVfn3n93T4Jq6NO/HyBq4thMg831/uRx2kInol3vGP6NkdMW3DBqZx3xHXe3vZLCmKXIMbxy/BkoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from BN9PR11MB5483.namprd11.prod.outlook.com (2603:10b6:408:104::10) by CY5PR11MB6308.namprd11.prod.outlook.com (2603:10b6:930:20::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.29; Tue, 28 Nov 2023 03:28:46 +0000 X-Received: from BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::6da1:a4b7:4771:14e1]) by BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::6da1:a4b7:4771:14e1%5]) with mapi id 15.20.7025.022; Tue, 28 Nov 2023 03:28:46 +0000 From: "Chiu, Chasel" To: "Desimone, Nathaniel L" , "devel@edk2.groups.io" CC: "Gao, Liming" , "Dong, Eric" Subject: Re: [edk2-devel] [edk2-platforms][PATCH v1] MinPlatformPkg: Update PatchFv Tools for Python 3.x Thread-Topic: [edk2-platforms][PATCH v1] MinPlatformPkg: Update PatchFv Tools for Python 3.x Thread-Index: AQHaIZbKwxuJOXxL6E+yrx8hco5NGLCPEsJQ Date: Tue, 28 Nov 2023 03:28:46 +0000 Message-ID: References: <20231128010339.1954-1-nathaniel.l.desimone@intel.com> <20231128010339.1954-2-nathaniel.l.desimone@intel.com> In-Reply-To: <20231128010339.1954-2-nathaniel.l.desimone@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BN9PR11MB5483:EE_|CY5PR11MB6308:EE_ x-ms-office365-filtering-correlation-id: f5b69170-3c75-4df0-640c-08dbefc22185 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: NBThlJ28gKjQfliMyTopRNgbERa3pHw69bhzHl+XbLRaNCwdl8wYtE3dDxHppfBepwR7WRC+yy6RQ3AdPVpkGlqMB4XPklOmj7MTxVdxfydRCcbSFFwGtjBkLU79NCCvm8lzuW+hCaqNDl3JoitpRAHK+1BhQD9SQrPVCbh7r6X0tXoJf2mKNGA765lbxbx5KREXmFBUfrxdcJsrvPhQrfgV/hoz1X8RkYXWtix/dFRe5kRRym9H4PeiTuo9P5cAvPcHE1sKRxP2eWW0LKlORZOLIqcKrlYp27STHbygM7VXn8ZF6OWd1VbojWeNYwpXPtcy0TETZX400gfiFPOs0FP0qOliRoA+txzkz7w84p0oDDHNTtvB4yTIbVFyK9EeQmGhwTWoygRmIIx1ifyFHnAGEgnKQU+4qdLUgOTJAM2C74Vklgy2xCOck9B1Wq1X7Qmxrcsa++DIzTlsXpGHoWZKA3pk/PHrg9wi1MpjviEXPv2H5BKYKoTbUswQdhIoUfoj91Kceu1w6bO8cdfirULtOSfYgU2lrSiobHjMvHuLSAzWoUIJ7Qs6/GncoO8q+aLj48GRi1CNO63NleU/76ZwG0rJ5fDue5xFZQ+aJhRrPZqFXy1B975lGAgbdmPd x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?RYXG6w0zEbs/1sowIXzdwkO+ltS0EgknosdBQ9safkLKM/SgSRxUdcmv86bl?= =?us-ascii?Q?w1rtWuy4m6frVPFJI4lMDbdxStt9R1anliK9YEIfz6VrMTC+CHGJ+s75YqMq?= =?us-ascii?Q?l92DcGvGc69U3tqZ3uEhH0Usl4dC1/5WAoCFxUMZ7/JzMDWLPSbzT1eO6hQt?= =?us-ascii?Q?zKBRjZldmshsUt7WVV+/drsiEEuLl3awFvlb76OZpI50hJc/DdrAKf76zYKK?= =?us-ascii?Q?/6NUZXhZcAvfTyJP7sphDaCVb30/xb90P+U+4HaAnA3+m9sHooEd2/FH9iPN?= =?us-ascii?Q?/2D0dRbUCOF1q1KSevHPB3tgSsbT/zkyA0ZbLx2s6pUOBnQcGuxzVM0glG8D?= =?us-ascii?Q?6Ai3QvAWBKmMahRhIqm483oBJc+O8qP7J3eZt81Ae2zpTuJUakSf0h5YjHFp?= =?us-ascii?Q?sujuYtgpaHYsgYvGBBzRi0p8n30lW2OqnF2U6bJ+yZTDYSpYicLUCSNXNGpS?= =?us-ascii?Q?ieK+Xk8Sr7anDlLtD1rkC6m912NRuLzY5Hwa5hXuzZ1pOZ8t2dNjdRcucnxs?= =?us-ascii?Q?FF1FAZG7C16efZUQ3DQfZCMoZKtXfXPgSGnnaCsQ0h/Tz8iv1VfrDzSPXWV6?= =?us-ascii?Q?AVlQHk0jLXSfHCK69a7/nd7L2DZfZTSQMtXK+zSlP2+9PfkSjo0o9CyvsgJH?= =?us-ascii?Q?x2HZvTRlAOLQDWovvtmAPlkLZ9smipy0bDsbLuAmV82pdLKUWvnXAOXss+1+?= =?us-ascii?Q?3t72xp2Es31kapr1ZyjGHogbldABZtEg23hYgwZ/wZEkU5AZoK5ZnhnUaodg?= =?us-ascii?Q?QfmiOAOoMF3eHfhheOs/wqsxMlHh9jf0feYaIgpatqU0ZiLgfYuPpSKVcxP8?= =?us-ascii?Q?VYU3N5WXurb/fciNiVzq1y2ciA/scnBnmmlQNF+Z6sjCnXMe/YbIbcznCxlo?= =?us-ascii?Q?XrGTyleR3yAzoUsV9WztXc5wWu7DtepjaCXSnsBZ2h3aGjcYN2F/d6jysNYZ?= =?us-ascii?Q?yRkFw7YmDOxkG94ssFt8Gad4p2hP1VV9PTvO3WB/g4b88656sfX7+A7cTREz?= =?us-ascii?Q?Ip3Ej7vOu5Dx1je0DRUFRKEABE2aRTRu/DoCcG2PFZwlB3l9ERDWZmYSg3Mg?= =?us-ascii?Q?nOxq/RZen3NotQkoOZidkWaENgDZhrX2qZCBMrJqZdztOe2O42ZPTTyIXMSz?= =?us-ascii?Q?4qLIJFQQCv9kWu2pt5uv85x4t+gvmvWlu8K7+yUNjhCKE1O83aD/G7ITcaAk?= =?us-ascii?Q?z7WDawM3Q+SoUxw9L8wuRj6zQZwBN/22xsCpCdWPPXjJGEI4G9CYFd7pgnE/?= =?us-ascii?Q?ReYPy8GbWs+Im97/Ktr2O4HRTIS7K2qRnqx/LQGtItu0STUBdSzQZ02EQnU5?= =?us-ascii?Q?GNjtjvwTCir1awK0/UsUV7rZDDEe5vtufocFMcGj+IABsuWOcq1L7qRnI3tZ?= =?us-ascii?Q?rvGxBce+AcZPWlYxV8Qwj8SJAKKBIwmC20M3k7WOn7f3TkFLoToag2WPhnXu?= =?us-ascii?Q?DVB9XmphuUD0n4sH5ZvaF+GQgWq57POXkT7qp7Ey5FhUa3fSAUdzEle1ySht?= =?us-ascii?Q?M0/z9qcIgI8WASvgL9SvuGki77nx46DSFJbbEuAcabhBwY6gjjK+bObckUgJ?= =?us-ascii?Q?vl/YkNDrulSpfFCvYmuvISOxIPsYud66GKMy4TRw?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5483.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5b69170-3c75-4df0-640c-08dbefc22185 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Nov 2023 03:28:46.8125 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: WZlA+V7E9c7qzs+qeVGMnHKlXrgpgOE7DMW8tJiXEQ6nOanyv8YhsTxPrM0fu43sFo2gao1iIiRRZvcDVhMilA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6308 X-OriginatorOrg: intel.com 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,chasel.chiu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: mzAHuKuYZPNfxMF94uK6OHC5x7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=V7eCn39r; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Reviewed-by: Chasel Chiu Thanks, Chasel > -----Original Message----- > From: Desimone, Nathaniel L > Sent: Monday, November 27, 2023 5:04 PM > To: devel@edk2.groups.io > Cc: Chiu, Chasel ; Gao, Liming > ; Dong, Eric > Subject: [edk2-platforms][PATCH v1] MinPlatformPkg: Update PatchFv Tools = for > Python 3.x >=20 > PatchFv tools now run on Python 3.x >=20 > Cc: Chasel Chiu > Cc: Liming Gao > Cc: Eric Dong > Signed-off-by: Nate DeSimone > --- > .../MinPlatformPkg/Tools/PatchFv/PatchBfv.py | 35 ++++---- > .../Tools/PatchFv/PatchBinFv.py | 69 ++++++++-------- > .../Tools/PatchFv/RebaseBinFv.py | 82 +++++++++---------- > 3 files changed, 92 insertions(+), 94 deletions(-) >=20 > diff --git a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBfv.py > b/Platform/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 File= Checker: >=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 (splitLin= e[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().s= plit(" ", 1) > - if (cmp (splitLine[0], "FIXED") =3D=3D 0) or (cm= p (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().s= plit()[0] > - print " Type - (" + Type + "), Value - (" += Value + ")" > + print(" Type - (" + Type + "), Value - (" > + + Value + ")") > return [Value, Type] > return ["", ""] > - > + > 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/Platform/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 Fi= leChecker: > 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 @@ cl= ass 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], "= UINT8") =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(= data[offset:offset+1]) + > " <=3D " + binascii.hexlify(b) > + print(" [" + hex(offset) + "] " + > + bytes(data[offset:offset+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(= data[offset:offset+2]) + > " <=3D " + binascii.hexlify(h) > + print(" [" + hex(offset) + "] " + > + bytes(data[offset:offset+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(= data[offset:offset+4]) + > " <=3D " + binascii.hexlify(l) > + print(" [" + hex(offset) + "] " + > + bytes(data[offset:offset+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(= data[offset:offset+8]) + > " <=3D " + binascii.hexlify(q) > + print(" [" + hex(offset) + "] " + > + bytes(data[offset:offset+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 (newlin= e[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 (splitLin= e[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().s= plit(" ", 1) > - if (cmp (splitLine[0], "FIXED") =3D=3D 0) or (cm= p (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().s= plit()[0] > - print " Type - (" + Type + "), Value - (" += Value + ")" > + print(" Type - (" + Type + "), Value - (" > + + Value + ")") > return [Value, Type] > return ["", ""] > - > + > 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/Platform/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, > self.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%02x%02x%02x" % (FvExHeader.FvName.Guid1, > FvExHeader.FvName.Guid2, FvExHeader.FvName.Guid3, > FvExHeader.FvName.Guid4[0], FvExHeader.FvName.Guid4[1], > FvExHeader.FvName.Guid4[2], FvExHeader.FvName.Guid4[3], > FvExHeader.FvName.Guid4[4], FvExHeader.FvName.Guid4[5], > FvExHeader.FvName.Guid4[6], FvExHeader.FvName.Guid4[7]) > - print " ExtHeaderSize - " + hex(FvExHeader.ExtHeaderSiz= e) > + print(" FvName - %08x-%04x-%04x-%02x%02x- > %02x%02x%02x%02x%02x%02x" % (FvExHeader.FvName.Guid1, > FvExHeader.FvName.Guid2, FvExHeader.FvName.Guid3, > FvExHeader.FvName.Guid4[0], FvExHeader.FvName.Guid4[1], > FvExHeader.FvName.Guid4[2], FvExHeader.FvName.Guid4[3], > FvExHeader.FvName.Guid4[4], FvExHeader.FvName.Guid4[5], > FvExHeader.FvName.Guid4[6], FvExHeader.FvName.Guid4[7])) > + print(" ExtHeaderSize - " + > + hex(FvExHeader.ExtHeaderSize)) > Offset =3D FvHeader.ExtHeaderOffset + FvExHeader.ExtHead= erSize > 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, FfsHeader.Name.Guid4[0], > FfsHeader.Name.Guid4[1], FfsHeader.Name.Guid4[2], FfsHeader.Name.Guid4[3]= , > FfsHeader.Name.Guid4[4], FfsHeader.Name.Guid4[5], FfsHeader.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, > + FfsHeader.Name.Guid4[0], FfsHeader.Name.Guid4[1], > + FfsHeader.Name.Guid4[2], FfsHeader.Name.Guid4[3], > + FfsHeader.Name.Guid4[4], FfsHeader.Name.Guid4[5], > + FfsHeader.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_buf= fer > (data, Offset) > #print " Section - " + hex(Offset) > if (SectionHeader.Type =3D=3D EFI_SECTION_PE32) or (= SectionHeader.Type > =3D=3D EFI_SECTION_TE) : > PeOffset =3D Offset + sizeof(EFI_COMMON_SECTION_= HEADER) > - print " PE - " + hex(PeOffset) + "(" + > binascii.hexlify(data[PeOffset:PeOffset+2]) + ")" > + print(" PE - " + hex(PeOffset) + "(" + > bytes(data[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(ol= dbase) + " <=3D=3D " + > hex(newbase) + ")" > + print(" delta - " + hex(delta) + "(" + hex(ol= dbase) + " <=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 (splitLin= e[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().s= plit(" ", 1) > - if (cmp (splitLine[0], "FIXED") =3D=3D 0) or (cm= p (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().s= plit()[0] > - print " Type - (" + Type + "), Value - (" += Value + ")" > + print(" Type - (" + Type + "), Value - (" > + + Value + ")") > 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,fvN= ame+".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 + "|" + Ne= wFvBase + "\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 m= ain(): > 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] > -- > 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 (#111787): https://edk2.groups.io/g/devel/message/111787 Mute This Topic: https://groups.io/mt/102842751/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-