BaseTools: report warning if VOID* PCD with {} value is not 8-byte aligned
authorYonghong Zhu <yonghong.zhu@intel.com>
Wed, 9 Mar 2016 06:03:39 +0000 (14:03 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Thu, 10 Mar 2016 09:39:58 +0000 (17:39 +0800)
For VOID* Pcd with {} value, If platform developer wants to put in a
specific hex offset value that is not 8-byte aligned for VOID * then we
allow it with a warning message.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/BPDG/GenVpd.py

index 776743a710726e32ce5c02c19bb537adebbe9cbb..05ce72bd914e53091d5dd162a834faac45146002 100644 (file)
@@ -1162,7 +1162,10 @@ class PlatformAutoGen(AutoGen):
                                 except:\r
                                     EdkLogger.error("build", FORMAT_INVALID, "Invalid offset value %s for PCD %s.%s." % (Sku.VpdOffset, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
                             if VpdOffset % Alignment != 0:\r
-                                EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Alignment))\r
+                                if PcdValue.startswith("{"):\r
+                                    EdkLogger.warn("build", "The offset value of PCD %s.%s is not 8-byte aligned!" %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName), File=self.MetaFile)\r
+                                else:\r
+                                    EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Alignment))\r
                         VpdFile.Add(Pcd, Sku.VpdOffset)\r
                         # if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
                         if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
@@ -1235,7 +1238,10 @@ class PlatformAutoGen(AutoGen):
                                         except:\r
                                             EdkLogger.error("build", FORMAT_INVALID, "Invalid offset value %s for PCD %s.%s." % (Sku.VpdOffset, DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName))\r
                                     if VpdOffset % Alignment != 0:\r
-                                        EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, Alignment))\r
+                                        if PcdValue.startswith("{"):\r
+                                            EdkLogger.warn("build", "The offset value of PCD %s.%s is not 8-byte aligned!" %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName), File=self.MetaFile)\r
+                                        else:\r
+                                            EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, Alignment))\r
                                 VpdFile.Add(DscPcdEntry, Sku.VpdOffset)\r
                                 if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
                                     NeedProcessVpdMapFile = True \r
index ee7e04295f1245afb0f0e0e50a3a6662cb629204..003011b709b16d6a0622f7621d4280c372109cd6 100644 (file)
@@ -420,8 +420,16 @@ class GenVPD :
                     Alignment = 2\r
                 else:\r
                     Alignment = 1\r
-                if PCD.PcdOccupySize % Alignment != 0:\r
-                    PCD.PcdOccupySize = (PCD.PcdOccupySize / Alignment + 1) * Alignment\r
+\r
+                if PCD.PcdOffset != '*':\r
+                    if PCD.PcdOccupySize % Alignment != 0:\r
+                        if PCD.PcdUnpackValue.startswith("{"):\r
+                            EdkLogger.warn("BPDG", "The offset value of PCD %s is not 8-byte aligned!" %(PCD.PcdCName), File=self.InputFileName)\r
+                        else:\r
+                            EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, 'The offset value of PCD %s should be %s-byte aligned.' % (PCD.PcdCName, Alignment))\r
+                else:\r
+                    if PCD.PcdOccupySize % Alignment != 0:\r
+                        PCD.PcdOccupySize = (PCD.PcdOccupySize / Alignment + 1) * Alignment\r
 \r
                 #\r
                 # Translate PCD size string to an integer value.\r