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