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