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