]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/BPDG/GenVpd.py
BaseTools: Enhance BaseTools supports FixedAtBuild usage in VFR file
[mirror_edk2.git] / BaseTools / Source / Python / BPDG / GenVpd.py
index ee7e04295f1245afb0f0e0e50a3a6662cb629204..4ff464756f20dca1a9dff95ca6af7034356db632 100644 (file)
@@ -2,7 +2,7 @@
 #  This file include GenVpd class for fix the Vpd type PCD offset, and PcdEntry for describe\r
 #  and process each entry of vpd type PCD.\r
 #\r
-#  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -409,20 +409,6 @@ class GenVPD :
                 #\r
                 PCD.PcdUnpackValue    =  str(PCD.PcdValue)\r
 \r
-                #\r
-                # If value is Unicode string (e.g. L""), then use 2-byte alignment\r
-                # If value is byte array (e.g. {}), then use 8-byte alignment\r
-                #\r
-                PCD.PcdOccupySize     =  int(PCD.PcdSize)\r
-                if PCD.PcdUnpackValue.startswith("{"):\r
-                    Alignment = 8\r
-                elif PCD.PcdUnpackValue.startswith("L"):\r
-                    Alignment = 2\r
-                else:\r
-                    Alignment = 1\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
                 PackSize = None\r
@@ -436,6 +422,28 @@ class GenVPD :
                     except:\r
                         EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid PCD size value %s at file: %s line: %s" % (PCD.PcdSize, self.InputFileName, PCD.Lineno))\r
 \r
+                #\r
+                # If value is Unicode string (e.g. L""), then use 2-byte alignment\r
+                # If value is byte array (e.g. {}), then use 8-byte alignment\r
+                #\r
+                PCD.PcdOccupySize = PCD.PcdBinSize\r
+                if PCD.PcdUnpackValue.startswith("{"):\r
+                    Alignment = 8\r
+                elif PCD.PcdUnpackValue.startswith("L"):\r
+                    Alignment = 2\r
+                else:\r
+                    Alignment = 1\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
                 if PCD._IsBoolean(PCD.PcdValue, PCD.PcdSize):\r
                     PCD._PackBooleanValue(PCD.PcdValue)\r
                     self.FileLinesList[count] = PCD\r