From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,493,1520924400"; d="scan'208";a="55428564" 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 From: "Kinney, Michael D" To: edk2-devel@lists.01.org Cc: Yanyan Sun , Yonghong Zhu , Liming Gao , Michael D Kinney 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: [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: , X-List-Received-Date: Sat, 09 Jun 2018 06:15:13 -0000 https://bugzilla.tianocore.org/show_bug.cgi?id=974 https://bugzilla.tianocore.org/show_bug.cgi?id=965 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 --- 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__ == '__main__': parser.add_argument("-m", "--max-size", dest = 'MaxSize', type = ValidateUnsignedInteger, help = "Maximum size of the PCD. Ignored with --type HII.") parser.add_argument("-f", "--offset", dest = 'Offset', type = ValidateUnsignedInteger, - help = "VPD offset if --type is VPD. UEFI Variable offset if --type is HII.") + help = "VPD offset if --type is VPD. UEFI Variable offset if --type is HII. Must be 8-byte aligned.") parser.add_argument("-n", "--variable-name", dest = 'VariableName', help = "UEFI variable name. Only used with --type HII.") parser.add_argument("-g", "--variable-guid", type = ValidateGuidName, dest = 'VariableGuid', @@ -178,6 +178,12 @@ if __name__ == '__main__': Pcd = ' %s|*|%d|%s' % (args.PcdName, args.MaxSize, PcdValue) else: # + # --offset value must be 8-byte aligned + # + if (args.Offset % 8) != 0: + print 'BinToPcd: error: argument --offset must be 8-byte aligned.' + sys.exit() + # # Use the --offset value provided. # Pcd = ' %s|%d|%d|%s' % (args.PcdName, args.Offset, args.MaxSize, PcdValue) @@ -194,6 +200,12 @@ if __name__ == '__main__': # Use UEFI Variable offset of 0 if --offset is not provided # args.Offset = 0 + # + # --offset value must be 8-byte aligned + # + if (args.Offset % 8) != 0: + print 'BinToPcd: error: argument --offset must be 8-byte aligned.' + sys.exit() Pcd = ' %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 with PCD sections' -- 2.14.2.windows.3