summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python
diff options
context:
space:
mode:
authorYonghong Zhu <yonghong.zhu@intel.com>2016-01-18 01:46:25 +0000
committerHao Wu <hao.a.wu@intel.com>2016-02-24 15:29:45 +0800
commit705dc80054346b44f81316786e178251f6b2752d (patch)
tree09dd04c29ed60d68229c3fe08dc2d5cab4f1beb6 /BaseTools/Source/Python
parentf4b872f4e7439e77ec92d5a7684de01096790ed6 (diff)
downloadedk2-platforms-705dc80054346b44f81316786e178251f6b2752d.tar.xz
BaseTools: VOID* PCDs in VPD region must be aligned based on value type
Base on build spec update, ASCII strings(“string”), will be byte aligned, Unicode strings(L”string”) will be two-byte aligned, Byte arrays, {0x00, 0x01} will be 8-byte aligned. This patch is going to halt with an error message if a VOID* PCD has an offset value that is not aligned based on the syntax of the PCD value. 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@19650 6f19259b-4bc3-4df7-8a09-765794883524 (cherry picked from commit 5a13737abf9d12d99a15961fa94716b507c701a2)
Diffstat (limited to 'BaseTools/Source/Python')
-rw-r--r--BaseTools/Source/Python/AutoGen/AutoGen.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 4c627dfb55..abac47758d 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -317,6 +317,11 @@ class WorkspaceAutoGen(AutoGen):
GlobalData.gFdfParser = Fdf
GlobalData.gAutoGenPhase = False
PcdSet = Fdf.Profile.PcdDict
+ FdDict = Fdf.Profile.FdDict[Fdf.CurrentFdName]
+ for FdRegion in FdDict.RegionList:
+ if str(FdRegion.RegionType) is 'FILE' and self.Platform.VpdToolGuid in str(FdRegion.RegionDataList):
+ if int(FdRegion.Offset) % 8 != 0:
+ EdkLogger.error("build", FORMAT_INVALID, 'The VPD Base Address %s must be 8-byte aligned.' % (FdRegion.Offset))
ModuleList = Fdf.Profile.InfList
self.FdfProfile = Fdf.Profile
for fvname in self.FvTargetList:
@@ -1138,6 +1143,18 @@ class PlatformAutoGen(AutoGen):
Pcd = VpdPcdDict[PcdKey]
for (SkuName,Sku) in Pcd.SkuInfoList.items():
Sku.VpdOffset = Sku.VpdOffset.strip()
+ PcdValue = Sku.DefaultValue
+ if PcdValue == "":
+ PcdValue = Pcd.DefaultValue
+ if Sku.VpdOffset != '*':
+ if PcdValue.startswith("{"):
+ Alignment = 8
+ elif PcdValue.startswith("L"):
+ Alignment = 2
+ else:
+ Alignment = 1
+ if int(Sku.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.
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
@@ -1193,6 +1210,17 @@ class PlatformAutoGen(AutoGen):
# Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]
Sku.VpdOffset = Sku.VpdOffset.strip()
PcdValue = Sku.DefaultValue
+ if PcdValue == "":
+ PcdValue = DscPcdEntry.DefaultValue
+ if Sku.VpdOffset != '*':
+ if PcdValue.startswith("{"):
+ Alignment = 8
+ elif PcdValue.startswith("L"):
+ Alignment = 2
+ else:
+ Alignment = 1
+ if int(Sku.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 == "*":
NeedProcessVpdMapFile = True