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=1086bb8d498ce6940fc704274ae18431cc173714;hp=5f86217378e1fa021c0c4d09e7cd4b5834bad05b;hb=bd4814401e1277f19fa1498dbd187dca68923b47;hpb=25832ed3375c65b1b2763acbd7461710fde0543b diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java index 5f86217378..1086bb8d49 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java @@ -23,28 +23,59 @@ 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.*; + +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.FilenameDocument.Filename; import org.tianocore.MsaHeaderDocument.MsaHeader; import org.tianocore.ProtocolsDocument.Protocols.Protocol; import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify; -import org.tianocore.SupportedArchitectures.Enum; +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.logger.EdkLog; +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 { @@ -79,7 +110,7 @@ public class SurfaceAreaQuery { /** * Set a Surface Area document for query later - * + * * @param map * A Surface Area document in TopLevelElementName/XmlObject * format. @@ -94,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. @@ -154,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 @@ -193,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 @@ -229,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 @@ -251,12 +282,12 @@ public class SurfaceAreaQuery { Filename[] sourceFileNames = (Filename[]) returns; List outputList = new ArrayList(); for (int i = 0; i < sourceFileNames.length; i++) { - List archList = sourceFileNames[i].getSupArchList(); - if (arch == null || arch.equalsIgnoreCase("") || archList == null || archList.contains(arch)) { + 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]; @@ -267,7 +298,7 @@ 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 */ @@ -291,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(); @@ -308,7 +339,7 @@ public class SurfaceAreaQuery { ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0]; return item.getFfsFormatKey(); } - + public static String getModuleFvBindingKeyword() { String[] xPath = new String[] { "/" }; @@ -319,7 +350,7 @@ public class SurfaceAreaQuery { ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0]; return item.getFvBinding(); } - + public static List getModuleSupportedArchs() { String[] xPath = new String[] { "/" }; @@ -330,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[] { "/" }; @@ -351,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) { @@ -371,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); @@ -416,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(); @@ -455,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)]", @@ -466,8 +493,8 @@ public class SurfaceAreaQuery { "/Options/Option[@TagName]", }; } return getOptions("ModuleSaBuildOptions", xPath, toolChainFamilyFlag); - } - + } + public static String[][] getPlatformBuildOptions(boolean toolChainFamilyFlag) { String[] xPath; @@ -491,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()); @@ -502,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 */ @@ -520,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 */ @@ -532,40 +559,51 @@ public class SurfaceAreaQuery { String packageGuid = null; String packageVersion = null; - + 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]; - List archList = item.getSupArchList(); - if (arch == null || archList == null || archList.contains(arch)) { + List archList = item.getSupArchList(); + if (arch == null || archList == null || contains(archList, arch)) { packageGuid = item.getPackageGuid(); packageVersion = item.getPackageVersion(); - packageIdList[i] = (new PackageIdentification(null, packageGuid, + 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 { @@ -578,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 @@ -612,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 */ @@ -652,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 */ @@ -675,10 +720,10 @@ 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 || archList.contains(arch)){ + List archList = returnlList[i].getSupArchList(); + if (archList == null || contains(archList, arch)){ protocolList.add(returnlList[i].getProtocolCName()); } } @@ -691,10 +736,10 @@ 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 */ @@ -713,13 +758,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 || archList.contains(arch)){ + 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++) { @@ -730,10 +775,10 @@ 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 */ @@ -770,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 @@ -795,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 */ @@ -812,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 */ @@ -833,14 +878,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 || archList.contains(arch)){ - ppiNotifyList.add(((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++) { @@ -852,11 +897,11 @@ 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 */ @@ -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 */ @@ -916,11 +961,11 @@ public class SurfaceAreaQuery { List ppiList = new ArrayList(); for (int i = 0; i < returns.length; i++) { - List archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList(); - if (archList == null || archList.contains(arch)){ - ppiList.add(((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()); } - + } String[] ppiArray = new String[ppiList.size()]; for (int i = 0; i < ppiList.size(); i++) { @@ -931,11 +976,11 @@ 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 */ @@ -972,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 */ @@ -995,11 +1040,11 @@ public class SurfaceAreaQuery { List guidList = new ArrayList(); for (int i = 0; i < returns.length; i++) { - List archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList(); - if (archList == null || archList.contains(arch)){ - guidList.add(((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()); } - + } String[] guidArray = new String[guidList.size()]; for (int i = 0; i < guidList.size(); i++) { @@ -1011,10 +1056,10 @@ 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 */ @@ -1050,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 @@ -1071,7 +1116,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. // @@ -1126,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 */ @@ -1144,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 */ @@ -1165,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 */ @@ -1176,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 */ @@ -1187,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 */ @@ -1198,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 */ @@ -1209,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 @@ -1221,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 @@ -1231,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 */ @@ -1263,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(); @@ -1290,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); @@ -1301,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; @@ -1323,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 */ @@ -1342,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][]; @@ -1422,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(); @@ -1459,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 */ @@ -1483,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][]; @@ -1524,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 @@ -1542,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 */ @@ -1653,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() { @@ -1679,7 +1689,7 @@ 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 @@ -1738,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(), @@ -1788,7 +1798,7 @@ 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]); @@ -1819,7 +1829,7 @@ 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]); @@ -1829,7 +1839,7 @@ 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 @@ -1854,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 */ @@ -1918,26 +1903,63 @@ 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() { - 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; - } + **/ + 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; + } + } }