]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
1) Change the schema type for <VariableGuid> used in PCD HiiEnable group in FPD file.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / action / CollectPCDAction.java
index 473247f847bf07d2e96a7a344cbd3989111841ca..dc60cc6eb75ae1d5e29cfaf68ce43e055bacfc4c 100644 (file)
@@ -21,6 +21,7 @@ import java.io.BufferedReader;
 import java.io.File;\r
 import java.io.FileReader;\r
 import java.io.IOException;\r
+import java.math.BigInteger;\r
 import java.util.ArrayList;\r
 import java.util.Collections;\r
 import java.util.Comparator;\r
@@ -33,8 +34,8 @@ import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;\r
 import org.tianocore.DynamicPcdBuildDefinitionsDocument;\r
 import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions;\r
-import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo;\r
 import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData;\r
+import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo;\r
 import org.tianocore.FrameworkModulesDocument;\r
 import org.tianocore.FrameworkPlatformDescriptionDocument;\r
 import org.tianocore.FrameworkPlatformDescriptionDocument.FrameworkPlatformDescription;\r
@@ -513,7 +514,7 @@ class LocalTokenNumberTable {
 \r
         str =  String.format(PcdDatabase.offsetOfStrTemplate, phase, token.hasDefaultValue() ? "Init" : "Uninit", token.getPrimaryKeyString());\r
 \r
-        if (token.isStringType()) {\r
+        if (token.isUnicodeStringType()) {\r
             str += " | PCD_TYPE_STRING";\r
         }\r
 \r
@@ -732,7 +733,7 @@ class PcdDatabase {
             return 4;\r
         }\r
 \r
-        if (token.isStringType()) {\r
+        if (token.isUnicodeStringType()) {\r
             return 2;\r
         }\r
 \r
@@ -964,7 +965,7 @@ class PcdDatabase {
                 } else if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {\r
                     decl.add(getVpdEnableTypeDeclaration(token));\r
                     inst.add(getVpdEnableTypeInstantiation(token));\r
-                } else if (token.isStringType()) {\r
+                } else if (token.isUnicodeStringType()) {\r
                     decl.add(getStringTypeDeclaration(token));\r
                     inst.add(getStringTypeInstantiation(stringTable.add(token.getStringTypeString(), token), token));\r
                 }\r
@@ -1529,9 +1530,22 @@ public class CollectPCDAction {
                 pcdType      = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString());\r
                 datumType    = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString());\r
                 tokenNumber  = Integer.decode(pcdBuildData.getToken().toString());\r
-                datum        = pcdBuildData.getValue();\r
+                if (pcdBuildData.getValue() != null) {\r
+                    datum = pcdBuildData.getValue().toString();\r
+                } else {\r
+                    datum = null;\r
+                }\r
                 maxDatumSize = pcdBuildData.getMaxDatumSize();\r
 \r
+                if ((pcdType    == Token.PCD_TYPE.FEATURE_FLAG) &&\r
+                    (datumType  != Token.DATUM_TYPE.BOOLEAN)){\r
+                    exceptionString = String.format("[FPD file error] For PCD %s in module %s, the PCD type is FEATRUE_FLAG but "+\r
+                                                    "datum type of this PCD entry is not BOOLEAN!",\r
+                                                    pcdBuildData.getCName(),\r
+                                                    moduleName);\r
+                    throw new EntityException(exceptionString);\r
+                }\r
+\r
                 //\r
                 // Check <TokenSpaceGuid> is exist? In future, because all schema verification will tools\r
                 // will check that, following checking code could be removed.\r
@@ -1562,10 +1576,11 @@ public class CollectPCDAction {
                      //\r
                      // Check whether the datum size is matched datum type.\r
                      // \r
-                     if ((exceptionString = verifyDatumSize(pcdBuildData.getCName(), \r
-                                                            moduleName,\r
-                                                            maxDatumSize, \r
-                                                            datumType)) != null) {\r
+                     if ((exceptionString = verifyDatum(pcdBuildData.getCName(), \r
+                                                        moduleName,\r
+                                                        datum,\r
+                                                        datumType,\r
+                                                        maxDatumSize)) != null) {\r
                          throw new EntityException(exceptionString);\r
                      }\r
                 }\r
@@ -1701,6 +1716,331 @@ public class CollectPCDAction {
         }\r
     }\r
 \r
+    /**\r
+       Verify the datum value according its datum size and datum type, this\r
+       function maybe moved to FPD verification tools in future.\r
+       \r
+       @param cName\r
+       @param moduleName\r
+       @param datum\r
+       @param datumType\r
+       @param maxDatumSize\r
+       \r
+       @return String\r
+     */\r
+    /***/\r
+    public String verifyDatum(String            cName,\r
+                              String            moduleName,\r
+                              String            datum, \r
+                              Token.DATUM_TYPE  datumType, \r
+                              int               maxDatumSize) {\r
+        String      exceptionString = null;\r
+        int         value;\r
+        BigInteger  value64;\r
+        String      subStr;\r
+        int         index;\r
+\r
+        if (moduleName == null) {\r
+            moduleName = "section <DynamicPcdBuildDefinitions>";\r
+        } else {\r
+            moduleName = "module " + moduleName;\r
+        }\r
+\r
+        if (maxDatumSize == 0) {\r
+            exceptionString = String.format("[FPD file error] You maybe miss <MaxDatumSize> for PCD %s in %s",\r
+                                            cName,\r
+                                            moduleName);\r
+            return exceptionString;\r
+        }\r
+\r
+        switch (datumType) {\r
+        case UINT8:\r
+            if (maxDatumSize != 1) {\r
+                exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+\r
+                                                "is UINT8, but datum size is %d, they are not matched!",\r
+                                                 cName,\r
+                                                 moduleName,\r
+                                                 maxDatumSize);\r
+                return exceptionString;\r
+            }\r
+\r
+            if (datum != null) {\r
+                try {\r
+                    value = Integer.decode(datum);\r
+                } catch (NumberFormatException nfeExp) {\r
+                    exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is not valid "+\r
+                                                    "digital format of UINT8",\r
+                                                    cName,\r
+                                                    moduleName);\r
+                    return exceptionString;\r
+                }\r
+                if (value > 0xFF) {\r
+                    exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is %s exceed"+\r
+                                                    " the max size of UINT8 - 0xFF",\r
+                                                    cName, \r
+                                                    moduleName,\r
+                                                    datum);\r
+                    return exceptionString;\r
+                }\r
+            }\r
+            break;\r
+        case UINT16:\r
+            if (maxDatumSize != 2) {\r
+                exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+\r
+                                                "is UINT16, but datum size is %d, they are not matched!",\r
+                                                 cName,\r
+                                                 moduleName,\r
+                                                 maxDatumSize);\r
+                return exceptionString;\r
+            }\r
+            if (datum != null) {\r
+                try {\r
+                    value = Integer.decode(datum);\r
+                } catch (NumberFormatException nfeExp) {\r
+                    exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is "+\r
+                                                    "not valid digital of UINT16",\r
+                                                    cName,\r
+                                                    moduleName);\r
+                    return exceptionString;\r
+                }\r
+                if (value > 0xFFFF) {\r
+                    exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is %s "+\r
+                                                    "which exceed the range of UINT16 - 0xFFFF",\r
+                                                    cName, \r
+                                                    moduleName,\r
+                                                    datum);\r
+                    return exceptionString;\r
+                }\r
+            }\r
+            break;\r
+        case UINT32:\r
+            if (maxDatumSize != 4) {\r
+                exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+\r
+                                                "is UINT32, but datum size is %d, they are not matched!",\r
+                                                 cName,\r
+                                                 moduleName,\r
+                                                 maxDatumSize);\r
+                return exceptionString;\r
+            }\r
+\r
+            if (datum != null) {\r
+                try {\r
+                    if (datum.length() > 2) {\r
+                        if ((datum.charAt(0) == '0')        && \r
+                            ((datum.charAt(1) == 'x') || (datum.charAt(1) == 'X'))){\r
+                            subStr = datum.substring(2, datum.length());\r
+                            value64 = new BigInteger(subStr, 16);\r
+                        } else {\r
+                            value64 = new BigInteger(datum);\r
+                        }\r
+                    } else {\r
+                        value64 = new BigInteger(datum);\r
+                    }\r
+                } catch (NumberFormatException nfeExp) {\r
+                    exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is not "+\r
+                                                    "valid digital of UINT32",\r
+                                                    cName,\r
+                                                    moduleName);\r
+                    return exceptionString;\r
+                }\r
+\r
+                if (value64.bitLength() > 32) {\r
+                    exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is %s which "+\r
+                                                    "exceed the range of UINT32 - 0xFFFFFFFF",\r
+                                                    cName, \r
+                                                    moduleName,\r
+                                                    datum);\r
+                    return exceptionString;\r
+                }\r
+            }\r
+            break;\r
+        case UINT64:\r
+            if (maxDatumSize != 8) {\r
+                exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+\r
+                                                "is UINT64, but datum size is %d, they are not matched!",\r
+                                                 cName,\r
+                                                 moduleName,\r
+                                                 maxDatumSize);\r
+                return exceptionString;\r
+            }\r
+\r
+            if (datum != null) {\r
+                try {\r
+                    if (datum.length() > 2) {\r
+                        if ((datum.charAt(0) == '0')        && \r
+                            ((datum.charAt(1) == 'x') || (datum.charAt(1) == 'X'))){\r
+                            subStr = datum.substring(2, datum.length());\r
+                            value64 = new BigInteger(subStr, 16);\r
+                        } else {\r
+                            value64 = new BigInteger(datum);\r
+                        }\r
+                    } else {\r
+                        value64 = new BigInteger(datum);\r
+                    }\r
+                } catch (NumberFormatException nfeExp) {\r
+                    exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is not valid"+\r
+                                                    " digital of UINT64",\r
+                                                    cName,\r
+                                                    moduleName);\r
+                    return exceptionString;\r
+                }\r
+\r
+                if (value64.bitLength() > 64) {\r
+                    exceptionString = String.format("[FPD file error] The datum for PCD %s in %s is %s "+\r
+                                                    "exceed the range of UINT64 - 0xFFFFFFFFFFFFFFFF",\r
+                                                    cName, \r
+                                                    moduleName,\r
+                                                    datum);\r
+                    return exceptionString;\r
+                }\r
+            }\r
+            break;\r
+        case BOOLEAN:\r
+            if (maxDatumSize != 1) {\r
+                exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+\r
+                                                "is BOOLEAN, but datum size is %d, they are not matched!",\r
+                                                 cName,\r
+                                                 moduleName,\r
+                                                 maxDatumSize);\r
+                return exceptionString;\r
+            }\r
+\r
+            if (datum != null) {\r
+                if (!(datum.equalsIgnoreCase("TRUE") ||\r
+                     datum.equalsIgnoreCase("FALSE"))) {\r
+                    exceptionString = String.format("[FPD file error] The datum type of PCD data %s in %s "+\r
+                                                    "is BOOELAN, but value is not 'true'/'TRUE' or 'FALSE'/'false'",\r
+                                                    cName,\r
+                                                    moduleName);\r
+                    return exceptionString;\r
+                }\r
+\r
+            }\r
+            break;\r
+        case POINTER:\r
+            if (datum == null) {\r
+                break;\r
+            }\r
+\r
+            char    ch     = datum.charAt(0);\r
+            int     start, end;\r
+            String  strValue;\r
+            //\r
+            // For void* type PCD, only three datum is support:\r
+            // 1) Unicode: string with start char is "L"\r
+            // 2) Ansci: String start char is ""\r
+            // 3) byte array: String start char "{"\r
+            // \r
+            if (ch == 'L') {\r
+                start       = datum.indexOf('\"');\r
+                end         = datum.lastIndexOf('\"');\r
+                if ((start > end)           || \r
+                    (end   > datum.length())||\r
+                    ((start == end) && (datum.length() > 0))) {\r
+                    exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID* and datum is "+\r
+                                                    "a UNICODE string because start with L\", but format maybe"+\r
+                                                    "is not right, correct UNICODE string is L\"...\"!",\r
+                                                    cName,\r
+                                                    moduleName);\r
+                    return exceptionString;\r
+                }\r
+\r
+                strValue    = datum.substring(start + 1, end);\r
+                if ((strValue.length() * 2) > maxDatumSize) {\r
+                    exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is "+\r
+                                                    "a UNICODE string, but the datum size is %d exceed to <MaxDatumSize> : %d",\r
+                                                    cName,\r
+                                                    moduleName,\r
+                                                    strValue.length() * 2, \r
+                                                    maxDatumSize);\r
+                    return exceptionString;\r
+                }\r
+            } else if (ch == '\"'){\r
+                start       = datum.indexOf('\"');\r
+                end         = datum.lastIndexOf('\"');\r
+                if ((start > end)           || \r
+                    (end   > datum.length())||\r
+                    ((start == end) && (datum.length() > 0))) {\r
+                    exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID* and datum is "+\r
+                                                    "a ANSCII string because start with \", but format maybe"+\r
+                                                    "is not right, correct ANSIC string is \"...\"!",\r
+                                                    cName,\r
+                                                    moduleName);\r
+                    return exceptionString;\r
+                }\r
+                strValue    = datum.substring(start + 1, end);\r
+                if ((strValue.length()) > maxDatumSize) {\r
+                    exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is "+\r
+                                                    "a ANSCI string, but the datum size is %d which exceed to <MaxDatumSize> : %d",\r
+                                                    cName,\r
+                                                    moduleName,\r
+                                                    strValue.length(),\r
+                                                    maxDatumSize);\r
+                    return exceptionString;\r
+                }\r
+            } else if (ch =='{') {\r
+                String[]  strValueArray;\r
+\r
+                start           = datum.indexOf('{');\r
+                end             = datum.lastIndexOf('}');\r
+                strValue        = datum.substring(start + 1, end);\r
+                strValue        = strValue.trim();\r
+                if (strValue.length() == 0) {\r
+                    break;\r
+                }\r
+                strValueArray   = strValue.split(",");\r
+                for (index = 0; index < strValueArray.length; index ++) {\r
+                    try{\r
+                        value = Integer.decode(strValueArray[index].trim());\r
+                    } catch (NumberFormatException nfeEx) {\r
+                        exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and "+\r
+                                                         "it is byte array in fact. For every byte in array should be a valid"+\r
+                                                         "byte digital, but element %s is not a valid byte digital!",\r
+                                                         cName,\r
+                                                         moduleName,\r
+                                                         strValueArray[index]);\r
+                        return exceptionString;\r
+                    }\r
+                    if (value > 0xFF) {\r
+                        exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, "+\r
+                                                        "it is byte array in fact. But the element of %s exceed the byte range",\r
+                                                        cName,\r
+                                                        moduleName,\r
+                                                        strValueArray[index]);\r
+                        return exceptionString;\r
+                    }\r
+                }\r
+\r
+                if (strValueArray.length > maxDatumSize) {\r
+                    exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is byte"+\r
+                                                    "array, but the number of bytes is %d which exceed to <MaxDatumSzie> : %d!",\r
+                                                    cName,\r
+                                                    moduleName,\r
+                                                    strValueArray.length,\r
+                                                    maxDatumSize);\r
+                    return exceptionString;\r
+                }\r
+            } else {\r
+                exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+\r
+                                                "1) UNICODE string: like L\"xxxx\";\r\n"+\r
+                                                "2) ANSIC string: like \"xxx\";\r\n"+\r
+                                                "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+\r
+                                                "But the datum in seems does not following above format!",\r
+                                                cName, \r
+                                                moduleName);\r
+                return exceptionString;\r
+            }\r
+            break;\r
+        default:\r
+            exceptionString = String.format("[FPD file error] For PCD entry %s in %s, datum type is unknown, it should be one of "+\r
+                                            "UINT8, UINT16, UINT32, UINT64, VOID*, BOOLEAN",\r
+                                            cName,\r
+                                            moduleName);\r
+            return exceptionString;\r
+        }\r
+        return null;\r
+    }\r
+\r
     /**\r
        Get dynamic information for a dynamic PCD from <DynamicPcdBuildDefinition> seciton in FPD file.\r
        \r
@@ -1765,81 +2105,6 @@ public class CollectPCDAction {
         return null;\r
     }\r
 \r
-    /**\r
-       Verify the maxDatumSize for a PCD data is matched to Datum type.\r
-       \r
-       @param token             The token instance\r
-       @param moduleName        The module name who use this PCD data.\r
-       @param maxDatumSize      The value of max datum size in FPD file\r
-       @param datumType         The datum type\r
-       \r
-       @return String           if is unmatched, set the exception information\r
-                                as return value, otherwice is null.\r
-    **/\r
-    private String verifyDatumSize(String           cName, \r
-                                   String           moduleName,\r
-                                   int              maxDatumSize, \r
-                                   Token.DATUM_TYPE datumType) {\r
-        String exceptionString = null;\r
-\r
-        if (maxDatumSize == 0) {\r
-            exceptionString = String.format("[FPD file error] You maybe miss <MaxDatumSize> for PCD %s in module %s",\r
-                                            cName,\r
-                                            moduleName);\r
-            return exceptionString;\r
-        }\r
-\r
-        switch (datumType) {\r
-        case UINT8:\r
-            if (maxDatumSize != 1) {\r
-                exceptionString = String.format("[FPD file error] The datum type of PCD data %s in module %s "+\r
-                                                "is UINT8, but datum size is %d, they are not matched!",\r
-                                                cName,\r
-                                                moduleName,\r
-                                                maxDatumSize);\r
-            }\r
-            break;\r
-        case UINT16:\r
-            if (maxDatumSize != 2) {\r
-                exceptionString = String.format("[FPD file error] The datum type of PCD data %s in module %s "+\r
-                                                "is UINT16, but datum size is %d, they are not matched!",\r
-                                                cName,\r
-                                                moduleName,\r
-                                                maxDatumSize);\r
-            }\r
-            break;\r
-        case UINT32:\r
-            if (maxDatumSize != 4) {\r
-                exceptionString = String.format("[FPD file error] the datum type of PCD data %s in module %s "+\r
-                                                "is UINT32, but datum size is %d, they are not matched!",\r
-                                                cName,\r
-                                                moduleName,\r
-                                                maxDatumSize);\r
-            }\r
-            break;\r
-        case UINT64:\r
-            if (maxDatumSize != 8) {\r
-                exceptionString = String.format("[FPD file error] the datum type of PCD data %s in module %s "+\r
-                                                "is UINT64, but datum size is %d, they are not matched!",\r
-                                                cName,\r
-                                                moduleName,\r
-                                                maxDatumSize);\r
-            }\r
-            break;\r
-        case BOOLEAN:\r
-            if (maxDatumSize != 1) {\r
-                exceptionString = String.format("[FPD file error] the datum type of PCD data %s in module %s "+\r
-                                                "is BOOLEAN, but datum size is %d, they are not matched!",\r
-                                                cName,\r
-                                                moduleName,\r
-                                                maxDatumSize);\r
-            }\r
-            break;\r
-        }\r
-\r
-        return exceptionString;\r
-    }\r
-\r
     /**\r
        Update dynamic information for PCD entry.\r
        \r
@@ -1865,6 +2130,10 @@ public class CollectPCDAction {
         SkuInstance         skuInstance     = null;\r
         String              temp;\r
         boolean             hasSkuId0       = false;\r
+        Token.PCD_TYPE      pcdType         = Token.PCD_TYPE.UNKNOWN;\r
+        int                 tokenNumber     = 0;\r
+        String              hiiDefaultValue = null;\r
+        String[]            variableGuidString = null;\r
 \r
         List<DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo>   skuInfoList = null;\r
         DynamicPcdBuildDefinitions.PcdBuildData                 dynamicInfo = null;\r
@@ -1881,7 +2150,11 @@ public class CollectPCDAction {
 \r
         token.datumSize = dynamicInfo.getMaxDatumSize();\r
 \r
-        exceptionString = verifyDatumSize(token.cName, moduleName, token.datumSize, token.datumType);\r
+        exceptionString = verifyDatum(token.cName, \r
+                                      moduleName,\r
+                                      null, \r
+                                      token.datumType, \r
+                                      token.datumSize);\r
         if (exceptionString != null) {\r
             throw new EntityException(exceptionString);\r
         }\r
@@ -1896,6 +2169,21 @@ public class CollectPCDAction {
                                             dynamicInfo.getMaxDatumSize());\r
             throw new EntityException(exceptionString);\r
         }\r
+        tokenNumber = Integer.decode(dynamicInfo.getToken().toString());\r
+        if (tokenNumber != token.tokenNumber) {\r
+            exceptionString = String.format("[FPD file error] For dynamic PCD %s, the token number in module %s is 0x%x, but"+\r
+                                            "in <DynamicPcdBuildDefinictions>, the token number is 0x%x, they are not match!",\r
+                                            token.cName,\r
+                                            moduleName,\r
+                                            token.tokenNumber,\r
+                                            tokenNumber);\r
+            throw new EntityException(exceptionString);\r
+        }\r
+\r
+        pcdType = Token.getpcdTypeFromString(dynamicInfo.getItemType().toString());\r
+        if (pcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
+            token.dynamicExTokenNumber = tokenNumber;\r
+        }\r
 \r
         skuInfoList = dynamicInfo.getSkuInfoList();\r
 \r
@@ -1916,7 +2204,15 @@ public class CollectPCDAction {
             // Judge whether is DefaultGroup at first, because most case is DefautlGroup.\r
             // \r
             if (skuInfoList.get(index).getValue() != null) {\r
-                skuInstance.value.setValue(skuInfoList.get(index).getValue());\r
+                skuInstance.value.setValue(skuInfoList.get(index).getValue().toString());\r
+                if ((exceptionString = verifyDatum(token.cName, \r
+                                                   null, \r
+                                                   skuInfoList.get(index).getValue().toString(), \r
+                                                   token.datumType, \r
+                                                   token.datumSize)) != null) {\r
+                    throw new EntityException(exceptionString);\r
+                }\r
+\r
                 token.skuData.add(skuInstance);\r
 \r
                 //\r
@@ -1925,8 +2221,8 @@ public class CollectPCDAction {
                 // \r
                 if (datum != null) {\r
                     if ((skuInstance.id == 0)                                   &&\r
-                        !datum.equalsIgnoreCase(skuInfoList.get(index).getValue())) {\r
-                        exceptionString = "[FPD file error] For dynamic PCD " + token.cName + ", the value in module is " + datum.toString() + " but the "+\r
+                        !datum.toString().equalsIgnoreCase(skuInfoList.get(index).getValue().toString())) {\r
+                        exceptionString = "[FPD file error] For dynamic PCD " + token.cName + ", the value in module " + moduleName + " is " + datum.toString() + " but the "+\r
                                           "value of sku 0 data in <DynamicPcdBuildDefinition> is " + skuInstance.value.value + ". They are must be same!"+\r
                                           " or you could not define value for a dynamic PCD in every <ModuleSA>!"; \r
                         throw new EntityException(exceptionString);\r
@@ -1945,7 +2241,9 @@ public class CollectPCDAction {
                                                     "file, who use HII, but there is no <VariableGuid> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
-                                                    \r
+                    if (exceptionString != null) {\r
+                        throw new EntityException(exceptionString);\r
+                    }                                                    \r
                 }\r
 \r
                 if (skuInfoList.get(index).getVariableOffset() == null) {\r
@@ -1953,6 +2251,9 @@ public class CollectPCDAction {
                                                     "file, who use HII, but there is no <VariableOffset> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
+                    if (exceptionString != null) {\r
+                        throw new EntityException(exceptionString);\r
+                    }\r
                 }\r
 \r
                 if (skuInfoList.get(index).getHiiDefaultValue() == null) {\r
@@ -1960,11 +2261,25 @@ public class CollectPCDAction {
                                                     "file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
+                    if (exceptionString != null) {\r
+                        throw new EntityException(exceptionString);\r
+                    }\r
+                }\r
+\r
+                if (skuInfoList.get(index).getHiiDefaultValue() != null) {\r
+                    hiiDefaultValue = skuInfoList.get(index).getHiiDefaultValue().toString();\r
+                } else {\r
+                    hiiDefaultValue = null;\r
                 }\r
 \r
-                if (exceptionString != null) {\r
+                if ((exceptionString = verifyDatum(token.cName, \r
+                                                   null, \r
+                                                   hiiDefaultValue, \r
+                                                   token.datumType, \r
+                                                   token.datumSize)) != null) {\r
                     throw new EntityException(exceptionString);\r
                 }\r
+\r
                 offset = Integer.decode(skuInfoList.get(index).getVariableOffset());\r
                 if (offset > 0xFFFF) {\r
                     throw new EntityException(String.format("[FPD file error] For dynamic PCD %s ,  the variable offset defined in sku %d data "+\r
@@ -1973,10 +2288,20 @@ public class CollectPCDAction {
                                                             index));\r
                 }\r
 \r
+                //\r
+                // Get variable guid string according to the name of guid which will be mapped into a GUID in SPD file.\r
+                // \r
+                variableGuidString = GlobalData.getGuidInfoGuid(skuInfoList.get(index).getVariableGuid().toString());\r
+                if (variableGuidString == null) {\r
+                    throw new EntityException(String.format("[GUID Error] For dynamic PCD %s,  the variable guid %s can be found in all SPD file!",\r
+                                                            token.cName, \r
+                                                            skuInfoList.get(index).getVariableGuid().toString()));\r
+                }\r
+\r
                 skuInstance.value.setHiiData(skuInfoList.get(index).getVariableName(),\r
-                                             translateSchemaStringToUUID(skuInfoList.get(index).getVariableGuid().toString()),\r
+                                             translateSchemaStringToUUID(variableGuidString[1]),\r
                                              skuInfoList.get(index).getVariableOffset(),\r
-                                             skuInfoList.get(index).getHiiDefaultValue());\r
+                                             skuInfoList.get(index).getHiiDefaultValue().toString());\r
                 token.skuData.add(skuInstance);\r
                 continue;\r
             }\r
@@ -2040,6 +2365,9 @@ public class CollectPCDAction {
             return new UUID(0, 0);\r
         }\r
 \r
+        uuidString = uuidString.replaceAll("\\{", "");\r
+        uuidString = uuidString.replaceAll("\\}", "");\r
+\r
         //\r
         // If the UUID schema string is GuidArrayType type then need translate \r
         // to GuidNamingConvention type at first.\r