X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fglobal%2FSurfaceAreaQuery.java;h=1086bb8d498ce6940fc704274ae18431cc173714;hb=bd4814401e1277f19fa1498dbd187dca68923b47;hp=5eb14d4a4521d1c701c05b4efb515b03b0084671;hpb=a29c47e01d9689fad735bbeccfaef67676a425d1;p=mirror_edk2.git diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java index 5eb14d4a45..1086bb8d49 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java @@ -23,16 +23,16 @@ import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.xmlbeans.XmlNormalizedString; +import org.w3c.dom.Node; + import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlString; + import org.tianocore.BuildOptionsDocument; -import org.tianocore.DataIdDocument; +import org.tianocore.CNameType; import org.tianocore.ExternsDocument; import org.tianocore.FileNameConvention; -import org.tianocore.FvAttributeDocument; import org.tianocore.FvImagesDocument; -import org.tianocore.FvOptionDocument; import org.tianocore.GuidDeclarationsDocument; import org.tianocore.GuidsDocument; import org.tianocore.LibrariesDocument; @@ -48,28 +48,34 @@ 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.SupportedArchitectures; +import org.tianocore.UserExtensionsDocument; import org.tianocore.FilenameDocument.Filename; import org.tianocore.MsaHeaderDocument.MsaHeader; import org.tianocore.ProtocolsDocument.Protocols.Protocol; import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify; -import org.tianocore.PlatformHeaderDocument; +import org.tianocore.PcdDriverTypes; + +import org.tianocore.common.logger.EdkLog; 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.build.autogen.CommonDefinition; /** * 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 { @@ -104,7 +110,7 @@ public class SurfaceAreaQuery { /** * Set a Surface Area document for query later - * + * * @param map * A Surface Area document in TopLevelElementName/XmlObject * format. @@ -119,7 +125,7 @@ public class SurfaceAreaQuery { * 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. @@ -179,7 +185,7 @@ 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 @@ -218,7 +224,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 @@ -254,7 +260,7 @@ 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 @@ -265,12 +271,7 @@ public class SurfaceAreaQuery { String[] xPath; Object[] returns; - if (arch == null || arch.equals("")) { - xPath = new String[] { "/Filename" }; - } else { - xPath = new String[] { "/Filename[not(@SupArchList) or @SupArchList='" - + arch + "']" }; - } + xPath = new String[] { "/Filename" }; returns = get("SourceFiles", xPath); @@ -279,17 +280,25 @@ public class SurfaceAreaQuery { } Filename[] sourceFileNames = (Filename[]) returns; - String[][] outputString = new String[sourceFileNames.length][2]; + List outputList = new ArrayList(); for (int i = 0; i < sourceFileNames.length; i++) { - outputString[i][0] = sourceFileNames[i].getToolCode(); - outputString[i][1] = sourceFileNames[i].getStringValue(); + List archList = sourceFileNames[i].getSupArchList(); + if (arch == null || arch.equalsIgnoreCase("") || archList == null || contains(archList, arch)) { + 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]; + outputString[index][1] = outputList.get(index)[1]; } return outputString; } /** * 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 */ @@ -313,7 +322,7 @@ public class SurfaceAreaQuery { } PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0]; if(item.getIntermediateDirectories() == null) { - return null; + return null; } else { return item.getIntermediateDirectories().toString(); @@ -330,7 +339,7 @@ public class SurfaceAreaQuery { ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0]; return item.getFfsFormatKey(); } - + public static String getModuleFvBindingKeyword() { String[] xPath = new String[] { "/" }; @@ -341,7 +350,7 @@ public class SurfaceAreaQuery { ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0]; return item.getFvBinding(); } - + public static List getModuleSupportedArchs() { String[] xPath = new String[] { "/" }; @@ -352,17 +361,17 @@ public class SurfaceAreaQuery { ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0]; return item.getSupportedArchitectures(); } - + public static 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() { String[] xPath = new String[] { "/" }; @@ -373,18 +382,18 @@ 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) { @@ -393,7 +402,6 @@ public class SurfaceAreaQuery { String toolchainFamily = null; List archList = null; String cmd = null; - String targetName = null; String optionName = null; Object[] returns = get(from, xPath); @@ -438,19 +446,16 @@ public class SurfaceAreaQuery { } archList = new ArrayList(); - List archEnumList = option.getSupArchList(); + List archEnumList = option.getSupArchList(); if (archEnumList == null) { archList.add(null); } else { - archList.addAll(archEnumList); - /* + //archList.addAll(archEnumList); Iterator it = archEnumList.iterator(); while (it.hasNext()) { - System.out.println(it.next().getClass().getName()); - SupportedArchitectures.Enum archType = it.next(); - archList.add(archType.toString()); + String archType = (String)it.next(); + archList.add(archType); } - */ } cmd = option.getToolCode(); @@ -477,7 +482,7 @@ public class SurfaceAreaQuery { public static String[][] getModuleBuildOptions(boolean toolChainFamilyFlag) { String[] xPath; - + if (toolChainFamilyFlag == true) { xPath = new String[] { "/Options/Option[not(@ToolChainFamily) and not(@TagName)]", @@ -488,8 +493,8 @@ public class SurfaceAreaQuery { "/Options/Option[@TagName]", }; } return getOptions("ModuleSaBuildOptions", xPath, toolChainFamilyFlag); - } - + } + public static String[][] getPlatformBuildOptions(boolean toolChainFamilyFlag) { String[] xPath; @@ -513,7 +518,7 @@ public class SurfaceAreaQuery { 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,7 +529,7 @@ public class SurfaceAreaQuery { /** * Retrieve /ModuleType - * + * * @returns The module type name if elements are found at the known xpath * @returns null if nothing is there */ @@ -542,10 +547,10 @@ 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 */ @@ -554,41 +559,51 @@ public class SurfaceAreaQuery { String packageGuid = null; String packageVersion = null; - if (arch == null || arch.equals("")) { - xPath = new String[] { "/Package" }; - } else { - xPath = new String[] { "/Package[not(@SupArchList) or @SupArchList='" - + arch + "']" }; - } + + xPath = new String[] { "/Package" }; Object[] returns = get("PackageDependencies", xPath); if (returns == null) { return new PackageIdentification[0]; } - PackageIdentification[] packageIdList = new PackageIdentification[returns.length]; + + // + // Get packageIdentification + // + List packageIdList = new ArrayList(); for (int i = 0; i < returns.length; i++) { PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i]; - packageGuid = item.getPackageGuid(); - packageVersion = item.getPackageVersion(); - packageIdList[i] = (new PackageIdentification(null, packageGuid, + List archList = item.getSupArchList(); + if (arch == null || archList == null || contains(archList, arch)) { + packageGuid = item.getPackageGuid(); + packageVersion = item.getPackageVersion(); + packageIdList.add(new PackageIdentification(null, packageGuid, packageVersion)); + } } - return packageIdList; + + // + // 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; } /** * 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) { + public static String[] getLibraryClasses(String usage, String arch) { String[] xPath; - if (usage == null || usage.equals("")) { xPath = new String[] { "/LibraryClass" }; } else { @@ -601,16 +616,23 @@ public class SurfaceAreaQuery { } LibraryClassDocument.LibraryClass[] libraryClassList = (LibraryClassDocument.LibraryClass[]) returns; - String[] libraryClassName = new String[libraryClassList.length]; + List libraryClassName = new ArrayList(); for (int i = 0; i < libraryClassList.length; i++) { - libraryClassName[i] = libraryClassList[i].getKeyword(); + List archList = libraryClassList[i].getSupArchList(); + + if (arch == null || contains(archList, arch)) { + libraryClassName.add(libraryClassList[i].getKeyword()); + } } - return libraryClassName; + + 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 @@ -624,8 +646,7 @@ public class SurfaceAreaQuery { String[] entryPoints = new String[returns.length]; for (int i = 0; i < returns.length; ++i) { - entryPoints[i] = ((XmlNormalizedString) returns[i]) - .getStringValue(); + entryPoints[i] = ((CNameType) returns[i]).getStringValue(); } return entryPoints; @@ -636,10 +657,10 @@ 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 */ @@ -651,7 +672,7 @@ public class SurfaceAreaQuery { if (arch == null || arch.equals("")) { return new String[0]; } else { - archXpath = "/Protocol[@SupArchList='" + arch + "']"; + archXpath = "/Protocol"; if (usage != null && !usage.equals("")) { usageXpath = "/Protocol[@Usage='" + usage + "']"; xPath = new String[] { usageXpath, archXpath }; @@ -676,10 +697,10 @@ 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 */ @@ -689,28 +710,36 @@ public class SurfaceAreaQuery { if (arch == null || arch.equals("")) { return new String[0]; } else { - xPath = new String[] { "/Protocol[@SupArchList='" + arch + "']" }; + xPath = new String[] { "/Protocol" }; } Object[] returns = get("Protocols", xPath); if (returns == null) { return new String[0]; } - Protocol[] protocolList = (Protocol[]) returns; + Protocol[] returnlList = (Protocol[]) returns; + + List protocolList = new ArrayList(); - String[] protocolArray = new String[returns.length]; for (int i = 0; i < returns.length; i++) { - protocolArray[i] = protocolList[i].getProtocolCName(); + List archList = returnlList[i].getSupArchList(); + if (archList == null || contains(archList, arch)){ + protocolList.add(returnlList[i].getProtocolCName()); + } + } + String[] protocolArray = new String[protocolList.size()]; + for (int i = 0; i < protocolList.size(); i++) { + protocolArray[i] = protocolList.get(i); } return protocolArray; } /** * 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 */ @@ -720,8 +749,7 @@ public class SurfaceAreaQuery { if (arch == null || arch.equals("")) { return new String[0]; } else { - xPath = new String[] { "/ProtocolNotify[@SupArchList='" + arch - + "']" }; + xPath = new String[] { "/ProtocolNotify" }; } Object[] returns = get("Protocols", xPath); @@ -729,20 +757,28 @@ public class SurfaceAreaQuery { return new String[0]; } - String[] protocolNotifyList = new String[returns.length]; + List protocolNotifyList = new ArrayList(); + for (int i = 0; i < returns.length; i++) { - protocolNotifyList[i] = ((ProtocolNotify) returns[i]).getProtocolNotifyCName(); - } + List archList = ((ProtocolNotify) returns[i]).getSupArchList(); + if (archList == null || contains(archList, arch)){ + protocolNotifyList.add(((ProtocolNotify) returns[i]).getProtocolNotifyCName()); + } - return protocolNotifyList; + } + String[] protocolNotifyArray = new String[protocolNotifyList.size()]; + for (int i = 0; i < protocolNotifyList.size(); i++) { + protocolNotifyArray[i] = protocolNotifyList.get(i); + } + return protocolNotifyArray; } /** * 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 */ @@ -755,7 +791,7 @@ public class SurfaceAreaQuery { if (arch == null || arch.equals("")) { return new String[0]; } else { - archXpath = "/ProtocolNotify[@SupArchList='" + arch + "']"; + archXpath = "/ProtocolNotify"; if (usage != null && !usage.equals("")) { usageXpath = "/ProtocolNotify[@Usage='" + arch + "']"; xPath = new String[] { archXpath, usageXpath }; @@ -779,7 +815,7 @@ public class SurfaceAreaQuery { /** * Retrieve ModuleUnloadImage names - * + * * @returns ModuleUnloadImage name list if elements are found at the known * xpath * @returns null if nothing is there @@ -790,7 +826,7 @@ public class SurfaceAreaQuery { Object[] returns = get("Externs", xPath); if (returns != null && returns.length > 0) { String[] stringArray = new String[returns.length]; - XmlNormalizedString[] doc = (XmlNormalizedString[]) returns; + CNameType[] doc = (CNameType[]) returns; for (int i = 0; i < returns.length; ++i) { stringArray[i] = doc[i].getStringValue(); @@ -804,7 +840,7 @@ public class SurfaceAreaQuery { /** * Retrieve Extern - * + * * @returns Extern objects list if elements are found at the known xpath * @returns null if nothing is there */ @@ -821,10 +857,10 @@ 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 */ @@ -834,7 +870,7 @@ public class SurfaceAreaQuery { if (arch == null || arch.equals("")) { return new String[0]; } else { - xPath = new String[] { "/PpiNotify[@SupArchList='" + arch + "']" }; + xPath = new String[] { "/PpiNotify" }; } Object[] returns = get("PPIs", xPath); @@ -842,21 +878,30 @@ public class SurfaceAreaQuery { return new String[0]; } - String[] ppiNotifyList = new String[returns.length]; + + List ppiNotifyList = new ArrayList(); for (int i = 0; i < returns.length; i++) { - ppiNotifyList[i] = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName(); + List archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList(); + if (archList == null || contains(archList, arch)){ + ppiNotifyList.add(((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName()); + } + + } + String[] ppiNotifyArray = new String[ppiNotifyList.size()]; + for (int i = 0; i < ppiNotifyList.size(); i++) { + ppiNotifyArray[i] = ppiNotifyList.get(i); } - return ppiNotifyList; + return ppiNotifyArray; } /** * 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 */ @@ -869,7 +914,7 @@ public class SurfaceAreaQuery { if (arch == null || arch.equals("")) { return new String[0]; } else { - archXpath = "/PpiNotify[@SupArchList='" + arch + "']"; + archXpath = "/PpiNotify"; if (usage != null && !usage.equals("")) { usageXpath = "/PpiNotify[@Usage='" + arch + "']"; xPath = new String[] { archXpath, usageXpath }; @@ -893,10 +938,10 @@ 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 */ @@ -906,7 +951,7 @@ public class SurfaceAreaQuery { if (arch == null || arch.equals("")) { return new String[0]; } else { - xPath = new String[] { "/Ppi[@SupArchList='" + arch + "']" }; + xPath = new String[] { "/Ppi" }; } Object[] returns = get("PPIs", xPath); @@ -914,20 +959,28 @@ public class SurfaceAreaQuery { return new String[0]; } - String[] ppiList = new String[returns.length]; + List ppiList = new ArrayList(); for (int i = 0; i < returns.length; i++) { - ppiList[i] = ((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName(); + List archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList(); + if (archList == null || contains(archList, arch)){ + ppiList.add(((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName()); + } + } - return ppiList; + String[] ppiArray = new String[ppiList.size()]; + for (int i = 0; i < ppiList.size(); i++) { + ppiArray[i] = ppiList.get(i); + } + return ppiArray; } /** * 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 */ @@ -940,7 +993,7 @@ public class SurfaceAreaQuery { if (arch == null || arch.equals("")) { return new String[0]; } else { - archXpath = "/Ppi[@SupArchList='" + arch + "']"; + archXpath = "/Ppi"; if (usage != null && !usage.equals("")) { usageXpath = "/Ppi[@Usage='" + arch + "']"; xPath = new String[] { archXpath, usageXpath }; @@ -964,10 +1017,10 @@ 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 */ @@ -975,29 +1028,38 @@ public class SurfaceAreaQuery { String[] xPath; if (arch == null || arch.equals("")) { - xPath = new String[] { "/GuidName" }; + xPath = new String[] { "/GuidCNames" }; } else { - xPath = new String[] { "/GuidName[@SupArchList='" + arch + "']" }; + xPath = new String[] { "/GuidCNames" }; } Object[] returns = get("Guids", xPath); if (returns == null) { return new String[0]; } - String[] guidList = new String[returns.length]; + + List guidList = new ArrayList(); for (int i = 0; i < returns.length; i++) { - guidList[i] = ((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName(); + List archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList(); + if (archList == null || contains(archList, arch)){ + guidList.add(((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName()); + } + } - return guidList; + String[] guidArray = new String[guidList.size()]; + for (int i = 0; i < guidList.size(); i++) { + guidArray[i] = guidList.get(i); + } + return guidArray; } /** * 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 */ @@ -1009,7 +1071,7 @@ public class SurfaceAreaQuery { if (arch == null || arch.equals("")) { return new String[0]; } else { - archXpath = "/GuidEntry[@SupArchList='" + arch + "']"; + archXpath = "/GuidEntry"; if (usage != null && !usage.equals("")) { usageXpath = "/GuidEntry[@Usage='" + arch + "']"; xPath = new String[] { archXpath, usageXpath }; @@ -1033,12 +1095,12 @@ 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 @@ -1053,6 +1115,11 @@ public class SurfaceAreaQuery { if (arch == null || arch.equalsIgnoreCase("")) { xPath = new String[] { "/Instance" }; } else { + // + // 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. + // xPath = new String[] { "/Instance[not(@SupArchList) or @SupArchList='" + arch + "']" }; } @@ -1096,7 +1163,7 @@ public class SurfaceAreaQuery { String[] strings = new String[returns.length]; for (int i = 0; i < returns.length; ++i) { // TBD - // strings[i] = ((CName) returns[i]).getStringValue(); + strings[i] = ((CNameType) returns[i]).getStringValue(); } return strings; @@ -1104,7 +1171,7 @@ 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 */ @@ -1113,8 +1180,8 @@ public class SurfaceAreaQuery { Object[] returns = get("Externs", xPath); if (returns != null && returns.length > 0) { - // CName constructor = (CName) returns[0]; - // return constructor.getStringValue(); + CNameType constructor = ((CNameType) returns[0]); + return constructor.getStringValue(); } return null; @@ -1122,7 +1189,7 @@ 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 */ @@ -1131,8 +1198,11 @@ public class SurfaceAreaQuery { Object[] returns = get("Externs", xPath); if (returns != null && returns.length > 0) { - // CName destructor = (CName) returns[0]; - // return destructor.getStringValue(); + // + // Only support one Destructor function. + // + CNameType destructor = (CNameType) returns[0]; + return destructor.getStringValue(); } return null; @@ -1140,7 +1210,7 @@ public class SurfaceAreaQuery { /** * Retrive DriverBinding names - * + * * @returns DriverBinding name list if elements are found at the known xpath * @returns null if nothing is there */ @@ -1151,7 +1221,7 @@ public class SurfaceAreaQuery { /** * Retrive ComponentName names - * + * * @returns ComponentName name list if elements are found at the known xpath * @returns null if nothing is there */ @@ -1162,7 +1232,7 @@ public class SurfaceAreaQuery { /** * Retrive DriverConfig names - * + * * @returns DriverConfig name list if elements are found at the known xpath * @returns null if nothing is there */ @@ -1173,7 +1243,7 @@ public class SurfaceAreaQuery { /** * Retrive DriverDiag names - * + * * @returns DriverDiag name list if elements are found at the known xpath * @returns null if nothing is there */ @@ -1184,7 +1254,7 @@ public class SurfaceAreaQuery { /** * Retrive SetVirtualAddressMapCallBack names - * + * * @returns SetVirtualAddressMapCallBack name list if elements are found at * the known xpath * @returns null if nothing is there @@ -1196,7 +1266,7 @@ public class SurfaceAreaQuery { /** * Retrive ExitBootServicesCallBack names - * + * * @returns ExitBootServicesCallBack name list if elements are found at the * known xpath * @returns null if nothing is there @@ -1206,9 +1276,33 @@ public class SurfaceAreaQuery { 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 static 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 */ @@ -1238,24 +1332,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. // - arch = moduleSA.getSupArchList().toString(); + 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(); @@ -1265,10 +1359,8 @@ 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); + ModuleIdentification saId = new ModuleIdentification(null, saGuid, saVersion); saId.setPackage(pkgId); @@ -1276,21 +1368,24 @@ public class SurfaceAreaQuery { // Create FpdModule Identification which have class member of module // identification // - if (arch != null) { - String[] archList = arch.split(" "); - for (int j = 0; j < archList.length; j++) { - FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId, archList[j]); - - if (fvBinding != null) { - fpdSaId.setFvBinding(fvBinding); - } - - // - // Put element to Map>. - // - fpdModuleMap.put(fpdSaId, ObjectMap); + String[] archList = new String[0]; + if (arch == null || arch.trim().length() == 0) { + archList = GlobalData.getToolChainInfo().getArchs(); + } else { + archList = arch.split(" "); + } + for (int j = 0; j < archList.length; j++) { + FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId, archList[j]); + + if (fvBinding != null) { + fpdSaId.setFvBinding(fvBinding); } + + // + // Put element to Map>. + // + fpdModuleMap.put(fpdSaId, ObjectMap); } } return fpdModuleMap; @@ -1298,7 +1393,7 @@ 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 */ @@ -1317,29 +1412,43 @@ public class SurfaceAreaQuery { return result; } - - public static XmlObject getFpdUserExtension() { - String[] xPath = new String[] { "" }; + + public static Node getFpdUserExtensionPreBuild() { + String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" }; Object[] queryResult = get("PlatformSurfaceArea", xPath); - if (queryResult == null) { + if (queryResult == null || queryResult.length == 0) { return null; } - 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']" }; + + 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) { 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][]; @@ -1397,24 +1506,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) { 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(); @@ -1434,7 +1543,7 @@ 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 */ @@ -1458,26 +1567,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" }; + 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][]; @@ -1499,12 +1608,12 @@ 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 @@ -1517,86 +1626,12 @@ public class SurfaceAreaQuery { return null; } - // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns; - // String[][] result = new String[pcds.length][2]; - // for (int i = 0; i < returns.length; ++i) { - // if (pcds[i].getItemType() != null) { - // result[i][1] = pcds[i].getItemType().toString(); - // } else { - // result[i][1] = null; - // } - // result[i][0] = pcds[i].getCName(); - // } - return null; } - /** - * Get the PcdToken array from module's surface area document. The array - * should contains following data: - *

- * ------------------------------------------------------------------- - *

- *

- * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText - *

- *

- * ------------------------------------------------------------------- - *

- *

- * Note: Until new schema applying, now we can only get CName, ItemType, - *

- * - * @return 2-array table contains all information of PCD token retrieved - * from MSA. - */ - public static Object[][] etModulePCDTokenArray() { - return null; - // int index; - // Object[][] result; - // PCDs.PcdData[] pcds; - // String[] xPath = new String[] { "/PcdData" }; - // Object[] returns = get("PCDs", xPath); - // - // if ((returns == null) || (returns.length == 0)) { - // return null; - // } - // - // pcds = (PCDs.PcdData[]) returns; - // result = new Object[pcds.length][6]; - // for (index = 0; index < pcds.length; index++) { - // // - // // Get CName - // // - // result[index][0] = pcds[index].getCName(); - // // - // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE, - // // DYNAMIC, DYNAMIC_EX - // // - // if (pcds[index].getItemType() != null) { - // result[index][1] = pcds[index].getItemType().toString(); - // } else { - // result[index][1] = null; - // } - // - // // - // // BUGBUG: following field can *not* be got from current MSA until - // // schema changed. - // // - // // result [index][2] = pcds[index].getTokenSpaceName(); - // result[index][2] = null; - // result[index][3] = pcds[index].getDefaultValue(); - // // result [index][4] = pcds[index].getUsage (); - // result[index][4] = null; - // // result [index][5] = pcds[index].getHelpText (); - // result[index][5] = null; - // } - // return result; - } - /** * Retrieve MAS header - * + * * @return * @return */ @@ -1628,12 +1663,12 @@ 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() { @@ -1646,16 +1681,15 @@ public class SurfaceAreaQuery { String[] specificationList = new String[queryResult.length]; for (int i = 0; i < queryResult.length; i++) { - // specificationList[i] = ((SpecificationDocument.Specification) - // queryResult[i]) - // .getStringValue(); + specificationList[i] = ((Sentence)queryResult[i]) + .getStringValue(); } return specificationList; } /** * Retreive MsaFile which in SPD - * + * * @param * @return String[][3] The string sequence is ModuleName, ModuleGuid, * ModuleVersion, MsaFile String[0][] If no msafile in SPD @@ -1714,7 +1748,7 @@ public class SurfaceAreaQuery { if (returns == null) { return packageIncludeMap; } -// GlobalData.log.info("" + returns[0].getClass().getName()); + for (int i = 0; i < returns.length; i++) { PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i]; packageIncludeMap.put(includeHeader.getModuleType().toString(), @@ -1764,7 +1798,10 @@ public class SurfaceAreaQuery { String[] guidPair = new String[2]; guidPair[0] = entry.getCName(); guidPair[1] = entry.getGuidValue(); - guidDeclMap.put(entry.getName(), guidPair); + guidDeclMap.put(entry.getCName(), guidPair); + EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName()); + EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[0]); + EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[1]); } return guidDeclMap; } @@ -1792,14 +1829,17 @@ public class SurfaceAreaQuery { protocolPair[0] = entry.getCName(); protocolPair[1] = entry.getGuidValue(); - protoclMap.put(entry.getName(), protocolPair); + protoclMap.put(entry.getCName(), protocolPair); + EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName()); + EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[0]); + EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[1]); } return protoclMap; } /** * 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 @@ -1824,39 +1864,14 @@ public class SurfaceAreaQuery { String[] ppiPair = new String[2]; ppiPair[0] = entry.getCName(); ppiPair[1] = entry.getGuidValue(); - ppiMap.put(entry.getName(), ppiPair); + ppiMap.put(entry.getCName(), ppiPair); } return ppiMap; } - /** - * getToolChainFamily - * - * This function is to retrieve ToolChainFamily attribute of FPD - * - * - * @param - * @return toolChainFamily If find toolChainFamily attribute in - * Null If don't have toolChainFamily in - * . - */ - public String getToolChainFamily() { - String toolChainFamily; - String[] xPath = new String[] { "/BuildOptions" }; - - Object[] result = get("PlatformSurfaceArea", xPath); - if (result == null) { - return null; - } - // toolChainFamily = - // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies(); - // return toolChainFamily; - return null; - } - /** * Retrieve module Guid string - * + * * @returns GUILD string if elements are found at the known xpath * @returns null if nothing is there */ @@ -1885,4 +1900,66 @@ public class SurfaceAreaQuery { return new ModuleSADocument.ModuleSA[0]; } + /** + 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() { + PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null; + String[] results; + int index; + String[] xPath = new String[] {"/PcdEntry"}; + Object[] returns = get ("PcdCoded", xPath); + + if (returns == null) { + return new String[0]; + } + + pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns; + results = new String[pcdEntries.length]; + + for (index = 0; index < pcdEntries.length; index ++) { + results[index] = pcdEntries[index].getCName(); + } + return results; + } + + /** + Search in a List for a given string + + @return boolean + **/ + public static boolean contains(List list, String str) { + if (list == null || list.size()== 0) { + return true; + } + Iterator it = list.iterator(); + while (it.hasNext()) { + String s = (String)it.next(); + if (s.equalsIgnoreCase(str)) { + return true; + } + } + + return false; + } + + public static boolean isHaveTianoR8FlashMap(){ + String[] xPath = new String[] {"/"}; + Object[] returns = get ("Externs", xPath); + + if (returns == null) { + return false; + } + + ExternsDocument.Externs ext = (ExternsDocument.Externs)returns[0]; + + if (ext.getTianoR8FlashMapH()){ + return true; + }else { + return false; + } + } }