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