]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix some bugs in PCD tools:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 13 Jun 2006 09:40:16 +0000 (09:40 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 13 Jun 2006 09:40:16 +0000 (09:40 +0000)
1) Normalize the exception text format,
2) Add throw exception in some special case.
3) Add more code to verify Datum Size.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@497 6f19259b-4bc3-4df7-8a09-765794883524

EdkNt32Pkg/Nt32.fpd
Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java

index e041ef53d502568f89f9e9269998bbd43fa6b6a5..8bee2a078275cb7842eef2d20d1723263cefec49 100644 (file)
       <C_Name>PcdWinNtSerialPort</C_Name>\r
       <Token>0x00001002</Token>\r
       <DatumType>VOID*</DatumType>\r
       <C_Name>PcdWinNtSerialPort</C_Name>\r
       <Token>0x00001002</Token>\r
       <DatumType>VOID*</DatumType>\r
-      <MaxDatumSize>20</MaxDatumSize>\r
+      <MaxDatumSize>18</MaxDatumSize>\r
       <SkuInfo>\r
         <SkuId>0</SkuId>\r
         <Value>L"COM1!COM2"</Value>\r
       <SkuInfo>\r
         <SkuId>0</SkuId>\r
         <Value>L"COM1!COM2"</Value>\r
index 1e3de2a4e6c467c8be0ae55d938a9156bc62544f..011e13de527af8a867d0d7b7f3dfc8a5809e32f9 100644 (file)
@@ -783,20 +783,24 @@ public class FpdParserTask extends Task {
     }\r
 \r
     public void collectPCDInformation() {\r
     }\r
 \r
     public void collectPCDInformation() {\r
-      CollectPCDAction collectAction = new CollectPCDAction ();\r
-      //\r
-      // Collect all PCD information from FPD to MSA, and get help information from SPD.\r
-      // These all information will be stored into memory database for future usage such \r
-      // as autogen.\r
-      //\r
-      try {\r
-        collectAction.perform (\r
-          getProject().getProperty("WORKSPACE_DIR"),\r
-          fpdFilename.getPath(),\r
-          ActionMessage.MAX_MESSAGE_LEVEL\r
-          );\r
-      } catch (Exception exp) {\r
-        throw new BuildException (String.format("Fail to do PCD preprocess from FPD file,  the cause is %s", exp.getMessage()));\r
-      }\r
+        String           exceptionString = null;\r
+        CollectPCDAction collectAction   = new CollectPCDAction ();\r
+        //\r
+        // Collect all PCD information from FPD to MSA, and get help information from SPD.\r
+        // These all information will be stored into memory database for future usage such \r
+        // as autogen.\r
+        //\r
+        try {\r
+            collectAction.perform (getProject().getProperty("WORKSPACE_DIR"),\r
+                                   fpdFilename.getPath(),\r
+                                   ActionMessage.MAX_MESSAGE_LEVEL\r
+                                   );\r
+        } catch (Exception exp) {\r
+            exceptionString = exp.getMessage();\r
+            if (exceptionString == null) {\r
+                exceptionString = "[Internal Error]Pcd tools catch a internel errors, Please report this bug into TianoCore or send email to Wang, scott or Lu, ken!";\r
+            }\r
+            throw new BuildException (String.format("Fail to do PCD preprocess from FPD file: %s", exceptionString));\r
+        }\r
     }\r
 }\r
     }\r
 }\r
index 4057c417e44783e1e10771b860ae36766d101673..fe09be2b9ab136c8297cf413a8cba2c0431a322a 100644 (file)
@@ -1469,7 +1469,7 @@ public class CollectPCDAction {
         modules = getComponentsFromFPD();\r
 \r
         if (modules == null) {\r
         modules = getComponentsFromFPD();\r
 \r
         if (modules == null) {\r
-            throw new EntityException("No modules in FPD file, Please check whether there are elements in <FrameworkModules> in FPD file!");\r
+            throw new EntityException("[FPD file error] No modules in FPD file, Please check whether there are elements in <FrameworkModules> in FPD file!");\r
         }\r
 \r
         //\r
         }\r
 \r
         //\r
@@ -1542,7 +1542,7 @@ public class CollectPCDAction {
                      // Value is required.\r
                      // \r
                      if (datum == null) {\r
                      // Value is required.\r
                      // \r
                      if (datum == null) {\r
-                         exceptionString = String.format("There is no value for PCD entry %s in module %s!",\r
+                         exceptionString = String.format("[FPD file error] There is no value for PCD entry %s in module %s!",\r
                                                          pcdBuildData.getCName(),\r
                                                          moduleName);\r
                          throw new EntityException(exceptionString);\r
                                                          pcdBuildData.getCName(),\r
                                                          moduleName);\r
                          throw new EntityException(exceptionString);\r
@@ -1576,7 +1576,7 @@ public class CollectPCDAction {
                     // modules.\r
                     // \r
                     if (token.datumType != datumType) {\r
                     // modules.\r
                     // \r
                     if (token.datumType != datumType) {\r
-                        exceptionString = String.format("The datum type of PCD entry %s is %s, which is different with  %s defined in before!",\r
+                        exceptionString = String.format("[FPD file error] The datum type of PCD entry %s is %s, which is different with  %s defined in before!",\r
                                                         pcdBuildData.getCName(), \r
                                                         pcdBuildData.getDatumType().toString(), \r
                                                         Token.getStringOfdatumType(token.datumType));\r
                                                         pcdBuildData.getCName(), \r
                                                         pcdBuildData.getDatumType().toString(), \r
                                                         Token.getStringOfdatumType(token.datumType));\r
@@ -1587,7 +1587,7 @@ public class CollectPCDAction {
                     // Check token number is valid\r
                     // \r
                     if (tokenNumber != token.tokenNumber) {\r
                     // Check token number is valid\r
                     // \r
                     if (tokenNumber != token.tokenNumber) {\r
-                        exceptionString = String.format("The token number of PCD entry %s in module %s is different with same PCD entry in other modules!",\r
+                        exceptionString = String.format("[FPD file error] The token number of PCD entry %s in module %s is different with same PCD entry in other modules!",\r
                                                         pcdBuildData.getCName(),\r
                                                         moduleName);\r
                         throw new EntityException(exceptionString);\r
                                                         pcdBuildData.getCName(),\r
                                                         moduleName);\r
                         throw new EntityException(exceptionString);\r
@@ -1597,7 +1597,7 @@ public class CollectPCDAction {
                     // For same PCD used in different modules, the PCD type should all be dynamic or non-dynamic.\r
                     // \r
                     if (token.isDynamicPCD != Token.isDynamic(pcdType)) {\r
                     // For same PCD used in different modules, the PCD type should all be dynamic or non-dynamic.\r
                     // \r
                     if (token.isDynamicPCD != Token.isDynamic(pcdType)) {\r
-                        exceptionString = String.format("For PCD entry %s in module %s, you define dynamic or non-dynamic PCD type which"+\r
+                        exceptionString = String.format("[FPD file error] For PCD entry %s in module %s, you define dynamic or non-dynamic PCD type which"+\r
                                                         "is different with others module's",\r
                                                         token.cName,\r
                                                         moduleName);\r
                                                         "is different with others module's",\r
                                                         token.cName,\r
                                                         moduleName);\r
@@ -1611,15 +1611,28 @@ public class CollectPCDAction {
                         // But if you write, the <Value> must be same as the value in <DynamicPcdBuildDefinitions>.\r
                         // \r
                         if (!token.isSkuEnable() && \r
                         // But if you write, the <Value> must be same as the value in <DynamicPcdBuildDefinitions>.\r
                         // \r
                         if (!token.isSkuEnable() && \r
-                            (token.skuData.get(0).value.type == DynamicTokenValue.VALUE_TYPE.DEFAULT_TYPE)) {\r
-                            if (!datum.equalsIgnoreCase(token.skuData.get(0).value.value)) {\r
-                                exceptionString = String.format("For dynamic PCD %s in module %s, the datum in <ModuleSA> is "+\r
+                            (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.DEFAULT_TYPE) &&\r
+                            (datum != null)) {\r
+                            if (!datum.equalsIgnoreCase(token.getDefaultSku().value)) {\r
+                                exceptionString = String.format("[FPD file error] For dynamic PCD %s in module %s, the datum in <ModuleSA> is "+\r
                                                                 "not equal to the datum in <DynamicPcdBuildDefinitions>, it is "+\r
                                                                 "not equal to the datum in <DynamicPcdBuildDefinitions>, it is "+\r
-                                                                "illega! You can choose no <Value> in <ModuleSA>!",\r
+                                                                "illega! You could no set <Value> in <ModuleSA> for a dynamic PCD!",\r
                                                                 token.cName,\r
                                                                 moduleName);\r
                                                                 token.cName,\r
                                                                 moduleName);\r
+                                throw new EntityException(exceptionString);\r
                             }\r
                         }\r
                             }\r
                         }\r
+\r
+                        if ((maxDatumSize != 0) &&\r
+                            (maxDatumSize != token.datumSize)){\r
+                            exceptionString = String.format("[FPD file error] For dynamic PCD %s in module %s, the max datum size is %d which "+\r
+                                                            "is different with <MaxDatumSize> %d defined in <DynamicPcdBuildDefinitions>!",\r
+                                                            token.cName,\r
+                                                            moduleName,\r
+                                                            maxDatumSize,\r
+                                                            token.datumSize);\r
+                            throw new EntityException(exceptionString);\r
+                        }\r
                     }\r
                     \r
                 } else {\r
                     }\r
                     \r
                 } else {\r
@@ -1712,7 +1725,7 @@ public class CollectPCDAction {
 \r
         dynamicPcdBuildDefinitions = fpdDocInstance.getFrameworkPlatformDescription().getDynamicPcdBuildDefinitions();\r
         if (dynamicPcdBuildDefinitions == null) {\r
 \r
         dynamicPcdBuildDefinitions = fpdDocInstance.getFrameworkPlatformDescription().getDynamicPcdBuildDefinitions();\r
         if (dynamicPcdBuildDefinitions == null) {\r
-            exceptionString = String.format("There are no <PcdDynamicBuildDescriptions> in FPD file but contains Dynamic type "+\r
+            exceptionString = String.format("[FPD file error] There are no <PcdDynamicBuildDescriptions> in FPD file but contains Dynamic type "+\r
                                             "PCD entry %s in module %s!",\r
                                             token.cName,\r
                                             moduleName);\r
                                             "PCD entry %s in module %s!",\r
                                             token.cName,\r
                                             moduleName);\r
@@ -1747,10 +1760,18 @@ public class CollectPCDAction {
                                    int              maxDatumSize, \r
                                    Token.DATUM_TYPE datumType) {\r
         String exceptionString = null;\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
         switch (datumType) {\r
         case UINT8:\r
             if (maxDatumSize != 1) {\r
-                exceptionString = String.format("In FPD file, the datum type of PCD data %s in module %s "+\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
                                                 "is UINT8, but datum size is %d, they are not matched!",\r
                                                 cName,\r
                                                 moduleName,\r
@@ -1759,7 +1780,7 @@ public class CollectPCDAction {
             break;\r
         case UINT16:\r
             if (maxDatumSize != 2) {\r
             break;\r
         case UINT16:\r
             if (maxDatumSize != 2) {\r
-                exceptionString = String.format("In FPD file, the datum type of PCD data %s in module %s "+\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
                                                 "is UINT16, but datum size is %d, they are not matched!",\r
                                                 cName,\r
                                                 moduleName,\r
@@ -1768,7 +1789,7 @@ public class CollectPCDAction {
             break;\r
         case UINT32:\r
             if (maxDatumSize != 4) {\r
             break;\r
         case UINT32:\r
             if (maxDatumSize != 4) {\r
-                exceptionString = String.format("In FPD file, the datum type of PCD data %s in module %s "+\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
                                                 "is UINT32, but datum size is %d, they are not matched!",\r
                                                 cName,\r
                                                 moduleName,\r
@@ -1777,7 +1798,7 @@ public class CollectPCDAction {
             break;\r
         case UINT64:\r
             if (maxDatumSize != 8) {\r
             break;\r
         case UINT64:\r
             if (maxDatumSize != 8) {\r
-                exceptionString = String.format("In FPD file, the datum type of PCD data %s in module %s "+\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
                                                 "is UINT64, but datum size is %d, they are not matched!",\r
                                                 cName,\r
                                                 moduleName,\r
@@ -1786,7 +1807,7 @@ public class CollectPCDAction {
             break;\r
         case BOOLEAN:\r
             if (maxDatumSize != 1) {\r
             break;\r
         case BOOLEAN:\r
             if (maxDatumSize != 1) {\r
-                exceptionString = String.format("In FPD file, the datum type of PCD data %s in module %s "+\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
                                                 "is BOOLEAN, but datum size is %d, they are not matched!",\r
                                                 cName,\r
                                                 moduleName,\r
@@ -1829,7 +1850,7 @@ public class CollectPCDAction {
 \r
         dynamicInfo = getDynamicInfoFromFPD(token, moduleName);\r
         if (dynamicInfo == null) {\r
 \r
         dynamicInfo = getDynamicInfoFromFPD(token, moduleName);\r
         if (dynamicInfo == null) {\r
-            exceptionString = String.format("For Dynamic PCD %s used by module %s, "+\r
+            exceptionString = String.format("[FPD file error] For Dynamic PCD %s used by module %s, "+\r
                                             "there is no dynamic information in <DynamicPcdBuildDefinitions> "+\r
                                             "in FPD file, but it is required!",\r
                                             token.cName,\r
                                             "there is no dynamic information in <DynamicPcdBuildDefinitions> "+\r
                                             "in FPD file, but it is required!",\r
                                             token.cName,\r
@@ -1837,6 +1858,24 @@ public class CollectPCDAction {
             throw new EntityException(exceptionString);\r
         }\r
 \r
             throw new EntityException(exceptionString);\r
         }\r
 \r
+        token.datumSize = dynamicInfo.getMaxDatumSize();\r
+\r
+        exceptionString = verifyDatumSize(token.cName, moduleName, token.datumSize, token.datumType);\r
+        if (exceptionString != null) {\r
+            throw new EntityException(exceptionString);\r
+        }\r
+\r
+        if ((maxDatumSize != 0) && \r
+            (maxDatumSize != token.datumSize)) {\r
+            exceptionString = String.format("FPD file error] For dynamic PCD %s, the datum size in module %s is %d, but "+\r
+                                            "the datum size in <DynamicPcdBuildDefinitions> is %d, they are not match!",\r
+                                            token.cName,\r
+                                            moduleName, \r
+                                            maxDatumSize,\r
+                                            dynamicInfo.getMaxDatumSize());\r
+            throw new EntityException(exceptionString);\r
+        }\r
+\r
         skuInfoList = dynamicInfo.getSkuInfoList();\r
 \r
         //\r
         skuInfoList = dynamicInfo.getSkuInfoList();\r
 \r
         //\r
@@ -1849,7 +1888,6 @@ public class CollectPCDAction {
             // \r
             temp = skuInfoList.get(index).getSkuId().toString();\r
             skuInstance.id = Integer.decode(temp);\r
             // \r
             temp = skuInfoList.get(index).getSkuId().toString();\r
             skuInstance.id = Integer.decode(temp);\r
-\r
             if (skuInstance.id == 0) {\r
                 hasSkuId0 = true;\r
             }\r
             if (skuInstance.id == 0) {\r
                 hasSkuId0 = true;\r
             }\r
@@ -1867,11 +1905,9 @@ public class CollectPCDAction {
                 if (datum != null) {\r
                     if ((skuInstance.id == 0)                                   &&\r
                         !datum.equalsIgnoreCase(skuInfoList.get(index).getValue())) {\r
                 if (datum != null) {\r
                     if ((skuInstance.id == 0)                                   &&\r
                         !datum.equalsIgnoreCase(skuInfoList.get(index).getValue())) {\r
-                        exceptionString = String.format("For dynamic PCD %s, module %s give <datum> as %s which is different with "+\r
-                                                        "Sku 0's <datum> %s defined in <DynamicPcdBuildDefinitions>! Please sync them at first!",\r
-                                                        token.cName,\r
-                                                        datum,\r
-                                                        skuInfoList.get(index).getValue());\r
+                        exceptionString = "[FPD file error] For dynamic PCD " + token.cName + ", the value in module 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
                     }\r
                 }\r
                         throw new EntityException(exceptionString);\r
                     }\r
                 }\r
@@ -1884,7 +1920,7 @@ public class CollectPCDAction {
             if (skuInfoList.get(index).getVariableName() != null) {\r
                 exceptionString = null;\r
                 if (skuInfoList.get(index).getVariableGuid() == null) {\r
             if (skuInfoList.get(index).getVariableName() != null) {\r
                 exceptionString = null;\r
                 if (skuInfoList.get(index).getVariableGuid() == null) {\r
-                    exceptionString = String.format("For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                    exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
                                                     "file, who use HII, but there is no <VariableGuid> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
                                                     "file, who use HII, but there is no <VariableGuid> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
@@ -1892,14 +1928,14 @@ public class CollectPCDAction {
                 }\r
 \r
                 if (skuInfoList.get(index).getVariableOffset() == null) {\r
                 }\r
 \r
                 if (skuInfoList.get(index).getVariableOffset() == null) {\r
-                    exceptionString = String.format("For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                    exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
                                                     "file, who use HII, but there is no <VariableOffset> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
                 }\r
 \r
                 if (skuInfoList.get(index).getHiiDefaultValue() == null) {\r
                                                     "file, who use HII, but there is no <VariableOffset> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
                 }\r
 \r
                 if (skuInfoList.get(index).getHiiDefaultValue() == null) {\r
-                    exceptionString = String.format("For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                    exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
                                                     "file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
                                                     "file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
@@ -1910,7 +1946,7 @@ public class CollectPCDAction {
                 }\r
                 offset = Integer.decode(skuInfoList.get(index).getVariableOffset());\r
                 if (offset > 0xFFFF) {\r
                 }\r
                 offset = Integer.decode(skuInfoList.get(index).getVariableOffset());\r
                 if (offset > 0xFFFF) {\r
-                    throw new EntityException(String.format("For dynamic PCD %s ,  the variable offset defined in sku %d data "+\r
+                    throw new EntityException(String.format("[FPD file error] For dynamic PCD %s ,  the variable offset defined in sku %d data "+\r
                                                             "exceed 64K, it is not allowed!",\r
                                                             token.cName,\r
                                                             index));\r
                                                             "exceed 64K, it is not allowed!",\r
                                                             token.cName,\r
                                                             index));\r
@@ -1930,16 +1966,17 @@ public class CollectPCDAction {
                 continue;\r
             }\r
 \r
                 continue;\r
             }\r
 \r
-            exceptionString = String.format("For dynamic PCD %s, the dynamic info must "+\r
+            exceptionString = String.format("[FPD file error] For dynamic PCD %s, the dynamic info must "+\r
                                             "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.",\r
                                             token.cName);\r
             throw new EntityException(exceptionString);\r
         }\r
 \r
         if (!hasSkuId0) {\r
                                             "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.",\r
                                             token.cName);\r
             throw new EntityException(exceptionString);\r
         }\r
 \r
         if (!hasSkuId0) {\r
-            exceptionString = String.format("For dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+\r
+            exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+\r
                                             "no sku id = 0 data, which is required for every dynamic PCD",\r
                                             token.cName);\r
                                             "no sku id = 0 data, which is required for every dynamic PCD",\r
                                             token.cName);\r
+            throw new EntityException(exceptionString);\r
         }\r
 \r
         return token;\r
         }\r
 \r
         return token;\r
@@ -1989,7 +2026,7 @@ public class CollectPCDAction {
         if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) {\r
             splitStringArray = uuidString.split("," );\r
             if (splitStringArray.length != 11) {\r
         if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) {\r
             splitStringArray = uuidString.split("," );\r
             if (splitStringArray.length != 11) {\r
-                throw new EntityException ("Wrong format for UUID string: " + uuidString);\r
+                throw new EntityException ("[FPD file error] Wrong format for UUID string: " + uuidString);\r
             }\r
 \r
             //\r
             }\r
 \r
             //\r