]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
Fixed EDKT163. Added code to assign "arch" to null when no "SupArchList" is specified...
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / SurfaceAreaQuery.java
index 5eb14d4a4521d1c701c05b4efb515b03b0084671..dbcc12772ceb16e566076a44bcd214bacb6a3c1c 100644 (file)
@@ -23,16 +23,13 @@ import java.util.Stack;
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
 \r
-import org.apache.xmlbeans.XmlNormalizedString;\r
 import org.apache.xmlbeans.XmlObject;\r
 import org.apache.xmlbeans.XmlString;\r
 import org.tianocore.BuildOptionsDocument;\r
-import org.tianocore.DataIdDocument;\r
+import org.tianocore.CNameType;\r
 import org.tianocore.ExternsDocument;\r
 import org.tianocore.FileNameConvention;\r
-import org.tianocore.FvAttributeDocument;\r
 import org.tianocore.FvImagesDocument;\r
-import org.tianocore.FvOptionDocument;\r
 import org.tianocore.GuidDeclarationsDocument;\r
 import org.tianocore.GuidsDocument;\r
 import org.tianocore.LibrariesDocument;\r
@@ -48,21 +45,25 @@ import org.tianocore.OptionDocument;
 import org.tianocore.PPIsDocument;\r
 import org.tianocore.PackageDependenciesDocument;\r
 import org.tianocore.PackageHeadersDocument;\r
+import org.tianocore.PcdCodedDocument;\r
 import org.tianocore.PlatformDefinitionsDocument;\r
+import org.tianocore.PlatformHeaderDocument;\r
 import org.tianocore.PpiDeclarationsDocument;\r
 import org.tianocore.ProtocolDeclarationsDocument;\r
+import org.tianocore.Sentence;\r
 import org.tianocore.SpdHeaderDocument;\r
-import org.tianocore.SupportedArchitectures;\r
+import org.tianocore.UserExtensionsDocument;\r
 import org.tianocore.FilenameDocument.Filename;\r
 import org.tianocore.MsaHeaderDocument.MsaHeader;\r
 import org.tianocore.ProtocolsDocument.Protocols.Protocol;\r
 import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
-import org.tianocore.PlatformHeaderDocument;\r
 import org.tianocore.build.id.FpdModuleIdentification;\r
 import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.id.PackageIdentification;\r
 import org.tianocore.build.id.PlatformIdentification;\r
 import org.tianocore.build.toolchain.ToolChainInfo;\r
+import org.tianocore.logger.EdkLog;\r
+import org.w3c.dom.Node;\r
 \r
 /**\r
  * SurfaceAreaQuery class is used to query Surface Area information from msa,\r
@@ -265,12 +266,7 @@ public class SurfaceAreaQuery {
         String[] xPath;\r
         Object[] returns;\r
 \r
-        if (arch == null || arch.equals("")) {\r
-            xPath = new String[] { "/Filename" };\r
-        } else {\r
-            xPath = new String[] { "/Filename[not(@SupArchList) or @SupArchList='"\r
-                    + arch + "']" };\r
-        }\r
+        xPath = new String[] { "/Filename" };\r
 \r
         returns = get("SourceFiles", xPath);\r
 \r
@@ -279,10 +275,18 @@ public class SurfaceAreaQuery {
         }\r
 \r
         Filename[] sourceFileNames = (Filename[]) returns;\r
-        String[][] outputString = new String[sourceFileNames.length][2];\r
+        List<String[]> outputList = new ArrayList<String[]>();\r
         for (int i = 0; i < sourceFileNames.length; i++) {\r
-            outputString[i][0] = sourceFileNames[i].getToolCode();\r
-            outputString[i][1] = sourceFileNames[i].getStringValue();\r
+            List archList = sourceFileNames[i].getSupArchList();\r
+            if (arch == null || arch.equalsIgnoreCase("") || archList == null || contains(archList, arch)) {\r
+                outputList.add(new String[] {sourceFileNames[i].getToolCode(),sourceFileNames[i].getStringValue()});\r
+            }\r
+        }\r
+           \r
+        String[][] outputString = new String[outputList.size()][2];\r
+        for (int index = 0; index < outputList.size(); index++) {\r
+            outputString[index][0] = outputList.get(index)[0];\r
+            outputString[index][1] = outputList.get(index)[1];\r
         }\r
         return outputString;\r
     }\r
@@ -393,7 +397,6 @@ public class SurfaceAreaQuery {
         String toolchainFamily = null;\r
         List<String> archList = null;\r
         String cmd = null;\r
-        String targetName = null;\r
         String optionName = null;\r
 \r
         Object[] returns = get(from, xPath);\r
@@ -438,19 +441,16 @@ public class SurfaceAreaQuery {
             }\r
 \r
             archList = new ArrayList<String>();\r
-            List<String> archEnumList = option.getSupArchList();            \r
+            List archEnumList = option.getSupArchList();            \r
             if (archEnumList == null) {\r
                 archList.add(null);\r
             } else {\r
-                archList.addAll(archEnumList);\r
-                /*\r
+                //archList.addAll(archEnumList);\r
                 Iterator it = archEnumList.iterator();\r
                 while (it.hasNext()) {\r
-                    System.out.println(it.next().getClass().getName());\r
-                    SupportedArchitectures.Enum archType = it.next();\r
-                    archList.add(archType.toString());\r
+                    String archType = (String)it.next();\r
+                    archList.add(archType);\r
                 }\r
-                */\r
             }\r
 \r
             cmd = option.getToolCode();\r
@@ -554,26 +554,37 @@ public class SurfaceAreaQuery {
         String packageGuid = null;\r
         String packageVersion = null;\r
 \r
-        if (arch == null || arch.equals("")) {\r
-            xPath = new String[] { "/Package" };\r
-        } else {\r
-            xPath = new String[] { "/Package[not(@SupArchList) or @SupArchList='"\r
-                    + arch + "']" };\r
-        }\r
-\r
+        \r
+        xPath = new String[] { "/Package" };\r
+        \r
         Object[] returns = get("PackageDependencies", xPath);\r
         if (returns == null) {\r
             return new PackageIdentification[0];\r
         }\r
-        PackageIdentification[] packageIdList = new PackageIdentification[returns.length];\r
+\r
+        //\r
+        //  Get packageIdentification \r
+        // \r
+        List<PackageIdentification> packageIdList = new ArrayList<PackageIdentification>();\r
         for (int i = 0; i < returns.length; i++) {\r
             PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i];\r
-            packageGuid = item.getPackageGuid();\r
-            packageVersion = item.getPackageVersion();\r
-            packageIdList[i] = (new PackageIdentification(null, packageGuid,\r
+            List archList = item.getSupArchList();\r
+            if (arch == null || archList == null || contains(archList, arch)) {\r
+                packageGuid = item.getPackageGuid();\r
+                packageVersion = item.getPackageVersion();\r
+                packageIdList.add(new PackageIdentification(null, packageGuid,\r
                     packageVersion));\r
+            }\r
+        }\r
+\r
+        //\r
+        //  transfer packageIdentification list to array.\r
+        // \r
+        PackageIdentification[] packageIdArray = new PackageIdentification[packageIdList.size()];\r
+        for (int i = 0; i < packageIdList.size(); i++) {\r
+            packageIdArray[i] = new PackageIdentification(null, packageIdList.get(i).getGuid(),packageIdList.get(i).getVersion());\r
         }\r
-        return packageIdList;\r
+        return packageIdArray;\r
     }\r
 \r
     /**\r
@@ -586,9 +597,8 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getLibraryClasses(String usage) {\r
+    public static String[] getLibraryClasses(String usage, String arch) {\r
         String[] xPath;\r
-\r
         if (usage == null || usage.equals("")) {\r
             xPath = new String[] { "/LibraryClass" };\r
         } else {\r
@@ -601,11 +611,19 @@ public class SurfaceAreaQuery {
         }\r
 \r
         LibraryClassDocument.LibraryClass[] libraryClassList = (LibraryClassDocument.LibraryClass[]) returns;\r
-        String[] libraryClassName = new String[libraryClassList.length];\r
+        List<String> libraryClassName = new ArrayList<String>();\r
         for (int i = 0; i < libraryClassList.length; i++) {\r
-            libraryClassName[i] = libraryClassList[i].getKeyword();\r
+                       List archList = libraryClassList[i].getSupArchList();\r
+                       \r
+                       if (arch == null || contains(archList, arch)) {\r
+                libraryClassName.add(libraryClassList[i].getKeyword());\r
+                       }\r
         }\r
-        return libraryClassName;\r
+               String[] libraryArray = new String[libraryClassName.size()];\r
+               for (int i = 0; i < libraryClassName.size(); i++) {\r
+                       libraryArray[i] = libraryClassName.get(i);\r
+               }\r
+        return libraryArray;\r
     }\r
 \r
     /**\r
@@ -624,8 +642,7 @@ public class SurfaceAreaQuery {
             String[] entryPoints = new String[returns.length];\r
 \r
             for (int i = 0; i < returns.length; ++i) {\r
-                entryPoints[i] = ((XmlNormalizedString) returns[i])\r
-                        .getStringValue();\r
+                entryPoints[i] = ((CNameType) returns[i]).getStringValue();\r
             }\r
 \r
             return entryPoints;\r
@@ -651,7 +668,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            archXpath = "/Protocol[@SupArchList='" + arch + "']";\r
+            archXpath = "/Protocol";\r
             if (usage != null && !usage.equals("")) {\r
                 usageXpath = "/Protocol[@Usage='" + usage + "']";\r
                 xPath = new String[] { usageXpath, archXpath };\r
@@ -689,18 +706,26 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            xPath = new String[] { "/Protocol[@SupArchList='" + arch + "']" };\r
+            xPath = new String[] { "/Protocol" };\r
         }\r
 \r
         Object[] returns = get("Protocols", xPath);\r
         if (returns == null) {\r
             return new String[0];\r
         }\r
-        Protocol[] protocolList = (Protocol[]) returns;\r
+        Protocol[] returnlList = (Protocol[]) returns;\r
 \r
-        String[] protocolArray = new String[returns.length];\r
+        List<String> protocolList = new ArrayList<String>();\r
+        \r
         for (int i = 0; i < returns.length; i++) {\r
-            protocolArray[i] = protocolList[i].getProtocolCName();\r
+            List archList = returnlList[i].getSupArchList();\r
+            if (archList == null || contains(archList, arch)){\r
+                protocolList.add(returnlList[i].getProtocolCName());\r
+            }\r
+        }\r
+        String[] protocolArray = new String[protocolList.size()];\r
+        for (int i = 0; i < protocolList.size(); i++) {\r
+            protocolArray[i] = protocolList.get(i);\r
         }\r
         return protocolArray;\r
     }\r
@@ -720,8 +745,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            xPath = new String[] { "/ProtocolNotify[@SupArchList='" + arch\r
-                    + "']" };\r
+            xPath = new String[] { "/ProtocolNotify" };\r
         }\r
 \r
         Object[] returns = get("Protocols", xPath);\r
@@ -729,12 +753,20 @@ public class SurfaceAreaQuery {
             return new String[0];\r
         }\r
 \r
-        String[] protocolNotifyList = new String[returns.length];\r
+        List<String> protocolNotifyList = new ArrayList<String>();\r
+        \r
         for (int i = 0; i < returns.length; i++) {\r
-            protocolNotifyList[i] = ((ProtocolNotify) returns[i]).getProtocolNotifyCName();\r
+            List archList = ((ProtocolNotify) returns[i]).getSupArchList();\r
+            if (archList == null || contains(archList, arch)){\r
+                protocolNotifyList.add(((ProtocolNotify) returns[i]).getProtocolNotifyCName());\r
+            }\r
+            \r
         }\r
-\r
-        return protocolNotifyList;\r
+        String[] protocolNotifyArray = new String[protocolNotifyList.size()];\r
+        for (int i = 0; i < protocolNotifyList.size(); i++) {\r
+            protocolNotifyArray[i] = protocolNotifyList.get(i);\r
+        }\r
+        return protocolNotifyArray;\r
     }\r
 \r
     /**\r
@@ -755,7 +787,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            archXpath = "/ProtocolNotify[@SupArchList='" + arch + "']";\r
+            archXpath = "/ProtocolNotify";\r
             if (usage != null && !usage.equals("")) {\r
                 usageXpath = "/ProtocolNotify[@Usage='" + arch + "']";\r
                 xPath = new String[] { archXpath, usageXpath };\r
@@ -790,7 +822,7 @@ public class SurfaceAreaQuery {
         Object[] returns = get("Externs", xPath);\r
         if (returns != null && returns.length > 0) {\r
             String[] stringArray = new String[returns.length];\r
-            XmlNormalizedString[] doc = (XmlNormalizedString[]) returns;\r
+            CNameType[] doc = (CNameType[]) returns;\r
 \r
             for (int i = 0; i < returns.length; ++i) {\r
                 stringArray[i] = doc[i].getStringValue();\r
@@ -834,7 +866,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            xPath = new String[] { "/PpiNotify[@SupArchList='" + arch + "']" };\r
+            xPath = new String[] { "/PpiNotify" };\r
         }\r
 \r
         Object[] returns = get("PPIs", xPath);\r
@@ -842,12 +874,21 @@ public class SurfaceAreaQuery {
             return new String[0];\r
         }\r
 \r
-        String[] ppiNotifyList = new String[returns.length];\r
+        \r
+        List<String> ppiNotifyList = new ArrayList<String>();\r
         for (int i = 0; i < returns.length; i++) {\r
-            ppiNotifyList[i] = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName();\r
+            List archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList();\r
+            if (archList == null || contains(archList, arch)){\r
+                ppiNotifyList.add(((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName()); \r
+            }\r
+            \r
+        }\r
+        String[] ppiNotifyArray = new String[ppiNotifyList.size()];\r
+        for (int i = 0; i < ppiNotifyList.size(); i++) {\r
+            ppiNotifyArray[i] = ppiNotifyList.get(i);\r
         }\r
 \r
-        return ppiNotifyList;\r
+        return ppiNotifyArray;\r
     }\r
 \r
     /**\r
@@ -869,7 +910,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            archXpath = "/PpiNotify[@SupArchList='" + arch + "']";\r
+            archXpath = "/PpiNotify";\r
             if (usage != null && !usage.equals("")) {\r
                 usageXpath = "/PpiNotify[@Usage='" + arch + "']";\r
                 xPath = new String[] { archXpath, usageXpath };\r
@@ -906,7 +947,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            xPath = new String[] { "/Ppi[@SupArchList='" + arch + "']" };\r
+            xPath = new String[] { "/Ppi" };\r
         }\r
 \r
         Object[] returns = get("PPIs", xPath);\r
@@ -914,11 +955,19 @@ public class SurfaceAreaQuery {
             return new String[0];\r
         }\r
 \r
-        String[] ppiList = new String[returns.length];\r
+        List<String> ppiList = new ArrayList<String>();\r
         for (int i = 0; i < returns.length; i++) {\r
-            ppiList[i] = ((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName();\r
+            List archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList();\r
+            if (archList == null || contains(archList, arch)){\r
+                ppiList.add(((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName());    \r
+            }\r
+            \r
         }\r
-        return ppiList;\r
+        String[] ppiArray = new String[ppiList.size()];\r
+        for (int i = 0; i < ppiList.size(); i++) {\r
+            ppiArray[i] = ppiList.get(i);\r
+        }\r
+        return ppiArray;\r
     }\r
 \r
     /**\r
@@ -940,7 +989,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            archXpath = "/Ppi[@SupArchList='" + arch + "']";\r
+            archXpath = "/Ppi";\r
             if (usage != null && !usage.equals("")) {\r
                 usageXpath = "/Ppi[@Usage='" + arch + "']";\r
                 xPath = new String[] { archXpath, usageXpath };\r
@@ -975,20 +1024,29 @@ public class SurfaceAreaQuery {
         String[] xPath;\r
 \r
         if (arch == null || arch.equals("")) {\r
-            xPath = new String[] { "/GuidName" };\r
+            xPath = new String[] { "/GuidCNames" };\r
         } else {\r
-            xPath = new String[] { "/GuidName[@SupArchList='" + arch + "']" };\r
+            xPath = new String[] { "/GuidCNames" };\r
         }\r
 \r
         Object[] returns = get("Guids", xPath);\r
         if (returns == null) {\r
             return new String[0];\r
         }\r
-        String[] guidList = new String[returns.length];\r
+\r
+        List<String> guidList = new ArrayList<String>();\r
         for (int i = 0; i < returns.length; i++) {\r
-            guidList[i] = ((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName();\r
+            List archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList();\r
+            if (archList == null || contains(archList, arch)){\r
+                guidList.add(((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName());    \r
+            }\r
+            \r
         }\r
-        return guidList;\r
+        String[] guidArray = new String[guidList.size()];\r
+        for (int i = 0; i < guidList.size(); i++) {\r
+            guidArray[i] = guidList.get(i);\r
+        }\r
+        return guidArray;\r
 \r
     }\r
 \r
@@ -1009,7 +1067,7 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equals("")) {\r
             return new String[0];\r
         } else {\r
-            archXpath = "/GuidEntry[@SupArchList='" + arch + "']";\r
+            archXpath = "/GuidEntry";\r
             if (usage != null && !usage.equals("")) {\r
                 usageXpath = "/GuidEntry[@Usage='" + arch + "']";\r
                 xPath = new String[] { archXpath, usageXpath };\r
@@ -1053,6 +1111,11 @@ public class SurfaceAreaQuery {
         if (arch == null || arch.equalsIgnoreCase("")) {\r
             xPath = new String[] { "/Instance" };\r
         } else {\r
+            //\r
+            // Since Schema don't have SupArchList now, so the follow Xpath is \r
+            // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]\r
+            // don't have effect.\r
+            //\r
             xPath = new String[] { "/Instance[not(@SupArchList) or @SupArchList='"\r
                     + arch + "']" };\r
         }\r
@@ -1096,7 +1159,7 @@ public class SurfaceAreaQuery {
         String[] strings = new String[returns.length];\r
         for (int i = 0; i < returns.length; ++i) {\r
             // TBD\r
-            // strings[i] = ((CName) returns[i]).getStringValue();\r
+             strings[i] = ((CNameType) returns[i]).getStringValue();\r
         }\r
 \r
         return strings;\r
@@ -1113,8 +1176,8 @@ public class SurfaceAreaQuery {
 \r
         Object[] returns = get("Externs", xPath);\r
         if (returns != null && returns.length > 0) {\r
-            // CName constructor = (CName) returns[0];\r
-            // return constructor.getStringValue();\r
+            CNameType constructor = ((CNameType) returns[0]);\r
+            return constructor.getStringValue();\r
         }\r
 \r
         return null;\r
@@ -1131,8 +1194,11 @@ public class SurfaceAreaQuery {
 \r
         Object[] returns = get("Externs", xPath);\r
         if (returns != null && returns.length > 0) {\r
-            // CName destructor = (CName) returns[0];\r
-            // return destructor.getStringValue();\r
+            //\r
+            // Only support one Destructor function.\r
+            //\r
+             CNameType destructor = (CNameType) returns[0];\r
+             return destructor.getStringValue();\r
         }\r
 \r
         return null;\r
@@ -1238,24 +1304,24 @@ public class SurfaceAreaQuery {
                 ObjectMap.put("Libraries", moduleSA.getLibraries());\r
             }\r
             if (((ModuleSADocument.ModuleSA) result[i]).getPcdBuildDefinition() != null) {\r
-                ObjectMap.put("PcdBuildDefinition", moduleSA\r
-                        .getPcdBuildDefinition());\r
+                ObjectMap.put("PcdBuildDefinition", moduleSA.getPcdBuildDefinition());\r
             }\r
-            if (((ModuleSADocument.ModuleSA) result[i])\r
-                    .getModuleSaBuildOptions() != null) {\r
-                ObjectMap.put("ModuleSaBuildOptions", moduleSA\r
-                        .getModuleSaBuildOptions());\r
+            if (((ModuleSADocument.ModuleSA) result[i]).getModuleSaBuildOptions() != null) {\r
+                ObjectMap.put("ModuleSaBuildOptions", moduleSA.getModuleSaBuildOptions());\r
             }\r
 \r
             //\r
             // Get Fpd SA Module attribute and create FpdMoudleIdentification.\r
             //\r
-            arch = moduleSA.getSupArchList().toString();\r
+            if (moduleSA.isSetSupArchList()) {\r
+                arch = moduleSA.getSupArchList().toString();\r
+            } else {\r
+                arch = null;\r
+            }\r
 \r
             // TBD\r
             fvBinding = null;\r
-            saVersion = ((ModuleSADocument.ModuleSA) result[i])\r
-                    .getModuleVersion();\r
+            saVersion = ((ModuleSADocument.ModuleSA) result[i]).getModuleVersion();\r
 \r
             saGuid = moduleSA.getModuleGuid();\r
             pkgGuid = moduleSA.getPackageGuid();\r
@@ -1265,10 +1331,8 @@ public class SurfaceAreaQuery {
             // Create Module Identification which have class member of package\r
             // identification.\r
             //\r
-            PackageIdentification pkgId = new PackageIdentification(null,\r
-                    pkgGuid, pkgVersion);\r
-            ModuleIdentification saId = new ModuleIdentification(null, saGuid,\r
-                    saVersion);\r
+            PackageIdentification pkgId = new PackageIdentification(null, pkgGuid, pkgVersion);\r
+            ModuleIdentification saId = new ModuleIdentification(null, saGuid, saVersion);\r
 \r
             saId.setPackage(pkgId);\r
 \r
@@ -1276,21 +1340,24 @@ public class SurfaceAreaQuery {
             // Create FpdModule Identification which have class member of module\r
             // identification\r
             //\r
-            if (arch != null) {\r
-                String[] archList = arch.split(" ");\r
-                for (int j = 0; j < archList.length; j++) {\r
-                    FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId,    archList[j]);\r
-        \r
-                    if (fvBinding != null) {\r
-                        fpdSaId.setFvBinding(fvBinding);\r
-                    }\r
-        \r
-                    //\r
-                    // Put element to Map<FpdModuleIdentification, Map<String,\r
-                    // Object>>.\r
-                    //\r
-                    fpdModuleMap.put(fpdSaId, ObjectMap);\r
+            String[] archList = new String[0];\r
+            if (arch == null || arch.trim().length() == 0) {\r
+                archList = GlobalData.getToolChainInfo().getArchs();\r
+            } else {\r
+                archList = arch.split(" ");\r
+            }\r
+            for (int j = 0; j < archList.length; j++) {\r
+                FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId, archList[j]);\r
+    \r
+                if (fvBinding != null) {\r
+                    fpdSaId.setFvBinding(fvBinding);\r
                 }\r
+    \r
+                //\r
+                // Put element to Map<FpdModuleIdentification, Map<String,\r
+                // Object>>.\r
+                //\r
+                fpdModuleMap.put(fpdSaId, ObjectMap);\r
             }\r
         }\r
         return fpdModuleMap;\r
@@ -1318,14 +1385,28 @@ public class SurfaceAreaQuery {
         return result;\r
     }\r
     \r
-    public static XmlObject getFpdUserExtension() {\r
-        String[] xPath = new String[] { "" };\r
+    public static Node getFpdUserExtensionPreBuild() {\r
+        String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" }; \r
 \r
         Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
-        if (queryResult == null) {\r
+        if (queryResult == null || queryResult.length == 0) {\r
             return null;\r
         }\r
-        return null;\r
+        UserExtensionsDocument.UserExtensions a =  (UserExtensionsDocument.UserExtensions)queryResult[0];\r
+        \r
+        return a.getDomNode();\r
+    }\r
+    \r
+    public static Node getFpdUserExtensionPostBuild() {\r
+        String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" }; \r
+\r
+        Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
+        if (queryResult == null || queryResult.length == 0) {\r
+            return null;\r
+        }\r
+        UserExtensionsDocument.UserExtensions a =  (UserExtensionsDocument.UserExtensions)queryResult[0];\r
+        \r
+        return a.getDomNode();\r
     }\r
 \r
     /**\r
@@ -1339,7 +1420,7 @@ public class SurfaceAreaQuery {
      */\r
     public static String[][] getFpdOptions(String fvName) {\r
            String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"\r
-                      + fvName.toUpperCase() + "']/FvImageOptions" };\r
+                      + fvName + "']/FvImageOptions" };\r
            Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
            if (queryResult == null) {\r
                  return new String[0][];\r
@@ -1407,7 +1488,7 @@ public class SurfaceAreaQuery {
      */\r
     public static String[][] getFpdAttributes(String fvName) {\r
         String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"\r
-                         + fvName.toUpperCase() + "']/FvImageOptions" };\r
+                         + fvName + "']/FvImageOptions" };\r
         Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
         if (queryResult == null) {\r
              return new String[0][];\r
@@ -1477,7 +1558,7 @@ public class SurfaceAreaQuery {
      * @returns empty list if nothing is there\r
      */\r
     public static String[][] getFpdComponents(String fvName) {\r
-        String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName.toUpperCase() + "']/FvImageOptions" };\r
+        String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName + "']/FvImageOptions" };\r
         Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
         if (queryResult == null) {\r
             return new String[0][];\r
@@ -1517,81 +1598,7 @@ public class SurfaceAreaQuery {
             return null;\r
         }\r
 \r
-        // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns;\r
-        // String[][] result = new String[pcds.length][2];\r
-        // for (int i = 0; i < returns.length; ++i) {\r
-        // if (pcds[i].getItemType() != null) {\r
-        // result[i][1] = pcds[i].getItemType().toString();\r
-        // } else {\r
-        // result[i][1] = null;\r
-        // }\r
-        // result[i][0] = pcds[i].getCName();\r
-        // }\r
-\r
-        return null;\r
-    }\r
-\r
-    /**\r
-     * Get the PcdToken array from module's surface area document. The array\r
-     * should contains following data:\r
-     * <p>\r
-     * -------------------------------------------------------------------\r
-     * </p>\r
-     * <p>\r
-     * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText\r
-     * </p>\r
-     * <p>\r
-     * -------------------------------------------------------------------\r
-     * </p>\r
-     * <p>\r
-     * Note: Until new schema applying, now we can only get CName, ItemType,\r
-     * </p>\r
-     * \r
-     * @return 2-array table contains all information of PCD token retrieved\r
-     *         from MSA.\r
-     */\r
-    public static Object[][] etModulePCDTokenArray() {\r
         return null;\r
-        // int index;\r
-        // Object[][] result;\r
-        // PCDs.PcdData[] pcds;\r
-        // String[] xPath = new String[] { "/PcdData" };\r
-        // Object[] returns = get("PCDs", xPath);\r
-        //\r
-        // if ((returns == null) || (returns.length == 0)) {\r
-        // return null;\r
-        // }\r
-        //\r
-        // pcds = (PCDs.PcdData[]) returns;\r
-        // result = new Object[pcds.length][6];\r
-        // for (index = 0; index < pcds.length; index++) {\r
-        // //\r
-        // // Get CName\r
-        // //\r
-        // result[index][0] = pcds[index].getCName();\r
-        // //\r
-        // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE,\r
-        // // DYNAMIC, DYNAMIC_EX\r
-        // //\r
-        // if (pcds[index].getItemType() != null) {\r
-        // result[index][1] = pcds[index].getItemType().toString();\r
-        // } else {\r
-        // result[index][1] = null;\r
-        // }\r
-        //\r
-        // //\r
-        // // BUGBUG: following field can *not* be got from current MSA until\r
-        // // schema changed.\r
-        // //\r
-        // // result [index][2] = pcds[index].getTokenSpaceName();\r
-        // result[index][2] = null;\r
-        // result[index][3] = pcds[index].getDefaultValue();\r
-        // // result [index][4] = pcds[index].getUsage ();\r
-        // result[index][4] = null;\r
-        // // result [index][5] = pcds[index].getHelpText ();\r
-        // result[index][5] = null;\r
-        // }\r
-        // return result;\r
     }\r
 \r
     /**\r
@@ -1646,9 +1653,8 @@ public class SurfaceAreaQuery {
 \r
         String[] specificationList = new String[queryResult.length];\r
         for (int i = 0; i < queryResult.length; i++) {\r
-            // specificationList[i] = ((SpecificationDocument.Specification)\r
-            // queryResult[i])\r
-            // .getStringValue();\r
+             specificationList[i] = ((Sentence)queryResult[i])\r
+             .getStringValue();\r
         }\r
         return specificationList;\r
     }\r
@@ -1714,7 +1720,7 @@ public class SurfaceAreaQuery {
         if (returns == null) {\r
             return packageIncludeMap;\r
         }\r
-//        GlobalData.log.info("" + returns[0].getClass().getName());\r
+\r
         for (int i = 0; i < returns.length; i++) {\r
             PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i];\r
             packageIncludeMap.put(includeHeader.getModuleType().toString(),\r
@@ -1764,7 +1770,10 @@ public class SurfaceAreaQuery {
             String[] guidPair = new String[2];\r
             guidPair[0] = entry.getCName();\r
             guidPair[1] = entry.getGuidValue();\r
-            guidDeclMap.put(entry.getName(), guidPair);\r
+            guidDeclMap.put(entry.getCName(), guidPair);\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[0]);\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[1]);\r
         }\r
         return guidDeclMap;\r
     }\r
@@ -1792,7 +1801,10 @@ public class SurfaceAreaQuery {
 \r
             protocolPair[0] = entry.getCName();\r
             protocolPair[1] = entry.getGuidValue();\r
-            protoclMap.put(entry.getName(), protocolPair);\r
+            protoclMap.put(entry.getCName(), protocolPair);\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[0]);\r
+            EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[1]);\r
         }\r
         return protoclMap;\r
     }\r
@@ -1824,36 +1836,11 @@ public class SurfaceAreaQuery {
             String[] ppiPair = new String[2];\r
             ppiPair[0] = entry.getCName();\r
             ppiPair[1] = entry.getGuidValue();\r
-            ppiMap.put(entry.getName(), ppiPair);\r
+            ppiMap.put(entry.getCName(), ppiPair);\r
         }\r
         return ppiMap;\r
     }\r
 \r
-    /**\r
-     * getToolChainFamily\r
-     * \r
-     * This function is to retrieve ToolChainFamily attribute of FPD\r
-     * <BuildOptions>\r
-     * \r
-     * @param\r
-     * @return toolChainFamily If find toolChainFamily attribute in\r
-     *         <BuildOptions> Null If don't have toolChainFamily in\r
-     *         <BuildOptions>.\r
-     */\r
-    public String getToolChainFamily() {\r
-        String toolChainFamily;\r
-        String[] xPath = new String[] { "/BuildOptions" };\r
-\r
-        Object[] result = get("PlatformSurfaceArea", xPath);\r
-        if (result == null) {\r
-            return null;\r
-        }\r
-        // toolChainFamily =\r
-        // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies();\r
-        // return toolChainFamily;\r
-        return null;\r
-    }\r
-\r
     /**\r
      * Retrieve module Guid string\r
      * \r
@@ -1885,4 +1872,66 @@ public class SurfaceAreaQuery {
         return new ModuleSADocument.ModuleSA[0];\r
 \r
     }\r
+    /**\r
+    Get name array of PCD in a module. In one module, token space\r
+    is same, and token name should not be conflicted.\r
+    \r
+    @return String[]\r
+    **/\r
+    public static String[] getModulePcdEntryNameArray() {\r
+        PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries  = null;\r
+        String[]            results;\r
+        int                 index;\r
+        String[]            xPath       = new String[] {"/PcdEntry"};\r
+        Object[]         returns     = get ("PcdCoded", xPath);\r
+\r
+        if (returns == null) {\r
+            return new String[0];\r
+        }\r
+\r
+        pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns;\r
+        results    = new String[pcdEntries.length];\r
+\r
+        for (index = 0; index < pcdEntries.length; index ++) {\r
+            results[index] = pcdEntries[index].getCName();\r
+        }\r
+        return results;\r
+    }\r
+\r
+    /**\r
+     Search in a List for a given string\r
+\r
+     @return boolean\r
+     **/\r
+    public static boolean contains(List list, String str) {\r
+               if (list == null || list.size()== 0) {\r
+                       return true;\r
+               }\r
+        Iterator it = list.iterator();\r
+        while (it.hasNext()) {\r
+            String s = (String)it.next();\r
+            if (s.equalsIgnoreCase(str)) {\r
+                return true;\r
+            }\r
+        }\r
+\r
+        return false;\r
+    }\r
+\r
+       public static boolean isHaveTianoR8FlashMap(){\r
+        String[]            xPath       = new String[] {"/"};\r
+        Object[]         returns     = get ("Externs", xPath);\r
+\r
+        if (returns == null) {\r
+            return false;\r
+        }\r
+\r
+               ExternsDocument.Externs ext = (ExternsDocument.Externs)returns[0];\r
+               \r
+               if (ext.getTianoR8FlashMapH()){\r
+                       return true;\r
+           }else {\r
+                       return false;\r
+               }\r
+       }\r
 }\r