]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
set default value of PCD from msa file or spd file.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
index f730fa2a6ee22cee410c272c63b5138f80e91df3..d942addf50adb966217dd3d720eacee22bc62e58 100644 (file)
@@ -231,7 +231,7 @@ public class FpdFileContents {
         ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r
         while(li.hasNext()) {\r
             ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();\r
-            if (msa.getModuleGuid().equals(s[0]) && msa.getPackageGuid().equals(s[2])) {\r
+            if (msa.getModuleGuid().equalsIgnoreCase(s[0]) && msa.getPackageGuid().equalsIgnoreCase(s[2])) {\r
                 if (msa.getModuleVersion() != null) {\r
                     if (!msa.getModuleVersion().equals(s[1])) {\r
                         continue;\r
@@ -776,7 +776,7 @@ public class FpdFileContents {
                     //\r
                     // ToDo Error \r
                     //\r
-                    throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName());\r
+                    throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + mi.getName());\r
                 }\r
                 //\r
                 // AddItem to ModuleSA PcdBuildDefinitions\r
@@ -788,7 +788,7 @@ public class FpdFileContents {
             \r
         }\r
         catch (Exception e){\r
-            e.printStackTrace();\r
+            \r
             throw e; \r
         }\r
         \r
@@ -873,16 +873,17 @@ public class FpdFileContents {
         //\r
         // Special dynamic type, if this pcd already exists in other ModuleSA\r
         //\r
+        /* Comment out Item type checking temporarily.\r
         if (itemType.equals("DYNAMIC")) {\r
             \r
             ListIterator li = pcdConsumer.listIterator();\r
             while(li.hasNext()) {\r
                 String value = li.next().toString();\r
                 String[] valuePart= value.split(" ");\r
-                if (!valuePart[4].equals("DYNAMIC")) {\r
+                if (!valuePart[5].equals("DYNAMIC")) {\r
                     //ToDo error for same pcd, other type than dynamic\r
                     pcdConsumer.remove(listValue);\r
-                    throw new PcdItemTypeConflictException(value);\r
+                    throw new PcdItemTypeConflictException(cName, value);\r
                 }\r
             }\r
         }\r
@@ -891,14 +892,14 @@ public class FpdFileContents {
             while(li.hasNext()) {\r
                 String value = li.next().toString();\r
                 String[] valuePart= value.split(" ");\r
-                if (valuePart[4].equals("DYNAMIC")) {\r
+                if (valuePart[5].equals("DYNAMIC")) {\r
                     //ToDo error for same pcd, other type than non-dynamic\r
                     pcdConsumer.remove(listValue);\r
-                    throw new PcdItemTypeConflictException(value);\r
+                    throw new PcdItemTypeConflictException(cName, value);\r
                 }\r
             }\r
         }\r
-        \r
+        */\r
         PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData();\r
         fpdPcd.setCName(cName);\r
         fpdPcd.setToken(token);\r
@@ -906,6 +907,41 @@ public class FpdFileContents {
         fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType));\r
         fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType));\r
         \r
+        if (defaultVal != null){\r
+            fpdPcd.setValue(defaultVal);\r
+        }\r
+        else {\r
+            if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {\r
+                fpdPcd.setValue("0");\r
+            }\r
+            if (dataType.equals("BOOLEAN")){\r
+                fpdPcd.setValue("false");\r
+            }\r
+            if (dataType.equals("VOID*")) {\r
+                fpdPcd.setValue("");\r
+            }\r
+        }\r
+        if (dataType.equals("UINT8")){\r
+            fpdPcd.setMaxDatumSize(1);\r
+        }\r
+        if (dataType.equals("UINT16")) {\r
+            fpdPcd.setMaxDatumSize(2);\r
+        }\r
+        if (dataType.equals("UINT32")) {\r
+            fpdPcd.setMaxDatumSize(4);\r
+        }\r
+        if (dataType.equals("UINT64")){\r
+            fpdPcd.setMaxDatumSize(8);\r
+        }\r
+        if (dataType.equals("BOOLEAN")){\r
+            fpdPcd.setMaxDatumSize(1);\r
+        }\r
+        if (dataType.equals("VOID*")) {\r
+            int maxSize = setMaxSizeForPointer(fpdPcd.getValue());\r
+            fpdPcd.setMaxDatumSize(maxSize);\r
+        }\r
+        \r
+        \r
         if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) {\r
             ArrayList<String> al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid);\r
             //\r
@@ -917,6 +953,7 @@ public class FpdFileContents {
             }\r
         }\r
         else {\r
+            /*\r
             if (defaultVal != null){\r
                 fpdPcd.setValue(defaultVal);\r
             }\r
@@ -931,6 +968,7 @@ public class FpdFileContents {
                     fpdPcd.setValue("");\r
                 }\r
             }\r
+            \r
             if (dataType.equals("UINT8")){\r
                 fpdPcd.setMaxDatumSize(1);\r
             }\r
@@ -950,6 +988,7 @@ public class FpdFileContents {
                 int maxSize = setMaxSizeForPointer(fpdPcd.getValue());\r
                 fpdPcd.setMaxDatumSize(maxSize);\r
             }\r
+            */\r
         }\r
     }\r
     \r
@@ -1030,7 +1069,7 @@ public class FpdFileContents {
     \r
     private ArrayList<String> LookupPlatformPcdData(String pcdKey) {\r
         \r
-        return dynPcdMap.get("pcdKey");\r
+        return dynPcdMap.get(pcdKey);\r
     }\r
     \r
     public int getDynamicPcdBuildDataCount() {\r
@@ -2320,7 +2359,7 @@ public class FpdFileContents {
         if (fpdHdr == null) {\r
             fpdHdr = fpdRoot.addNewPlatformHeader();\r
         }\r
-        genPlatformDefsSkuInfo("0", "DEFAULT");\r
+        \r
         return fpdHdr;\r
     }\r
     \r
@@ -2464,8 +2503,9 @@ class PcdItemTypeConflictException extends Exception {
     private static final long serialVersionUID = 1L;\r
     private String details = null;\r
     \r
-    PcdItemTypeConflictException(String info){\r
-        details = info;\r
+    PcdItemTypeConflictException(String pcdName, String info){\r
+        ModuleIdentification mi = GlobalData.getModuleId(info);\r
+        details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackage().getName();\r
     }\r
     \r
     public String getMessage() {\r
@@ -2482,7 +2522,7 @@ class PcdDeclNotFound extends Exception {
     private String details = null;\r
     \r
     PcdDeclNotFound(String info) {\r
-        details = info;\r
+        details = "PcdDeclNotFound: " + info;\r
     }\r
     \r
     public String getMessage() {\r
@@ -2499,7 +2539,7 @@ class PcdValueMalFormed extends Exception {
     private String details = null;\r
     \r
     PcdValueMalFormed(String info) {\r
-        details = info;\r
+        details = "PcdValueMalFormed: " + info;\r
     }\r
     \r
     public String getMessage() {\r