]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
Fix the track EDKT187: If a module do not use PCD, PcdLib library class need not...
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / SurfaceAreaQuery.java
index 149b30dd173e88fb7946e4b21eeb629bc55a7e25..1086bb8d498ce6940fc704274ae18431cc173714 100644 (file)
@@ -23,8 +23,11 @@ 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.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
@@ -57,20 +60,22 @@ import org.tianocore.FilenameDocument.Filename;
 import org.tianocore.MsaHeaderDocument.MsaHeader;\r
 import org.tianocore.ProtocolsDocument.Protocols.Protocol;\r
 import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
+import org.tianocore.PcdDriverTypes;\r
+\r
+import org.tianocore.common.logger.EdkLog;\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
+import org.tianocore.build.autogen.CommonDefinition;\r
 \r
 /**\r
  * SurfaceAreaQuery class is used to query Surface Area information from msa,\r
  * mbd, spd and fpd files.\r
- * \r
+ *\r
  * This class should not instantiated. All the public interfaces is static.\r
- * \r
+ *\r
  * @since GenBuild 1.0\r
  */\r
 public class SurfaceAreaQuery {\r
@@ -105,7 +110,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Set a Surface Area document for query later\r
-     * \r
+     *\r
      * @param map\r
      *            A Surface Area document in TopLevelElementName/XmlObject\r
      *            format.\r
@@ -120,7 +125,7 @@ public class SurfaceAreaQuery {
      * Push current used Surface Area document into query stack. The given new\r
      * document will be used for any immediately followed getXXX() callings,\r
      * untill pop() is called.\r
-     * \r
+     *\r
      * @param newMap\r
      *            The TopLevelElementName/XmlObject format of a Surface Area\r
      *            document.\r
@@ -180,7 +185,7 @@ public class SurfaceAreaQuery {
     /**\r
      * Search all XML documents stored in "map" for the specified xPath, using\r
      * relative path (starting with '$this')\r
-     * \r
+     *\r
      * @param xPath\r
      *            xpath query string array\r
      * @returns An array of XmlObject if elements are found at the specified\r
@@ -219,7 +224,7 @@ public class SurfaceAreaQuery {
     /**\r
      * Search XML documents named by "rootName" for the given xPath, using\r
      * relative path (starting with '$this')\r
-     * \r
+     *\r
      * @param rootName\r
      *            The top level element name\r
      * @param xPath\r
@@ -255,7 +260,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve SourceFiles/Filename for specified ARCH type\r
-     * \r
+     *\r
      * @param arch\r
      *            architecture name\r
      * @returns An 2 dimension string array if elements are found at the known\r
@@ -282,7 +287,7 @@ public class SurfaceAreaQuery {
                 outputList.add(new String[] {sourceFileNames[i].getToolCode(),sourceFileNames[i].getStringValue()});\r
             }\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
@@ -293,7 +298,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve /PlatformDefinitions/OutputDirectory from FPD\r
-     * \r
+     *\r
      * @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
@@ -317,7 +322,7 @@ public class SurfaceAreaQuery {
         }\r
         PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];\r
         if(item.getIntermediateDirectories() == null) {\r
-            return null;     \r
+            return null;\r
         }\r
         else {\r
             return item.getIntermediateDirectories().toString();\r
@@ -334,7 +339,7 @@ public class SurfaceAreaQuery {
         ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0];\r
         return item.getFfsFormatKey();\r
     }\r
-    \r
+\r
     public static String getModuleFvBindingKeyword() {\r
         String[] xPath = new String[] { "/" };\r
 \r
@@ -345,7 +350,7 @@ public class SurfaceAreaQuery {
         ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0];\r
         return item.getFvBinding();\r
     }\r
-    \r
+\r
     public static List getModuleSupportedArchs() {\r
         String[] xPath = new String[] { "/" };\r
 \r
@@ -356,17 +361,17 @@ public class SurfaceAreaQuery {
         ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0];\r
         return item.getSupportedArchitectures();\r
     }\r
-    \r
+\r
     public static BuildOptionsDocument.BuildOptions.Ffs[] getFpdFfs() {\r
         String[] xPath = new String[] {"/Ffs"};\r
-        \r
+\r
         Object[] returns = get("BuildOptions", xPath);\r
         if (returns == null || returns.length == 0) {\r
             return new BuildOptionsDocument.BuildOptions.Ffs[0];\r
         }\r
         return (BuildOptionsDocument.BuildOptions.Ffs[])returns;\r
     }\r
-    \r
+\r
     public static String getModuleOutputFileBasename() {\r
         String[] xPath = new String[] { "/" };\r
 \r
@@ -377,18 +382,18 @@ public class SurfaceAreaQuery {
         ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0];\r
         return item.getOutputFileBasename();\r
     }\r
-    \r
+\r
     /**\r
      * Retrieve BuildOptions/Option or Arch/Option\r
-     * \r
+     *\r
      * @param toolChainFamilyFlag\r
      *            if true, retrieve options for toolchain family; otherwise for\r
      *            toolchain\r
-     * \r
+     *\r
      * @returns String[][5] name, target, toolchain, arch, coommand of options\r
      *          if elements are found at the known xpath. String[0][] if dont\r
      *          find element.\r
-     * \r
+     *\r
      * @returns Empty array if nothing is there\r
      */\r
     public static String[][] getOptions(String from, String[] xPath, boolean toolChainFamilyFlag) {\r
@@ -441,7 +446,7 @@ public class SurfaceAreaQuery {
             }\r
 \r
             archList = new ArrayList<String>();\r
-            List archEnumList = option.getSupArchList();            \r
+            List archEnumList = option.getSupArchList();\r
             if (archEnumList == null) {\r
                 archList.add(null);\r
             } else {\r
@@ -477,7 +482,7 @@ public class SurfaceAreaQuery {
 \r
     public static String[][] getModuleBuildOptions(boolean toolChainFamilyFlag) {\r
         String[] xPath;\r
-        \r
+\r
         if (toolChainFamilyFlag == true) {\r
             xPath = new String[] {\r
                     "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r
@@ -488,8 +493,8 @@ public class SurfaceAreaQuery {
                     "/Options/Option[@TagName]", };\r
         }\r
         return getOptions("ModuleSaBuildOptions", xPath, toolChainFamilyFlag);\r
-    }   \r
-    \r
+    }\r
+\r
     public static String[][] getPlatformBuildOptions(boolean toolChainFamilyFlag) {\r
         String[] xPath;\r
 \r
@@ -513,7 +518,7 @@ public class SurfaceAreaQuery {
         if (returns == null || returns.length == 0) {\r
             return null;\r
         }\r
-        \r
+\r
         PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];\r
         ToolChainInfo toolChainInfo = new ToolChainInfo();\r
         toolChainInfo.addTargets(item.getBuildTargets().toString());\r
@@ -524,7 +529,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve <xxxHeader>/ModuleType\r
-     * \r
+     *\r
      * @returns The module type name if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -542,10 +547,10 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve PackageDependencies/Package\r
-     * \r
+     *\r
      * @param arch\r
      *            Architecture name\r
-     * \r
+     *\r
      * @returns package name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -554,17 +559,17 @@ public class SurfaceAreaQuery {
         String packageGuid = null;\r
         String packageVersion = null;\r
 \r
-        \r
+\r
         xPath = new String[] { "/Package" };\r
-        \r
+\r
         Object[] returns = get("PackageDependencies", xPath);\r
         if (returns == null) {\r
             return new PackageIdentification[0];\r
         }\r
 \r
         //\r
-        //  Get packageIdentification \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
@@ -579,7 +584,7 @@ public class SurfaceAreaQuery {
 \r
         //\r
         //  transfer packageIdentification list to array.\r
-        // \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
@@ -589,10 +594,10 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve LibraryClassDefinitions/LibraryClass for specified usage\r
-     * \r
+     *\r
      * @param usage\r
      *            Library class usage\r
-     * \r
+     *\r
      * @returns LibraryClass objects list if elements are found at the known\r
      *          xpath\r
      * @returns null if nothing is there\r
@@ -614,21 +619,20 @@ public class SurfaceAreaQuery {
         List<String> libraryClassName = new ArrayList<String>();\r
         for (int i = 0; i < libraryClassList.length; i++) {\r
                        List archList = libraryClassList[i].getSupArchList();\r
-                       \r
+\r
                        if (arch == null || contains(archList, arch)) {\r
                 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
     /**\r
      * Retrieve ModuleEntryPoint names\r
-     * \r
+     *\r
      * @returns ModuleEntryPoint name list if elements are found at the known\r
      *          xpath\r
      * @returns null if nothing is there\r
@@ -653,10 +657,10 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * retrieve Protocol for specified usage\r
-     * \r
+     *\r
      * @param usage\r
      *            Protocol usage arch Architecture\r
-     * \r
+     *\r
      * @returns Protocol String list if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
@@ -693,10 +697,10 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * retrieve Protocol for specified usage\r
-     * \r
+     *\r
      * @param arch\r
      *            Architecture\r
-     * \r
+     *\r
      * @returns Protocol String list if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
@@ -716,7 +720,7 @@ public class SurfaceAreaQuery {
         Protocol[] returnlList = (Protocol[]) returns;\r
 \r
         List<String> protocolList = new ArrayList<String>();\r
-        \r
+\r
         for (int i = 0; i < returns.length; i++) {\r
             List archList = returnlList[i].getSupArchList();\r
             if (archList == null || contains(archList, arch)){\r
@@ -732,10 +736,10 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve ProtocolNotify for specified usage\r
-     * \r
+     *\r
      * @param usage\r
      *            ProtocolNotify usage\r
-     * \r
+     *\r
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
@@ -754,13 +758,13 @@ public class SurfaceAreaQuery {
         }\r
 \r
         List<String> protocolNotifyList = new ArrayList<String>();\r
-        \r
+\r
         for (int i = 0; i < returns.length; i++) {\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
         String[] protocolNotifyArray = new String[protocolNotifyList.size()];\r
         for (int i = 0; i < protocolNotifyList.size(); i++) {\r
@@ -771,10 +775,10 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve ProtocolNotify for specified usage\r
-     * \r
+     *\r
      * @param usage\r
      *            ProtocolNotify usage\r
-     * \r
+     *\r
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
@@ -811,7 +815,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve ModuleUnloadImage names\r
-     * \r
+     *\r
      * @returns ModuleUnloadImage name list if elements are found at the known\r
      *          xpath\r
      * @returns null if nothing is there\r
@@ -836,7 +840,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve Extern\r
-     * \r
+     *\r
      * @returns Extern objects list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -853,10 +857,10 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve PpiNotify for specified arch\r
-     * \r
+     *\r
      * @param arch\r
      *            PpiNotify arch\r
-     * \r
+     *\r
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
@@ -874,14 +878,14 @@ public class SurfaceAreaQuery {
             return new String[0];\r
         }\r
 \r
-        \r
+\r
         List<String> ppiNotifyList = new ArrayList<String>();\r
         for (int i = 0; i < returns.length; i++) {\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
+                ppiNotifyList.add(((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName());\r
             }\r
-            \r
+\r
         }\r
         String[] ppiNotifyArray = new String[ppiNotifyList.size()];\r
         for (int i = 0; i < ppiNotifyList.size(); i++) {\r
@@ -893,11 +897,11 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve PpiNotify for specified usage and arch\r
-     * \r
+     *\r
      * @param arch\r
      *            PpiNotify arch usage PpiNotify usage\r
-     * \r
-     * \r
+     *\r
+     *\r
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
@@ -934,10 +938,10 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve Ppi for specified arch\r
-     * \r
+     *\r
      * @param arch\r
      *            Ppi arch\r
-     * \r
+     *\r
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
@@ -959,9 +963,9 @@ public class SurfaceAreaQuery {
         for (int i = 0; i < returns.length; i++) {\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
+                ppiList.add(((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName());\r
             }\r
-            \r
+\r
         }\r
         String[] ppiArray = new String[ppiList.size()];\r
         for (int i = 0; i < ppiList.size(); i++) {\r
@@ -972,11 +976,11 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve PpiNotify for specified usage and arch\r
-     * \r
+     *\r
      * @param arch\r
      *            PpiNotify arch usage PpiNotify usage\r
-     * \r
-     * \r
+     *\r
+     *\r
      * @returns String[] if elements are found at the known xpath\r
      * @returns String[0] if nothing is there\r
      */\r
@@ -1013,10 +1017,10 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve GuidEntry information for specified usage\r
-     * \r
+     *\r
      * @param arch\r
      *            GuidEntry arch\r
-     * \r
+     *\r
      * @returns GuidEntry objects list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -1038,9 +1042,9 @@ public class SurfaceAreaQuery {
         for (int i = 0; i < returns.length; i++) {\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
+                guidList.add(((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName());\r
             }\r
-            \r
+\r
         }\r
         String[] guidArray = new String[guidList.size()];\r
         for (int i = 0; i < guidList.size(); i++) {\r
@@ -1052,10 +1056,10 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve GuidEntry information for specified usage\r
-     * \r
+     *\r
      * @param arch\r
      *            GuidEntry arch usage GuidEntry usage\r
-     * \r
+     *\r
      * @returns GuidEntry objects list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -1091,12 +1095,12 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve Library instance information\r
-     * \r
+     *\r
      * @param arch\r
      *            Architecture name\r
      * @param usage\r
      *            Library instance usage\r
-     * \r
+     *\r
      * @returns library instance name list if elements are found at the known\r
      *          xpath\r
      * @returns null if nothing is there\r
@@ -1112,7 +1116,7 @@ public class SurfaceAreaQuery {
             xPath = new String[] { "/Instance" };\r
         } else {\r
             //\r
-            // Since Schema don't have SupArchList now, so the follow Xpath is \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
@@ -1167,7 +1171,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrive library's constructor name\r
-     * \r
+     *\r
      * @returns constructor name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -1185,7 +1189,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrive library's destructor name\r
-     * \r
+     *\r
      * @returns destructor name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -1206,7 +1210,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrive DriverBinding names\r
-     * \r
+     *\r
      * @returns DriverBinding name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -1217,7 +1221,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrive ComponentName names\r
-     * \r
+     *\r
      * @returns ComponentName name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -1228,7 +1232,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrive DriverConfig names\r
-     * \r
+     *\r
      * @returns DriverConfig name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -1239,7 +1243,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrive DriverDiag names\r
-     * \r
+     *\r
      * @returns DriverDiag name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -1250,7 +1254,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrive SetVirtualAddressMapCallBack names\r
-     * \r
+     *\r
      * @returns SetVirtualAddressMapCallBack name list if elements are found at\r
      *          the known xpath\r
      * @returns null if nothing is there\r
@@ -1262,7 +1266,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrive ExitBootServicesCallBack names\r
-     * \r
+     *\r
      * @returns ExitBootServicesCallBack name list if elements are found at the\r
      *          known xpath\r
      * @returns null if nothing is there\r
@@ -1272,9 +1276,33 @@ public class SurfaceAreaQuery {
         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 static 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
+     *\r
      * @returns ModuleSA objects list if elements are found at the known xpath\r
      * @returns Empty ModuleSA list if nothing is there\r
      */\r
@@ -1304,24 +1332,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
@@ -1331,10 +1359,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
@@ -1342,21 +1368,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
@@ -1364,7 +1393,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve valid image names\r
-     * \r
+     *\r
      * @returns valid iamges name list if elements are found at the known xpath\r
      * @returns empty list if nothing is there\r
      */\r
@@ -1383,43 +1412,43 @@ public class SurfaceAreaQuery {
 \r
         return result;\r
     }\r
-    \r
+\r
     public static Node getFpdUserExtensionPreBuild() {\r
-        String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" }; \r
+        String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" };\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
+\r
         return a.getDomNode();\r
     }\r
-    \r
+\r
     public static Node getFpdUserExtensionPostBuild() {\r
-        String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" }; \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
+\r
         return a.getDomNode();\r
     }\r
 \r
     /**\r
      * Retrieve FV image option information\r
-     * \r
+     *\r
      * @param fvName\r
      *            FV image name\r
-     * \r
+     *\r
      * @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
            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
@@ -1477,24 +1506,24 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve FV image attributes information\r
-     * \r
+     *\r
      * @param fvName\r
      *            FV image name\r
-     * \r
+     *\r
      * @returns attribute name/value list if elements are found at the known\r
      *          xpath\r
      * @returns empty list if nothing is there\r
      */\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
         }\r
         ArrayList<String[]> list = new ArrayList<String[]>();\r
         for (int i = 0; i < queryResult.length; i++) {\r
-            \r
+\r
             FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r
             List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item.getNameValueList();\r
             Iterator iter = namevalues.iterator();\r
@@ -1514,7 +1543,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve flash definition file name\r
-     * \r
+     *\r
      * @returns file name if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -1538,26 +1567,26 @@ public class SurfaceAreaQuery {
         }\r
 \r
         String[][] result = new String[queryResult.length][2];\r
-        \r
+\r
         for (int i = 0; i < queryResult.length; i++) {\r
             FvImagesDocument.FvImages.NameValue item = (FvImagesDocument.FvImages.NameValue)queryResult[i];\r
             result[i][0] = item.getName();\r
             result[i][1] = item.getValue();\r
         }\r
-        return result;   \r
+        return result;\r
     }\r
-    \r
+\r
     /**\r
      * Retrieve FV image component options\r
-     * \r
+     *\r
      * @param fvName\r
      *            FV image name\r
-     * \r
+     *\r
      * @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
-        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
@@ -1579,12 +1608,12 @@ public class SurfaceAreaQuery {
                result[i][0] = list.get(i)[0];\r
              result[i][1] = list.get(i)[1];\r
         }\r
-            return result;  \r
+            return result;\r
     }\r
 \r
     /**\r
      * Retrieve PCD tokens\r
-     * \r
+     *\r
      * @returns CName/ItemType pairs list if elements are found at the known\r
      *          xpath\r
      * @returns null if nothing is there\r
@@ -1602,7 +1631,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve MAS header\r
-     * \r
+     *\r
      * @return\r
      * @return\r
      */\r
@@ -1634,12 +1663,12 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retrieve Extern Specification\r
-     * \r
+     *\r
      * @param\r
-     * \r
+     *\r
      * @return String[] If have specification element in the <extern> String[0]\r
      *         If no specification element in the <extern>\r
-     * \r
+     *\r
      */\r
 \r
     public static String[] getExternSpecificaiton() {\r
@@ -1660,7 +1689,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * Retreive MsaFile which in SPD\r
-     * \r
+     *\r
      * @param\r
      * @return String[][3] The string sequence is ModuleName, ModuleGuid,\r
      *         ModuleVersion, MsaFile String[0][] If no msafile in SPD\r
@@ -1769,7 +1798,7 @@ 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
@@ -1800,7 +1829,7 @@ 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
@@ -1810,7 +1839,7 @@ public class SurfaceAreaQuery {
 \r
     /**\r
      * getSpdPpi() Retrieve the SPD PPI Entry\r
-     * \r
+     *\r
      * @param\r
      * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI\r
      *         Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI\r
@@ -1835,14 +1864,14 @@ 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
      * Retrieve module Guid string\r
-     * \r
+     *\r
      * @returns GUILD string if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
@@ -1874,7 +1903,7 @@ public class SurfaceAreaQuery {
     /**\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
+\r
     @return String[]\r
     **/\r
     public static String[] getModulePcdEntryNameArray() {\r
@@ -1916,4 +1945,21 @@ public class SurfaceAreaQuery {
 \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