2 This file is for surface area information retrieval.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 package org
.tianocore
.build
.global
;
16 import java
.util
.ArrayList
;
17 import java
.util
.HashMap
;
18 import java
.util
.Iterator
;
19 import java
.util
.LinkedHashMap
;
20 import java
.util
.List
;
22 import java
.util
.Stack
;
23 import java
.util
.regex
.Matcher
;
24 import java
.util
.regex
.Pattern
;
26 import org
.apache
.xmlbeans
.XmlNormalizedString
;
27 import org
.apache
.xmlbeans
.XmlObject
;
28 import org
.apache
.xmlbeans
.XmlString
;
29 import org
.tianocore
.*;
30 import org
.tianocore
.FilenameDocument
.Filename
;
31 import org
.tianocore
.MsaHeaderDocument
.MsaHeader
;
32 import org
.tianocore
.ProtocolsDocument
.Protocols
.Protocol
;
33 import org
.tianocore
.ProtocolsDocument
.Protocols
.ProtocolNotify
;
34 import org
.tianocore
.SupportedArchitectures
.Enum
;
35 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
36 import org
.tianocore
.build
.id
.ModuleIdentification
;
37 import org
.tianocore
.build
.id
.PackageIdentification
;
38 import org
.tianocore
.build
.id
.PlatformIdentification
;
39 import org
.tianocore
.build
.toolchain
.ToolChainInfo
;
40 import org
.tianocore
.logger
.EdkLog
;
43 * SurfaceAreaQuery class is used to query Surface Area information from msa,
44 * mbd, spd and fpd files.
46 * This class should not instantiated. All the public interfaces is static.
50 public class SurfaceAreaQuery
{
52 public static String prefix
= "http://www.TianoCore.org/2006/Edk2.0";
55 // / Contains name/value pairs of Surface Area document object. The name is
56 // / always the top level element name.
58 private static Map
<String
, XmlObject
> map
= null;
61 // / mapStack is used to do nested query
63 private static Stack
<Map
<String
, XmlObject
>> mapStack
= new Stack
<Map
<String
, XmlObject
>>();
66 // / prefix of name space
68 private static String nsPrefix
= "sans";
71 // / xmlbeans needs a name space for each Xpath element
73 private static String ns
= null;
76 // / keep the namep declaration for xmlbeans Xpath query
78 private static String queryDeclaration
= null;
81 * Set a Surface Area document for query later
84 * A Surface Area document in TopLevelElementName/XmlObject
87 public static void setDoc(Map
<String
, XmlObject
> map
) {
89 queryDeclaration
= "declare namespace " + nsPrefix
+ "='" + ns
+ "'; ";
90 SurfaceAreaQuery
.map
= map
;
94 * Push current used Surface Area document into query stack. The given new
95 * document will be used for any immediately followed getXXX() callings,
96 * untill pop() is called.
99 * The TopLevelElementName/XmlObject format of a Surface Area
102 public static void push(Map
<String
, XmlObject
> newMap
) {
103 mapStack
.push(SurfaceAreaQuery
.map
);
104 SurfaceAreaQuery
.map
= newMap
;
108 * Discard current used Surface Area document and use the top document in
111 public static void pop() {
112 SurfaceAreaQuery
.map
= mapStack
.pop();
116 // / Convert xPath to be namespace qualified, which is necessary for
118 // / selectPath(). For example, converting /MsaHeader/ModuleType to
119 // / /ns:MsaHeader/ns:ModuleType
121 private static String
normalizeQueryString(String
[] exp
, String from
) {
122 StringBuffer normQueryString
= new StringBuffer(4096);
125 while (i
< exp
.length
) {
126 String newExp
= from
+ exp
[i
];
127 Pattern pattern
= Pattern
.compile("([^/]*)(/|//)([^/]+)");
128 Matcher matcher
= pattern
.matcher(newExp
);
130 while (matcher
.find()) {
131 String starter
= newExp
.substring(matcher
.start(1), matcher
133 String seperator
= newExp
.substring(matcher
.start(2), matcher
135 String token
= newExp
.substring(matcher
.start(3), matcher
138 normQueryString
.append(starter
);
139 normQueryString
.append(seperator
);
140 normQueryString
.append(nsPrefix
);
141 normQueryString
.append(":");
142 normQueryString
.append(token
);
146 if (i
< exp
.length
) {
147 normQueryString
.append(" | ");
151 return normQueryString
.toString();
155 * Search all XML documents stored in "map" for the specified xPath, using
156 * relative path (starting with '$this')
159 * xpath query string array
160 * @returns An array of XmlObject if elements are found at the specified
162 * @returns NULL if nothing is at the specified xpath
164 public static Object
[] get(String
[] xPath
) {
169 String
[] keys
= (String
[]) map
.keySet().toArray(new String
[map
.size()]);
170 List
<Object
> result
= new ArrayList
<Object
>();
171 for (int i
= 0; i
< keys
.length
; ++i
) {
172 XmlObject rootNode
= (XmlObject
) map
.get(keys
[i
]);
173 if (rootNode
== null) {
177 String query
= queryDeclaration
178 + normalizeQueryString(xPath
, "$this/" + keys
[i
]);
179 XmlObject
[] tmp
= rootNode
.selectPath(query
);
180 for (int j
= 0; j
< tmp
.length
; ++j
) {
181 result
.add((Object
)tmp
[j
]);
185 int size
= result
.size();
190 return (Object
[]) result
.toArray(new Object
[size
]);
194 * Search XML documents named by "rootName" for the given xPath, using
195 * relative path (starting with '$this')
198 * The top level element name
200 * The xpath query string array
201 * @returns An array of XmlObject if elements are found at the given xpath
202 * @returns NULL if nothing is found at the given xpath
204 public static Object
[] get(String rootName
, String
[] xPath
) {
209 XmlObject root
= (XmlObject
) map
.get(rootName
);
214 String query
= queryDeclaration
215 + normalizeQueryString(xPath
, "$this/" + rootName
);
216 XmlObject
[] result
= root
.selectPath(query
);
217 if (result
.length
> 0) {
218 return (Object
[])result
;
221 query
= queryDeclaration
+ normalizeQueryString(xPath
, "/" + rootName
);
222 result
= root
.selectPath(query
);
223 if (result
.length
> 0) {
224 return (Object
[])result
;
231 * Retrieve SourceFiles/Filename for specified ARCH type
235 * @returns An 2 dimension string array if elements are found at the known
237 * @returns NULL if nothing is found at the known xpath
239 public static String
[][] getSourceFiles(String arch
) {
243 xPath
= new String
[] { "/Filename" };
245 returns
= get("SourceFiles", xPath
);
247 if (returns
== null || returns
.length
== 0) {
248 return new String
[0][0];
251 Filename
[] sourceFileNames
= (Filename
[]) returns
;
252 List
<String
[]> outputList
= new ArrayList
<String
[]>();
253 for (int i
= 0; i
< sourceFileNames
.length
; i
++) {
254 List
<String
> archList
= sourceFileNames
[i
].getSupArchList();
255 if (arch
== null || arch
.equalsIgnoreCase("") || archList
== null || archList
.contains(arch
)) {
256 outputList
.add(new String
[] {sourceFileNames
[i
].getToolCode(),sourceFileNames
[i
].getStringValue()});
260 String
[][] outputString
= new String
[outputList
.size()][2];
261 for (int index
= 0; index
< outputList
.size(); index
++) {
262 outputString
[index
][0] = outputList
.get(index
)[0];
263 outputString
[index
][1] = outputList
.get(index
)[1];
269 * Retrieve /PlatformDefinitions/OutputDirectory from FPD
271 * @returns Directory names array if elements are found at the known xpath
272 * @returns Empty if nothing is found at the known xpath
274 public static String
getFpdOutputDirectory() {
275 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
277 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
278 if (returns
== null || returns
.length
== 0) {
281 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
282 return item
.getOutputDirectory();
285 public static String
getFpdIntermediateDirectories() {
286 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
288 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
289 if (returns
== null || returns
.length
== 0) {
292 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
293 if(item
.getIntermediateDirectories() == null) {
297 return item
.getIntermediateDirectories().toString();
301 public static String
getModuleFfsKeyword() {
302 String
[] xPath
= new String
[] { "/" };
304 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
305 if (returns
== null || returns
.length
== 0) {
308 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
309 return item
.getFfsFormatKey();
312 public static String
getModuleFvBindingKeyword() {
313 String
[] xPath
= new String
[] { "/" };
315 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
316 if (returns
== null || returns
.length
== 0) {
319 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
320 return item
.getFvBinding();
323 public static List
getModuleSupportedArchs() {
324 String
[] xPath
= new String
[] { "/" };
326 Object
[] returns
= get("ModuleDefinitions", xPath
);
327 if (returns
== null || returns
.length
== 0) {
330 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
331 return item
.getSupportedArchitectures();
334 public static BuildOptionsDocument
.BuildOptions
.Ffs
[] getFpdFfs() {
335 String
[] xPath
= new String
[] {"/Ffs"};
337 Object
[] returns
= get("BuildOptions", xPath
);
338 if (returns
== null || returns
.length
== 0) {
339 return new BuildOptionsDocument
.BuildOptions
.Ffs
[0];
341 return (BuildOptionsDocument
.BuildOptions
.Ffs
[])returns
;
344 public static String
getModuleOutputFileBasename() {
345 String
[] xPath
= new String
[] { "/" };
347 Object
[] returns
= get("ModuleDefinitions", xPath
);
348 if (returns
== null || returns
.length
== 0) {
351 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
352 return item
.getOutputFileBasename();
356 * Retrieve BuildOptions/Option or Arch/Option
358 * @param toolChainFamilyFlag
359 * if true, retrieve options for toolchain family; otherwise for
362 * @returns String[][5] name, target, toolchain, arch, coommand of options
363 * if elements are found at the known xpath. String[0][] if dont
366 * @returns Empty array if nothing is there
368 public static String
[][] getOptions(String from
, String
[] xPath
, boolean toolChainFamilyFlag
) {
369 String target
= null;
370 String toolchain
= null;
371 String toolchainFamily
= null;
372 List
<String
> archList
= null;
374 String targetName
= null;
375 String optionName
= null;
377 Object
[] returns
= get(from
, xPath
);
378 if (returns
== null) {
379 return new String
[0][5];
382 List
<String
[]> optionList
= new ArrayList
<String
[]>();
383 OptionDocument
.Option option
;
385 for (int i
= 0; i
< returns
.length
; i
++) {
386 option
= (OptionDocument
.Option
) returns
[i
];
389 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
391 // put to result[][5] array in above order.
394 if (option
.getBuildTargets() == null) {
398 target
= option
.getBuildTargets().toString();
400 if (target
!= null) {
401 targetList
= target
.split(" ");
403 targetList
= new String
[1];
404 targetList
[0] = null;
407 if (toolChainFamilyFlag
) {
408 toolchainFamily
= option
.getToolChainFamily();
409 if (toolchainFamily
!= null) {
410 toolchain
= toolchainFamily
.toString();
415 toolchain
= option
.getTagName();
418 archList
= new ArrayList
<String
>();
419 List
<String
> archEnumList
= option
.getSupArchList();
420 if (archEnumList
== null) {
423 archList
.addAll(archEnumList
);
425 Iterator it = archEnumList.iterator();
426 while (it.hasNext()) {
427 System.out.println(it.next().getClass().getName());
428 SupportedArchitectures.Enum archType = it.next();
429 archList.add(archType.toString());
434 cmd
= option
.getToolCode();
436 optionName
= option
.getStringValue();
437 for (int t
= 0; t
< targetList
.length
; t
++) {
438 for (int j
= 0; j
< archList
.size(); j
++) {
439 optionList
.add(new String
[] { targetList
[t
],
440 toolchain
, archList
.get(j
), cmd
, optionName
});
445 String
[][] result
= new String
[optionList
.size()][5];
446 for (int i
= 0; i
< optionList
.size(); i
++) {
447 result
[i
][0] = optionList
.get(i
)[0];
448 result
[i
][1] = optionList
.get(i
)[1];
449 result
[i
][2] = optionList
.get(i
)[2];
450 result
[i
][3] = optionList
.get(i
)[3];
451 result
[i
][4] = optionList
.get(i
)[4];
456 public static String
[][] getModuleBuildOptions(boolean toolChainFamilyFlag
) {
459 if (toolChainFamilyFlag
== true) {
460 xPath
= new String
[] {
461 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
462 "/Options/Option[@ToolChainFamily]", };
464 xPath
= new String
[] {
465 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
466 "/Options/Option[@TagName]", };
468 return getOptions("ModuleSaBuildOptions", xPath
, toolChainFamilyFlag
);
471 public static String
[][] getPlatformBuildOptions(boolean toolChainFamilyFlag
) {
474 if (toolChainFamilyFlag
== true) {
475 xPath
= new String
[] {
476 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
477 "/BuildOptions/Options/Option[@ToolChainFamily]", };
479 xPath
= new String
[] {
480 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
481 "/BuildOptions/Options/Option[@TagName]", };
484 return getOptions("PlatformSurfaceArea", xPath
, toolChainFamilyFlag
);
487 public static ToolChainInfo
getFpdToolChainInfo() {
488 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
490 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
491 if (returns
== null || returns
.length
== 0) {
495 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
496 ToolChainInfo toolChainInfo
= new ToolChainInfo();
497 toolChainInfo
.addTargets(item
.getBuildTargets().toString());
498 toolChainInfo
.addArchs(item
.getSupportedArchitectures().toString());
499 toolChainInfo
.addTagnames((String
)null);
500 return toolChainInfo
;
504 * Retrieve <xxxHeader>/ModuleType
506 * @returns The module type name if elements are found at the known xpath
507 * @returns null if nothing is there
509 public static String
getModuleType() {
510 String
[] xPath
= new String
[] { "/ModuleType" };
512 Object
[] returns
= get(xPath
);
513 if (returns
!= null && returns
.length
> 0) {
514 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
515 return type
.enumValue().toString();
522 * Retrieve PackageDependencies/Package
527 * @returns package name list if elements are found at the known xpath
528 * @returns null if nothing is there
530 public static PackageIdentification
[] getDependencePkg(String arch
) {
532 String packageGuid
= null;
533 String packageVersion
= null;
536 xPath
= new String
[] { "/Package" };
538 Object
[] returns
= get("PackageDependencies", xPath
);
539 if (returns
== null) {
540 return new PackageIdentification
[0];
542 PackageIdentification
[] packageIdList
= new PackageIdentification
[returns
.length
];
543 for (int i
= 0; i
< returns
.length
; i
++) {
544 PackageDependenciesDocument
.PackageDependencies
.Package item
= (PackageDependenciesDocument
.PackageDependencies
.Package
) returns
[i
];
545 List
<String
> archList
= item
.getSupArchList();
546 if (arch
== null || archList
== null || archList
.contains(arch
)) {
547 packageGuid
= item
.getPackageGuid();
548 packageVersion
= item
.getPackageVersion();
549 packageIdList
[i
] = (new PackageIdentification(null, packageGuid
,
553 return packageIdList
;
557 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
560 * Library class usage
562 * @returns LibraryClass objects list if elements are found at the known
564 * @returns null if nothing is there
566 public static String
[] getLibraryClasses(String usage
) {
569 if (usage
== null || usage
.equals("")) {
570 xPath
= new String
[] { "/LibraryClass" };
572 xPath
= new String
[] { "/LibraryClass[@Usage='" + usage
+ "']" };
575 Object
[] returns
= get("LibraryClassDefinitions", xPath
);
576 if (returns
== null || returns
.length
== 0) {
577 return new String
[0];
580 LibraryClassDocument
.LibraryClass
[] libraryClassList
= (LibraryClassDocument
.LibraryClass
[]) returns
;
581 String
[] libraryClassName
= new String
[libraryClassList
.length
];
582 for (int i
= 0; i
< libraryClassList
.length
; i
++) {
583 libraryClassName
[i
] = libraryClassList
[i
].getKeyword();
585 return libraryClassName
;
589 * Retrieve ModuleEntryPoint names
591 * @returns ModuleEntryPoint name list if elements are found at the known
593 * @returns null if nothing is there
595 public static String
[] getModuleEntryPointArray() {
596 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
598 Object
[] returns
= get("Externs", xPath
);
600 if (returns
!= null && returns
.length
> 0) {
601 String
[] entryPoints
= new String
[returns
.length
];
603 for (int i
= 0; i
< returns
.length
; ++i
) {
604 entryPoints
[i
] = ((CNameType
) returns
[i
]).getStringValue();
614 * retrieve Protocol for specified usage
617 * Protocol usage arch Architecture
619 * @returns Protocol String list if elements are found at the known xpath
620 * @returns String[0] if nothing is there
622 public static String
[] getProtocolArray(String arch
, String usage
) {
624 String usageXpath
= "";
625 String archXpath
= "";
627 if (arch
== null || arch
.equals("")) {
628 return new String
[0];
630 archXpath
= "/Protocol";
631 if (usage
!= null && !usage
.equals("")) {
632 usageXpath
= "/Protocol[@Usage='" + usage
+ "']";
633 xPath
= new String
[] { usageXpath
, archXpath
};
635 return getProtocolArray(arch
);
640 Object
[] returns
= get("Protocols", xPath
);
641 if (returns
== null) {
642 return new String
[0];
644 Protocol
[] protocolList
= (Protocol
[]) returns
;
646 String
[] protocolArray
= new String
[returns
.length
];
647 for (int i
= 0; i
< returns
.length
; i
++) {
648 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
650 return protocolArray
;
654 * retrieve Protocol for specified usage
659 * @returns Protocol String list if elements are found at the known xpath
660 * @returns String[0] if nothing is there
662 public static String
[] getProtocolArray(String arch
) {
665 if (arch
== null || arch
.equals("")) {
666 return new String
[0];
668 xPath
= new String
[] { "/Protocol" };
671 Object
[] returns
= get("Protocols", xPath
);
672 if (returns
== null) {
673 return new String
[0];
675 Protocol
[] returnlList
= (Protocol
[]) returns
;
677 List
<String
> protocolList
= new ArrayList
<String
>();
679 for (int i
= 0; i
< returns
.length
; i
++) {
680 List
<String
> archList
= returnlList
[i
].getSupArchList();
681 if (archList
== null || archList
.contains(arch
)){
682 protocolList
.add(returnlList
[i
].getProtocolCName());
685 String
[] protocolArray
= new String
[protocolList
.size()];
686 for (int i
= 0; i
< protocolList
.size(); i
++) {
687 protocolArray
[i
] = protocolList
.get(i
);
689 return protocolArray
;
693 * Retrieve ProtocolNotify for specified usage
696 * ProtocolNotify usage
698 * @returns String[] if elements are found at the known xpath
699 * @returns String[0] if nothing is there
701 public static String
[] getProtocolNotifyArray(String arch
) {
704 if (arch
== null || arch
.equals("")) {
705 return new String
[0];
707 xPath
= new String
[] { "/ProtocolNotify" };
710 Object
[] returns
= get("Protocols", xPath
);
711 if (returns
== null) {
712 return new String
[0];
715 List
<String
> protocolNotifyList
= new ArrayList
<String
>();
717 for (int i
= 0; i
< returns
.length
; i
++) {
718 List
<String
> archList
= ((ProtocolNotify
) returns
[i
]).getSupArchList();
719 if (archList
== null || archList
.contains(arch
)){
720 protocolNotifyList
.add(((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName());
724 String
[] protocolNotifyArray
= new String
[protocolNotifyList
.size()];
725 for (int i
= 0; i
< protocolNotifyList
.size(); i
++) {
726 protocolNotifyArray
[i
] = protocolNotifyList
.get(i
);
728 return protocolNotifyArray
;
732 * Retrieve ProtocolNotify for specified usage
735 * ProtocolNotify usage
737 * @returns String[] if elements are found at the known xpath
738 * @returns String[0] if nothing is there
740 public static String
[] getProtocolNotifyArray(String arch
, String usage
) {
746 if (arch
== null || arch
.equals("")) {
747 return new String
[0];
749 archXpath
= "/ProtocolNotify";
750 if (usage
!= null && !usage
.equals("")) {
751 usageXpath
= "/ProtocolNotify[@Usage='" + arch
+ "']";
752 xPath
= new String
[] { archXpath
, usageXpath
};
754 return getProtocolNotifyArray(arch
);
758 Object
[] returns
= get("Protocols", xPath
);
759 if (returns
== null) {
760 return new String
[0];
763 String
[] protocolNotifyList
= new String
[returns
.length
];
765 for (int i
= 0; i
< returns
.length
; i
++) {
766 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
768 return protocolNotifyList
;
772 * Retrieve ModuleUnloadImage names
774 * @returns ModuleUnloadImage name list if elements are found at the known
776 * @returns null if nothing is there
778 public static String
[] getModuleUnloadImageArray() {
779 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
781 Object
[] returns
= get("Externs", xPath
);
782 if (returns
!= null && returns
.length
> 0) {
783 String
[] stringArray
= new String
[returns
.length
];
784 CNameType
[] doc
= (CNameType
[]) returns
;
786 for (int i
= 0; i
< returns
.length
; ++i
) {
787 stringArray
[i
] = doc
[i
].getStringValue();
799 * @returns Extern objects list if elements are found at the known xpath
800 * @returns null if nothing is there
802 public static ExternsDocument
.Externs
.Extern
[] getExternArray() {
803 String
[] xPath
= new String
[] { "/Extern" };
805 Object
[] returns
= get("Externs", xPath
);
806 if (returns
!= null && returns
.length
> 0) {
807 return (ExternsDocument
.Externs
.Extern
[]) returns
;
814 * Retrieve PpiNotify for specified arch
819 * @returns String[] if elements are found at the known xpath
820 * @returns String[0] if nothing is there
822 public static String
[] getPpiNotifyArray(String arch
) {
825 if (arch
== null || arch
.equals("")) {
826 return new String
[0];
828 xPath
= new String
[] { "/PpiNotify" };
831 Object
[] returns
= get("PPIs", xPath
);
832 if (returns
== null) {
833 return new String
[0];
837 List
<String
> ppiNotifyList
= new ArrayList
<String
>();
838 for (int i
= 0; i
< returns
.length
; i
++) {
839 List
<String
> archList
= ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getSupArchList();
840 if (archList
== null || archList
.contains(arch
)){
841 ppiNotifyList
.add(((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName());
845 String
[] ppiNotifyArray
= new String
[ppiNotifyList
.size()];
846 for (int i
= 0; i
< ppiNotifyList
.size(); i
++) {
847 ppiNotifyArray
[i
] = ppiNotifyList
.get(i
);
850 return ppiNotifyArray
;
854 * Retrieve PpiNotify for specified usage and arch
857 * PpiNotify arch usage PpiNotify usage
860 * @returns String[] if elements are found at the known xpath
861 * @returns String[0] if nothing is there
863 public static String
[] getPpiNotifyArray(String arch
, String usage
) {
869 if (arch
== null || arch
.equals("")) {
870 return new String
[0];
872 archXpath
= "/PpiNotify";
873 if (usage
!= null && !usage
.equals("")) {
874 usageXpath
= "/PpiNotify[@Usage='" + arch
+ "']";
875 xPath
= new String
[] { archXpath
, usageXpath
};
877 return getProtocolNotifyArray(arch
);
881 Object
[] returns
= get("PPIs", xPath
);
882 if (returns
== null) {
883 return new String
[0];
886 String
[] ppiNotifyList
= new String
[returns
.length
];
888 for (int i
= 0; i
< returns
.length
; i
++) {
889 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
891 return ppiNotifyList
;
895 * Retrieve Ppi for specified arch
900 * @returns String[] if elements are found at the known xpath
901 * @returns String[0] if nothing is there
903 public static String
[] getPpiArray(String arch
) {
906 if (arch
== null || arch
.equals("")) {
907 return new String
[0];
909 xPath
= new String
[] { "/Ppi" };
912 Object
[] returns
= get("PPIs", xPath
);
913 if (returns
== null) {
914 return new String
[0];
917 List
<String
> ppiList
= new ArrayList
<String
>();
918 for (int i
= 0; i
< returns
.length
; i
++) {
919 List
<String
> archList
= ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getSupArchList();
920 if (archList
== null || archList
.contains(arch
)){
921 ppiList
.add(((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName());
925 String
[] ppiArray
= new String
[ppiList
.size()];
926 for (int i
= 0; i
< ppiList
.size(); i
++) {
927 ppiArray
[i
] = ppiList
.get(i
);
933 * Retrieve PpiNotify for specified usage and arch
936 * PpiNotify arch usage PpiNotify usage
939 * @returns String[] if elements are found at the known xpath
940 * @returns String[0] if nothing is there
942 public static String
[] getPpiArray(String arch
, String usage
) {
948 if (arch
== null || arch
.equals("")) {
949 return new String
[0];
952 if (usage
!= null && !usage
.equals("")) {
953 usageXpath
= "/Ppi[@Usage='" + arch
+ "']";
954 xPath
= new String
[] { archXpath
, usageXpath
};
956 return getProtocolNotifyArray(arch
);
960 Object
[] returns
= get("PPIs", xPath
);
961 if (returns
== null) {
962 return new String
[0];
965 String
[] ppiList
= new String
[returns
.length
];
967 for (int i
= 0; i
< returns
.length
; i
++) {
968 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
974 * Retrieve GuidEntry information for specified usage
979 * @returns GuidEntry objects list if elements are found at the known xpath
980 * @returns null if nothing is there
982 public static String
[] getGuidEntryArray(String arch
) {
985 if (arch
== null || arch
.equals("")) {
986 xPath
= new String
[] { "/GuidCNames" };
988 xPath
= new String
[] { "/GuidCNames" };
991 Object
[] returns
= get("Guids", xPath
);
992 if (returns
== null) {
993 return new String
[0];
996 List
<String
> guidList
= new ArrayList
<String
>();
997 for (int i
= 0; i
< returns
.length
; i
++) {
998 List
<String
> archList
= ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getSupArchList();
999 if (archList
== null || archList
.contains(arch
)){
1000 guidList
.add(((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName());
1004 String
[] guidArray
= new String
[guidList
.size()];
1005 for (int i
= 0; i
< guidList
.size(); i
++) {
1006 guidArray
[i
] = guidList
.get(i
);
1013 * Retrieve GuidEntry information for specified usage
1016 * GuidEntry arch usage GuidEntry usage
1018 * @returns GuidEntry objects list if elements are found at the known xpath
1019 * @returns null if nothing is there
1021 public static String
[] getGuidEntryArray(String arch
, String usage
) {
1026 if (arch
== null || arch
.equals("")) {
1027 return new String
[0];
1029 archXpath
= "/GuidEntry";
1030 if (usage
!= null && !usage
.equals("")) {
1031 usageXpath
= "/GuidEntry[@Usage='" + arch
+ "']";
1032 xPath
= new String
[] { archXpath
, usageXpath
};
1034 return getProtocolNotifyArray(arch
);
1038 Object
[] returns
= get("Guids", xPath
);
1039 if (returns
== null) {
1040 return new String
[0];
1043 String
[] guidList
= new String
[returns
.length
];
1045 for (int i
= 0; i
< returns
.length
; i
++) {
1046 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1052 * Retrieve Library instance information
1057 * Library instance usage
1059 * @returns library instance name list if elements are found at the known
1061 * @returns null if nothing is there
1063 public static ModuleIdentification
[] getLibraryInstance(String arch
) {
1065 String saGuid
= null;
1066 String saVersion
= null;
1067 String pkgGuid
= null;
1068 String pkgVersion
= null;
1070 if (arch
== null || arch
.equalsIgnoreCase("")) {
1071 xPath
= new String
[] { "/Instance" };
1074 // Since Schema don't have SupArchList now, so the follow Xpath is
1075 // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]
1076 // don't have effect.
1078 xPath
= new String
[] { "/Instance[not(@SupArchList) or @SupArchList='"
1082 Object
[] returns
= get("Libraries", xPath
);
1083 if (returns
== null || returns
.length
== 0) {
1084 return new ModuleIdentification
[0];
1087 ModuleIdentification
[] saIdList
= new ModuleIdentification
[returns
.length
];
1088 for (int i
= 0; i
< returns
.length
; i
++) {
1089 LibrariesDocument
.Libraries
.Instance library
= (LibrariesDocument
.Libraries
.Instance
) returns
[i
];
1090 saGuid
= library
.getModuleGuid();
1091 saVersion
= library
.getModuleVersion();
1093 pkgGuid
= library
.getPackageGuid();
1094 pkgVersion
= library
.getPackageVersion();
1096 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1098 PackageIdentification pkgId
= new PackageIdentification(null,
1099 pkgGuid
, pkgVersion
);
1100 saId
.setPackage(pkgId
);
1109 // / This method is used for retrieving the elements information which has
1110 // / CName sub-element
1112 private static String
[] getCNames(String from
, String xPath
[]) {
1113 Object
[] returns
= get(from
, xPath
);
1114 if (returns
== null || returns
.length
== 0) {
1118 String
[] strings
= new String
[returns
.length
];
1119 for (int i
= 0; i
< returns
.length
; ++i
) {
1121 strings
[i
] = ((CNameType
) returns
[i
]).getStringValue();
1128 * Retrive library's constructor name
1130 * @returns constructor name list if elements are found at the known xpath
1131 * @returns null if nothing is there
1133 public static String
getLibConstructorName() {
1134 String
[] xPath
= new String
[] { "/Extern/Constructor" };
1136 Object
[] returns
= get("Externs", xPath
);
1137 if (returns
!= null && returns
.length
> 0) {
1138 CNameType constructor
= ((CNameType
) returns
[0]);
1139 return constructor
.getStringValue();
1146 * Retrive library's destructor name
1148 * @returns destructor name list if elements are found at the known xpath
1149 * @returns null if nothing is there
1151 public static String
getLibDestructorName() {
1152 String
[] xPath
= new String
[] { "/Extern/Destructor" };
1154 Object
[] returns
= get("Externs", xPath
);
1155 if (returns
!= null && returns
.length
> 0) {
1157 // Only support one Destructor function.
1159 CNameType destructor
= (CNameType
) returns
[0];
1160 return destructor
.getStringValue();
1167 * Retrive DriverBinding names
1169 * @returns DriverBinding name list if elements are found at the known xpath
1170 * @returns null if nothing is there
1172 public static String
[] getDriverBindingArray() {
1173 String
[] xPath
= new String
[] { "/Extern/DriverBinding" };
1174 return getCNames("Externs", xPath
);
1178 * Retrive ComponentName names
1180 * @returns ComponentName name list if elements are found at the known xpath
1181 * @returns null if nothing is there
1183 public static String
[] getComponentNameArray() {
1184 String
[] xPath
= new String
[] { "/Extern/ComponentName" };
1185 return getCNames("Externs", xPath
);
1189 * Retrive DriverConfig names
1191 * @returns DriverConfig name list if elements are found at the known xpath
1192 * @returns null if nothing is there
1194 public static String
[] getDriverConfigArray() {
1195 String
[] xPath
= new String
[] { "/Extern/DriverConfig" };
1196 return getCNames("Externs", xPath
);
1200 * Retrive DriverDiag names
1202 * @returns DriverDiag name list if elements are found at the known xpath
1203 * @returns null if nothing is there
1205 public static String
[] getDriverDiagArray() {
1206 String
[] xPath
= new String
[] { "/Extern/DriverDiag" };
1207 return getCNames("Externs", xPath
);
1211 * Retrive SetVirtualAddressMapCallBack names
1213 * @returns SetVirtualAddressMapCallBack name list if elements are found at
1215 * @returns null if nothing is there
1217 public static String
[] getSetVirtualAddressMapCallBackArray() {
1218 String
[] xPath
= new String
[] { "/Extern/SetVirtualAddressMapCallBack" };
1219 return getCNames("Externs", xPath
);
1223 * Retrive ExitBootServicesCallBack names
1225 * @returns ExitBootServicesCallBack name list if elements are found at the
1227 * @returns null if nothing is there
1229 public static String
[] getExitBootServicesCallBackArray() {
1230 String
[] xPath
= new String
[] { "/Extern/ExitBootServicesCallBack" };
1231 return getCNames("Externs", xPath
);
1235 * Retrieve module surface area file information
1237 * @returns ModuleSA objects list if elements are found at the known xpath
1238 * @returns Empty ModuleSA list if nothing is there
1240 public static Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> getFpdModules() {
1241 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1242 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1244 String fvBinding
= null;
1245 String saGuid
= null;
1246 String saVersion
= null;
1247 String pkgGuid
= null;
1248 String pkgVersion
= null;
1250 Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleMap
= new LinkedHashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
1252 if (result
== null) {
1253 return fpdModuleMap
;
1256 for (int i
= 0; i
< result
.length
; i
++) {
1258 // Get Fpd SA Module element node and add to ObjectMap.
1260 Map
<String
, XmlObject
> ObjectMap
= new HashMap
<String
, XmlObject
>();
1261 ModuleSADocument
.ModuleSA moduleSA
= (ModuleSADocument
.ModuleSA
) result
[i
];
1262 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getLibraries() != null) {
1263 ObjectMap
.put("Libraries", moduleSA
.getLibraries());
1265 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getPcdBuildDefinition() != null) {
1266 ObjectMap
.put("PcdBuildDefinition", moduleSA
1267 .getPcdBuildDefinition());
1269 if (((ModuleSADocument
.ModuleSA
) result
[i
])
1270 .getModuleSaBuildOptions() != null) {
1271 ObjectMap
.put("ModuleSaBuildOptions", moduleSA
1272 .getModuleSaBuildOptions());
1276 // Get Fpd SA Module attribute and create FpdMoudleIdentification.
1278 arch
= moduleSA
.getSupArchList().toString();
1282 saVersion
= ((ModuleSADocument
.ModuleSA
) result
[i
])
1283 .getModuleVersion();
1285 saGuid
= moduleSA
.getModuleGuid();
1286 pkgGuid
= moduleSA
.getPackageGuid();
1287 pkgVersion
= moduleSA
.getPackageVersion();
1290 // Create Module Identification which have class member of package
1293 PackageIdentification pkgId
= new PackageIdentification(null,
1294 pkgGuid
, pkgVersion
);
1295 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1298 saId
.setPackage(pkgId
);
1301 // Create FpdModule Identification which have class member of module
1305 String
[] archList
= arch
.split(" ");
1306 for (int j
= 0; j
< archList
.length
; j
++) {
1307 FpdModuleIdentification fpdSaId
= new FpdModuleIdentification(saId
, archList
[j
]);
1309 if (fvBinding
!= null) {
1310 fpdSaId
.setFvBinding(fvBinding
);
1314 // Put element to Map<FpdModuleIdentification, Map<String,
1317 fpdModuleMap
.put(fpdSaId
, ObjectMap
);
1321 return fpdModuleMap
;
1325 * Retrieve valid image names
1327 * @returns valid iamges name list if elements are found at the known xpath
1328 * @returns empty list if nothing is there
1330 public static String
[] getFpdValidImageNames() {
1331 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
1333 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1334 if (queryResult
== null) {
1335 return new String
[0];
1338 String
[] result
= new String
[queryResult
.length
];
1339 for (int i
= 0; i
< queryResult
.length
; i
++) {
1340 result
[i
] = ((XmlString
) queryResult
[i
]).getStringValue();
1346 public static XmlObject
getFpdUserExtension() {
1347 String
[] xPath
= new String
[] { "" };
1349 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1350 if (queryResult
== null) {
1357 * Retrieve FV image option information
1362 * @returns option name/value list if elements are found at the known xpath
1363 * @returns empty list if nothing is there
1365 public static String
[][] getFpdOptions(String fvName
) {
1366 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
1367 + fvName
.toUpperCase() + "']/FvImageOptions" };
1368 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1369 if (queryResult
== null) {
1370 return new String
[0][];
1372 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1373 for (int i
= 0; i
< queryResult
.length
; i
++) {
1374 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1375 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
1376 .getNameValueList();
1377 Iterator iter
= namevalues
.iterator();
1378 while (iter
.hasNext()) {
1379 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1381 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1384 String
[][] result
= new String
[list
.size()][2];
1385 for (int i
= 0; i
< list
.size(); i
++) {
1386 result
[i
][0] = list
.get(i
)[0];
1387 result
[i
][1] = list
.get(i
)[1];
1393 public static XmlObject
getFpdBuildOptions() {
1394 String
[] xPath
= new String
[] { "/BuildOptions" };
1396 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1398 if (queryResult
== null || queryResult
.length
== 0) {
1401 return (XmlObject
)queryResult
[0];
1404 public static PlatformIdentification
getFpdHeader() {
1405 String
[] xPath
= new String
[] { "/PlatformHeader" };
1407 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
1409 if (returns
== null || returns
.length
== 0) {
1412 PlatformHeaderDocument
.PlatformHeader header
= (PlatformHeaderDocument
.PlatformHeader
) returns
[0];
1414 String name
= header
.getPlatformName();
1416 String guid
= header
.getGuidValue();
1418 String version
= header
.getVersion();
1420 return new PlatformIdentification(name
, guid
, version
);
1424 * Retrieve FV image attributes information
1429 * @returns attribute name/value list if elements are found at the known
1431 * @returns empty list if nothing is there
1433 public static String
[][] getFpdAttributes(String fvName
) {
1434 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
1435 + fvName
.toUpperCase() + "']/FvImageOptions" };
1436 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1437 if (queryResult
== null) {
1438 return new String
[0][];
1440 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1441 for (int i
= 0; i
< queryResult
.length
; i
++) {
1443 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1444 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1445 Iterator iter
= namevalues
.iterator();
1446 while (iter
.hasNext()) {
1447 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1449 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1452 String
[][] result
= new String
[list
.size()][2];
1453 for (int i
= 0; i
< list
.size(); i
++) {
1454 result
[i
][0] = list
.get(i
)[0];
1455 result
[i
][1] = list
.get(i
)[1];
1461 * Retrieve flash definition file name
1463 * @returns file name if elements are found at the known xpath
1464 * @returns null if nothing is there
1466 public static String
getFlashDefinitionFile() {
1467 String
[] xPath
= new String
[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
1469 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1470 if (queryResult
== null || queryResult
.length
== 0) {
1474 FileNameConvention filename
= (FileNameConvention
) queryResult
[queryResult
.length
- 1];
1475 return filename
.getStringValue();
1478 public static String
[][] getFpdGlobalVariable() {
1479 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
1480 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1481 if (queryResult
== null) {
1482 return new String
[0][];
1485 String
[][] result
= new String
[queryResult
.length
][2];
1487 for (int i
= 0; i
< queryResult
.length
; i
++) {
1488 FvImagesDocument
.FvImages
.NameValue item
= (FvImagesDocument
.FvImages
.NameValue
)queryResult
[i
];
1489 result
[i
][0] = item
.getName();
1490 result
[i
][1] = item
.getValue();
1496 * Retrieve FV image component options
1501 * @returns name/value pairs list if elements are found at the known xpath
1502 * @returns empty list if nothing is there
1504 public static String
[][] getFpdComponents(String fvName
) {
1505 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName
.toUpperCase() + "']/FvImageOptions" };
1506 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1507 if (queryResult
== null) {
1508 return new String
[0][];
1511 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1512 for (int i
= 0; i
< queryResult
.length
; i
++) {
1513 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1514 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1515 Iterator iter
= namevalues
.iterator();
1516 while (iter
.hasNext()) {
1517 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1519 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1522 String
[][] result
= new String
[list
.size()][2];
1523 for (int i
= 0; i
< list
.size(); i
++) {
1524 result
[i
][0] = list
.get(i
)[0];
1525 result
[i
][1] = list
.get(i
)[1];
1531 * Retrieve PCD tokens
1533 * @returns CName/ItemType pairs list if elements are found at the known
1535 * @returns null if nothing is there
1537 public static String
[][] getPcdTokenArray() {
1538 String
[] xPath
= new String
[] { "/PcdData" };
1540 Object
[] returns
= get("PCDs", xPath
);
1541 if (returns
== null || returns
.length
== 0) {
1545 // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns;
1546 // String[][] result = new String[pcds.length][2];
1547 // for (int i = 0; i < returns.length; ++i) {
1548 // if (pcds[i].getItemType() != null) {
1549 // result[i][1] = pcds[i].getItemType().toString();
1551 // result[i][1] = null;
1553 // result[i][0] = pcds[i].getCName();
1560 * Get the PcdToken array from module's surface area document. The array
1561 * should contains following data:
1563 * -------------------------------------------------------------------
1566 * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText
1569 * -------------------------------------------------------------------
1572 * Note: Until new schema applying, now we can only get CName, ItemType,
1575 * @return 2-array table contains all information of PCD token retrieved
1578 public static Object
[][] etModulePCDTokenArray() {
1581 // Object[][] result;
1582 // PCDs.PcdData[] pcds;
1583 // String[] xPath = new String[] { "/PcdData" };
1584 // Object[] returns = get("PCDs", xPath);
1586 // if ((returns == null) || (returns.length == 0)) {
1590 // pcds = (PCDs.PcdData[]) returns;
1591 // result = new Object[pcds.length][6];
1592 // for (index = 0; index < pcds.length; index++) {
1596 // result[index][0] = pcds[index].getCName();
1598 // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE,
1599 // // DYNAMIC, DYNAMIC_EX
1601 // if (pcds[index].getItemType() != null) {
1602 // result[index][1] = pcds[index].getItemType().toString();
1604 // result[index][1] = null;
1608 // // BUGBUG: following field can *not* be got from current MSA until
1609 // // schema changed.
1611 // // result [index][2] = pcds[index].getTokenSpaceName();
1612 // result[index][2] = null;
1613 // result[index][3] = pcds[index].getDefaultValue();
1614 // // result [index][4] = pcds[index].getUsage ();
1615 // result[index][4] = null;
1616 // // result [index][5] = pcds[index].getHelpText ();
1617 // result[index][5] = null;
1623 * Retrieve MAS header
1628 public static ModuleIdentification
getMsaHeader() {
1629 String
[] xPath
= new String
[] { "/" };
1630 Object
[] returns
= get("MsaHeader", xPath
);
1632 if (returns
== null || returns
.length
== 0) {
1636 MsaHeader msaHeader
= (MsaHeader
) returns
[0];
1638 // Get BaseName, ModuleType, GuidValue, Version
1639 // which in MsaHeader.
1641 String name
= msaHeader
.getModuleName();
1642 String moduleType
= msaHeader
.getModuleType().toString();
1643 String guid
= msaHeader
.getGuidValue();
1644 String version
= msaHeader
.getVersion();
1646 ModuleIdentification moduleId
= new ModuleIdentification(name
, guid
,
1649 moduleId
.setModuleType(moduleType
);
1655 * Retrieve Extern Specification
1659 * @return String[] If have specification element in the <extern> String[0]
1660 * If no specification element in the <extern>
1664 public static String
[] getExternSpecificaiton() {
1665 String
[] xPath
= new String
[] { "/Specification" };
1667 Object
[] queryResult
= get("Externs", xPath
);
1668 if (queryResult
== null) {
1669 return new String
[0];
1672 String
[] specificationList
= new String
[queryResult
.length
];
1673 for (int i
= 0; i
< queryResult
.length
; i
++) {
1674 specificationList
[i
] = ((Sentence
)queryResult
[i
])
1677 return specificationList
;
1681 * Retreive MsaFile which in SPD
1684 * @return String[][3] The string sequence is ModuleName, ModuleGuid,
1685 * ModuleVersion, MsaFile String[0][] If no msafile in SPD
1687 public static String
[] getSpdMsaFile() {
1688 String
[] xPath
= new String
[] { "/MsaFiles" };
1690 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1691 if (returns
== null) {
1692 return new String
[0];
1695 List
<String
> filenameList
= ((MsaFilesDocument
.MsaFiles
) returns
[0])
1697 return filenameList
.toArray(new String
[filenameList
.size()]);
1703 public static Map
<String
, String
[]> getSpdLibraryClasses() {
1704 String
[] xPath
= new String
[] { "/LibraryClassDeclarations/LibraryClass" };
1706 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1709 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
1711 Map
<String
, String
[]> libClassHeaderMap
= new HashMap
<String
, String
[]>();
1713 if (returns
== null) {
1714 return libClassHeaderMap
;
1717 for (int i
= 0; i
< returns
.length
; i
++) {
1718 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass library
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) returns
[i
];
1719 libClassHeaderMap
.put(library
.getName(), new String
[] { library
1720 .getIncludeHeader() });
1722 return libClassHeaderMap
;
1728 public static Map
<String
, String
> getSpdPackageHeaderFiles() {
1729 String
[] xPath
= new String
[] { "/PackageHeaders/IncludePkgHeader" };
1731 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1734 // Create Map, Key - ModuleType, String - PackageInclude Header file.
1736 Map
<String
, String
> packageIncludeMap
= new HashMap
<String
, String
>();
1738 if (returns
== null) {
1739 return packageIncludeMap
;
1741 // GlobalData.log.info("" + returns[0].getClass().getName());
1742 for (int i
= 0; i
< returns
.length
; i
++) {
1743 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader includeHeader
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) returns
[i
];
1744 packageIncludeMap
.put(includeHeader
.getModuleType().toString(),
1745 includeHeader
.getStringValue());
1747 return packageIncludeMap
;
1750 public static PackageIdentification
getSpdHeader() {
1751 String
[] xPath
= new String
[] { "/SpdHeader" };
1753 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1755 if (returns
== null || returns
.length
== 0) {
1759 SpdHeaderDocument
.SpdHeader header
= (SpdHeaderDocument
.SpdHeader
) returns
[0];
1761 String name
= header
.getPackageName();
1763 String guid
= header
.getGuidValue();
1765 String version
= header
.getVersion();
1767 return new PackageIdentification(name
, guid
, version
);
1773 public static Map
<String
, String
[]> getSpdGuid() {
1774 String
[] xPath
= new String
[] { "/GuidDeclarations/Entry" };
1776 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1779 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
1781 Map
<String
, String
[]> guidDeclMap
= new HashMap
<String
, String
[]>();
1782 if (returns
== null) {
1786 for (int i
= 0; i
< returns
.length
; i
++) {
1787 GuidDeclarationsDocument
.GuidDeclarations
.Entry entry
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) returns
[i
];
1788 String
[] guidPair
= new String
[2];
1789 guidPair
[0] = entry
.getCName();
1790 guidPair
[1] = entry
.getGuidValue();
1791 guidDeclMap
.put(entry
.getName(), guidPair
);
1792 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1793 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[0]);
1794 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[1]);
1802 public static Map
<String
, String
[]> getSpdProtocol() {
1803 String
[] xPath
= new String
[] { "/ProtocolDeclarations/Entry" };
1805 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1808 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1810 Map
<String
, String
[]> protoclMap
= new HashMap
<String
, String
[]>();
1812 if (returns
== null) {
1816 for (int i
= 0; i
< returns
.length
; i
++) {
1817 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry entry
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) returns
[i
];
1818 String
[] protocolPair
= new String
[2];
1820 protocolPair
[0] = entry
.getCName();
1821 protocolPair
[1] = entry
.getGuidValue();
1822 protoclMap
.put(entry
.getName(), protocolPair
);
1823 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1824 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[0]);
1825 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[1]);
1831 * getSpdPpi() Retrieve the SPD PPI Entry
1834 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
1835 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
1838 public static Map
<String
, String
[]> getSpdPpi() {
1839 String
[] xPath
= new String
[] { "/PpiDeclarations/Entry" };
1841 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1844 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1846 Map
<String
, String
[]> ppiMap
= new HashMap
<String
, String
[]>();
1848 if (returns
== null) {
1852 for (int i
= 0; i
< returns
.length
; i
++) {
1853 PpiDeclarationsDocument
.PpiDeclarations
.Entry entry
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) returns
[i
];
1854 String
[] ppiPair
= new String
[2];
1855 ppiPair
[0] = entry
.getCName();
1856 ppiPair
[1] = entry
.getGuidValue();
1857 ppiMap
.put(entry
.getName(), ppiPair
);
1863 * getToolChainFamily
1865 * This function is to retrieve ToolChainFamily attribute of FPD
1869 * @return toolChainFamily If find toolChainFamily attribute in
1870 * <BuildOptions> Null If don't have toolChainFamily in
1873 public String
getToolChainFamily() {
1874 String toolChainFamily
;
1875 String
[] xPath
= new String
[] { "/BuildOptions" };
1877 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1878 if (result
== null) {
1881 // toolChainFamily =
1882 // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies();
1883 // return toolChainFamily;
1888 * Retrieve module Guid string
1890 * @returns GUILD string if elements are found at the known xpath
1891 * @returns null if nothing is there
1893 public static String
getModuleGuid() {
1894 String
[] xPath
= new String
[] { "" };
1896 Object
[] returns
= get("MsaHeader", xPath
);
1897 if (returns
!= null && returns
.length
> 0) {
1898 String guid
= ((MsaHeaderDocument
.MsaHeader
) returns
[0])
1909 public static ModuleSADocument
.ModuleSA
[] getFpdModuleSAs() {
1910 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1911 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1912 if (result
!= null) {
1913 return (ModuleSADocument
.ModuleSA
[]) result
;
1915 return new ModuleSADocument
.ModuleSA
[0];
1919 Get name array of PCD in a module. In one module, token space
1920 is same, and token name should not be conflicted.
1924 public static String
[] getModulePcdEntryNameArray() {
1925 PcdCodedDocument
.PcdCoded
.PcdEntry
[] pcdEntries
= null;
1928 String
[] xPath
= new String
[] {"/PcdEntry"};
1929 Object
[] returns
= get ("PcdCoded", xPath
);
1931 if (returns
== null) {
1932 return new String
[0];
1935 pcdEntries
= (PcdCodedDocument
.PcdCoded
.PcdEntry
[])returns
;
1936 results
= new String
[pcdEntries
.length
];
1938 for (index
= 0; index
< pcdEntries
.length
; index
++) {
1939 results
[index
] = pcdEntries
[index
].getCName();