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