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 List archList
= sourceFileNames
[i
].getSupArchList();
281 if (arch
== null || arch
.equalsIgnoreCase("") || archList
== null || contains(archList
, arch
)) {
282 outputList
.add(new String
[] {sourceFileNames
[i
].getToolCode(),sourceFileNames
[i
].getStringValue()});
286 String
[][] outputString
= new String
[outputList
.size()][2];
287 for (int index
= 0; index
< outputList
.size(); index
++) {
288 outputString
[index
][0] = outputList
.get(index
)[0];
289 outputString
[index
][1] = outputList
.get(index
)[1];
295 * Retrieve /PlatformDefinitions/OutputDirectory from FPD
297 * @returns Directory names array if elements are found at the known xpath
298 * @returns Empty if nothing is found at the known xpath
300 public static String
getFpdOutputDirectory() {
301 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
303 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
304 if (returns
== null || returns
.length
== 0) {
307 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
308 return item
.getOutputDirectory();
311 public static String
getFpdIntermediateDirectories() {
312 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
314 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
315 if (returns
== null || returns
.length
== 0) {
318 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
319 if(item
.getIntermediateDirectories() == null) {
323 return item
.getIntermediateDirectories().toString();
327 public static String
getModuleFfsKeyword() {
328 String
[] xPath
= new String
[] { "/" };
330 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
331 if (returns
== null || returns
.length
== 0) {
334 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
335 return item
.getFfsFormatKey();
338 public static String
getModuleFvBindingKeyword() {
339 String
[] xPath
= new String
[] { "/" };
341 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
342 if (returns
== null || returns
.length
== 0) {
345 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
346 return item
.getFvBinding();
349 public static List
getModuleSupportedArchs() {
350 String
[] xPath
= new String
[] { "/" };
352 Object
[] returns
= get("ModuleDefinitions", xPath
);
353 if (returns
== null || returns
.length
== 0) {
356 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
357 return item
.getSupportedArchitectures();
360 public static BuildOptionsDocument
.BuildOptions
.Ffs
[] getFpdFfs() {
361 String
[] xPath
= new String
[] {"/Ffs"};
363 Object
[] returns
= get("BuildOptions", xPath
);
364 if (returns
== null || returns
.length
== 0) {
365 return new BuildOptionsDocument
.BuildOptions
.Ffs
[0];
367 return (BuildOptionsDocument
.BuildOptions
.Ffs
[])returns
;
370 public static String
getModuleOutputFileBasename() {
371 String
[] xPath
= new String
[] { "/" };
373 Object
[] returns
= get("ModuleDefinitions", xPath
);
374 if (returns
== null || returns
.length
== 0) {
377 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
378 return item
.getOutputFileBasename();
382 * Retrieve BuildOptions/Option or Arch/Option
384 * @param toolChainFamilyFlag
385 * if true, retrieve options for toolchain family; otherwise for
388 * @returns String[][5] name, target, toolchain, arch, coommand of options
389 * if elements are found at the known xpath. String[0][] if dont
392 * @returns Empty array if nothing is there
394 public static String
[][] getOptions(String from
, String
[] xPath
, boolean toolChainFamilyFlag
) {
395 String target
= null;
396 String toolchain
= null;
397 String toolchainFamily
= null;
398 List
<String
> archList
= null;
400 String targetName
= null;
401 String optionName
= null;
403 Object
[] returns
= get(from
, xPath
);
404 if (returns
== null) {
405 return new String
[0][5];
408 List
<String
[]> optionList
= new ArrayList
<String
[]>();
409 OptionDocument
.Option option
;
411 for (int i
= 0; i
< returns
.length
; i
++) {
412 option
= (OptionDocument
.Option
) returns
[i
];
415 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
417 // put to result[][5] array in above order.
420 if (option
.getBuildTargets() == null) {
424 target
= option
.getBuildTargets().toString();
426 if (target
!= null) {
427 targetList
= target
.split(" ");
429 targetList
= new String
[1];
430 targetList
[0] = null;
433 if (toolChainFamilyFlag
) {
434 toolchainFamily
= option
.getToolChainFamily();
435 if (toolchainFamily
!= null) {
436 toolchain
= toolchainFamily
.toString();
441 toolchain
= option
.getTagName();
444 archList
= new ArrayList
<String
>();
445 List archEnumList
= option
.getSupArchList();
446 if (archEnumList
== null) {
449 //archList.addAll(archEnumList);
450 Iterator it
= archEnumList
.iterator();
451 while (it
.hasNext()) {
452 String archType
= (String
)it
.next();
453 archList
.add(archType
);
457 cmd
= option
.getToolCode();
459 optionName
= option
.getStringValue();
460 for (int t
= 0; t
< targetList
.length
; t
++) {
461 for (int j
= 0; j
< archList
.size(); j
++) {
462 optionList
.add(new String
[] { targetList
[t
],
463 toolchain
, archList
.get(j
), cmd
, optionName
});
468 String
[][] result
= new String
[optionList
.size()][5];
469 for (int i
= 0; i
< optionList
.size(); i
++) {
470 result
[i
][0] = optionList
.get(i
)[0];
471 result
[i
][1] = optionList
.get(i
)[1];
472 result
[i
][2] = optionList
.get(i
)[2];
473 result
[i
][3] = optionList
.get(i
)[3];
474 result
[i
][4] = optionList
.get(i
)[4];
479 public static String
[][] getModuleBuildOptions(boolean toolChainFamilyFlag
) {
482 if (toolChainFamilyFlag
== true) {
483 xPath
= new String
[] {
484 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
485 "/Options/Option[@ToolChainFamily]", };
487 xPath
= new String
[] {
488 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
489 "/Options/Option[@TagName]", };
491 return getOptions("ModuleSaBuildOptions", xPath
, toolChainFamilyFlag
);
494 public static String
[][] getPlatformBuildOptions(boolean toolChainFamilyFlag
) {
497 if (toolChainFamilyFlag
== true) {
498 xPath
= new String
[] {
499 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
500 "/BuildOptions/Options/Option[@ToolChainFamily]", };
502 xPath
= new String
[] {
503 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
504 "/BuildOptions/Options/Option[@TagName]", };
507 return getOptions("PlatformSurfaceArea", xPath
, toolChainFamilyFlag
);
510 public static ToolChainInfo
getFpdToolChainInfo() {
511 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
513 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
514 if (returns
== null || returns
.length
== 0) {
518 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
519 ToolChainInfo toolChainInfo
= new ToolChainInfo();
520 toolChainInfo
.addTargets(item
.getBuildTargets().toString());
521 toolChainInfo
.addArchs(item
.getSupportedArchitectures().toString());
522 toolChainInfo
.addTagnames((String
)null);
523 return toolChainInfo
;
527 * Retrieve <xxxHeader>/ModuleType
529 * @returns The module type name if elements are found at the known xpath
530 * @returns null if nothing is there
532 public static String
getModuleType() {
533 String
[] xPath
= new String
[] { "/ModuleType" };
535 Object
[] returns
= get(xPath
);
536 if (returns
!= null && returns
.length
> 0) {
537 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
538 return type
.enumValue().toString();
545 * Retrieve PackageDependencies/Package
550 * @returns package name list if elements are found at the known xpath
551 * @returns null if nothing is there
553 public static PackageIdentification
[] getDependencePkg(String arch
) {
555 String packageGuid
= null;
556 String packageVersion
= null;
559 xPath
= new String
[] { "/Package" };
561 Object
[] returns
= get("PackageDependencies", xPath
);
562 if (returns
== null) {
563 return new PackageIdentification
[0];
567 // Get packageIdentification
569 List
<PackageIdentification
> packageIdList
= new ArrayList
<PackageIdentification
>();
570 for (int i
= 0; i
< returns
.length
; i
++) {
571 PackageDependenciesDocument
.PackageDependencies
.Package item
= (PackageDependenciesDocument
.PackageDependencies
.Package
) returns
[i
];
572 List archList
= item
.getSupArchList();
573 if (arch
== null || archList
== null || contains(archList
, arch
)) {
574 packageGuid
= item
.getPackageGuid();
575 packageVersion
= item
.getPackageVersion();
576 packageIdList
.add(new PackageIdentification(null, packageGuid
,
582 // transfer packageIdentification list to array.
584 PackageIdentification
[] packageIdArray
= new PackageIdentification
[packageIdList
.size()];
585 for (int i
= 0; i
< packageIdList
.size(); i
++) {
586 packageIdArray
[i
] = new PackageIdentification(null, packageIdList
.get(i
).getGuid(),packageIdList
.get(i
).getVersion());
588 return packageIdArray
;
592 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
595 * Library class usage
597 * @returns LibraryClass objects list if elements are found at the known
599 * @returns null if nothing is there
601 public static String
[] getLibraryClasses(String usage
) {
604 if (usage
== null || usage
.equals("")) {
605 xPath
= new String
[] { "/LibraryClass" };
607 xPath
= new String
[] { "/LibraryClass[@Usage='" + usage
+ "']" };
610 Object
[] returns
= get("LibraryClassDefinitions", xPath
);
611 if (returns
== null || returns
.length
== 0) {
612 return new String
[0];
615 LibraryClassDocument
.LibraryClass
[] libraryClassList
= (LibraryClassDocument
.LibraryClass
[]) returns
;
616 String
[] libraryClassName
= new String
[libraryClassList
.length
];
617 for (int i
= 0; i
< libraryClassList
.length
; i
++) {
618 libraryClassName
[i
] = libraryClassList
[i
].getKeyword();
620 return libraryClassName
;
624 * Retrieve ModuleEntryPoint names
626 * @returns ModuleEntryPoint name list if elements are found at the known
628 * @returns null if nothing is there
630 public static String
[] getModuleEntryPointArray() {
631 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
633 Object
[] returns
= get("Externs", xPath
);
635 if (returns
!= null && returns
.length
> 0) {
636 String
[] entryPoints
= new String
[returns
.length
];
638 for (int i
= 0; i
< returns
.length
; ++i
) {
639 entryPoints
[i
] = ((CNameType
) returns
[i
]).getStringValue();
649 * retrieve Protocol for specified usage
652 * Protocol usage arch Architecture
654 * @returns Protocol String list if elements are found at the known xpath
655 * @returns String[0] if nothing is there
657 public static String
[] getProtocolArray(String arch
, String usage
) {
659 String usageXpath
= "";
660 String archXpath
= "";
662 if (arch
== null || arch
.equals("")) {
663 return new String
[0];
665 archXpath
= "/Protocol";
666 if (usage
!= null && !usage
.equals("")) {
667 usageXpath
= "/Protocol[@Usage='" + usage
+ "']";
668 xPath
= new String
[] { usageXpath
, archXpath
};
670 return getProtocolArray(arch
);
675 Object
[] returns
= get("Protocols", xPath
);
676 if (returns
== null) {
677 return new String
[0];
679 Protocol
[] protocolList
= (Protocol
[]) returns
;
681 String
[] protocolArray
= new String
[returns
.length
];
682 for (int i
= 0; i
< returns
.length
; i
++) {
683 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
685 return protocolArray
;
689 * retrieve Protocol for specified usage
694 * @returns Protocol String list if elements are found at the known xpath
695 * @returns String[0] if nothing is there
697 public static String
[] getProtocolArray(String arch
) {
700 if (arch
== null || arch
.equals("")) {
701 return new String
[0];
703 xPath
= new String
[] { "/Protocol" };
706 Object
[] returns
= get("Protocols", xPath
);
707 if (returns
== null) {
708 return new String
[0];
710 Protocol
[] returnlList
= (Protocol
[]) returns
;
712 List
<String
> protocolList
= new ArrayList
<String
>();
714 for (int i
= 0; i
< returns
.length
; i
++) {
715 List archList
= returnlList
[i
].getSupArchList();
716 if (archList
== null || contains(archList
, arch
)){
717 protocolList
.add(returnlList
[i
].getProtocolCName());
720 String
[] protocolArray
= new String
[protocolList
.size()];
721 for (int i
= 0; i
< protocolList
.size(); i
++) {
722 protocolArray
[i
] = protocolList
.get(i
);
724 return protocolArray
;
728 * Retrieve ProtocolNotify for specified usage
731 * ProtocolNotify usage
733 * @returns String[] if elements are found at the known xpath
734 * @returns String[0] if nothing is there
736 public static String
[] getProtocolNotifyArray(String arch
) {
739 if (arch
== null || arch
.equals("")) {
740 return new String
[0];
742 xPath
= new String
[] { "/ProtocolNotify" };
745 Object
[] returns
= get("Protocols", xPath
);
746 if (returns
== null) {
747 return new String
[0];
750 List
<String
> protocolNotifyList
= new ArrayList
<String
>();
752 for (int i
= 0; i
< returns
.length
; i
++) {
753 List archList
= ((ProtocolNotify
) returns
[i
]).getSupArchList();
754 if (archList
== null || contains(archList
, arch
)){
755 protocolNotifyList
.add(((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName());
759 String
[] protocolNotifyArray
= new String
[protocolNotifyList
.size()];
760 for (int i
= 0; i
< protocolNotifyList
.size(); i
++) {
761 protocolNotifyArray
[i
] = protocolNotifyList
.get(i
);
763 return protocolNotifyArray
;
767 * Retrieve ProtocolNotify for specified usage
770 * ProtocolNotify usage
772 * @returns String[] if elements are found at the known xpath
773 * @returns String[0] if nothing is there
775 public static String
[] getProtocolNotifyArray(String arch
, String usage
) {
781 if (arch
== null || arch
.equals("")) {
782 return new String
[0];
784 archXpath
= "/ProtocolNotify";
785 if (usage
!= null && !usage
.equals("")) {
786 usageXpath
= "/ProtocolNotify[@Usage='" + arch
+ "']";
787 xPath
= new String
[] { archXpath
, usageXpath
};
789 return getProtocolNotifyArray(arch
);
793 Object
[] returns
= get("Protocols", xPath
);
794 if (returns
== null) {
795 return new String
[0];
798 String
[] protocolNotifyList
= new String
[returns
.length
];
800 for (int i
= 0; i
< returns
.length
; i
++) {
801 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
803 return protocolNotifyList
;
807 * Retrieve ModuleUnloadImage names
809 * @returns ModuleUnloadImage name list if elements are found at the known
811 * @returns null if nothing is there
813 public static String
[] getModuleUnloadImageArray() {
814 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
816 Object
[] returns
= get("Externs", xPath
);
817 if (returns
!= null && returns
.length
> 0) {
818 String
[] stringArray
= new String
[returns
.length
];
819 CNameType
[] doc
= (CNameType
[]) returns
;
821 for (int i
= 0; i
< returns
.length
; ++i
) {
822 stringArray
[i
] = doc
[i
].getStringValue();
834 * @returns Extern objects list if elements are found at the known xpath
835 * @returns null if nothing is there
837 public static ExternsDocument
.Externs
.Extern
[] getExternArray() {
838 String
[] xPath
= new String
[] { "/Extern" };
840 Object
[] returns
= get("Externs", xPath
);
841 if (returns
!= null && returns
.length
> 0) {
842 return (ExternsDocument
.Externs
.Extern
[]) returns
;
849 * Retrieve PpiNotify for specified arch
854 * @returns String[] if elements are found at the known xpath
855 * @returns String[0] if nothing is there
857 public static String
[] getPpiNotifyArray(String arch
) {
860 if (arch
== null || arch
.equals("")) {
861 return new String
[0];
863 xPath
= new String
[] { "/PpiNotify" };
866 Object
[] returns
= get("PPIs", xPath
);
867 if (returns
== null) {
868 return new String
[0];
872 List
<String
> ppiNotifyList
= new ArrayList
<String
>();
873 for (int i
= 0; i
< returns
.length
; i
++) {
874 List archList
= ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getSupArchList();
875 if (archList
== null || contains(archList
, arch
)){
876 ppiNotifyList
.add(((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName());
880 String
[] ppiNotifyArray
= new String
[ppiNotifyList
.size()];
881 for (int i
= 0; i
< ppiNotifyList
.size(); i
++) {
882 ppiNotifyArray
[i
] = ppiNotifyList
.get(i
);
885 return ppiNotifyArray
;
889 * Retrieve PpiNotify for specified usage and arch
892 * PpiNotify arch usage PpiNotify usage
895 * @returns String[] if elements are found at the known xpath
896 * @returns String[0] if nothing is there
898 public static String
[] getPpiNotifyArray(String arch
, String usage
) {
904 if (arch
== null || arch
.equals("")) {
905 return new String
[0];
907 archXpath
= "/PpiNotify";
908 if (usage
!= null && !usage
.equals("")) {
909 usageXpath
= "/PpiNotify[@Usage='" + arch
+ "']";
910 xPath
= new String
[] { archXpath
, usageXpath
};
912 return getProtocolNotifyArray(arch
);
916 Object
[] returns
= get("PPIs", xPath
);
917 if (returns
== null) {
918 return new String
[0];
921 String
[] ppiNotifyList
= new String
[returns
.length
];
923 for (int i
= 0; i
< returns
.length
; i
++) {
924 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
926 return ppiNotifyList
;
930 * Retrieve Ppi for specified arch
935 * @returns String[] if elements are found at the known xpath
936 * @returns String[0] if nothing is there
938 public static String
[] getPpiArray(String arch
) {
941 if (arch
== null || arch
.equals("")) {
942 return new String
[0];
944 xPath
= new String
[] { "/Ppi" };
947 Object
[] returns
= get("PPIs", xPath
);
948 if (returns
== null) {
949 return new String
[0];
952 List
<String
> ppiList
= new ArrayList
<String
>();
953 for (int i
= 0; i
< returns
.length
; i
++) {
954 List archList
= ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getSupArchList();
955 if (archList
== null || contains(archList
, arch
)){
956 ppiList
.add(((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName());
960 String
[] ppiArray
= new String
[ppiList
.size()];
961 for (int i
= 0; i
< ppiList
.size(); i
++) {
962 ppiArray
[i
] = ppiList
.get(i
);
968 * Retrieve PpiNotify for specified usage and arch
971 * PpiNotify arch usage PpiNotify usage
974 * @returns String[] if elements are found at the known xpath
975 * @returns String[0] if nothing is there
977 public static String
[] getPpiArray(String arch
, String usage
) {
983 if (arch
== null || arch
.equals("")) {
984 return new String
[0];
987 if (usage
!= null && !usage
.equals("")) {
988 usageXpath
= "/Ppi[@Usage='" + arch
+ "']";
989 xPath
= new String
[] { archXpath
, usageXpath
};
991 return getProtocolNotifyArray(arch
);
995 Object
[] returns
= get("PPIs", xPath
);
996 if (returns
== null) {
997 return new String
[0];
1000 String
[] ppiList
= new String
[returns
.length
];
1002 for (int i
= 0; i
< returns
.length
; i
++) {
1003 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
1009 * Retrieve GuidEntry information for specified usage
1014 * @returns GuidEntry objects list if elements are found at the known xpath
1015 * @returns null if nothing is there
1017 public static String
[] getGuidEntryArray(String arch
) {
1020 if (arch
== null || arch
.equals("")) {
1021 xPath
= new String
[] { "/GuidCNames" };
1023 xPath
= new String
[] { "/GuidCNames" };
1026 Object
[] returns
= get("Guids", xPath
);
1027 if (returns
== null) {
1028 return new String
[0];
1031 List
<String
> guidList
= new ArrayList
<String
>();
1032 for (int i
= 0; i
< returns
.length
; i
++) {
1033 List archList
= ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getSupArchList();
1034 if (archList
== null || contains(archList
, arch
)){
1035 guidList
.add(((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName());
1039 String
[] guidArray
= new String
[guidList
.size()];
1040 for (int i
= 0; i
< guidList
.size(); i
++) {
1041 guidArray
[i
] = guidList
.get(i
);
1048 * Retrieve GuidEntry information for specified usage
1051 * GuidEntry arch usage GuidEntry usage
1053 * @returns GuidEntry objects list if elements are found at the known xpath
1054 * @returns null if nothing is there
1056 public static String
[] getGuidEntryArray(String arch
, String usage
) {
1061 if (arch
== null || arch
.equals("")) {
1062 return new String
[0];
1064 archXpath
= "/GuidEntry";
1065 if (usage
!= null && !usage
.equals("")) {
1066 usageXpath
= "/GuidEntry[@Usage='" + arch
+ "']";
1067 xPath
= new String
[] { archXpath
, usageXpath
};
1069 return getProtocolNotifyArray(arch
);
1073 Object
[] returns
= get("Guids", xPath
);
1074 if (returns
== null) {
1075 return new String
[0];
1078 String
[] guidList
= new String
[returns
.length
];
1080 for (int i
= 0; i
< returns
.length
; i
++) {
1081 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1087 * Retrieve Library instance information
1092 * Library instance usage
1094 * @returns library instance name list if elements are found at the known
1096 * @returns null if nothing is there
1098 public static ModuleIdentification
[] getLibraryInstance(String arch
) {
1100 String saGuid
= null;
1101 String saVersion
= null;
1102 String pkgGuid
= null;
1103 String pkgVersion
= null;
1105 if (arch
== null || arch
.equalsIgnoreCase("")) {
1106 xPath
= new String
[] { "/Instance" };
1109 // Since Schema don't have SupArchList now, so the follow Xpath is
1110 // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]
1111 // don't have effect.
1113 xPath
= new String
[] { "/Instance[not(@SupArchList) or @SupArchList='"
1117 Object
[] returns
= get("Libraries", xPath
);
1118 if (returns
== null || returns
.length
== 0) {
1119 return new ModuleIdentification
[0];
1122 ModuleIdentification
[] saIdList
= new ModuleIdentification
[returns
.length
];
1123 for (int i
= 0; i
< returns
.length
; i
++) {
1124 LibrariesDocument
.Libraries
.Instance library
= (LibrariesDocument
.Libraries
.Instance
) returns
[i
];
1125 saGuid
= library
.getModuleGuid();
1126 saVersion
= library
.getModuleVersion();
1128 pkgGuid
= library
.getPackageGuid();
1129 pkgVersion
= library
.getPackageVersion();
1131 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1133 PackageIdentification pkgId
= new PackageIdentification(null,
1134 pkgGuid
, pkgVersion
);
1135 saId
.setPackage(pkgId
);
1144 // / This method is used for retrieving the elements information which has
1145 // / CName sub-element
1147 private static String
[] getCNames(String from
, String xPath
[]) {
1148 Object
[] returns
= get(from
, xPath
);
1149 if (returns
== null || returns
.length
== 0) {
1153 String
[] strings
= new String
[returns
.length
];
1154 for (int i
= 0; i
< returns
.length
; ++i
) {
1156 strings
[i
] = ((CNameType
) returns
[i
]).getStringValue();
1163 * Retrive library's constructor name
1165 * @returns constructor name list if elements are found at the known xpath
1166 * @returns null if nothing is there
1168 public static String
getLibConstructorName() {
1169 String
[] xPath
= new String
[] { "/Extern/Constructor" };
1171 Object
[] returns
= get("Externs", xPath
);
1172 if (returns
!= null && returns
.length
> 0) {
1173 CNameType constructor
= ((CNameType
) returns
[0]);
1174 return constructor
.getStringValue();
1181 * Retrive library's destructor name
1183 * @returns destructor name list if elements are found at the known xpath
1184 * @returns null if nothing is there
1186 public static String
getLibDestructorName() {
1187 String
[] xPath
= new String
[] { "/Extern/Destructor" };
1189 Object
[] returns
= get("Externs", xPath
);
1190 if (returns
!= null && returns
.length
> 0) {
1192 // Only support one Destructor function.
1194 CNameType destructor
= (CNameType
) returns
[0];
1195 return destructor
.getStringValue();
1202 * Retrive DriverBinding names
1204 * @returns DriverBinding name list if elements are found at the known xpath
1205 * @returns null if nothing is there
1207 public static String
[] getDriverBindingArray() {
1208 String
[] xPath
= new String
[] { "/Extern/DriverBinding" };
1209 return getCNames("Externs", xPath
);
1213 * Retrive ComponentName names
1215 * @returns ComponentName name list if elements are found at the known xpath
1216 * @returns null if nothing is there
1218 public static String
[] getComponentNameArray() {
1219 String
[] xPath
= new String
[] { "/Extern/ComponentName" };
1220 return getCNames("Externs", xPath
);
1224 * Retrive DriverConfig names
1226 * @returns DriverConfig name list if elements are found at the known xpath
1227 * @returns null if nothing is there
1229 public static String
[] getDriverConfigArray() {
1230 String
[] xPath
= new String
[] { "/Extern/DriverConfig" };
1231 return getCNames("Externs", xPath
);
1235 * Retrive DriverDiag names
1237 * @returns DriverDiag name list if elements are found at the known xpath
1238 * @returns null if nothing is there
1240 public static String
[] getDriverDiagArray() {
1241 String
[] xPath
= new String
[] { "/Extern/DriverDiag" };
1242 return getCNames("Externs", xPath
);
1246 * Retrive SetVirtualAddressMapCallBack names
1248 * @returns SetVirtualAddressMapCallBack name list if elements are found at
1250 * @returns null if nothing is there
1252 public static String
[] getSetVirtualAddressMapCallBackArray() {
1253 String
[] xPath
= new String
[] { "/Extern/SetVirtualAddressMapCallBack" };
1254 return getCNames("Externs", xPath
);
1258 * Retrive ExitBootServicesCallBack names
1260 * @returns ExitBootServicesCallBack name list if elements are found at the
1262 * @returns null if nothing is there
1264 public static String
[] getExitBootServicesCallBackArray() {
1265 String
[] xPath
= new String
[] { "/Extern/ExitBootServicesCallBack" };
1266 return getCNames("Externs", xPath
);
1270 * Retrieve module surface area file information
1272 * @returns ModuleSA objects list if elements are found at the known xpath
1273 * @returns Empty ModuleSA list if nothing is there
1275 public static Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> getFpdModules() {
1276 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1277 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1279 String fvBinding
= null;
1280 String saGuid
= null;
1281 String saVersion
= null;
1282 String pkgGuid
= null;
1283 String pkgVersion
= null;
1285 Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleMap
= new LinkedHashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
1287 if (result
== null) {
1288 return fpdModuleMap
;
1291 for (int i
= 0; i
< result
.length
; i
++) {
1293 // Get Fpd SA Module element node and add to ObjectMap.
1295 Map
<String
, XmlObject
> ObjectMap
= new HashMap
<String
, XmlObject
>();
1296 ModuleSADocument
.ModuleSA moduleSA
= (ModuleSADocument
.ModuleSA
) result
[i
];
1297 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getLibraries() != null) {
1298 ObjectMap
.put("Libraries", moduleSA
.getLibraries());
1300 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getPcdBuildDefinition() != null) {
1301 ObjectMap
.put("PcdBuildDefinition", moduleSA
1302 .getPcdBuildDefinition());
1304 if (((ModuleSADocument
.ModuleSA
) result
[i
])
1305 .getModuleSaBuildOptions() != null) {
1306 ObjectMap
.put("ModuleSaBuildOptions", moduleSA
1307 .getModuleSaBuildOptions());
1311 // Get Fpd SA Module attribute and create FpdMoudleIdentification.
1313 arch
= moduleSA
.getSupArchList().toString();
1317 saVersion
= ((ModuleSADocument
.ModuleSA
) result
[i
])
1318 .getModuleVersion();
1320 saGuid
= moduleSA
.getModuleGuid();
1321 pkgGuid
= moduleSA
.getPackageGuid();
1322 pkgVersion
= moduleSA
.getPackageVersion();
1325 // Create Module Identification which have class member of package
1328 PackageIdentification pkgId
= new PackageIdentification(null,
1329 pkgGuid
, pkgVersion
);
1330 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1333 saId
.setPackage(pkgId
);
1336 // Create FpdModule Identification which have class member of module
1340 String
[] archList
= arch
.split(" ");
1341 for (int j
= 0; j
< archList
.length
; j
++) {
1342 FpdModuleIdentification fpdSaId
= new FpdModuleIdentification(saId
, archList
[j
]);
1344 if (fvBinding
!= null) {
1345 fpdSaId
.setFvBinding(fvBinding
);
1349 // Put element to Map<FpdModuleIdentification, Map<String,
1352 fpdModuleMap
.put(fpdSaId
, ObjectMap
);
1356 return fpdModuleMap
;
1360 * Retrieve valid image names
1362 * @returns valid iamges name list if elements are found at the known xpath
1363 * @returns empty list if nothing is there
1365 public static String
[] getFpdValidImageNames() {
1366 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
1368 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1369 if (queryResult
== null) {
1370 return new String
[0];
1373 String
[] result
= new String
[queryResult
.length
];
1374 for (int i
= 0; i
< queryResult
.length
; i
++) {
1375 result
[i
] = ((XmlString
) queryResult
[i
]).getStringValue();
1381 public static Node
getFpdUserExtension() {
1382 String
[] xPath
= new String
[] { "/UserExtensions[@UserID='TianoCore']" };
1384 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1385 if (queryResult
== null || queryResult
.length
== 0) {
1388 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)queryResult
[0];
1390 return a
.getDomNode();
1394 * Retrieve FV image option information
1399 * @returns option name/value list if elements are found at the known xpath
1400 * @returns empty list if nothing is there
1402 public static String
[][] getFpdOptions(String fvName
) {
1403 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
1404 + fvName
.toUpperCase() + "']/FvImageOptions" };
1405 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1406 if (queryResult
== null) {
1407 return new String
[0][];
1409 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1410 for (int i
= 0; i
< queryResult
.length
; i
++) {
1411 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1412 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
1413 .getNameValueList();
1414 Iterator iter
= namevalues
.iterator();
1415 while (iter
.hasNext()) {
1416 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1418 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1421 String
[][] result
= new String
[list
.size()][2];
1422 for (int i
= 0; i
< list
.size(); i
++) {
1423 result
[i
][0] = list
.get(i
)[0];
1424 result
[i
][1] = list
.get(i
)[1];
1430 public static XmlObject
getFpdBuildOptions() {
1431 String
[] xPath
= new String
[] { "/BuildOptions" };
1433 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1435 if (queryResult
== null || queryResult
.length
== 0) {
1438 return (XmlObject
)queryResult
[0];
1441 public static PlatformIdentification
getFpdHeader() {
1442 String
[] xPath
= new String
[] { "/PlatformHeader" };
1444 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
1446 if (returns
== null || returns
.length
== 0) {
1449 PlatformHeaderDocument
.PlatformHeader header
= (PlatformHeaderDocument
.PlatformHeader
) returns
[0];
1451 String name
= header
.getPlatformName();
1453 String guid
= header
.getGuidValue();
1455 String version
= header
.getVersion();
1457 return new PlatformIdentification(name
, guid
, version
);
1461 * Retrieve FV image attributes information
1466 * @returns attribute name/value list if elements are found at the known
1468 * @returns empty list if nothing is there
1470 public static String
[][] getFpdAttributes(String fvName
) {
1471 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
1472 + fvName
.toUpperCase() + "']/FvImageOptions" };
1473 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1474 if (queryResult
== null) {
1475 return new String
[0][];
1477 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1478 for (int i
= 0; i
< queryResult
.length
; i
++) {
1480 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1481 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1482 Iterator iter
= namevalues
.iterator();
1483 while (iter
.hasNext()) {
1484 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1486 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1489 String
[][] result
= new String
[list
.size()][2];
1490 for (int i
= 0; i
< list
.size(); i
++) {
1491 result
[i
][0] = list
.get(i
)[0];
1492 result
[i
][1] = list
.get(i
)[1];
1498 * Retrieve flash definition file name
1500 * @returns file name if elements are found at the known xpath
1501 * @returns null if nothing is there
1503 public static String
getFlashDefinitionFile() {
1504 String
[] xPath
= new String
[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
1506 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1507 if (queryResult
== null || queryResult
.length
== 0) {
1511 FileNameConvention filename
= (FileNameConvention
) queryResult
[queryResult
.length
- 1];
1512 return filename
.getStringValue();
1515 public static String
[][] getFpdGlobalVariable() {
1516 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
1517 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1518 if (queryResult
== null) {
1519 return new String
[0][];
1522 String
[][] result
= new String
[queryResult
.length
][2];
1524 for (int i
= 0; i
< queryResult
.length
; i
++) {
1525 FvImagesDocument
.FvImages
.NameValue item
= (FvImagesDocument
.FvImages
.NameValue
)queryResult
[i
];
1526 result
[i
][0] = item
.getName();
1527 result
[i
][1] = item
.getValue();
1533 * Retrieve FV image component options
1538 * @returns name/value pairs list if elements are found at the known xpath
1539 * @returns empty list if nothing is there
1541 public static String
[][] getFpdComponents(String fvName
) {
1542 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName
.toUpperCase() + "']/FvImageOptions" };
1543 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1544 if (queryResult
== null) {
1545 return new String
[0][];
1548 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1549 for (int i
= 0; i
< queryResult
.length
; i
++) {
1550 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1551 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1552 Iterator iter
= namevalues
.iterator();
1553 while (iter
.hasNext()) {
1554 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1556 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1559 String
[][] result
= new String
[list
.size()][2];
1560 for (int i
= 0; i
< list
.size(); i
++) {
1561 result
[i
][0] = list
.get(i
)[0];
1562 result
[i
][1] = list
.get(i
)[1];
1568 * Retrieve PCD tokens
1570 * @returns CName/ItemType pairs list if elements are found at the known
1572 * @returns null if nothing is there
1574 public static String
[][] getPcdTokenArray() {
1575 String
[] xPath
= new String
[] { "/PcdData" };
1577 Object
[] returns
= get("PCDs", xPath
);
1578 if (returns
== null || returns
.length
== 0) {
1586 * Retrieve MAS header
1591 public static ModuleIdentification
getMsaHeader() {
1592 String
[] xPath
= new String
[] { "/" };
1593 Object
[] returns
= get("MsaHeader", xPath
);
1595 if (returns
== null || returns
.length
== 0) {
1599 MsaHeader msaHeader
= (MsaHeader
) returns
[0];
1601 // Get BaseName, ModuleType, GuidValue, Version
1602 // which in MsaHeader.
1604 String name
= msaHeader
.getModuleName();
1605 String moduleType
= msaHeader
.getModuleType().toString();
1606 String guid
= msaHeader
.getGuidValue();
1607 String version
= msaHeader
.getVersion();
1609 ModuleIdentification moduleId
= new ModuleIdentification(name
, guid
,
1612 moduleId
.setModuleType(moduleType
);
1618 * Retrieve Extern Specification
1622 * @return String[] If have specification element in the <extern> String[0]
1623 * If no specification element in the <extern>
1627 public static String
[] getExternSpecificaiton() {
1628 String
[] xPath
= new String
[] { "/Specification" };
1630 Object
[] queryResult
= get("Externs", xPath
);
1631 if (queryResult
== null) {
1632 return new String
[0];
1635 String
[] specificationList
= new String
[queryResult
.length
];
1636 for (int i
= 0; i
< queryResult
.length
; i
++) {
1637 specificationList
[i
] = ((Sentence
)queryResult
[i
])
1640 return specificationList
;
1644 * Retreive MsaFile which in SPD
1647 * @return String[][3] The string sequence is ModuleName, ModuleGuid,
1648 * ModuleVersion, MsaFile String[0][] If no msafile in SPD
1650 public static String
[] getSpdMsaFile() {
1651 String
[] xPath
= new String
[] { "/MsaFiles" };
1653 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1654 if (returns
== null) {
1655 return new String
[0];
1658 List
<String
> filenameList
= ((MsaFilesDocument
.MsaFiles
) returns
[0])
1660 return filenameList
.toArray(new String
[filenameList
.size()]);
1666 public static Map
<String
, String
[]> getSpdLibraryClasses() {
1667 String
[] xPath
= new String
[] { "/LibraryClassDeclarations/LibraryClass" };
1669 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1672 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
1674 Map
<String
, String
[]> libClassHeaderMap
= new HashMap
<String
, String
[]>();
1676 if (returns
== null) {
1677 return libClassHeaderMap
;
1680 for (int i
= 0; i
< returns
.length
; i
++) {
1681 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass library
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) returns
[i
];
1682 libClassHeaderMap
.put(library
.getName(), new String
[] { library
1683 .getIncludeHeader() });
1685 return libClassHeaderMap
;
1691 public static Map
<String
, String
> getSpdPackageHeaderFiles() {
1692 String
[] xPath
= new String
[] { "/PackageHeaders/IncludePkgHeader" };
1694 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1697 // Create Map, Key - ModuleType, String - PackageInclude Header file.
1699 Map
<String
, String
> packageIncludeMap
= new HashMap
<String
, String
>();
1701 if (returns
== null) {
1702 return packageIncludeMap
;
1705 for (int i
= 0; i
< returns
.length
; i
++) {
1706 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader includeHeader
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) returns
[i
];
1707 packageIncludeMap
.put(includeHeader
.getModuleType().toString(),
1708 includeHeader
.getStringValue());
1710 return packageIncludeMap
;
1713 public static PackageIdentification
getSpdHeader() {
1714 String
[] xPath
= new String
[] { "/SpdHeader" };
1716 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1718 if (returns
== null || returns
.length
== 0) {
1722 SpdHeaderDocument
.SpdHeader header
= (SpdHeaderDocument
.SpdHeader
) returns
[0];
1724 String name
= header
.getPackageName();
1726 String guid
= header
.getGuidValue();
1728 String version
= header
.getVersion();
1730 return new PackageIdentification(name
, guid
, version
);
1736 public static Map
<String
, String
[]> getSpdGuid() {
1737 String
[] xPath
= new String
[] { "/GuidDeclarations/Entry" };
1739 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1742 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
1744 Map
<String
, String
[]> guidDeclMap
= new HashMap
<String
, String
[]>();
1745 if (returns
== null) {
1749 for (int i
= 0; i
< returns
.length
; i
++) {
1750 GuidDeclarationsDocument
.GuidDeclarations
.Entry entry
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) returns
[i
];
1751 String
[] guidPair
= new String
[2];
1752 guidPair
[0] = entry
.getCName();
1753 guidPair
[1] = entry
.getGuidValue();
1754 guidDeclMap
.put(entry
.getName(), guidPair
);
1755 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1756 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[0]);
1757 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[1]);
1765 public static Map
<String
, String
[]> getSpdProtocol() {
1766 String
[] xPath
= new String
[] { "/ProtocolDeclarations/Entry" };
1768 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1771 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1773 Map
<String
, String
[]> protoclMap
= new HashMap
<String
, String
[]>();
1775 if (returns
== null) {
1779 for (int i
= 0; i
< returns
.length
; i
++) {
1780 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry entry
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) returns
[i
];
1781 String
[] protocolPair
= new String
[2];
1783 protocolPair
[0] = entry
.getCName();
1784 protocolPair
[1] = entry
.getGuidValue();
1785 protoclMap
.put(entry
.getName(), protocolPair
);
1786 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1787 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[0]);
1788 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[1]);
1794 * getSpdPpi() Retrieve the SPD PPI Entry
1797 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
1798 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
1801 public static Map
<String
, String
[]> getSpdPpi() {
1802 String
[] xPath
= new String
[] { "/PpiDeclarations/Entry" };
1804 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1807 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1809 Map
<String
, String
[]> ppiMap
= new HashMap
<String
, String
[]>();
1811 if (returns
== null) {
1815 for (int i
= 0; i
< returns
.length
; i
++) {
1816 PpiDeclarationsDocument
.PpiDeclarations
.Entry entry
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) returns
[i
];
1817 String
[] ppiPair
= new String
[2];
1818 ppiPair
[0] = entry
.getCName();
1819 ppiPair
[1] = entry
.getGuidValue();
1820 ppiMap
.put(entry
.getName(), ppiPair
);
1826 * Retrieve module Guid string
1828 * @returns GUILD string if elements are found at the known xpath
1829 * @returns null if nothing is there
1831 public static String
getModuleGuid() {
1832 String
[] xPath
= new String
[] { "" };
1834 Object
[] returns
= get("MsaHeader", xPath
);
1835 if (returns
!= null && returns
.length
> 0) {
1836 String guid
= ((MsaHeaderDocument
.MsaHeader
) returns
[0])
1847 public static ModuleSADocument
.ModuleSA
[] getFpdModuleSAs() {
1848 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1849 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1850 if (result
!= null) {
1851 return (ModuleSADocument
.ModuleSA
[]) result
;
1853 return new ModuleSADocument
.ModuleSA
[0];
1857 Get name array of PCD in a module. In one module, token space
1858 is same, and token name should not be conflicted.
1862 public static String
[] getModulePcdEntryNameArray() {
1863 PcdCodedDocument
.PcdCoded
.PcdEntry
[] pcdEntries
= null;
1866 String
[] xPath
= new String
[] {"/PcdEntry"};
1867 Object
[] returns
= get ("PcdCoded", xPath
);
1869 if (returns
== null) {
1870 return new String
[0];
1873 pcdEntries
= (PcdCodedDocument
.PcdCoded
.PcdEntry
[])returns
;
1874 results
= new String
[pcdEntries
.length
];
1876 for (index
= 0; index
< pcdEntries
.length
; index
++) {
1877 results
[index
] = pcdEntries
[index
].getCName();
1883 Search in a List for a given string
1887 public static boolean contains(List list
, String str
) {
1888 Iterator it
= list
.iterator();
1889 while (it
.hasNext()) {
1890 String s
= (String
)it
.next();
1891 if (s
.equalsIgnoreCase(str
)) {