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
.w3c
.dom
.Node
;
28 import org
.apache
.xmlbeans
.XmlObject
;
29 import org
.apache
.xmlbeans
.XmlString
;
31 import org
.tianocore
.BuildOptionsDocument
;
32 import org
.tianocore
.CNameType
;
33 import org
.tianocore
.ExternsDocument
;
34 import org
.tianocore
.FileNameConvention
;
35 import org
.tianocore
.FvImagesDocument
;
36 import org
.tianocore
.GuidDeclarationsDocument
;
37 import org
.tianocore
.GuidsDocument
;
38 import org
.tianocore
.LibrariesDocument
;
39 import org
.tianocore
.LibraryClassDeclarationsDocument
;
40 import org
.tianocore
.LibraryClassDocument
;
41 import org
.tianocore
.ModuleDefinitionsDocument
;
42 import org
.tianocore
.ModuleSADocument
;
43 import org
.tianocore
.ModuleSaBuildOptionsDocument
;
44 import org
.tianocore
.ModuleTypeDef
;
45 import org
.tianocore
.MsaFilesDocument
;
46 import org
.tianocore
.MsaHeaderDocument
;
47 import org
.tianocore
.OptionDocument
;
48 import org
.tianocore
.PPIsDocument
;
49 import org
.tianocore
.PackageDependenciesDocument
;
50 import org
.tianocore
.PackageHeadersDocument
;
51 import org
.tianocore
.PcdCodedDocument
;
52 import org
.tianocore
.PlatformDefinitionsDocument
;
53 import org
.tianocore
.PlatformHeaderDocument
;
54 import org
.tianocore
.PpiDeclarationsDocument
;
55 import org
.tianocore
.ProtocolDeclarationsDocument
;
56 import org
.tianocore
.Sentence
;
57 import org
.tianocore
.SpdHeaderDocument
;
58 import org
.tianocore
.UserExtensionsDocument
;
59 import org
.tianocore
.FilenameDocument
.Filename
;
60 import org
.tianocore
.MsaHeaderDocument
.MsaHeader
;
61 import org
.tianocore
.ProtocolsDocument
.Protocols
.Protocol
;
62 import org
.tianocore
.ProtocolsDocument
.Protocols
.ProtocolNotify
;
63 import org
.tianocore
.PcdDriverTypes
;
65 import org
.tianocore
.common
.logger
.EdkLog
;
66 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
67 import org
.tianocore
.build
.id
.ModuleIdentification
;
68 import org
.tianocore
.build
.id
.PackageIdentification
;
69 import org
.tianocore
.build
.id
.PlatformIdentification
;
70 import org
.tianocore
.build
.toolchain
.ToolChainInfo
;
71 import org
.tianocore
.build
.autogen
.CommonDefinition
;
74 * SurfaceAreaQuery class is used to query Surface Area information from msa,
75 * mbd, spd and fpd files.
77 * This class should not instantiated. All the public interfaces is static.
81 public class SurfaceAreaQuery
{
83 public String prefix
= "http://www.TianoCore.org/2006/Edk2.0";
86 // Contains name/value pairs of Surface Area document object. The name is
87 // always the top level element name.
89 private Map
<String
, XmlObject
> map
= null;
92 // mapStack is used to do nested query
94 private Stack
<Map
<String
, XmlObject
>> mapStack
= new Stack
<Map
<String
, XmlObject
>>();
97 // prefix of name space
99 private String nsPrefix
= "sans";
102 // xmlbeans needs a name space for each Xpath element
104 private String ns
= null;
107 // keep the namep declaration for xmlbeans Xpath query
109 private String queryDeclaration
= null;
111 private StringBuffer normQueryString
= new StringBuffer(4096);
112 private Pattern xPathPattern
= Pattern
.compile("([^/]*)(/|//)([^/]+)");
115 * Set a Surface Area document for query later
118 * A Surface Area document in TopLevelElementName/XmlObject
121 public SurfaceAreaQuery(Map
<String
, XmlObject
> map
) {
123 queryDeclaration
= "declare namespace " + nsPrefix
+ "='" + ns
+ "'; ";
128 * Push current used Surface Area document into query stack. The given new
129 * document will be used for any immediately followed getXXX() callings,
130 * untill pop() is called.
133 * The TopLevelElementName/XmlObject format of a Surface Area
136 public void push(Map
<String
, XmlObject
> newMap
) {
137 mapStack
.push(this.map
);
142 * Discard current used Surface Area document and use the top document in
146 this.map
= mapStack
.pop();
150 // / Convert xPath to be namespace qualified, which is necessary for
152 // / selectPath(). For example, converting /MsaHeader/ModuleType to
153 // / /ns:MsaHeader/ns:ModuleType
155 private String
normalizeQueryString(String
[] exp
, String from
) {
156 normQueryString
.setLength(0);
159 while (i
< exp
.length
) {
160 String newExp
= from
+ exp
[i
];
161 Matcher matcher
= xPathPattern
.matcher(newExp
);
163 while (matcher
.find()) {
164 String starter
= newExp
.substring(matcher
.start(1), matcher
166 String seperator
= newExp
.substring(matcher
.start(2), matcher
168 String token
= newExp
.substring(matcher
.start(3), matcher
171 normQueryString
.append(starter
);
172 normQueryString
.append(seperator
);
173 normQueryString
.append(nsPrefix
);
174 normQueryString
.append(":");
175 normQueryString
.append(token
);
179 if (i
< exp
.length
) {
180 normQueryString
.append(" | ");
184 return normQueryString
.toString();
188 * Search all XML documents stored in "map" for the specified xPath, using
189 * relative path (starting with '$this')
192 * xpath query string array
193 * @returns An array of XmlObject if elements are found at the specified
195 * @returns NULL if nothing is at the specified xpath
197 public Object
[] get(String
[] xPath
) {
202 String
[] keys
= (String
[]) map
.keySet().toArray(new String
[map
.size()]);
203 List
<Object
> result
= new ArrayList
<Object
>();
204 for (int i
= 0; i
< keys
.length
; ++i
) {
205 XmlObject rootNode
= (XmlObject
) map
.get(keys
[i
]);
206 if (rootNode
== null) {
210 String query
= queryDeclaration
211 + normalizeQueryString(xPath
, "$this/" + keys
[i
]);
212 XmlObject
[] tmp
= rootNode
.selectPath(query
);
213 for (int j
= 0; j
< tmp
.length
; ++j
) {
214 result
.add((Object
)tmp
[j
]);
218 int size
= result
.size();
223 return (Object
[]) result
.toArray(new Object
[size
]);
227 * Search XML documents named by "rootName" for the given xPath, using
228 * relative path (starting with '$this')
231 * The top level element name
233 * The xpath query string array
234 * @returns An array of XmlObject if elements are found at the given xpath
235 * @returns NULL if nothing is found at the given xpath
237 public Object
[] get(String rootName
, String
[] xPath
) {
242 XmlObject root
= (XmlObject
) map
.get(rootName
);
247 String query
= queryDeclaration
248 + normalizeQueryString(xPath
, "$this/" + rootName
);
249 XmlObject
[] result
= root
.selectPath(query
);
250 if (result
.length
> 0) {
251 return (Object
[])result
;
254 query
= queryDeclaration
+ normalizeQueryString(xPath
, "/" + rootName
);
255 result
= root
.selectPath(query
);
256 if (result
.length
> 0) {
257 return (Object
[])result
;
264 * Retrieve SourceFiles/Filename for specified ARCH type
268 * @returns An 2 dimension string array if elements are found at the known
270 * @returns NULL if nothing is found at the known xpath
272 public String
[][] getSourceFiles(String arch
) {
276 xPath
= new String
[] { "/Filename" };
278 returns
= get("SourceFiles", xPath
);
280 if (returns
== null || returns
.length
== 0) {
281 return new String
[0][0];
284 Filename
[] sourceFileNames
= (Filename
[]) returns
;
285 List
<String
[]> outputList
= new ArrayList
<String
[]>();
286 for (int i
= 0; i
< sourceFileNames
.length
; i
++) {
287 List archList
= sourceFileNames
[i
].getSupArchList();
288 if (arch
== null || arch
.equalsIgnoreCase("") || archList
== null || contains(archList
, arch
)) {
289 outputList
.add(new String
[] {sourceFileNames
[i
].getToolCode(),sourceFileNames
[i
].getStringValue()});
293 String
[][] outputString
= new String
[outputList
.size()][2];
294 for (int index
= 0; index
< outputList
.size(); index
++) {
295 outputString
[index
][0] = outputList
.get(index
)[0];
296 outputString
[index
][1] = outputList
.get(index
)[1];
302 * Retrieve /PlatformDefinitions/OutputDirectory from FPD
304 * @returns Directory names array if elements are found at the known xpath
305 * @returns Empty if nothing is found at the known xpath
307 public String
getFpdOutputDirectory() {
308 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
310 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
311 if (returns
== null || returns
.length
== 0) {
314 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
315 return item
.getOutputDirectory();
318 public String
getFpdIntermediateDirectories() {
319 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
321 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
322 if (returns
== null || returns
.length
== 0) {
325 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
326 if(item
.getIntermediateDirectories() == null) {
330 return item
.getIntermediateDirectories().toString();
334 public String
getModuleFfsKeyword() {
335 String
[] xPath
= new String
[] { "/" };
337 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
338 if (returns
== null || returns
.length
== 0) {
341 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
342 return item
.getFfsFormatKey();
345 public String
getModuleFvBindingKeyword() {
346 String
[] xPath
= new String
[] { "/" };
348 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
349 if (returns
== null || returns
.length
== 0) {
352 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
353 return item
.getFvBinding();
356 public List
getModuleSupportedArchs() {
357 String
[] xPath
= new String
[] { "/" };
359 Object
[] returns
= get("ModuleDefinitions", xPath
);
360 if (returns
== null || returns
.length
== 0) {
363 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
364 return item
.getSupportedArchitectures();
367 public BuildOptionsDocument
.BuildOptions
.Ffs
[] getFpdFfs() {
368 String
[] xPath
= new String
[] {"/Ffs"};
370 Object
[] returns
= get("BuildOptions", xPath
);
371 if (returns
== null || returns
.length
== 0) {
372 return new BuildOptionsDocument
.BuildOptions
.Ffs
[0];
374 return (BuildOptionsDocument
.BuildOptions
.Ffs
[])returns
;
377 public String
getModuleOutputFileBasename() {
378 String
[] xPath
= new String
[] { "/" };
380 Object
[] returns
= get("ModuleDefinitions", xPath
);
381 if (returns
== null || returns
.length
== 0) {
384 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
385 return item
.getOutputFileBasename();
389 * Retrieve BuildOptions/Option or Arch/Option
391 * @param toolChainFamilyFlag
392 * if true, retrieve options for toolchain family; otherwise for
395 * @returns String[][5] name, target, toolchain, arch, coommand of options
396 * if elements are found at the known xpath. String[0][] if dont
399 * @returns Empty array if nothing is there
401 public String
[][] getOptions(String from
, String
[] xPath
, boolean toolChainFamilyFlag
) {
402 String target
= null;
403 String toolchain
= null;
404 String toolchainFamily
= null;
405 List
<String
> archList
= null;
407 String optionName
= null;
409 Object
[] returns
= get(from
, xPath
);
410 if (returns
== null) {
411 return new String
[0][5];
414 List
<String
[]> optionList
= new ArrayList
<String
[]>();
415 OptionDocument
.Option option
;
417 for (int i
= 0; i
< returns
.length
; i
++) {
418 option
= (OptionDocument
.Option
) returns
[i
];
421 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
423 // put to result[][5] array in above order.
426 if (option
.getBuildTargets() == null) {
430 target
= option
.getBuildTargets().toString();
432 if (target
!= null) {
433 targetList
= target
.split(" ");
435 targetList
= new String
[1];
436 targetList
[0] = null;
439 if (toolChainFamilyFlag
) {
440 toolchainFamily
= option
.getToolChainFamily();
441 if (toolchainFamily
!= null) {
442 toolchain
= toolchainFamily
.toString();
447 toolchain
= option
.getTagName();
450 archList
= new ArrayList
<String
>();
451 List archEnumList
= option
.getSupArchList();
452 if (archEnumList
== null) {
455 //archList.addAll(archEnumList);
456 Iterator it
= archEnumList
.iterator();
457 while (it
.hasNext()) {
458 String archType
= (String
)it
.next();
459 archList
.add(archType
);
463 cmd
= option
.getToolCode();
465 optionName
= option
.getStringValue();
466 for (int t
= 0; t
< targetList
.length
; t
++) {
467 for (int j
= 0; j
< archList
.size(); j
++) {
468 optionList
.add(new String
[] { targetList
[t
],
469 toolchain
, archList
.get(j
), cmd
, optionName
});
474 String
[][] result
= new String
[optionList
.size()][5];
475 for (int i
= 0; i
< optionList
.size(); i
++) {
476 result
[i
][0] = optionList
.get(i
)[0];
477 result
[i
][1] = optionList
.get(i
)[1];
478 result
[i
][2] = optionList
.get(i
)[2];
479 result
[i
][3] = optionList
.get(i
)[3];
480 result
[i
][4] = optionList
.get(i
)[4];
485 public String
[][] getModuleBuildOptions(boolean toolChainFamilyFlag
) {
488 if (toolChainFamilyFlag
== true) {
489 xPath
= new String
[] {
490 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
491 "/Options/Option[@ToolChainFamily]", };
493 xPath
= new String
[] {
494 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
495 "/Options/Option[@TagName]", };
497 return getOptions("ModuleSaBuildOptions", xPath
, toolChainFamilyFlag
);
500 public String
[][] getPlatformBuildOptions(boolean toolChainFamilyFlag
) {
503 if (toolChainFamilyFlag
== true) {
504 xPath
= new String
[] {
505 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
506 "/BuildOptions/Options/Option[@ToolChainFamily]", };
508 xPath
= new String
[] {
509 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
510 "/BuildOptions/Options/Option[@TagName]", };
513 return getOptions("PlatformSurfaceArea", xPath
, toolChainFamilyFlag
);
516 public ToolChainInfo
getFpdToolChainInfo() {
517 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
519 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
520 if (returns
== null || returns
.length
== 0) {
524 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
525 ToolChainInfo toolChainInfo
= new ToolChainInfo();
526 toolChainInfo
.addTargets(item
.getBuildTargets().toString());
527 toolChainInfo
.addArchs(item
.getSupportedArchitectures().toString());
528 toolChainInfo
.addTagnames((String
)null);
529 return toolChainInfo
;
533 * Retrieve <xxxHeader>/ModuleType
535 * @returns The module type name if elements are found at the known xpath
536 * @returns null if nothing is there
538 public String
getModuleType() {
539 String
[] xPath
= new String
[] { "/ModuleType" };
541 Object
[] returns
= get(xPath
);
542 if (returns
!= null && returns
.length
> 0) {
543 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
544 return type
.enumValue().toString();
551 * Retrieve PackageDependencies/Package
556 * @returns package name list if elements are found at the known xpath
557 * @returns null if nothing is there
559 public PackageIdentification
[] getDependencePkg(String arch
) {
561 String packageGuid
= null;
562 String packageVersion
= null;
565 xPath
= new String
[] { "/Package" };
567 Object
[] returns
= get("PackageDependencies", xPath
);
568 if (returns
== null) {
569 return new PackageIdentification
[0];
573 // Get packageIdentification
575 List
<PackageIdentification
> packageIdList
= new ArrayList
<PackageIdentification
>();
576 for (int i
= 0; i
< returns
.length
; i
++) {
577 PackageDependenciesDocument
.PackageDependencies
.Package item
= (PackageDependenciesDocument
.PackageDependencies
.Package
) returns
[i
];
578 List archList
= item
.getSupArchList();
579 if (arch
== null || archList
== null || contains(archList
, arch
)) {
580 packageGuid
= item
.getPackageGuid();
581 packageVersion
= item
.getPackageVersion();
582 packageIdList
.add(new PackageIdentification(null, packageGuid
,
588 // transfer packageIdentification list to array.
590 PackageIdentification
[] packageIdArray
= new PackageIdentification
[packageIdList
.size()];
591 for (int i
= 0; i
< packageIdList
.size(); i
++) {
592 packageIdArray
[i
] = new PackageIdentification(null, packageIdList
.get(i
).getGuid(),packageIdList
.get(i
).getVersion());
594 return packageIdArray
;
598 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
601 * Library class usage
603 * @returns LibraryClass objects list if elements are found at the known
605 * @returns null if nothing is there
607 public String
[] getLibraryClasses(String usage
, String arch
) {
609 if (usage
== null || usage
.equals("")) {
610 xPath
= new String
[] { "/LibraryClass" };
612 xPath
= new String
[] { "/LibraryClass[@Usage='" + usage
+ "']" };
615 Object
[] returns
= get("LibraryClassDefinitions", xPath
);
616 if (returns
== null || returns
.length
== 0) {
617 return new String
[0];
620 LibraryClassDocument
.LibraryClass
[] libraryClassList
= (LibraryClassDocument
.LibraryClass
[]) returns
;
621 List
<String
> libraryClassName
= new ArrayList
<String
>();
622 for (int i
= 0; i
< libraryClassList
.length
; i
++) {
623 List archList
= libraryClassList
[i
].getSupArchList();
625 if (arch
== null || contains(archList
, arch
)) {
626 libraryClassName
.add(libraryClassList
[i
].getKeyword());
630 String
[] libraryArray
= new String
[libraryClassName
.size()];
631 libraryClassName
.toArray(libraryArray
);
636 * Retrieve ModuleEntryPoint names
638 * @returns ModuleEntryPoint name list if elements are found at the known
640 * @returns null if nothing is there
642 public String
[] getModuleEntryPointArray() {
643 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
645 Object
[] returns
= get("Externs", xPath
);
647 if (returns
!= null && returns
.length
> 0) {
648 String
[] entryPoints
= new String
[returns
.length
];
650 for (int i
= 0; i
< returns
.length
; ++i
) {
651 entryPoints
[i
] = ((CNameType
) returns
[i
]).getStringValue();
661 * retrieve Protocol for specified usage
664 * Protocol usage arch Architecture
666 * @returns Protocol String list if elements are found at the known xpath
667 * @returns String[0] if nothing is there
669 public String
[] getProtocolArray(String arch
, String usage
) {
671 String usageXpath
= "";
672 String archXpath
= "";
674 if (arch
== null || arch
.equals("")) {
675 return new String
[0];
677 archXpath
= "/Protocol";
678 if (usage
!= null && !usage
.equals("")) {
679 usageXpath
= "/Protocol[@Usage='" + usage
+ "']";
680 xPath
= new String
[] { usageXpath
, archXpath
};
682 return getProtocolArray(arch
);
687 Object
[] returns
= get("Protocols", xPath
);
688 if (returns
== null) {
689 return new String
[0];
691 Protocol
[] protocolList
= (Protocol
[]) returns
;
693 String
[] protocolArray
= new String
[returns
.length
];
694 for (int i
= 0; i
< returns
.length
; i
++) {
695 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
697 return protocolArray
;
701 * retrieve Protocol for specified usage
706 * @returns Protocol String list if elements are found at the known xpath
707 * @returns String[0] if nothing is there
709 public String
[] getProtocolArray(String arch
) {
712 if (arch
== null || arch
.equals("")) {
713 return new String
[0];
715 xPath
= new String
[] { "/Protocol" };
718 Object
[] returns
= get("Protocols", xPath
);
719 if (returns
== null) {
720 return new String
[0];
722 Protocol
[] returnlList
= (Protocol
[]) returns
;
724 List
<String
> protocolList
= new ArrayList
<String
>();
726 for (int i
= 0; i
< returns
.length
; i
++) {
727 List archList
= returnlList
[i
].getSupArchList();
728 if (archList
== null || contains(archList
, arch
)){
729 protocolList
.add(returnlList
[i
].getProtocolCName());
732 String
[] protocolArray
= new String
[protocolList
.size()];
733 for (int i
= 0; i
< protocolList
.size(); i
++) {
734 protocolArray
[i
] = protocolList
.get(i
);
736 return protocolArray
;
740 * Retrieve ProtocolNotify for specified usage
743 * ProtocolNotify usage
745 * @returns String[] if elements are found at the known xpath
746 * @returns String[0] if nothing is there
748 public String
[] getProtocolNotifyArray(String arch
) {
751 if (arch
== null || arch
.equals("")) {
752 return new String
[0];
754 xPath
= new String
[] { "/ProtocolNotify" };
757 Object
[] returns
= get("Protocols", xPath
);
758 if (returns
== null) {
759 return new String
[0];
762 List
<String
> protocolNotifyList
= new ArrayList
<String
>();
764 for (int i
= 0; i
< returns
.length
; i
++) {
765 List archList
= ((ProtocolNotify
) returns
[i
]).getSupArchList();
766 if (archList
== null || contains(archList
, arch
)){
767 protocolNotifyList
.add(((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName());
771 String
[] protocolNotifyArray
= new String
[protocolNotifyList
.size()];
772 for (int i
= 0; i
< protocolNotifyList
.size(); i
++) {
773 protocolNotifyArray
[i
] = protocolNotifyList
.get(i
);
775 return protocolNotifyArray
;
779 * Retrieve ProtocolNotify for specified usage
782 * ProtocolNotify usage
784 * @returns String[] if elements are found at the known xpath
785 * @returns String[0] if nothing is there
787 public String
[] getProtocolNotifyArray(String arch
, String usage
) {
793 if (arch
== null || arch
.equals("")) {
794 return new String
[0];
796 archXpath
= "/ProtocolNotify";
797 if (usage
!= null && !usage
.equals("")) {
798 usageXpath
= "/ProtocolNotify[@Usage='" + arch
+ "']";
799 xPath
= new String
[] { archXpath
, usageXpath
};
801 return getProtocolNotifyArray(arch
);
805 Object
[] returns
= get("Protocols", xPath
);
806 if (returns
== null) {
807 return new String
[0];
810 String
[] protocolNotifyList
= new String
[returns
.length
];
812 for (int i
= 0; i
< returns
.length
; i
++) {
813 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
815 return protocolNotifyList
;
819 * Retrieve ModuleUnloadImage names
821 * @returns ModuleUnloadImage name list if elements are found at the known
823 * @returns null if nothing is there
825 public String
[] getModuleUnloadImageArray() {
826 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
828 Object
[] returns
= get("Externs", xPath
);
829 if (returns
!= null && returns
.length
> 0) {
830 String
[] stringArray
= new String
[returns
.length
];
831 CNameType
[] doc
= (CNameType
[]) returns
;
833 for (int i
= 0; i
< returns
.length
; ++i
) {
834 stringArray
[i
] = doc
[i
].getStringValue();
846 * @returns Extern objects list if elements are found at the known xpath
847 * @returns null if nothing is there
849 public ExternsDocument
.Externs
.Extern
[] getExternArray() {
850 String
[] xPath
= new String
[] { "/Extern" };
852 Object
[] returns
= get("Externs", xPath
);
853 if (returns
!= null && returns
.length
> 0) {
854 return (ExternsDocument
.Externs
.Extern
[]) returns
;
861 * Retrieve PpiNotify for specified arch
866 * @returns String[] if elements are found at the known xpath
867 * @returns String[0] if nothing is there
869 public String
[] getPpiNotifyArray(String arch
) {
872 if (arch
== null || arch
.equals("")) {
873 return new String
[0];
875 xPath
= new String
[] { "/PpiNotify" };
878 Object
[] returns
= get("PPIs", xPath
);
879 if (returns
== null) {
880 return new String
[0];
884 List
<String
> ppiNotifyList
= new ArrayList
<String
>();
885 for (int i
= 0; i
< returns
.length
; i
++) {
886 List archList
= ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getSupArchList();
887 if (archList
== null || contains(archList
, arch
)){
888 ppiNotifyList
.add(((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName());
892 String
[] ppiNotifyArray
= new String
[ppiNotifyList
.size()];
893 for (int i
= 0; i
< ppiNotifyList
.size(); i
++) {
894 ppiNotifyArray
[i
] = ppiNotifyList
.get(i
);
897 return ppiNotifyArray
;
901 * Retrieve PpiNotify for specified usage and arch
904 * PpiNotify arch usage PpiNotify usage
907 * @returns String[] if elements are found at the known xpath
908 * @returns String[0] if nothing is there
910 public String
[] getPpiNotifyArray(String arch
, String usage
) {
916 if (arch
== null || arch
.equals("")) {
917 return new String
[0];
919 archXpath
= "/PpiNotify";
920 if (usage
!= null && !usage
.equals("")) {
921 usageXpath
= "/PpiNotify[@Usage='" + arch
+ "']";
922 xPath
= new String
[] { archXpath
, usageXpath
};
924 return getProtocolNotifyArray(arch
);
928 Object
[] returns
= get("PPIs", xPath
);
929 if (returns
== null) {
930 return new String
[0];
933 String
[] ppiNotifyList
= new String
[returns
.length
];
935 for (int i
= 0; i
< returns
.length
; i
++) {
936 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
938 return ppiNotifyList
;
942 * Retrieve Ppi for specified arch
947 * @returns String[] if elements are found at the known xpath
948 * @returns String[0] if nothing is there
950 public String
[] getPpiArray(String arch
) {
953 if (arch
== null || arch
.equals("")) {
954 return new String
[0];
956 xPath
= new String
[] { "/Ppi" };
959 Object
[] returns
= get("PPIs", xPath
);
960 if (returns
== null) {
961 return new String
[0];
964 List
<String
> ppiList
= new ArrayList
<String
>();
965 for (int i
= 0; i
< returns
.length
; i
++) {
966 List archList
= ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getSupArchList();
967 if (archList
== null || contains(archList
, arch
)){
968 ppiList
.add(((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName());
972 String
[] ppiArray
= new String
[ppiList
.size()];
973 for (int i
= 0; i
< ppiList
.size(); i
++) {
974 ppiArray
[i
] = ppiList
.get(i
);
980 * Retrieve PpiNotify for specified usage and arch
983 * PpiNotify arch usage PpiNotify usage
986 * @returns String[] if elements are found at the known xpath
987 * @returns String[0] if nothing is there
989 public String
[] getPpiArray(String arch
, String usage
) {
995 if (arch
== null || arch
.equals("")) {
996 return new String
[0];
999 if (usage
!= null && !usage
.equals("")) {
1000 usageXpath
= "/Ppi[@Usage='" + arch
+ "']";
1001 xPath
= new String
[] { archXpath
, usageXpath
};
1003 return getProtocolNotifyArray(arch
);
1007 Object
[] returns
= get("PPIs", xPath
);
1008 if (returns
== null) {
1009 return new String
[0];
1012 String
[] ppiList
= new String
[returns
.length
];
1014 for (int i
= 0; i
< returns
.length
; i
++) {
1015 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
1021 * Retrieve GuidEntry information for specified usage
1026 * @returns GuidEntry objects list if elements are found at the known xpath
1027 * @returns null if nothing is there
1029 public String
[] getGuidEntryArray(String arch
) {
1032 if (arch
== null || arch
.equals("")) {
1033 xPath
= new String
[] { "/GuidCNames" };
1035 xPath
= new String
[] { "/GuidCNames" };
1038 Object
[] returns
= get("Guids", xPath
);
1039 if (returns
== null) {
1040 return new String
[0];
1043 List
<String
> guidList
= new ArrayList
<String
>();
1044 for (int i
= 0; i
< returns
.length
; i
++) {
1045 List archList
= ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getSupArchList();
1046 if (archList
== null || contains(archList
, arch
)){
1047 guidList
.add(((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName());
1051 String
[] guidArray
= new String
[guidList
.size()];
1052 for (int i
= 0; i
< guidList
.size(); i
++) {
1053 guidArray
[i
] = guidList
.get(i
);
1060 * Retrieve GuidEntry information for specified usage
1063 * GuidEntry arch usage GuidEntry usage
1065 * @returns GuidEntry objects list if elements are found at the known xpath
1066 * @returns null if nothing is there
1068 public String
[] getGuidEntryArray(String arch
, String usage
) {
1073 if (arch
== null || arch
.equals("")) {
1074 return new String
[0];
1076 archXpath
= "/GuidEntry";
1077 if (usage
!= null && !usage
.equals("")) {
1078 usageXpath
= "/GuidEntry[@Usage='" + arch
+ "']";
1079 xPath
= new String
[] { archXpath
, usageXpath
};
1081 return getProtocolNotifyArray(arch
);
1085 Object
[] returns
= get("Guids", xPath
);
1086 if (returns
== null) {
1087 return new String
[0];
1090 String
[] guidList
= new String
[returns
.length
];
1092 for (int i
= 0; i
< returns
.length
; i
++) {
1093 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1099 * Retrieve Library instance information
1104 * Library instance usage
1106 * @returns library instance name list if elements are found at the known
1108 * @returns null if nothing is there
1110 public ModuleIdentification
[] getLibraryInstance(String arch
) {
1112 String saGuid
= null;
1113 String saVersion
= null;
1114 String pkgGuid
= null;
1115 String pkgVersion
= null;
1117 if (arch
== null || arch
.equalsIgnoreCase("")) {
1118 xPath
= new String
[] { "/Instance" };
1121 // Since Schema don't have SupArchList now, so the follow Xpath is
1122 // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]
1123 // don't have effect.
1125 xPath
= new String
[] { "/Instance[not(@SupArchList) or @SupArchList='"
1129 Object
[] returns
= get("Libraries", xPath
);
1130 if (returns
== null || returns
.length
== 0) {
1131 return new ModuleIdentification
[0];
1134 ModuleIdentification
[] saIdList
= new ModuleIdentification
[returns
.length
];
1135 for (int i
= 0; i
< returns
.length
; i
++) {
1136 LibrariesDocument
.Libraries
.Instance library
= (LibrariesDocument
.Libraries
.Instance
) returns
[i
];
1137 saGuid
= library
.getModuleGuid();
1138 saVersion
= library
.getModuleVersion();
1140 pkgGuid
= library
.getPackageGuid();
1141 pkgVersion
= library
.getPackageVersion();
1143 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1145 PackageIdentification pkgId
= new PackageIdentification(null,
1146 pkgGuid
, pkgVersion
);
1147 saId
.setPackage(pkgId
);
1156 // / This method is used for retrieving the elements information which has
1157 // / CName sub-element
1159 private String
[] getCNames(String from
, String xPath
[]) {
1160 Object
[] returns
= get(from
, xPath
);
1161 if (returns
== null || returns
.length
== 0) {
1165 String
[] strings
= new String
[returns
.length
];
1166 for (int i
= 0; i
< returns
.length
; ++i
) {
1168 strings
[i
] = ((CNameType
) returns
[i
]).getStringValue();
1175 * Retrive library's constructor name
1177 * @returns constructor name list if elements are found at the known xpath
1178 * @returns null if nothing is there
1180 public String
getLibConstructorName() {
1181 String
[] xPath
= new String
[] { "/Extern/Constructor" };
1183 Object
[] returns
= get("Externs", xPath
);
1184 if (returns
!= null && returns
.length
> 0) {
1185 CNameType constructor
= ((CNameType
) returns
[0]);
1186 return constructor
.getStringValue();
1193 * Retrive library's destructor name
1195 * @returns destructor name list if elements are found at the known xpath
1196 * @returns null if nothing is there
1198 public String
getLibDestructorName() {
1199 String
[] xPath
= new String
[] { "/Extern/Destructor" };
1201 Object
[] returns
= get("Externs", xPath
);
1202 if (returns
!= null && returns
.length
> 0) {
1204 // Only support one Destructor function.
1206 CNameType destructor
= (CNameType
) returns
[0];
1207 return destructor
.getStringValue();
1214 * Retrive DriverBinding names
1216 * @returns DriverBinding name list if elements are found at the known xpath
1217 * @returns null if nothing is there
1219 public String
[] getDriverBindingArray() {
1220 String
[] xPath
= new String
[] { "/Extern/DriverBinding" };
1221 return getCNames("Externs", xPath
);
1225 * Retrive ComponentName names
1227 * @returns ComponentName name list if elements are found at the known xpath
1228 * @returns null if nothing is there
1230 public String
[] getComponentNameArray() {
1231 String
[] xPath
= new String
[] { "/Extern/ComponentName" };
1232 return getCNames("Externs", xPath
);
1236 * Retrive DriverConfig names
1238 * @returns DriverConfig name list if elements are found at the known xpath
1239 * @returns null if nothing is there
1241 public String
[] getDriverConfigArray() {
1242 String
[] xPath
= new String
[] { "/Extern/DriverConfig" };
1243 return getCNames("Externs", xPath
);
1247 * Retrive DriverDiag names
1249 * @returns DriverDiag name list if elements are found at the known xpath
1250 * @returns null if nothing is there
1252 public String
[] getDriverDiagArray() {
1253 String
[] xPath
= new String
[] { "/Extern/DriverDiag" };
1254 return getCNames("Externs", xPath
);
1258 * Retrive SetVirtualAddressMapCallBack names
1260 * @returns SetVirtualAddressMapCallBack name list if elements are found at
1262 * @returns null if nothing is there
1264 public String
[] getSetVirtualAddressMapCallBackArray() {
1265 String
[] xPath
= new String
[] { "/Extern/SetVirtualAddressMapCallBack" };
1266 return getCNames("Externs", xPath
);
1270 * Retrive ExitBootServicesCallBack names
1272 * @returns ExitBootServicesCallBack name list if elements are found at the
1274 * @returns null if nothing is there
1276 public String
[] getExitBootServicesCallBackArray() {
1277 String
[] xPath
= new String
[] { "/Extern/ExitBootServicesCallBack" };
1278 return getCNames("Externs", xPath
);
1282 Judge whether current driver is PEI_PCD_DRIVER or DXE_PCD_DRIVER or
1285 @return CommonDefinition.PCD_DRIVER_TYPE the type of current driver
1287 public CommonDefinition
.PCD_DRIVER_TYPE
getPcdDriverType() {
1288 String
[] xPath
= new String
[] {"/PcdIsDriver"};
1289 Object
[] results
= get ("Externs", xPath
);
1291 if (results
!= null && results
.length
!= 0) {
1292 PcdDriverTypes type
= (PcdDriverTypes
) results
[0];
1293 String typeStr
= type
.enumValue().toString();
1294 if (typeStr
.equals(CommonDefinition
.PCD_DRIVER_TYPE
.PEI_PCD_DRIVER
.toString())) {
1295 return CommonDefinition
.PCD_DRIVER_TYPE
.PEI_PCD_DRIVER
;
1296 } else if (typeStr
.equals(CommonDefinition
.PCD_DRIVER_TYPE
.DXE_PCD_DRIVER
.toString())) {
1297 return CommonDefinition
.PCD_DRIVER_TYPE
.DXE_PCD_DRIVER
;
1299 return CommonDefinition
.PCD_DRIVER_TYPE
.UNKNOWN_PCD_DRIVER
;
1302 return CommonDefinition
.PCD_DRIVER_TYPE
.NOT_PCD_DRIVER
;
1306 * Retrieve module surface area file information
1308 * @returns ModuleSA objects list if elements are found at the known xpath
1309 * @returns Empty ModuleSA list if nothing is there
1311 public Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> getFpdModules() {
1312 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1313 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1315 String fvBinding
= null;
1316 String saGuid
= null;
1317 String saVersion
= null;
1318 String pkgGuid
= null;
1319 String pkgVersion
= null;
1321 Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleMap
= new LinkedHashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
1323 if (result
== null) {
1324 return fpdModuleMap
;
1327 for (int i
= 0; i
< result
.length
; i
++) {
1329 // Get Fpd SA Module element node and add to ObjectMap.
1331 Map
<String
, XmlObject
> ObjectMap
= new HashMap
<String
, XmlObject
>();
1332 ModuleSADocument
.ModuleSA moduleSA
= (ModuleSADocument
.ModuleSA
) result
[i
];
1333 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getLibraries() != null) {
1334 ObjectMap
.put("Libraries", moduleSA
.getLibraries());
1336 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getPcdBuildDefinition() != null) {
1337 ObjectMap
.put("PcdBuildDefinition", moduleSA
.getPcdBuildDefinition());
1339 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getModuleSaBuildOptions() != null) {
1340 ObjectMap
.put("ModuleSaBuildOptions", moduleSA
.getModuleSaBuildOptions());
1344 // Get Fpd SA Module attribute and create FpdMoudleIdentification.
1346 if (moduleSA
.isSetSupArchList()) {
1347 arch
= moduleSA
.getSupArchList().toString();
1354 saVersion
= ((ModuleSADocument
.ModuleSA
) result
[i
]).getModuleVersion();
1356 saGuid
= moduleSA
.getModuleGuid();
1357 pkgGuid
= moduleSA
.getPackageGuid();
1358 pkgVersion
= moduleSA
.getPackageVersion();
1361 // Create Module Identification which have class member of package
1364 PackageIdentification pkgId
= new PackageIdentification(null, pkgGuid
, pkgVersion
);
1365 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
, saVersion
);
1367 saId
.setPackage(pkgId
);
1370 // Create FpdModule Identification which have class member of module
1373 String
[] archList
= new String
[0];
1374 if (arch
== null || arch
.trim().length() == 0) {
1375 archList
= GlobalData
.getToolChainInfo().getArchs();
1377 archList
= arch
.split(" ");
1379 for (int j
= 0; j
< archList
.length
; j
++) {
1380 FpdModuleIdentification fpdSaId
= new FpdModuleIdentification(saId
, archList
[j
]);
1382 if (fvBinding
!= null) {
1383 fpdSaId
.setFvBinding(fvBinding
);
1387 // Put element to Map<FpdModuleIdentification, Map<String,
1390 fpdModuleMap
.put(fpdSaId
, ObjectMap
);
1393 return fpdModuleMap
;
1397 * Retrieve valid image names
1399 * @returns valid iamges name list if elements are found at the known xpath
1400 * @returns empty list if nothing is there
1402 public String
[] getFpdValidImageNames() {
1403 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
1405 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1406 if (queryResult
== null) {
1407 return new String
[0];
1410 String
[] result
= new String
[queryResult
.length
];
1411 for (int i
= 0; i
< queryResult
.length
; i
++) {
1412 result
[i
] = ((XmlString
) queryResult
[i
]).getStringValue();
1418 public Node
getFpdUserExtensionPreBuild() {
1419 String
[] xPath
= new String
[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" };
1421 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1422 if (queryResult
== null || queryResult
.length
== 0) {
1425 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)queryResult
[0];
1427 return a
.getDomNode();
1430 public Node
getFpdUserExtensionPostBuild() {
1431 String
[] xPath
= new String
[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" };
1433 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1434 if (queryResult
== null || queryResult
.length
== 0) {
1437 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)queryResult
[0];
1439 return a
.getDomNode();
1443 * Retrieve FV image option information
1448 * @returns option name/value list if elements are found at the known xpath
1449 * @returns empty list if nothing is there
1451 public String
[][] getFpdOptions(String fvName
) {
1452 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
1453 + fvName
+ "']/FvImageOptions" };
1454 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1455 if (queryResult
== null) {
1456 return new String
[0][];
1458 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1459 for (int i
= 0; i
< queryResult
.length
; i
++) {
1460 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1461 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
1462 .getNameValueList();
1463 Iterator iter
= namevalues
.iterator();
1464 while (iter
.hasNext()) {
1465 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1467 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1470 String
[][] result
= new String
[list
.size()][2];
1471 for (int i
= 0; i
< list
.size(); i
++) {
1472 result
[i
][0] = list
.get(i
)[0];
1473 result
[i
][1] = list
.get(i
)[1];
1479 public XmlObject
getFpdBuildOptions() {
1480 String
[] xPath
= new String
[] { "/BuildOptions" };
1482 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1484 if (queryResult
== null || queryResult
.length
== 0) {
1487 return (XmlObject
)queryResult
[0];
1490 public PlatformIdentification
getFpdHeader() {
1491 String
[] xPath
= new String
[] { "/PlatformHeader" };
1493 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
1495 if (returns
== null || returns
.length
== 0) {
1498 PlatformHeaderDocument
.PlatformHeader header
= (PlatformHeaderDocument
.PlatformHeader
) returns
[0];
1500 String name
= header
.getPlatformName();
1502 String guid
= header
.getGuidValue();
1504 String version
= header
.getVersion();
1506 return new PlatformIdentification(name
, guid
, version
);
1510 * Retrieve FV image attributes information
1515 * @returns attribute name/value list if elements are found at the known
1517 * @returns empty list if nothing is there
1519 public String
[][] getFpdAttributes(String fvName
) {
1520 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
1521 + fvName
+ "']/FvImageOptions" };
1522 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1523 if (queryResult
== null) {
1524 return new String
[0][];
1526 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1527 for (int i
= 0; i
< queryResult
.length
; i
++) {
1529 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1530 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1531 Iterator iter
= namevalues
.iterator();
1532 while (iter
.hasNext()) {
1533 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1535 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1538 String
[][] result
= new String
[list
.size()][2];
1539 for (int i
= 0; i
< list
.size(); i
++) {
1540 result
[i
][0] = list
.get(i
)[0];
1541 result
[i
][1] = list
.get(i
)[1];
1547 * Retrieve flash definition file name
1549 * @returns file name if elements are found at the known xpath
1550 * @returns null if nothing is there
1552 public String
getFlashDefinitionFile() {
1553 String
[] xPath
= new String
[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
1555 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1556 if (queryResult
== null || queryResult
.length
== 0) {
1560 FileNameConvention filename
= (FileNameConvention
) queryResult
[queryResult
.length
- 1];
1561 return filename
.getStringValue();
1564 public String
[][] getFpdGlobalVariable() {
1565 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
1566 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1567 if (queryResult
== null) {
1568 return new String
[0][];
1571 String
[][] result
= new String
[queryResult
.length
][2];
1573 for (int i
= 0; i
< queryResult
.length
; i
++) {
1574 FvImagesDocument
.FvImages
.NameValue item
= (FvImagesDocument
.FvImages
.NameValue
)queryResult
[i
];
1575 result
[i
][0] = item
.getName();
1576 result
[i
][1] = item
.getValue();
1582 * Retrieve FV image component options
1587 * @returns name/value pairs list if elements are found at the known xpath
1588 * @returns empty list if nothing is there
1590 public String
[][] getFpdComponents(String fvName
) {
1591 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName
+ "']/FvImageOptions" };
1592 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1593 if (queryResult
== null) {
1594 return new String
[0][];
1597 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1598 for (int i
= 0; i
< queryResult
.length
; i
++) {
1599 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1600 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1601 Iterator iter
= namevalues
.iterator();
1602 while (iter
.hasNext()) {
1603 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1605 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1608 String
[][] result
= new String
[list
.size()][2];
1609 for (int i
= 0; i
< list
.size(); i
++) {
1610 result
[i
][0] = list
.get(i
)[0];
1611 result
[i
][1] = list
.get(i
)[1];
1617 * Retrieve PCD tokens
1619 * @returns CName/ItemType pairs list if elements are found at the known
1621 * @returns null if nothing is there
1623 public String
[][] getPcdTokenArray() {
1624 String
[] xPath
= new String
[] { "/PcdData" };
1626 Object
[] returns
= get("PCDs", xPath
);
1627 if (returns
== null || returns
.length
== 0) {
1635 * Retrieve MAS header
1640 public ModuleIdentification
getMsaHeader() {
1641 String
[] xPath
= new String
[] { "/" };
1642 Object
[] returns
= get("MsaHeader", xPath
);
1644 if (returns
== null || returns
.length
== 0) {
1648 MsaHeader msaHeader
= (MsaHeader
) returns
[0];
1650 // Get BaseName, ModuleType, GuidValue, Version
1651 // which in MsaHeader.
1653 String name
= msaHeader
.getModuleName();
1654 String moduleType
= msaHeader
.getModuleType().toString();
1655 String guid
= msaHeader
.getGuidValue();
1656 String version
= msaHeader
.getVersion();
1658 ModuleIdentification moduleId
= new ModuleIdentification(name
, guid
,
1661 moduleId
.setModuleType(moduleType
);
1667 * Retrieve Extern Specification
1671 * @return String[] If have specification element in the <extern> String[0]
1672 * If no specification element in the <extern>
1676 public String
[] getExternSpecificaiton() {
1677 String
[] xPath
= new String
[] { "/Specification" };
1679 Object
[] queryResult
= get("Externs", xPath
);
1680 if (queryResult
== null) {
1681 return new String
[0];
1684 String
[] specificationList
= new String
[queryResult
.length
];
1685 for (int i
= 0; i
< queryResult
.length
; i
++) {
1686 specificationList
[i
] = ((Sentence
)queryResult
[i
])
1689 return specificationList
;
1693 * Retreive MsaFile which in SPD
1696 * @return String[][3] The string sequence is ModuleName, ModuleGuid,
1697 * ModuleVersion, MsaFile String[0][] If no msafile in SPD
1699 public String
[] getSpdMsaFile() {
1700 String
[] xPath
= new String
[] { "/MsaFiles" };
1702 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1703 if (returns
== null) {
1704 return new String
[0];
1707 List
<String
> filenameList
= ((MsaFilesDocument
.MsaFiles
) returns
[0])
1709 return filenameList
.toArray(new String
[filenameList
.size()]);
1715 public Map
<String
, String
[]> getSpdLibraryClasses() {
1716 String
[] xPath
= new String
[] { "/LibraryClassDeclarations/LibraryClass" };
1718 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1721 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
1723 Map
<String
, String
[]> libClassHeaderMap
= new HashMap
<String
, String
[]>();
1725 if (returns
== null) {
1726 return libClassHeaderMap
;
1729 for (int i
= 0; i
< returns
.length
; i
++) {
1730 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass library
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) returns
[i
];
1731 libClassHeaderMap
.put(library
.getName(), new String
[] { library
1732 .getIncludeHeader() });
1734 return libClassHeaderMap
;
1740 public Map
<String
, String
> getSpdPackageHeaderFiles() {
1741 String
[] xPath
= new String
[] { "/PackageHeaders/IncludePkgHeader" };
1743 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1746 // Create Map, Key - ModuleType, String - PackageInclude Header file.
1748 Map
<String
, String
> packageIncludeMap
= new HashMap
<String
, String
>();
1750 if (returns
== null) {
1751 return packageIncludeMap
;
1754 for (int i
= 0; i
< returns
.length
; i
++) {
1755 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader includeHeader
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) returns
[i
];
1756 packageIncludeMap
.put(includeHeader
.getModuleType().toString(),
1757 includeHeader
.getStringValue());
1759 return packageIncludeMap
;
1762 public PackageIdentification
getSpdHeader() {
1763 String
[] xPath
= new String
[] { "/SpdHeader" };
1765 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1767 if (returns
== null || returns
.length
== 0) {
1771 SpdHeaderDocument
.SpdHeader header
= (SpdHeaderDocument
.SpdHeader
) returns
[0];
1773 String name
= header
.getPackageName();
1775 String guid
= header
.getGuidValue();
1777 String version
= header
.getVersion();
1779 return new PackageIdentification(name
, guid
, version
);
1785 public Map
<String
, String
[]> getSpdGuid() {
1786 String
[] xPath
= new String
[] { "/GuidDeclarations/Entry" };
1788 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1791 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
1793 Map
<String
, String
[]> guidDeclMap
= new HashMap
<String
, String
[]>();
1794 if (returns
== null) {
1798 for (int i
= 0; i
< returns
.length
; i
++) {
1799 GuidDeclarationsDocument
.GuidDeclarations
.Entry entry
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) returns
[i
];
1800 String
[] guidPair
= new String
[2];
1801 guidPair
[0] = entry
.getCName();
1802 guidPair
[1] = entry
.getGuidValue();
1803 guidDeclMap
.put(entry
.getCName(), guidPair
);
1804 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1805 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[0]);
1806 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[1]);
1814 public Map
<String
, String
[]> getSpdProtocol() {
1815 String
[] xPath
= new String
[] { "/ProtocolDeclarations/Entry" };
1817 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1820 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1822 Map
<String
, String
[]> protoclMap
= new HashMap
<String
, String
[]>();
1824 if (returns
== null) {
1828 for (int i
= 0; i
< returns
.length
; i
++) {
1829 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry entry
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) returns
[i
];
1830 String
[] protocolPair
= new String
[2];
1832 protocolPair
[0] = entry
.getCName();
1833 protocolPair
[1] = entry
.getGuidValue();
1834 protoclMap
.put(entry
.getCName(), protocolPair
);
1835 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1836 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[0]);
1837 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[1]);
1843 * getSpdPpi() Retrieve the SPD PPI Entry
1846 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
1847 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
1850 public Map
<String
, String
[]> getSpdPpi() {
1851 String
[] xPath
= new String
[] { "/PpiDeclarations/Entry" };
1853 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1856 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1858 Map
<String
, String
[]> ppiMap
= new HashMap
<String
, String
[]>();
1860 if (returns
== null) {
1864 for (int i
= 0; i
< returns
.length
; i
++) {
1865 PpiDeclarationsDocument
.PpiDeclarations
.Entry entry
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) returns
[i
];
1866 String
[] ppiPair
= new String
[2];
1867 ppiPair
[0] = entry
.getCName();
1868 ppiPair
[1] = entry
.getGuidValue();
1869 ppiMap
.put(entry
.getCName(), ppiPair
);
1875 * Retrieve module Guid string
1877 * @returns GUILD string if elements are found at the known xpath
1878 * @returns null if nothing is there
1880 public String
getModuleGuid() {
1881 String
[] xPath
= new String
[] { "" };
1883 Object
[] returns
= get("MsaHeader", xPath
);
1884 if (returns
!= null && returns
.length
> 0) {
1885 String guid
= ((MsaHeaderDocument
.MsaHeader
) returns
[0])
1896 public ModuleSADocument
.ModuleSA
[] getFpdModuleSAs() {
1897 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1898 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1899 if (result
!= null) {
1900 return (ModuleSADocument
.ModuleSA
[]) result
;
1902 return new ModuleSADocument
.ModuleSA
[0];
1906 Get name array of PCD in a module. In one module, token space
1907 is same, and token name should not be conflicted.
1911 public String
[] getModulePcdEntryNameArray() {
1912 PcdCodedDocument
.PcdCoded
.PcdEntry
[] pcdEntries
= null;
1915 String
[] xPath
= new String
[] {"/PcdEntry"};
1916 Object
[] returns
= get ("PcdCoded", xPath
);
1918 if (returns
== null) {
1919 return new String
[0];
1922 pcdEntries
= (PcdCodedDocument
.PcdCoded
.PcdEntry
[])returns
;
1923 results
= new String
[pcdEntries
.length
];
1925 for (index
= 0; index
< pcdEntries
.length
; index
++) {
1926 results
[index
] = pcdEntries
[index
].getCName();
1932 Search in a List for a given string
1936 public boolean contains(List list
, String str
) {
1937 if (list
== null || list
.size()== 0) {
1940 Iterator it
= list
.iterator();
1941 while (it
.hasNext()) {
1942 String s
= (String
)it
.next();
1943 if (s
.equalsIgnoreCase(str
)) {
1951 public boolean isHaveTianoR8FlashMap(){
1952 String
[] xPath
= new String
[] {"/"};
1953 Object
[] returns
= get ("Externs", xPath
);
1955 if (returns
== null) {
1959 ExternsDocument
.Externs ext
= (ExternsDocument
.Externs
)returns
[0];
1961 if (ext
.getTianoR8FlashMapH()){