Revision: 19650
          http://sourceforge.net/p/edk2/code/19650
Author:   yzhu52
Date:     2016-01-18 01:46:25 +0000 (Mon, 18 Jan 2016)
Log Message:
-----------
BaseTools: VOID* PCDs in VPD region must be aligned based on value type

Base on build spec update, ASCII strings(?\226?\128?\156string?\226?\128?\157), 
will be byte aligned,
Unicode strings(L?\226?\128?\157string?\226?\128?\157) 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 <[email protected]>
Reviewed-by: Liming Gao <[email protected]>

Modified Paths:
--------------
    trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py

Modified: trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py       2016-01-18 
01:42:20 UTC (rev 19649)
+++ trunk/edk2/BaseTools/Source/Python/AutoGen/AutoGen.py       2016-01-18 
01:46:25 UTC (rev 19650)
@@ -317,6 +317,11 @@
             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 @@
                     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 @@
 #                                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 


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to