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