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