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