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