public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Kinney, Michael D" <michael.d.kinney@intel.com>
To: edk2-devel@lists.01.org
Cc: Yanyan Sun <yanyan.sun@intel.com>,
	Yonghong Zhu <yonghong.zhu@intel.com>,
	Liming Gao <liming.gao@intel.com>,
	Michael D Kinney <michael.d.kinney@intel.com>
Subject: [Patch 3/5] BaseTools/BinToPcd: --offset must be 8-byte aligned
Date: Fri,  8 Jun 2018 23:15:03 -0700	[thread overview]
Message-ID: <20180609061505.14380-4-michael.d.kinney@intel.com> (raw)
In-Reply-To: <20180609061505.14380-1-michael.d.kinney@intel.com>

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 <yanyan.sun@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
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



  parent reply	other threads:[~2018-06-09  6:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-09  6:15 [Patch 0/5] BaseTools/BinToPcd: Multiple clean up tasks Kinney, Michael D
2018-06-09  6:15 ` [Patch 1/5] BaseTools/BinToPcd: Fix typo in error messages Kinney, Michael D
2018-06-09  6:15 ` [Patch 2/5] BaseTools/BinToPcd: Clarify error message for --type HII Kinney, Michael D
2018-06-09  6:15 ` Kinney, Michael D [this message]
2018-06-09  6:15 ` [Patch 4/5] BaseTools/BinToPcd: Update for Python 3 compatibility Kinney, Michael D
2018-06-09  6:15 ` [Patch 5/5] BaseTools/BinToPcd: Follow PEP-8 indent of 4 spaces Kinney, Michael D
2018-06-12  0:40 ` [Patch 0/5] BaseTools/BinToPcd: Multiple clean up tasks Zhu, Yonghong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180609061505.14380-4-michael.d.kinney@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox