]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
Support using @ToolChainFamily in <Filename> to do the filter. This is also to fix...
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / global / SurfaceAreaQuery.java
CommitLineData
878ddf1f 1/** @file\r
2 This file is for surface area information retrieval.\r
3\r
4 Copyright (c) 2006, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13 **/\r
14package org.tianocore.build.global;\r
15\r
16import java.util.ArrayList;\r
a29c47e0 17import java.util.HashMap;\r
878ddf1f 18import java.util.Iterator;\r
a29c47e0 19import java.util.LinkedHashMap;\r
878ddf1f 20import java.util.List;\r
21import java.util.Map;\r
22import java.util.Stack;\r
23import java.util.regex.Matcher;\r
24import java.util.regex.Pattern;\r
25\r
d8f1335e 26import org.tianocore.ExternsDocument.Externs.Extern;\r
878ddf1f 27import org.apache.xmlbeans.XmlObject;\r
28import org.apache.xmlbeans.XmlString;\r
d8f1335e 29import org.tianocore.*;\r
a29c47e0 30import org.tianocore.FilenameDocument.Filename;\r
250258de 31import org.tianocore.MsaHeaderDocument.MsaHeader;\r
a29c47e0 32import org.tianocore.ProtocolsDocument.Protocols.Protocol;\r
33import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
d8f1335e 34import org.tianocore.build.autogen.CommonDefinition;\r
a29c47e0 35import org.tianocore.build.id.FpdModuleIdentification;\r
36import org.tianocore.build.id.ModuleIdentification;\r
37import org.tianocore.build.id.PackageIdentification;\r
38import org.tianocore.build.id.PlatformIdentification;\r
39import org.tianocore.build.toolchain.ToolChainInfo;\r
d8f1335e 40import org.tianocore.common.exception.EdkException;\r
d8f1335e 41import org.w3c.dom.Node;\r
878ddf1f 42\r
43/**\r
a29c47e0 44 * SurfaceAreaQuery class is used to query Surface Area information from msa,\r
45 * mbd, spd and fpd files.\r
ff225cbb 46 *\r
a29c47e0 47 * This class should not instantiated. All the public interfaces is static.\r
ff225cbb 48 *\r
a29c47e0 49 * @since GenBuild 1.0\r
50 */\r
878ddf1f 51public class SurfaceAreaQuery {\r
a29c47e0 52\r
83fba802 53 public String prefix = "http://www.TianoCore.org/2006/Edk2.0";\r
a29c47e0 54\r
1fa1cb75 55 //\r
56 // Contains name/value pairs of Surface Area document object. The name is\r
57 // always the top level element name.\r
58 //\r
83fba802 59 private Map<String, XmlObject> map = null;\r
a29c47e0 60\r
1fa1cb75 61 //\r
62 // mapStack is used to do nested query\r
63 //\r
83fba802 64 private Stack<Map<String, XmlObject>> mapStack = new Stack<Map<String, XmlObject>>();\r
a29c47e0 65\r
1fa1cb75 66 //\r
67 // prefix of name space\r
68 //\r
83fba802 69 private String nsPrefix = "sans";\r
a29c47e0 70\r
1fa1cb75 71 //\r
72 // xmlbeans needs a name space for each Xpath element\r
73 //\r
83fba802 74 private String ns = null;\r
a29c47e0 75\r
1fa1cb75 76 //\r
77 // keep the namep declaration for xmlbeans Xpath query\r
78 //\r
83fba802 79 private String queryDeclaration = null;\r
878ddf1f 80\r
83fba802 81 private StringBuffer normQueryString = new StringBuffer(4096);\r
82 private Pattern xPathPattern = Pattern.compile("([^/]*)(/|//)([^/]+)");\r
1fa1cb75 83\r
878ddf1f 84 /**\r
a29c47e0 85 * Set a Surface Area document for query later\r
ff225cbb 86 *\r
a29c47e0 87 * @param map\r
88 * A Surface Area document in TopLevelElementName/XmlObject\r
89 * format.\r
90 */\r
83fba802 91 public SurfaceAreaQuery(Map<String, XmlObject> map) {\r
a29c47e0 92 ns = prefix;\r
878ddf1f 93 queryDeclaration = "declare namespace " + nsPrefix + "='" + ns + "'; ";\r
83fba802 94 this.map = map;\r
878ddf1f 95 }\r
96\r
97 /**\r
a29c47e0 98 * Push current used Surface Area document into query stack. The given new\r
99 * document will be used for any immediately followed getXXX() callings,\r
100 * untill pop() is called.\r
ff225cbb 101 *\r
a29c47e0 102 * @param newMap\r
103 * The TopLevelElementName/XmlObject format of a Surface Area\r
104 * document.\r
105 */\r
83fba802 106 public void push(Map<String, XmlObject> newMap) {\r
107 mapStack.push(this.map);\r
108 this.map = newMap;\r
878ddf1f 109 }\r
a29c47e0 110\r
878ddf1f 111 /**\r
a29c47e0 112 * Discard current used Surface Area document and use the top document in\r
113 * stack instead.\r
114 */\r
83fba802 115 public void pop() {\r
116 this.map = mapStack.pop();\r
878ddf1f 117 }\r
a29c47e0 118\r
119 // /\r
120 // / Convert xPath to be namespace qualified, which is necessary for\r
121 // XmlBeans\r
122 // / selectPath(). For example, converting /MsaHeader/ModuleType to\r
123 // / /ns:MsaHeader/ns:ModuleType\r
124 // /\r
83fba802 125 private String normalizeQueryString(String[] exp, String from) {\r
1fa1cb75 126 normQueryString.setLength(0);\r
878ddf1f 127\r
128 int i = 0;\r
129 while (i < exp.length) {\r
130 String newExp = from + exp[i];\r
1fa1cb75 131 Matcher matcher = xPathPattern.matcher(newExp);\r
878ddf1f 132\r
133 while (matcher.find()) {\r
a29c47e0 134 String starter = newExp.substring(matcher.start(1), matcher\r
135 .end(1));\r
136 String seperator = newExp.substring(matcher.start(2), matcher\r
137 .end(2));\r
138 String token = newExp.substring(matcher.start(3), matcher\r
139 .end(3));\r
140\r
878ddf1f 141 normQueryString.append(starter);\r
142 normQueryString.append(seperator);\r
143 normQueryString.append(nsPrefix);\r
144 normQueryString.append(":");\r
145 normQueryString.append(token);\r
146 }\r
147\r
148 ++i;\r
149 if (i < exp.length) {\r
150 normQueryString.append(" | ");\r
151 }\r
152 }\r
153\r
154 return normQueryString.toString();\r
155 }\r
156\r
157 /**\r
a29c47e0 158 * Search all XML documents stored in "map" for the specified xPath, using\r
159 * relative path (starting with '$this')\r
ff225cbb 160 *\r
a29c47e0 161 * @param xPath\r
162 * xpath query string array\r
163 * @returns An array of XmlObject if elements are found at the specified\r
164 * xpath\r
165 * @returns NULL if nothing is at the specified xpath\r
166 */\r
83fba802 167 public Object[] get(String[] xPath) {\r
878ddf1f 168 if (map == null) {\r
169 return null;\r
170 }\r
a29c47e0 171\r
878ddf1f 172 String[] keys = (String[]) map.keySet().toArray(new String[map.size()]);\r
a29c47e0 173 List<Object> result = new ArrayList<Object>();\r
878ddf1f 174 for (int i = 0; i < keys.length; ++i) {\r
175 XmlObject rootNode = (XmlObject) map.get(keys[i]);\r
176 if (rootNode == null) {\r
177 continue;\r
178 }\r
a29c47e0 179\r
180 String query = queryDeclaration\r
181 + normalizeQueryString(xPath, "$this/" + keys[i]);\r
878ddf1f 182 XmlObject[] tmp = rootNode.selectPath(query);\r
183 for (int j = 0; j < tmp.length; ++j) {\r
a29c47e0 184 result.add((Object)tmp[j]);\r
878ddf1f 185 }\r
186 }\r
a29c47e0 187\r
878ddf1f 188 int size = result.size();\r
189 if (size <= 0) {\r
190 return null;\r
191 }\r
a29c47e0 192\r
193 return (Object[]) result.toArray(new Object[size]);\r
878ddf1f 194 }\r
195\r
196 /**\r
a29c47e0 197 * Search XML documents named by "rootName" for the given xPath, using\r
198 * relative path (starting with '$this')\r
ff225cbb 199 *\r
a29c47e0 200 * @param rootName\r
201 * The top level element name\r
202 * @param xPath\r
203 * The xpath query string array\r
204 * @returns An array of XmlObject if elements are found at the given xpath\r
205 * @returns NULL if nothing is found at the given xpath\r
206 */\r
83fba802 207 public Object[] get(String rootName, String[] xPath) {\r
878ddf1f 208 if (map == null) {\r
209 return null;\r
210 }\r
a29c47e0 211\r
878ddf1f 212 XmlObject root = (XmlObject) map.get(rootName);\r
213 if (root == null) {\r
214 return null;\r
215 }\r
216\r
a29c47e0 217 String query = queryDeclaration\r
218 + normalizeQueryString(xPath, "$this/" + rootName);\r
878ddf1f 219 XmlObject[] result = root.selectPath(query);\r
220 if (result.length > 0) {\r
a29c47e0 221 return (Object[])result;\r
878ddf1f 222 }\r
223\r
224 query = queryDeclaration + normalizeQueryString(xPath, "/" + rootName);\r
225 result = root.selectPath(query);\r
226 if (result.length > 0) {\r
a29c47e0 227 return (Object[])result;\r
878ddf1f 228 }\r
229\r
230 return null;\r
231 }\r
232\r
233 /**\r
a29c47e0 234 * Retrieve SourceFiles/Filename for specified ARCH type\r
ff225cbb 235 *\r
a29c47e0 236 * @param arch\r
237 * architecture name\r
238 * @returns An 2 dimension string array if elements are found at the known\r
239 * xpath\r
240 * @returns NULL if nothing is found at the known xpath\r
241 */\r
83fba802 242 public String[][] getSourceFiles(String arch) {\r
878ddf1f 243 String[] xPath;\r
a29c47e0 244 Object[] returns;\r
878ddf1f 245\r
25832ed3 246 xPath = new String[] { "/Filename" };\r
878ddf1f 247\r
a29c47e0 248 returns = get("SourceFiles", xPath);\r
878ddf1f 249\r
a29c47e0 250 if (returns == null || returns.length == 0) {\r
91a1f0d7 251 return new String[0][3];\r
878ddf1f 252 }\r
253\r
a29c47e0 254 Filename[] sourceFileNames = (Filename[]) returns;\r
25832ed3 255 List<String[]> outputList = new ArrayList<String[]>();\r
a29c47e0 256 for (int i = 0; i < sourceFileNames.length; i++) {\r
7d6ef0a9 257 List archList = sourceFileNames[i].getSupArchList();\r
91a1f0d7 258 if (arch == null || arch.trim().equalsIgnoreCase("") || archList == null || contains(archList, arch)) {\r
259 outputList.add(new String[] {sourceFileNames[i].getToolCode(), sourceFileNames[i].getStringValue(), sourceFileNames[i].getToolChainFamily()});\r
25832ed3 260 }\r
261 }\r
ff225cbb 262\r
91a1f0d7 263 String[][] outputString = new String[outputList.size()][3];\r
25832ed3 264 for (int index = 0; index < outputList.size(); index++) {\r
91a1f0d7 265 //\r
266 // ToolCode (FileType)\r
267 //\r
25832ed3 268 outputString[index][0] = outputList.get(index)[0];\r
91a1f0d7 269 //\r
270 // File name (relative to MODULE_DIR)\r
271 //\r
25832ed3 272 outputString[index][1] = outputList.get(index)[1];\r
91a1f0d7 273 //\r
274 // Tool chain family\r
275 //\r
276 outputString[index][2] = outputList.get(index)[2];\r
a29c47e0 277 }\r
278 return outputString;\r
878ddf1f 279 }\r
280\r
281 /**\r
a29c47e0 282 * Retrieve /PlatformDefinitions/OutputDirectory from FPD\r
ff225cbb 283 *\r
a29c47e0 284 * @returns Directory names array if elements are found at the known xpath\r
285 * @returns Empty if nothing is found at the known xpath\r
286 */\r
83fba802 287 public String getFpdOutputDirectory() {\r
a29c47e0 288 String[] xPath = new String[] { "/PlatformDefinitions" };\r
289\r
290 Object[] returns = get("PlatformSurfaceArea", xPath);\r
291 if (returns == null || returns.length == 0) {\r
292 return null;\r
293 }\r
294 PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];\r
295 return item.getOutputDirectory();\r
296 }\r
878ddf1f 297\r
83fba802 298 public String getFpdIntermediateDirectories() {\r
a29c47e0 299 String[] xPath = new String[] { "/PlatformDefinitions" };\r
878ddf1f 300\r
a29c47e0 301 Object[] returns = get("PlatformSurfaceArea", xPath);\r
302 if (returns == null || returns.length == 0) {\r
303 return "UNIFIED";\r
304 }\r
305 PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];\r
306 if(item.getIntermediateDirectories() == null) {\r
ff225cbb 307 return null;\r
a29c47e0 308 }\r
309 else {\r
310 return item.getIntermediateDirectories().toString();\r
311 }\r
312 }\r
878ddf1f 313\r
83fba802 314 public String getModuleFfsKeyword() {\r
a29c47e0 315 String[] xPath = new String[] { "/" };\r
878ddf1f 316\r
a29c47e0 317 Object[] returns = get("ModuleSaBuildOptions", xPath);\r
318 if (returns == null || returns.length == 0) {\r
319 return null;\r
878ddf1f 320 }\r
a29c47e0 321 ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0];\r
322 return item.getFfsFormatKey();\r
323 }\r
ff225cbb 324\r
83fba802 325 public String getModuleFvBindingKeyword() {\r
a29c47e0 326 String[] xPath = new String[] { "/" };\r
878ddf1f 327\r
a29c47e0 328 Object[] returns = get("ModuleSaBuildOptions", xPath);\r
329 if (returns == null || returns.length == 0) {\r
330 return null;\r
331 }\r
332 ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0];\r
333 return item.getFvBinding();\r
334 }\r
ff225cbb 335\r
83fba802 336 public List getModuleSupportedArchs() {\r
a29c47e0 337 String[] xPath = new String[] { "/" };\r
338\r
339 Object[] returns = get("ModuleDefinitions", xPath);\r
340 if (returns == null || returns.length == 0) {\r
341 return null;\r
342 }\r
343 ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0];\r
344 return item.getSupportedArchitectures();\r
345 }\r
ff225cbb 346\r
83fba802 347 public BuildOptionsDocument.BuildOptions.Ffs[] getFpdFfs() {\r
a29c47e0 348 String[] xPath = new String[] {"/Ffs"};\r
ff225cbb 349\r
a29c47e0 350 Object[] returns = get("BuildOptions", xPath);\r
351 if (returns == null || returns.length == 0) {\r
352 return new BuildOptionsDocument.BuildOptions.Ffs[0];\r
353 }\r
354 return (BuildOptionsDocument.BuildOptions.Ffs[])returns;\r
878ddf1f 355 }\r
ff225cbb 356\r
83fba802 357 public String getModuleOutputFileBasename() {\r
a29c47e0 358 String[] xPath = new String[] { "/" };\r
878ddf1f 359\r
a29c47e0 360 Object[] returns = get("ModuleDefinitions", xPath);\r
361 if (returns == null || returns.length == 0) {\r
362 return null;\r
363 }\r
364 ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0];\r
365 return item.getOutputFileBasename();\r
366 }\r
ff225cbb 367\r
878ddf1f 368 /**\r
a29c47e0 369 * Retrieve BuildOptions/Option or Arch/Option\r
ff225cbb 370 *\r
a29c47e0 371 * @param toolChainFamilyFlag\r
372 * if true, retrieve options for toolchain family; otherwise for\r
373 * toolchain\r
ff225cbb 374 *\r
a29c47e0 375 * @returns String[][5] name, target, toolchain, arch, coommand of options\r
376 * if elements are found at the known xpath. String[0][] if dont\r
377 * find element.\r
ff225cbb 378 *\r
a29c47e0 379 * @returns Empty array if nothing is there\r
380 */\r
83fba802 381 public String[][] getOptions(String from, String[] xPath, boolean toolChainFamilyFlag) {\r
a29c47e0 382 String target = null;\r
383 String toolchain = null;\r
384 String toolchainFamily = null;\r
385 List<String> archList = null;\r
386 String cmd = null;\r
a29c47e0 387 String optionName = null;\r
388\r
389 Object[] returns = get(from, xPath);\r
390 if (returns == null) {\r
391 return new String[0][5];\r
392 }\r
878ddf1f 393\r
a29c47e0 394 List<String[]> optionList = new ArrayList<String[]>();\r
395 OptionDocument.Option option;\r
878ddf1f 396\r
a29c47e0 397 for (int i = 0; i < returns.length; i++) {\r
398 option = (OptionDocument.Option) returns[i];\r
878ddf1f 399\r
a29c47e0 400 //\r
401 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,\r
402 // then\r
403 // put to result[][5] array in above order.\r
404 //\r
405 String[] targetList;\r
406 if (option.getBuildTargets() == null) {\r
407 target = null;\r
408 }\r
409 else {\r
410 target = option.getBuildTargets().toString();\r
411 }\r
412 if (target != null) {\r
413 targetList = target.split(" ");\r
414 } else {\r
415 targetList = new String[1];\r
416 targetList[0] = null;\r
417 }\r
878ddf1f 418\r
a29c47e0 419 if (toolChainFamilyFlag) {\r
420 toolchainFamily = option.getToolChainFamily();\r
421 if (toolchainFamily != null) {\r
422 toolchain = toolchainFamily.toString();\r
423 } else {\r
424 toolchain = null;\r
425 }\r
878ddf1f 426 } else {\r
a29c47e0 427 toolchain = option.getTagName();\r
878ddf1f 428 }\r
a29c47e0 429\r
430 archList = new ArrayList<String>();\r
ff225cbb 431 List archEnumList = option.getSupArchList();\r
a29c47e0 432 if (archEnumList == null) {\r
433 archList.add(null);\r
434 } else {\r
7d6ef0a9 435 //archList.addAll(archEnumList);\r
a29c47e0 436 Iterator it = archEnumList.iterator();\r
437 while (it.hasNext()) {\r
7d6ef0a9 438 String archType = (String)it.next();\r
439 archList.add(archType);\r
a29c47e0 440 }\r
a29c47e0 441 }\r
442\r
443 cmd = option.getToolCode();\r
444\r
445 optionName = option.getStringValue();\r
446 for (int t = 0; t < targetList.length; t++) {\r
447 for (int j = 0; j < archList.size(); j++) {\r
448 optionList.add(new String[] { targetList[t],\r
449 toolchain, archList.get(j), cmd, optionName});\r
878ddf1f 450 }\r
451 }\r
878ddf1f 452 }\r
453\r
a29c47e0 454 String[][] result = new String[optionList.size()][5];\r
455 for (int i = 0; i < optionList.size(); i++) {\r
456 result[i][0] = optionList.get(i)[0];\r
457 result[i][1] = optionList.get(i)[1];\r
458 result[i][2] = optionList.get(i)[2];\r
459 result[i][3] = optionList.get(i)[3];\r
460 result[i][4] = optionList.get(i)[4];\r
461 }\r
878ddf1f 462 return result;\r
463 }\r
a29c47e0 464\r
83fba802 465 public String[][] getModuleBuildOptions(boolean toolChainFamilyFlag) {\r
a29c47e0 466 String[] xPath;\r
ff225cbb 467\r
a29c47e0 468 if (toolChainFamilyFlag == true) {\r
469 xPath = new String[] {\r
470 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r
471 "/Options/Option[@ToolChainFamily]", };\r
472 } else {\r
473 xPath = new String[] {\r
474 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r
475 "/Options/Option[@TagName]", };\r
476 }\r
477 return getOptions("ModuleSaBuildOptions", xPath, toolChainFamilyFlag);\r
ff225cbb 478 }\r
479\r
83fba802 480 public String[][] getPlatformBuildOptions(boolean toolChainFamilyFlag) {\r
a29c47e0 481 String[] xPath;\r
250258de 482\r
a29c47e0 483 if (toolChainFamilyFlag == true) {\r
484 xPath = new String[] {\r
485 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r
486 "/BuildOptions/Options/Option[@ToolChainFamily]", };\r
487 } else {\r
488 xPath = new String[] {\r
489 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r
490 "/BuildOptions/Options/Option[@TagName]", };\r
250258de 491 }\r
492\r
a29c47e0 493 return getOptions("PlatformSurfaceArea", xPath, toolChainFamilyFlag);\r
250258de 494 }\r
495\r
83fba802 496 public ToolChainInfo getFpdToolChainInfo() {\r
a29c47e0 497 String[] xPath = new String[] { "/PlatformDefinitions" };\r
878ddf1f 498\r
a29c47e0 499 Object[] returns = get("PlatformSurfaceArea", xPath);\r
500 if (returns == null || returns.length == 0) {\r
501 return null;\r
878ddf1f 502 }\r
ff225cbb 503\r
a29c47e0 504 PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];\r
505 ToolChainInfo toolChainInfo = new ToolChainInfo();\r
506 toolChainInfo.addTargets(item.getBuildTargets().toString());\r
507 toolChainInfo.addArchs(item.getSupportedArchitectures().toString());\r
508 toolChainInfo.addTagnames((String)null);\r
509 return toolChainInfo;\r
878ddf1f 510 }\r
511\r
512 /**\r
a29c47e0 513 * Retrieve <xxxHeader>/ModuleType\r
ff225cbb 514 *\r
a29c47e0 515 * @returns The module type name if elements are found at the known xpath\r
516 * @returns null if nothing is there\r
517 */\r
83fba802 518 public String getModuleType() {\r
a29c47e0 519 String[] xPath = new String[] { "/ModuleType" };\r
520\r
521 Object[] returns = get(xPath);\r
878ddf1f 522 if (returns != null && returns.length > 0) {\r
a29c47e0 523 ModuleTypeDef type = (ModuleTypeDef) returns[0];\r
878ddf1f 524 return type.enumValue().toString();\r
525 }\r
526\r
527 return null;\r
528 }\r
529\r
530 /**\r
a29c47e0 531 * Retrieve PackageDependencies/Package\r
ff225cbb 532 *\r
a29c47e0 533 * @param arch\r
534 * Architecture name\r
ff225cbb 535 *\r
a29c47e0 536 * @returns package name list if elements are found at the known xpath\r
537 * @returns null if nothing is there\r
538 */\r
892b0e7a 539 public PackageIdentification[] getDependencePkg(String arch) throws EdkException {\r
878ddf1f 540 String[] xPath;\r
a29c47e0 541 String packageGuid = null;\r
542 String packageVersion = null;\r
878ddf1f 543\r
ff225cbb 544\r
25832ed3 545 xPath = new String[] { "/Package" };\r
ff225cbb 546\r
a29c47e0 547 Object[] returns = get("PackageDependencies", xPath);\r
548 if (returns == null) {\r
549 return new PackageIdentification[0];\r
878ddf1f 550 }\r
a84091c4 551\r
552 //\r
ff225cbb 553 // Get packageIdentification\r
554 //\r
a84091c4 555 List<PackageIdentification> packageIdList = new ArrayList<PackageIdentification>();\r
a29c47e0 556 for (int i = 0; i < returns.length; i++) {\r
557 PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i];\r
7d6ef0a9 558 List archList = item.getSupArchList();\r
559 if (arch == null || archList == null || contains(archList, arch)) {\r
25832ed3 560 packageGuid = item.getPackageGuid();\r
561 packageVersion = item.getPackageVersion();\r
892b0e7a 562 PackageIdentification pkgId = new PackageIdentification(null, packageGuid, packageVersion);\r
563 GlobalData.refreshPackageIdentification(pkgId);\r
564 packageIdList.add(pkgId);\r
25832ed3 565 }\r
a29c47e0 566 }\r
a84091c4 567\r
892b0e7a 568 return packageIdList.toArray(new PackageIdentification[packageIdList.size()]);\r
878ddf1f 569 }\r
570\r
571 /**\r
a29c47e0 572 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage\r
ff225cbb 573 *\r
a29c47e0 574 * @param usage\r
575 * Library class usage\r
ff225cbb 576 *\r
a29c47e0 577 * @returns LibraryClass objects list if elements are found at the known\r
578 * xpath\r
579 * @returns null if nothing is there\r
580 */\r
83fba802 581 public String[] getLibraryClasses(String usage, String arch) {\r
878ddf1f 582 String[] xPath;\r
878ddf1f 583 if (usage == null || usage.equals("")) {\r
a29c47e0 584 xPath = new String[] { "/LibraryClass" };\r
878ddf1f 585 } else {\r
a29c47e0 586 xPath = new String[] { "/LibraryClass[@Usage='" + usage + "']" };\r
878ddf1f 587 }\r
588\r
a29c47e0 589 Object[] returns = get("LibraryClassDefinitions", xPath);\r
590 if (returns == null || returns.length == 0) {\r
591 return new String[0];\r
878ddf1f 592 }\r
593\r
a29c47e0 594 LibraryClassDocument.LibraryClass[] libraryClassList = (LibraryClassDocument.LibraryClass[]) returns;\r
42b78757 595 List<String> libraryClassName = new ArrayList<String>();\r
a29c47e0 596 for (int i = 0; i < libraryClassList.length; i++) {\r
42b78757 597 List archList = libraryClassList[i].getSupArchList();\r
ff225cbb 598\r
42b78757 599 if (arch == null || contains(archList, arch)) {\r
600 libraryClassName.add(libraryClassList[i].getKeyword());\r
601 }\r
a29c47e0 602 }\r
bd481440 603\r
604 String[] libraryArray = new String[libraryClassName.size()];\r
605 libraryClassName.toArray(libraryArray);\r
42b78757 606 return libraryArray;\r
878ddf1f 607 }\r
608\r
609 /**\r
a29c47e0 610 * Retrieve ModuleEntryPoint names\r
ff225cbb 611 *\r
a29c47e0 612 * @returns ModuleEntryPoint name list if elements are found at the known\r
613 * xpath\r
614 * @returns null if nothing is there\r
615 */\r
83fba802 616 public String[] getModuleEntryPointArray() {\r
878ddf1f 617 String[] xPath = new String[] { "/Extern/ModuleEntryPoint" };\r
618\r
a29c47e0 619 Object[] returns = get("Externs", xPath);\r
878ddf1f 620\r
621 if (returns != null && returns.length > 0) {\r
622 String[] entryPoints = new String[returns.length];\r
623\r
624 for (int i = 0; i < returns.length; ++i) {\r
136adffc 625 entryPoints[i] = ((CNameType) returns[i]).getStringValue();\r
878ddf1f 626 }\r
627\r
628 return entryPoints;\r
629 }\r
630\r
631 return null;\r
632 }\r
633\r
634 /**\r
a29c47e0 635 * retrieve Protocol for specified usage\r
ff225cbb 636 *\r
a29c47e0 637 * @param usage\r
638 * Protocol usage arch Architecture\r
ff225cbb 639 *\r
a29c47e0 640 * @returns Protocol String list if elements are found at the known xpath\r
641 * @returns String[0] if nothing is there\r
642 */\r
83fba802 643 public String[] getProtocolArray(String arch, String usage) {\r
a29c47e0 644 String[] xPath;\r
645 String usageXpath = "";\r
646 String archXpath = "";\r
878ddf1f 647\r
a29c47e0 648 if (arch == null || arch.equals("")) {\r
649 return new String[0];\r
650 } else {\r
25832ed3 651 archXpath = "/Protocol";\r
a29c47e0 652 if (usage != null && !usage.equals("")) {\r
653 usageXpath = "/Protocol[@Usage='" + usage + "']";\r
654 xPath = new String[] { usageXpath, archXpath };\r
655 } else {\r
656 return getProtocolArray(arch);\r
250258de 657 }\r
a29c47e0 658\r
250258de 659 }\r
660\r
a29c47e0 661 Object[] returns = get("Protocols", xPath);\r
662 if (returns == null) {\r
663 return new String[0];\r
664 }\r
665 Protocol[] protocolList = (Protocol[]) returns;\r
666\r
667 String[] protocolArray = new String[returns.length];\r
668 for (int i = 0; i < returns.length; i++) {\r
669 protocolArray[i] = protocolList[i].getProtocolCName();\r
670 }\r
671 return protocolArray;\r
250258de 672 }\r
673\r
674 /**\r
a29c47e0 675 * retrieve Protocol for specified usage\r
ff225cbb 676 *\r
a29c47e0 677 * @param arch\r
678 * Architecture\r
ff225cbb 679 *\r
a29c47e0 680 * @returns Protocol String list if elements are found at the known xpath\r
681 * @returns String[0] if nothing is there\r
682 */\r
83fba802 683 public String[] getProtocolArray(String arch) {\r
a29c47e0 684 String[] xPath;\r
685\r
686 if (arch == null || arch.equals("")) {\r
687 return new String[0];\r
688 } else {\r
136adffc 689 xPath = new String[] { "/Protocol" };\r
a29c47e0 690 }\r
250258de 691\r
a29c47e0 692 Object[] returns = get("Protocols", xPath);\r
693 if (returns == null) {\r
694 return new String[0];\r
878ddf1f 695 }\r
25832ed3 696 Protocol[] returnlList = (Protocol[]) returns;\r
878ddf1f 697\r
25832ed3 698 List<String> protocolList = new ArrayList<String>();\r
ff225cbb 699\r
a29c47e0 700 for (int i = 0; i < returns.length; i++) {\r
7d6ef0a9 701 List archList = returnlList[i].getSupArchList();\r
702 if (archList == null || contains(archList, arch)){\r
25832ed3 703 protocolList.add(returnlList[i].getProtocolCName());\r
136adffc 704 }\r
a29c47e0 705 }\r
25832ed3 706 String[] protocolArray = new String[protocolList.size()];\r
707 for (int i = 0; i < protocolList.size(); i++) {\r
708 protocolArray[i] = protocolList.get(i);\r
709 }\r
a29c47e0 710 return protocolArray;\r
878ddf1f 711 }\r
712\r
713 /**\r
a29c47e0 714 * Retrieve ProtocolNotify for specified usage\r
ff225cbb 715 *\r
a29c47e0 716 * @param usage\r
717 * ProtocolNotify usage\r
ff225cbb 718 *\r
a29c47e0 719 * @returns String[] if elements are found at the known xpath\r
720 * @returns String[0] if nothing is there\r
721 */\r
83fba802 722 public String[] getProtocolNotifyArray(String arch) {\r
878ddf1f 723 String[] xPath;\r
724\r
a29c47e0 725 if (arch == null || arch.equals("")) {\r
726 return new String[0];\r
878ddf1f 727 } else {\r
136adffc 728 xPath = new String[] { "/ProtocolNotify" };\r
878ddf1f 729 }\r
730\r
a29c47e0 731 Object[] returns = get("Protocols", xPath);\r
732 if (returns == null) {\r
733 return new String[0];\r
878ddf1f 734 }\r
735\r
25832ed3 736 List<String> protocolNotifyList = new ArrayList<String>();\r
ff225cbb 737\r
a29c47e0 738 for (int i = 0; i < returns.length; i++) {\r
7d6ef0a9 739 List archList = ((ProtocolNotify) returns[i]).getSupArchList();\r
740 if (archList == null || contains(archList, arch)){\r
25832ed3 741 protocolNotifyList.add(((ProtocolNotify) returns[i]).getProtocolNotifyCName());\r
136adffc 742 }\r
ff225cbb 743\r
a29c47e0 744 }\r
25832ed3 745 String[] protocolNotifyArray = new String[protocolNotifyList.size()];\r
746 for (int i = 0; i < protocolNotifyList.size(); i++) {\r
747 protocolNotifyArray[i] = protocolNotifyList.get(i);\r
748 }\r
749 return protocolNotifyArray;\r
878ddf1f 750 }\r
751\r
752 /**\r
a29c47e0 753 * Retrieve ProtocolNotify for specified usage\r
ff225cbb 754 *\r
a29c47e0 755 * @param usage\r
756 * ProtocolNotify usage\r
ff225cbb 757 *\r
a29c47e0 758 * @returns String[] if elements are found at the known xpath\r
759 * @returns String[0] if nothing is there\r
760 */\r
83fba802 761 public String[] getProtocolNotifyArray(String arch, String usage) {\r
878ddf1f 762\r
878ddf1f 763 String[] xPath;\r
a29c47e0 764 String usageXpath;\r
765 String archXpath;\r
878ddf1f 766\r
a29c47e0 767 if (arch == null || arch.equals("")) {\r
768 return new String[0];\r
878ddf1f 769 } else {\r
25832ed3 770 archXpath = "/ProtocolNotify";\r
a29c47e0 771 if (usage != null && !usage.equals("")) {\r
772 usageXpath = "/ProtocolNotify[@Usage='" + arch + "']";\r
773 xPath = new String[] { archXpath, usageXpath };\r
774 } else {\r
775 return getProtocolNotifyArray(arch);\r
776 }\r
878ddf1f 777 }\r
778\r
a29c47e0 779 Object[] returns = get("Protocols", xPath);\r
780 if (returns == null) {\r
781 return new String[0];\r
878ddf1f 782 }\r
783\r
a29c47e0 784 String[] protocolNotifyList = new String[returns.length];\r
785\r
786 for (int i = 0; i < returns.length; i++) {\r
787 protocolNotifyList[i] = ((ProtocolNotify) returns[i]).getProtocolNotifyCName();\r
788 }\r
789 return protocolNotifyList;\r
878ddf1f 790 }\r
791\r
792 /**\r
a29c47e0 793 * Retrieve ModuleUnloadImage names\r
ff225cbb 794 *\r
a29c47e0 795 * @returns ModuleUnloadImage name list if elements are found at the known\r
796 * xpath\r
797 * @returns null if nothing is there\r
798 */\r
83fba802 799 public String[] getModuleUnloadImageArray() {\r
878ddf1f 800 String[] xPath = new String[] { "/Extern/ModuleUnloadImage" };\r
801\r
a29c47e0 802 Object[] returns = get("Externs", xPath);\r
878ddf1f 803 if (returns != null && returns.length > 0) {\r
804 String[] stringArray = new String[returns.length];\r
136adffc 805 CNameType[] doc = (CNameType[]) returns;\r
878ddf1f 806\r
807 for (int i = 0; i < returns.length; ++i) {\r
808 stringArray[i] = doc[i].getStringValue();\r
809 }\r
810\r
811 return stringArray;\r
812 }\r
813\r
814 return null;\r
815 }\r
816\r
817 /**\r
a29c47e0 818 * Retrieve Extern\r
ff225cbb 819 *\r
a29c47e0 820 * @returns Extern objects list if elements are found at the known xpath\r
821 * @returns null if nothing is there\r
822 */\r
83fba802 823 public ExternsDocument.Externs.Extern[] getExternArray() {\r
878ddf1f 824 String[] xPath = new String[] { "/Extern" };\r
825\r
a29c47e0 826 Object[] returns = get("Externs", xPath);\r
878ddf1f 827 if (returns != null && returns.length > 0) {\r
828 return (ExternsDocument.Externs.Extern[]) returns;\r
829 }\r
830\r
831 return null;\r
832 }\r
833\r
834 /**\r
a29c47e0 835 * Retrieve PpiNotify for specified arch\r
ff225cbb 836 *\r
a29c47e0 837 * @param arch\r
838 * PpiNotify arch\r
ff225cbb 839 *\r
a29c47e0 840 * @returns String[] if elements are found at the known xpath\r
841 * @returns String[0] if nothing is there\r
842 */\r
83fba802 843 public String[] getPpiNotifyArray(String arch) {\r
878ddf1f 844 String[] xPath;\r
845\r
a29c47e0 846 if (arch == null || arch.equals("")) {\r
847 return new String[0];\r
878ddf1f 848 } else {\r
136adffc 849 xPath = new String[] { "/PpiNotify" };\r
878ddf1f 850 }\r
851\r
a29c47e0 852 Object[] returns = get("PPIs", xPath);\r
853 if (returns == null) {\r
854 return new String[0];\r
878ddf1f 855 }\r
856\r
ff225cbb 857\r
25832ed3 858 List<String> ppiNotifyList = new ArrayList<String>();\r
a29c47e0 859 for (int i = 0; i < returns.length; i++) {\r
7d6ef0a9 860 List archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList();\r
861 if (archList == null || contains(archList, arch)){\r
ff225cbb 862 ppiNotifyList.add(((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName());\r
136adffc 863 }\r
ff225cbb 864\r
a29c47e0 865 }\r
25832ed3 866 String[] ppiNotifyArray = new String[ppiNotifyList.size()];\r
867 for (int i = 0; i < ppiNotifyList.size(); i++) {\r
868 ppiNotifyArray[i] = ppiNotifyList.get(i);\r
869 }\r
a29c47e0 870\r
25832ed3 871 return ppiNotifyArray;\r
878ddf1f 872 }\r
873\r
874 /**\r
a29c47e0 875 * Retrieve PpiNotify for specified usage and arch\r
ff225cbb 876 *\r
a29c47e0 877 * @param arch\r
878 * PpiNotify arch usage PpiNotify usage\r
ff225cbb 879 *\r
880 *\r
a29c47e0 881 * @returns String[] if elements are found at the known xpath\r
882 * @returns String[0] if nothing is there\r
883 */\r
83fba802 884 public String[] getPpiNotifyArray(String arch, String usage) {\r
878ddf1f 885\r
878ddf1f 886 String[] xPath;\r
a29c47e0 887 String usageXpath;\r
888 String archXpath;\r
878ddf1f 889\r
a29c47e0 890 if (arch == null || arch.equals("")) {\r
891 return new String[0];\r
878ddf1f 892 } else {\r
136adffc 893 archXpath = "/PpiNotify";\r
a29c47e0 894 if (usage != null && !usage.equals("")) {\r
895 usageXpath = "/PpiNotify[@Usage='" + arch + "']";\r
896 xPath = new String[] { archXpath, usageXpath };\r
897 } else {\r
898 return getProtocolNotifyArray(arch);\r
899 }\r
878ddf1f 900 }\r
901\r
a29c47e0 902 Object[] returns = get("PPIs", xPath);\r
903 if (returns == null) {\r
904 return new String[0];\r
878ddf1f 905 }\r
906\r
a29c47e0 907 String[] ppiNotifyList = new String[returns.length];\r
908\r
909 for (int i = 0; i < returns.length; i++) {\r
910 ppiNotifyList[i] = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName();\r
911 }\r
912 return ppiNotifyList;\r
878ddf1f 913 }\r
914\r
915 /**\r
a29c47e0 916 * Retrieve Ppi for specified arch\r
ff225cbb 917 *\r
a29c47e0 918 * @param arch\r
919 * Ppi arch\r
ff225cbb 920 *\r
a29c47e0 921 * @returns String[] if elements are found at the known xpath\r
922 * @returns String[0] if nothing is there\r
923 */\r
83fba802 924 public String[] getPpiArray(String arch) {\r
a29c47e0 925 String[] xPath;\r
926\r
927 if (arch == null || arch.equals("")) {\r
928 return new String[0];\r
929 } else {\r
136adffc 930 xPath = new String[] { "/Ppi" };\r
a29c47e0 931 }\r
932\r
933 Object[] returns = get("PPIs", xPath);\r
934 if (returns == null) {\r
935 return new String[0];\r
936 }\r
937\r
25832ed3 938 List<String> ppiList = new ArrayList<String>();\r
a29c47e0 939 for (int i = 0; i < returns.length; i++) {\r
7d6ef0a9 940 List archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList();\r
941 if (archList == null || contains(archList, arch)){\r
ff225cbb 942 ppiList.add(((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName());\r
136adffc 943 }\r
ff225cbb 944\r
a29c47e0 945 }\r
25832ed3 946 String[] ppiArray = new String[ppiList.size()];\r
947 for (int i = 0; i < ppiList.size(); i++) {\r
948 ppiArray[i] = ppiList.get(i);\r
949 }\r
950 return ppiArray;\r
a29c47e0 951 }\r
878ddf1f 952\r
a29c47e0 953 /**\r
954 * Retrieve PpiNotify for specified usage and arch\r
ff225cbb 955 *\r
a29c47e0 956 * @param arch\r
957 * PpiNotify arch usage PpiNotify usage\r
ff225cbb 958 *\r
959 *\r
a29c47e0 960 * @returns String[] if elements are found at the known xpath\r
961 * @returns String[0] if nothing is there\r
962 */\r
83fba802 963 public String[] getPpiArray(String arch, String usage) {\r
878ddf1f 964\r
878ddf1f 965 String[] xPath;\r
a29c47e0 966 String usageXpath;\r
967 String archXpath;\r
878ddf1f 968\r
a29c47e0 969 if (arch == null || arch.equals("")) {\r
970 return new String[0];\r
878ddf1f 971 } else {\r
136adffc 972 archXpath = "/Ppi";\r
a29c47e0 973 if (usage != null && !usage.equals("")) {\r
974 usageXpath = "/Ppi[@Usage='" + arch + "']";\r
975 xPath = new String[] { archXpath, usageXpath };\r
976 } else {\r
977 return getProtocolNotifyArray(arch);\r
978 }\r
878ddf1f 979 }\r
980\r
a29c47e0 981 Object[] returns = get("PPIs", xPath);\r
982 if (returns == null) {\r
983 return new String[0];\r
878ddf1f 984 }\r
985\r
a29c47e0 986 String[] ppiList = new String[returns.length];\r
987\r
988 for (int i = 0; i < returns.length; i++) {\r
989 ppiList[i] = ((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName();\r
990 }\r
991 return ppiList;\r
878ddf1f 992 }\r
993\r
994 /**\r
a29c47e0 995 * Retrieve GuidEntry information for specified usage\r
ff225cbb 996 *\r
a29c47e0 997 * @param arch\r
998 * GuidEntry arch\r
ff225cbb 999 *\r
a29c47e0 1000 * @returns GuidEntry objects list if elements are found at the known xpath\r
1001 * @returns null if nothing is there\r
1002 */\r
83fba802 1003 public String[] getGuidEntryArray(String arch) {\r
a29c47e0 1004 String[] xPath;\r
1005\r
1006 if (arch == null || arch.equals("")) {\r
136adffc 1007 xPath = new String[] { "/GuidCNames" };\r
a29c47e0 1008 } else {\r
136adffc 1009 xPath = new String[] { "/GuidCNames" };\r
a29c47e0 1010 }\r
1011\r
1012 Object[] returns = get("Guids", xPath);\r
1013 if (returns == null) {\r
1014 return new String[0];\r
1015 }\r
25832ed3 1016\r
1017 List<String> guidList = new ArrayList<String>();\r
a29c47e0 1018 for (int i = 0; i < returns.length; i++) {\r
7d6ef0a9 1019 List archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList();\r
1020 if (archList == null || contains(archList, arch)){\r
ff225cbb 1021 guidList.add(((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName());\r
136adffc 1022 }\r
ff225cbb 1023\r
a29c47e0 1024 }\r
25832ed3 1025 String[] guidArray = new String[guidList.size()];\r
1026 for (int i = 0; i < guidList.size(); i++) {\r
1027 guidArray[i] = guidList.get(i);\r
1028 }\r
1029 return guidArray;\r
878ddf1f 1030\r
a29c47e0 1031 }\r
878ddf1f 1032\r
a29c47e0 1033 /**\r
1034 * Retrieve GuidEntry information for specified usage\r
ff225cbb 1035 *\r
a29c47e0 1036 * @param arch\r
1037 * GuidEntry arch usage GuidEntry usage\r
ff225cbb 1038 *\r
a29c47e0 1039 * @returns GuidEntry objects list if elements are found at the known xpath\r
1040 * @returns null if nothing is there\r
1041 */\r
83fba802 1042 public String[] getGuidEntryArray(String arch, String usage) {\r
878ddf1f 1043 String[] xPath;\r
a29c47e0 1044 String archXpath;\r
1045 String usageXpath;\r
878ddf1f 1046\r
a29c47e0 1047 if (arch == null || arch.equals("")) {\r
1048 return new String[0];\r
1049 } else {\r
136adffc 1050 archXpath = "/GuidEntry";\r
a29c47e0 1051 if (usage != null && !usage.equals("")) {\r
1052 usageXpath = "/GuidEntry[@Usage='" + arch + "']";\r
1053 xPath = new String[] { archXpath, usageXpath };\r
878ddf1f 1054 } else {\r
a29c47e0 1055 return getProtocolNotifyArray(arch);\r
878ddf1f 1056 }\r
1057 }\r
878ddf1f 1058\r
a29c47e0 1059 Object[] returns = get("Guids", xPath);\r
1060 if (returns == null) {\r
1061 return new String[0];\r
878ddf1f 1062 }\r
a29c47e0 1063\r
1064 String[] guidList = new String[returns.length];\r
1065\r
1066 for (int i = 0; i < returns.length; i++) {\r
1067 guidList[i] = ((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName();\r
1068 }\r
1069 return guidList;\r
1070 }\r
1071\r
1072 /**\r
1073 * Retrieve Library instance information\r
ff225cbb 1074 *\r
a29c47e0 1075 * @param arch\r
1076 * Architecture name\r
1077 * @param usage\r
1078 * Library instance usage\r
ff225cbb 1079 *\r
a29c47e0 1080 * @returns library instance name list if elements are found at the known\r
1081 * xpath\r
1082 * @returns null if nothing is there\r
1083 */\r
892b0e7a 1084 public ModuleIdentification[] getLibraryInstance(String arch) throws EdkException {\r
a29c47e0 1085 String[] xPath;\r
1086 String saGuid = null;\r
1087 String saVersion = null;\r
1088 String pkgGuid = null;\r
1089 String pkgVersion = null;\r
1090\r
1091 if (arch == null || arch.equalsIgnoreCase("")) {\r
1092 xPath = new String[] { "/Instance" };\r
1093 } else {\r
25832ed3 1094 //\r
ff225cbb 1095 // Since Schema don't have SupArchList now, so the follow Xpath is\r
25832ed3 1096 // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]\r
1097 // don't have effect.\r
1098 //\r
a29c47e0 1099 xPath = new String[] { "/Instance[not(@SupArchList) or @SupArchList='"\r
1100 + arch + "']" };\r
878ddf1f 1101 }\r
1102\r
a29c47e0 1103 Object[] returns = get("Libraries", xPath);\r
1104 if (returns == null || returns.length == 0) {\r
1105 return new ModuleIdentification[0];\r
1106 }\r
1107\r
1108 ModuleIdentification[] saIdList = new ModuleIdentification[returns.length];\r
1109 for (int i = 0; i < returns.length; i++) {\r
1110 LibrariesDocument.Libraries.Instance library = (LibrariesDocument.Libraries.Instance) returns[i];\r
1111 saGuid = library.getModuleGuid();\r
1112 saVersion = library.getModuleVersion();\r
1113\r
1114 pkgGuid = library.getPackageGuid();\r
1115 pkgVersion = library.getPackageVersion();\r
1116\r
1117 ModuleIdentification saId = new ModuleIdentification(null, saGuid,\r
1118 saVersion);\r
1119 PackageIdentification pkgId = new PackageIdentification(null,\r
1120 pkgGuid, pkgVersion);\r
892b0e7a 1121 GlobalData.refreshPackageIdentification(pkgId);\r
a29c47e0 1122 saId.setPackage(pkgId);\r
892b0e7a 1123 GlobalData.refreshModuleIdentification(saId);\r
a29c47e0 1124\r
1125 saIdList[i] = saId;\r
1126\r
1127 }\r
1128 return saIdList;\r
878ddf1f 1129 }\r
1130\r
a29c47e0 1131 // /\r
1132 // / This method is used for retrieving the elements information which has\r
1133 // / CName sub-element\r
1134 // /\r
83fba802 1135 private String[] getCNames(String from, String xPath[]) {\r
a29c47e0 1136 Object[] returns = get(from, xPath);\r
878ddf1f 1137 if (returns == null || returns.length == 0) {\r
1138 return null;\r
1139 }\r
a29c47e0 1140\r
878ddf1f 1141 String[] strings = new String[returns.length];\r
1142 for (int i = 0; i < returns.length; ++i) {\r
a29c47e0 1143 // TBD\r
136adffc 1144 strings[i] = ((CNameType) returns[i]).getStringValue();\r
878ddf1f 1145 }\r
a29c47e0 1146\r
1147 return strings;\r
878ddf1f 1148 }\r
878ddf1f 1149\r
a29c47e0 1150 /**\r
1151 * Retrive library's constructor name\r
ff225cbb 1152 *\r
a29c47e0 1153 * @returns constructor name list if elements are found at the known xpath\r
1154 * @returns null if nothing is there\r
1155 */\r
83fba802 1156 public String getLibConstructorName() {\r
a29c47e0 1157 String[] xPath = new String[] { "/Extern/Constructor" };\r
878ddf1f 1158\r
a29c47e0 1159 Object[] returns = get("Externs", xPath);\r
878ddf1f 1160 if (returns != null && returns.length > 0) {\r
136adffc 1161 CNameType constructor = ((CNameType) returns[0]);\r
1162 return constructor.getStringValue();\r
878ddf1f 1163 }\r
1164\r
1165 return null;\r
1166 }\r
1167\r
1168 /**\r
a29c47e0 1169 * Retrive library's destructor name\r
ff225cbb 1170 *\r
a29c47e0 1171 * @returns destructor name list if elements are found at the known xpath\r
1172 * @returns null if nothing is there\r
1173 */\r
83fba802 1174 public String getLibDestructorName() {\r
a29c47e0 1175 String[] xPath = new String[] { "/Extern/Destructor" };\r
878ddf1f 1176\r
a29c47e0 1177 Object[] returns = get("Externs", xPath);\r
878ddf1f 1178 if (returns != null && returns.length > 0) {\r
136adffc 1179 //\r
1180 // Only support one Destructor function.\r
1181 //\r
1182 CNameType destructor = (CNameType) returns[0];\r
1183 return destructor.getStringValue();\r
878ddf1f 1184 }\r
1185\r
1186 return null;\r
1187 }\r
878ddf1f 1188\r
a29c47e0 1189 /**\r
1190 * Retrive DriverBinding names\r
ff225cbb 1191 *\r
a29c47e0 1192 * @returns DriverBinding name list if elements are found at the known xpath\r
1193 * @returns null if nothing is there\r
1194 */\r
83fba802 1195 public String[] getDriverBindingArray() {\r
a29c47e0 1196 String[] xPath = new String[] { "/Extern/DriverBinding" };\r
878ddf1f 1197 return getCNames("Externs", xPath);\r
1198 }\r
878ddf1f 1199\r
a29c47e0 1200 /**\r
1201 * Retrive ComponentName names\r
ff225cbb 1202 *\r
a29c47e0 1203 * @returns ComponentName name list if elements are found at the known xpath\r
1204 * @returns null if nothing is there\r
1205 */\r
83fba802 1206 public String[] getComponentNameArray() {\r
a29c47e0 1207 String[] xPath = new String[] { "/Extern/ComponentName" };\r
878ddf1f 1208 return getCNames("Externs", xPath);\r
1209 }\r
878ddf1f 1210\r
a29c47e0 1211 /**\r
1212 * Retrive DriverConfig names\r
ff225cbb 1213 *\r
a29c47e0 1214 * @returns DriverConfig name list if elements are found at the known xpath\r
1215 * @returns null if nothing is there\r
1216 */\r
83fba802 1217 public String[] getDriverConfigArray() {\r
a29c47e0 1218 String[] xPath = new String[] { "/Extern/DriverConfig" };\r
878ddf1f 1219 return getCNames("Externs", xPath);\r
1220 }\r
878ddf1f 1221\r
a29c47e0 1222 /**\r
1223 * Retrive DriverDiag names\r
ff225cbb 1224 *\r
a29c47e0 1225 * @returns DriverDiag name list if elements are found at the known xpath\r
1226 * @returns null if nothing is there\r
1227 */\r
83fba802 1228 public String[] getDriverDiagArray() {\r
a29c47e0 1229 String[] xPath = new String[] { "/Extern/DriverDiag" };\r
878ddf1f 1230 return getCNames("Externs", xPath);\r
1231 }\r
1232\r
d8f1335e 1233 /**\r
1234 * Retrive DriverBinding, ComponentName, DriverConfig,\r
1235 * DriverDiag group array\r
1236 * \r
1237 * @returns DriverBinding group name list if elements are found\r
1238 * at the known xpath\r
1239 * @returns null if nothing is there\r
1240 */\r
1241 public String[][] getExternProtocolGroup() {\r
1242 String[] xPath = new String[] {"/Extern"};\r
1243 Object[] returns = get("Externs",xPath);\r
1244\r
1245 if (returns == null) {\r
1246 return new String[0][4];\r
1247 }\r
1248 List<Extern> externList = new ArrayList<Extern>();\r
1249 for (int i = 0; i < returns.length; i++) {\r
1250 org.tianocore.ExternsDocument.Externs.Extern extern = (org.tianocore.ExternsDocument.Externs.Extern)returns[i];\r
1251 if (extern.getDriverBinding() != null) {\r
1252 externList.add(extern);\r
1253 }\r
1254 }\r
1255\r
1256 String[][] externGroup = new String[externList.size()][4];\r
1257 for (int i = 0; i < externList.size(); i++) {\r
1258 String driverBindingStr = externList.get(i).getDriverBinding();\r
1259 if ( driverBindingStr != null){\r
1260 externGroup[i][0] = driverBindingStr;\r
1261 } else {\r
1262 externGroup[i][0] = null;\r
1263 }\r
1264\r
1265 String componentNameStr = externList.get(i).getComponentName();\r
1266 if (componentNameStr != null) {\r
1267 externGroup[i][1] = componentNameStr;\r
1268 } else {\r
1269 externGroup[i][1] = null;\r
1270 }\r
1271\r
1272 String driverConfigStr = externList.get(i).getDriverConfig();\r
1273 if (driverConfigStr != null) {\r
1274 externGroup[i][2] = driverConfigStr;\r
1275 } else {\r
1276 externGroup[i][2] = null;\r
1277 }\r
1278\r
1279 String driverDiagStr = externList.get(i).getDriverDiag();\r
1280 if (driverDiagStr != null) {\r
1281 externGroup[i][3] = driverDiagStr;\r
1282 } else {\r
1283 externGroup[i][3] = null;\r
1284 }\r
1285 }\r
1286 return externGroup;\r
1287 }\r
1288 \r
878ddf1f 1289 /**\r
a29c47e0 1290 * Retrive SetVirtualAddressMapCallBack names\r
ff225cbb 1291 *\r
a29c47e0 1292 * @returns SetVirtualAddressMapCallBack name list if elements are found at\r
1293 * the known xpath\r
1294 * @returns null if nothing is there\r
1295 */\r
83fba802 1296 public String[] getSetVirtualAddressMapCallBackArray() {\r
a29c47e0 1297 String[] xPath = new String[] { "/Extern/SetVirtualAddressMapCallBack" };\r
878ddf1f 1298 return getCNames("Externs", xPath);\r
1299 }\r
878ddf1f 1300\r
a29c47e0 1301 /**\r
1302 * Retrive ExitBootServicesCallBack names\r
ff225cbb 1303 *\r
a29c47e0 1304 * @returns ExitBootServicesCallBack name list if elements are found at the\r
1305 * known xpath\r
1306 * @returns null if nothing is there\r
1307 */\r
83fba802 1308 public String[] getExitBootServicesCallBackArray() {\r
a29c47e0 1309 String[] xPath = new String[] { "/Extern/ExitBootServicesCallBack" };\r
878ddf1f 1310 return getCNames("Externs", xPath);\r
1311 }\r
1312\r
5f907e4a 1313 /**\r
1314 Judge whether current driver is PEI_PCD_DRIVER or DXE_PCD_DRIVER or\r
1315 NOT_PCD_DRIVER.\r
1316 \r
1317 @return CommonDefinition.PCD_DRIVER_TYPE the type of current driver\r
1318 **/\r
83fba802 1319 public CommonDefinition.PCD_DRIVER_TYPE getPcdDriverType() {\r
5f907e4a 1320 String[] xPath = new String[] {"/PcdIsDriver"};\r
1321 Object[] results = get ("Externs", xPath);\r
1322\r
1323 if (results != null && results.length != 0) {\r
1324 PcdDriverTypes type = (PcdDriverTypes) results[0];\r
1325 String typeStr = type.enumValue().toString();\r
1326 if (typeStr.equals(CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER.toString())) {\r
1327 return CommonDefinition.PCD_DRIVER_TYPE.PEI_PCD_DRIVER;\r
1328 } else if (typeStr.equals(CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER.toString())) {\r
1329 return CommonDefinition.PCD_DRIVER_TYPE.DXE_PCD_DRIVER;\r
1330 }\r
1331 return CommonDefinition.PCD_DRIVER_TYPE.UNKNOWN_PCD_DRIVER;\r
1332 }\r
1333\r
1334 return CommonDefinition.PCD_DRIVER_TYPE.NOT_PCD_DRIVER;\r
1335 }\r
1336\r
878ddf1f 1337 /**\r
a29c47e0 1338 * Retrieve module surface area file information\r
ff225cbb 1339 *\r
a29c47e0 1340 * @returns ModuleSA objects list if elements are found at the known xpath\r
1341 * @returns Empty ModuleSA list if nothing is there\r
1342 */\r
892b0e7a 1343 public Map<FpdModuleIdentification, Map<String, XmlObject>> getFpdModules() throws EdkException {\r
a29c47e0 1344 String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r
1345 Object[] result = get("PlatformSurfaceArea", xPath);\r
1346 String arch = null;\r
1347 String fvBinding = null;\r
1348 String saGuid = null;\r
1349 String saVersion = null;\r
1350 String pkgGuid = null;\r
1351 String pkgVersion = null;\r
1352\r
1353 Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleMap = new LinkedHashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r
878ddf1f 1354\r
878ddf1f 1355 if (result == null) {\r
a29c47e0 1356 return fpdModuleMap;\r
1357 }\r
1358\r
1359 for (int i = 0; i < result.length; i++) {\r
1360 //\r
1361 // Get Fpd SA Module element node and add to ObjectMap.\r
1362 //\r
1363 Map<String, XmlObject> ObjectMap = new HashMap<String, XmlObject>();\r
1364 ModuleSADocument.ModuleSA moduleSA = (ModuleSADocument.ModuleSA) result[i];\r
1365 if (((ModuleSADocument.ModuleSA) result[i]).getLibraries() != null) {\r
1366 ObjectMap.put("Libraries", moduleSA.getLibraries());\r
1367 }\r
1368 if (((ModuleSADocument.ModuleSA) result[i]).getPcdBuildDefinition() != null) {\r
19d66cd5 1369 ObjectMap.put("PcdBuildDefinition", moduleSA.getPcdBuildDefinition());\r
a29c47e0 1370 }\r
19d66cd5 1371 if (((ModuleSADocument.ModuleSA) result[i]).getModuleSaBuildOptions() != null) {\r
1372 ObjectMap.put("ModuleSaBuildOptions", moduleSA.getModuleSaBuildOptions());\r
a29c47e0 1373 }\r
1374\r
1375 //\r
1376 // Get Fpd SA Module attribute and create FpdMoudleIdentification.\r
1377 //\r
19d66cd5 1378 if (moduleSA.isSetSupArchList()) {\r
ae208998 1379 arch = moduleSA.getSupArchList().toString();\r
19d66cd5 1380 } else {\r
1381 arch = null;\r
ae208998 1382 }\r
a29c47e0 1383\r
1384 // TBD\r
1385 fvBinding = null;\r
19d66cd5 1386 saVersion = ((ModuleSADocument.ModuleSA) result[i]).getModuleVersion();\r
a29c47e0 1387\r
1388 saGuid = moduleSA.getModuleGuid();\r
1389 pkgGuid = moduleSA.getPackageGuid();\r
1390 pkgVersion = moduleSA.getPackageVersion();\r
1391\r
1392 //\r
1393 // Create Module Identification which have class member of package\r
1394 // identification.\r
1395 //\r
19d66cd5 1396 PackageIdentification pkgId = new PackageIdentification(null, pkgGuid, pkgVersion);\r
892b0e7a 1397 GlobalData.refreshPackageIdentification(pkgId);\r
89e1408f 1398 \r
19d66cd5 1399 ModuleIdentification saId = new ModuleIdentification(null, saGuid, saVersion);\r
89e1408f 1400 saId.setPackage(pkgId);\r
892b0e7a 1401 GlobalData.refreshModuleIdentification(saId);\r
1402 \r
89e1408f 1403\r
a29c47e0 1404\r
1405 //\r
1406 // Create FpdModule Identification which have class member of module\r
1407 // identification\r
1408 //\r
ae208998 1409 String[] archList = new String[0];\r
1410 if (arch == null || arch.trim().length() == 0) {\r
1411 archList = GlobalData.getToolChainInfo().getArchs();\r
19d66cd5 1412 } else {\r
ae208998 1413 archList = arch.split(" ");\r
1414 }\r
1415 for (int j = 0; j < archList.length; j++) {\r
19d66cd5 1416 FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId, archList[j]);\r
ff225cbb 1417\r
ae208998 1418 if (fvBinding != null) {\r
1419 fpdSaId.setFvBinding(fvBinding);\r
a29c47e0 1420 }\r
ff225cbb 1421\r
ae208998 1422 //\r
1423 // Put element to Map<FpdModuleIdentification, Map<String,\r
1424 // Object>>.\r
1425 //\r
1426 fpdModuleMap.put(fpdSaId, ObjectMap);\r
250258de 1427 }\r
878ddf1f 1428 }\r
a29c47e0 1429 return fpdModuleMap;\r
1430 }\r
878ddf1f 1431\r
a29c47e0 1432 /**\r
1433 * Retrieve valid image names\r
ff225cbb 1434 *\r
a29c47e0 1435 * @returns valid iamges name list if elements are found at the known xpath\r
1436 * @returns empty list if nothing is there\r
1437 */\r
83fba802 1438 public String[] getFpdValidImageNames() {\r
a29c47e0 1439 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };\r
1440\r
1441 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1442 if (queryResult == null) {\r
1443 return new String[0];\r
1444 }\r
1445\r
1446 String[] result = new String[queryResult.length];\r
1447 for (int i = 0; i < queryResult.length; i++) {\r
1448 result[i] = ((XmlString) queryResult[i]).getStringValue();\r
1449 }\r
1450\r
1451 return result;\r
1452 }\r
ff225cbb 1453\r
83fba802 1454 public Node getFpdUserExtensionPreBuild() {\r
ff225cbb 1455 String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" };\r
8cf5da75 1456\r
1457 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1458 if (queryResult == null || queryResult.length == 0) {\r
1459 return null;\r
1460 }\r
1461 UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0];\r
ff225cbb 1462\r
8cf5da75 1463 return a.getDomNode();\r
1464 }\r
ff225cbb 1465\r
83fba802 1466 public Node getFpdUserExtensionPostBuild() {\r
ff225cbb 1467 String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" };\r
a29c47e0 1468\r
1469 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
80785fd5 1470 if (queryResult == null || queryResult.length == 0) {\r
a29c47e0 1471 return null;\r
1472 }\r
8031d48d 1473 UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0];\r
ff225cbb 1474\r
8031d48d 1475 return a.getDomNode();\r
878ddf1f 1476 }\r
1477\r
03b1a72d 1478 /**\r
a29c47e0 1479 * Retrieve FV image option information\r
ff225cbb 1480 *\r
a29c47e0 1481 * @param fvName\r
1482 * FV image name\r
ff225cbb 1483 *\r
a29c47e0 1484 * @returns option name/value list if elements are found at the known xpath\r
1485 * @returns empty list if nothing is there\r
1486 */\r
83fba802 1487 public String[][] getFpdOptions(String fvName) {\r
a29c47e0 1488 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"\r
57cc2ee7 1489 + fvName + "']/FvImageOptions" };\r
a29c47e0 1490 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1491 if (queryResult == null) {\r
1492 return new String[0][];\r
1493 }\r
1494 ArrayList<String[]> list = new ArrayList<String[]>();\r
1495 for (int i = 0; i < queryResult.length; i++) {\r
1496 FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r
1497 List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item\r
1498 .getNameValueList();\r
1499 Iterator iter = namevalues.iterator();\r
1500 while (iter.hasNext()) {\r
1501 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r
1502 .next();\r
1503 list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r
1504 }\r
1505 }\r
1506 String[][] result = new String[list.size()][2];\r
1507 for (int i = 0; i < list.size(); i++) {\r
1508 result[i][0] = list.get(i)[0];\r
1509 result[i][1] = list.get(i)[1];\r
1510 }\r
1511 return result;\r
03b1a72d 1512\r
a29c47e0 1513 }\r
03b1a72d 1514\r
83fba802 1515 public XmlObject getFpdBuildOptions() {\r
a29c47e0 1516 String[] xPath = new String[] { "/BuildOptions" };\r
1517\r
1518 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1519\r
1520 if (queryResult == null || queryResult.length == 0) {\r
1521 return null;\r
03b1a72d 1522 }\r
a29c47e0 1523 return (XmlObject)queryResult[0];\r
1524 }\r
1525\r
83fba802 1526 public PlatformIdentification getFpdHeader() {\r
a29c47e0 1527 String[] xPath = new String[] { "/PlatformHeader" };\r
1528\r
1529 Object[] returns = get("PlatformSurfaceArea", xPath);\r
1530\r
1531 if (returns == null || returns.length == 0) {\r
1532 return null;\r
1533 }\r
1534 PlatformHeaderDocument.PlatformHeader header = (PlatformHeaderDocument.PlatformHeader) returns[0];\r
1535\r
1536 String name = header.getPlatformName();\r
1537\r
1538 String guid = header.getGuidValue();\r
1539\r
1540 String version = header.getVersion();\r
1541\r
1542 return new PlatformIdentification(name, guid, version);\r
03b1a72d 1543 }\r
1544\r
878ddf1f 1545 /**\r
a29c47e0 1546 * Retrieve FV image attributes information\r
ff225cbb 1547 *\r
a29c47e0 1548 * @param fvName\r
1549 * FV image name\r
ff225cbb 1550 *\r
a29c47e0 1551 * @returns attribute name/value list if elements are found at the known\r
1552 * xpath\r
1553 * @returns empty list if nothing is there\r
1554 */\r
83fba802 1555 public String[][] getFpdAttributes(String fvName) {\r
a29c47e0 1556 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"\r
57cc2ee7 1557 + fvName + "']/FvImageOptions" };\r
a29c47e0 1558 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1559 if (queryResult == null) {\r
1560 return new String[0][];\r
1561 }\r
1562 ArrayList<String[]> list = new ArrayList<String[]>();\r
1563 for (int i = 0; i < queryResult.length; i++) {\r
ff225cbb 1564\r
a29c47e0 1565 FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r
1566 List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item.getNameValueList();\r
1567 Iterator iter = namevalues.iterator();\r
1568 while (iter.hasNext()) {\r
1569 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r
1570 .next();\r
1571 list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r
1572 }\r
1573 }\r
1574 String[][] result = new String[list.size()][2];\r
1575 for (int i = 0; i < list.size(); i++) {\r
1576 result[i][0] = list.get(i)[0];\r
1577 result[i][1] = list.get(i)[1];\r
1578 }\r
1579 return result;\r
1580 }\r
1581\r
1582 /**\r
1583 * Retrieve flash definition file name\r
ff225cbb 1584 *\r
a29c47e0 1585 * @returns file name if elements are found at the known xpath\r
1586 * @returns null if nothing is there\r
1587 */\r
83fba802 1588 public String getFlashDefinitionFile() {\r
a29c47e0 1589 String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };\r
1590\r
1591 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1592 if (queryResult == null || queryResult.length == 0) {\r
1593 return null;\r
1594 }\r
1595\r
1596 FileNameConvention filename = (FileNameConvention) queryResult[queryResult.length - 1];\r
1597 return filename.getStringValue();\r
1598 }\r
878ddf1f 1599\r
83fba802 1600 public String[][] getFpdGlobalVariable() {\r
878ddf1f 1601 String[] xPath = new String[] { "/Flash/FvImages/NameValue" };\r
a29c47e0 1602 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
878ddf1f 1603 if (queryResult == null) {\r
1604 return new String[0][];\r
1605 }\r
1606\r
1607 String[][] result = new String[queryResult.length][2];\r
ff225cbb 1608\r
a29c47e0 1609 for (int i = 0; i < queryResult.length; i++) {\r
1610 FvImagesDocument.FvImages.NameValue item = (FvImagesDocument.FvImages.NameValue)queryResult[i];\r
1611 result[i][0] = item.getName();\r
1612 result[i][1] = item.getValue();\r
878ddf1f 1613 }\r
ff225cbb 1614 return result;\r
878ddf1f 1615 }\r
ff225cbb 1616\r
878ddf1f 1617 /**\r
a29c47e0 1618 * Retrieve FV image component options\r
ff225cbb 1619 *\r
a29c47e0 1620 * @param fvName\r
1621 * FV image name\r
ff225cbb 1622 *\r
a29c47e0 1623 * @returns name/value pairs list if elements are found at the known xpath\r
1624 * @returns empty list if nothing is there\r
1625 */\r
83fba802 1626 public String[][] getFpdComponents(String fvName) {\r
57cc2ee7 1627 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName + "']/FvImageOptions" };\r
a29c47e0 1628 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
878ddf1f 1629 if (queryResult == null) {\r
a29c47e0 1630 return new String[0][];\r
878ddf1f 1631 }\r
1632\r
a29c47e0 1633 ArrayList<String[]> list = new ArrayList<String[]>();\r
1634 for (int i = 0; i < queryResult.length; i++) {\r
1635 FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r
1636 List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item.getNameValueList();\r
1637 Iterator iter = namevalues.iterator();\r
1638 while (iter.hasNext()) {\r
1639 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r
1640 .next();\r
1641 list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r
1642 }\r
1643 }\r
1644 String[][] result = new String[list.size()][2];\r
1645 for (int i = 0; i < list.size(); i++) {\r
1646 result[i][0] = list.get(i)[0];\r
1647 result[i][1] = list.get(i)[1];\r
878ddf1f 1648 }\r
ff225cbb 1649 return result;\r
a29c47e0 1650 }\r
878ddf1f 1651\r
a29c47e0 1652 /**\r
1653 * Retrieve PCD tokens\r
ff225cbb 1654 *\r
a29c47e0 1655 * @returns CName/ItemType pairs list if elements are found at the known\r
1656 * xpath\r
1657 * @returns null if nothing is there\r
1658 */\r
83fba802 1659 public String[][] getPcdTokenArray() {\r
a29c47e0 1660 String[] xPath = new String[] { "/PcdData" };\r
1661\r
1662 Object[] returns = get("PCDs", xPath);\r
1663 if (returns == null || returns.length == 0) {\r
1664 return null;\r
1665 }\r
1666\r
a29c47e0 1667 return null;\r
a29c47e0 1668 }\r
1669\r
1670 /**\r
1671 * Retrieve MAS header\r
ff225cbb 1672 *\r
a29c47e0 1673 * @return\r
1674 * @return\r
1675 */\r
83fba802 1676 public ModuleIdentification getMsaHeader() {\r
a29c47e0 1677 String[] xPath = new String[] { "/" };\r
1678 Object[] returns = get("MsaHeader", xPath);\r
1679\r
1680 if (returns == null || returns.length == 0) {\r
1681 return null;\r
1682 }\r
1683\r
1684 MsaHeader msaHeader = (MsaHeader) returns[0];\r
1685 //\r
1686 // Get BaseName, ModuleType, GuidValue, Version\r
1687 // which in MsaHeader.\r
1688 //\r
1689 String name = msaHeader.getModuleName();\r
1690 String moduleType = msaHeader.getModuleType().toString();\r
1691 String guid = msaHeader.getGuidValue();\r
1692 String version = msaHeader.getVersion();\r
878ddf1f 1693\r
a29c47e0 1694 ModuleIdentification moduleId = new ModuleIdentification(name, guid,\r
1695 version);\r
878ddf1f 1696\r
a29c47e0 1697 moduleId.setModuleType(moduleType);\r
1698\r
1699 return moduleId;\r
1700 }\r
878ddf1f 1701\r
a29c47e0 1702 /**\r
1703 * Retrieve Extern Specification\r
ff225cbb 1704 *\r
a29c47e0 1705 * @param\r
ff225cbb 1706 *\r
a29c47e0 1707 * @return String[] If have specification element in the <extern> String[0]\r
1708 * If no specification element in the <extern>\r
ff225cbb 1709 *\r
a29c47e0 1710 */\r
1711\r
83fba802 1712 public String[] getExternSpecificaiton() {\r
a29c47e0 1713 String[] xPath = new String[] { "/Specification" };\r
1714\r
1715 Object[] queryResult = get("Externs", xPath);\r
878ddf1f 1716 if (queryResult == null) {\r
a29c47e0 1717 return new String[0];\r
878ddf1f 1718 }\r
1719\r
a29c47e0 1720 String[] specificationList = new String[queryResult.length];\r
1721 for (int i = 0; i < queryResult.length; i++) {\r
136adffc 1722 specificationList[i] = ((Sentence)queryResult[i])\r
1723 .getStringValue();\r
878ddf1f 1724 }\r
a29c47e0 1725 return specificationList;\r
1726 }\r
878ddf1f 1727\r
a29c47e0 1728 /**\r
1729 * Retreive MsaFile which in SPD\r
ff225cbb 1730 *\r
a29c47e0 1731 * @param\r
1732 * @return String[][3] The string sequence is ModuleName, ModuleGuid,\r
1733 * ModuleVersion, MsaFile String[0][] If no msafile in SPD\r
1734 */\r
83fba802 1735 public String[] getSpdMsaFile() {\r
a29c47e0 1736 String[] xPath = new String[] { "/MsaFiles" };\r
1737\r
1738 Object[] returns = get("PackageSurfaceArea", xPath);\r
1739 if (returns == null) {\r
1740 return new String[0];\r
1741 }\r
1742\r
1743 List<String> filenameList = ((MsaFilesDocument.MsaFiles) returns[0])\r
1744 .getFilenameList();\r
1745 return filenameList.toArray(new String[filenameList.size()]);\r
878ddf1f 1746 }\r
a29c47e0 1747\r
878ddf1f 1748 /**\r
a29c47e0 1749 * Reteive\r
1750 */\r
83fba802 1751 public Map<String, String[]> getSpdLibraryClasses() {\r
a29c47e0 1752 String[] xPath = new String[] { "/LibraryClassDeclarations/LibraryClass" };\r
878ddf1f 1753\r
a29c47e0 1754 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1755\r
a29c47e0 1756 //\r
1757 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.\r
1758 //\r
1759 Map<String, String[]> libClassHeaderMap = new HashMap<String, String[]>();\r
878ddf1f 1760\r
a29c47e0 1761 if (returns == null) {\r
1762 return libClassHeaderMap;\r
878ddf1f 1763 }\r
1764\r
a29c47e0 1765 for (int i = 0; i < returns.length; i++) {\r
1766 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass library = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass) returns[i];\r
1767 libClassHeaderMap.put(library.getName(), new String[] { library\r
1768 .getIncludeHeader() });\r
1769 }\r
1770 return libClassHeaderMap;\r
1771 }\r
878ddf1f 1772\r
a29c47e0 1773 /**\r
1774 * Reteive\r
1775 */\r
83fba802 1776 public Map<String, String> getSpdPackageHeaderFiles() {\r
a29c47e0 1777 String[] xPath = new String[] { "/PackageHeaders/IncludePkgHeader" };\r
878ddf1f 1778\r
a29c47e0 1779 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1780\r
a29c47e0 1781 //\r
1782 // Create Map, Key - ModuleType, String - PackageInclude Header file.\r
1783 //\r
1784 Map<String, String> packageIncludeMap = new HashMap<String, String>();\r
1785\r
1786 if (returns == null) {\r
1787 return packageIncludeMap;\r
878ddf1f 1788 }\r
7d6ef0a9 1789\r
a29c47e0 1790 for (int i = 0; i < returns.length; i++) {\r
1791 PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i];\r
1792 packageIncludeMap.put(includeHeader.getModuleType().toString(),\r
1793 includeHeader.getStringValue());\r
1794 }\r
1795 return packageIncludeMap;\r
1796 }\r
878ddf1f 1797\r
83fba802 1798 public PackageIdentification getSpdHeader() {\r
a29c47e0 1799 String[] xPath = new String[] { "/SpdHeader" };\r
1800\r
1801 Object[] returns = get("PackageSurfaceArea", xPath);\r
1802\r
1803 if (returns == null || returns.length == 0) {\r
1804 return null;\r
878ddf1f 1805 }\r
1806\r
a29c47e0 1807 SpdHeaderDocument.SpdHeader header = (SpdHeaderDocument.SpdHeader) returns[0];\r
1808\r
1809 String name = header.getPackageName();\r
1810\r
1811 String guid = header.getGuidValue();\r
1812\r
1813 String version = header.getVersion();\r
1814\r
1815 return new PackageIdentification(name, guid, version);\r
878ddf1f 1816 }\r
a29c47e0 1817\r
878ddf1f 1818 /**\r
a29c47e0 1819 * Reteive\r
1820 */\r
83fba802 1821 public Map<String, String[]> getSpdGuid() {\r
a29c47e0 1822 String[] xPath = new String[] { "/GuidDeclarations/Entry" };\r
878ddf1f 1823\r
a29c47e0 1824 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1825\r
a29c47e0 1826 //\r
1827 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.\r
1828 //\r
1829 Map<String, String[]> guidDeclMap = new HashMap<String, String[]>();\r
1830 if (returns == null) {\r
1831 return guidDeclMap;\r
878ddf1f 1832 }\r
1833\r
a29c47e0 1834 for (int i = 0; i < returns.length; i++) {\r
1835 GuidDeclarationsDocument.GuidDeclarations.Entry entry = (GuidDeclarationsDocument.GuidDeclarations.Entry) returns[i];\r
1836 String[] guidPair = new String[2];\r
1837 guidPair[0] = entry.getCName();\r
1838 guidPair[1] = entry.getGuidValue();\r
53b86193 1839 guidDeclMap.put(entry.getCName(), guidPair);\r
a29c47e0 1840 }\r
1841 return guidDeclMap;\r
878ddf1f 1842 }\r
a29c47e0 1843\r
878ddf1f 1844 /**\r
a29c47e0 1845 * Reteive\r
1846 */\r
83fba802 1847 public Map<String, String[]> getSpdProtocol() {\r
a29c47e0 1848 String[] xPath = new String[] { "/ProtocolDeclarations/Entry" };\r
878ddf1f 1849\r
a29c47e0 1850 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1851\r
a29c47e0 1852 //\r
1853 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.\r
1854 //\r
1855 Map<String, String[]> protoclMap = new HashMap<String, String[]>();\r
878ddf1f 1856\r
a29c47e0 1857 if (returns == null) {\r
1858 return protoclMap;\r
878ddf1f 1859 }\r
1860\r
a29c47e0 1861 for (int i = 0; i < returns.length; i++) {\r
1862 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry entry = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) returns[i];\r
1863 String[] protocolPair = new String[2];\r
878ddf1f 1864\r
a29c47e0 1865 protocolPair[0] = entry.getCName();\r
1866 protocolPair[1] = entry.getGuidValue();\r
53b86193 1867 protoclMap.put(entry.getCName(), protocolPair);\r
a29c47e0 1868 }\r
1869 return protoclMap;\r
1870 }\r
878ddf1f 1871\r
a29c47e0 1872 /**\r
1873 * getSpdPpi() Retrieve the SPD PPI Entry\r
ff225cbb 1874 *\r
a29c47e0 1875 * @param\r
1876 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI\r
1877 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI\r
1878 * entry in SPD.\r
1879 */\r
83fba802 1880 public Map<String, String[]> getSpdPpi() {\r
a29c47e0 1881 String[] xPath = new String[] { "/PpiDeclarations/Entry" };\r
1882\r
1883 Object[] returns = get("PackageSurfaceArea", xPath);\r
1884\r
1885 //\r
1886 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.\r
1887 //\r
1888 Map<String, String[]> ppiMap = new HashMap<String, String[]>();\r
878ddf1f 1889\r
a29c47e0 1890 if (returns == null) {\r
1891 return ppiMap;\r
878ddf1f 1892 }\r
1893\r
a29c47e0 1894 for (int i = 0; i < returns.length; i++) {\r
1895 PpiDeclarationsDocument.PpiDeclarations.Entry entry = (PpiDeclarationsDocument.PpiDeclarations.Entry) returns[i];\r
1896 String[] ppiPair = new String[2];\r
1897 ppiPair[0] = entry.getCName();\r
1898 ppiPair[1] = entry.getGuidValue();\r
53b86193 1899 ppiMap.put(entry.getCName(), ppiPair);\r
878ddf1f 1900 }\r
a29c47e0 1901 return ppiMap;\r
878ddf1f 1902 }\r
a29c47e0 1903\r
a29c47e0 1904 /**\r
1905 * Retrieve module Guid string\r
ff225cbb 1906 *\r
a29c47e0 1907 * @returns GUILD string if elements are found at the known xpath\r
1908 * @returns null if nothing is there\r
1909 */\r
83fba802 1910 public String getModuleGuid() {\r
a29c47e0 1911 String[] xPath = new String[] { "" };\r
1912\r
1913 Object[] returns = get("MsaHeader", xPath);\r
1914 if (returns != null && returns.length > 0) {\r
1915 String guid = ((MsaHeaderDocument.MsaHeader) returns[0])\r
1916 .getGuidValue();\r
1917 return guid;\r
ad82307c 1918 }\r
a29c47e0 1919\r
1920 return null;\r
1921 }\r
1922\r
1923 //\r
1924 // For new Pcd\r
1925 //\r
83fba802 1926 public ModuleSADocument.ModuleSA[] getFpdModuleSAs() {\r
a29c47e0 1927 String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r
1928 Object[] result = get("PlatformSurfaceArea", xPath);\r
1929 if (result != null) {\r
1930 return (ModuleSADocument.ModuleSA[]) result;\r
1931 }\r
1932 return new ModuleSADocument.ModuleSA[0];\r
1933\r
878ddf1f 1934 }\r
136adffc 1935 /**\r
1936 Get name array of PCD in a module. In one module, token space\r
1937 is same, and token name should not be conflicted.\r
ff225cbb 1938\r
136adffc 1939 @return String[]\r
7d6ef0a9 1940 **/\r
83fba802 1941 public String[] getModulePcdEntryNameArray() {\r
7d6ef0a9 1942 PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null;\r
1943 String[] results;\r
1944 int index;\r
1945 String[] xPath = new String[] {"/PcdEntry"};\r
1946 Object[] returns = get ("PcdCoded", xPath);\r
1947\r
1948 if (returns == null) {\r
1949 return new String[0];\r
1950 }\r
1951\r
1952 pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns;\r
1953 results = new String[pcdEntries.length];\r
1954\r
1955 for (index = 0; index < pcdEntries.length; index ++) {\r
1956 results[index] = pcdEntries[index].getCName();\r
1957 }\r
1958 return results;\r
1959 }\r
1960\r
1961 /**\r
1962 Search in a List for a given string\r
1963\r
1964 @return boolean\r
1965 **/\r
83fba802 1966 public boolean contains(List list, String str) {\r
42b78757 1967 if (list == null || list.size()== 0) {\r
1968 return true;\r
1969 }\r
7d6ef0a9 1970 Iterator it = list.iterator();\r
1971 while (it.hasNext()) {\r
1972 String s = (String)it.next();\r
1973 if (s.equalsIgnoreCase(str)) {\r
1974 return true;\r
1975 }\r
1976 }\r
1977\r
1978 return false;\r
1979 }\r
73b4e31a 1980\r
83fba802 1981 public boolean isHaveTianoR8FlashMap(){\r
73b4e31a 1982 String[] xPath = new String[] {"/"};\r
1983 Object[] returns = get ("Externs", xPath);\r
1984\r
1985 if (returns == null) {\r
1986 return false;\r
1987 }\r
1988\r
1989 ExternsDocument.Externs ext = (ExternsDocument.Externs)returns[0];\r
ff225cbb 1990\r
73b4e31a 1991 if (ext.getTianoR8FlashMapH()){\r
1992 return true;\r
1993 }else {\r
1994 return false;\r
1995 }\r
1996 }\r
bb511931 1997 \r
1998 public Node getFpdModuleSequence(String fvName) {\r
1999 String[] xPath = new String[] { "/BuildOptions/UserExtensions[@UserID='IMAGES' and @Identifier='1' and ./FvName='" + fvName + "']" };\r
2000 Object[] result = get("PlatformSurfaceArea", xPath);\r
2001 \r
2002 if (result == null || result.length == 0) {\r
2003 return null;\r
2004 }\r
2005 \r
2006 UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)result[0];\r
2007 \r
2008 return a.getDomNode();\r
2009 }\r
878ddf1f 2010}\r