From 705dc80054346b44f81316786e178251f6b2752d Mon Sep 17 00:00:00 2001 From: Yonghong Zhu Date: Mon, 18 Jan 2016 01:46:25 +0000 Subject: BaseTools: VOID* PCDs in VPD region must be aligned based on value type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19650 6f19259b-4bc3-4df7-8a09-765794883524 (cherry picked from commit 5a13737abf9d12d99a15961fa94716b507c701a2) --- BaseTools/Source/Python/AutoGen/AutoGen.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'BaseTools/Source/Python/AutoGen') 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 -- cgit v1.2.3