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