From ca85291f1f020652254457cc9edbb3caf6a2ed56 Mon Sep 17 00:00:00 2001 From: Yonghong Zhu Date: Fri, 29 Jan 2016 04:44:54 +0000 Subject: [PATCH] BaseTools: Fix a bug for VpdOffset calculate The VpdOffset value in the DSC both support integer and Hex value, so we fix the bug to support both format. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19765 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/AutoGen/AutoGen.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index dfb5b72b13..55a59dabc0 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1154,7 +1154,14 @@ class PlatformAutoGen(AutoGen): Alignment = 2 else: Alignment = 1 - if int(Sku.VpdOffset) % Alignment != 0: + try: + VpdOffset = int(Sku.VpdOffset) + except: + try: + VpdOffset = int(Sku.VpdOffset, 16) + except: + EdkLogger.error("build", FORMAT_INVALID, "Invalid offset value %s for PCD %s.%s." % (Sku.VpdOffset, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)) + if VpdOffset % Alignment != 0: EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Alignment)) VpdFile.Add(Pcd, Sku.VpdOffset) # if the offset of a VPD is *, then it need to be fixed up by third party tool. @@ -1220,7 +1227,14 @@ class PlatformAutoGen(AutoGen): Alignment = 2 else: Alignment = 1 - if int(Sku.VpdOffset) % Alignment != 0: + try: + VpdOffset = int(Sku.VpdOffset) + except: + try: + VpdOffset = int(Sku.VpdOffset, 16) + except: + EdkLogger.error("build", FORMAT_INVALID, "Invalid offset value %s for PCD %s.%s." % (Sku.VpdOffset, DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName)) + if VpdOffset % Alignment != 0: EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, Alignment)) VpdFile.Add(DscPcdEntry, Sku.VpdOffset) if not NeedProcessVpdMapFile and Sku.VpdOffset == "*": -- 2.39.5