]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
Modify for enabling native VISTA
[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
19d66cd5 1363 ModuleIdentification saId = new ModuleIdentification(null, saGuid, saVersion);\r
892b0e7a 1364 GlobalData.refreshModuleIdentification(saId);\r
1365 \r
a29c47e0 1366 saId.setPackage(pkgId);\r
1367\r
1368 //\r
1369 // Create FpdModule Identification which have class member of module\r
1370 // identification\r
1371 //\r
ae208998 1372 String[] archList = new String[0];\r
1373 if (arch == null || arch.trim().length() == 0) {\r
1374 archList = GlobalData.getToolChainInfo().getArchs();\r
19d66cd5 1375 } else {\r
ae208998 1376 archList = arch.split(" ");\r
1377 }\r
1378 for (int j = 0; j < archList.length; j++) {\r
19d66cd5 1379 FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId, archList[j]);\r
ff225cbb 1380\r
ae208998 1381 if (fvBinding != null) {\r
1382 fpdSaId.setFvBinding(fvBinding);\r
a29c47e0 1383 }\r
ff225cbb 1384\r
ae208998 1385 //\r
1386 // Put element to Map<FpdModuleIdentification, Map<String,\r
1387 // Object>>.\r
1388 //\r
1389 fpdModuleMap.put(fpdSaId, ObjectMap);\r
250258de 1390 }\r
878ddf1f 1391 }\r
a29c47e0 1392 return fpdModuleMap;\r
1393 }\r
878ddf1f 1394\r
a29c47e0 1395 /**\r
1396 * Retrieve valid image names\r
ff225cbb 1397 *\r
a29c47e0 1398 * @returns valid iamges name list if elements are found at the known xpath\r
1399 * @returns empty list if nothing is there\r
1400 */\r
83fba802 1401 public String[] getFpdValidImageNames() {\r
a29c47e0 1402 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };\r
1403\r
1404 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1405 if (queryResult == null) {\r
1406 return new String[0];\r
1407 }\r
1408\r
1409 String[] result = new String[queryResult.length];\r
1410 for (int i = 0; i < queryResult.length; i++) {\r
1411 result[i] = ((XmlString) queryResult[i]).getStringValue();\r
1412 }\r
1413\r
1414 return result;\r
1415 }\r
ff225cbb 1416\r
83fba802 1417 public Node getFpdUserExtensionPreBuild() {\r
ff225cbb 1418 String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" };\r
8cf5da75 1419\r
1420 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1421 if (queryResult == null || queryResult.length == 0) {\r
1422 return null;\r
1423 }\r
1424 UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0];\r
ff225cbb 1425\r
8cf5da75 1426 return a.getDomNode();\r
1427 }\r
ff225cbb 1428\r
83fba802 1429 public Node getFpdUserExtensionPostBuild() {\r
ff225cbb 1430 String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" };\r
a29c47e0 1431\r
1432 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
80785fd5 1433 if (queryResult == null || queryResult.length == 0) {\r
a29c47e0 1434 return null;\r
1435 }\r
8031d48d 1436 UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0];\r
ff225cbb 1437\r
8031d48d 1438 return a.getDomNode();\r
878ddf1f 1439 }\r
1440\r
03b1a72d 1441 /**\r
a29c47e0 1442 * Retrieve FV image option information\r
ff225cbb 1443 *\r
a29c47e0 1444 * @param fvName\r
1445 * FV image name\r
ff225cbb 1446 *\r
a29c47e0 1447 * @returns option name/value list if elements are found at the known xpath\r
1448 * @returns empty list if nothing is there\r
1449 */\r
83fba802 1450 public String[][] getFpdOptions(String fvName) {\r
a29c47e0 1451 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"\r
57cc2ee7 1452 + fvName + "']/FvImageOptions" };\r
a29c47e0 1453 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1454 if (queryResult == null) {\r
1455 return new String[0][];\r
1456 }\r
1457 ArrayList<String[]> list = new ArrayList<String[]>();\r
1458 for (int i = 0; i < queryResult.length; i++) {\r
1459 FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r
1460 List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item\r
1461 .getNameValueList();\r
1462 Iterator iter = namevalues.iterator();\r
1463 while (iter.hasNext()) {\r
1464 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r
1465 .next();\r
1466 list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r
1467 }\r
1468 }\r
1469 String[][] result = new String[list.size()][2];\r
1470 for (int i = 0; i < list.size(); i++) {\r
1471 result[i][0] = list.get(i)[0];\r
1472 result[i][1] = list.get(i)[1];\r
1473 }\r
1474 return result;\r
03b1a72d 1475\r
a29c47e0 1476 }\r
03b1a72d 1477\r
83fba802 1478 public XmlObject getFpdBuildOptions() {\r
a29c47e0 1479 String[] xPath = new String[] { "/BuildOptions" };\r
1480\r
1481 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1482\r
1483 if (queryResult == null || queryResult.length == 0) {\r
1484 return null;\r
03b1a72d 1485 }\r
a29c47e0 1486 return (XmlObject)queryResult[0];\r
1487 }\r
1488\r
83fba802 1489 public PlatformIdentification getFpdHeader() {\r
a29c47e0 1490 String[] xPath = new String[] { "/PlatformHeader" };\r
1491\r
1492 Object[] returns = get("PlatformSurfaceArea", xPath);\r
1493\r
1494 if (returns == null || returns.length == 0) {\r
1495 return null;\r
1496 }\r
1497 PlatformHeaderDocument.PlatformHeader header = (PlatformHeaderDocument.PlatformHeader) returns[0];\r
1498\r
1499 String name = header.getPlatformName();\r
1500\r
1501 String guid = header.getGuidValue();\r
1502\r
1503 String version = header.getVersion();\r
1504\r
1505 return new PlatformIdentification(name, guid, version);\r
03b1a72d 1506 }\r
1507\r
878ddf1f 1508 /**\r
a29c47e0 1509 * Retrieve FV image attributes information\r
ff225cbb 1510 *\r
a29c47e0 1511 * @param fvName\r
1512 * FV image name\r
ff225cbb 1513 *\r
a29c47e0 1514 * @returns attribute name/value list if elements are found at the known\r
1515 * xpath\r
1516 * @returns empty list if nothing is there\r
1517 */\r
83fba802 1518 public String[][] getFpdAttributes(String fvName) {\r
a29c47e0 1519 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"\r
57cc2ee7 1520 + fvName + "']/FvImageOptions" };\r
a29c47e0 1521 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1522 if (queryResult == null) {\r
1523 return new String[0][];\r
1524 }\r
1525 ArrayList<String[]> list = new ArrayList<String[]>();\r
1526 for (int i = 0; i < queryResult.length; i++) {\r
ff225cbb 1527\r
a29c47e0 1528 FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r
1529 List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item.getNameValueList();\r
1530 Iterator iter = namevalues.iterator();\r
1531 while (iter.hasNext()) {\r
1532 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r
1533 .next();\r
1534 list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r
1535 }\r
1536 }\r
1537 String[][] result = new String[list.size()][2];\r
1538 for (int i = 0; i < list.size(); i++) {\r
1539 result[i][0] = list.get(i)[0];\r
1540 result[i][1] = list.get(i)[1];\r
1541 }\r
1542 return result;\r
1543 }\r
1544\r
1545 /**\r
1546 * Retrieve flash definition file name\r
ff225cbb 1547 *\r
a29c47e0 1548 * @returns file name if elements are found at the known xpath\r
1549 * @returns null if nothing is there\r
1550 */\r
83fba802 1551 public String getFlashDefinitionFile() {\r
a29c47e0 1552 String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };\r
1553\r
1554 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1555 if (queryResult == null || queryResult.length == 0) {\r
1556 return null;\r
1557 }\r
1558\r
1559 FileNameConvention filename = (FileNameConvention) queryResult[queryResult.length - 1];\r
1560 return filename.getStringValue();\r
1561 }\r
878ddf1f 1562\r
83fba802 1563 public String[][] getFpdGlobalVariable() {\r
878ddf1f 1564 String[] xPath = new String[] { "/Flash/FvImages/NameValue" };\r
a29c47e0 1565 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
878ddf1f 1566 if (queryResult == null) {\r
1567 return new String[0][];\r
1568 }\r
1569\r
1570 String[][] result = new String[queryResult.length][2];\r
ff225cbb 1571\r
a29c47e0 1572 for (int i = 0; i < queryResult.length; i++) {\r
1573 FvImagesDocument.FvImages.NameValue item = (FvImagesDocument.FvImages.NameValue)queryResult[i];\r
1574 result[i][0] = item.getName();\r
1575 result[i][1] = item.getValue();\r
878ddf1f 1576 }\r
ff225cbb 1577 return result;\r
878ddf1f 1578 }\r
ff225cbb 1579\r
878ddf1f 1580 /**\r
a29c47e0 1581 * Retrieve FV image component options\r
ff225cbb 1582 *\r
a29c47e0 1583 * @param fvName\r
1584 * FV image name\r
ff225cbb 1585 *\r
a29c47e0 1586 * @returns name/value pairs list if elements are found at the known xpath\r
1587 * @returns empty list if nothing is there\r
1588 */\r
83fba802 1589 public String[][] getFpdComponents(String fvName) {\r
57cc2ee7 1590 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName + "']/FvImageOptions" };\r
a29c47e0 1591 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
878ddf1f 1592 if (queryResult == null) {\r
a29c47e0 1593 return new String[0][];\r
878ddf1f 1594 }\r
1595\r
a29c47e0 1596 ArrayList<String[]> list = new ArrayList<String[]>();\r
1597 for (int i = 0; i < queryResult.length; i++) {\r
1598 FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r
1599 List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item.getNameValueList();\r
1600 Iterator iter = namevalues.iterator();\r
1601 while (iter.hasNext()) {\r
1602 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r
1603 .next();\r
1604 list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r
1605 }\r
1606 }\r
1607 String[][] result = new String[list.size()][2];\r
1608 for (int i = 0; i < list.size(); i++) {\r
1609 result[i][0] = list.get(i)[0];\r
1610 result[i][1] = list.get(i)[1];\r
878ddf1f 1611 }\r
ff225cbb 1612 return result;\r
a29c47e0 1613 }\r
878ddf1f 1614\r
a29c47e0 1615 /**\r
1616 * Retrieve PCD tokens\r
ff225cbb 1617 *\r
a29c47e0 1618 * @returns CName/ItemType pairs list if elements are found at the known\r
1619 * xpath\r
1620 * @returns null if nothing is there\r
1621 */\r
83fba802 1622 public String[][] getPcdTokenArray() {\r
a29c47e0 1623 String[] xPath = new String[] { "/PcdData" };\r
1624\r
1625 Object[] returns = get("PCDs", xPath);\r
1626 if (returns == null || returns.length == 0) {\r
1627 return null;\r
1628 }\r
1629\r
a29c47e0 1630 return null;\r
a29c47e0 1631 }\r
1632\r
1633 /**\r
1634 * Retrieve MAS header\r
ff225cbb 1635 *\r
a29c47e0 1636 * @return\r
1637 * @return\r
1638 */\r
83fba802 1639 public ModuleIdentification getMsaHeader() {\r
a29c47e0 1640 String[] xPath = new String[] { "/" };\r
1641 Object[] returns = get("MsaHeader", xPath);\r
1642\r
1643 if (returns == null || returns.length == 0) {\r
1644 return null;\r
1645 }\r
1646\r
1647 MsaHeader msaHeader = (MsaHeader) returns[0];\r
1648 //\r
1649 // Get BaseName, ModuleType, GuidValue, Version\r
1650 // which in MsaHeader.\r
1651 //\r
1652 String name = msaHeader.getModuleName();\r
1653 String moduleType = msaHeader.getModuleType().toString();\r
1654 String guid = msaHeader.getGuidValue();\r
1655 String version = msaHeader.getVersion();\r
878ddf1f 1656\r
a29c47e0 1657 ModuleIdentification moduleId = new ModuleIdentification(name, guid,\r
1658 version);\r
878ddf1f 1659\r
a29c47e0 1660 moduleId.setModuleType(moduleType);\r
1661\r
1662 return moduleId;\r
1663 }\r
878ddf1f 1664\r
a29c47e0 1665 /**\r
1666 * Retrieve Extern Specification\r
ff225cbb 1667 *\r
a29c47e0 1668 * @param\r
ff225cbb 1669 *\r
a29c47e0 1670 * @return String[] If have specification element in the <extern> String[0]\r
1671 * If no specification element in the <extern>\r
ff225cbb 1672 *\r
a29c47e0 1673 */\r
1674\r
83fba802 1675 public String[] getExternSpecificaiton() {\r
a29c47e0 1676 String[] xPath = new String[] { "/Specification" };\r
1677\r
1678 Object[] queryResult = get("Externs", xPath);\r
878ddf1f 1679 if (queryResult == null) {\r
a29c47e0 1680 return new String[0];\r
878ddf1f 1681 }\r
1682\r
a29c47e0 1683 String[] specificationList = new String[queryResult.length];\r
1684 for (int i = 0; i < queryResult.length; i++) {\r
136adffc 1685 specificationList[i] = ((Sentence)queryResult[i])\r
1686 .getStringValue();\r
878ddf1f 1687 }\r
a29c47e0 1688 return specificationList;\r
1689 }\r
878ddf1f 1690\r
a29c47e0 1691 /**\r
1692 * Retreive MsaFile which in SPD\r
ff225cbb 1693 *\r
a29c47e0 1694 * @param\r
1695 * @return String[][3] The string sequence is ModuleName, ModuleGuid,\r
1696 * ModuleVersion, MsaFile String[0][] If no msafile in SPD\r
1697 */\r
83fba802 1698 public String[] getSpdMsaFile() {\r
a29c47e0 1699 String[] xPath = new String[] { "/MsaFiles" };\r
1700\r
1701 Object[] returns = get("PackageSurfaceArea", xPath);\r
1702 if (returns == null) {\r
1703 return new String[0];\r
1704 }\r
1705\r
1706 List<String> filenameList = ((MsaFilesDocument.MsaFiles) returns[0])\r
1707 .getFilenameList();\r
1708 return filenameList.toArray(new String[filenameList.size()]);\r
878ddf1f 1709 }\r
a29c47e0 1710\r
878ddf1f 1711 /**\r
a29c47e0 1712 * Reteive\r
1713 */\r
83fba802 1714 public Map<String, String[]> getSpdLibraryClasses() {\r
a29c47e0 1715 String[] xPath = new String[] { "/LibraryClassDeclarations/LibraryClass" };\r
878ddf1f 1716\r
a29c47e0 1717 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1718\r
a29c47e0 1719 //\r
1720 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.\r
1721 //\r
1722 Map<String, String[]> libClassHeaderMap = new HashMap<String, String[]>();\r
878ddf1f 1723\r
a29c47e0 1724 if (returns == null) {\r
1725 return libClassHeaderMap;\r
878ddf1f 1726 }\r
1727\r
a29c47e0 1728 for (int i = 0; i < returns.length; i++) {\r
1729 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass library = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass) returns[i];\r
1730 libClassHeaderMap.put(library.getName(), new String[] { library\r
1731 .getIncludeHeader() });\r
1732 }\r
1733 return libClassHeaderMap;\r
1734 }\r
878ddf1f 1735\r
a29c47e0 1736 /**\r
1737 * Reteive\r
1738 */\r
83fba802 1739 public Map<String, String> getSpdPackageHeaderFiles() {\r
a29c47e0 1740 String[] xPath = new String[] { "/PackageHeaders/IncludePkgHeader" };\r
878ddf1f 1741\r
a29c47e0 1742 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1743\r
a29c47e0 1744 //\r
1745 // Create Map, Key - ModuleType, String - PackageInclude Header file.\r
1746 //\r
1747 Map<String, String> packageIncludeMap = new HashMap<String, String>();\r
1748\r
1749 if (returns == null) {\r
1750 return packageIncludeMap;\r
878ddf1f 1751 }\r
7d6ef0a9 1752\r
a29c47e0 1753 for (int i = 0; i < returns.length; i++) {\r
1754 PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i];\r
1755 packageIncludeMap.put(includeHeader.getModuleType().toString(),\r
1756 includeHeader.getStringValue());\r
1757 }\r
1758 return packageIncludeMap;\r
1759 }\r
878ddf1f 1760\r
83fba802 1761 public PackageIdentification getSpdHeader() {\r
a29c47e0 1762 String[] xPath = new String[] { "/SpdHeader" };\r
1763\r
1764 Object[] returns = get("PackageSurfaceArea", xPath);\r
1765\r
1766 if (returns == null || returns.length == 0) {\r
1767 return null;\r
878ddf1f 1768 }\r
1769\r
a29c47e0 1770 SpdHeaderDocument.SpdHeader header = (SpdHeaderDocument.SpdHeader) returns[0];\r
1771\r
1772 String name = header.getPackageName();\r
1773\r
1774 String guid = header.getGuidValue();\r
1775\r
1776 String version = header.getVersion();\r
1777\r
1778 return new PackageIdentification(name, guid, version);\r
878ddf1f 1779 }\r
a29c47e0 1780\r
878ddf1f 1781 /**\r
a29c47e0 1782 * Reteive\r
1783 */\r
83fba802 1784 public Map<String, String[]> getSpdGuid() {\r
a29c47e0 1785 String[] xPath = new String[] { "/GuidDeclarations/Entry" };\r
878ddf1f 1786\r
a29c47e0 1787 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1788\r
a29c47e0 1789 //\r
1790 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.\r
1791 //\r
1792 Map<String, String[]> guidDeclMap = new HashMap<String, String[]>();\r
1793 if (returns == null) {\r
1794 return guidDeclMap;\r
878ddf1f 1795 }\r
1796\r
a29c47e0 1797 for (int i = 0; i < returns.length; i++) {\r
1798 GuidDeclarationsDocument.GuidDeclarations.Entry entry = (GuidDeclarationsDocument.GuidDeclarations.Entry) returns[i];\r
1799 String[] guidPair = new String[2];\r
1800 guidPair[0] = entry.getCName();\r
1801 guidPair[1] = entry.getGuidValue();\r
53b86193 1802 guidDeclMap.put(entry.getCName(), guidPair);\r
136adffc 1803 EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());\r
1804 EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[0]);\r
1805 EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[1]);\r
a29c47e0 1806 }\r
1807 return guidDeclMap;\r
878ddf1f 1808 }\r
a29c47e0 1809\r
878ddf1f 1810 /**\r
a29c47e0 1811 * Reteive\r
1812 */\r
83fba802 1813 public Map<String, String[]> getSpdProtocol() {\r
a29c47e0 1814 String[] xPath = new String[] { "/ProtocolDeclarations/Entry" };\r
878ddf1f 1815\r
a29c47e0 1816 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1817\r
a29c47e0 1818 //\r
1819 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.\r
1820 //\r
1821 Map<String, String[]> protoclMap = new HashMap<String, String[]>();\r
878ddf1f 1822\r
a29c47e0 1823 if (returns == null) {\r
1824 return protoclMap;\r
878ddf1f 1825 }\r
1826\r
a29c47e0 1827 for (int i = 0; i < returns.length; i++) {\r
1828 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry entry = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) returns[i];\r
1829 String[] protocolPair = new String[2];\r
878ddf1f 1830\r
a29c47e0 1831 protocolPair[0] = entry.getCName();\r
1832 protocolPair[1] = entry.getGuidValue();\r
53b86193 1833 protoclMap.put(entry.getCName(), protocolPair);\r
136adffc 1834 EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());\r
1835 EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[0]);\r
1836 EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[1]);\r
a29c47e0 1837 }\r
1838 return protoclMap;\r
1839 }\r
878ddf1f 1840\r
a29c47e0 1841 /**\r
1842 * getSpdPpi() Retrieve the SPD PPI Entry\r
ff225cbb 1843 *\r
a29c47e0 1844 * @param\r
1845 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI\r
1846 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI\r
1847 * entry in SPD.\r
1848 */\r
83fba802 1849 public Map<String, String[]> getSpdPpi() {\r
a29c47e0 1850 String[] xPath = new String[] { "/PpiDeclarations/Entry" };\r
1851\r
1852 Object[] returns = get("PackageSurfaceArea", xPath);\r
1853\r
1854 //\r
1855 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.\r
1856 //\r
1857 Map<String, String[]> ppiMap = new HashMap<String, String[]>();\r
878ddf1f 1858\r
a29c47e0 1859 if (returns == null) {\r
1860 return ppiMap;\r
878ddf1f 1861 }\r
1862\r
a29c47e0 1863 for (int i = 0; i < returns.length; i++) {\r
1864 PpiDeclarationsDocument.PpiDeclarations.Entry entry = (PpiDeclarationsDocument.PpiDeclarations.Entry) returns[i];\r
1865 String[] ppiPair = new String[2];\r
1866 ppiPair[0] = entry.getCName();\r
1867 ppiPair[1] = entry.getGuidValue();\r
53b86193 1868 ppiMap.put(entry.getCName(), ppiPair);\r
878ddf1f 1869 }\r
a29c47e0 1870 return ppiMap;\r
878ddf1f 1871 }\r
a29c47e0 1872\r
a29c47e0 1873 /**\r
1874 * Retrieve module Guid string\r
ff225cbb 1875 *\r
a29c47e0 1876 * @returns GUILD string if elements are found at the known xpath\r
1877 * @returns null if nothing is there\r
1878 */\r
83fba802 1879 public String getModuleGuid() {\r
a29c47e0 1880 String[] xPath = new String[] { "" };\r
1881\r
1882 Object[] returns = get("MsaHeader", xPath);\r
1883 if (returns != null && returns.length > 0) {\r
1884 String guid = ((MsaHeaderDocument.MsaHeader) returns[0])\r
1885 .getGuidValue();\r
1886 return guid;\r
ad82307c 1887 }\r
a29c47e0 1888\r
1889 return null;\r
1890 }\r
1891\r
1892 //\r
1893 // For new Pcd\r
1894 //\r
83fba802 1895 public ModuleSADocument.ModuleSA[] getFpdModuleSAs() {\r
a29c47e0 1896 String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r
1897 Object[] result = get("PlatformSurfaceArea", xPath);\r
1898 if (result != null) {\r
1899 return (ModuleSADocument.ModuleSA[]) result;\r
1900 }\r
1901 return new ModuleSADocument.ModuleSA[0];\r
1902\r
878ddf1f 1903 }\r
136adffc 1904 /**\r
1905 Get name array of PCD in a module. In one module, token space\r
1906 is same, and token name should not be conflicted.\r
ff225cbb 1907\r
136adffc 1908 @return String[]\r
7d6ef0a9 1909 **/\r
83fba802 1910 public String[] getModulePcdEntryNameArray() {\r
7d6ef0a9 1911 PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null;\r
1912 String[] results;\r
1913 int index;\r
1914 String[] xPath = new String[] {"/PcdEntry"};\r
1915 Object[] returns = get ("PcdCoded", xPath);\r
1916\r
1917 if (returns == null) {\r
1918 return new String[0];\r
1919 }\r
1920\r
1921 pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns;\r
1922 results = new String[pcdEntries.length];\r
1923\r
1924 for (index = 0; index < pcdEntries.length; index ++) {\r
1925 results[index] = pcdEntries[index].getCName();\r
1926 }\r
1927 return results;\r
1928 }\r
1929\r
1930 /**\r
1931 Search in a List for a given string\r
1932\r
1933 @return boolean\r
1934 **/\r
83fba802 1935 public boolean contains(List list, String str) {\r
42b78757 1936 if (list == null || list.size()== 0) {\r
1937 return true;\r
1938 }\r
7d6ef0a9 1939 Iterator it = list.iterator();\r
1940 while (it.hasNext()) {\r
1941 String s = (String)it.next();\r
1942 if (s.equalsIgnoreCase(str)) {\r
1943 return true;\r
1944 }\r
1945 }\r
1946\r
1947 return false;\r
1948 }\r
73b4e31a 1949\r
83fba802 1950 public boolean isHaveTianoR8FlashMap(){\r
73b4e31a 1951 String[] xPath = new String[] {"/"};\r
1952 Object[] returns = get ("Externs", xPath);\r
1953\r
1954 if (returns == null) {\r
1955 return false;\r
1956 }\r
1957\r
1958 ExternsDocument.Externs ext = (ExternsDocument.Externs)returns[0];\r
ff225cbb 1959\r
73b4e31a 1960 if (ext.getTianoR8FlashMapH()){\r
1961 return true;\r
1962 }else {\r
1963 return false;\r
1964 }\r
1965 }\r
878ddf1f 1966}\r