]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / global / SurfaceAreaQuery.java
CommitLineData
a13899c5 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.frameworkwizard.platform.ui.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.Set;\r
23import java.util.Stack;\r
24import java.util.regex.Matcher;\r
25import java.util.regex.Pattern;\r
26\r
27import org.apache.xmlbeans.XmlNormalizedString;\r
28import org.apache.xmlbeans.XmlObject;\r
29import org.apache.xmlbeans.XmlString;\r
30import org.tianocore.BuildOptionsDocument;\r
31import org.tianocore.BuildTargetList;\r
32import org.tianocore.DataIdDocument;\r
33import org.tianocore.ExternsDocument;\r
34import org.tianocore.FileNameConvention;\r
35import org.tianocore.FvAttributeDocument;\r
36//import org.tianocore.FvImageDocument;\r
37import org.tianocore.FvImagesDocument;\r
38import org.tianocore.FvOptionDocument;\r
39import org.tianocore.GuidDeclarationsDocument;\r
40import org.tianocore.GuidsDocument;\r
41import org.tianocore.LibrariesDocument;\r
42import org.tianocore.LibraryClassDeclarationsDocument;\r
43import org.tianocore.LibraryClassDocument;\r
44import org.tianocore.ModuleSADocument;\r
45import org.tianocore.ModuleTypeDef;\r
46import org.tianocore.MsaFilesDocument;\r
47import org.tianocore.MsaHeaderDocument;\r
48import org.tianocore.OptionDocument;\r
49import org.tianocore.PPIsDocument;\r
50import org.tianocore.PackageDependenciesDocument;\r
51import org.tianocore.PackageHeadersDocument;\r
52import org.tianocore.PlatformDefinitionsDocument;\r
53import org.tianocore.PpiDeclarationsDocument;\r
54import org.tianocore.ProtocolDeclarationsDocument;\r
55import org.tianocore.SpdHeaderDocument;\r
56import org.tianocore.FilenameDocument.Filename;\r
57import org.tianocore.MsaHeaderDocument.MsaHeader;\r
58import org.tianocore.ProtocolsDocument.Protocols.Protocol;\r
59import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
60import org.tianocore.PlatformHeaderDocument;\r
61import org.tianocore.frameworkwizard.platform.ui.id.FpdModuleIdentification;\r
62import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;\r
63import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;\r
64import org.tianocore.frameworkwizard.platform.ui.id.PlatformIdentification;\r
65\r
66/**\r
67 * SurfaceAreaQuery class is used to query Surface Area information from msa,\r
68 * mbd, spd and fpd files.\r
69 * \r
70 * This class should not instantiated. All the public interfaces is static.\r
71 * \r
72 * @since GenBuild 1.0\r
73 */\r
74public class SurfaceAreaQuery {\r
75\r
76 public static String prefix = "http://www.TianoCore.org/2006/Edk2.0";\r
77\r
78 // /\r
79 // / Contains name/value pairs of Surface Area document object. The name is\r
80 // / always the top level element name.\r
81 // /\r
82 private static Map<String, XmlObject> map = null;\r
83\r
84 // /\r
85 // / mapStack is used to do nested query\r
86 // /\r
87 private static Stack<Map<String, XmlObject>> mapStack = new Stack<Map<String, XmlObject>>();\r
88\r
89 // /\r
90 // / prefix of name space\r
91 // /\r
92 private static String nsPrefix = "sans";\r
93\r
94 // /\r
95 // / xmlbeans needs a name space for each Xpath element\r
96 // /\r
97 private static String ns = null;\r
98\r
99 // /\r
100 // / keep the namep declaration for xmlbeans Xpath query\r
101 // /\r
102 private static String queryDeclaration = null;\r
103\r
104 /**\r
105 * Set a Surface Area document for query later\r
106 * \r
107 * @param map\r
108 * A Surface Area document in TopLevelElementName/XmlObject\r
109 * format.\r
110 */\r
111 public static void setDoc(Map<String, XmlObject> map) {\r
112 ns = prefix;\r
113 queryDeclaration = "declare namespace " + nsPrefix + "='" + ns + "'; ";\r
114 SurfaceAreaQuery.map = map;\r
115 }\r
116\r
117 /**\r
118 * Push current used Surface Area document into query stack. The given new\r
119 * document will be used for any immediately followed getXXX() callings,\r
120 * untill pop() is called.\r
121 * \r
122 * @param newMap\r
123 * The TopLevelElementName/XmlObject format of a Surface Area\r
124 * document.\r
125 */\r
126 public static void push(Map<String, XmlObject> newMap) {\r
127 mapStack.push(SurfaceAreaQuery.map);\r
128 SurfaceAreaQuery.map = newMap;\r
129 }\r
130\r
131 /**\r
132 * Discard current used Surface Area document and use the top document in\r
133 * stack instead.\r
134 */\r
135 public static void pop() {\r
136 SurfaceAreaQuery.map = mapStack.pop();\r
137 }\r
138\r
139 // /\r
140 // / Convert xPath to be namespace qualified, which is necessary for\r
141 // XmlBeans\r
142 // / selectPath(). For example, converting /MsaHeader/ModuleType to\r
143 // / /ns:MsaHeader/ns:ModuleType\r
144 // /\r
145 private static String normalizeQueryString(String[] exp, String from) {\r
146 StringBuffer normQueryString = new StringBuffer(4096);\r
147\r
148 int i = 0;\r
149 while (i < exp.length) {\r
150 String newExp = from + exp[i];\r
151 Pattern pattern = Pattern.compile("([^/]*)(/|//)([^/]+)");\r
152 Matcher matcher = pattern.matcher(newExp);\r
153\r
154 while (matcher.find()) {\r
155 String starter = newExp.substring(matcher.start(1), matcher\r
156 .end(1));\r
157 String seperator = newExp.substring(matcher.start(2), matcher\r
158 .end(2));\r
159 String token = newExp.substring(matcher.start(3), matcher\r
160 .end(3));\r
161\r
162 normQueryString.append(starter);\r
163 normQueryString.append(seperator);\r
164 normQueryString.append(nsPrefix);\r
165 normQueryString.append(":");\r
166 normQueryString.append(token);\r
167 }\r
168\r
169 ++i;\r
170 if (i < exp.length) {\r
171 normQueryString.append(" | ");\r
172 }\r
173 }\r
174\r
175 return normQueryString.toString();\r
176 }\r
177\r
178 /**\r
179 * Search all XML documents stored in "map" for the specified xPath, using\r
180 * relative path (starting with '$this')\r
181 * \r
182 * @param xPath\r
183 * xpath query string array\r
184 * @returns An array of XmlObject if elements are found at the specified\r
185 * xpath\r
186 * @returns NULL if nothing is at the specified xpath\r
187 */\r
188 public static XmlObject[] get(String[] xPath) {\r
189 if (map == null) {\r
190 return null;\r
191 }\r
192\r
193 String[] keys = (String[]) map.keySet().toArray(new String[map.size()]);\r
194 List<XmlObject> result = new ArrayList<XmlObject>();\r
195 for (int i = 0; i < keys.length; ++i) {\r
196 XmlObject rootNode = (XmlObject) map.get(keys[i]);\r
197 if (rootNode == null) {\r
198 continue;\r
199 }\r
200\r
201 String query = queryDeclaration\r
202 + normalizeQueryString(xPath, "$this/" + keys[i]);\r
203 XmlObject[] tmp = rootNode.selectPath(query);\r
204 for (int j = 0; j < tmp.length; ++j) {\r
205 result.add(tmp[j]);\r
206 }\r
207 }\r
208\r
209 int size = result.size();\r
210 if (size <= 0) {\r
211 return null;\r
212 }\r
213\r
214 return (XmlObject[]) result.toArray(new XmlObject[size]);\r
215 }\r
216\r
217 /**\r
218 * Search XML documents named by "rootName" for the given xPath, using\r
219 * relative path (starting with '$this')\r
220 * \r
221 * @param rootName\r
222 * The top level element name\r
223 * @param xPath\r
224 * The xpath query string array\r
225 * @returns An array of XmlObject if elements are found at the given xpath\r
226 * @returns NULL if nothing is found at the given xpath\r
227 */\r
228 public static XmlObject[] get(String rootName, String[] xPath) {\r
229 if (map == null) {\r
230 return null;\r
231 }\r
232\r
233 XmlObject root = (XmlObject) map.get(rootName);\r
234 if (root == null) {\r
235 return null;\r
236 }\r
237\r
238 String query = queryDeclaration\r
239 + normalizeQueryString(xPath, "$this/" + rootName);\r
240 XmlObject[] result = root.selectPath(query);\r
241 if (result.length > 0) {\r
242 return result;\r
243 }\r
244\r
245 query = queryDeclaration + normalizeQueryString(xPath, "/" + rootName);\r
246 result = root.selectPath(query);\r
247 if (result.length > 0) {\r
248 return result;\r
249 }\r
250\r
251 return null;\r
252 }\r
253\r
254 /**\r
255 * Retrieve SourceFiles/Filename for specified ARCH type\r
256 * \r
257 * @param arch\r
258 * architecture name\r
259 * @returns An 2 dimension string array if elements are found at the known\r
260 * xpath\r
261 * @returns NULL if nothing is found at the known xpath\r
262 */\r
263 public static String[][] getSourceFiles(String arch) {\r
264 String[] xPath;\r
265 XmlObject[] returns;\r
266\r
267 if (arch == null || arch.equals("")) {\r
268 xPath = new String[] { "/Filename" };\r
269 } else {\r
270 xPath = new String[] { "/Filename[not(@SupArchList) or @SupArchList='"\r
271 + arch + "']" };\r
272 }\r
273\r
274 returns = get("SourceFiles", xPath);\r
275\r
276 if (returns == null || returns.length == 0) {\r
277 return null;\r
278 }\r
279\r
280 Filename[] sourceFileNames = (Filename[]) returns;\r
281 String[][] outputString = new String[sourceFileNames.length][2];\r
282 for (int i = 0; i < sourceFileNames.length; i++) {\r
283 outputString[i][0] = sourceFileNames[i].getToolCode();\r
284 outputString[i][1] = sourceFileNames[i].getStringValue();\r
285 }\r
286 return outputString;\r
287 }\r
288\r
289 /**\r
290 * Retrieve /PlatformDefinitions/OutputDirectory from FPD\r
291 * \r
292 * @returns Directory names array if elements are found at the known xpath\r
293 * @returns Empty if nothing is found at the known xpath\r
294 */\r
295 public static String getFpdOutputDirectory() {\r
296 String[] xPath = new String[] { "/PlatformDefinitions/OutputDirectory" };\r
297\r
298 XmlObject[] returns = get("FrameworkPlatformDescription", xPath);\r
299 if (returns != null && returns.length > 0) {\r
300 // String TBD\r
301 }\r
302\r
303 return null;\r
304 }\r
305\r
306 public static String getFpdIntermediateDirectories() {\r
307 String[] xPath = new String[] { "/PlatformDefinitions/IntermediateDirectories" };\r
308\r
309 XmlObject[] returns = get("FrameworkPlatformDescription", xPath);\r
310 if (returns != null && returns.length > 0) {\r
311 // TBD\r
312 }\r
313 return "UNIFIED";\r
314 }\r
315\r
316 /**\r
317 * Retrieve BuildOptions/Option or Arch/Option\r
318 * \r
319 * @param toolChainFamilyFlag\r
320 * if true, retrieve options for toolchain family; otherwise for\r
321 * toolchain\r
322 * \r
323 * @returns String[][5] name, target, toolchain, arch, coommand of options\r
324 * if elements are found at the known xpath. String[0][] if dont\r
325 * find element.\r
326 * \r
327 * @returns Empty array if nothing is there\r
328 */\r
329 public static String[][] getOptions(boolean toolChainFamilyFlag) {\r
330 String[] xPath;\r
331 String target = null;\r
332 String toolchain = null;\r
333 String toolchainFamily = null;\r
334 List<String> archList = null;\r
335 String cmd = null;\r
336 String targetName = null;\r
337 String optionName = null;\r
338\r
339 if (toolChainFamilyFlag == true) {\r
340 xPath = new String[] {\r
341 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@ToolChainTag)]",\r
342 "/BuildOptions/Options/Option[@ToolChainFamily]", };\r
343 } else {\r
344 xPath = new String[] {\r
345 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@ToolChainTag)]",\r
346 "/BuildOptions/Options/Option[@TagName]", };\r
347 }\r
348\r
349 XmlObject[] returns = get("FrameworkPlatformDescription", xPath);\r
350 if (returns == null) {\r
351 return new String[0][5];\r
352 }\r
353\r
354 List<String[]> optionList = new ArrayList<String[]>();\r
355 OptionDocument.Option option;\r
356\r
357 for (int i = 0; i < returns.length; i++) {\r
358 option = (OptionDocument.Option) returns[i];\r
359\r
360 //\r
361 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,\r
362 // then\r
363 // put to result[][5] array in above order.\r
364 //\r
365 String[] targetList;\r
366 target = null;//Auber option.getBuildTargets();\r
367 if (target != null) {\r
368 targetList = target.split(" ");\r
369 } else {\r
370 targetList = new String[1];\r
371 targetList[0] = null;\r
372 }\r
373\r
374 if (toolChainFamilyFlag) {\r
375 toolchainFamily = option.getToolChainFamily();\r
376 if (toolchainFamily != null) {\r
377 toolchain = toolchainFamily.toString();\r
378 } else {\r
379 toolchain = null;\r
380 }\r
381 } else {\r
382 toolchain = option.getTagName();\r
383 }\r
384\r
385 archList = option.getSupArchList();\r
386 if (archList == null) {\r
387 archList.add(null);\r
388 }\r
389\r
390 cmd = option.getToolCode();\r
391\r
392 optionName = option.getStringValue();\r
393 for (int t = 0; t < targetList.length; t++) {\r
394 for (int j = 0; j < archList.size(); j++) {\r
395 optionList.add(new String[] { optionName, targetList[i],\r
396 toolchain, archList.get(j), cmd });\r
397 }\r
398 }\r
399 }\r
400\r
401 String[][] result = new String[optionList.size()][5];\r
402 for (int i = 0; i < optionList.size(); i++) {\r
403 result[i][0] = optionList.get(i)[0];\r
404 result[i][1] = optionList.get(i)[1];\r
405 result[i][2] = optionList.get(i)[2];\r
406 result[i][3] = optionList.get(i)[3];\r
407 result[i][4] = optionList.get(i)[4];\r
408 }\r
409 return result;\r
410 }\r
411\r
412 public static String getBuildTarget() {\r
413 String[] xPath = new String[] { "/PlatformDefinitions/BuildTargets" };\r
414\r
415 XmlObject[] returns = get("FrameworkPlatformDescription", xPath);\r
416 if (returns != null && returns.length > 0) {\r
417 return ((BuildTargetList) returns[0]).getStringValue();\r
418 }\r
419\r
420 return null;\r
421 }\r
422\r
423 /**\r
424 * Retrieve <xxxHeader>/ModuleType\r
425 * \r
426 * @returns The module type name if elements are found at the known xpath\r
427 * @returns null if nothing is there\r
428 */\r
429 public static String getModuleType() {\r
430 String[] xPath = new String[] { "/ModuleType" };\r
431\r
432 XmlObject[] returns = get(xPath);\r
433 if (returns != null && returns.length > 0) {\r
434 ModuleTypeDef type = (ModuleTypeDef) returns[0];\r
435 return type.enumValue().toString();\r
436 }\r
437\r
438 return null;\r
439 }\r
440\r
441 /**\r
442 * Retrieve PackageDependencies/Package\r
443 * \r
444 * @param arch\r
445 * Architecture name\r
446 * \r
447 * @returns package name list if elements are found at the known xpath\r
448 * @returns null if nothing is there\r
449 */\r
450 public static PackageIdentification[] getDependencePkg(String arch) {\r
451 String[] xPath;\r
452 String packageGuid = null;\r
453 String packageVersion = null;\r
454\r
455 if (arch == null || arch.equals("")) {\r
456 xPath = new String[] { "/PackageDependencies/Package" };\r
457 } else {\r
458 xPath = new String[] { "/PackageDependencies/Package[not(@SupArchList) or @SupArchList='"\r
459 + arch + "']" };\r
460 }\r
461\r
462 XmlObject[] returns = get("ModuleSurfaceArea", xPath);\r
463 if (returns == null) {\r
464 return new PackageIdentification[0];\r
465 }\r
466 PackageIdentification[] packageIdList = new PackageIdentification[returns.length];\r
467 for (int i = 0; i < returns.length; i++) {\r
468 PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i];\r
469 packageGuid = item.getPackageGuid();\r
470 packageVersion = item.getPackageVersion();\r
471\r
472 Set<PackageIdentification> spi = GlobalData.getPackageList();\r
473 Iterator<PackageIdentification> ispi = spi.iterator();\r
474 String ver = "";\r
475 while(ispi.hasNext()) {\r
476 PackageIdentification pi = ispi.next();\r
477 if (packageVersion != null) {\r
478 if (pi.getGuid().equals(packageGuid) && pi.getVersion().equals(packageVersion)) {\r
479 packageIdList[i] = pi;\r
480 break;\r
481 } \r
482 }\r
483 else {\r
484 if (pi.getGuid().equals(packageGuid)) {\r
485 if (pi.getVersion() != null && pi.getVersion().compareTo(ver) > 0){\r
486 ver = pi.getVersion();\r
487 packageIdList[i] = pi;\r
488 }\r
489 else if (packageIdList[i] == null){\r
490 packageIdList[i] = pi;\r
491 }\r
492 }\r
493 }\r
494 \r
495 }\r
496 }\r
497 return packageIdList;\r
498 }\r
499\r
500 /**\r
501 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage\r
502 * \r
503 * @param usage\r
504 * Library class usage\r
505 * \r
506 * @returns LibraryClass objects list if elements are found at the known\r
507 * xpath\r
508 * @returns null if nothing is there\r
509 */\r
510 public static String[] getLibraryClasses(String usage) {\r
511 String[] xPath;\r
512\r
513 if (usage == null || usage.equals("")) {\r
514 xPath = new String[] { "/LibraryClass" };\r
515 } else {\r
516 xPath = new String[] { "/LibraryClass[@Usage='" + usage + "']" };\r
517 }\r
518\r
519 XmlObject[] returns = get("LibraryClassDefinitions", xPath);\r
520 if (returns == null || returns.length == 0) {\r
521 return new String[0];\r
522 }\r
523\r
524 LibraryClassDocument.LibraryClass[] libraryClassList = (LibraryClassDocument.LibraryClass[]) returns;\r
525 String[] libraryClassName = new String[libraryClassList.length];\r
526 for (int i = 0; i < libraryClassList.length; i++) {\r
527 libraryClassName[i] = libraryClassList[i].getKeyword();\r
528 }\r
529 return libraryClassName;\r
530 }\r
531\r
532 /**\r
533 * Retrieve ModuleEntryPoint names\r
534 * \r
535 * @returns ModuleEntryPoint name list if elements are found at the known\r
536 * xpath\r
537 * @returns null if nothing is there\r
538 */\r
539 public static String[] getModuleEntryPointArray() {\r
540 String[] xPath = new String[] { "/Extern/ModuleEntryPoint" };\r
541\r
542 XmlObject[] returns = get("Externs", xPath);\r
543\r
544 if (returns != null && returns.length > 0) {\r
545 String[] entryPoints = new String[returns.length];\r
546\r
547 for (int i = 0; i < returns.length; ++i) {\r
548 entryPoints[i] = ((XmlNormalizedString) returns[i])\r
549 .getStringValue();\r
550 }\r
551\r
552 return entryPoints;\r
553 }\r
554\r
555 return null;\r
556 }\r
557\r
558 \r
559 \r
560\r
561 /**\r
562 * Retrieve ModuleUnloadImage names\r
563 * \r
564 * @returns ModuleUnloadImage name list if elements are found at the known\r
565 * xpath\r
566 * @returns null if nothing is there\r
567 */\r
568 public static String[] getModuleUnloadImageArray() {\r
569 String[] xPath = new String[] { "/Extern/ModuleUnloadImage" };\r
570\r
571 XmlObject[] returns = get("Externs", xPath);\r
572 if (returns != null && returns.length > 0) {\r
573 String[] stringArray = new String[returns.length];\r
574 XmlNormalizedString[] doc = (XmlNormalizedString[]) returns;\r
575\r
576 for (int i = 0; i < returns.length; ++i) {\r
577 stringArray[i] = doc[i].getStringValue();\r
578 }\r
579\r
580 return stringArray;\r
581 }\r
582\r
583 return null;\r
584 }\r
585\r
586 /**\r
587 * Retrieve Extern\r
588 * \r
589 * @returns Extern objects list if elements are found at the known xpath\r
590 * @returns null if nothing is there\r
591 */\r
592 public static ExternsDocument.Externs.Extern[] getExternArray() {\r
593 String[] xPath = new String[] { "/Extern" };\r
594\r
595 XmlObject[] returns = get("Externs", xPath);\r
596 if (returns != null && returns.length > 0) {\r
597 return (ExternsDocument.Externs.Extern[]) returns;\r
598 }\r
599\r
600 return null;\r
601 }\r
602 \r
603 /**\r
604 * Retrieve Library instance information\r
605 * \r
606 * @param arch\r
607 * Architecture name\r
608 * @param usage\r
609 * Library instance usage\r
610 * \r
611 * @returns library instance name list if elements are found at the known\r
612 * xpath\r
613 * @returns null if nothing is there\r
614 */\r
615 public static ModuleIdentification[] getLibraryInstance(String arch) {\r
616 String[] xPath;\r
617 String saGuid = null;\r
618 String saVersion = null;\r
619 String pkgGuid = null;\r
620 String pkgVersion = null;\r
621\r
622 if (arch == null || arch.equalsIgnoreCase("")) {\r
623 xPath = new String[] { "/Instance" };\r
624 } else {\r
625 xPath = new String[] { "/Instance[not(@SupArchList) or @SupArchList='"\r
626 + arch + "']" };\r
627 }\r
628\r
629 XmlObject[] returns = get("Libraries", xPath);\r
630 if (returns == null || returns.length == 0) {\r
631 return new ModuleIdentification[0];\r
632 }\r
633\r
634 ModuleIdentification[] saIdList = new ModuleIdentification[returns.length];\r
635 for (int i = 0; i < returns.length; i++) {\r
636 LibrariesDocument.Libraries.Instance library = (LibrariesDocument.Libraries.Instance) returns[i];\r
637 saGuid = library.getModuleGuid();\r
638 saVersion = library.getModuleVersion();\r
639\r
640 pkgGuid = library.getPackageGuid();\r
641 pkgVersion = library.getPackageVersion();\r
642\r
643 ModuleIdentification saId = new ModuleIdentification(null, saGuid,\r
644 saVersion);\r
645 PackageIdentification pkgId = new PackageIdentification(null,\r
646 pkgGuid, pkgVersion);\r
647 saId.setPackage(pkgId);\r
648\r
649 saIdList[i] = saId;\r
650\r
651 }\r
652 return saIdList;\r
653 }\r
654\r
655 // /\r
656 // / This method is used for retrieving the elements information which has\r
657 // / CName sub-element\r
658 // /\r
659 private static String[] getCNames(String from, String xPath[]) {\r
660 XmlObject[] returns = get(from, xPath);\r
661 if (returns == null || returns.length == 0) {\r
662 return null;\r
663 }\r
664\r
665 String[] strings = new String[returns.length];\r
666 for (int i = 0; i < returns.length; ++i) {\r
667 // TBD\r
668 // strings[i] = ((CName) returns[i]).getStringValue();\r
669 }\r
670\r
671 return strings;\r
672 }\r
673\r
674 /**\r
675 * Retrive library's constructor name\r
676 * \r
677 * @returns constructor name list if elements are found at the known xpath\r
678 * @returns null if nothing is there\r
679 */\r
680 public static String getLibConstructorName() {\r
681 String[] xPath = new String[] { "/Extern/Constructor" };\r
682\r
683 XmlObject[] returns = get("Externs", xPath);\r
684 if (returns != null && returns.length > 0) {\r
685 // CName constructor = (CName) returns[0];\r
686 // return constructor.getStringValue();\r
687 }\r
688\r
689 return null;\r
690 }\r
691\r
692 /**\r
693 * Retrive library's destructor name\r
694 * \r
695 * @returns destructor name list if elements are found at the known xpath\r
696 * @returns null if nothing is there\r
697 */\r
698 public static String getLibDestructorName() {\r
699 String[] xPath = new String[] { "/Extern/Destructor" };\r
700\r
701 XmlObject[] returns = get("Externs", xPath);\r
702 if (returns != null && returns.length > 0) {\r
703 // CName destructor = (CName) returns[0];\r
704 // return destructor.getStringValue();\r
705 }\r
706\r
707 return null;\r
708 }\r
709\r
710 /**\r
711 * Retrive DriverBinding names\r
712 * \r
713 * @returns DriverBinding name list if elements are found at the known xpath\r
714 * @returns null if nothing is there\r
715 */\r
716 public static String[] getDriverBindingArray() {\r
717 String[] xPath = new String[] { "/Extern/DriverBinding" };\r
718 return getCNames("Externs", xPath);\r
719 }\r
720\r
721 /**\r
722 * Retrive ComponentName names\r
723 * \r
724 * @returns ComponentName name list if elements are found at the known xpath\r
725 * @returns null if nothing is there\r
726 */\r
727 public static String[] getComponentNameArray() {\r
728 String[] xPath = new String[] { "/Extern/ComponentName" };\r
729 return getCNames("Externs", xPath);\r
730 }\r
731\r
732 /**\r
733 * Retrive DriverConfig names\r
734 * \r
735 * @returns DriverConfig name list if elements are found at the known xpath\r
736 * @returns null if nothing is there\r
737 */\r
738 public static String[] getDriverConfigArray() {\r
739 String[] xPath = new String[] { "/Extern/DriverConfig" };\r
740 return getCNames("Externs", xPath);\r
741 }\r
742\r
743 /**\r
744 * Retrive DriverDiag names\r
745 * \r
746 * @returns DriverDiag name list if elements are found at the known xpath\r
747 * @returns null if nothing is there\r
748 */\r
749 public static String[] getDriverDiagArray() {\r
750 String[] xPath = new String[] { "/Extern/DriverDiag" };\r
751 return getCNames("Externs", xPath);\r
752 }\r
753\r
754 /**\r
755 * Retrive SetVirtualAddressMapCallBack names\r
756 * \r
757 * @returns SetVirtualAddressMapCallBack name list if elements are found at\r
758 * the known xpath\r
759 * @returns null if nothing is there\r
760 */\r
761 public static String[] getSetVirtualAddressMapCallBackArray() {\r
762 String[] xPath = new String[] { "/Extern/SetVirtualAddressMapCallBack" };\r
763 return getCNames("Externs", xPath);\r
764 }\r
765\r
766 /**\r
767 * Retrive ExitBootServicesCallBack names\r
768 * \r
769 * @returns ExitBootServicesCallBack name list if elements are found at the\r
770 * known xpath\r
771 * @returns null if nothing is there\r
772 */\r
773 public static String[] getExitBootServicesCallBackArray() {\r
774 String[] xPath = new String[] { "/Extern/ExitBootServicesCallBack" };\r
775 return getCNames("Externs", xPath);\r
776 }\r
777\r
778 /**\r
779 * Retrieve module surface area file information\r
780 * \r
781 * @returns ModuleSA objects list if elements are found at the known xpath\r
782 * @returns Empty ModuleSA list if nothing is there\r
783 */\r
784 public static Map<FpdModuleIdentification, Map<String, XmlObject>> getFpdModules() {\r
785 String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r
786 XmlObject[] result = get("FrameworkPlatformDescription", xPath);\r
787 String arch = null;\r
788 String fvBinding = null;\r
789 String saGuid = null;\r
790 String saVersion = null;\r
791 String pkgGuid = null;\r
792 String pkgVersion = null;\r
793\r
794 Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleMap = new LinkedHashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r
795\r
796 if (result == null) {\r
797 return fpdModuleMap;\r
798 }\r
799\r
800 for (int i = 0; i < result.length; i++) {\r
801 //\r
802 // Get Fpd SA Module element node and add to xmlObjectMap.\r
803 //\r
804 Map<String, XmlObject> xmlObjectMap = new HashMap<String, XmlObject>();\r
805 ModuleSADocument.ModuleSA moduleSA = (ModuleSADocument.ModuleSA) result[i];\r
806 if (((ModuleSADocument.ModuleSA) result[i]).getLibraries() != null) {\r
807 xmlObjectMap.put("Libraries", moduleSA.getLibraries());\r
808 }\r
809 if (((ModuleSADocument.ModuleSA) result[i]).getPcdBuildDefinition() != null) {\r
810 xmlObjectMap.put("PcdBuildDefinition", moduleSA\r
811 .getPcdBuildDefinition());\r
812 }\r
813 if (((ModuleSADocument.ModuleSA) result[i])\r
814 .getModuleSaBuildOptions() != null) {\r
815 xmlObjectMap.put("ModuleSaBuildOptions", moduleSA\r
816 .getModuleSaBuildOptions());\r
817 }\r
818\r
819 //\r
820 // Get Fpd SA Module attribute and create FpdMoudleIdentification.\r
821 //\r
822 arch = moduleSA.getSupArchList().toString();\r
823\r
824 // TBD\r
825 fvBinding = null;\r
826 saVersion = ((ModuleSADocument.ModuleSA) result[i])\r
827 .getModuleVersion();\r
828\r
829 saGuid = moduleSA.getModuleGuid();\r
830 pkgGuid = moduleSA.getPackageGuid();\r
831 pkgVersion = moduleSA.getPackageVersion();\r
832\r
833 //\r
834 // Create Module Identification which have class member of package\r
835 // identification.\r
836 //\r
837 PackageIdentification pkgId = new PackageIdentification(null,\r
838 pkgGuid, pkgVersion);\r
839 ModuleIdentification saId = new ModuleIdentification(null, saGuid,\r
840 saVersion);\r
841\r
842 saId.setPackage(pkgId);\r
843\r
844 //\r
845 // Create FpdModule Identification which have class member of module\r
846 // identification\r
847 //\r
848 FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId,\r
849 arch);\r
850 if (arch != null) {\r
851 fpdSaId.setArch(arch);\r
852 }\r
853 if (fvBinding != null) {\r
854 fpdSaId.setFvBinding(fvBinding);\r
855 }\r
856\r
857 //\r
858 // Put element to Map<FpdModuleIdentification, Map<String,\r
859 // XmlObject>>.\r
860 //\r
861 fpdModuleMap.put(fpdSaId, xmlObjectMap);\r
862 }\r
863 return fpdModuleMap;\r
864 }\r
865\r
866 /**\r
867 * Retrieve valid image names\r
868 * \r
869 * @returns valid iamges name list if elements are found at the known xpath\r
870 * @returns empty list if nothing is there\r
871 */\r
872 public static String[] getFpdValidImageNames() {\r
873 String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/FvImages/FvImage[@Type='ValidImageNames']/FvImageNames" };\r
874\r
875 XmlObject[] queryResult = get("FrameworkPlatformDescription", xPath);\r
876 if (queryResult == null) {\r
877 return new String[0];\r
878 }\r
879\r
880 String[] result = new String[queryResult.length];\r
881 for (int i = 0; i < queryResult.length; i++) {\r
882 result[i] = ((XmlString) queryResult[i]).getStringValue();\r
883 }\r
884\r
885 return result;\r
886 }\r
887\r
888\r
889\r
890 public static XmlObject getFpdBuildOptions() {\r
891 String[] xPath = new String[] { "/BuildOptions" };\r
892\r
893 XmlObject[] queryResult = get("FrameworkPlatformDescription", xPath);\r
894\r
895 if (queryResult == null || queryResult.length == 0) {\r
896 return null;\r
897 }\r
898 return queryResult[0];\r
899 }\r
900\r
901 public static PlatformIdentification getFpdHeader() {\r
902 String[] xPath = new String[] { "/PlatformHeader" };\r
903\r
904 XmlObject[] returns = get("FrameworkPlatformDescription", xPath);\r
905\r
906 if (returns == null || returns.length == 0) {\r
907 return null;\r
908 }\r
909 PlatformHeaderDocument.PlatformHeader header = (PlatformHeaderDocument.PlatformHeader) returns[0];\r
910\r
911 String name = header.getPlatformName();\r
912\r
913 String guid = header.getGuidValue();\r
914\r
915 String version = header.getVersion();\r
916\r
917 return new PlatformIdentification(name, guid, version);\r
918 }\r
919\r
920 /**\r
921 * Retrieve flash definition file name\r
922 * \r
923 * @returns file name if elements are found at the known xpath\r
924 * @returns null if nothing is there\r
925 */\r
926 public static String getFlashDefinitionFile() {\r
927 String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };\r
928\r
929 XmlObject[] queryResult = get("FrameworkPlatformDescription", xPath);\r
930 if (queryResult == null || queryResult.length == 0) {\r
931 return null;\r
932 }\r
933\r
934 FileNameConvention filename = (FileNameConvention) queryResult[queryResult.length - 1];\r
935 return filename.getStringValue();\r
936 }\r
937\r
938 /**\r
939 * Retrieve FV image component options\r
940 * \r
941 * @param fvName\r
942 * FV image name\r
943 * \r
944 * @returns name/value pairs list if elements are found at the known xpath\r
945 * @returns empty list if nothing is there\r
946 */\r
947 public static String[][] getFpdComponents(String fvName) {\r
948 String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/DataRegions/FvDataRegion[@Name='"\r
949 + fvName.toUpperCase() + "']/DataId" };\r
950\r
951 XmlObject[] queryResult = get("FrameworkPlatformDescription", xPath);\r
952 if (queryResult == null) {\r
953 return new String[0][];\r
954 }\r
955\r
956 ArrayList<String[]> list = new ArrayList<String[]>();\r
957 for (int i = 0; i < queryResult.length; i++) {\r
958 DataIdDocument.DataId item = (DataIdDocument.DataId) queryResult[i];\r
959 list\r
960 .add(new String[] { item.getStringValue(),\r
961 item.getDataSize() });\r
962 }\r
963\r
964 String[][] result = new String[list.size()][2];\r
965 for (int i = 0; i < list.size(); i++) {\r
966 result[i][0] = list.get(i)[0];\r
967 result[i][1] = list.get(i)[1];\r
968 }\r
969\r
970 return result;\r
971 }\r
972\r
973 /**\r
974 * Retrieve PCD tokens\r
975 * \r
976 * @returns CName/ItemType pairs list if elements are found at the known\r
977 * xpath\r
978 * @returns null if nothing is there\r
979 */\r
980 public static String[][] getPcdTokenArray() {\r
981 String[] xPath = new String[] { "/PcdData" };\r
982\r
983 XmlObject[] returns = get("PCDs", xPath);\r
984 if (returns == null || returns.length == 0) {\r
985 return null;\r
986 }\r
987\r
988 // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns;\r
989 // String[][] result = new String[pcds.length][2];\r
990 // for (int i = 0; i < returns.length; ++i) {\r
991 // if (pcds[i].getItemType() != null) {\r
992 // result[i][1] = pcds[i].getItemType().toString();\r
993 // } else {\r
994 // result[i][1] = null;\r
995 // }\r
996 // result[i][0] = pcds[i].getCName();\r
997 // }\r
998\r
999 return null;\r
1000 }\r
1001\r
1002 /**\r
1003 * Get the PcdToken array from module's surface area document. The array\r
1004 * should contains following data:\r
1005 * <p>\r
1006 * -------------------------------------------------------------------\r
1007 * </p>\r
1008 * <p>\r
1009 * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText\r
1010 * </p>\r
1011 * <p>\r
1012 * -------------------------------------------------------------------\r
1013 * </p>\r
1014 * <p>\r
1015 * Note: Until new schema applying, now we can only get CName, ItemType,\r
1016 * </p>\r
1017 * \r
1018 * @return 2-array table contains all information of PCD token retrieved\r
1019 * from MSA.\r
1020 */\r
1021 public static Object[][] etModulePCDTokenArray() {\r
1022 return null;\r
1023 // int index;\r
1024 // Object[][] result;\r
1025 // PCDs.PcdData[] pcds;\r
1026 // String[] xPath = new String[] { "/PcdData" };\r
1027 // XmlObject[] returns = get("PCDs", xPath);\r
1028 //\r
1029 // if ((returns == null) || (returns.length == 0)) {\r
1030 // return null;\r
1031 // }\r
1032 //\r
1033 // pcds = (PCDs.PcdData[]) returns;\r
1034 // result = new Object[pcds.length][6];\r
1035 // for (index = 0; index < pcds.length; index++) {\r
1036 // //\r
1037 // // Get CName\r
1038 // //\r
1039 // result[index][0] = pcds[index].getCName();\r
1040 // //\r
1041 // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE,\r
1042 // // DYNAMIC, DYNAMIC_EX\r
1043 // //\r
1044 // if (pcds[index].getItemType() != null) {\r
1045 // result[index][1] = pcds[index].getItemType().toString();\r
1046 // } else {\r
1047 // result[index][1] = null;\r
1048 // }\r
1049 //\r
1050 // //\r
1051 // // BUGBUG: following field can *not* be got from current MSA until\r
1052 // // schema changed.\r
1053 // //\r
1054 // // result [index][2] = pcds[index].getTokenSpaceName();\r
1055 // result[index][2] = null;\r
1056 // result[index][3] = pcds[index].getDefaultValue();\r
1057 // // result [index][4] = pcds[index].getUsage ();\r
1058 // result[index][4] = null;\r
1059 // // result [index][5] = pcds[index].getHelpText ();\r
1060 // result[index][5] = null;\r
1061 // }\r
1062 // return result;\r
1063 }\r
1064\r
1065 /**\r
1066 * Retrieve MAS header\r
1067 * \r
1068 * @return\r
1069 * @return\r
1070 */\r
1071 public static ModuleIdentification getMsaHeader() {\r
1072 String[] xPath = new String[] { "/" };\r
1073 XmlObject[] returns = get("MsaHeader", xPath);\r
1074\r
1075 if (returns == null || returns.length == 0) {\r
1076 return null;\r
1077 }\r
1078\r
1079 MsaHeader msaHeader = (MsaHeader) returns[0];\r
1080 //\r
1081 // Get BaseName, ModuleType, GuidValue, Version\r
1082 // which in MsaHeader.\r
1083 //\r
1084 String name = msaHeader.getModuleName();\r
1085 String moduleType = msaHeader.getModuleType().toString();\r
1086 String guid = msaHeader.getGuidValue();\r
1087 String version = msaHeader.getVersion();\r
1088\r
1089 ModuleIdentification moduleId = new ModuleIdentification(name, guid,\r
1090 version);\r
1091\r
1092 moduleId.setModuleType(moduleType);\r
1093\r
1094 return moduleId;\r
1095 }\r
1096\r
1097 /**\r
1098 * Retrieve Extern Specification\r
1099 * \r
1100 * @param\r
1101 * \r
1102 * @return String[] If have specification element in the <extern> String[0]\r
1103 * If no specification element in the <extern>\r
1104 * \r
1105 */\r
1106\r
1107 public static String[] getExternSpecificaiton() {\r
1108 String[] xPath = new String[] { "/Specification" };\r
1109\r
1110 XmlObject[] queryResult = get("Externs", xPath);\r
1111 if (queryResult == null) {\r
1112 return new String[0];\r
1113 }\r
1114\r
1115 String[] specificationList = new String[queryResult.length];\r
1116 for (int i = 0; i < queryResult.length; i++) {\r
1117 // specificationList[i] = ((SpecificationDocument.Specification)\r
1118 // queryResult[i])\r
1119 // .getStringValue();\r
1120 }\r
1121 return specificationList;\r
1122 }\r
1123\r
1124 /**\r
1125 * Retreive MsaFile which in SPD\r
1126 * \r
1127 * @param\r
1128 * @return String[][3] The string sequence is ModuleName, ModuleGuid,\r
1129 * ModuleVersion, MsaFile String[0][] If no msafile in SPD\r
1130 */\r
1131 public static String[] getSpdMsaFile() {\r
1132 String[] xPath = new String[] { "/MsaFiles" };\r
1133\r
1134 XmlObject[] returns = get("PackageSurfaceArea", xPath);\r
1135 if (returns == null) {\r
1136 return new String[0];\r
1137 }\r
1138\r
1139 List<String> filenameList = ((MsaFilesDocument.MsaFiles) returns[0])\r
1140 .getFilenameList();\r
1141 return filenameList.toArray(new String[filenameList.size()]);\r
1142 }\r
1143\r
1144 /**\r
1145 * Reteive\r
1146 */\r
1147 public static Map<String, String[]> getSpdLibraryClasses() {\r
1148 String[] xPath = new String[] { "/LibraryClassDeclarations/LibraryClass" };\r
1149\r
1150 XmlObject[] returns = get("PackageSurfaceArea", xPath);\r
1151\r
1152 //\r
1153 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.\r
1154 //\r
1155 Map<String, String[]> libClassHeaderMap = new HashMap<String, String[]>();\r
1156\r
1157 if (returns == null) {\r
1158 return libClassHeaderMap;\r
1159 }\r
1160\r
1161 for (int i = 0; i < returns.length; i++) {\r
1162 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass library = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass) returns[i];\r
1163 libClassHeaderMap.put(library.getName(), new String[] { library\r
1164 .getIncludeHeader() });\r
1165 }\r
1166 return libClassHeaderMap;\r
1167 }\r
1168\r
1169 /**\r
1170 * Reteive\r
1171 */\r
1172 public static Map<String, String> getSpdPackageHeaderFiles() {\r
1173 String[] xPath = new String[] { "/PackageHeaders/IncludePkgHeader" };\r
1174\r
1175 XmlObject[] returns = get("PackageSurfaceArea", xPath);\r
1176\r
1177 //\r
1178 // Create Map, Key - ModuleType, String - PackageInclude Header file.\r
1179 //\r
1180 Map<String, String> packageIncludeMap = new HashMap<String, String>();\r
1181\r
1182 if (returns == null) {\r
1183 return packageIncludeMap;\r
1184 }\r
1185 GlobalData.log.info("" + returns[0].getClass().getName());\r
1186 for (int i = 0; i < returns.length; i++) {\r
1187 PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i];\r
1188 packageIncludeMap.put(includeHeader.getModuleType().toString(),\r
1189 includeHeader.getStringValue());\r
1190 }\r
1191 return packageIncludeMap;\r
1192 }\r
1193\r
1194 public static PackageIdentification getSpdHeader() {\r
1195 String[] xPath = new String[] { "/SpdHeader" };\r
1196\r
1197 XmlObject[] returns = get("PackageSurfaceArea", xPath);\r
1198\r
1199 if (returns == null || returns.length == 0) {\r
1200 return null;\r
1201 }\r
1202\r
1203 SpdHeaderDocument.SpdHeader header = (SpdHeaderDocument.SpdHeader) returns[0];\r
1204\r
1205 String name = header.getPackageName();\r
1206\r
1207 String guid = header.getGuidValue();\r
1208\r
1209 String version = header.getVersion();\r
1210\r
1211 return new PackageIdentification(name, guid, version);\r
1212 }\r
1213\r
1214 /**\r
1215 * Reteive\r
1216 */\r
1217 public static Map<String, String[]> getSpdGuid() {\r
1218 String[] xPath = new String[] { "/GuidDeclarations/Entry" };\r
1219\r
1220 XmlObject[] returns = get("PackageSurfaceArea", xPath);\r
1221\r
1222 //\r
1223 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.\r
1224 //\r
1225 Map<String, String[]> guidDeclMap = new HashMap<String, String[]>();\r
1226 if (returns == null) {\r
1227 return guidDeclMap;\r
1228 }\r
1229\r
1230 for (int i = 0; i < returns.length; i++) {\r
1231 GuidDeclarationsDocument.GuidDeclarations.Entry entry = (GuidDeclarationsDocument.GuidDeclarations.Entry) returns[i];\r
1232 String[] guidPair = new String[2];\r
1233 guidPair[0] = entry.getCName();\r
1234 guidPair[1] = entry.getGuidValue();\r
1235 guidDeclMap.put(entry.getName(), guidPair);\r
1236 }\r
1237 return guidDeclMap;\r
1238 }\r
1239\r
1240 /**\r
1241 * Reteive\r
1242 */\r
1243 public static Map<String, String[]> getSpdProtocol() {\r
1244 String[] xPath = new String[] { "/ProtocolDeclarations/Entry" };\r
1245\r
1246 XmlObject[] returns = get("PackageSurfaceArea", xPath);\r
1247\r
1248 //\r
1249 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.\r
1250 //\r
1251 Map<String, String[]> protoclMap = new HashMap<String, String[]>();\r
1252\r
1253 if (returns == null) {\r
1254 return protoclMap;\r
1255 }\r
1256\r
1257 for (int i = 0; i < returns.length; i++) {\r
1258 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry entry = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) returns[i];\r
1259 String[] protocolPair = new String[2];\r
1260\r
1261 protocolPair[0] = entry.getCName();\r
1262 protocolPair[1] = entry.getGuidValue();\r
1263 protoclMap.put(entry.getName(), protocolPair);\r
1264 }\r
1265 return protoclMap;\r
1266 }\r
1267\r
1268 /**\r
1269 * getSpdPpi() Retrieve the SPD PPI Entry\r
1270 * \r
1271 * @param\r
1272 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI\r
1273 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI\r
1274 * entry in SPD.\r
1275 */\r
1276 public static Map<String, String[]> getSpdPpi() {\r
1277 String[] xPath = new String[] { "/PpiDeclarations/Entry" };\r
1278\r
1279 XmlObject[] returns = get("PackageSurfaceArea", xPath);\r
1280\r
1281 //\r
1282 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.\r
1283 //\r
1284 Map<String, String[]> ppiMap = new HashMap<String, String[]>();\r
1285\r
1286 if (returns == null) {\r
1287 return ppiMap;\r
1288 }\r
1289\r
1290 for (int i = 0; i < returns.length; i++) {\r
1291 PpiDeclarationsDocument.PpiDeclarations.Entry entry = (PpiDeclarationsDocument.PpiDeclarations.Entry) returns[i];\r
1292 String[] ppiPair = new String[2];\r
1293 ppiPair[0] = entry.getCName();\r
1294 ppiPair[1] = entry.getGuidValue();\r
1295 ppiMap.put(entry.getName(), ppiPair);\r
1296 }\r
1297 return ppiMap;\r
1298 }\r
1299\r
1300 /**\r
1301 * getModuleSupportedArchs()\r
1302 * \r
1303 * This function is to Retrieve Archs one module supported.\r
1304 * \r
1305 * @param\r
1306 * @return supportArch String of supporting archs. null No arch specified in\r
1307 * <MouduleSupport> element.\r
1308 */\r
1309 public static List<String> getModuleSupportedArchs() {\r
1310 String[] xPath = new String[] { "/ModuleDefinitions/SupportedArchitectures" };\r
1311\r
1312 XmlObject[] returns = get("ModuleSurfaceArea", xPath);\r
1313\r
1314 if (returns == null) {\r
1315 return null;\r
1316 }\r
1317\r
1318 return (List<String>)returns[0];\r
1319 }\r
1320\r
1321 public static XmlObject[] getSpdPcdDeclarations() {\r
1322 String[] xPath = null;\r
1323// if (tsGuid != null){\r
1324// xPath = new String[] { "/PcdDeclarations/PcdEntry[C_Name='" + cName + "' and TokenSpaceGuid='"+ tsGuid + "']" };\r
1325// }\r
1326// else{\r
1327// xPath = new String[] { "/PcdDeclarations/PcdEntry[C_Name='" + cName + "']" };\r
1328// } \r
1329 xPath = new String[] { "/PcdDeclarations/PcdEntry"};\r
1330 XmlObject[] returns = get("PackageSurfaceArea", xPath);\r
1331 \r
1332 return returns;\r
1333 }\r
1334 \r
1335 public static XmlObject[] getFpdPcdBuildDefinitions(String cName, String tsGuid, String type) {\r
1336 String[] xPath = new String[] { "/PcdBuildDefinition/PcdData[C_Name='" + cName + "' and TokenSpaceGuid='"\r
1337 + tsGuid + "' and DatumType!='" + type + "']" };\r
1338\r
1339 XmlObject[] returns = get("ModuleSA", xPath);\r
1340\r
1341 return returns;\r
1342 }\r
1343 /**\r
1344 * getToolChainFamily\r
1345 * \r
1346 * This function is to retrieve ToolChainFamily attribute of FPD\r
1347 * <BuildOptions>\r
1348 * \r
1349 * @param\r
1350 * @return toolChainFamily If find toolChainFamily attribute in\r
1351 * <BuildOptions> Null If don't have toolChainFamily in\r
1352 * <BuildOptions>.\r
1353 */\r
1354 public String getToolChainFamily() {\r
1355 String toolChainFamily;\r
1356 String[] xPath = new String[] { "/BuildOptions" };\r
1357\r
1358 XmlObject[] result = get("FrameworkPlatformDescription", xPath);\r
1359 if (result == null) {\r
1360 return null;\r
1361 }\r
1362 // toolChainFamily =\r
1363 // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies();\r
1364 // return toolChainFamily;\r
1365 return null;\r
1366 }\r
1367\r
1368 /**\r
1369 * Retrieve module Guid string\r
1370 * \r
1371 * @returns GUILD string if elements are found at the known xpath\r
1372 * @returns null if nothing is there\r
1373 */\r
1374 public static String getModuleGuid() {\r
1375 String[] xPath = new String[] { "" };\r
1376\r
1377 XmlObject[] returns = get("MsaHeader", xPath);\r
1378 if (returns != null && returns.length > 0) {\r
1379 String guid = ((MsaHeaderDocument.MsaHeader) returns[0])\r
1380 .getGuidValue();\r
1381 return guid;\r
1382 }\r
1383\r
1384 return null;\r
1385 }\r
1386\r
1387 //\r
1388 // For new Pcd\r
1389 //\r
1390 public static ModuleSADocument.ModuleSA[] getFpdModuleSAs() {\r
1391 String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r
1392 XmlObject[] result = get("FrameworkPlatformDescription", xPath);\r
1393 if (result != null) {\r
1394 return (ModuleSADocument.ModuleSA[]) result;\r
1395 }\r
1396 return new ModuleSADocument.ModuleSA[0];\r
1397\r
1398 }\r
1399}\r