X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fglobal%2FSurfaceAreaQuery.java;h=9a1ca98d189bc175e9d6d5e3f011f6e56aa71781;hp=f795e1e5212d583d6611bcb9f0eb28684324ae11;hb=d8f1335e235d080a96d2b952974f5015ad21b756;hpb=fa2da5b1c1f8f4ff193c120acbd5412732a57342 diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java index f795e1e521..9a1ca98d18 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java @@ -23,119 +23,100 @@ import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.tianocore.ExternsDocument.Externs.Extern; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlString; -import org.tianocore.BuildOptionsDocument; -import org.tianocore.CNameType; -import org.tianocore.ExternsDocument; -import org.tianocore.FileNameConvention; -import org.tianocore.FvImagesDocument; -import org.tianocore.GuidDeclarationsDocument; -import org.tianocore.GuidsDocument; -import org.tianocore.LibrariesDocument; -import org.tianocore.LibraryClassDeclarationsDocument; -import org.tianocore.LibraryClassDocument; -import org.tianocore.ModuleDefinitionsDocument; -import org.tianocore.ModuleSADocument; -import org.tianocore.ModuleSaBuildOptionsDocument; -import org.tianocore.ModuleTypeDef; -import org.tianocore.MsaFilesDocument; -import org.tianocore.MsaHeaderDocument; -import org.tianocore.OptionDocument; -import org.tianocore.PPIsDocument; -import org.tianocore.PackageDependenciesDocument; -import org.tianocore.PackageHeadersDocument; -import org.tianocore.PcdCodedDocument; -import org.tianocore.PlatformDefinitionsDocument; -import org.tianocore.PlatformHeaderDocument; -import org.tianocore.PpiDeclarationsDocument; -import org.tianocore.ProtocolDeclarationsDocument; -import org.tianocore.Sentence; -import org.tianocore.SpdHeaderDocument; -import org.tianocore.UserExtensionsDocument; +import org.tianocore.*; +import org.tianocore.ExternsDocument.Externs; import org.tianocore.FilenameDocument.Filename; +import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; import org.tianocore.MsaHeaderDocument.MsaHeader; import org.tianocore.ProtocolsDocument.Protocols.Protocol; import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify; +import org.tianocore.build.autogen.CommonDefinition; import org.tianocore.build.id.FpdModuleIdentification; import org.tianocore.build.id.ModuleIdentification; import org.tianocore.build.id.PackageIdentification; import org.tianocore.build.id.PlatformIdentification; import org.tianocore.build.toolchain.ToolChainInfo; -import org.tianocore.logger.EdkLog; +import org.tianocore.common.exception.EdkException; +import org.tianocore.common.logger.EdkLog; import org.w3c.dom.Node; /** * SurfaceAreaQuery class is used to query Surface Area information from msa, * mbd, spd and fpd files. - * + * * This class should not instantiated. All the public interfaces is static. - * + * * @since GenBuild 1.0 */ public class SurfaceAreaQuery { - public static String prefix = "http://www.TianoCore.org/2006/Edk2.0"; + public String prefix = "http://www.TianoCore.org/2006/Edk2.0"; - // / - // / Contains name/value pairs of Surface Area document object. The name is - // / always the top level element name. - // / - private static Map map = null; + // + // Contains name/value pairs of Surface Area document object. The name is + // always the top level element name. + // + private Map map = null; - // / - // / mapStack is used to do nested query - // / - private static Stack> mapStack = new Stack>(); + // + // mapStack is used to do nested query + // + private Stack> mapStack = new Stack>(); - // / - // / prefix of name space - // / - private static String nsPrefix = "sans"; + // + // prefix of name space + // + private String nsPrefix = "sans"; - // / - // / xmlbeans needs a name space for each Xpath element - // / - private static String ns = null; + // + // xmlbeans needs a name space for each Xpath element + // + private String ns = null; - // / - // / keep the namep declaration for xmlbeans Xpath query - // / - private static String queryDeclaration = null; + // + // keep the namep declaration for xmlbeans Xpath query + // + private String queryDeclaration = null; + + private StringBuffer normQueryString = new StringBuffer(4096); + private Pattern xPathPattern = Pattern.compile("([^/]*)(/|//)([^/]+)"); /** * Set a Surface Area document for query later - * + * * @param map * A Surface Area document in TopLevelElementName/XmlObject * format. */ - public static void setDoc(Map map) { + public SurfaceAreaQuery(Map map) { ns = prefix; queryDeclaration = "declare namespace " + nsPrefix + "='" + ns + "'; "; - SurfaceAreaQuery.map = map; + this.map = map; } /** * Push current used Surface Area document into query stack. The given new * document will be used for any immediately followed getXXX() callings, * untill pop() is called. - * + * * @param newMap * The TopLevelElementName/XmlObject format of a Surface Area * document. */ - public static void push(Map newMap) { - mapStack.push(SurfaceAreaQuery.map); - SurfaceAreaQuery.map = newMap; + public void push(Map newMap) { + mapStack.push(this.map); + this.map = newMap; } /** * Discard current used Surface Area document and use the top document in * stack instead. */ - public static void pop() { - SurfaceAreaQuery.map = mapStack.pop(); + public void pop() { + this.map = mapStack.pop(); } // / @@ -144,14 +125,13 @@ public class SurfaceAreaQuery { // / selectPath(). For example, converting /MsaHeader/ModuleType to // / /ns:MsaHeader/ns:ModuleType // / - private static String normalizeQueryString(String[] exp, String from) { - StringBuffer normQueryString = new StringBuffer(4096); + private String normalizeQueryString(String[] exp, String from) { + normQueryString.setLength(0); int i = 0; while (i < exp.length) { String newExp = from + exp[i]; - Pattern pattern = Pattern.compile("([^/]*)(/|//)([^/]+)"); - Matcher matcher = pattern.matcher(newExp); + Matcher matcher = xPathPattern.matcher(newExp); while (matcher.find()) { String starter = newExp.substring(matcher.start(1), matcher @@ -180,14 +160,14 @@ public class SurfaceAreaQuery { /** * Search all XML documents stored in "map" for the specified xPath, using * relative path (starting with '$this') - * + * * @param xPath * xpath query string array * @returns An array of XmlObject if elements are found at the specified * xpath * @returns NULL if nothing is at the specified xpath */ - public static Object[] get(String[] xPath) { + public Object[] get(String[] xPath) { if (map == null) { return null; } @@ -219,7 +199,7 @@ public class SurfaceAreaQuery { /** * Search XML documents named by "rootName" for the given xPath, using * relative path (starting with '$this') - * + * * @param rootName * The top level element name * @param xPath @@ -227,7 +207,7 @@ public class SurfaceAreaQuery { * @returns An array of XmlObject if elements are found at the given xpath * @returns NULL if nothing is found at the given xpath */ - public static Object[] get(String rootName, String[] xPath) { + public Object[] get(String rootName, String[] xPath) { if (map == null) { return null; } @@ -255,14 +235,14 @@ public class SurfaceAreaQuery { /** * Retrieve SourceFiles/Filename for specified ARCH type - * + * * @param arch * architecture name * @returns An 2 dimension string array if elements are found at the known * xpath * @returns NULL if nothing is found at the known xpath */ - public static String[][] getSourceFiles(String arch) { + public String[][] getSourceFiles(String arch) { String[] xPath; Object[] returns; @@ -282,7 +262,7 @@ public class SurfaceAreaQuery { outputList.add(new String[] {sourceFileNames[i].getToolCode(),sourceFileNames[i].getStringValue()}); } } - + String[][] outputString = new String[outputList.size()][2]; for (int index = 0; index < outputList.size(); index++) { outputString[index][0] = outputList.get(index)[0]; @@ -293,11 +273,11 @@ public class SurfaceAreaQuery { /** * Retrieve /PlatformDefinitions/OutputDirectory from FPD - * + * * @returns Directory names array if elements are found at the known xpath * @returns Empty if nothing is found at the known xpath */ - public static String getFpdOutputDirectory() { + public String getFpdOutputDirectory() { String[] xPath = new String[] { "/PlatformDefinitions" }; Object[] returns = get("PlatformSurfaceArea", xPath); @@ -308,7 +288,7 @@ public class SurfaceAreaQuery { return item.getOutputDirectory(); } - public static String getFpdIntermediateDirectories() { + public String getFpdIntermediateDirectories() { String[] xPath = new String[] { "/PlatformDefinitions" }; Object[] returns = get("PlatformSurfaceArea", xPath); @@ -317,14 +297,14 @@ public class SurfaceAreaQuery { } PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0]; if(item.getIntermediateDirectories() == null) { - return null; + return null; } else { return item.getIntermediateDirectories().toString(); } } - public static String getModuleFfsKeyword() { + public String getModuleFfsKeyword() { String[] xPath = new String[] { "/" }; Object[] returns = get("ModuleSaBuildOptions", xPath); @@ -334,8 +314,8 @@ public class SurfaceAreaQuery { ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0]; return item.getFfsFormatKey(); } - - public static String getModuleFvBindingKeyword() { + + public String getModuleFvBindingKeyword() { String[] xPath = new String[] { "/" }; Object[] returns = get("ModuleSaBuildOptions", xPath); @@ -345,8 +325,8 @@ public class SurfaceAreaQuery { ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0]; return item.getFvBinding(); } - - public static List getModuleSupportedArchs() { + + public List getModuleSupportedArchs() { String[] xPath = new String[] { "/" }; Object[] returns = get("ModuleDefinitions", xPath); @@ -356,18 +336,18 @@ public class SurfaceAreaQuery { ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0]; return item.getSupportedArchitectures(); } - - public static BuildOptionsDocument.BuildOptions.Ffs[] getFpdFfs() { + + public BuildOptionsDocument.BuildOptions.Ffs[] getFpdFfs() { String[] xPath = new String[] {"/Ffs"}; - + Object[] returns = get("BuildOptions", xPath); if (returns == null || returns.length == 0) { return new BuildOptionsDocument.BuildOptions.Ffs[0]; } return (BuildOptionsDocument.BuildOptions.Ffs[])returns; } - - public static String getModuleOutputFileBasename() { + + public String getModuleOutputFileBasename() { String[] xPath = new String[] { "/" }; Object[] returns = get("ModuleDefinitions", xPath); @@ -377,21 +357,21 @@ public class SurfaceAreaQuery { ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0]; return item.getOutputFileBasename(); } - + /** * Retrieve BuildOptions/Option or Arch/Option - * + * * @param toolChainFamilyFlag * if true, retrieve options for toolchain family; otherwise for * toolchain - * + * * @returns String[][5] name, target, toolchain, arch, coommand of options * if elements are found at the known xpath. String[0][] if dont * find element. - * + * * @returns Empty array if nothing is there */ - public static String[][] getOptions(String from, String[] xPath, boolean toolChainFamilyFlag) { + public String[][] getOptions(String from, String[] xPath, boolean toolChainFamilyFlag) { String target = null; String toolchain = null; String toolchainFamily = null; @@ -441,7 +421,7 @@ public class SurfaceAreaQuery { } archList = new ArrayList(); - List archEnumList = option.getSupArchList(); + List archEnumList = option.getSupArchList(); if (archEnumList == null) { archList.add(null); } else { @@ -475,9 +455,9 @@ public class SurfaceAreaQuery { return result; } - public static String[][] getModuleBuildOptions(boolean toolChainFamilyFlag) { + public String[][] getModuleBuildOptions(boolean toolChainFamilyFlag) { String[] xPath; - + if (toolChainFamilyFlag == true) { xPath = new String[] { "/Options/Option[not(@ToolChainFamily) and not(@TagName)]", @@ -488,9 +468,9 @@ public class SurfaceAreaQuery { "/Options/Option[@TagName]", }; } return getOptions("ModuleSaBuildOptions", xPath, toolChainFamilyFlag); - } - - public static String[][] getPlatformBuildOptions(boolean toolChainFamilyFlag) { + } + + public String[][] getPlatformBuildOptions(boolean toolChainFamilyFlag) { String[] xPath; if (toolChainFamilyFlag == true) { @@ -506,14 +486,14 @@ public class SurfaceAreaQuery { return getOptions("PlatformSurfaceArea", xPath, toolChainFamilyFlag); } - public static ToolChainInfo getFpdToolChainInfo() { + public ToolChainInfo getFpdToolChainInfo() { String[] xPath = new String[] { "/PlatformDefinitions" }; Object[] returns = get("PlatformSurfaceArea", xPath); if (returns == null || returns.length == 0) { return null; } - + PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0]; ToolChainInfo toolChainInfo = new ToolChainInfo(); toolChainInfo.addTargets(item.getBuildTargets().toString()); @@ -524,11 +504,11 @@ public class SurfaceAreaQuery { /** * Retrieve /ModuleType - * + * * @returns The module type name if elements are found at the known xpath * @returns null if nothing is there */ - public static String getModuleType() { + public String getModuleType() { String[] xPath = new String[] { "/ModuleType" }; Object[] returns = get(xPath); @@ -542,29 +522,29 @@ public class SurfaceAreaQuery { /** * Retrieve PackageDependencies/Package - * + * * @param arch * Architecture name - * + * * @returns package name list if elements are found at the known xpath * @returns null if nothing is there */ - public static PackageIdentification[] getDependencePkg(String arch) { + public PackageIdentification[] getDependencePkg(String arch) throws EdkException { String[] xPath; String packageGuid = null; String packageVersion = null; - + xPath = new String[] { "/Package" }; - + Object[] returns = get("PackageDependencies", xPath); if (returns == null) { return new PackageIdentification[0]; } // - // Get packageIdentification - // + // Get packageIdentification + // List packageIdList = new ArrayList(); for (int i = 0; i < returns.length; i++) { PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i]; @@ -572,32 +552,26 @@ public class SurfaceAreaQuery { if (arch == null || archList == null || contains(archList, arch)) { packageGuid = item.getPackageGuid(); packageVersion = item.getPackageVersion(); - packageIdList.add(new PackageIdentification(null, packageGuid, - packageVersion)); + PackageIdentification pkgId = new PackageIdentification(null, packageGuid, packageVersion); + GlobalData.refreshPackageIdentification(pkgId); + packageIdList.add(pkgId); } } - // - // transfer packageIdentification list to array. - // - PackageIdentification[] packageIdArray = new PackageIdentification[packageIdList.size()]; - for (int i = 0; i < packageIdList.size(); i++) { - packageIdArray[i] = new PackageIdentification(null, packageIdList.get(i).getGuid(),packageIdList.get(i).getVersion()); - } - return packageIdArray; + return packageIdList.toArray(new PackageIdentification[packageIdList.size()]); } /** * Retrieve LibraryClassDefinitions/LibraryClass for specified usage - * + * * @param usage * Library class usage - * + * * @returns LibraryClass objects list if elements are found at the known * xpath * @returns null if nothing is there */ - public static String[] getLibraryClasses(String usage, String arch) { + public String[] getLibraryClasses(String usage, String arch) { String[] xPath; if (usage == null || usage.equals("")) { xPath = new String[] { "/LibraryClass" }; @@ -614,26 +588,25 @@ public class SurfaceAreaQuery { List libraryClassName = new ArrayList(); for (int i = 0; i < libraryClassList.length; i++) { List archList = libraryClassList[i].getSupArchList(); - + if (arch == null || contains(archList, arch)) { libraryClassName.add(libraryClassList[i].getKeyword()); } } - String[] libraryArray = new String[libraryClassName.size()]; - for (int i = 0; i < libraryClassName.size(); i++) { - libraryArray[i] = libraryClassName.get(i); - } + + String[] libraryArray = new String[libraryClassName.size()]; + libraryClassName.toArray(libraryArray); return libraryArray; } /** * Retrieve ModuleEntryPoint names - * + * * @returns ModuleEntryPoint name list if elements are found at the known * xpath * @returns null if nothing is there */ - public static String[] getModuleEntryPointArray() { + public String[] getModuleEntryPointArray() { String[] xPath = new String[] { "/Extern/ModuleEntryPoint" }; Object[] returns = get("Externs", xPath); @@ -653,14 +626,14 @@ public class SurfaceAreaQuery { /** * retrieve Protocol for specified usage - * + * * @param usage * Protocol usage arch Architecture - * + * * @returns Protocol String list if elements are found at the known xpath * @returns String[0] if nothing is there */ - public static String[] getProtocolArray(String arch, String usage) { + public String[] getProtocolArray(String arch, String usage) { String[] xPath; String usageXpath = ""; String archXpath = ""; @@ -693,14 +666,14 @@ public class SurfaceAreaQuery { /** * retrieve Protocol for specified usage - * + * * @param arch * Architecture - * + * * @returns Protocol String list if elements are found at the known xpath * @returns String[0] if nothing is there */ - public static String[] getProtocolArray(String arch) { + public String[] getProtocolArray(String arch) { String[] xPath; if (arch == null || arch.equals("")) { @@ -716,7 +689,7 @@ public class SurfaceAreaQuery { Protocol[] returnlList = (Protocol[]) returns; List protocolList = new ArrayList(); - + for (int i = 0; i < returns.length; i++) { List archList = returnlList[i].getSupArchList(); if (archList == null || contains(archList, arch)){ @@ -732,14 +705,14 @@ public class SurfaceAreaQuery { /** * Retrieve ProtocolNotify for specified usage - * + * * @param usage * ProtocolNotify usage - * + * * @returns String[] if elements are found at the known xpath * @returns String[0] if nothing is there */ - public static String[] getProtocolNotifyArray(String arch) { + public String[] getProtocolNotifyArray(String arch) { String[] xPath; if (arch == null || arch.equals("")) { @@ -754,13 +727,13 @@ public class SurfaceAreaQuery { } List protocolNotifyList = new ArrayList(); - + for (int i = 0; i < returns.length; i++) { List archList = ((ProtocolNotify) returns[i]).getSupArchList(); if (archList == null || contains(archList, arch)){ protocolNotifyList.add(((ProtocolNotify) returns[i]).getProtocolNotifyCName()); } - + } String[] protocolNotifyArray = new String[protocolNotifyList.size()]; for (int i = 0; i < protocolNotifyList.size(); i++) { @@ -771,14 +744,14 @@ public class SurfaceAreaQuery { /** * Retrieve ProtocolNotify for specified usage - * + * * @param usage * ProtocolNotify usage - * + * * @returns String[] if elements are found at the known xpath * @returns String[0] if nothing is there */ - public static String[] getProtocolNotifyArray(String arch, String usage) { + public String[] getProtocolNotifyArray(String arch, String usage) { String[] xPath; String usageXpath; @@ -811,12 +784,12 @@ public class SurfaceAreaQuery { /** * Retrieve ModuleUnloadImage names - * + * * @returns ModuleUnloadImage name list if elements are found at the known * xpath * @returns null if nothing is there */ - public static String[] getModuleUnloadImageArray() { + public String[] getModuleUnloadImageArray() { String[] xPath = new String[] { "/Extern/ModuleUnloadImage" }; Object[] returns = get("Externs", xPath); @@ -836,11 +809,11 @@ public class SurfaceAreaQuery { /** * Retrieve Extern - * + * * @returns Extern objects list if elements are found at the known xpath * @returns null if nothing is there */ - public static ExternsDocument.Externs.Extern[] getExternArray() { + public ExternsDocument.Externs.Extern[] getExternArray() { String[] xPath = new String[] { "/Extern" }; Object[] returns = get("Externs", xPath); @@ -853,14 +826,14 @@ public class SurfaceAreaQuery { /** * Retrieve PpiNotify for specified arch - * + * * @param arch * PpiNotify arch - * + * * @returns String[] if elements are found at the known xpath * @returns String[0] if nothing is there */ - public static String[] getPpiNotifyArray(String arch) { + public String[] getPpiNotifyArray(String arch) { String[] xPath; if (arch == null || arch.equals("")) { @@ -874,14 +847,14 @@ public class SurfaceAreaQuery { return new String[0]; } - + List ppiNotifyList = new ArrayList(); for (int i = 0; i < returns.length; i++) { List archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList(); if (archList == null || contains(archList, arch)){ - ppiNotifyList.add(((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName()); + ppiNotifyList.add(((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName()); } - + } String[] ppiNotifyArray = new String[ppiNotifyList.size()]; for (int i = 0; i < ppiNotifyList.size(); i++) { @@ -893,15 +866,15 @@ public class SurfaceAreaQuery { /** * Retrieve PpiNotify for specified usage and arch - * + * * @param arch * PpiNotify arch usage PpiNotify usage - * - * + * + * * @returns String[] if elements are found at the known xpath * @returns String[0] if nothing is there */ - public static String[] getPpiNotifyArray(String arch, String usage) { + public String[] getPpiNotifyArray(String arch, String usage) { String[] xPath; String usageXpath; @@ -934,14 +907,14 @@ public class SurfaceAreaQuery { /** * Retrieve Ppi for specified arch - * + * * @param arch * Ppi arch - * + * * @returns String[] if elements are found at the known xpath * @returns String[0] if nothing is there */ - public static String[] getPpiArray(String arch) { + public String[] getPpiArray(String arch) { String[] xPath; if (arch == null || arch.equals("")) { @@ -959,9 +932,9 @@ public class SurfaceAreaQuery { for (int i = 0; i < returns.length; i++) { List archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList(); if (archList == null || contains(archList, arch)){ - ppiList.add(((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName()); + ppiList.add(((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName()); } - + } String[] ppiArray = new String[ppiList.size()]; for (int i = 0; i < ppiList.size(); i++) { @@ -972,15 +945,15 @@ public class SurfaceAreaQuery { /** * Retrieve PpiNotify for specified usage and arch - * + * * @param arch * PpiNotify arch usage PpiNotify usage - * - * + * + * * @returns String[] if elements are found at the known xpath * @returns String[0] if nothing is there */ - public static String[] getPpiArray(String arch, String usage) { + public String[] getPpiArray(String arch, String usage) { String[] xPath; String usageXpath; @@ -1013,14 +986,14 @@ public class SurfaceAreaQuery { /** * Retrieve GuidEntry information for specified usage - * + * * @param arch * GuidEntry arch - * + * * @returns GuidEntry objects list if elements are found at the known xpath * @returns null if nothing is there */ - public static String[] getGuidEntryArray(String arch) { + public String[] getGuidEntryArray(String arch) { String[] xPath; if (arch == null || arch.equals("")) { @@ -1038,9 +1011,9 @@ public class SurfaceAreaQuery { for (int i = 0; i < returns.length; i++) { List archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList(); if (archList == null || contains(archList, arch)){ - guidList.add(((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName()); + guidList.add(((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName()); } - + } String[] guidArray = new String[guidList.size()]; for (int i = 0; i < guidList.size(); i++) { @@ -1052,14 +1025,14 @@ public class SurfaceAreaQuery { /** * Retrieve GuidEntry information for specified usage - * + * * @param arch * GuidEntry arch usage GuidEntry usage - * + * * @returns GuidEntry objects list if elements are found at the known xpath * @returns null if nothing is there */ - public static String[] getGuidEntryArray(String arch, String usage) { + public String[] getGuidEntryArray(String arch, String usage) { String[] xPath; String archXpath; String usageXpath; @@ -1091,17 +1064,17 @@ public class SurfaceAreaQuery { /** * Retrieve Library instance information - * + * * @param arch * Architecture name * @param usage * Library instance usage - * + * * @returns library instance name list if elements are found at the known * xpath * @returns null if nothing is there */ - public static ModuleIdentification[] getLibraryInstance(String arch) { + public ModuleIdentification[] getLibraryInstance(String arch) throws EdkException { String[] xPath; String saGuid = null; String saVersion = null; @@ -1112,7 +1085,7 @@ public class SurfaceAreaQuery { xPath = new String[] { "/Instance" }; } else { // - // Since Schema don't have SupArchList now, so the follow Xpath is + // Since Schema don't have SupArchList now, so the follow Xpath is // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch] // don't have effect. // @@ -1138,7 +1111,9 @@ public class SurfaceAreaQuery { saVersion); PackageIdentification pkgId = new PackageIdentification(null, pkgGuid, pkgVersion); + GlobalData.refreshPackageIdentification(pkgId); saId.setPackage(pkgId); + GlobalData.refreshModuleIdentification(saId); saIdList[i] = saId; @@ -1150,7 +1125,7 @@ public class SurfaceAreaQuery { // / This method is used for retrieving the elements information which has // / CName sub-element // / - private static String[] getCNames(String from, String xPath[]) { + private String[] getCNames(String from, String xPath[]) { Object[] returns = get(from, xPath); if (returns == null || returns.length == 0) { return null; @@ -1167,11 +1142,11 @@ public class SurfaceAreaQuery { /** * Retrive library's constructor name - * + * * @returns constructor name list if elements are found at the known xpath * @returns null if nothing is there */ - public static String getLibConstructorName() { + public String getLibConstructorName() { String[] xPath = new String[] { "/Extern/Constructor" }; Object[] returns = get("Externs", xPath); @@ -1185,11 +1160,11 @@ public class SurfaceAreaQuery { /** * Retrive library's destructor name - * + * * @returns destructor name list if elements are found at the known xpath * @returns null if nothing is there */ - public static String getLibDestructorName() { + public String getLibDestructorName() { String[] xPath = new String[] { "/Extern/Destructor" }; Object[] returns = get("Externs", xPath); @@ -1206,79 +1181,159 @@ public class SurfaceAreaQuery { /** * Retrive DriverBinding names - * + * * @returns DriverBinding name list if elements are found at the known xpath * @returns null if nothing is there */ - public static String[] getDriverBindingArray() { + public String[] getDriverBindingArray() { String[] xPath = new String[] { "/Extern/DriverBinding" }; return getCNames("Externs", xPath); } /** * Retrive ComponentName names - * + * * @returns ComponentName name list if elements are found at the known xpath * @returns null if nothing is there */ - public static String[] getComponentNameArray() { + public String[] getComponentNameArray() { String[] xPath = new String[] { "/Extern/ComponentName" }; return getCNames("Externs", xPath); } /** * Retrive DriverConfig names - * + * * @returns DriverConfig name list if elements are found at the known xpath * @returns null if nothing is there */ - public static String[] getDriverConfigArray() { + public String[] getDriverConfigArray() { String[] xPath = new String[] { "/Extern/DriverConfig" }; return getCNames("Externs", xPath); } /** * Retrive DriverDiag names - * + * * @returns DriverDiag name list if elements are found at the known xpath * @returns null if nothing is there */ - public static String[] getDriverDiagArray() { + public String[] getDriverDiagArray() { String[] xPath = new String[] { "/Extern/DriverDiag" }; return getCNames("Externs", xPath); } /** - * Retrive SetVirtualAddressMapCallBack names + * Retrive DriverBinding, ComponentName, DriverConfig, + * DriverDiag group array * + * @returns DriverBinding group name list if elements are found + * at the known xpath + * @returns null if nothing is there + */ + public String[][] getExternProtocolGroup() { + String[] xPath = new String[] {"/Extern"}; + Object[] returns = get("Externs",xPath); + + if (returns == null) { + return new String[0][4]; + } + List externList = new ArrayList(); + for (int i = 0; i < returns.length; i++) { + org.tianocore.ExternsDocument.Externs.Extern extern = (org.tianocore.ExternsDocument.Externs.Extern)returns[i]; + if (extern.getDriverBinding() != null) { + externList.add(extern); + } + } + + String[][] externGroup = new String[externList.size()][4]; + for (int i = 0; i < externList.size(); i++) { + String driverBindingStr = externList.get(i).getDriverBinding(); + if ( driverBindingStr != null){ + externGroup[i][0] = driverBindingStr; + } else { + externGroup[i][0] = null; + } + + String componentNameStr = externList.get(i).getComponentName(); + if (componentNameStr != null) { + externGroup[i][1] = componentNameStr; + } else { + externGroup[i][1] = null; + } + + String driverConfigStr = externList.get(i).getDriverConfig(); + if (driverConfigStr != null) { + externGroup[i][2] = driverConfigStr; + } else { + externGroup[i][2] = null; + } + + String driverDiagStr = externList.get(i).getDriverDiag(); + if (driverDiagStr != null) { + externGroup[i][3] = driverDiagStr; + } else { + externGroup[i][3] = null; + } + } + return externGroup; + } + + /** + * Retrive SetVirtualAddressMapCallBack names + * * @returns SetVirtualAddressMapCallBack name list if elements are found at * the known xpath * @returns null if nothing is there */ - public static String[] getSetVirtualAddressMapCallBackArray() { + public String[] getSetVirtualAddressMapCallBackArray() { String[] xPath = new String[] { "/Extern/SetVirtualAddressMapCallBack" }; return getCNames("Externs", xPath); } /** * Retrive ExitBootServicesCallBack names - * + * * @returns ExitBootServicesCallBack name list if elements are found at the * known xpath * @returns null if nothing is there */ - public static String[] getExitBootServicesCallBackArray() { + public String[] getExitBootServicesCallBackArray() { String[] xPath = new String[] { "/Extern/ExitBootServicesCallBack" }; return getCNames("Externs", xPath); } + /** + Judge whether current driver is PEI_PCD_DRIVER or DXE_PCD_DRIVER or + NOT_PCD_DRIVER. + + @return CommonDefinition.PCD_DRIVER_TYPE the type of current driver + **/ + public CommonDefinition.PCD_DRIVER_TYPE getPcdDriverType() { + String[] xPath = new String[] {"/PcdIsDriver"}; + Object[] results = get ("Externs", xPath); + + if (results != null && results.length != 0) { + PcdDriverTypes type = (PcdDriverTypes) results[0]; + String typeStr = type.enumValue().toString(); + if (typeStr.equals(CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER.toString())) { + return CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER; + } else if (typeStr.equals(CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER.toString())) { + return CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER; + } + return CommonDefinition.PCD_DRIVER_TYPE.UNKNOWN_PCD_DRIVER; + } + + return CommonDefinition.PCD_DRIVER_TYPE.NOT_PCD_DRIVER; + } + /** * Retrieve module surface area file information - * + * * @returns ModuleSA objects list if elements are found at the known xpath * @returns Empty ModuleSA list if nothing is there */ - public static Map> getFpdModules() { + public Map> getFpdModules() throws EdkException { String[] xPath = new String[] { "/FrameworkModules/ModuleSA" }; Object[] result = get("PlatformSurfaceArea", xPath); String arch = null; @@ -1304,26 +1359,24 @@ public class SurfaceAreaQuery { ObjectMap.put("Libraries", moduleSA.getLibraries()); } if (((ModuleSADocument.ModuleSA) result[i]).getPcdBuildDefinition() != null) { - ObjectMap.put("PcdBuildDefinition", moduleSA - .getPcdBuildDefinition()); + ObjectMap.put("PcdBuildDefinition", moduleSA.getPcdBuildDefinition()); } - if (((ModuleSADocument.ModuleSA) result[i]) - .getModuleSaBuildOptions() != null) { - ObjectMap.put("ModuleSaBuildOptions", moduleSA - .getModuleSaBuildOptions()); + if (((ModuleSADocument.ModuleSA) result[i]).getModuleSaBuildOptions() != null) { + ObjectMap.put("ModuleSaBuildOptions", moduleSA.getModuleSaBuildOptions()); } // // Get Fpd SA Module attribute and create FpdMoudleIdentification. // - if (moduleSA.getSupArchList() != null) { + if (moduleSA.isSetSupArchList()) { arch = moduleSA.getSupArchList().toString(); + } else { + arch = null; } // TBD fvBinding = null; - saVersion = ((ModuleSADocument.ModuleSA) result[i]) - .getModuleVersion(); + saVersion = ((ModuleSADocument.ModuleSA) result[i]).getModuleVersion(); saGuid = moduleSA.getModuleGuid(); pkgGuid = moduleSA.getPackageGuid(); @@ -1333,12 +1386,14 @@ public class SurfaceAreaQuery { // Create Module Identification which have class member of package // identification. // - PackageIdentification pkgId = new PackageIdentification(null, - pkgGuid, pkgVersion); - ModuleIdentification saId = new ModuleIdentification(null, saGuid, - saVersion); - + PackageIdentification pkgId = new PackageIdentification(null, pkgGuid, pkgVersion); + GlobalData.refreshPackageIdentification(pkgId); + + ModuleIdentification saId = new ModuleIdentification(null, saGuid, saVersion); saId.setPackage(pkgId); + GlobalData.refreshModuleIdentification(saId); + + // // Create FpdModule Identification which have class member of module @@ -1347,17 +1402,16 @@ public class SurfaceAreaQuery { String[] archList = new String[0]; if (arch == null || arch.trim().length() == 0) { archList = GlobalData.getToolChainInfo().getArchs(); - } - else{ + } else { archList = arch.split(" "); } for (int j = 0; j < archList.length; j++) { - FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId, archList[j]); - + FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId, archList[j]); + if (fvBinding != null) { fpdSaId.setFvBinding(fvBinding); } - + // // Put element to Map>. @@ -1370,11 +1424,11 @@ public class SurfaceAreaQuery { /** * Retrieve valid image names - * + * * @returns valid iamges name list if elements are found at the known xpath * @returns empty list if nothing is there */ - public static String[] getFpdValidImageNames() { + public String[] getFpdValidImageNames() { String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" }; Object[] queryResult = get("PlatformSurfaceArea", xPath); @@ -1389,43 +1443,43 @@ public class SurfaceAreaQuery { return result; } - - public static Node getFpdUserExtensionPreBuild() { - String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" }; + + public Node getFpdUserExtensionPreBuild() { + String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" }; Object[] queryResult = get("PlatformSurfaceArea", xPath); if (queryResult == null || queryResult.length == 0) { return null; } UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0]; - + return a.getDomNode(); } - - public static Node getFpdUserExtensionPostBuild() { - String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" }; + + public Node getFpdUserExtensionPostBuild() { + String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" }; Object[] queryResult = get("PlatformSurfaceArea", xPath); if (queryResult == null || queryResult.length == 0) { return null; } UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0]; - + return a.getDomNode(); } /** * Retrieve FV image option information - * + * * @param fvName * FV image name - * + * * @returns option name/value list if elements are found at the known xpath * @returns empty list if nothing is there */ - public static String[][] getFpdOptions(String fvName) { + public String[][] getFpdOptions(String fvName) { String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='" - + fvName.toUpperCase() + "']/FvImageOptions" }; + + fvName + "']/FvImageOptions" }; Object[] queryResult = get("PlatformSurfaceArea", xPath); if (queryResult == null) { return new String[0][]; @@ -1451,7 +1505,7 @@ public class SurfaceAreaQuery { } - public static XmlObject getFpdBuildOptions() { + public XmlObject getFpdBuildOptions() { String[] xPath = new String[] { "/BuildOptions" }; Object[] queryResult = get("PlatformSurfaceArea", xPath); @@ -1462,7 +1516,7 @@ public class SurfaceAreaQuery { return (XmlObject)queryResult[0]; } - public static PlatformIdentification getFpdHeader() { + public PlatformIdentification getFpdHeader() { String[] xPath = new String[] { "/PlatformHeader" }; Object[] returns = get("PlatformSurfaceArea", xPath); @@ -1483,24 +1537,24 @@ public class SurfaceAreaQuery { /** * Retrieve FV image attributes information - * + * * @param fvName * FV image name - * + * * @returns attribute name/value list if elements are found at the known * xpath * @returns empty list if nothing is there */ - public static String[][] getFpdAttributes(String fvName) { + public String[][] getFpdAttributes(String fvName) { String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='" - + fvName.toUpperCase() + "']/FvImageOptions" }; + + fvName + "']/FvImageOptions" }; Object[] queryResult = get("PlatformSurfaceArea", xPath); if (queryResult == null) { return new String[0][]; } ArrayList list = new ArrayList(); for (int i = 0; i < queryResult.length; i++) { - + FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i]; List namevalues = item.getNameValueList(); Iterator iter = namevalues.iterator(); @@ -1520,11 +1574,11 @@ public class SurfaceAreaQuery { /** * Retrieve flash definition file name - * + * * @returns file name if elements are found at the known xpath * @returns null if nothing is there */ - public static String getFlashDefinitionFile() { + public String getFlashDefinitionFile() { String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" }; Object[] queryResult = get("PlatformSurfaceArea", xPath); @@ -1536,7 +1590,7 @@ public class SurfaceAreaQuery { return filename.getStringValue(); } - public static String[][] getFpdGlobalVariable() { + public String[][] getFpdGlobalVariable() { String[] xPath = new String[] { "/Flash/FvImages/NameValue" }; Object[] queryResult = get("PlatformSurfaceArea", xPath); if (queryResult == null) { @@ -1544,26 +1598,26 @@ public class SurfaceAreaQuery { } String[][] result = new String[queryResult.length][2]; - + for (int i = 0; i < queryResult.length; i++) { FvImagesDocument.FvImages.NameValue item = (FvImagesDocument.FvImages.NameValue)queryResult[i]; result[i][0] = item.getName(); result[i][1] = item.getValue(); } - return result; + return result; } - + /** * Retrieve FV image component options - * + * * @param fvName * FV image name - * + * * @returns name/value pairs list if elements are found at the known xpath * @returns empty list if nothing is there */ - public static String[][] getFpdComponents(String fvName) { - String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName.toUpperCase() + "']/FvImageOptions" }; + public String[][] getFpdComponents(String fvName) { + String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName + "']/FvImageOptions" }; Object[] queryResult = get("PlatformSurfaceArea", xPath); if (queryResult == null) { return new String[0][]; @@ -1585,17 +1639,17 @@ public class SurfaceAreaQuery { result[i][0] = list.get(i)[0]; result[i][1] = list.get(i)[1]; } - return result; + return result; } /** * Retrieve PCD tokens - * + * * @returns CName/ItemType pairs list if elements are found at the known * xpath * @returns null if nothing is there */ - public static String[][] getPcdTokenArray() { + public String[][] getPcdTokenArray() { String[] xPath = new String[] { "/PcdData" }; Object[] returns = get("PCDs", xPath); @@ -1608,11 +1662,11 @@ public class SurfaceAreaQuery { /** * Retrieve MAS header - * + * * @return * @return */ - public static ModuleIdentification getMsaHeader() { + public ModuleIdentification getMsaHeader() { String[] xPath = new String[] { "/" }; Object[] returns = get("MsaHeader", xPath); @@ -1640,15 +1694,15 @@ public class SurfaceAreaQuery { /** * Retrieve Extern Specification - * + * * @param - * + * * @return String[] If have specification element in the String[0] * If no specification element in the - * + * */ - public static String[] getExternSpecificaiton() { + public String[] getExternSpecificaiton() { String[] xPath = new String[] { "/Specification" }; Object[] queryResult = get("Externs", xPath); @@ -1666,12 +1720,12 @@ public class SurfaceAreaQuery { /** * Retreive MsaFile which in SPD - * + * * @param * @return String[][3] The string sequence is ModuleName, ModuleGuid, * ModuleVersion, MsaFile String[0][] If no msafile in SPD */ - public static String[] getSpdMsaFile() { + public String[] getSpdMsaFile() { String[] xPath = new String[] { "/MsaFiles" }; Object[] returns = get("PackageSurfaceArea", xPath); @@ -1687,7 +1741,7 @@ public class SurfaceAreaQuery { /** * Reteive */ - public static Map getSpdLibraryClasses() { + public Map getSpdLibraryClasses() { String[] xPath = new String[] { "/LibraryClassDeclarations/LibraryClass" }; Object[] returns = get("PackageSurfaceArea", xPath); @@ -1712,7 +1766,7 @@ public class SurfaceAreaQuery { /** * Reteive */ - public static Map getSpdPackageHeaderFiles() { + public Map getSpdPackageHeaderFiles() { String[] xPath = new String[] { "/PackageHeaders/IncludePkgHeader" }; Object[] returns = get("PackageSurfaceArea", xPath); @@ -1734,7 +1788,7 @@ public class SurfaceAreaQuery { return packageIncludeMap; } - public static PackageIdentification getSpdHeader() { + public PackageIdentification getSpdHeader() { String[] xPath = new String[] { "/SpdHeader" }; Object[] returns = get("PackageSurfaceArea", xPath); @@ -1757,7 +1811,7 @@ public class SurfaceAreaQuery { /** * Reteive */ - public static Map getSpdGuid() { + public Map getSpdGuid() { String[] xPath = new String[] { "/GuidDeclarations/Entry" }; Object[] returns = get("PackageSurfaceArea", xPath); @@ -1786,7 +1840,7 @@ public class SurfaceAreaQuery { /** * Reteive */ - public static Map getSpdProtocol() { + public Map getSpdProtocol() { String[] xPath = new String[] { "/ProtocolDeclarations/Entry" }; Object[] returns = get("PackageSurfaceArea", xPath); @@ -1816,13 +1870,13 @@ public class SurfaceAreaQuery { /** * getSpdPpi() Retrieve the SPD PPI Entry - * + * * @param * @return Map if get the PPI entry from SPD. Key - PPI * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI * entry in SPD. */ - public static Map getSpdPpi() { + public Map getSpdPpi() { String[] xPath = new String[] { "/PpiDeclarations/Entry" }; Object[] returns = get("PackageSurfaceArea", xPath); @@ -1848,11 +1902,11 @@ public class SurfaceAreaQuery { /** * Retrieve module Guid string - * + * * @returns GUILD string if elements are found at the known xpath * @returns null if nothing is there */ - public static String getModuleGuid() { + public String getModuleGuid() { String[] xPath = new String[] { "" }; Object[] returns = get("MsaHeader", xPath); @@ -1868,7 +1922,7 @@ public class SurfaceAreaQuery { // // For new Pcd // - public static ModuleSADocument.ModuleSA[] getFpdModuleSAs() { + public ModuleSADocument.ModuleSA[] getFpdModuleSAs() { String[] xPath = new String[] { "/FrameworkModules/ModuleSA" }; Object[] result = get("PlatformSurfaceArea", xPath); if (result != null) { @@ -1880,10 +1934,10 @@ public class SurfaceAreaQuery { /** Get name array of PCD in a module. In one module, token space is same, and token name should not be conflicted. - + @return String[] **/ - public static String[] getModulePcdEntryNameArray() { + public String[] getModulePcdEntryNameArray() { PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null; String[] results; int index; @@ -1908,7 +1962,7 @@ public class SurfaceAreaQuery { @return boolean **/ - public static boolean contains(List list, String str) { + public boolean contains(List list, String str) { if (list == null || list.size()== 0) { return true; } @@ -1923,7 +1977,7 @@ public class SurfaceAreaQuery { return false; } - public static boolean isHaveTianoR8FlashMap(){ + public boolean isHaveTianoR8FlashMap(){ String[] xPath = new String[] {"/"}; Object[] returns = get ("Externs", xPath); @@ -1932,7 +1986,7 @@ public class SurfaceAreaQuery { } ExternsDocument.Externs ext = (ExternsDocument.Externs)returns[0]; - + if (ext.getTianoR8FlashMapH()){ return true; }else {