From nobody Sun Apr 28 22:26:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1528524916382534.8061489118378; Fri, 8 Jun 2018 23:15:16 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F39EF2110A007; Fri, 8 Jun 2018 23:15:14 -0700 (PDT) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B24B12110717E for ; Fri, 8 Jun 2018 23:15:11 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 23:15:11 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.254.116.225]) by fmsmga002.fm.intel.com with ESMTP; 08 Jun 2018 23:15:11 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,493,1520924400"; d="scan'208";a="55428554" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Fri, 8 Jun 2018 23:15:01 -0700 Message-Id: <20180609061505.14380-2-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180609061505.14380-1-michael.d.kinney@intel.com> References: <20180609061505.14380-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch 1/5] BaseTools/BinToPcd: Fix typo in error messages X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Yanyan Sun , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D962 Change "PcdToBin" to "BinToPcd" Cc: Yanyan Sun Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Yonghong Zhu =20 --- BaseTools/Scripts/BinToPcd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py index f2485a27fa..014aad9800 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -135,7 +135,7 @@ if __name__ =3D=3D '__main__': # Pcd =3D PcdValue if args.Verbose: - print 'PcdToBin: Convert binary file to PCD Value' + print 'BinToPcd: Convert binary file to PCD Value' elif args.PcdType is None: # # If --type is neither VPD nor HII, then use PCD statement syntax that= is @@ -155,7 +155,7 @@ if __name__ =3D=3D '__main__': Pcd =3D ' %s|%s|VOID*|%d' % (args.PcdName, PcdValue, args.MaxSize) =20 if args.Verbose: - print 'PcdToBin: Convert binary file to PCD statement compatible wit= h PCD sections:' + print 'BinToPcd: Convert binary file to PCD statement compatible wit= h PCD sections:' print ' [PcdsFixedAtBuild]' print ' [PcdsPatchableInModule]' print ' [PcdsDynamicDefault]' @@ -182,7 +182,7 @@ if __name__ =3D=3D '__main__': # Pcd =3D ' %s|%d|%d|%s' % (args.PcdName, args.Offset, args.MaxSize, = PcdValue) if args.Verbose: - print 'PcdToBin: Convert binary file to PCD statement compatible wit= h PCD sections' + print 'BinToPcd: Convert binary file to PCD statement compatible wit= h PCD sections' print ' [PcdsDynamicVpd]' print ' [PcdsDynamicExVpd]' elif args.PcdType =3D=3D 'HII': @@ -199,7 +199,7 @@ if __name__ =3D=3D '__main__': args.Offset =3D 0 Pcd =3D ' %s|L"%s"|%s|%d|%s' % (args.PcdName, args.VariableName, args= .VariableGuid, args.Offset, PcdValue) if args.Verbose: - print 'PcdToBin: Convert binary file to PCD statement compatible wit= h PCD sections' + print 'BinToPcd: Convert binary file to PCD statement compatible wit= h PCD sections' print ' [PcdsDynamicHii]' print ' [PcdsDynamicExHii]' =20 --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 22:26:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1528524920043343.2742947816895; Fri, 8 Jun 2018 23:15:20 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 27E7B2110D51A; Fri, 8 Jun 2018 23:15:15 -0700 (PDT) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 599A12110717E for ; Fri, 8 Jun 2018 23:15:12 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 23:15:12 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.254.116.225]) by fmsmga002.fm.intel.com with ESMTP; 08 Jun 2018 23:15:11 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,493,1520924400"; d="scan'208";a="55428559" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Fri, 8 Jun 2018 23:15:02 -0700 Message-Id: <20180609061505.14380-3-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180609061505.14380-1-michael.d.kinney@intel.com> References: <20180609061505.14380-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch 2/5] BaseTools/BinToPcd: Clarify error message for --type HII X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Yanyan Sun , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D963 Update error message for --type HII. If either --variable-guid or --variable-name is missing, then print an error message that states that both --variable-guid and --variable-name are required. Cc: Yanyan Sun Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Yonghong Zhu =20 --- BaseTools/Scripts/BinToPcd.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py index 014aad9800..7e3380190e 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -186,11 +186,8 @@ if __name__ =3D=3D '__main__': print ' [PcdsDynamicVpd]' print ' [PcdsDynamicExVpd]' elif args.PcdType =3D=3D 'HII': - if args.VariableGuid is None: - print 'BinToPcd: error: argument --variable-guid is required for --t= ype HII.' - sys.exit() - if args.VariableName is None: - print 'BinToPcd: error: argument --variable-name is required for --t= ype HII.' + if args.VariableGuid is None or args.VariableName is None: + print 'BinToPcd: error: arguments --variable-guid and --variable-nam= e are required for --type HII.' sys.exit() if args.Offset is None: # --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 22:26:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1528524923514776.3791963517062; Fri, 8 Jun 2018 23:15:23 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 50D6B21112BB3; Fri, 8 Jun 2018 23:15:15 -0700 (PDT) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EE09721109399 for ; Fri, 8 Jun 2018 23:15:12 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 23:15:12 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.254.116.225]) by fmsmga002.fm.intel.com with ESMTP; 08 Jun 2018 23:15:12 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,493,1520924400"; d="scan'208";a="55428564" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Fri, 8 Jun 2018 23:15:03 -0700 Message-Id: <20180609061505.14380-4-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180609061505.14380-1-michael.d.kinney@intel.com> References: <20180609061505.14380-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch 3/5] BaseTools/BinToPcd: --offset must be 8-byte aligned X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Yanyan Sun , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D974 https://bugzilla.tianocore.org/show_bug.cgi?id=3D965 Update help to state that --offset must be 8-byte aligned. Verify that --offset is 8-byte aligned and print an error message if it is not 8-byte aligned. Cc: Yanyan Sun Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Yonghong Zhu =20 --- BaseTools/Scripts/BinToPcd.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py index 7e3380190e..54cb844d68 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -89,7 +89,7 @@ if __name__ =3D=3D '__main__': parser.add_argument("-m", "--max-size", dest =3D 'MaxSize', type =3D Val= idateUnsignedInteger, help =3D "Maximum size of the PCD. Ignored with --t= ype HII.") parser.add_argument("-f", "--offset", dest =3D 'Offset', type =3D Valida= teUnsignedInteger, - help =3D "VPD offset if --type is VPD. UEFI Variabl= e offset if --type is HII.") + help =3D "VPD offset if --type is VPD. UEFI Variabl= e offset if --type is HII. Must be 8-byte aligned.") parser.add_argument("-n", "--variable-name", dest =3D 'VariableName', help =3D "UEFI variable name. Only used with --type= HII.") parser.add_argument("-g", "--variable-guid", type =3D ValidateGuidName, = dest =3D 'VariableGuid', @@ -178,6 +178,12 @@ if __name__ =3D=3D '__main__': Pcd =3D ' %s|*|%d|%s' % (args.PcdName, args.MaxSize, PcdValue) else: # + # --offset value must be 8-byte aligned + # + if (args.Offset % 8) !=3D 0: + print 'BinToPcd: error: argument --offset must be 8-byte aligned.' + sys.exit() + # # Use the --offset value provided. # Pcd =3D ' %s|%d|%d|%s' % (args.PcdName, args.Offset, args.MaxSize, = PcdValue) @@ -194,6 +200,12 @@ if __name__ =3D=3D '__main__': # Use UEFI Variable offset of 0 if --offset is not provided # args.Offset =3D 0 + # + # --offset value must be 8-byte aligned + # + if (args.Offset % 8) !=3D 0: + print 'BinToPcd: error: argument --offset must be 8-byte aligned.' + sys.exit() Pcd =3D ' %s|L"%s"|%s|%d|%s' % (args.PcdName, args.VariableName, args= .VariableGuid, args.Offset, PcdValue) if args.Verbose: print 'BinToPcd: Convert binary file to PCD statement compatible wit= h PCD sections' --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 22:26:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 15285249272771021.4003090147918; Fri, 8 Jun 2018 23:15:27 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7B4CC21122E2C; Fri, 8 Jun 2018 23:15:15 -0700 (PDT) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 988722110718E for ; Fri, 8 Jun 2018 23:15:13 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 23:15:13 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.254.116.225]) by fmsmga002.fm.intel.com with ESMTP; 08 Jun 2018 23:15:13 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,493,1520924400"; d="scan'208";a="55428568" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Fri, 8 Jun 2018 23:15:04 -0700 Message-Id: <20180609061505.14380-5-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180609061505.14380-1-michael.d.kinney@intel.com> References: <20180609061505.14380-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch 4/5] BaseTools/BinToPcd: Update for Python 3 compatibility X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Yanyan Sun , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Update to be compatible with both Python 2.x and Python 3.x. Also return error code 1 when an error is detected to support use of this tool in scripts. Cc: Yanyan Sun Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Yonghong Zhu =20 --- BaseTools/Scripts/BinToPcd.py | 81 +++++++++++++++++++++------------------= ---- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py index 54cb844d68..52c231615f 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -24,7 +24,6 @@ import xdrlib # Globals for help information # __prog__ =3D 'BinToPcd' -__version__ =3D '%s Version %s' % (__prog__, '0.91 ') __copyright__ =3D 'Copyright (c) 2016 - 2018, Intel Corporation. All rig= hts reserved.' __description__ =3D 'Convert one or more binary files to a VOID* PCD value= or DSC file VOID* PCD statement.\n' =20 @@ -33,22 +32,22 @@ if __name__ =3D=3D '__main__': try: Value =3D int (Argument, 0) except: - Message =3D '%s is not a valid integer value.' % (Argument) + Message =3D '{Argument} is not a valid integer value.'.format (Argum= ent =3D Argument) raise argparse.ArgumentTypeError(Message) if Value < 0: - Message =3D '%s is a negative value.' % (Argument) + Message =3D '{Argument} is a negative value.'.format (Argument =3D A= rgument) raise argparse.ArgumentTypeError(Message) return Value =20 def ValidatePcdName (Argument): - if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argu= ment) <> ['','']: - Message =3D '%s is not in the form .' % (Argument) + if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argu= ment) !=3D ['','']: + Message =3D '{Argument} is not in the form .= '.format (Argument =3D Argument) raise argparse.ArgumentTypeError(Message) return Argument =20 def ValidateGuidName (Argument): - if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) <> ['','']: - Message =3D '%s is not a valid GUID C name' % (Argument) + if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) !=3D ['','']: + Message =3D '{Argument} is not a valid GUID C name'.format (Argument= =3D Argument) raise argparse.ArgumentTypeError(Message) return Argument =20 @@ -61,21 +60,21 @@ if __name__ =3D=3D '__main__': XdrEncoder =3D xdrlib.Packer() for Item in Buffer: XdrEncoder.pack_bytes(Item) - Buffer =3D XdrEncoder.get_buffer() + Buffer =3D bytearray(XdrEncoder.get_buffer()) else: # # If Xdr flag is not set, then concatenate all the data # - Buffer =3D ''.join(Buffer) + Buffer =3D b''.join(Buffer) # # Return a PCD value of the form '{0x01, 0x02, ...}' along with the PC= D length in bytes # - return '{%s}' % (', '.join(['0x%02x' % (ord(Item)) for Item in Buffer]= )), len (Buffer) + return '{' + (', '.join(['0x{Byte:02X}'.format(Byte =3D Item) for Item= in Buffer])) + '}', len (Buffer) =20 # # Create command line argument parser object # - parser =3D argparse.ArgumentParser(prog =3D __prog__, version =3D __vers= ion__, + parser =3D argparse.ArgumentParser(prog =3D __prog__, description =3D __description__ + __cop= yright__, conflict_handler =3D 'resolve') parser.add_argument("-i", "--input", dest =3D 'InputFile', type =3D argp= arse.FileType('rb'), action=3D'append', required =3D True, @@ -117,8 +116,8 @@ if __name__ =3D=3D '__main__': Buffer.append(File.read()) File.close() except: - print 'BinToPcd: error: can not read binary input file', File - sys.exit() + print ('BinToPcd: error: can not read binary input file {File}'.form= at (File =3D File)) + sys.exit(1) =20 # # Convert PCD to an encoded string of hex values and determine the size = of @@ -135,7 +134,7 @@ if __name__ =3D=3D '__main__': # Pcd =3D PcdValue if args.Verbose: - print 'BinToPcd: Convert binary file to PCD Value' + print ('BinToPcd: Convert binary file to PCD Value') elif args.PcdType is None: # # If --type is neither VPD nor HII, then use PCD statement syntax that= is @@ -147,19 +146,19 @@ if __name__ =3D=3D '__main__': # If --max-size is not provided, then do not generate the syntax that # includes the maximum size. # - Pcd =3D ' %s|%s' % (args.PcdName, PcdValue) + Pcd =3D ' {Name}|{Value}'.format (Name =3D args.PcdName, Value =3D = PcdValue) elif args.MaxSize < PcdSize: - print 'BinToPcd: error: argument --max-size is smaller than input fi= le.' - sys.exit() + print ('BinToPcd: error: argument --max-size is smaller than input f= ile.') + sys.exit(1) else: - Pcd =3D ' %s|%s|VOID*|%d' % (args.PcdName, PcdValue, args.MaxSize) + Pcd =3D ' {Name}|{Value}|VOID*|{Size}'.format (Name =3D args.PcdNam= e, Value =3D PcdValue, Size =3D args.MaxSize) =20 if args.Verbose: - print 'BinToPcd: Convert binary file to PCD statement compatible wit= h PCD sections:' - print ' [PcdsFixedAtBuild]' - print ' [PcdsPatchableInModule]' - print ' [PcdsDynamicDefault]' - print ' [PcdsDynamicExDefault]' + print ('BinToPcd: Convert binary file to PCD statement compatible wi= th PCD sections:') + print (' [PcdsFixedAtBuild]') + print (' [PcdsPatchableInModule]') + print (' [PcdsDynamicDefault]') + print (' [PcdsDynamicExDefault]') elif args.PcdType =3D=3D 'VPD': if args.MaxSize is None: # @@ -168,33 +167,33 @@ if __name__ =3D=3D '__main__': # args.MaxSize =3D PcdSize if args.MaxSize < PcdSize: - print 'BinToPcd: error: argument --max-size is smaller than input fi= le.' - sys.exit() + print ('BinToPcd: error: argument --max-size is smaller than input f= ile.') + sys.exit(1) if args.Offset is None: # # if --offset is not provided, then set offset field to '*' so build # tools will compute offset of PCD in VPD region. # - Pcd =3D ' %s|*|%d|%s' % (args.PcdName, args.MaxSize, PcdValue) + Pcd =3D ' {Name}|*|{Size}|{Value}'.format (Name =3D args.PcdName, S= ize =3D args.MaxSize, Value =3D PcdValue) else: # # --offset value must be 8-byte aligned # if (args.Offset % 8) !=3D 0: - print 'BinToPcd: error: argument --offset must be 8-byte aligned.' - sys.exit() + print ('BinToPcd: error: argument --offset must be 8-byte aligned.= ') + sys.exit(1) # # Use the --offset value provided. # - Pcd =3D ' %s|%d|%d|%s' % (args.PcdName, args.Offset, args.MaxSize, = PcdValue) + Pcd =3D ' {Name}|{Offset}|{Size}|{Value}'.format (Name =3D args.Pcd= Name, Offset =3D args.Offset, Size =3D args.MaxSize, Value =3D PcdValue) if args.Verbose: - print 'BinToPcd: Convert binary file to PCD statement compatible wit= h PCD sections' - print ' [PcdsDynamicVpd]' - print ' [PcdsDynamicExVpd]' + print ('BinToPcd: Convert binary file to PCD statement compatible wi= th PCD sections') + print (' [PcdsDynamicVpd]') + print (' [PcdsDynamicExVpd]') elif args.PcdType =3D=3D 'HII': if args.VariableGuid is None or args.VariableName is None: - print 'BinToPcd: error: arguments --variable-guid and --variable-nam= e are required for --type HII.' - sys.exit() + print ('BinToPcd: error: arguments --variable-guid and --variable-na= me are required for --type HII.') + sys.exit(1) if args.Offset is None: # # Use UEFI Variable offset of 0 if --offset is not provided @@ -204,13 +203,13 @@ if __name__ =3D=3D '__main__': # --offset value must be 8-byte aligned # if (args.Offset % 8) !=3D 0: - print 'BinToPcd: error: argument --offset must be 8-byte aligned.' - sys.exit() - Pcd =3D ' %s|L"%s"|%s|%d|%s' % (args.PcdName, args.VariableName, args= .VariableGuid, args.Offset, PcdValue) + print ('BinToPcd: error: argument --offset must be 8-byte aligned.') + sys.exit(1) + Pcd =3D ' {Name}|L"{VarName}"|{VarGuid}|{Offset}|{Value}'.format (Nam= e =3D args.PcdName, VarName =3D args.VariableName, VarGuid =3D args.Variabl= eGuid, Offset =3D args.Offset, Value =3D PcdValue) if args.Verbose: - print 'BinToPcd: Convert binary file to PCD statement compatible wit= h PCD sections' - print ' [PcdsDynamicHii]' - print ' [PcdsDynamicExHii]' + print ('BinToPcd: Convert binary file to PCD statement compatible wi= th PCD sections') + print (' [PcdsDynamicHii]') + print (' [PcdsDynamicExHii]') =20 # # Write PCD value or PCD statement to the output file @@ -223,4 +222,4 @@ if __name__ =3D=3D '__main__': # If output file is not specified or it can not be written, then write= the # PCD value or PCD statement to the console # - print Pcd + print (Pcd) --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 22:26:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 152852493089186.28028608356112; Fri, 8 Jun 2018 23:15:30 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A3B602112388D; Fri, 8 Jun 2018 23:15:16 -0700 (PDT) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 43A9121109FEC for ; Fri, 8 Jun 2018 23:15:14 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 23:15:14 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.254.116.225]) by fmsmga002.fm.intel.com with ESMTP; 08 Jun 2018 23:15:13 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,493,1520924400"; d="scan'208";a="55428572" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Fri, 8 Jun 2018 23:15:05 -0700 Message-Id: <20180609061505.14380-6-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180609061505.14380-1-michael.d.kinney@intel.com> References: <20180609061505.14380-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch 5/5] BaseTools/BinToPcd: Follow PEP-8 indent of 4 spaces X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Yanyan Sun , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://www.python.org/dev/peps/pep-0008/ Cc: Yanyan Sun Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Yonghong Zhu =20 --- BaseTools/Scripts/BinToPcd.py | 356 +++++++++++++++++++++-----------------= ---- 1 file changed, 178 insertions(+), 178 deletions(-) diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py index 52c231615f..b907d3e5e0 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -28,198 +28,198 @@ __copyright__ =3D 'Copyright (c) 2016 - 2018, Intel= Corporation. All rights rese __description__ =3D 'Convert one or more binary files to a VOID* PCD value= or DSC file VOID* PCD statement.\n' =20 if __name__ =3D=3D '__main__': - def ValidateUnsignedInteger (Argument): - try: - Value =3D int (Argument, 0) - except: - Message =3D '{Argument} is not a valid integer value.'.format (Argum= ent =3D Argument) - raise argparse.ArgumentTypeError(Message) - if Value < 0: - Message =3D '{Argument} is a negative value.'.format (Argument =3D A= rgument) - raise argparse.ArgumentTypeError(Message) - return Value + def ValidateUnsignedInteger (Argument): + try: + Value =3D int (Argument, 0) + except: + Message =3D '{Argument} is not a valid integer value.'.format = (Argument =3D Argument) + raise argparse.ArgumentTypeError (Message) + if Value < 0: + Message =3D '{Argument} is a negative value.'.format (Argument= =3D Argument) + raise argparse.ArgumentTypeError (Message) + return Value =20 - def ValidatePcdName (Argument): - if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argu= ment) !=3D ['','']: - Message =3D '{Argument} is not in the form .= '.format (Argument =3D Argument) - raise argparse.ArgumentTypeError(Message) - return Argument + def ValidatePcdName (Argument): + if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*',= Argument) !=3D ['','']: + Message =3D '{Argument} is not in the form .'.format (Argument =3D Argument) + raise argparse.ArgumentTypeError (Message) + return Argument =20 - def ValidateGuidName (Argument): - if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) !=3D ['','']: - Message =3D '{Argument} is not a valid GUID C name'.format (Argument= =3D Argument) - raise argparse.ArgumentTypeError(Message) - return Argument + def ValidateGuidName (Argument): + if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) !=3D ['','']: + Message =3D '{Argument} is not a valid GUID C name'.format (Ar= gument =3D Argument) + raise argparse.ArgumentTypeError (Message) + return Argument + + def ByteArray (Buffer, Xdr =3D False): + if Xdr: + # + # If Xdr flag is set then encode data using the Variable-Lengt= h Opaque + # Data format of RFC 4506 External Data Representation Standar= d (XDR). + # + XdrEncoder =3D xdrlib.Packer () + for Item in Buffer: + XdrEncoder.pack_bytes (Item) + Buffer =3D bytearray (XdrEncoder.get_buffer ()) + else: + # + # If Xdr flag is not set, then concatenate all the data + # + Buffer =3D b''.join (Buffer) + # + # Return a PCD value of the form '{0x01, 0x02, ...}' along with th= e PCD length in bytes + # + return '{' + (', '.join (['0x{Byte:02X}'.format (Byte =3D Item) fo= r Item in Buffer])) + '}', len (Buffer) =20 - def ByteArray (Buffer, Xdr =3D False): - if Xdr: - # - # If Xdr flag is set then encode data using the Variable-Length Opaq= ue - # Data format of RFC 4506 External Data Representation Standard (XDR= ). - # - XdrEncoder =3D xdrlib.Packer() - for Item in Buffer: - XdrEncoder.pack_bytes(Item) - Buffer =3D bytearray(XdrEncoder.get_buffer()) - else: - # - # If Xdr flag is not set, then concatenate all the data - # - Buffer =3D b''.join(Buffer) # - # Return a PCD value of the form '{0x01, 0x02, ...}' along with the PC= D length in bytes + # Create command line argument parser object # - return '{' + (', '.join(['0x{Byte:02X}'.format(Byte =3D Item) for Item= in Buffer])) + '}', len (Buffer) - - # - # Create command line argument parser object - # - parser =3D argparse.ArgumentParser(prog =3D __prog__, - description =3D __description__ + __cop= yright__, - conflict_handler =3D 'resolve') - parser.add_argument("-i", "--input", dest =3D 'InputFile', type =3D argp= arse.FileType('rb'), action=3D'append', required =3D True, - help =3D "Input binary filename. Multiple input fil= es are combined into a single PCD.") - parser.add_argument("-o", "--output", dest =3D 'OutputFile', type =3D ar= gparse.FileType('wb'), - help =3D "Output filename for PCD value or PCD state= ment") - parser.add_argument("-p", "--pcd", dest =3D 'PcdName', type =3D Validate= PcdName, - help =3D "Name of the PCD in the form .") - parser.add_argument("-t", "--type", dest =3D 'PcdType', default =3D None= , choices =3D ['VPD','HII'], - help =3D "PCD statement type (HII or VPD). Default = is standard.") - parser.add_argument("-m", "--max-size", dest =3D 'MaxSize', type =3D Val= idateUnsignedInteger, - help =3D "Maximum size of the PCD. Ignored with --t= ype HII.") - parser.add_argument("-f", "--offset", dest =3D 'Offset', type =3D Valida= teUnsignedInteger, - help =3D "VPD offset if --type is VPD. UEFI Variabl= e offset if --type is HII. Must be 8-byte aligned.") - parser.add_argument("-n", "--variable-name", dest =3D 'VariableName', - help =3D "UEFI variable name. Only used with --type= HII.") - parser.add_argument("-g", "--variable-guid", type =3D ValidateGuidName, = dest =3D 'VariableGuid', - help =3D "UEFI variable GUID C name. Only used with= --type HII.") - parser.add_argument("-x", "--xdr", dest =3D 'Xdr', action =3D "store_tru= e", - help =3D "Encode PCD using the Variable-Length Opaqu= e Data format of RFC 4506 External Data Representation Standard (XDR)") - parser.add_argument("-v", "--verbose", dest =3D 'Verbose', action =3D "s= tore_true", - help =3D "Increase output messages") - parser.add_argument("-q", "--quiet", dest =3D 'Quiet', action =3D "store= _true", - help =3D "Reduce output messages") - parser.add_argument("--debug", dest =3D 'Debug', type =3D int, metavar = =3D '[0-9]', choices =3D range(0,10), default =3D 0, - help =3D "Set debug level") - - # - # Parse command line arguments - # - args =3D parser.parse_args() - - # - # Read all binary input files - # - Buffer =3D [] - for File in args.InputFile: - try: - Buffer.append(File.read()) - File.close() - except: - print ('BinToPcd: error: can not read binary input file {File}'.form= at (File =3D File)) - sys.exit(1) + parser =3D argparse.ArgumentParser (prog =3D __prog__, + description =3D __description__ + __= copyright__, + conflict_handler =3D 'resolve') + parser.add_argument ("-i", "--input", dest =3D 'InputFile', type =3D a= rgparse.FileType ('rb'), action=3D'append', required =3D True, + help =3D "Input binary filename. Multiple input = files are combined into a single PCD.") + parser.add_argument ("-o", "--output", dest =3D 'OutputFile', type =3D= argparse.FileType ('wb'), + help =3D "Output filename for PCD value or PCD st= atement") + parser.add_argument ("-p", "--pcd", dest =3D 'PcdName', type =3D Valid= atePcdName, + help =3D "Name of the PCD in the form .") + parser.add_argument ("-t", "--type", dest =3D 'PcdType', default =3D N= one, choices =3D ['VPD','HII'], + help =3D "PCD statement type (HII or VPD). Defau= lt is standard.") + parser.add_argument ("-m", "--max-size", dest =3D 'MaxSize', type =3D = ValidateUnsignedInteger, + help =3D "Maximum size of the PCD. Ignored with = --type HII.") + parser.add_argument ("-f", "--offset", dest =3D 'Offset', type =3D Val= idateUnsignedInteger, + help =3D "VPD offset if --type is VPD. UEFI Vari= able offset if --type is HII. Must be 8-byte aligned.") + parser.add_argument ("-n", "--variable-name", dest =3D 'VariableName', + help =3D "UEFI variable name. Only used with --t= ype HII.") + parser.add_argument ("-g", "--variable-guid", type =3D ValidateGuidNam= e, dest =3D 'VariableGuid', + help =3D "UEFI variable GUID C name. Only used w= ith --type HII.") + parser.add_argument ("-x", "--xdr", dest =3D 'Xdr', action =3D "store_= true", + help =3D "Encode PCD using the Variable-Length Op= aque Data format of RFC 4506 External Data Representation Standard (XDR)") + parser.add_argument ("-v", "--verbose", dest =3D 'Verbose', action =3D= "store_true", + help =3D "Increase output messages") + parser.add_argument ("-q", "--quiet", dest =3D 'Quiet', action =3D "st= ore_true", + help =3D "Reduce output messages") + parser.add_argument ("--debug", dest =3D 'Debug', type =3D int, metava= r =3D '[0-9]', choices =3D range (0, 10), default =3D 0, + help =3D "Set debug level") =20 - # - # Convert PCD to an encoded string of hex values and determine the size = of - # the encoded PCD in bytes. - # - PcdValue, PcdSize =3D ByteArray (Buffer, args.Xdr) + # + # Parse command line arguments + # + args =3D parser.parse_args () =20 - # - # Convert binary buffer to a DSC file PCD statement - # - if args.PcdName is None: # - # If PcdName is None, then only a PCD value is being requested. + # Read all binary input files # - Pcd =3D PcdValue - if args.Verbose: - print ('BinToPcd: Convert binary file to PCD Value') - elif args.PcdType is None: + Buffer =3D [] + for File in args.InputFile: + try: + Buffer.append (File.read ()) + File.close () + except: + print ('BinToPcd: error: can not read binary input file {File}= '.format (File =3D File)) + sys.exit (1) + # - # If --type is neither VPD nor HII, then use PCD statement syntax that= is - # compatible with [PcdsFixedAtBuild], [PcdsPatchableInModule], - # [PcdsDynamicDefault], and [PcdsDynamicExDefault]. + # Convert PCD to an encoded string of hex values and determine the siz= e of + # the encoded PCD in bytes. # - if args.MaxSize is None: - # - # If --max-size is not provided, then do not generate the syntax that - # includes the maximum size. - # - Pcd =3D ' {Name}|{Value}'.format (Name =3D args.PcdName, Value =3D = PcdValue) - elif args.MaxSize < PcdSize: - print ('BinToPcd: error: argument --max-size is smaller than input f= ile.') - sys.exit(1) - else: - Pcd =3D ' {Name}|{Value}|VOID*|{Size}'.format (Name =3D args.PcdNam= e, Value =3D PcdValue, Size =3D args.MaxSize) + PcdValue, PcdSize =3D ByteArray (Buffer, args.Xdr) =20 - if args.Verbose: - print ('BinToPcd: Convert binary file to PCD statement compatible wi= th PCD sections:') - print (' [PcdsFixedAtBuild]') - print (' [PcdsPatchableInModule]') - print (' [PcdsDynamicDefault]') - print (' [PcdsDynamicExDefault]') - elif args.PcdType =3D=3D 'VPD': - if args.MaxSize is None: - # - # If --max-size is not provided, then set maximum size to the size o= f the - # binary input file - # - args.MaxSize =3D PcdSize - if args.MaxSize < PcdSize: - print ('BinToPcd: error: argument --max-size is smaller than input f= ile.') - sys.exit(1) - if args.Offset is None: - # - # if --offset is not provided, then set offset field to '*' so build - # tools will compute offset of PCD in VPD region. - # - Pcd =3D ' {Name}|*|{Size}|{Value}'.format (Name =3D args.PcdName, S= ize =3D args.MaxSize, Value =3D PcdValue) - else: - # - # --offset value must be 8-byte aligned - # - if (args.Offset % 8) !=3D 0: - print ('BinToPcd: error: argument --offset must be 8-byte aligned.= ') - sys.exit(1) - # - # Use the --offset value provided. - # - Pcd =3D ' {Name}|{Offset}|{Size}|{Value}'.format (Name =3D args.Pcd= Name, Offset =3D args.Offset, Size =3D args.MaxSize, Value =3D PcdValue) - if args.Verbose: - print ('BinToPcd: Convert binary file to PCD statement compatible wi= th PCD sections') - print (' [PcdsDynamicVpd]') - print (' [PcdsDynamicExVpd]') - elif args.PcdType =3D=3D 'HII': - if args.VariableGuid is None or args.VariableName is None: - print ('BinToPcd: error: arguments --variable-guid and --variable-na= me are required for --type HII.') - sys.exit(1) - if args.Offset is None: - # - # Use UEFI Variable offset of 0 if --offset is not provided - # - args.Offset =3D 0 # - # --offset value must be 8-byte aligned + # Convert binary buffer to a DSC file PCD statement # - if (args.Offset % 8) !=3D 0: - print ('BinToPcd: error: argument --offset must be 8-byte aligned.') - sys.exit(1) - Pcd =3D ' {Name}|L"{VarName}"|{VarGuid}|{Offset}|{Value}'.format (Nam= e =3D args.PcdName, VarName =3D args.VariableName, VarGuid =3D args.Variabl= eGuid, Offset =3D args.Offset, Value =3D PcdValue) - if args.Verbose: - print ('BinToPcd: Convert binary file to PCD statement compatible wi= th PCD sections') - print (' [PcdsDynamicHii]') - print (' [PcdsDynamicExHii]') + if args.PcdName is None: + # + # If PcdName is None, then only a PCD value is being requested. + # + Pcd =3D PcdValue + if args.Verbose: + print ('BinToPcd: Convert binary file to PCD Value') + elif args.PcdType is None: + # + # If --type is neither VPD nor HII, then use PCD statement syntax = that is + # compatible with [PcdsFixedAtBuild], [PcdsPatchableInModule], + # [PcdsDynamicDefault], and [PcdsDynamicExDefault]. + # + if args.MaxSize is None: + # + # If --max-size is not provided, then do not generate the synt= ax that + # includes the maximum size. + # + Pcd =3D ' {Name}|{Value}'.format (Name =3D args.PcdName, Valu= e =3D PcdValue) + elif args.MaxSize < PcdSize: + print ('BinToPcd: error: argument --max-size is smaller than i= nput file.') + sys.exit (1) + else: + Pcd =3D ' {Name}|{Value}|VOID*|{Size}'.format (Name =3D args.= PcdName, Value =3D PcdValue, Size =3D args.MaxSize) + + if args.Verbose: + print ('BinToPcd: Convert binary file to PCD statement compati= ble with PCD sections:') + print (' [PcdsFixedAtBuild]') + print (' [PcdsPatchableInModule]') + print (' [PcdsDynamicDefault]') + print (' [PcdsDynamicExDefault]') + elif args.PcdType =3D=3D 'VPD': + if args.MaxSize is None: + # + # If --max-size is not provided, then set maximum size to the = size of the + # binary input file + # + args.MaxSize =3D PcdSize + if args.MaxSize < PcdSize: + print ('BinToPcd: error: argument --max-size is smaller than i= nput file.') + sys.exit (1) + if args.Offset is None: + # + # if --offset is not provided, then set offset field to '*' so= build + # tools will compute offset of PCD in VPD region. + # + Pcd =3D ' {Name}|*|{Size}|{Value}'.format (Name =3D args.PcdN= ame, Size =3D args.MaxSize, Value =3D PcdValue) + else: + # + # --offset value must be 8-byte aligned + # + if (args.Offset % 8) !=3D 0: + print ('BinToPcd: error: argument --offset must be 8-byte = aligned.') + sys.exit (1) + # + # Use the --offset value provided. + # + Pcd =3D ' {Name}|{Offset}|{Size}|{Value}'.format (Name =3D ar= gs.PcdName, Offset =3D args.Offset, Size =3D args.MaxSize, Value =3D PcdVal= ue) + if args.Verbose: + print ('BinToPcd: Convert binary file to PCD statement compati= ble with PCD sections') + print (' [PcdsDynamicVpd]') + print (' [PcdsDynamicExVpd]') + elif args.PcdType =3D=3D 'HII': + if args.VariableGuid is None or args.VariableName is None: + print ('BinToPcd: error: arguments --variable-guid and --varia= ble-name are required for --type HII.') + sys.exit (1) + if args.Offset is None: + # + # Use UEFI Variable offset of 0 if --offset is not provided + # + args.Offset =3D 0 + # + # --offset value must be 8-byte aligned + # + if (args.Offset % 8) !=3D 0: + print ('BinToPcd: error: argument --offset must be 8-byte alig= ned.') + sys.exit (1) + Pcd =3D ' {Name}|L"{VarName}"|{VarGuid}|{Offset}|{Value}'.format = (Name =3D args.PcdName, VarName =3D args.VariableName, VarGuid =3D args.Var= iableGuid, Offset =3D args.Offset, Value =3D PcdValue) + if args.Verbose: + print ('BinToPcd: Convert binary file to PCD statement compati= ble with PCD sections') + print (' [PcdsDynamicHii]') + print (' [PcdsDynamicExHii]') =20 - # - # Write PCD value or PCD statement to the output file - # - try: - args.OutputFile.write (Pcd) - args.OutputFile.close () - except: # - # If output file is not specified or it can not be written, then write= the - # PCD value or PCD statement to the console + # Write PCD value or PCD statement to the output file # - print (Pcd) + try: + args.OutputFile.write (Pcd) + args.OutputFile.close () + except: + # + # If output file is not specified or it can not be written, then w= rite the + # PCD value or PCD statement to the console + # + print (Pcd) --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel