]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
a. Enhanced toolchain setting UI for ModuleSa build options and global build options.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
index 6d9f84d6896fb28e817b3f8a5b99999fc2ee19f1..9e2f955599a4130847bee90aac003e4b48a78ad6 100644 (file)
@@ -60,8 +60,8 @@ import org.tianocore.UserDefinedAntTasksDocument;
 import org.tianocore.UserExtensionsDocument;\r
 import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;\r
 import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r
-import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;\r
-import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
 \r
 /**\r
  This class processes fpd file contents such as add remove xml elements. \r
@@ -184,6 +184,32 @@ public class FpdFileContents {
         return fpdFrameworkModules;\r
     }\r
     \r
+    public void getFrameworkModuleGuid (String fvName, Vector<String> vGuid) {\r
+        if (getFrameworkModulesCount() == 0){\r
+            return;\r
+        }\r
+        \r
+        ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r
+        while(li.hasNext()) {\r
+            ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r
+            if (moduleSa.getModuleSaBuildOptions() == null) {\r
+                continue;\r
+            }\r
+            String fvBinding = moduleSa.getModuleSaBuildOptions().getFvBinding();\r
+            if (fvBinding == null) {\r
+                continue;\r
+            }\r
+            \r
+            String[] fvNames = fvBinding.split(" ");\r
+            for (int i = 0; i < fvNames.length; ++i) {\r
+                if (fvNames[i].equals(fvName) || fvNames[i].replaceAll("_", "").equals(fvName)) {\r
+                    vGuid.add(moduleSa.getModuleGuid());\r
+                    break;\r
+                }\r
+            }\r
+        }\r
+    }\r
+    \r
     public int getFrameworkModulesCount() {\r
         if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r
             removeElement(getfpdFrameworkModules());\r
@@ -201,13 +227,13 @@ public class FpdFileContents {
         ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r
         int i = 0;\r
         while(li.hasNext()) {\r
-            ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();\r
-            saa[i][0] = msa.getModuleGuid();\r
-            saa[i][1] = msa.getModuleVersion();\r
+            ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r
+            saa[i][0] = moduleSa.getModuleGuid();\r
+            saa[i][1] = moduleSa.getModuleVersion();\r
             \r
-            saa[i][2] = msa.getPackageGuid();\r
-            saa[i][3] = msa.getPackageVersion();\r
-            saa[i][4] = listToString(msa.getSupArchList());\r
+            saa[i][2] = moduleSa.getPackageGuid();\r
+            saa[i][3] = moduleSa.getPackageVersion();\r
+            saa[i][4] = listToString(moduleSa.getSupArchList());\r
             ++i;\r
         }\r
     }\r
@@ -605,25 +631,18 @@ public class FpdFileContents {
                 if (moduleSA.getPcdBuildDefinition() != null) {\r
                     XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor();\r
                     if (cursor.toFirstChild()) {\r
-                        PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor\r
-                                                                                                                                                      .getObject();\r
-                        if (msaPcd.getCName().equals(pcdData.getCName())\r
-                            && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r
-\r
-                            maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleKey);\r
-                            cursor.removeXml();\r
-                            break;\r
-                        }\r
-                        while (cursor.toNextSibling()) {\r
-                            pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor.getObject();\r
+                        do {\r
+                            PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor\r
+                                                                                                                                                          .getObject();\r
                             if (msaPcd.getCName().equals(pcdData.getCName())\r
                                 && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r
+\r
                                 maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(),\r
                                                   moduleKey);\r
                                 cursor.removeXml();\r
                                 break;\r
                             }\r
-                        }\r
+                        } while (cursor.toNextSibling());\r
                     }\r
                     cursor.dispose();\r
                 }\r
@@ -702,14 +721,14 @@ public class FpdFileContents {
         String mn = libMi.getName();\r
         String mg = libMi.getGuid();\r
         String mv = libMi.getVersion();\r
-        String pn = libMi.getPackage().getName();\r
-        String pg = libMi.getPackage().getGuid();\r
-        String pv = libMi.getPackage().getVersion();\r
+        String pn = libMi.getPackageId().getName();\r
+        String pg = libMi.getPackageId().getGuid();\r
+        String pv = libMi.getPackageId().getVersion();\r
         LibrariesDocument.Libraries.Instance instance = libs.addNewInstance();\r
         XmlCursor cursor = instance.newCursor();\r
         try{\r
             String comment = "Pkg: " + pn + " Mod: " + mn \r
-                + " Path: " + WorkspaceProfile.getMsaFile(libMi).getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
+                + " Path: " + libMi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
             cursor.insertComment(comment);\r
         }\r
         catch (Exception e){\r
@@ -727,31 +746,169 @@ public class FpdFileContents {
     }\r
     \r
     public String getFvBinding(String moduleKey){\r
-        ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
-        if (msa == null || msa.getModuleSaBuildOptions() == null) {\r
+        ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r
+        return getFvBinding (moduleSa);\r
+    }\r
+    \r
+    public String getFvBinding (ModuleSADocument.ModuleSA moduleSa) {\r
+        if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null) {\r
             return null;\r
         }\r
-        return msa.getModuleSaBuildOptions().getFvBinding();\r
+        return moduleSa.getModuleSaBuildOptions().getFvBinding();\r
+    }\r
+    \r
+    public void setFvBinding(ModuleSADocument.ModuleSA moduleSa, String fvBinding) {\r
+        if (moduleSa == null ) {\r
+            return;\r
+        }\r
+        if (fvBinding == null || fvBinding.length() == 0) {\r
+            if(moduleSa.getModuleSaBuildOptions() != null){\r
+                moduleSa.getModuleSaBuildOptions().unsetFvBinding();\r
+            }\r
+        }\r
+        else {\r
+            if(moduleSa.getModuleSaBuildOptions() == null){\r
+                moduleSa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);\r
+                return;\r
+            }\r
+            moduleSa.getModuleSaBuildOptions().setFvBinding(fvBinding);\r
+        }\r
     }\r
     \r
     public void setFvBinding(String moduleKey, String fvBinding){\r
-        ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
-        if (msa == null ) {\r
+        ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r
+        setFvBinding (moduleSa, fvBinding);\r
+    }\r
+    \r
+    private int fvBindingForModuleSA (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r
+        if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r
+            return -1;\r
+        }\r
+        \r
+        String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r
+        String[] fvNamesArray = fvNameList.split(" ");\r
+        int occursAt = -1;\r
+        for (int i = 0; i < fvNamesArray.length; ++i) {\r
+            if (fvNamesArray[i].equals(fvName)) {\r
+                occursAt = i;\r
+                break;\r
+            }\r
+        }\r
+        return occursAt;\r
+    }\r
+    \r
+    public void removeFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r
+        if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r
             return;\r
         }\r
-        if(msa.getModuleSaBuildOptions() == null){\r
-            msa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);\r
+        \r
+        String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r
+        String[] fvNamesArray = fvNameList.split(" ");\r
+        int occursAt = -1;\r
+        for (int i = 0; i < fvNamesArray.length; ++i) {\r
+            if (fvNamesArray[i].equals(fvName)) {\r
+                occursAt = i;\r
+                break;\r
+            }\r
+        }\r
+        // jump over where the input fvName occurs in the original Fv list.\r
+        if (occursAt != -1) {\r
+            String newFvNameList = " ";\r
+            for (int i = 0; i < fvNamesArray.length; ++i) {\r
+                if (i == occursAt) {\r
+                    continue;\r
+                }\r
+                newFvNameList += fvNamesArray[i];\r
+            }\r
+            setFvBinding (moduleSa, newFvNameList.trim());\r
+        }\r
+\r
+    }\r
+    \r
+    /**\r
+     * @param fvName The FV name that to be removed from FvBinding List.\r
+     */\r
+    public void removeFvBindingAll (String fvName) {\r
+        if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r
+            removeElement(getfpdFrameworkModules());\r
+            fpdFrameworkModules = null;\r
+            return;\r
+        }\r
+        \r
+        Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();\r
+        while (li.hasNext()) {\r
+            ModuleSADocument.ModuleSA moduleSa = li.next();\r
+            removeFvBinding (moduleSa, fvName); \r
+        }\r
+    }\r
+    \r
+    public void appendFvBindingAll (String fvName) {\r
+        if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r
+            removeElement(getfpdFrameworkModules());\r
+            fpdFrameworkModules = null;\r
+            return;\r
+        }\r
+        \r
+        Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();\r
+        while (li.hasNext()) {\r
+            ModuleSADocument.ModuleSA moduleSa = li.next();\r
+            appendFvBinding (moduleSa, fvName); \r
+        }\r
+    }\r
+    \r
+    public void appendFvBindingFor (String oldFvName, String newFvName) {\r
+        if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r
+            removeElement(getfpdFrameworkModules());\r
+            fpdFrameworkModules = null;\r
+            return;\r
+        }\r
+        \r
+        Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();\r
+        while (li.hasNext()) {\r
+            ModuleSADocument.ModuleSA moduleSa = li.next();\r
+            String fvBinding = getFvBinding (moduleSa);\r
+            if (fvBinding != null && fvBindingForModuleSA (moduleSa, oldFvName) >= 0) {\r
+                appendFvBinding (moduleSa, newFvName); \r
+            }\r
+        }\r
+    }\r
+    \r
+    public void appendFvBinding (String moduleKey, String fvName) {\r
+        ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r
+        appendFvBinding (moduleSa, fvName);\r
+    }\r
+    \r
+    public void appendFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r
+        if (moduleSa == null) {\r
             return;\r
         }\r
-        msa.getModuleSaBuildOptions().setFvBinding(fvBinding);\r
+        \r
+        if (moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r
+            setFvBinding(moduleSa, fvName);\r
+            return;\r
+        }\r
+        \r
+        String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r
+        String newFvNameList = fvNameList + " " + fvName;\r
+        setFvBinding (moduleSa, newFvNameList.trim());\r
+    }\r
+    \r
+    public void updateFvBindingInModuleSA (ModuleIdentification mi, String fvName) {\r
+        Vector<Object> vSupArchs = new Vector<Object>();\r
+        getPlatformDefsSupportedArchs(vSupArchs);\r
+        String moduleInfo = mi.getGuid() + " " + mi.getVersion() + " " + mi.getPackageId().getGuid() + " " + mi.getPackageId().getVersion();\r
+        for (int i = 0; i < vSupArchs.size(); ++i) {\r
+            String moduleKey = moduleInfo + " " + vSupArchs.get(i);\r
+            appendFvBinding (moduleKey, fvName);\r
+        }\r
     }\r
     \r
     public String getFfsFileNameGuid(String moduleKey){\r
-        ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
-        if (msa == null || msa.getModuleSaBuildOptions() == null) {\r
+        ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r
+        if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null) {\r
             return null;\r
         }\r
-        return msa.getModuleSaBuildOptions().getFfsFileNameGuid();\r
+        return moduleSa.getModuleSaBuildOptions().getFfsFileNameGuid();\r
     }\r
     \r
     public void setFfsFileNameGuid(String moduleKey, String fileGuid){\r
@@ -831,7 +988,9 @@ public class FpdFileContents {
             \r
             if (opt.getSupArchList() != null){\r
                 saa[i][4] = listToString(opt.getSupArchList());\r
-\r
+            }\r
+            else {\r
+                saa[i][4] = "";\r
             }\r
             \r
             saa[i][5] = opt.getStringValue();\r
@@ -947,12 +1106,10 @@ public class FpdFileContents {
     \r
     private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) {\r
         \r
-        Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r
         PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;\r
         for (int i = 0; i < depPkgs.length; ++i) {\r
-            m.put("PackageSurfaceArea", WorkspaceProfile.getPackageXmlObject(depPkgs[i]));\r
-            SurfaceAreaQuery.setDoc(m);\r
-            XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations();\r
+\r
+            XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations(depPkgs[i]);\r
             if (xo == null) {\r
                 continue;\r
             }\r
@@ -980,8 +1137,8 @@ public class FpdFileContents {
         ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();\r
         XmlCursor cursor = msa.newCursor();\r
         try{\r
-            String comment = "Mod: " + mi.getName() + " Type: " + mi.getModuleType() + " Path: "\r
-                            + WorkspaceProfile.getMsaFile(mi).getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
+            String comment = "Mod: " + mi.getName() + " Type: " + SurfaceAreaQuery.getModuleType(mi) + " Path: "\r
+                            + mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
             cursor.insertComment(comment);\r
         }\r
         catch(Exception e){\r
@@ -1044,7 +1201,7 @@ public class FpdFileContents {
                 fpdPcd.setValue("0");\r
             }\r
             if (dataType.equals("BOOLEAN")){\r
-                fpdPcd.setValue("false");\r
+                fpdPcd.setValue("FALSE");\r
             }\r
             if (dataType.equals("VOID*")) {\r
                 fpdPcd.setValue("");\r
@@ -1145,7 +1302,7 @@ public class FpdFileContents {
                 \r
                 if (value > 0xFF) {\r
 //                   "[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
+//                   "it must be a byte array. But the element of %s exceed the byte range",\r
                     throw new PcdValueMalFormed (datum);                               \r
                 }\r
             }\r
@@ -1498,26 +1655,31 @@ public class FpdFileContents {
         return fpdBuildOpts;\r
     }\r
     \r
-    public void genBuildOptionsUserExtensions(String fvName, String infName, String outputFileName, String[][] includeModules) {\r
+    public void genBuildOptionsUserExtensions(String fvName, String outputFileName, Vector<String[]> includeModules) {\r
+        QName elementFvName = new QName (xmlNs, "FvName");\r
+        QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r
+        QName elementInfFileName = new QName(xmlNs, "InfFileName");\r
+        QName elementModule = new QName(xmlNs, "Module");\r
+        \r
         UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();\r
         userExts.setUserID("IMAGES");\r
         userExts.setIdentifier(new BigInteger("1"));\r
         XmlCursor cursor = userExts.newCursor();\r
         cursor.toEndToken();\r
         \r
-        cursor.beginElement("FvName");\r
+        cursor.beginElement(elementFvName);\r
         cursor.insertChars(fvName);\r
         cursor.toNextToken();\r
         \r
-        cursor.beginElement("InfFileName");\r
-        cursor.insertChars(infName);\r
+        cursor.beginElement(elementInfFileName);\r
+        cursor.insertChars(fvName + ".inf");\r
         cursor.toNextToken();\r
         \r
-        cursor.beginElement("IncludeModules");\r
-        for (int i = 0; i < includeModules.length; ++i) {\r
-            cursor.beginElement("Module");\r
-            cursor.insertAttributeWithValue("ModuleGuid", includeModules[i][0]);\r
-            cursor.insertAttributeWithValue("BaseName", includeModules[i][1]);\r
+        cursor.beginElement(elementIncludeModules);\r
+        for (int i = 0; i < includeModules.size(); ++i) {\r
+            cursor.beginElement(elementModule);\r
+            cursor.insertAttributeWithValue("ModuleGuid", includeModules.get(i)[0]);\r
+            cursor.insertAttributeWithValue("BaseName", includeModules.get(i)[1]);\r
             cursor.toEndToken();\r
             cursor.toNextToken();\r
         }\r
@@ -1529,6 +1691,7 @@ public class FpdFileContents {
             return -1;\r
         }\r
         ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r
+        QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r
         while (li.hasNext()) {\r
             UserExtensionsDocument.UserExtensions ues = li.next();\r
             if (!ues.getUserID().equals("IMAGES")) {\r
@@ -1538,7 +1701,7 @@ public class FpdFileContents {
             cursor.toFirstChild();\r
             String elementName = cursor.getTextValue();\r
             if (elementName.equals(fvName)) {\r
-                cursor.toNextSibling(new QName("", "IncludeModules"));\r
+                cursor.toNextSibling(elementIncludeModules);\r
                 if (cursor.toFirstChild()) {\r
                     int i = 1;\r
                     for (i = 1; cursor.toNextSibling(); ++i);\r
@@ -1557,6 +1720,67 @@ public class FpdFileContents {
         if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
             return;\r
         }\r
+        \r
+        XmlCursor cursor = getfpdBuildOpts().newCursor();\r
+        QName elementUserExts = new QName (xmlNs, "UserExtensions");\r
+        QName attribUserId = new QName ("UserID");\r
+        QName elementFvName = new QName (xmlNs, "FvName");\r
+        QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r
+        QName attribModuleGuid = new QName("ModuleGuid");\r
+        QName attribBaseName = new QName("BaseName");\r
+        \r
+        if (cursor.toChild(elementUserExts)) {\r
+            do {\r
+                cursor.push();\r
+                if (cursor.getAttributeText(attribUserId).equals("IMAGES")) {\r
+                    cursor.toChild(elementFvName);\r
+                    String elementName = cursor.getTextValue();\r
+                    if (elementName.equals(fvName)) {\r
+                        cursor.toNextSibling(elementIncludeModules);\r
+                        if (cursor.toFirstChild()) {\r
+                            int i = 0;\r
+                            do {\r
+                                saa[i][0] = cursor.getAttributeText(attribModuleGuid);\r
+                                saa[i][1] = cursor.getAttributeText(attribBaseName);\r
+                                ++i;\r
+                            }while (cursor.toNextSibling());\r
+                        }\r
+                        break;\r
+                    }\r
+                }\r
+                cursor.pop();\r
+            }while (cursor.toNextSibling(elementUserExts));\r
+        }\r
+        cursor.dispose();\r
+        \r
+    }\r
+    \r
+    public void updateBuildOptionsUserExtensions (String oldFvName, String newFvName) {\r
+        if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
+            return;\r
+        }\r
+        ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r
+        while (li.hasNext()) {\r
+            UserExtensionsDocument.UserExtensions ues = li.next();\r
+            if (!ues.getUserID().equals("IMAGES")) {\r
+                continue;\r
+            }\r
+            XmlCursor cursor = ues.newCursor();\r
+            cursor.toFirstChild();\r
+            String elementName = cursor.getTextValue();\r
+            if (elementName.equals(oldFvName)) {\r
+                cursor.setTextValue(newFvName);\r
+            }\r
+            cursor.dispose();\r
+        }\r
+        \r
+    }\r
+    \r
+    public void removeBuildOptionsUserExtensions (String fvName) {\r
+        if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
+            return;\r
+        }\r
+        \r
         ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r
         while (li.hasNext()) {\r
             UserExtensionsDocument.UserExtensions ues = li.next();\r
@@ -1567,15 +1791,8 @@ public class FpdFileContents {
             cursor.toFirstChild();\r
             String elementName = cursor.getTextValue();\r
             if (elementName.equals(fvName)) {\r
-                cursor.toNextSibling(new QName("", "IncludeModules"));\r
-                if (cursor.toFirstChild()) {\r
-                    int i = 0;\r
-                    do {\r
-                        saa[i][0] = cursor.getAttributeText(new QName("ModuleGuid"));\r
-                        saa[i][1] = cursor.getAttributeText(new QName("BaseName"));\r
-                        ++i;\r
-                    }while (cursor.toNextSibling());\r
-                }\r
+                cursor.toParent();\r
+                cursor.removeXml();\r
                 cursor.dispose();\r
                 return;\r
             }\r
@@ -1584,6 +1801,7 @@ public class FpdFileContents {
         \r
     }\r
     \r
+    \r
     public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {\r
         UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r
         if (udats == null) {\r
@@ -2372,6 +2590,43 @@ public class FpdFileContents {
         }\r
     }\r
     \r
+    public void getFvImagesFvImageFvImageNames (Vector<String> vImageNames) {\r
+        FvImagesDocument.FvImages fis = getfpdFlash().getFvImages();\r
+        if (fis == null || fis.getFvImageList() == null) {\r
+            return;\r
+        }\r
+        \r
+        ListIterator<FvImagesDocument.FvImages.FvImage> li = fis.getFvImageList().listIterator();\r
+        while (li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = li.next();\r
+            if (fi.getType().toString().equals("ImageName")) {\r
+                vImageNames.addAll(fi.getFvImageNamesList());\r
+                return;\r
+            }\r
+        }\r
+    }\r
+    \r
+    public void AddFvImageFvImageNames (String[] fvNames) {\r
+        FvImagesDocument.FvImages fis = getfpdFlash().getFvImages();\r
+        if (fis == null || fis.getFvImageList() == null) {\r
+            genFvImagesFvImage (fvNames, "ImageName", null);\r
+            return;\r
+        }\r
+        \r
+        ListIterator<FvImagesDocument.FvImages.FvImage> li = fis.getFvImageList().listIterator();\r
+        while (li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = li.next();\r
+            if (fi.getType().toString().equals("ImageName")) {\r
+                for (int i = 0; i < fvNames.length; ++i) {\r
+                    fi.addFvImageNames(fvNames[i]);\r
+                }\r
+                return;\r
+            }\r
+        }\r
+        genFvImagesFvImage (fvNames, "ImageName", null);\r
+        \r
+    }\r
+    \r
     public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {\r
       \r
         FvImagesDocument.FvImages fis = null;\r
@@ -2431,6 +2686,52 @@ public class FpdFileContents {
         cursor.dispose();\r
     }\r
     \r
+    /**\r
+     * @param oldFvName\r
+     * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.\r
+     */\r
+    public void updateFvImageNameAll (String oldFvName, String newFvName) {\r
+        if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r
+            return;\r
+        }\r
+        ListIterator<FvImagesDocument.FvImages.FvImage> li = getfpdFlash().getFvImages().getFvImageList().listIterator();\r
+        while (li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = li.next();\r
+            updateFvImageNamesInFvImage (fi, oldFvName, newFvName);\r
+        }\r
+    }\r
+    \r
+    /**\r
+     * @param fi\r
+     * @param oldFvName The FV Name to be replaced.\r
+     * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.\r
+     */\r
+    public void updateFvImageNamesInFvImage (FvImagesDocument.FvImages.FvImage fi, String oldFvName, String newFvName) {\r
+        QName qFvImageNames = new QName(xmlNs, "FvImageNames");\r
+        XmlCursor cursor = fi.newCursor();\r
+        \r
+        if (cursor.toChild(qFvImageNames)) {\r
+            do {\r
+                if (cursor.getTextValue().equals(oldFvName)){\r
+                    if (newFvName != null) {\r
+                        cursor.setTextValue(newFvName);\r
+                    }\r
+                    else {\r
+                        if (fi.getFvImageNamesList().size() == 1) {\r
+                            removeElement(fi);\r
+                            break;\r
+                        }\r
+                        else {\r
+                            cursor.removeXml();\r
+                        }\r
+                    }\r
+                }\r
+            }while (cursor.toNextSibling(qFvImageNames));\r
+        }\r
+        \r
+        cursor.dispose();\r
+    }\r
+    \r
     public void updateFvImagesFvImage(int i, String[] names, String types, Map<String, String> options){\r
            \r
         XmlObject o = getfpdFlash().getFvImages();\r
@@ -2471,18 +2772,50 @@ public class FpdFileContents {
         cursor.dispose();\r
     }\r
     \r
-    public int getFvImagesFvImageCount() {\r
+    public int getFvImagesFvImageCount(String type) {\r
         \r
         if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r
             return 0;\r
         }\r
-        return getfpdFlash().getFvImages().getFvImageList().size();\r
+        List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r
+        ListIterator li = l.listIterator();\r
+        int i = 0;\r
+        while(li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+            if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+                continue;\r
+            }\r
+            \r
+            ++i;\r
+        }\r
+        \r
+        return i;\r
     }\r
     \r
-    /**Only Get Fv image setting - name and type.\r
+    public Vector<FvImagesDocument.FvImages.FvImage> getFvImagesFvImageWithName (String fvName, String type) {\r
+        Vector<FvImagesDocument.FvImages.FvImage> vFvImage = new Vector<FvImagesDocument.FvImages.FvImage>();\r
+        if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r
+            return vFvImage;\r
+        }\r
+        List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r
+        ListIterator li = l.listIterator();\r
+        while(li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+            if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+                continue;\r
+            }\r
+            if (fi.getFvImageNamesList().contains(fvName)) {\r
+                vFvImage.add(fi);\r
+            }\r
+        }\r
+        \r
+        return vFvImage;\r
+    }\r
+    /**\r
      * @param saa\r
+     * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components.\r
      */\r
-    public void getFvImagesFvImages(String[][] saa) {\r
+    public void getFvImagesFvImages(String[][] saa, String type) {\r
     \r
         if (getfpdFlash().getFvImages() == null) {\r
             return;\r
@@ -2495,6 +2828,9 @@ public class FpdFileContents {
         int i = 0;\r
         while(li.hasNext()) {\r
             FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+            if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+                continue;\r
+            }\r
             //\r
             // get FvImageNames array, space separated\r
             //\r
@@ -2513,6 +2849,108 @@ public class FpdFileContents {
         }\r
     }\r
     \r
+    /**Add name-value pair to FvImage element with type.\r
+     * @param fvName FV name to add name-value pair.\r
+     * @param type FvImage attribute.\r
+     * @param name\r
+     * @param value\r
+     */\r
+    public void setTypedNamedFvImageNameValue (String fvName, String type, String name, String value) {\r
+        if (getfpdFlash().getFvImages() == null) {\r
+            return;\r
+        }\r
+        List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r
+        if (l == null) {\r
+            return;\r
+        }\r
+        ListIterator li = l.listIterator();\r
+        while(li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+            if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+                continue;\r
+            }\r
+            if (!fi.getFvImageNamesList().contains(fvName)) {\r
+                continue;\r
+            }\r
+            setFvImagesFvImageNameValue (fi, name, value, null);\r
+        }\r
+    }\r
+    \r
+    /**Add to all FvImage elements with type, the name-value pair.\r
+     * @param type\r
+     * @param name\r
+     * @param value\r
+     */\r
+    public void setTypedFvImageNameValue (String type, String name, String value) {\r
+        if (getfpdFlash().getFvImages() == null) {\r
+            return;\r
+        }\r
+        List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r
+        if (l == null) {\r
+            return;\r
+        }\r
+        ListIterator li = l.listIterator();\r
+        while(li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+            if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+                continue;\r
+            }\r
+            setFvImagesFvImageNameValue (fi, name, value, null);\r
+        }\r
+    }\r
+    \r
+    /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.\r
+     * @param fi\r
+     * @param name\r
+     * @param value\r
+     * @param newName\r
+     */\r
+    public void setFvImagesFvImageNameValue (FvImagesDocument.FvImages.FvImage fi, String name, String value, String newName) {\r
+        if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) {\r
+            return;\r
+        }\r
+        \r
+        XmlCursor cursor = fi.getFvImageOptions().newCursor();\r
+        if (cursor.toFirstChild()) {\r
+            do {\r
+                FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue)cursor.getObject();\r
+                if (nv.getName().equals(name)) {\r
+                    nv.setValue(value);\r
+                    if (newName != null) {\r
+                        nv.setName(newName);\r
+                    }\r
+                    cursor.dispose();\r
+                    return;\r
+                }\r
+            }while (cursor.toNextSibling());\r
+        }\r
+        \r
+        FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.getFvImageOptions().addNewNameValue();\r
+        nv.setName(name);\r
+        nv.setValue(value);\r
+        if (newName != null) {\r
+            nv.setName(newName);\r
+        }\r
+        cursor.dispose();\r
+    }\r
+    \r
+    public void getFvImagesFvImageOptions (String fvName, Map<String, String> m) {\r
+        Vector<FvImagesDocument.FvImages.FvImage> vFvImage = getFvImagesFvImageWithName (fvName, "Options");\r
+        for (int i = 0; i < vFvImage.size(); ++i) {\r
+            FvImagesDocument.FvImages.FvImage fi = vFvImage.get(i);\r
+            if (fi == null || fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) {\r
+                continue;\r
+            }\r
+\r
+            ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions()\r
+                                                                                            .getNameValueList()\r
+                                                                                            .listIterator();\r
+            while (li.hasNext()) {\r
+                FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r
+                m.put(nv.getName(), nv.getValue());\r
+            }\r
+        }\r
+    }\r
     /**Get FvImage Options for FvImage i\r
      * @param i the ith FvImage\r
      */\r
@@ -2693,7 +3131,7 @@ class PcdItemTypeConflictException extends Exception {
     \r
     PcdItemTypeConflictException(String pcdName, String info){\r
         ModuleIdentification mi = WorkspaceProfile.getModuleId(info);\r
-        details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackage().getName();\r
+        details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName();\r
     }\r
     \r
     public String getMessage() {\r