]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / SurfaceAreaQuery.java
index 93727dbfc432c0e1b64d8cfd9ee85c89b93dec2e..0140e8b704614bee058546f39c659935760ae256 100644 (file)
@@ -23,50 +23,23 @@ import java.util.Stack;
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
 \r
-import org.w3c.dom.Node;\r
-\r
+import org.tianocore.ExternsDocument.Externs.Extern;\r
 import org.apache.xmlbeans.XmlObject;\r
 import org.apache.xmlbeans.XmlString;\r
-\r
-import org.tianocore.BuildOptionsDocument;\r
-import org.tianocore.CNameType;\r
-import org.tianocore.ExternsDocument;\r
-import org.tianocore.FileNameConvention;\r
-import org.tianocore.FvImagesDocument;\r
-import org.tianocore.GuidDeclarationsDocument;\r
-import org.tianocore.GuidsDocument;\r
-import org.tianocore.LibrariesDocument;\r
-import org.tianocore.LibraryClassDeclarationsDocument;\r
-import org.tianocore.LibraryClassDocument;\r
-import org.tianocore.ModuleDefinitionsDocument;\r
-import org.tianocore.ModuleSADocument;\r
-import org.tianocore.ModuleSaBuildOptionsDocument;\r
-import org.tianocore.ModuleTypeDef;\r
-import org.tianocore.MsaFilesDocument;\r
-import org.tianocore.MsaHeaderDocument;\r
-import org.tianocore.OptionDocument;\r
-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.UserExtensionsDocument;\r
+import org.tianocore.*;\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
-\r
-import org.tianocore.common.logger.EdkLog;\r
+import org.tianocore.build.autogen.CommonDefinition;\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.common.exception.EdkException;\r
+import org.tianocore.common.logger.EdkLog;\r
+import org.w3c.dom.Node;\r
 \r
 /**\r
  * SurfaceAreaQuery class is used to query Surface Area information from msa,\r
@@ -78,33 +51,36 @@ import org.tianocore.build.toolchain.ToolChainInfo;
  */\r
 public class SurfaceAreaQuery {\r
 \r
-    public static String prefix = "http://www.TianoCore.org/2006/Edk2.0";\r
+    public String prefix = "http://www.TianoCore.org/2006/Edk2.0";\r
 \r
-    // /\r
-    // Contains name/value pairs of Surface Area document object. The name is\r
-    // always the top level element name.\r
-    // /\r
-    private static Map<String, XmlObject> map = null;\r
+    //\r
+    // Contains name/value pairs of Surface Area document object. The name is\r
+    // always the top level element name.\r
+    //\r
+    private Map<String, XmlObject> map = null;\r
 \r
-    // /\r
-    // mapStack is used to do nested query\r
-    // /\r
-    private static Stack<Map<String, XmlObject>> mapStack = new Stack<Map<String, XmlObject>>();\r
+    //\r
+    // mapStack is used to do nested query\r
+    //\r
+    private Stack<Map<String, XmlObject>> mapStack = new Stack<Map<String, XmlObject>>();\r
 \r
-    // /\r
-    // prefix of name space\r
-    // /\r
-    private static String nsPrefix = "sans";\r
+    //\r
+    // prefix of name space\r
+    //\r
+    private String nsPrefix = "sans";\r
 \r
-    // /\r
-    // xmlbeans needs a name space for each Xpath element\r
-    // /\r
-    private static String ns = null;\r
+    //\r
+    // xmlbeans needs a name space for each Xpath element\r
+    //\r
+    private String ns = null;\r
 \r
-    // /\r
-    // / keep the namep declaration for xmlbeans Xpath query\r
-    // /\r
-    private static String queryDeclaration = null;\r
+    //\r
+    // keep the namep declaration for xmlbeans Xpath query\r
+    //\r
+    private String queryDeclaration = null;\r
+\r
+    private StringBuffer normQueryString = new StringBuffer(4096);\r
+    private Pattern xPathPattern = Pattern.compile("([^/]*)(/|//)([^/]+)");\r
 \r
     /**\r
      * Set a Surface Area document for query later\r
@@ -113,10 +89,10 @@ public class SurfaceAreaQuery {
      *            A Surface Area document in TopLevelElementName/XmlObject\r
      *            format.\r
      */\r
-    public static void setDoc(Map<String, XmlObject> map) {\r
+    public SurfaceAreaQuery(Map<String, XmlObject> map) {\r
         ns = prefix;\r
         queryDeclaration = "declare namespace " + nsPrefix + "='" + ns + "'; ";\r
-        SurfaceAreaQuery.map = map;\r
+        this.map = map;\r
     }\r
 \r
     /**\r
@@ -128,17 +104,17 @@ public class SurfaceAreaQuery {
      *            The TopLevelElementName/XmlObject format of a Surface Area\r
      *            document.\r
      */\r
-    public static void push(Map<String, XmlObject> newMap) {\r
-        mapStack.push(SurfaceAreaQuery.map);\r
-        SurfaceAreaQuery.map = newMap;\r
+    public void push(Map<String, XmlObject> newMap) {\r
+        mapStack.push(this.map);\r
+        this.map = newMap;\r
     }\r
 \r
     /**\r
      * Discard current used Surface Area document and use the top document in\r
      * stack instead.\r
      */\r
-    public static void pop() {\r
-        SurfaceAreaQuery.map = mapStack.pop();\r
+    public void pop() {\r
+        this.map = mapStack.pop();\r
     }\r
 \r
     // /\r
@@ -147,14 +123,13 @@ public class SurfaceAreaQuery {
     // / selectPath(). For example, converting /MsaHeader/ModuleType to\r
     // / /ns:MsaHeader/ns:ModuleType\r
     // /\r
-    private static String normalizeQueryString(String[] exp, String from) {\r
-        StringBuffer normQueryString = new StringBuffer(4096);\r
+    private String normalizeQueryString(String[] exp, String from) {\r
+        normQueryString.setLength(0);\r
 \r
         int i = 0;\r
         while (i < exp.length) {\r
             String newExp = from + exp[i];\r
-            Pattern pattern = Pattern.compile("([^/]*)(/|//)([^/]+)");\r
-            Matcher matcher = pattern.matcher(newExp);\r
+            Matcher matcher = xPathPattern.matcher(newExp);\r
 \r
             while (matcher.find()) {\r
                 String starter = newExp.substring(matcher.start(1), matcher\r
@@ -190,7 +165,7 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns NULL if nothing is at the specified xpath\r
      */\r
-    public static Object[] get(String[] xPath) {\r
+    public Object[] get(String[] xPath) {\r
         if (map == null) {\r
             return null;\r
         }\r
@@ -230,7 +205,7 @@ public class SurfaceAreaQuery {
      * @returns An array of XmlObject if elements are found at the given xpath\r
      * @returns NULL if nothing is found at the given xpath\r
      */\r
-    public static Object[] get(String rootName, String[] xPath) {\r
+    public Object[] get(String rootName, String[] xPath) {\r
         if (map == null) {\r
             return null;\r
         }\r
@@ -265,7 +240,7 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns NULL if nothing is found at the known xpath\r
      */\r
-    public static String[][] getSourceFiles(String arch) {\r
+    public String[][] getSourceFiles(String arch) {\r
         String[] xPath;\r
         Object[] returns;\r
 \r
@@ -300,7 +275,7 @@ public class SurfaceAreaQuery {
      * @returns Directory names array if elements are found at the known xpath\r
      * @returns Empty if nothing is found at the known xpath\r
      */\r
-    public static String getFpdOutputDirectory() {\r
+    public String getFpdOutputDirectory() {\r
         String[] xPath = new String[] { "/PlatformDefinitions" };\r
 \r
         Object[] returns = get("PlatformSurfaceArea", xPath);\r
@@ -311,7 +286,7 @@ public class SurfaceAreaQuery {
         return item.getOutputDirectory();\r
     }\r
 \r
-    public static String getFpdIntermediateDirectories() {\r
+    public String getFpdIntermediateDirectories() {\r
         String[] xPath = new String[] { "/PlatformDefinitions" };\r
 \r
         Object[] returns = get("PlatformSurfaceArea", xPath);\r
@@ -327,7 +302,7 @@ public class SurfaceAreaQuery {
         }\r
     }\r
 \r
-    public static String getModuleFfsKeyword() {\r
+    public String getModuleFfsKeyword() {\r
         String[] xPath = new String[] { "/" };\r
 \r
         Object[] returns = get("ModuleSaBuildOptions", xPath);\r
@@ -338,7 +313,7 @@ public class SurfaceAreaQuery {
         return item.getFfsFormatKey();\r
     }\r
 \r
-    public static String getModuleFvBindingKeyword() {\r
+    public String getModuleFvBindingKeyword() {\r
         String[] xPath = new String[] { "/" };\r
 \r
         Object[] returns = get("ModuleSaBuildOptions", xPath);\r
@@ -349,7 +324,7 @@ public class SurfaceAreaQuery {
         return item.getFvBinding();\r
     }\r
 \r
-    public static List getModuleSupportedArchs() {\r
+    public List getModuleSupportedArchs() {\r
         String[] xPath = new String[] { "/" };\r
 \r
         Object[] returns = get("ModuleDefinitions", xPath);\r
@@ -360,7 +335,7 @@ public class SurfaceAreaQuery {
         return item.getSupportedArchitectures();\r
     }\r
 \r
-    public static BuildOptionsDocument.BuildOptions.Ffs[] getFpdFfs() {\r
+    public BuildOptionsDocument.BuildOptions.Ffs[] getFpdFfs() {\r
         String[] xPath = new String[] {"/Ffs"};\r
 \r
         Object[] returns = get("BuildOptions", xPath);\r
@@ -370,7 +345,7 @@ public class SurfaceAreaQuery {
         return (BuildOptionsDocument.BuildOptions.Ffs[])returns;\r
     }\r
 \r
-    public static String getModuleOutputFileBasename() {\r
+    public String getModuleOutputFileBasename() {\r
         String[] xPath = new String[] { "/" };\r
 \r
         Object[] returns = get("ModuleDefinitions", xPath);\r
@@ -394,7 +369,7 @@ public class SurfaceAreaQuery {
      *\r
      * @returns Empty array if nothing is there\r
      */\r
-    public static String[][] getOptions(String from, String[] xPath, boolean toolChainFamilyFlag) {\r
+    public String[][] getOptions(String from, String[] xPath, boolean toolChainFamilyFlag) {\r
         String target = null;\r
         String toolchain = null;\r
         String toolchainFamily = null;\r
@@ -478,7 +453,7 @@ public class SurfaceAreaQuery {
         return result;\r
     }\r
 \r
-    public static String[][] getModuleBuildOptions(boolean toolChainFamilyFlag) {\r
+    public String[][] getModuleBuildOptions(boolean toolChainFamilyFlag) {\r
         String[] xPath;\r
 \r
         if (toolChainFamilyFlag == true) {\r
@@ -493,7 +468,7 @@ public class SurfaceAreaQuery {
         return getOptions("ModuleSaBuildOptions", xPath, toolChainFamilyFlag);\r
     }\r
 \r
-    public static String[][] getPlatformBuildOptions(boolean toolChainFamilyFlag) {\r
+    public String[][] getPlatformBuildOptions(boolean toolChainFamilyFlag) {\r
         String[] xPath;\r
 \r
         if (toolChainFamilyFlag == true) {\r
@@ -509,7 +484,7 @@ public class SurfaceAreaQuery {
         return getOptions("PlatformSurfaceArea", xPath, toolChainFamilyFlag);\r
     }\r
 \r
-    public static ToolChainInfo getFpdToolChainInfo() {\r
+    public ToolChainInfo getFpdToolChainInfo() {\r
         String[] xPath = new String[] { "/PlatformDefinitions" };\r
 \r
         Object[] returns = get("PlatformSurfaceArea", xPath);\r
@@ -531,7 +506,7 @@ public class SurfaceAreaQuery {
      * @returns The module type name if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String getModuleType() {\r
+    public String getModuleType() {\r
         String[] xPath = new String[] { "/ModuleType" };\r
 \r
         Object[] returns = get(xPath);\r
@@ -552,7 +527,7 @@ public class SurfaceAreaQuery {
      * @returns package name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static PackageIdentification[] getDependencePkg(String arch) {\r
+    public PackageIdentification[] getDependencePkg(String arch) throws EdkException {\r
         String[] xPath;\r
         String packageGuid = null;\r
         String packageVersion = null;\r
@@ -575,19 +550,13 @@ public class SurfaceAreaQuery {
             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
+                PackageIdentification pkgId = new PackageIdentification(null, packageGuid, packageVersion);\r
+                GlobalData.refreshPackageIdentification(pkgId);\r
+                packageIdList.add(pkgId);\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 packageIdArray;\r
+        return packageIdList.toArray(new PackageIdentification[packageIdList.size()]);\r
     }\r
 \r
     /**\r
@@ -600,7 +569,7 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getLibraryClasses(String usage, String arch) {\r
+    public String[] getLibraryClasses(String usage, String arch) {\r
         String[] xPath;\r
         if (usage == null || usage.equals("")) {\r
             xPath = new String[] { "/LibraryClass" };\r
@@ -622,10 +591,9 @@ public class SurfaceAreaQuery {
                 libraryClassName.add(libraryClassList[i].getKeyword());\r
                        }\r
         }\r
-               String[] libraryArray = new String[libraryClassName.size()];\r
-               for (int i = 0; i < libraryClassName.size(); i++) {\r
-                       libraryArray[i] = libraryClassName.get(i);\r
-               }\r
+\r
+        String[] libraryArray = new String[libraryClassName.size()];\r
+        libraryClassName.toArray(libraryArray);\r
         return libraryArray;\r
     }\r
 \r
@@ -636,7 +604,7 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getModuleEntryPointArray() {\r
+    public String[] getModuleEntryPointArray() {\r
         String[] xPath = new String[] { "/Extern/ModuleEntryPoint" };\r
 \r
         Object[] returns = get("Externs", xPath);\r
@@ -663,7 +631,7 @@ public class SurfaceAreaQuery {
      * @returns Protocol String list if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
-    public static String[] getProtocolArray(String arch, String usage) {\r
+    public String[] getProtocolArray(String arch, String usage) {\r
         String[] xPath;\r
         String usageXpath = "";\r
         String archXpath = "";\r
@@ -703,7 +671,7 @@ public class SurfaceAreaQuery {
      * @returns Protocol String list if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
-    public static String[] getProtocolArray(String arch) {\r
+    public String[] getProtocolArray(String arch) {\r
         String[] xPath;\r
 \r
         if (arch == null || arch.equals("")) {\r
@@ -742,7 +710,7 @@ public class SurfaceAreaQuery {
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
-    public static String[] getProtocolNotifyArray(String arch) {\r
+    public String[] getProtocolNotifyArray(String arch) {\r
         String[] xPath;\r
 \r
         if (arch == null || arch.equals("")) {\r
@@ -781,7 +749,7 @@ public class SurfaceAreaQuery {
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
-    public static String[] getProtocolNotifyArray(String arch, String usage) {\r
+    public String[] getProtocolNotifyArray(String arch, String usage) {\r
 \r
         String[] xPath;\r
         String usageXpath;\r
@@ -819,7 +787,7 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getModuleUnloadImageArray() {\r
+    public String[] getModuleUnloadImageArray() {\r
         String[] xPath = new String[] { "/Extern/ModuleUnloadImage" };\r
 \r
         Object[] returns = get("Externs", xPath);\r
@@ -843,7 +811,7 @@ public class SurfaceAreaQuery {
      * @returns Extern objects list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static ExternsDocument.Externs.Extern[] getExternArray() {\r
+    public ExternsDocument.Externs.Extern[] getExternArray() {\r
         String[] xPath = new String[] { "/Extern" };\r
 \r
         Object[] returns = get("Externs", xPath);\r
@@ -863,7 +831,7 @@ public class SurfaceAreaQuery {
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
-    public static String[] getPpiNotifyArray(String arch) {\r
+    public String[] getPpiNotifyArray(String arch) {\r
         String[] xPath;\r
 \r
         if (arch == null || arch.equals("")) {\r
@@ -904,7 +872,7 @@ public class SurfaceAreaQuery {
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
-    public static String[] getPpiNotifyArray(String arch, String usage) {\r
+    public String[] getPpiNotifyArray(String arch, String usage) {\r
 \r
         String[] xPath;\r
         String usageXpath;\r
@@ -944,7 +912,7 @@ public class SurfaceAreaQuery {
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
-    public static String[] getPpiArray(String arch) {\r
+    public String[] getPpiArray(String arch) {\r
         String[] xPath;\r
 \r
         if (arch == null || arch.equals("")) {\r
@@ -983,7 +951,7 @@ public class SurfaceAreaQuery {
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
-    public static String[] getPpiArray(String arch, String usage) {\r
+    public String[] getPpiArray(String arch, String usage) {\r
 \r
         String[] xPath;\r
         String usageXpath;\r
@@ -1023,7 +991,7 @@ public class SurfaceAreaQuery {
      * @returns GuidEntry objects list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getGuidEntryArray(String arch) {\r
+    public String[] getGuidEntryArray(String arch) {\r
         String[] xPath;\r
 \r
         if (arch == null || arch.equals("")) {\r
@@ -1062,7 +1030,7 @@ public class SurfaceAreaQuery {
      * @returns GuidEntry objects list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getGuidEntryArray(String arch, String usage) {\r
+    public String[] getGuidEntryArray(String arch, String usage) {\r
         String[] xPath;\r
         String archXpath;\r
         String usageXpath;\r
@@ -1104,7 +1072,7 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static ModuleIdentification[] getLibraryInstance(String arch) {\r
+    public ModuleIdentification[] getLibraryInstance(String arch) throws EdkException {\r
         String[] xPath;\r
         String saGuid = null;\r
         String saVersion = null;\r
@@ -1141,7 +1109,9 @@ public class SurfaceAreaQuery {
                     saVersion);\r
             PackageIdentification pkgId = new PackageIdentification(null,\r
                     pkgGuid, pkgVersion);\r
+            GlobalData.refreshPackageIdentification(pkgId);\r
             saId.setPackage(pkgId);\r
+            GlobalData.refreshModuleIdentification(saId);\r
 \r
             saIdList[i] = saId;\r
 \r
@@ -1153,7 +1123,7 @@ public class SurfaceAreaQuery {
     // / This method is used for retrieving the elements information which has\r
     // / CName sub-element\r
     // /\r
-    private static String[] getCNames(String from, String xPath[]) {\r
+    private String[] getCNames(String from, String xPath[]) {\r
         Object[] returns = get(from, xPath);\r
         if (returns == null || returns.length == 0) {\r
             return null;\r
@@ -1174,7 +1144,7 @@ public class SurfaceAreaQuery {
      * @returns constructor name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String getLibConstructorName() {\r
+    public String getLibConstructorName() {\r
         String[] xPath = new String[] { "/Extern/Constructor" };\r
 \r
         Object[] returns = get("Externs", xPath);\r
@@ -1192,7 +1162,7 @@ public class SurfaceAreaQuery {
      * @returns destructor name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String getLibDestructorName() {\r
+    public String getLibDestructorName() {\r
         String[] xPath = new String[] { "/Extern/Destructor" };\r
 \r
         Object[] returns = get("Externs", xPath);\r
@@ -1213,7 +1183,7 @@ public class SurfaceAreaQuery {
      * @returns DriverBinding name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getDriverBindingArray() {\r
+    public String[] getDriverBindingArray() {\r
         String[] xPath = new String[] { "/Extern/DriverBinding" };\r
         return getCNames("Externs", xPath);\r
     }\r
@@ -1224,7 +1194,7 @@ public class SurfaceAreaQuery {
      * @returns ComponentName name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getComponentNameArray() {\r
+    public String[] getComponentNameArray() {\r
         String[] xPath = new String[] { "/Extern/ComponentName" };\r
         return getCNames("Externs", xPath);\r
     }\r
@@ -1235,7 +1205,7 @@ public class SurfaceAreaQuery {
      * @returns DriverConfig name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getDriverConfigArray() {\r
+    public String[] getDriverConfigArray() {\r
         String[] xPath = new String[] { "/Extern/DriverConfig" };\r
         return getCNames("Externs", xPath);\r
     }\r
@@ -1246,11 +1216,67 @@ public class SurfaceAreaQuery {
      * @returns DriverDiag name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getDriverDiagArray() {\r
+    public String[] getDriverDiagArray() {\r
         String[] xPath = new String[] { "/Extern/DriverDiag" };\r
         return getCNames("Externs", xPath);\r
     }\r
 \r
+    /**\r
+     * Retrive DriverBinding, ComponentName, DriverConfig,\r
+     * DriverDiag group array\r
+     * \r
+     * @returns DriverBinding group name list if elements are found\r
+     *        at the known xpath\r
+     * @returns null if nothing is there\r
+     */\r
+       public String[][] getExternProtocolGroup() {\r
+               String[] xPath = new String[] {"/Extern"};\r
+               Object[] returns = get("Externs",xPath);\r
+\r
+        if (returns == null) {\r
+                       return new String[0][4];\r
+               }\r
+               List<Extern> externList = new ArrayList<Extern>();\r
+               for (int i = 0; i < returns.length; i++) {\r
+                       org.tianocore.ExternsDocument.Externs.Extern extern = (org.tianocore.ExternsDocument.Externs.Extern)returns[i];\r
+                       if (extern.getDriverBinding() != null) {\r
+                               externList.add(extern);\r
+                       }\r
+               }\r
+\r
+               String[][] externGroup = new String[externList.size()][4];\r
+               for (int i = 0; i < externList.size(); i++) {\r
+            String driverBindingStr = externList.get(i).getDriverBinding();\r
+                       if ( driverBindingStr != null){\r
+                               externGroup[i][0] = driverBindingStr;\r
+                       } else {\r
+                               externGroup[i][0] = null;\r
+                       }\r
+\r
+                       String componentNameStr = externList.get(i).getComponentName();\r
+                       if (componentNameStr != null) {\r
+                               externGroup[i][1] = componentNameStr;\r
+                       } else {\r
+                               externGroup[i][1] = null;\r
+                       }\r
+\r
+                       String driverConfigStr = externList.get(i).getDriverConfig();\r
+                       if (driverConfigStr != null) {\r
+                               externGroup[i][2] = driverConfigStr;\r
+                       } else {\r
+                               externGroup[i][2] = null;\r
+                       }\r
+\r
+                       String driverDiagStr = externList.get(i).getDriverDiag();\r
+                       if (driverDiagStr != null) {\r
+                           externGroup[i][3] = driverDiagStr;\r
+                       } else {\r
+                               externGroup[i][3] = null;\r
+                       }\r
+               }\r
+               return externGroup;\r
+       }\r
+    \r
     /**\r
      * Retrive SetVirtualAddressMapCallBack names\r
      *\r
@@ -1258,7 +1284,7 @@ public class SurfaceAreaQuery {
      *          the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getSetVirtualAddressMapCallBackArray() {\r
+    public String[] getSetVirtualAddressMapCallBackArray() {\r
         String[] xPath = new String[] { "/Extern/SetVirtualAddressMapCallBack" };\r
         return getCNames("Externs", xPath);\r
     }\r
@@ -1270,18 +1296,42 @@ public class SurfaceAreaQuery {
      *          known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[] getExitBootServicesCallBackArray() {\r
+    public String[] getExitBootServicesCallBackArray() {\r
         String[] xPath = new String[] { "/Extern/ExitBootServicesCallBack" };\r
         return getCNames("Externs", xPath);\r
     }\r
 \r
+    /**\r
+      Judge whether current driver is PEI_PCD_DRIVER or DXE_PCD_DRIVER or\r
+      NOT_PCD_DRIVER.\r
+      \r
+      @return CommonDefinition.PCD_DRIVER_TYPE  the type of current driver\r
+    **/\r
+    public CommonDefinition.PCD_DRIVER_TYPE getPcdDriverType() {\r
+        String[] xPath   = new String[] {"/PcdIsDriver"};\r
+        Object[] results = get ("Externs", xPath);\r
+\r
+        if (results != null && results.length != 0) {\r
+            PcdDriverTypes type     = (PcdDriverTypes) results[0];\r
+            String         typeStr  = type.enumValue().toString();\r
+            if (typeStr.equals(CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER.toString())) {\r
+                return CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER;\r
+            } else if (typeStr.equals(CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER.toString())) {\r
+                return CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER;\r
+            }\r
+            return CommonDefinition.PCD_DRIVER_TYPE.UNKNOWN_PCD_DRIVER;\r
+        }\r
+\r
+        return CommonDefinition.PCD_DRIVER_TYPE.NOT_PCD_DRIVER;\r
+    }\r
+\r
     /**\r
      * Retrieve module surface area file information\r
      *\r
      * @returns ModuleSA objects list if elements are found at the known xpath\r
      * @returns Empty ModuleSA list if nothing is there\r
      */\r
-    public static Map<FpdModuleIdentification, Map<String, XmlObject>> getFpdModules() {\r
+    public Map<FpdModuleIdentification, Map<String, XmlObject>> getFpdModules() throws EdkException {\r
         String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r
         Object[] result = get("PlatformSurfaceArea", xPath);\r
         String arch = null;\r
@@ -1335,9 +1385,13 @@ public class SurfaceAreaQuery {
             // identification.\r
             //\r
             PackageIdentification pkgId = new PackageIdentification(null, pkgGuid, pkgVersion);\r
+            GlobalData.refreshPackageIdentification(pkgId);\r
+            \r
             ModuleIdentification saId = new ModuleIdentification(null, saGuid, saVersion);\r
-\r
             saId.setPackage(pkgId);\r
+            GlobalData.refreshModuleIdentification(saId);\r
+            \r
+\r
 \r
             //\r
             // Create FpdModule Identification which have class member of module\r
@@ -1372,7 +1426,7 @@ public class SurfaceAreaQuery {
      * @returns valid iamges name list if elements are found at the known xpath\r
      * @returns empty list if nothing is there\r
      */\r
-    public static String[] getFpdValidImageNames() {\r
+    public String[] getFpdValidImageNames() {\r
         String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };\r
 \r
         Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
@@ -1388,7 +1442,7 @@ public class SurfaceAreaQuery {
         return result;\r
     }\r
 \r
-    public static Node getFpdUserExtensionPreBuild() {\r
+    public Node getFpdUserExtensionPreBuild() {\r
         String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" };\r
 \r
         Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
@@ -1400,7 +1454,7 @@ public class SurfaceAreaQuery {
         return a.getDomNode();\r
     }\r
 \r
-    public static Node getFpdUserExtensionPostBuild() {\r
+    public Node getFpdUserExtensionPostBuild() {\r
         String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" };\r
 \r
         Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
@@ -1421,7 +1475,7 @@ public class SurfaceAreaQuery {
      * @returns option name/value list if elements are found at the known xpath\r
      * @returns empty list if nothing is there\r
      */\r
-    public static String[][] getFpdOptions(String fvName) {\r
+    public String[][] getFpdOptions(String fvName) {\r
            String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"\r
                       + fvName + "']/FvImageOptions" };\r
            Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
@@ -1449,7 +1503,7 @@ public class SurfaceAreaQuery {
 \r
     }\r
 \r
-    public static XmlObject getFpdBuildOptions() {\r
+    public XmlObject getFpdBuildOptions() {\r
         String[] xPath = new String[] { "/BuildOptions" };\r
 \r
         Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
@@ -1460,7 +1514,7 @@ public class SurfaceAreaQuery {
         return (XmlObject)queryResult[0];\r
     }\r
 \r
-    public static PlatformIdentification getFpdHeader() {\r
+    public PlatformIdentification getFpdHeader() {\r
         String[] xPath = new String[] { "/PlatformHeader" };\r
 \r
         Object[] returns = get("PlatformSurfaceArea", xPath);\r
@@ -1489,7 +1543,7 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns empty list if nothing is there\r
      */\r
-    public static String[][] getFpdAttributes(String fvName) {\r
+    public String[][] getFpdAttributes(String fvName) {\r
         String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"\r
                          + fvName + "']/FvImageOptions" };\r
         Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
@@ -1522,7 +1576,7 @@ public class SurfaceAreaQuery {
      * @returns file name if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String getFlashDefinitionFile() {\r
+    public String getFlashDefinitionFile() {\r
         String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };\r
 \r
         Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
@@ -1534,7 +1588,7 @@ public class SurfaceAreaQuery {
         return filename.getStringValue();\r
     }\r
 \r
-    public static String[][] getFpdGlobalVariable() {\r
+    public String[][] getFpdGlobalVariable() {\r
         String[] xPath = new String[] { "/Flash/FvImages/NameValue" };\r
         Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
         if (queryResult == null) {\r
@@ -1560,7 +1614,7 @@ public class SurfaceAreaQuery {
      * @returns name/value pairs list if elements are found at the known xpath\r
      * @returns empty list if nothing is there\r
      */\r
-    public static String[][] getFpdComponents(String fvName) {\r
+    public String[][] getFpdComponents(String fvName) {\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
@@ -1593,7 +1647,7 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String[][] getPcdTokenArray() {\r
+    public String[][] getPcdTokenArray() {\r
         String[] xPath = new String[] { "/PcdData" };\r
 \r
         Object[] returns = get("PCDs", xPath);\r
@@ -1610,7 +1664,7 @@ public class SurfaceAreaQuery {
      * @return\r
      * @return\r
      */\r
-    public static ModuleIdentification getMsaHeader() {\r
+    public ModuleIdentification getMsaHeader() {\r
         String[] xPath = new String[] { "/" };\r
         Object[] returns = get("MsaHeader", xPath);\r
 \r
@@ -1646,7 +1700,7 @@ public class SurfaceAreaQuery {
      *\r
      */\r
 \r
-    public static String[] getExternSpecificaiton() {\r
+    public String[] getExternSpecificaiton() {\r
         String[] xPath = new String[] { "/Specification" };\r
 \r
         Object[] queryResult = get("Externs", xPath);\r
@@ -1669,7 +1723,7 @@ public class SurfaceAreaQuery {
      * @return String[][3] The string sequence is ModuleName, ModuleGuid,\r
      *         ModuleVersion, MsaFile String[0][] If no msafile in SPD\r
      */\r
-    public static String[] getSpdMsaFile() {\r
+    public String[] getSpdMsaFile() {\r
         String[] xPath = new String[] { "/MsaFiles" };\r
 \r
         Object[] returns = get("PackageSurfaceArea", xPath);\r
@@ -1685,7 +1739,7 @@ public class SurfaceAreaQuery {
     /**\r
      * Reteive\r
      */\r
-    public static Map<String, String[]> getSpdLibraryClasses() {\r
+    public Map<String, String[]> getSpdLibraryClasses() {\r
         String[] xPath = new String[] { "/LibraryClassDeclarations/LibraryClass" };\r
 \r
         Object[] returns = get("PackageSurfaceArea", xPath);\r
@@ -1710,7 +1764,7 @@ public class SurfaceAreaQuery {
     /**\r
      * Reteive\r
      */\r
-    public static Map<String, String> getSpdPackageHeaderFiles() {\r
+    public Map<String, String> getSpdPackageHeaderFiles() {\r
         String[] xPath = new String[] { "/PackageHeaders/IncludePkgHeader" };\r
 \r
         Object[] returns = get("PackageSurfaceArea", xPath);\r
@@ -1732,7 +1786,7 @@ public class SurfaceAreaQuery {
         return packageIncludeMap;\r
     }\r
 \r
-    public static PackageIdentification getSpdHeader() {\r
+    public PackageIdentification getSpdHeader() {\r
         String[] xPath = new String[] { "/SpdHeader" };\r
 \r
         Object[] returns = get("PackageSurfaceArea", xPath);\r
@@ -1755,7 +1809,7 @@ public class SurfaceAreaQuery {
     /**\r
      * Reteive\r
      */\r
-    public static Map<String, String[]> getSpdGuid() {\r
+    public Map<String, String[]> getSpdGuid() {\r
         String[] xPath = new String[] { "/GuidDeclarations/Entry" };\r
 \r
         Object[] returns = get("PackageSurfaceArea", xPath);\r
@@ -1784,7 +1838,7 @@ public class SurfaceAreaQuery {
     /**\r
      * Reteive\r
      */\r
-    public static Map<String, String[]> getSpdProtocol() {\r
+    public Map<String, String[]> getSpdProtocol() {\r
         String[] xPath = new String[] { "/ProtocolDeclarations/Entry" };\r
 \r
         Object[] returns = get("PackageSurfaceArea", xPath);\r
@@ -1820,7 +1874,7 @@ public class SurfaceAreaQuery {
      *         Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI\r
      *         entry in SPD.\r
      */\r
-    public static Map<String, String[]> getSpdPpi() {\r
+    public Map<String, String[]> getSpdPpi() {\r
         String[] xPath = new String[] { "/PpiDeclarations/Entry" };\r
 \r
         Object[] returns = get("PackageSurfaceArea", xPath);\r
@@ -1850,7 +1904,7 @@ public class SurfaceAreaQuery {
      * @returns GUILD string if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public static String getModuleGuid() {\r
+    public String getModuleGuid() {\r
         String[] xPath = new String[] { "" };\r
 \r
         Object[] returns = get("MsaHeader", xPath);\r
@@ -1866,7 +1920,7 @@ public class SurfaceAreaQuery {
     //\r
     // For new Pcd\r
     //\r
-    public static ModuleSADocument.ModuleSA[] getFpdModuleSAs() {\r
+    public ModuleSADocument.ModuleSA[] getFpdModuleSAs() {\r
         String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r
         Object[] result = get("PlatformSurfaceArea", xPath);\r
         if (result != null) {\r
@@ -1881,7 +1935,7 @@ public class SurfaceAreaQuery {
 \r
     @return String[]\r
     **/\r
-    public static String[] getModulePcdEntryNameArray() {\r
+    public String[] getModulePcdEntryNameArray() {\r
         PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries  = null;\r
         String[]            results;\r
         int                 index;\r
@@ -1906,7 +1960,7 @@ public class SurfaceAreaQuery {
 \r
      @return boolean\r
      **/\r
-    public static boolean contains(List list, String str) {\r
+    public boolean contains(List list, String str) {\r
                if (list == null || list.size()== 0) {\r
                        return true;\r
                }\r
@@ -1921,7 +1975,7 @@ public class SurfaceAreaQuery {
         return false;\r
     }\r
 \r
-       public static boolean isHaveTianoR8FlashMap(){\r
+       public boolean isHaveTianoR8FlashMap(){\r
         String[]            xPath       = new String[] {"/"};\r
         Object[]         returns     = get ("Externs", xPath);\r
 \r
@@ -1937,4 +1991,17 @@ public class SurfaceAreaQuery {
                        return false;\r
                }\r
        }\r
+    \r
+    public Node getFpdModuleSequence(String fvName) {\r
+        String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='IMAGES' and @Identifier='1' and ./FvName='" + fvName + "']" };\r
+        Object[] result = get("PlatformSurfaceArea", xPath);\r
+        \r
+        if (result == null || result.length == 0) {\r
+            return null;\r
+        }\r
+        \r
+        UserExtensionsDocument.UserExtensions a =  (UserExtensionsDocument.UserExtensions)result[0];\r
+        \r
+        return a.getDomNode();\r
+    }\r
 }\r