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
.XmlObject
;
27 import org
.apache
.xmlbeans
.XmlString
;
28 import org
.tianocore
.BuildOptionsDocument
;
29 import org
.tianocore
.CNameType
;
30 import org
.tianocore
.ExternsDocument
;
31 import org
.tianocore
.FileNameConvention
;
32 import org
.tianocore
.FvImagesDocument
;
33 import org
.tianocore
.GuidDeclarationsDocument
;
34 import org
.tianocore
.GuidsDocument
;
35 import org
.tianocore
.LibrariesDocument
;
36 import org
.tianocore
.LibraryClassDeclarationsDocument
;
37 import org
.tianocore
.LibraryClassDocument
;
38 import org
.tianocore
.ModuleDefinitionsDocument
;
39 import org
.tianocore
.ModuleSADocument
;
40 import org
.tianocore
.ModuleSaBuildOptionsDocument
;
41 import org
.tianocore
.ModuleTypeDef
;
42 import org
.tianocore
.MsaFilesDocument
;
43 import org
.tianocore
.MsaHeaderDocument
;
44 import org
.tianocore
.OptionDocument
;
45 import org
.tianocore
.PPIsDocument
;
46 import org
.tianocore
.PackageDependenciesDocument
;
47 import org
.tianocore
.PackageHeadersDocument
;
48 import org
.tianocore
.PcdCodedDocument
;
49 import org
.tianocore
.PlatformDefinitionsDocument
;
50 import org
.tianocore
.PlatformHeaderDocument
;
51 import org
.tianocore
.PpiDeclarationsDocument
;
52 import org
.tianocore
.ProtocolDeclarationsDocument
;
53 import org
.tianocore
.Sentence
;
54 import org
.tianocore
.SpdHeaderDocument
;
55 import org
.tianocore
.UserExtensionsDocument
;
56 import org
.tianocore
.FilenameDocument
.Filename
;
57 import org
.tianocore
.MsaHeaderDocument
.MsaHeader
;
58 import org
.tianocore
.ProtocolsDocument
.Protocols
.Protocol
;
59 import org
.tianocore
.ProtocolsDocument
.Protocols
.ProtocolNotify
;
60 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
61 import org
.tianocore
.build
.id
.ModuleIdentification
;
62 import org
.tianocore
.build
.id
.PackageIdentification
;
63 import org
.tianocore
.build
.id
.PlatformIdentification
;
64 import org
.tianocore
.build
.toolchain
.ToolChainInfo
;
65 import org
.tianocore
.logger
.EdkLog
;
66 import org
.w3c
.dom
.Node
;
69 * SurfaceAreaQuery class is used to query Surface Area information from msa,
70 * mbd, spd and fpd files.
72 * This class should not instantiated. All the public interfaces is static.
76 public class SurfaceAreaQuery
{
78 public static String prefix
= "http://www.TianoCore.org/2006/Edk2.0";
81 // / Contains name/value pairs of Surface Area document object. The name is
82 // / always the top level element name.
84 private static Map
<String
, XmlObject
> map
= null;
87 // / mapStack is used to do nested query
89 private static Stack
<Map
<String
, XmlObject
>> mapStack
= new Stack
<Map
<String
, XmlObject
>>();
92 // / prefix of name space
94 private static String nsPrefix
= "sans";
97 // / xmlbeans needs a name space for each Xpath element
99 private static String ns
= null;
102 // / keep the namep declaration for xmlbeans Xpath query
104 private static String queryDeclaration
= null;
107 * Set a Surface Area document for query later
110 * A Surface Area document in TopLevelElementName/XmlObject
113 public static void setDoc(Map
<String
, XmlObject
> map
) {
115 queryDeclaration
= "declare namespace " + nsPrefix
+ "='" + ns
+ "'; ";
116 SurfaceAreaQuery
.map
= map
;
120 * Push current used Surface Area document into query stack. The given new
121 * document will be used for any immediately followed getXXX() callings,
122 * untill pop() is called.
125 * The TopLevelElementName/XmlObject format of a Surface Area
128 public static void push(Map
<String
, XmlObject
> newMap
) {
129 mapStack
.push(SurfaceAreaQuery
.map
);
130 SurfaceAreaQuery
.map
= newMap
;
134 * Discard current used Surface Area document and use the top document in
137 public static void pop() {
138 SurfaceAreaQuery
.map
= mapStack
.pop();
142 // / Convert xPath to be namespace qualified, which is necessary for
144 // / selectPath(). For example, converting /MsaHeader/ModuleType to
145 // / /ns:MsaHeader/ns:ModuleType
147 private static String
normalizeQueryString(String
[] exp
, String from
) {
148 StringBuffer normQueryString
= new StringBuffer(4096);
151 while (i
< exp
.length
) {
152 String newExp
= from
+ exp
[i
];
153 Pattern pattern
= Pattern
.compile("([^/]*)(/|//)([^/]+)");
154 Matcher matcher
= pattern
.matcher(newExp
);
156 while (matcher
.find()) {
157 String starter
= newExp
.substring(matcher
.start(1), matcher
159 String seperator
= newExp
.substring(matcher
.start(2), matcher
161 String token
= newExp
.substring(matcher
.start(3), matcher
164 normQueryString
.append(starter
);
165 normQueryString
.append(seperator
);
166 normQueryString
.append(nsPrefix
);
167 normQueryString
.append(":");
168 normQueryString
.append(token
);
172 if (i
< exp
.length
) {
173 normQueryString
.append(" | ");
177 return normQueryString
.toString();
181 * Search all XML documents stored in "map" for the specified xPath, using
182 * relative path (starting with '$this')
185 * xpath query string array
186 * @returns An array of XmlObject if elements are found at the specified
188 * @returns NULL if nothing is at the specified xpath
190 public static Object
[] get(String
[] xPath
) {
195 String
[] keys
= (String
[]) map
.keySet().toArray(new String
[map
.size()]);
196 List
<Object
> result
= new ArrayList
<Object
>();
197 for (int i
= 0; i
< keys
.length
; ++i
) {
198 XmlObject rootNode
= (XmlObject
) map
.get(keys
[i
]);
199 if (rootNode
== null) {
203 String query
= queryDeclaration
204 + normalizeQueryString(xPath
, "$this/" + keys
[i
]);
205 XmlObject
[] tmp
= rootNode
.selectPath(query
);
206 for (int j
= 0; j
< tmp
.length
; ++j
) {
207 result
.add((Object
)tmp
[j
]);
211 int size
= result
.size();
216 return (Object
[]) result
.toArray(new Object
[size
]);
220 * Search XML documents named by "rootName" for the given xPath, using
221 * relative path (starting with '$this')
224 * The top level element name
226 * The xpath query string array
227 * @returns An array of XmlObject if elements are found at the given xpath
228 * @returns NULL if nothing is found at the given xpath
230 public static Object
[] get(String rootName
, String
[] xPath
) {
235 XmlObject root
= (XmlObject
) map
.get(rootName
);
240 String query
= queryDeclaration
241 + normalizeQueryString(xPath
, "$this/" + rootName
);
242 XmlObject
[] result
= root
.selectPath(query
);
243 if (result
.length
> 0) {
244 return (Object
[])result
;
247 query
= queryDeclaration
+ normalizeQueryString(xPath
, "/" + rootName
);
248 result
= root
.selectPath(query
);
249 if (result
.length
> 0) {
250 return (Object
[])result
;
257 * Retrieve SourceFiles/Filename for specified ARCH type
261 * @returns An 2 dimension string array if elements are found at the known
263 * @returns NULL if nothing is found at the known xpath
265 public static String
[][] getSourceFiles(String arch
) {
269 xPath
= new String
[] { "/Filename" };
271 returns
= get("SourceFiles", xPath
);
273 if (returns
== null || returns
.length
== 0) {
274 return new String
[0][0];
277 Filename
[] sourceFileNames
= (Filename
[]) returns
;
278 List
<String
[]> outputList
= new ArrayList
<String
[]>();
279 for (int i
= 0; i
< sourceFileNames
.length
; i
++) {
280 @SuppressWarnings("unchecked")
281 List
<String
> archList
= sourceFileNames
[i
].getSupArchList();
282 if (arch
== null || arch
.equalsIgnoreCase("") || archList
== null || archList
.contains(arch
)) {
283 outputList
.add(new String
[] {sourceFileNames
[i
].getToolCode(),sourceFileNames
[i
].getStringValue()});
287 String
[][] outputString
= new String
[outputList
.size()][2];
288 for (int index
= 0; index
< outputList
.size(); index
++) {
289 outputString
[index
][0] = outputList
.get(index
)[0];
290 outputString
[index
][1] = outputList
.get(index
)[1];
296 * Retrieve /PlatformDefinitions/OutputDirectory from FPD
298 * @returns Directory names array if elements are found at the known xpath
299 * @returns Empty if nothing is found at the known xpath
301 public static String
getFpdOutputDirectory() {
302 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
304 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
305 if (returns
== null || returns
.length
== 0) {
308 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
309 return item
.getOutputDirectory();
312 public static String
getFpdIntermediateDirectories() {
313 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
315 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
316 if (returns
== null || returns
.length
== 0) {
319 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
320 if(item
.getIntermediateDirectories() == null) {
324 return item
.getIntermediateDirectories().toString();
328 public static String
getModuleFfsKeyword() {
329 String
[] xPath
= new String
[] { "/" };
331 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
332 if (returns
== null || returns
.length
== 0) {
335 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
336 return item
.getFfsFormatKey();
339 public static String
getModuleFvBindingKeyword() {
340 String
[] xPath
= new String
[] { "/" };
342 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
343 if (returns
== null || returns
.length
== 0) {
346 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
347 return item
.getFvBinding();
350 public static List
getModuleSupportedArchs() {
351 String
[] xPath
= new String
[] { "/" };
353 Object
[] returns
= get("ModuleDefinitions", xPath
);
354 if (returns
== null || returns
.length
== 0) {
357 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
358 return item
.getSupportedArchitectures();
361 public static BuildOptionsDocument
.BuildOptions
.Ffs
[] getFpdFfs() {
362 String
[] xPath
= new String
[] {"/Ffs"};
364 Object
[] returns
= get("BuildOptions", xPath
);
365 if (returns
== null || returns
.length
== 0) {
366 return new BuildOptionsDocument
.BuildOptions
.Ffs
[0];
368 return (BuildOptionsDocument
.BuildOptions
.Ffs
[])returns
;
371 public static String
getModuleOutputFileBasename() {
372 String
[] xPath
= new String
[] { "/" };
374 Object
[] returns
= get("ModuleDefinitions", xPath
);
375 if (returns
== null || returns
.length
== 0) {
378 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
379 return item
.getOutputFileBasename();
383 * Retrieve BuildOptions/Option or Arch/Option
385 * @param toolChainFamilyFlag
386 * if true, retrieve options for toolchain family; otherwise for
389 * @returns String[][5] name, target, toolchain, arch, coommand of options
390 * if elements are found at the known xpath. String[0][] if dont
393 * @returns Empty array if nothing is there
395 public static String
[][] getOptions(String from
, String
[] xPath
, boolean toolChainFamilyFlag
) {
396 String target
= null;
397 String toolchain
= null;
398 String toolchainFamily
= null;
399 List
<String
> archList
= null;
401 String targetName
= null;
402 String optionName
= null;
404 Object
[] returns
= get(from
, xPath
);
405 if (returns
== null) {
406 return new String
[0][5];
409 List
<String
[]> optionList
= new ArrayList
<String
[]>();
410 OptionDocument
.Option option
;
412 for (int i
= 0; i
< returns
.length
; i
++) {
413 option
= (OptionDocument
.Option
) returns
[i
];
416 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
418 // put to result[][5] array in above order.
421 if (option
.getBuildTargets() == null) {
425 target
= option
.getBuildTargets().toString();
427 if (target
!= null) {
428 targetList
= target
.split(" ");
430 targetList
= new String
[1];
431 targetList
[0] = null;
434 if (toolChainFamilyFlag
) {
435 toolchainFamily
= option
.getToolChainFamily();
436 if (toolchainFamily
!= null) {
437 toolchain
= toolchainFamily
.toString();
442 toolchain
= option
.getTagName();
445 archList
= new ArrayList
<String
>();
446 @SuppressWarnings("unchecked")
447 List
<String
> archEnumList
= option
.getSupArchList();
448 if (archEnumList
== null) {
451 archList
.addAll(archEnumList
);
453 Iterator it = archEnumList.iterator();
454 while (it.hasNext()) {
455 System.out.println(it.next().getClass().getName());
456 SupportedArchitectures.Enum archType = it.next();
457 archList.add(archType.toString());
462 cmd
= option
.getToolCode();
464 optionName
= option
.getStringValue();
465 for (int t
= 0; t
< targetList
.length
; t
++) {
466 for (int j
= 0; j
< archList
.size(); j
++) {
467 optionList
.add(new String
[] { targetList
[t
],
468 toolchain
, archList
.get(j
), cmd
, optionName
});
473 String
[][] result
= new String
[optionList
.size()][5];
474 for (int i
= 0; i
< optionList
.size(); i
++) {
475 result
[i
][0] = optionList
.get(i
)[0];
476 result
[i
][1] = optionList
.get(i
)[1];
477 result
[i
][2] = optionList
.get(i
)[2];
478 result
[i
][3] = optionList
.get(i
)[3];
479 result
[i
][4] = optionList
.get(i
)[4];
484 public static String
[][] getModuleBuildOptions(boolean toolChainFamilyFlag
) {
487 if (toolChainFamilyFlag
== true) {
488 xPath
= new String
[] {
489 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
490 "/Options/Option[@ToolChainFamily]", };
492 xPath
= new String
[] {
493 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
494 "/Options/Option[@TagName]", };
496 return getOptions("ModuleSaBuildOptions", xPath
, toolChainFamilyFlag
);
499 public static String
[][] getPlatformBuildOptions(boolean toolChainFamilyFlag
) {
502 if (toolChainFamilyFlag
== true) {
503 xPath
= new String
[] {
504 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
505 "/BuildOptions/Options/Option[@ToolChainFamily]", };
507 xPath
= new String
[] {
508 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
509 "/BuildOptions/Options/Option[@TagName]", };
512 return getOptions("PlatformSurfaceArea", xPath
, toolChainFamilyFlag
);
515 public static ToolChainInfo
getFpdToolChainInfo() {
516 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
518 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
519 if (returns
== null || returns
.length
== 0) {
523 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
524 ToolChainInfo toolChainInfo
= new ToolChainInfo();
525 toolChainInfo
.addTargets(item
.getBuildTargets().toString());
526 toolChainInfo
.addArchs(item
.getSupportedArchitectures().toString());
527 toolChainInfo
.addTagnames((String
)null);
528 return toolChainInfo
;
532 * Retrieve <xxxHeader>/ModuleType
534 * @returns The module type name if elements are found at the known xpath
535 * @returns null if nothing is there
537 public static String
getModuleType() {
538 String
[] xPath
= new String
[] { "/ModuleType" };
540 Object
[] returns
= get(xPath
);
541 if (returns
!= null && returns
.length
> 0) {
542 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
543 return type
.enumValue().toString();
550 * Retrieve PackageDependencies/Package
555 * @returns package name list if elements are found at the known xpath
556 * @returns null if nothing is there
558 public static PackageIdentification
[] getDependencePkg(String arch
) {
560 String packageGuid
= null;
561 String packageVersion
= null;
564 xPath
= new String
[] { "/Package" };
566 Object
[] returns
= get("PackageDependencies", xPath
);
567 if (returns
== null) {
568 return new PackageIdentification
[0];
570 PackageIdentification
[] packageIdList
= new PackageIdentification
[returns
.length
];
571 for (int i
= 0; i
< returns
.length
; i
++) {
572 PackageDependenciesDocument
.PackageDependencies
.Package item
= (PackageDependenciesDocument
.PackageDependencies
.Package
) returns
[i
];
573 @SuppressWarnings("unchecked")
574 List
<String
> archList
= item
.getSupArchList();
575 if (arch
== null || archList
== null || archList
.contains(arch
)) {
576 packageGuid
= item
.getPackageGuid();
577 packageVersion
= item
.getPackageVersion();
578 packageIdList
[i
] = (new PackageIdentification(null, packageGuid
,
582 return packageIdList
;
586 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
589 * Library class usage
591 * @returns LibraryClass objects list if elements are found at the known
593 * @returns null if nothing is there
595 public static String
[] getLibraryClasses(String usage
) {
598 if (usage
== null || usage
.equals("")) {
599 xPath
= new String
[] { "/LibraryClass" };
601 xPath
= new String
[] { "/LibraryClass[@Usage='" + usage
+ "']" };
604 Object
[] returns
= get("LibraryClassDefinitions", xPath
);
605 if (returns
== null || returns
.length
== 0) {
606 return new String
[0];
609 LibraryClassDocument
.LibraryClass
[] libraryClassList
= (LibraryClassDocument
.LibraryClass
[]) returns
;
610 String
[] libraryClassName
= new String
[libraryClassList
.length
];
611 for (int i
= 0; i
< libraryClassList
.length
; i
++) {
612 libraryClassName
[i
] = libraryClassList
[i
].getKeyword();
614 return libraryClassName
;
618 * Retrieve ModuleEntryPoint names
620 * @returns ModuleEntryPoint name list if elements are found at the known
622 * @returns null if nothing is there
624 public static String
[] getModuleEntryPointArray() {
625 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
627 Object
[] returns
= get("Externs", xPath
);
629 if (returns
!= null && returns
.length
> 0) {
630 String
[] entryPoints
= new String
[returns
.length
];
632 for (int i
= 0; i
< returns
.length
; ++i
) {
633 entryPoints
[i
] = ((CNameType
) returns
[i
]).getStringValue();
643 * retrieve Protocol for specified usage
646 * Protocol usage arch Architecture
648 * @returns Protocol String list if elements are found at the known xpath
649 * @returns String[0] if nothing is there
651 public static String
[] getProtocolArray(String arch
, String usage
) {
653 String usageXpath
= "";
654 String archXpath
= "";
656 if (arch
== null || arch
.equals("")) {
657 return new String
[0];
659 archXpath
= "/Protocol";
660 if (usage
!= null && !usage
.equals("")) {
661 usageXpath
= "/Protocol[@Usage='" + usage
+ "']";
662 xPath
= new String
[] { usageXpath
, archXpath
};
664 return getProtocolArray(arch
);
669 Object
[] returns
= get("Protocols", xPath
);
670 if (returns
== null) {
671 return new String
[0];
673 Protocol
[] protocolList
= (Protocol
[]) returns
;
675 String
[] protocolArray
= new String
[returns
.length
];
676 for (int i
= 0; i
< returns
.length
; i
++) {
677 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
679 return protocolArray
;
683 * retrieve Protocol for specified usage
688 * @returns Protocol String list if elements are found at the known xpath
689 * @returns String[0] if nothing is there
691 public static String
[] getProtocolArray(String arch
) {
694 if (arch
== null || arch
.equals("")) {
695 return new String
[0];
697 xPath
= new String
[] { "/Protocol" };
700 Object
[] returns
= get("Protocols", xPath
);
701 if (returns
== null) {
702 return new String
[0];
704 Protocol
[] returnlList
= (Protocol
[]) returns
;
706 List
<String
> protocolList
= new ArrayList
<String
>();
708 for (int i
= 0; i
< returns
.length
; i
++) {
709 @SuppressWarnings("unchecked")
710 List
<String
> archList
= returnlList
[i
].getSupArchList();
711 if (archList
== null || archList
.contains(arch
)){
712 protocolList
.add(returnlList
[i
].getProtocolCName());
715 String
[] protocolArray
= new String
[protocolList
.size()];
716 for (int i
= 0; i
< protocolList
.size(); i
++) {
717 protocolArray
[i
] = protocolList
.get(i
);
719 return protocolArray
;
723 * Retrieve ProtocolNotify for specified usage
726 * ProtocolNotify usage
728 * @returns String[] if elements are found at the known xpath
729 * @returns String[0] if nothing is there
731 public static String
[] getProtocolNotifyArray(String arch
) {
734 if (arch
== null || arch
.equals("")) {
735 return new String
[0];
737 xPath
= new String
[] { "/ProtocolNotify" };
740 Object
[] returns
= get("Protocols", xPath
);
741 if (returns
== null) {
742 return new String
[0];
745 List
<String
> protocolNotifyList
= new ArrayList
<String
>();
747 for (int i
= 0; i
< returns
.length
; i
++) {
748 @SuppressWarnings("unchecked")
749 List
<String
> archList
= ((ProtocolNotify
) returns
[i
]).getSupArchList();
750 if (archList
== null || archList
.contains(arch
)){
751 protocolNotifyList
.add(((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName());
755 String
[] protocolNotifyArray
= new String
[protocolNotifyList
.size()];
756 for (int i
= 0; i
< protocolNotifyList
.size(); i
++) {
757 protocolNotifyArray
[i
] = protocolNotifyList
.get(i
);
759 return protocolNotifyArray
;
763 * Retrieve ProtocolNotify for specified usage
766 * ProtocolNotify usage
768 * @returns String[] if elements are found at the known xpath
769 * @returns String[0] if nothing is there
771 public static String
[] getProtocolNotifyArray(String arch
, String usage
) {
777 if (arch
== null || arch
.equals("")) {
778 return new String
[0];
780 archXpath
= "/ProtocolNotify";
781 if (usage
!= null && !usage
.equals("")) {
782 usageXpath
= "/ProtocolNotify[@Usage='" + arch
+ "']";
783 xPath
= new String
[] { archXpath
, usageXpath
};
785 return getProtocolNotifyArray(arch
);
789 Object
[] returns
= get("Protocols", xPath
);
790 if (returns
== null) {
791 return new String
[0];
794 String
[] protocolNotifyList
= new String
[returns
.length
];
796 for (int i
= 0; i
< returns
.length
; i
++) {
797 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
799 return protocolNotifyList
;
803 * Retrieve ModuleUnloadImage names
805 * @returns ModuleUnloadImage name list if elements are found at the known
807 * @returns null if nothing is there
809 public static String
[] getModuleUnloadImageArray() {
810 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
812 Object
[] returns
= get("Externs", xPath
);
813 if (returns
!= null && returns
.length
> 0) {
814 String
[] stringArray
= new String
[returns
.length
];
815 CNameType
[] doc
= (CNameType
[]) returns
;
817 for (int i
= 0; i
< returns
.length
; ++i
) {
818 stringArray
[i
] = doc
[i
].getStringValue();
830 * @returns Extern objects list if elements are found at the known xpath
831 * @returns null if nothing is there
833 public static ExternsDocument
.Externs
.Extern
[] getExternArray() {
834 String
[] xPath
= new String
[] { "/Extern" };
836 Object
[] returns
= get("Externs", xPath
);
837 if (returns
!= null && returns
.length
> 0) {
838 return (ExternsDocument
.Externs
.Extern
[]) returns
;
845 * Retrieve PpiNotify for specified arch
850 * @returns String[] if elements are found at the known xpath
851 * @returns String[0] if nothing is there
853 public static String
[] getPpiNotifyArray(String arch
) {
856 if (arch
== null || arch
.equals("")) {
857 return new String
[0];
859 xPath
= new String
[] { "/PpiNotify" };
862 Object
[] returns
= get("PPIs", xPath
);
863 if (returns
== null) {
864 return new String
[0];
868 List
<String
> ppiNotifyList
= new ArrayList
<String
>();
869 for (int i
= 0; i
< returns
.length
; i
++) {
870 @SuppressWarnings("unchecked")
871 List
<String
> archList
= ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getSupArchList();
872 if (archList
== null || archList
.contains(arch
)){
873 ppiNotifyList
.add(((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName());
877 String
[] ppiNotifyArray
= new String
[ppiNotifyList
.size()];
878 for (int i
= 0; i
< ppiNotifyList
.size(); i
++) {
879 ppiNotifyArray
[i
] = ppiNotifyList
.get(i
);
882 return ppiNotifyArray
;
886 * Retrieve PpiNotify for specified usage and arch
889 * PpiNotify arch usage PpiNotify usage
892 * @returns String[] if elements are found at the known xpath
893 * @returns String[0] if nothing is there
895 public static String
[] getPpiNotifyArray(String arch
, String usage
) {
901 if (arch
== null || arch
.equals("")) {
902 return new String
[0];
904 archXpath
= "/PpiNotify";
905 if (usage
!= null && !usage
.equals("")) {
906 usageXpath
= "/PpiNotify[@Usage='" + arch
+ "']";
907 xPath
= new String
[] { archXpath
, usageXpath
};
909 return getProtocolNotifyArray(arch
);
913 Object
[] returns
= get("PPIs", xPath
);
914 if (returns
== null) {
915 return new String
[0];
918 String
[] ppiNotifyList
= new String
[returns
.length
];
920 for (int i
= 0; i
< returns
.length
; i
++) {
921 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
923 return ppiNotifyList
;
927 * Retrieve Ppi for specified arch
932 * @returns String[] if elements are found at the known xpath
933 * @returns String[0] if nothing is there
935 public static String
[] getPpiArray(String arch
) {
938 if (arch
== null || arch
.equals("")) {
939 return new String
[0];
941 xPath
= new String
[] { "/Ppi" };
944 Object
[] returns
= get("PPIs", xPath
);
945 if (returns
== null) {
946 return new String
[0];
949 List
<String
> ppiList
= new ArrayList
<String
>();
950 for (int i
= 0; i
< returns
.length
; i
++) {
951 @SuppressWarnings("unchecked")
952 List
<String
> archList
= ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getSupArchList();
953 if (archList
== null || archList
.contains(arch
)){
954 ppiList
.add(((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName());
958 String
[] ppiArray
= new String
[ppiList
.size()];
959 for (int i
= 0; i
< ppiList
.size(); i
++) {
960 ppiArray
[i
] = ppiList
.get(i
);
966 * Retrieve PpiNotify for specified usage and arch
969 * PpiNotify arch usage PpiNotify usage
972 * @returns String[] if elements are found at the known xpath
973 * @returns String[0] if nothing is there
975 public static String
[] getPpiArray(String arch
, String usage
) {
981 if (arch
== null || arch
.equals("")) {
982 return new String
[0];
985 if (usage
!= null && !usage
.equals("")) {
986 usageXpath
= "/Ppi[@Usage='" + arch
+ "']";
987 xPath
= new String
[] { archXpath
, usageXpath
};
989 return getProtocolNotifyArray(arch
);
993 Object
[] returns
= get("PPIs", xPath
);
994 if (returns
== null) {
995 return new String
[0];
998 String
[] ppiList
= new String
[returns
.length
];
1000 for (int i
= 0; i
< returns
.length
; i
++) {
1001 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
1007 * Retrieve GuidEntry information for specified usage
1012 * @returns GuidEntry objects list if elements are found at the known xpath
1013 * @returns null if nothing is there
1015 public static String
[] getGuidEntryArray(String arch
) {
1018 if (arch
== null || arch
.equals("")) {
1019 xPath
= new String
[] { "/GuidCNames" };
1021 xPath
= new String
[] { "/GuidCNames" };
1024 Object
[] returns
= get("Guids", xPath
);
1025 if (returns
== null) {
1026 return new String
[0];
1029 List
<String
> guidList
= new ArrayList
<String
>();
1030 for (int i
= 0; i
< returns
.length
; i
++) {
1031 @SuppressWarnings("unchecked")
1032 List
<String
> archList
= ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getSupArchList();
1033 if (archList
== null || archList
.contains(arch
)){
1034 guidList
.add(((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName());
1038 String
[] guidArray
= new String
[guidList
.size()];
1039 for (int i
= 0; i
< guidList
.size(); i
++) {
1040 guidArray
[i
] = guidList
.get(i
);
1047 * Retrieve GuidEntry information for specified usage
1050 * GuidEntry arch usage GuidEntry usage
1052 * @returns GuidEntry objects list if elements are found at the known xpath
1053 * @returns null if nothing is there
1055 public static String
[] getGuidEntryArray(String arch
, String usage
) {
1060 if (arch
== null || arch
.equals("")) {
1061 return new String
[0];
1063 archXpath
= "/GuidEntry";
1064 if (usage
!= null && !usage
.equals("")) {
1065 usageXpath
= "/GuidEntry[@Usage='" + arch
+ "']";
1066 xPath
= new String
[] { archXpath
, usageXpath
};
1068 return getProtocolNotifyArray(arch
);
1072 Object
[] returns
= get("Guids", xPath
);
1073 if (returns
== null) {
1074 return new String
[0];
1077 String
[] guidList
= new String
[returns
.length
];
1079 for (int i
= 0; i
< returns
.length
; i
++) {
1080 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1086 * Retrieve Library instance information
1091 * Library instance usage
1093 * @returns library instance name list if elements are found at the known
1095 * @returns null if nothing is there
1097 public static ModuleIdentification
[] getLibraryInstance(String arch
) {
1099 String saGuid
= null;
1100 String saVersion
= null;
1101 String pkgGuid
= null;
1102 String pkgVersion
= null;
1104 if (arch
== null || arch
.equalsIgnoreCase("")) {
1105 xPath
= new String
[] { "/Instance" };
1108 // Since Schema don't have SupArchList now, so the follow Xpath is
1109 // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]
1110 // don't have effect.
1112 xPath
= new String
[] { "/Instance[not(@SupArchList) or @SupArchList='"
1116 Object
[] returns
= get("Libraries", xPath
);
1117 if (returns
== null || returns
.length
== 0) {
1118 return new ModuleIdentification
[0];
1121 ModuleIdentification
[] saIdList
= new ModuleIdentification
[returns
.length
];
1122 for (int i
= 0; i
< returns
.length
; i
++) {
1123 LibrariesDocument
.Libraries
.Instance library
= (LibrariesDocument
.Libraries
.Instance
) returns
[i
];
1124 saGuid
= library
.getModuleGuid();
1125 saVersion
= library
.getModuleVersion();
1127 pkgGuid
= library
.getPackageGuid();
1128 pkgVersion
= library
.getPackageVersion();
1130 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1132 PackageIdentification pkgId
= new PackageIdentification(null,
1133 pkgGuid
, pkgVersion
);
1134 saId
.setPackage(pkgId
);
1143 // / This method is used for retrieving the elements information which has
1144 // / CName sub-element
1146 private static String
[] getCNames(String from
, String xPath
[]) {
1147 Object
[] returns
= get(from
, xPath
);
1148 if (returns
== null || returns
.length
== 0) {
1152 String
[] strings
= new String
[returns
.length
];
1153 for (int i
= 0; i
< returns
.length
; ++i
) {
1155 strings
[i
] = ((CNameType
) returns
[i
]).getStringValue();
1162 * Retrive library's constructor name
1164 * @returns constructor name list if elements are found at the known xpath
1165 * @returns null if nothing is there
1167 public static String
getLibConstructorName() {
1168 String
[] xPath
= new String
[] { "/Extern/Constructor" };
1170 Object
[] returns
= get("Externs", xPath
);
1171 if (returns
!= null && returns
.length
> 0) {
1172 CNameType constructor
= ((CNameType
) returns
[0]);
1173 return constructor
.getStringValue();
1180 * Retrive library's destructor name
1182 * @returns destructor name list if elements are found at the known xpath
1183 * @returns null if nothing is there
1185 public static String
getLibDestructorName() {
1186 String
[] xPath
= new String
[] { "/Extern/Destructor" };
1188 Object
[] returns
= get("Externs", xPath
);
1189 if (returns
!= null && returns
.length
> 0) {
1191 // Only support one Destructor function.
1193 CNameType destructor
= (CNameType
) returns
[0];
1194 return destructor
.getStringValue();
1201 * Retrive DriverBinding names
1203 * @returns DriverBinding name list if elements are found at the known xpath
1204 * @returns null if nothing is there
1206 public static String
[] getDriverBindingArray() {
1207 String
[] xPath
= new String
[] { "/Extern/DriverBinding" };
1208 return getCNames("Externs", xPath
);
1212 * Retrive ComponentName names
1214 * @returns ComponentName name list if elements are found at the known xpath
1215 * @returns null if nothing is there
1217 public static String
[] getComponentNameArray() {
1218 String
[] xPath
= new String
[] { "/Extern/ComponentName" };
1219 return getCNames("Externs", xPath
);
1223 * Retrive DriverConfig names
1225 * @returns DriverConfig name list if elements are found at the known xpath
1226 * @returns null if nothing is there
1228 public static String
[] getDriverConfigArray() {
1229 String
[] xPath
= new String
[] { "/Extern/DriverConfig" };
1230 return getCNames("Externs", xPath
);
1234 * Retrive DriverDiag names
1236 * @returns DriverDiag name list if elements are found at the known xpath
1237 * @returns null if nothing is there
1239 public static String
[] getDriverDiagArray() {
1240 String
[] xPath
= new String
[] { "/Extern/DriverDiag" };
1241 return getCNames("Externs", xPath
);
1245 * Retrive SetVirtualAddressMapCallBack names
1247 * @returns SetVirtualAddressMapCallBack name list if elements are found at
1249 * @returns null if nothing is there
1251 public static String
[] getSetVirtualAddressMapCallBackArray() {
1252 String
[] xPath
= new String
[] { "/Extern/SetVirtualAddressMapCallBack" };
1253 return getCNames("Externs", xPath
);
1257 * Retrive ExitBootServicesCallBack names
1259 * @returns ExitBootServicesCallBack name list if elements are found at the
1261 * @returns null if nothing is there
1263 public static String
[] getExitBootServicesCallBackArray() {
1264 String
[] xPath
= new String
[] { "/Extern/ExitBootServicesCallBack" };
1265 return getCNames("Externs", xPath
);
1269 * Retrieve module surface area file information
1271 * @returns ModuleSA objects list if elements are found at the known xpath
1272 * @returns Empty ModuleSA list if nothing is there
1274 public static Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> getFpdModules() {
1275 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1276 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1278 String fvBinding
= null;
1279 String saGuid
= null;
1280 String saVersion
= null;
1281 String pkgGuid
= null;
1282 String pkgVersion
= null;
1284 Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleMap
= new LinkedHashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
1286 if (result
== null) {
1287 return fpdModuleMap
;
1290 for (int i
= 0; i
< result
.length
; i
++) {
1292 // Get Fpd SA Module element node and add to ObjectMap.
1294 Map
<String
, XmlObject
> ObjectMap
= new HashMap
<String
, XmlObject
>();
1295 ModuleSADocument
.ModuleSA moduleSA
= (ModuleSADocument
.ModuleSA
) result
[i
];
1296 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getLibraries() != null) {
1297 ObjectMap
.put("Libraries", moduleSA
.getLibraries());
1299 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getPcdBuildDefinition() != null) {
1300 ObjectMap
.put("PcdBuildDefinition", moduleSA
1301 .getPcdBuildDefinition());
1303 if (((ModuleSADocument
.ModuleSA
) result
[i
])
1304 .getModuleSaBuildOptions() != null) {
1305 ObjectMap
.put("ModuleSaBuildOptions", moduleSA
1306 .getModuleSaBuildOptions());
1310 // Get Fpd SA Module attribute and create FpdMoudleIdentification.
1312 arch
= moduleSA
.getSupArchList().toString();
1316 saVersion
= ((ModuleSADocument
.ModuleSA
) result
[i
])
1317 .getModuleVersion();
1319 saGuid
= moduleSA
.getModuleGuid();
1320 pkgGuid
= moduleSA
.getPackageGuid();
1321 pkgVersion
= moduleSA
.getPackageVersion();
1324 // Create Module Identification which have class member of package
1327 PackageIdentification pkgId
= new PackageIdentification(null,
1328 pkgGuid
, pkgVersion
);
1329 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1332 saId
.setPackage(pkgId
);
1335 // Create FpdModule Identification which have class member of module
1339 String
[] archList
= arch
.split(" ");
1340 for (int j
= 0; j
< archList
.length
; j
++) {
1341 FpdModuleIdentification fpdSaId
= new FpdModuleIdentification(saId
, archList
[j
]);
1343 if (fvBinding
!= null) {
1344 fpdSaId
.setFvBinding(fvBinding
);
1348 // Put element to Map<FpdModuleIdentification, Map<String,
1351 fpdModuleMap
.put(fpdSaId
, ObjectMap
);
1355 return fpdModuleMap
;
1359 * Retrieve valid image names
1361 * @returns valid iamges name list if elements are found at the known xpath
1362 * @returns empty list if nothing is there
1364 public static String
[] getFpdValidImageNames() {
1365 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
1367 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1368 if (queryResult
== null) {
1369 return new String
[0];
1372 String
[] result
= new String
[queryResult
.length
];
1373 for (int i
= 0; i
< queryResult
.length
; i
++) {
1374 result
[i
] = ((XmlString
) queryResult
[i
]).getStringValue();
1380 public static Node
getFpdUserExtension() {
1381 String
[] xPath
= new String
[] { "/UserExtensions[@UserID='TianoCore']" };
1383 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1384 if (queryResult
== null || queryResult
.length
== 0) {
1387 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)queryResult
[0];
1389 return a
.getDomNode();
1393 * Retrieve FV image option information
1398 * @returns option name/value list if elements are found at the known xpath
1399 * @returns empty list if nothing is there
1401 public static String
[][] getFpdOptions(String fvName
) {
1402 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
1403 + fvName
.toUpperCase() + "']/FvImageOptions" };
1404 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1405 if (queryResult
== null) {
1406 return new String
[0][];
1408 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1409 for (int i
= 0; i
< queryResult
.length
; i
++) {
1410 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1411 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
1412 .getNameValueList();
1413 Iterator iter
= namevalues
.iterator();
1414 while (iter
.hasNext()) {
1415 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1417 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1420 String
[][] result
= new String
[list
.size()][2];
1421 for (int i
= 0; i
< list
.size(); i
++) {
1422 result
[i
][0] = list
.get(i
)[0];
1423 result
[i
][1] = list
.get(i
)[1];
1429 public static XmlObject
getFpdBuildOptions() {
1430 String
[] xPath
= new String
[] { "/BuildOptions" };
1432 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1434 if (queryResult
== null || queryResult
.length
== 0) {
1437 return (XmlObject
)queryResult
[0];
1440 public static PlatformIdentification
getFpdHeader() {
1441 String
[] xPath
= new String
[] { "/PlatformHeader" };
1443 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
1445 if (returns
== null || returns
.length
== 0) {
1448 PlatformHeaderDocument
.PlatformHeader header
= (PlatformHeaderDocument
.PlatformHeader
) returns
[0];
1450 String name
= header
.getPlatformName();
1452 String guid
= header
.getGuidValue();
1454 String version
= header
.getVersion();
1456 return new PlatformIdentification(name
, guid
, version
);
1460 * Retrieve FV image attributes information
1465 * @returns attribute name/value list if elements are found at the known
1467 * @returns empty list if nothing is there
1469 public static String
[][] getFpdAttributes(String fvName
) {
1470 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
1471 + fvName
.toUpperCase() + "']/FvImageOptions" };
1472 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1473 if (queryResult
== null) {
1474 return new String
[0][];
1476 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1477 for (int i
= 0; i
< queryResult
.length
; i
++) {
1479 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1480 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1481 Iterator iter
= namevalues
.iterator();
1482 while (iter
.hasNext()) {
1483 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1485 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1488 String
[][] result
= new String
[list
.size()][2];
1489 for (int i
= 0; i
< list
.size(); i
++) {
1490 result
[i
][0] = list
.get(i
)[0];
1491 result
[i
][1] = list
.get(i
)[1];
1497 * Retrieve flash definition file name
1499 * @returns file name if elements are found at the known xpath
1500 * @returns null if nothing is there
1502 public static String
getFlashDefinitionFile() {
1503 String
[] xPath
= new String
[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
1505 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1506 if (queryResult
== null || queryResult
.length
== 0) {
1510 FileNameConvention filename
= (FileNameConvention
) queryResult
[queryResult
.length
- 1];
1511 return filename
.getStringValue();
1514 public static String
[][] getFpdGlobalVariable() {
1515 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
1516 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1517 if (queryResult
== null) {
1518 return new String
[0][];
1521 String
[][] result
= new String
[queryResult
.length
][2];
1523 for (int i
= 0; i
< queryResult
.length
; i
++) {
1524 FvImagesDocument
.FvImages
.NameValue item
= (FvImagesDocument
.FvImages
.NameValue
)queryResult
[i
];
1525 result
[i
][0] = item
.getName();
1526 result
[i
][1] = item
.getValue();
1532 * Retrieve FV image component options
1537 * @returns name/value pairs list if elements are found at the known xpath
1538 * @returns empty list if nothing is there
1540 public static String
[][] getFpdComponents(String fvName
) {
1541 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName
.toUpperCase() + "']/FvImageOptions" };
1542 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1543 if (queryResult
== null) {
1544 return new String
[0][];
1547 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1548 for (int i
= 0; i
< queryResult
.length
; i
++) {
1549 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1550 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1551 Iterator iter
= namevalues
.iterator();
1552 while (iter
.hasNext()) {
1553 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1555 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1558 String
[][] result
= new String
[list
.size()][2];
1559 for (int i
= 0; i
< list
.size(); i
++) {
1560 result
[i
][0] = list
.get(i
)[0];
1561 result
[i
][1] = list
.get(i
)[1];
1567 * Retrieve PCD tokens
1569 * @returns CName/ItemType pairs list if elements are found at the known
1571 * @returns null if nothing is there
1573 public static String
[][] getPcdTokenArray() {
1574 String
[] xPath
= new String
[] { "/PcdData" };
1576 Object
[] returns
= get("PCDs", xPath
);
1577 if (returns
== null || returns
.length
== 0) {
1581 // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns;
1582 // String[][] result = new String[pcds.length][2];
1583 // for (int i = 0; i < returns.length; ++i) {
1584 // if (pcds[i].getItemType() != null) {
1585 // result[i][1] = pcds[i].getItemType().toString();
1587 // result[i][1] = null;
1589 // result[i][0] = pcds[i].getCName();
1596 * Get the PcdToken array from module's surface area document. The array
1597 * should contains following data:
1599 * -------------------------------------------------------------------
1602 * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText
1605 * -------------------------------------------------------------------
1608 * Note: Until new schema applying, now we can only get CName, ItemType,
1611 * @return 2-array table contains all information of PCD token retrieved
1614 public static Object
[][] etModulePCDTokenArray() {
1617 // Object[][] result;
1618 // PCDs.PcdData[] pcds;
1619 // String[] xPath = new String[] { "/PcdData" };
1620 // Object[] returns = get("PCDs", xPath);
1622 // if ((returns == null) || (returns.length == 0)) {
1626 // pcds = (PCDs.PcdData[]) returns;
1627 // result = new Object[pcds.length][6];
1628 // for (index = 0; index < pcds.length; index++) {
1632 // result[index][0] = pcds[index].getCName();
1634 // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE,
1635 // // DYNAMIC, DYNAMIC_EX
1637 // if (pcds[index].getItemType() != null) {
1638 // result[index][1] = pcds[index].getItemType().toString();
1640 // result[index][1] = null;
1644 // // BUGBUG: following field can *not* be got from current MSA until
1645 // // schema changed.
1647 // // result [index][2] = pcds[index].getTokenSpaceName();
1648 // result[index][2] = null;
1649 // result[index][3] = pcds[index].getDefaultValue();
1650 // // result [index][4] = pcds[index].getUsage ();
1651 // result[index][4] = null;
1652 // // result [index][5] = pcds[index].getHelpText ();
1653 // result[index][5] = null;
1659 * Retrieve MAS header
1664 public static ModuleIdentification
getMsaHeader() {
1665 String
[] xPath
= new String
[] { "/" };
1666 Object
[] returns
= get("MsaHeader", xPath
);
1668 if (returns
== null || returns
.length
== 0) {
1672 MsaHeader msaHeader
= (MsaHeader
) returns
[0];
1674 // Get BaseName, ModuleType, GuidValue, Version
1675 // which in MsaHeader.
1677 String name
= msaHeader
.getModuleName();
1678 String moduleType
= msaHeader
.getModuleType().toString();
1679 String guid
= msaHeader
.getGuidValue();
1680 String version
= msaHeader
.getVersion();
1682 ModuleIdentification moduleId
= new ModuleIdentification(name
, guid
,
1685 moduleId
.setModuleType(moduleType
);
1691 * Retrieve Extern Specification
1695 * @return String[] If have specification element in the <extern> String[0]
1696 * If no specification element in the <extern>
1700 public static String
[] getExternSpecificaiton() {
1701 String
[] xPath
= new String
[] { "/Specification" };
1703 Object
[] queryResult
= get("Externs", xPath
);
1704 if (queryResult
== null) {
1705 return new String
[0];
1708 String
[] specificationList
= new String
[queryResult
.length
];
1709 for (int i
= 0; i
< queryResult
.length
; i
++) {
1710 specificationList
[i
] = ((Sentence
)queryResult
[i
])
1713 return specificationList
;
1717 * Retreive MsaFile which in SPD
1720 * @return String[][3] The string sequence is ModuleName, ModuleGuid,
1721 * ModuleVersion, MsaFile String[0][] If no msafile in SPD
1723 public static String
[] getSpdMsaFile() {
1724 String
[] xPath
= new String
[] { "/MsaFiles" };
1726 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1727 if (returns
== null) {
1728 return new String
[0];
1731 List
<String
> filenameList
= ((MsaFilesDocument
.MsaFiles
) returns
[0])
1733 return filenameList
.toArray(new String
[filenameList
.size()]);
1739 public static Map
<String
, String
[]> getSpdLibraryClasses() {
1740 String
[] xPath
= new String
[] { "/LibraryClassDeclarations/LibraryClass" };
1742 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1745 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
1747 Map
<String
, String
[]> libClassHeaderMap
= new HashMap
<String
, String
[]>();
1749 if (returns
== null) {
1750 return libClassHeaderMap
;
1753 for (int i
= 0; i
< returns
.length
; i
++) {
1754 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass library
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) returns
[i
];
1755 libClassHeaderMap
.put(library
.getName(), new String
[] { library
1756 .getIncludeHeader() });
1758 return libClassHeaderMap
;
1764 public static Map
<String
, String
> getSpdPackageHeaderFiles() {
1765 String
[] xPath
= new String
[] { "/PackageHeaders/IncludePkgHeader" };
1767 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1770 // Create Map, Key - ModuleType, String - PackageInclude Header file.
1772 Map
<String
, String
> packageIncludeMap
= new HashMap
<String
, String
>();
1774 if (returns
== null) {
1775 return packageIncludeMap
;
1777 // GlobalData.log.info("" + returns[0].getClass().getName());
1778 for (int i
= 0; i
< returns
.length
; i
++) {
1779 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader includeHeader
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) returns
[i
];
1780 packageIncludeMap
.put(includeHeader
.getModuleType().toString(),
1781 includeHeader
.getStringValue());
1783 return packageIncludeMap
;
1786 public static PackageIdentification
getSpdHeader() {
1787 String
[] xPath
= new String
[] { "/SpdHeader" };
1789 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1791 if (returns
== null || returns
.length
== 0) {
1795 SpdHeaderDocument
.SpdHeader header
= (SpdHeaderDocument
.SpdHeader
) returns
[0];
1797 String name
= header
.getPackageName();
1799 String guid
= header
.getGuidValue();
1801 String version
= header
.getVersion();
1803 return new PackageIdentification(name
, guid
, version
);
1809 public static Map
<String
, String
[]> getSpdGuid() {
1810 String
[] xPath
= new String
[] { "/GuidDeclarations/Entry" };
1812 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1815 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
1817 Map
<String
, String
[]> guidDeclMap
= new HashMap
<String
, String
[]>();
1818 if (returns
== null) {
1822 for (int i
= 0; i
< returns
.length
; i
++) {
1823 GuidDeclarationsDocument
.GuidDeclarations
.Entry entry
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) returns
[i
];
1824 String
[] guidPair
= new String
[2];
1825 guidPair
[0] = entry
.getCName();
1826 guidPair
[1] = entry
.getGuidValue();
1827 guidDeclMap
.put(entry
.getName(), guidPair
);
1828 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1829 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[0]);
1830 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[1]);
1838 public static Map
<String
, String
[]> getSpdProtocol() {
1839 String
[] xPath
= new String
[] { "/ProtocolDeclarations/Entry" };
1841 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1844 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1846 Map
<String
, String
[]> protoclMap
= new HashMap
<String
, String
[]>();
1848 if (returns
== null) {
1852 for (int i
= 0; i
< returns
.length
; i
++) {
1853 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry entry
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) returns
[i
];
1854 String
[] protocolPair
= new String
[2];
1856 protocolPair
[0] = entry
.getCName();
1857 protocolPair
[1] = entry
.getGuidValue();
1858 protoclMap
.put(entry
.getName(), protocolPair
);
1859 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1860 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[0]);
1861 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[1]);
1867 * getSpdPpi() Retrieve the SPD PPI Entry
1870 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
1871 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
1874 public static Map
<String
, String
[]> getSpdPpi() {
1875 String
[] xPath
= new String
[] { "/PpiDeclarations/Entry" };
1877 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1880 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1882 Map
<String
, String
[]> ppiMap
= new HashMap
<String
, String
[]>();
1884 if (returns
== null) {
1888 for (int i
= 0; i
< returns
.length
; i
++) {
1889 PpiDeclarationsDocument
.PpiDeclarations
.Entry entry
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) returns
[i
];
1890 String
[] ppiPair
= new String
[2];
1891 ppiPair
[0] = entry
.getCName();
1892 ppiPair
[1] = entry
.getGuidValue();
1893 ppiMap
.put(entry
.getName(), ppiPair
);
1899 * getToolChainFamily
1901 * This function is to retrieve ToolChainFamily attribute of FPD
1905 * @return toolChainFamily If find toolChainFamily attribute in
1906 * <BuildOptions> Null If don't have toolChainFamily in
1909 public String
getToolChainFamily() {
1910 String toolChainFamily
;
1911 String
[] xPath
= new String
[] { "/BuildOptions" };
1913 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1914 if (result
== null) {
1917 // toolChainFamily =
1918 // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies();
1919 // return toolChainFamily;
1924 * Retrieve module Guid string
1926 * @returns GUILD string if elements are found at the known xpath
1927 * @returns null if nothing is there
1929 public static String
getModuleGuid() {
1930 String
[] xPath
= new String
[] { "" };
1932 Object
[] returns
= get("MsaHeader", xPath
);
1933 if (returns
!= null && returns
.length
> 0) {
1934 String guid
= ((MsaHeaderDocument
.MsaHeader
) returns
[0])
1945 public static ModuleSADocument
.ModuleSA
[] getFpdModuleSAs() {
1946 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1947 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1948 if (result
!= null) {
1949 return (ModuleSADocument
.ModuleSA
[]) result
;
1951 return new ModuleSADocument
.ModuleSA
[0];
1955 Get name array of PCD in a module. In one module, token space
1956 is same, and token name should not be conflicted.
1960 public static String
[] getModulePcdEntryNameArray() {
1961 PcdCodedDocument
.PcdCoded
.PcdEntry
[] pcdEntries
= null;
1964 String
[] xPath
= new String
[] {"/PcdEntry"};
1965 Object
[] returns
= get ("PcdCoded", xPath
);
1967 if (returns
== null) {
1968 return new String
[0];
1971 pcdEntries
= (PcdCodedDocument
.PcdCoded
.PcdEntry
[])returns
;
1972 results
= new String
[pcdEntries
.length
];
1974 for (index
= 0; index
< pcdEntries
.length
; index
++) {
1975 results
[index
] = pcdEntries
[index
].getCName();