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