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 <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19765 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Yonghong Zhu 2016-01-29 04:44:54 +00:00 committed by yzhu52
parent 898b5b63c3
commit ca85291f1f
1 changed files with 16 additions and 2 deletions

View File

@ -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 == "*":