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
.tianocore
.ExternsDocument
.Externs
.Extern
;
27 import org
.apache
.xmlbeans
.XmlObject
;
28 import org
.apache
.xmlbeans
.XmlString
;
29 import org
.tianocore
.*;
30 import org
.tianocore
.FilenameDocument
.Filename
;
31 import org
.tianocore
.MsaHeaderDocument
.MsaHeader
;
32 import org
.tianocore
.ProtocolsDocument
.Protocols
.Protocol
;
33 import org
.tianocore
.ProtocolsDocument
.Protocols
.ProtocolNotify
;
34 import org
.tianocore
.build
.autogen
.CommonDefinition
;
35 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
36 import org
.tianocore
.build
.id
.ModuleIdentification
;
37 import org
.tianocore
.build
.id
.PackageIdentification
;
38 import org
.tianocore
.build
.id
.PlatformIdentification
;
39 import org
.tianocore
.build
.toolchain
.ToolChainInfo
;
40 import org
.tianocore
.common
.exception
.EdkException
;
41 import org
.tianocore
.common
.logger
.EdkLog
;
42 import org
.w3c
.dom
.Node
;
45 * SurfaceAreaQuery class is used to query Surface Area information from msa,
46 * mbd, spd and fpd files.
48 * This class should not instantiated. All the public interfaces is static.
52 public class SurfaceAreaQuery
{
54 public String prefix
= "http://www.TianoCore.org/2006/Edk2.0";
57 // Contains name/value pairs of Surface Area document object. The name is
58 // always the top level element name.
60 private Map
<String
, XmlObject
> map
= null;
63 // mapStack is used to do nested query
65 private Stack
<Map
<String
, XmlObject
>> mapStack
= new Stack
<Map
<String
, XmlObject
>>();
68 // prefix of name space
70 private String nsPrefix
= "sans";
73 // xmlbeans needs a name space for each Xpath element
75 private String ns
= null;
78 // keep the namep declaration for xmlbeans Xpath query
80 private String queryDeclaration
= null;
82 private StringBuffer normQueryString
= new StringBuffer(4096);
83 private Pattern xPathPattern
= Pattern
.compile("([^/]*)(/|//)([^/]+)");
86 * Set a Surface Area document for query later
89 * A Surface Area document in TopLevelElementName/XmlObject
92 public SurfaceAreaQuery(Map
<String
, XmlObject
> map
) {
94 queryDeclaration
= "declare namespace " + nsPrefix
+ "='" + ns
+ "'; ";
99 * Push current used Surface Area document into query stack. The given new
100 * document will be used for any immediately followed getXXX() callings,
101 * untill pop() is called.
104 * The TopLevelElementName/XmlObject format of a Surface Area
107 public void push(Map
<String
, XmlObject
> newMap
) {
108 mapStack
.push(this.map
);
113 * Discard current used Surface Area document and use the top document in
117 this.map
= mapStack
.pop();
121 // / Convert xPath to be namespace qualified, which is necessary for
123 // / selectPath(). For example, converting /MsaHeader/ModuleType to
124 // / /ns:MsaHeader/ns:ModuleType
126 private String
normalizeQueryString(String
[] exp
, String from
) {
127 normQueryString
.setLength(0);
130 while (i
< exp
.length
) {
131 String newExp
= from
+ exp
[i
];
132 Matcher matcher
= xPathPattern
.matcher(newExp
);
134 while (matcher
.find()) {
135 String starter
= newExp
.substring(matcher
.start(1), matcher
137 String seperator
= newExp
.substring(matcher
.start(2), matcher
139 String token
= newExp
.substring(matcher
.start(3), matcher
142 normQueryString
.append(starter
);
143 normQueryString
.append(seperator
);
144 normQueryString
.append(nsPrefix
);
145 normQueryString
.append(":");
146 normQueryString
.append(token
);
150 if (i
< exp
.length
) {
151 normQueryString
.append(" | ");
155 return normQueryString
.toString();
159 * Search all XML documents stored in "map" for the specified xPath, using
160 * relative path (starting with '$this')
163 * xpath query string array
164 * @returns An array of XmlObject if elements are found at the specified
166 * @returns NULL if nothing is at the specified xpath
168 public Object
[] get(String
[] xPath
) {
173 String
[] keys
= (String
[]) map
.keySet().toArray(new String
[map
.size()]);
174 List
<Object
> result
= new ArrayList
<Object
>();
175 for (int i
= 0; i
< keys
.length
; ++i
) {
176 XmlObject rootNode
= (XmlObject
) map
.get(keys
[i
]);
177 if (rootNode
== null) {
181 String query
= queryDeclaration
182 + normalizeQueryString(xPath
, "$this/" + keys
[i
]);
183 XmlObject
[] tmp
= rootNode
.selectPath(query
);
184 for (int j
= 0; j
< tmp
.length
; ++j
) {
185 result
.add((Object
)tmp
[j
]);
189 int size
= result
.size();
194 return (Object
[]) result
.toArray(new Object
[size
]);
198 * Search XML documents named by "rootName" for the given xPath, using
199 * relative path (starting with '$this')
202 * The top level element name
204 * The xpath query string array
205 * @returns An array of XmlObject if elements are found at the given xpath
206 * @returns NULL if nothing is found at the given xpath
208 public Object
[] get(String rootName
, String
[] xPath
) {
213 XmlObject root
= (XmlObject
) map
.get(rootName
);
218 String query
= queryDeclaration
219 + normalizeQueryString(xPath
, "$this/" + rootName
);
220 XmlObject
[] result
= root
.selectPath(query
);
221 if (result
.length
> 0) {
222 return (Object
[])result
;
225 query
= queryDeclaration
+ normalizeQueryString(xPath
, "/" + rootName
);
226 result
= root
.selectPath(query
);
227 if (result
.length
> 0) {
228 return (Object
[])result
;
235 * Retrieve SourceFiles/Filename for specified ARCH type
239 * @returns An 2 dimension string array if elements are found at the known
241 * @returns NULL if nothing is found at the known xpath
243 public String
[][] getSourceFiles(String arch
) {
247 xPath
= new String
[] { "/Filename" };
249 returns
= get("SourceFiles", xPath
);
251 if (returns
== null || returns
.length
== 0) {
252 return new String
[0][0];
255 Filename
[] sourceFileNames
= (Filename
[]) returns
;
256 List
<String
[]> outputList
= new ArrayList
<String
[]>();
257 for (int i
= 0; i
< sourceFileNames
.length
; i
++) {
258 List archList
= sourceFileNames
[i
].getSupArchList();
259 if (arch
== null || arch
.equalsIgnoreCase("") || archList
== null || contains(archList
, arch
)) {
260 outputList
.add(new String
[] {sourceFileNames
[i
].getToolCode(),sourceFileNames
[i
].getStringValue()});
264 String
[][] outputString
= new String
[outputList
.size()][2];
265 for (int index
= 0; index
< outputList
.size(); index
++) {
266 outputString
[index
][0] = outputList
.get(index
)[0];
267 outputString
[index
][1] = outputList
.get(index
)[1];
273 * Retrieve /PlatformDefinitions/OutputDirectory from FPD
275 * @returns Directory names array if elements are found at the known xpath
276 * @returns Empty if nothing is found at the known xpath
278 public String
getFpdOutputDirectory() {
279 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
281 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
282 if (returns
== null || returns
.length
== 0) {
285 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
286 return item
.getOutputDirectory();
289 public String
getFpdIntermediateDirectories() {
290 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
292 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
293 if (returns
== null || returns
.length
== 0) {
296 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
297 if(item
.getIntermediateDirectories() == null) {
301 return item
.getIntermediateDirectories().toString();
305 public String
getModuleFfsKeyword() {
306 String
[] xPath
= new String
[] { "/" };
308 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
309 if (returns
== null || returns
.length
== 0) {
312 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
313 return item
.getFfsFormatKey();
316 public String
getModuleFvBindingKeyword() {
317 String
[] xPath
= new String
[] { "/" };
319 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
320 if (returns
== null || returns
.length
== 0) {
323 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
324 return item
.getFvBinding();
327 public List
getModuleSupportedArchs() {
328 String
[] xPath
= new String
[] { "/" };
330 Object
[] returns
= get("ModuleDefinitions", xPath
);
331 if (returns
== null || returns
.length
== 0) {
334 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
335 return item
.getSupportedArchitectures();
338 public BuildOptionsDocument
.BuildOptions
.Ffs
[] getFpdFfs() {
339 String
[] xPath
= new String
[] {"/Ffs"};
341 Object
[] returns
= get("BuildOptions", xPath
);
342 if (returns
== null || returns
.length
== 0) {
343 return new BuildOptionsDocument
.BuildOptions
.Ffs
[0];
345 return (BuildOptionsDocument
.BuildOptions
.Ffs
[])returns
;
348 public String
getModuleOutputFileBasename() {
349 String
[] xPath
= new String
[] { "/" };
351 Object
[] returns
= get("ModuleDefinitions", xPath
);
352 if (returns
== null || returns
.length
== 0) {
355 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
356 return item
.getOutputFileBasename();
360 * Retrieve BuildOptions/Option or Arch/Option
362 * @param toolChainFamilyFlag
363 * if true, retrieve options for toolchain family; otherwise for
366 * @returns String[][5] name, target, toolchain, arch, coommand of options
367 * if elements are found at the known xpath. String[0][] if dont
370 * @returns Empty array if nothing is there
372 public String
[][] getOptions(String from
, String
[] xPath
, boolean toolChainFamilyFlag
) {
373 String target
= null;
374 String toolchain
= null;
375 String toolchainFamily
= null;
376 List
<String
> archList
= null;
378 String optionName
= null;
380 Object
[] returns
= get(from
, xPath
);
381 if (returns
== null) {
382 return new String
[0][5];
385 List
<String
[]> optionList
= new ArrayList
<String
[]>();
386 OptionDocument
.Option option
;
388 for (int i
= 0; i
< returns
.length
; i
++) {
389 option
= (OptionDocument
.Option
) returns
[i
];
392 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
394 // put to result[][5] array in above order.
397 if (option
.getBuildTargets() == null) {
401 target
= option
.getBuildTargets().toString();
403 if (target
!= null) {
404 targetList
= target
.split(" ");
406 targetList
= new String
[1];
407 targetList
[0] = null;
410 if (toolChainFamilyFlag
) {
411 toolchainFamily
= option
.getToolChainFamily();
412 if (toolchainFamily
!= null) {
413 toolchain
= toolchainFamily
.toString();
418 toolchain
= option
.getTagName();
421 archList
= new ArrayList
<String
>();
422 List archEnumList
= option
.getSupArchList();
423 if (archEnumList
== null) {
426 //archList.addAll(archEnumList);
427 Iterator it
= archEnumList
.iterator();
428 while (it
.hasNext()) {
429 String archType
= (String
)it
.next();
430 archList
.add(archType
);
434 cmd
= option
.getToolCode();
436 optionName
= option
.getStringValue();
437 for (int t
= 0; t
< targetList
.length
; t
++) {
438 for (int j
= 0; j
< archList
.size(); j
++) {
439 optionList
.add(new String
[] { targetList
[t
],
440 toolchain
, archList
.get(j
), cmd
, optionName
});
445 String
[][] result
= new String
[optionList
.size()][5];
446 for (int i
= 0; i
< optionList
.size(); i
++) {
447 result
[i
][0] = optionList
.get(i
)[0];
448 result
[i
][1] = optionList
.get(i
)[1];
449 result
[i
][2] = optionList
.get(i
)[2];
450 result
[i
][3] = optionList
.get(i
)[3];
451 result
[i
][4] = optionList
.get(i
)[4];
456 public String
[][] getModuleBuildOptions(boolean toolChainFamilyFlag
) {
459 if (toolChainFamilyFlag
== true) {
460 xPath
= new String
[] {
461 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
462 "/Options/Option[@ToolChainFamily]", };
464 xPath
= new String
[] {
465 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
466 "/Options/Option[@TagName]", };
468 return getOptions("ModuleSaBuildOptions", xPath
, toolChainFamilyFlag
);
471 public String
[][] getPlatformBuildOptions(boolean toolChainFamilyFlag
) {
474 if (toolChainFamilyFlag
== true) {
475 xPath
= new String
[] {
476 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
477 "/BuildOptions/Options/Option[@ToolChainFamily]", };
479 xPath
= new String
[] {
480 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
481 "/BuildOptions/Options/Option[@TagName]", };
484 return getOptions("PlatformSurfaceArea", xPath
, toolChainFamilyFlag
);
487 public ToolChainInfo
getFpdToolChainInfo() {
488 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
490 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
491 if (returns
== null || returns
.length
== 0) {
495 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
496 ToolChainInfo toolChainInfo
= new ToolChainInfo();
497 toolChainInfo
.addTargets(item
.getBuildTargets().toString());
498 toolChainInfo
.addArchs(item
.getSupportedArchitectures().toString());
499 toolChainInfo
.addTagnames((String
)null);
500 return toolChainInfo
;
504 * Retrieve <xxxHeader>/ModuleType
506 * @returns The module type name if elements are found at the known xpath
507 * @returns null if nothing is there
509 public String
getModuleType() {
510 String
[] xPath
= new String
[] { "/ModuleType" };
512 Object
[] returns
= get(xPath
);
513 if (returns
!= null && returns
.length
> 0) {
514 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
515 return type
.enumValue().toString();
522 * Retrieve PackageDependencies/Package
527 * @returns package name list if elements are found at the known xpath
528 * @returns null if nothing is there
530 public PackageIdentification
[] getDependencePkg(String arch
) throws EdkException
{
532 String packageGuid
= null;
533 String packageVersion
= null;
536 xPath
= new String
[] { "/Package" };
538 Object
[] returns
= get("PackageDependencies", xPath
);
539 if (returns
== null) {
540 return new PackageIdentification
[0];
544 // Get packageIdentification
546 List
<PackageIdentification
> packageIdList
= new ArrayList
<PackageIdentification
>();
547 for (int i
= 0; i
< returns
.length
; i
++) {
548 PackageDependenciesDocument
.PackageDependencies
.Package item
= (PackageDependenciesDocument
.PackageDependencies
.Package
) returns
[i
];
549 List archList
= item
.getSupArchList();
550 if (arch
== null || archList
== null || contains(archList
, arch
)) {
551 packageGuid
= item
.getPackageGuid();
552 packageVersion
= item
.getPackageVersion();
553 PackageIdentification pkgId
= new PackageIdentification(null, packageGuid
, packageVersion
);
554 GlobalData
.refreshPackageIdentification(pkgId
);
555 packageIdList
.add(pkgId
);
559 return packageIdList
.toArray(new PackageIdentification
[packageIdList
.size()]);
563 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
566 * Library class usage
568 * @returns LibraryClass objects list if elements are found at the known
570 * @returns null if nothing is there
572 public String
[] getLibraryClasses(String usage
, String arch
) {
574 if (usage
== null || usage
.equals("")) {
575 xPath
= new String
[] { "/LibraryClass" };
577 xPath
= new String
[] { "/LibraryClass[@Usage='" + usage
+ "']" };
580 Object
[] returns
= get("LibraryClassDefinitions", xPath
);
581 if (returns
== null || returns
.length
== 0) {
582 return new String
[0];
585 LibraryClassDocument
.LibraryClass
[] libraryClassList
= (LibraryClassDocument
.LibraryClass
[]) returns
;
586 List
<String
> libraryClassName
= new ArrayList
<String
>();
587 for (int i
= 0; i
< libraryClassList
.length
; i
++) {
588 List archList
= libraryClassList
[i
].getSupArchList();
590 if (arch
== null || contains(archList
, arch
)) {
591 libraryClassName
.add(libraryClassList
[i
].getKeyword());
595 String
[] libraryArray
= new String
[libraryClassName
.size()];
596 libraryClassName
.toArray(libraryArray
);
601 * Retrieve ModuleEntryPoint names
603 * @returns ModuleEntryPoint name list if elements are found at the known
605 * @returns null if nothing is there
607 public String
[] getModuleEntryPointArray() {
608 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
610 Object
[] returns
= get("Externs", xPath
);
612 if (returns
!= null && returns
.length
> 0) {
613 String
[] entryPoints
= new String
[returns
.length
];
615 for (int i
= 0; i
< returns
.length
; ++i
) {
616 entryPoints
[i
] = ((CNameType
) returns
[i
]).getStringValue();
626 * retrieve Protocol for specified usage
629 * Protocol usage arch Architecture
631 * @returns Protocol String list if elements are found at the known xpath
632 * @returns String[0] if nothing is there
634 public String
[] getProtocolArray(String arch
, String usage
) {
636 String usageXpath
= "";
637 String archXpath
= "";
639 if (arch
== null || arch
.equals("")) {
640 return new String
[0];
642 archXpath
= "/Protocol";
643 if (usage
!= null && !usage
.equals("")) {
644 usageXpath
= "/Protocol[@Usage='" + usage
+ "']";
645 xPath
= new String
[] { usageXpath
, archXpath
};
647 return getProtocolArray(arch
);
652 Object
[] returns
= get("Protocols", xPath
);
653 if (returns
== null) {
654 return new String
[0];
656 Protocol
[] protocolList
= (Protocol
[]) returns
;
658 String
[] protocolArray
= new String
[returns
.length
];
659 for (int i
= 0; i
< returns
.length
; i
++) {
660 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
662 return protocolArray
;
666 * retrieve Protocol for specified usage
671 * @returns Protocol String list if elements are found at the known xpath
672 * @returns String[0] if nothing is there
674 public String
[] getProtocolArray(String arch
) {
677 if (arch
== null || arch
.equals("")) {
678 return new String
[0];
680 xPath
= new String
[] { "/Protocol" };
683 Object
[] returns
= get("Protocols", xPath
);
684 if (returns
== null) {
685 return new String
[0];
687 Protocol
[] returnlList
= (Protocol
[]) returns
;
689 List
<String
> protocolList
= new ArrayList
<String
>();
691 for (int i
= 0; i
< returns
.length
; i
++) {
692 List archList
= returnlList
[i
].getSupArchList();
693 if (archList
== null || contains(archList
, arch
)){
694 protocolList
.add(returnlList
[i
].getProtocolCName());
697 String
[] protocolArray
= new String
[protocolList
.size()];
698 for (int i
= 0; i
< protocolList
.size(); i
++) {
699 protocolArray
[i
] = protocolList
.get(i
);
701 return protocolArray
;
705 * Retrieve ProtocolNotify for specified usage
708 * ProtocolNotify usage
710 * @returns String[] if elements are found at the known xpath
711 * @returns String[0] if nothing is there
713 public String
[] getProtocolNotifyArray(String arch
) {
716 if (arch
== null || arch
.equals("")) {
717 return new String
[0];
719 xPath
= new String
[] { "/ProtocolNotify" };
722 Object
[] returns
= get("Protocols", xPath
);
723 if (returns
== null) {
724 return new String
[0];
727 List
<String
> protocolNotifyList
= new ArrayList
<String
>();
729 for (int i
= 0; i
< returns
.length
; i
++) {
730 List archList
= ((ProtocolNotify
) returns
[i
]).getSupArchList();
731 if (archList
== null || contains(archList
, arch
)){
732 protocolNotifyList
.add(((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName());
736 String
[] protocolNotifyArray
= new String
[protocolNotifyList
.size()];
737 for (int i
= 0; i
< protocolNotifyList
.size(); i
++) {
738 protocolNotifyArray
[i
] = protocolNotifyList
.get(i
);
740 return protocolNotifyArray
;
744 * Retrieve ProtocolNotify for specified usage
747 * ProtocolNotify usage
749 * @returns String[] if elements are found at the known xpath
750 * @returns String[0] if nothing is there
752 public String
[] getProtocolNotifyArray(String arch
, String usage
) {
758 if (arch
== null || arch
.equals("")) {
759 return new String
[0];
761 archXpath
= "/ProtocolNotify";
762 if (usage
!= null && !usage
.equals("")) {
763 usageXpath
= "/ProtocolNotify[@Usage='" + arch
+ "']";
764 xPath
= new String
[] { archXpath
, usageXpath
};
766 return getProtocolNotifyArray(arch
);
770 Object
[] returns
= get("Protocols", xPath
);
771 if (returns
== null) {
772 return new String
[0];
775 String
[] protocolNotifyList
= new String
[returns
.length
];
777 for (int i
= 0; i
< returns
.length
; i
++) {
778 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
780 return protocolNotifyList
;
784 * Retrieve ModuleUnloadImage names
786 * @returns ModuleUnloadImage name list if elements are found at the known
788 * @returns null if nothing is there
790 public String
[] getModuleUnloadImageArray() {
791 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
793 Object
[] returns
= get("Externs", xPath
);
794 if (returns
!= null && returns
.length
> 0) {
795 String
[] stringArray
= new String
[returns
.length
];
796 CNameType
[] doc
= (CNameType
[]) returns
;
798 for (int i
= 0; i
< returns
.length
; ++i
) {
799 stringArray
[i
] = doc
[i
].getStringValue();
811 * @returns Extern objects list if elements are found at the known xpath
812 * @returns null if nothing is there
814 public ExternsDocument
.Externs
.Extern
[] getExternArray() {
815 String
[] xPath
= new String
[] { "/Extern" };
817 Object
[] returns
= get("Externs", xPath
);
818 if (returns
!= null && returns
.length
> 0) {
819 return (ExternsDocument
.Externs
.Extern
[]) returns
;
826 * Retrieve PpiNotify for specified arch
831 * @returns String[] if elements are found at the known xpath
832 * @returns String[0] if nothing is there
834 public String
[] getPpiNotifyArray(String arch
) {
837 if (arch
== null || arch
.equals("")) {
838 return new String
[0];
840 xPath
= new String
[] { "/PpiNotify" };
843 Object
[] returns
= get("PPIs", xPath
);
844 if (returns
== null) {
845 return new String
[0];
849 List
<String
> ppiNotifyList
= new ArrayList
<String
>();
850 for (int i
= 0; i
< returns
.length
; i
++) {
851 List archList
= ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getSupArchList();
852 if (archList
== null || contains(archList
, arch
)){
853 ppiNotifyList
.add(((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName());
857 String
[] ppiNotifyArray
= new String
[ppiNotifyList
.size()];
858 for (int i
= 0; i
< ppiNotifyList
.size(); i
++) {
859 ppiNotifyArray
[i
] = ppiNotifyList
.get(i
);
862 return ppiNotifyArray
;
866 * Retrieve PpiNotify for specified usage and arch
869 * PpiNotify arch usage PpiNotify usage
872 * @returns String[] if elements are found at the known xpath
873 * @returns String[0] if nothing is there
875 public String
[] getPpiNotifyArray(String arch
, String usage
) {
881 if (arch
== null || arch
.equals("")) {
882 return new String
[0];
884 archXpath
= "/PpiNotify";
885 if (usage
!= null && !usage
.equals("")) {
886 usageXpath
= "/PpiNotify[@Usage='" + arch
+ "']";
887 xPath
= new String
[] { archXpath
, usageXpath
};
889 return getProtocolNotifyArray(arch
);
893 Object
[] returns
= get("PPIs", xPath
);
894 if (returns
== null) {
895 return new String
[0];
898 String
[] ppiNotifyList
= new String
[returns
.length
];
900 for (int i
= 0; i
< returns
.length
; i
++) {
901 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
903 return ppiNotifyList
;
907 * Retrieve Ppi for specified arch
912 * @returns String[] if elements are found at the known xpath
913 * @returns String[0] if nothing is there
915 public String
[] getPpiArray(String arch
) {
918 if (arch
== null || arch
.equals("")) {
919 return new String
[0];
921 xPath
= new String
[] { "/Ppi" };
924 Object
[] returns
= get("PPIs", xPath
);
925 if (returns
== null) {
926 return new String
[0];
929 List
<String
> ppiList
= new ArrayList
<String
>();
930 for (int i
= 0; i
< returns
.length
; i
++) {
931 List archList
= ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getSupArchList();
932 if (archList
== null || contains(archList
, arch
)){
933 ppiList
.add(((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName());
937 String
[] ppiArray
= new String
[ppiList
.size()];
938 for (int i
= 0; i
< ppiList
.size(); i
++) {
939 ppiArray
[i
] = ppiList
.get(i
);
945 * Retrieve PpiNotify for specified usage and arch
948 * PpiNotify arch usage PpiNotify usage
951 * @returns String[] if elements are found at the known xpath
952 * @returns String[0] if nothing is there
954 public String
[] getPpiArray(String arch
, String usage
) {
960 if (arch
== null || arch
.equals("")) {
961 return new String
[0];
964 if (usage
!= null && !usage
.equals("")) {
965 usageXpath
= "/Ppi[@Usage='" + arch
+ "']";
966 xPath
= new String
[] { archXpath
, usageXpath
};
968 return getProtocolNotifyArray(arch
);
972 Object
[] returns
= get("PPIs", xPath
);
973 if (returns
== null) {
974 return new String
[0];
977 String
[] ppiList
= new String
[returns
.length
];
979 for (int i
= 0; i
< returns
.length
; i
++) {
980 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
986 * Retrieve GuidEntry information for specified usage
991 * @returns GuidEntry objects list if elements are found at the known xpath
992 * @returns null if nothing is there
994 public String
[] getGuidEntryArray(String arch
) {
997 if (arch
== null || arch
.equals("")) {
998 xPath
= new String
[] { "/GuidCNames" };
1000 xPath
= new String
[] { "/GuidCNames" };
1003 Object
[] returns
= get("Guids", xPath
);
1004 if (returns
== null) {
1005 return new String
[0];
1008 List
<String
> guidList
= new ArrayList
<String
>();
1009 for (int i
= 0; i
< returns
.length
; i
++) {
1010 List archList
= ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getSupArchList();
1011 if (archList
== null || contains(archList
, arch
)){
1012 guidList
.add(((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName());
1016 String
[] guidArray
= new String
[guidList
.size()];
1017 for (int i
= 0; i
< guidList
.size(); i
++) {
1018 guidArray
[i
] = guidList
.get(i
);
1025 * Retrieve GuidEntry information for specified usage
1028 * GuidEntry arch usage GuidEntry usage
1030 * @returns GuidEntry objects list if elements are found at the known xpath
1031 * @returns null if nothing is there
1033 public String
[] getGuidEntryArray(String arch
, String usage
) {
1038 if (arch
== null || arch
.equals("")) {
1039 return new String
[0];
1041 archXpath
= "/GuidEntry";
1042 if (usage
!= null && !usage
.equals("")) {
1043 usageXpath
= "/GuidEntry[@Usage='" + arch
+ "']";
1044 xPath
= new String
[] { archXpath
, usageXpath
};
1046 return getProtocolNotifyArray(arch
);
1050 Object
[] returns
= get("Guids", xPath
);
1051 if (returns
== null) {
1052 return new String
[0];
1055 String
[] guidList
= new String
[returns
.length
];
1057 for (int i
= 0; i
< returns
.length
; i
++) {
1058 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1064 * Retrieve Library instance information
1069 * Library instance usage
1071 * @returns library instance name list if elements are found at the known
1073 * @returns null if nothing is there
1075 public ModuleIdentification
[] getLibraryInstance(String arch
) throws EdkException
{
1077 String saGuid
= null;
1078 String saVersion
= null;
1079 String pkgGuid
= null;
1080 String pkgVersion
= null;
1082 if (arch
== null || arch
.equalsIgnoreCase("")) {
1083 xPath
= new String
[] { "/Instance" };
1086 // Since Schema don't have SupArchList now, so the follow Xpath is
1087 // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]
1088 // don't have effect.
1090 xPath
= new String
[] { "/Instance[not(@SupArchList) or @SupArchList='"
1094 Object
[] returns
= get("Libraries", xPath
);
1095 if (returns
== null || returns
.length
== 0) {
1096 return new ModuleIdentification
[0];
1099 ModuleIdentification
[] saIdList
= new ModuleIdentification
[returns
.length
];
1100 for (int i
= 0; i
< returns
.length
; i
++) {
1101 LibrariesDocument
.Libraries
.Instance library
= (LibrariesDocument
.Libraries
.Instance
) returns
[i
];
1102 saGuid
= library
.getModuleGuid();
1103 saVersion
= library
.getModuleVersion();
1105 pkgGuid
= library
.getPackageGuid();
1106 pkgVersion
= library
.getPackageVersion();
1108 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1110 PackageIdentification pkgId
= new PackageIdentification(null,
1111 pkgGuid
, pkgVersion
);
1112 GlobalData
.refreshPackageIdentification(pkgId
);
1113 saId
.setPackage(pkgId
);
1114 GlobalData
.refreshModuleIdentification(saId
);
1123 // / This method is used for retrieving the elements information which has
1124 // / CName sub-element
1126 private String
[] getCNames(String from
, String xPath
[]) {
1127 Object
[] returns
= get(from
, xPath
);
1128 if (returns
== null || returns
.length
== 0) {
1132 String
[] strings
= new String
[returns
.length
];
1133 for (int i
= 0; i
< returns
.length
; ++i
) {
1135 strings
[i
] = ((CNameType
) returns
[i
]).getStringValue();
1142 * Retrive library's constructor name
1144 * @returns constructor name list if elements are found at the known xpath
1145 * @returns null if nothing is there
1147 public String
getLibConstructorName() {
1148 String
[] xPath
= new String
[] { "/Extern/Constructor" };
1150 Object
[] returns
= get("Externs", xPath
);
1151 if (returns
!= null && returns
.length
> 0) {
1152 CNameType constructor
= ((CNameType
) returns
[0]);
1153 return constructor
.getStringValue();
1160 * Retrive library's destructor name
1162 * @returns destructor name list if elements are found at the known xpath
1163 * @returns null if nothing is there
1165 public String
getLibDestructorName() {
1166 String
[] xPath
= new String
[] { "/Extern/Destructor" };
1168 Object
[] returns
= get("Externs", xPath
);
1169 if (returns
!= null && returns
.length
> 0) {
1171 // Only support one Destructor function.
1173 CNameType destructor
= (CNameType
) returns
[0];
1174 return destructor
.getStringValue();
1181 * Retrive DriverBinding names
1183 * @returns DriverBinding name list if elements are found at the known xpath
1184 * @returns null if nothing is there
1186 public String
[] getDriverBindingArray() {
1187 String
[] xPath
= new String
[] { "/Extern/DriverBinding" };
1188 return getCNames("Externs", xPath
);
1192 * Retrive ComponentName names
1194 * @returns ComponentName name list if elements are found at the known xpath
1195 * @returns null if nothing is there
1197 public String
[] getComponentNameArray() {
1198 String
[] xPath
= new String
[] { "/Extern/ComponentName" };
1199 return getCNames("Externs", xPath
);
1203 * Retrive DriverConfig names
1205 * @returns DriverConfig name list if elements are found at the known xpath
1206 * @returns null if nothing is there
1208 public String
[] getDriverConfigArray() {
1209 String
[] xPath
= new String
[] { "/Extern/DriverConfig" };
1210 return getCNames("Externs", xPath
);
1214 * Retrive DriverDiag names
1216 * @returns DriverDiag name list if elements are found at the known xpath
1217 * @returns null if nothing is there
1219 public String
[] getDriverDiagArray() {
1220 String
[] xPath
= new String
[] { "/Extern/DriverDiag" };
1221 return getCNames("Externs", xPath
);
1225 * Retrive DriverBinding, ComponentName, DriverConfig,
1226 * DriverDiag group array
1228 * @returns DriverBinding group name list if elements are found
1229 * at the known xpath
1230 * @returns null if nothing is there
1232 public String
[][] getExternProtocolGroup() {
1233 String
[] xPath
= new String
[] {"/Extern"};
1234 Object
[] returns
= get("Externs",xPath
);
1236 if (returns
== null) {
1237 return new String
[0][4];
1239 List
<Extern
> externList
= new ArrayList
<Extern
>();
1240 for (int i
= 0; i
< returns
.length
; i
++) {
1241 org
.tianocore
.ExternsDocument
.Externs
.Extern extern
= (org
.tianocore
.ExternsDocument
.Externs
.Extern
)returns
[i
];
1242 if (extern
.getDriverBinding() != null) {
1243 externList
.add(extern
);
1247 String
[][] externGroup
= new String
[externList
.size()][4];
1248 for (int i
= 0; i
< externList
.size(); i
++) {
1249 String driverBindingStr
= externList
.get(i
).getDriverBinding();
1250 if ( driverBindingStr
!= null){
1251 externGroup
[i
][0] = driverBindingStr
;
1253 externGroup
[i
][0] = null;
1256 String componentNameStr
= externList
.get(i
).getComponentName();
1257 if (componentNameStr
!= null) {
1258 externGroup
[i
][1] = componentNameStr
;
1260 externGroup
[i
][1] = null;
1263 String driverConfigStr
= externList
.get(i
).getDriverConfig();
1264 if (driverConfigStr
!= null) {
1265 externGroup
[i
][2] = driverConfigStr
;
1267 externGroup
[i
][2] = null;
1270 String driverDiagStr
= externList
.get(i
).getDriverDiag();
1271 if (driverDiagStr
!= null) {
1272 externGroup
[i
][3] = driverDiagStr
;
1274 externGroup
[i
][3] = null;
1281 * Retrive SetVirtualAddressMapCallBack names
1283 * @returns SetVirtualAddressMapCallBack name list if elements are found at
1285 * @returns null if nothing is there
1287 public String
[] getSetVirtualAddressMapCallBackArray() {
1288 String
[] xPath
= new String
[] { "/Extern/SetVirtualAddressMapCallBack" };
1289 return getCNames("Externs", xPath
);
1293 * Retrive ExitBootServicesCallBack names
1295 * @returns ExitBootServicesCallBack name list if elements are found at the
1297 * @returns null if nothing is there
1299 public String
[] getExitBootServicesCallBackArray() {
1300 String
[] xPath
= new String
[] { "/Extern/ExitBootServicesCallBack" };
1301 return getCNames("Externs", xPath
);
1305 Judge whether current driver is PEI_PCD_DRIVER or DXE_PCD_DRIVER or
1308 @return CommonDefinition.PCD_DRIVER_TYPE the type of current driver
1310 public CommonDefinition
.PCD_DRIVER_TYPE
getPcdDriverType() {
1311 String
[] xPath
= new String
[] {"/PcdIsDriver"};
1312 Object
[] results
= get ("Externs", xPath
);
1314 if (results
!= null && results
.length
!= 0) {
1315 PcdDriverTypes type
= (PcdDriverTypes
) results
[0];
1316 String typeStr
= type
.enumValue().toString();
1317 if (typeStr
.equals(CommonDefinition
.PCD_DRIVER_TYPE
.PEI_PCD_DRIVER
.toString())) {
1318 return CommonDefinition
.PCD_DRIVER_TYPE
.PEI_PCD_DRIVER
;
1319 } else if (typeStr
.equals(CommonDefinition
.PCD_DRIVER_TYPE
.DXE_PCD_DRIVER
.toString())) {
1320 return CommonDefinition
.PCD_DRIVER_TYPE
.DXE_PCD_DRIVER
;
1322 return CommonDefinition
.PCD_DRIVER_TYPE
.UNKNOWN_PCD_DRIVER
;
1325 return CommonDefinition
.PCD_DRIVER_TYPE
.NOT_PCD_DRIVER
;
1329 * Retrieve module surface area file information
1331 * @returns ModuleSA objects list if elements are found at the known xpath
1332 * @returns Empty ModuleSA list if nothing is there
1334 public Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> getFpdModules() throws EdkException
{
1335 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1336 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1338 String fvBinding
= null;
1339 String saGuid
= null;
1340 String saVersion
= null;
1341 String pkgGuid
= null;
1342 String pkgVersion
= null;
1344 Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleMap
= new LinkedHashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
1346 if (result
== null) {
1347 return fpdModuleMap
;
1350 for (int i
= 0; i
< result
.length
; i
++) {
1352 // Get Fpd SA Module element node and add to ObjectMap.
1354 Map
<String
, XmlObject
> ObjectMap
= new HashMap
<String
, XmlObject
>();
1355 ModuleSADocument
.ModuleSA moduleSA
= (ModuleSADocument
.ModuleSA
) result
[i
];
1356 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getLibraries() != null) {
1357 ObjectMap
.put("Libraries", moduleSA
.getLibraries());
1359 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getPcdBuildDefinition() != null) {
1360 ObjectMap
.put("PcdBuildDefinition", moduleSA
.getPcdBuildDefinition());
1362 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getModuleSaBuildOptions() != null) {
1363 ObjectMap
.put("ModuleSaBuildOptions", moduleSA
.getModuleSaBuildOptions());
1367 // Get Fpd SA Module attribute and create FpdMoudleIdentification.
1369 if (moduleSA
.isSetSupArchList()) {
1370 arch
= moduleSA
.getSupArchList().toString();
1377 saVersion
= ((ModuleSADocument
.ModuleSA
) result
[i
]).getModuleVersion();
1379 saGuid
= moduleSA
.getModuleGuid();
1380 pkgGuid
= moduleSA
.getPackageGuid();
1381 pkgVersion
= moduleSA
.getPackageVersion();
1384 // Create Module Identification which have class member of package
1387 PackageIdentification pkgId
= new PackageIdentification(null, pkgGuid
, pkgVersion
);
1388 GlobalData
.refreshPackageIdentification(pkgId
);
1390 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
, saVersion
);
1391 saId
.setPackage(pkgId
);
1392 GlobalData
.refreshModuleIdentification(saId
);
1397 // Create FpdModule Identification which have class member of module
1400 String
[] archList
= new String
[0];
1401 if (arch
== null || arch
.trim().length() == 0) {
1402 archList
= GlobalData
.getToolChainInfo().getArchs();
1404 archList
= arch
.split(" ");
1406 for (int j
= 0; j
< archList
.length
; j
++) {
1407 FpdModuleIdentification fpdSaId
= new FpdModuleIdentification(saId
, archList
[j
]);
1409 if (fvBinding
!= null) {
1410 fpdSaId
.setFvBinding(fvBinding
);
1414 // Put element to Map<FpdModuleIdentification, Map<String,
1417 fpdModuleMap
.put(fpdSaId
, ObjectMap
);
1420 return fpdModuleMap
;
1424 * Retrieve valid image names
1426 * @returns valid iamges name list if elements are found at the known xpath
1427 * @returns empty list if nothing is there
1429 public String
[] getFpdValidImageNames() {
1430 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
1432 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1433 if (queryResult
== null) {
1434 return new String
[0];
1437 String
[] result
= new String
[queryResult
.length
];
1438 for (int i
= 0; i
< queryResult
.length
; i
++) {
1439 result
[i
] = ((XmlString
) queryResult
[i
]).getStringValue();
1445 public Node
getFpdUserExtensionPreBuild() {
1446 String
[] xPath
= new String
[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" };
1448 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1449 if (queryResult
== null || queryResult
.length
== 0) {
1452 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)queryResult
[0];
1454 return a
.getDomNode();
1457 public Node
getFpdUserExtensionPostBuild() {
1458 String
[] xPath
= new String
[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" };
1460 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1461 if (queryResult
== null || queryResult
.length
== 0) {
1464 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)queryResult
[0];
1466 return a
.getDomNode();
1470 * Retrieve FV image option information
1475 * @returns option name/value list if elements are found at the known xpath
1476 * @returns empty list if nothing is there
1478 public String
[][] getFpdOptions(String fvName
) {
1479 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
1480 + fvName
+ "']/FvImageOptions" };
1481 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1482 if (queryResult
== null) {
1483 return new String
[0][];
1485 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1486 for (int i
= 0; i
< queryResult
.length
; i
++) {
1487 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1488 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
1489 .getNameValueList();
1490 Iterator iter
= namevalues
.iterator();
1491 while (iter
.hasNext()) {
1492 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1494 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1497 String
[][] result
= new String
[list
.size()][2];
1498 for (int i
= 0; i
< list
.size(); i
++) {
1499 result
[i
][0] = list
.get(i
)[0];
1500 result
[i
][1] = list
.get(i
)[1];
1506 public XmlObject
getFpdBuildOptions() {
1507 String
[] xPath
= new String
[] { "/BuildOptions" };
1509 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1511 if (queryResult
== null || queryResult
.length
== 0) {
1514 return (XmlObject
)queryResult
[0];
1517 public PlatformIdentification
getFpdHeader() {
1518 String
[] xPath
= new String
[] { "/PlatformHeader" };
1520 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
1522 if (returns
== null || returns
.length
== 0) {
1525 PlatformHeaderDocument
.PlatformHeader header
= (PlatformHeaderDocument
.PlatformHeader
) returns
[0];
1527 String name
= header
.getPlatformName();
1529 String guid
= header
.getGuidValue();
1531 String version
= header
.getVersion();
1533 return new PlatformIdentification(name
, guid
, version
);
1537 * Retrieve FV image attributes information
1542 * @returns attribute name/value list if elements are found at the known
1544 * @returns empty list if nothing is there
1546 public String
[][] getFpdAttributes(String fvName
) {
1547 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
1548 + fvName
+ "']/FvImageOptions" };
1549 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1550 if (queryResult
== null) {
1551 return new String
[0][];
1553 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1554 for (int i
= 0; i
< queryResult
.length
; i
++) {
1556 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1557 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1558 Iterator iter
= namevalues
.iterator();
1559 while (iter
.hasNext()) {
1560 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1562 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1565 String
[][] result
= new String
[list
.size()][2];
1566 for (int i
= 0; i
< list
.size(); i
++) {
1567 result
[i
][0] = list
.get(i
)[0];
1568 result
[i
][1] = list
.get(i
)[1];
1574 * Retrieve flash definition file name
1576 * @returns file name if elements are found at the known xpath
1577 * @returns null if nothing is there
1579 public String
getFlashDefinitionFile() {
1580 String
[] xPath
= new String
[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
1582 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1583 if (queryResult
== null || queryResult
.length
== 0) {
1587 FileNameConvention filename
= (FileNameConvention
) queryResult
[queryResult
.length
- 1];
1588 return filename
.getStringValue();
1591 public String
[][] getFpdGlobalVariable() {
1592 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
1593 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1594 if (queryResult
== null) {
1595 return new String
[0][];
1598 String
[][] result
= new String
[queryResult
.length
][2];
1600 for (int i
= 0; i
< queryResult
.length
; i
++) {
1601 FvImagesDocument
.FvImages
.NameValue item
= (FvImagesDocument
.FvImages
.NameValue
)queryResult
[i
];
1602 result
[i
][0] = item
.getName();
1603 result
[i
][1] = item
.getValue();
1609 * Retrieve FV image component options
1614 * @returns name/value pairs list if elements are found at the known xpath
1615 * @returns empty list if nothing is there
1617 public String
[][] getFpdComponents(String fvName
) {
1618 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName
+ "']/FvImageOptions" };
1619 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1620 if (queryResult
== null) {
1621 return new String
[0][];
1624 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1625 for (int i
= 0; i
< queryResult
.length
; i
++) {
1626 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1627 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1628 Iterator iter
= namevalues
.iterator();
1629 while (iter
.hasNext()) {
1630 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1632 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1635 String
[][] result
= new String
[list
.size()][2];
1636 for (int i
= 0; i
< list
.size(); i
++) {
1637 result
[i
][0] = list
.get(i
)[0];
1638 result
[i
][1] = list
.get(i
)[1];
1644 * Retrieve PCD tokens
1646 * @returns CName/ItemType pairs list if elements are found at the known
1648 * @returns null if nothing is there
1650 public String
[][] getPcdTokenArray() {
1651 String
[] xPath
= new String
[] { "/PcdData" };
1653 Object
[] returns
= get("PCDs", xPath
);
1654 if (returns
== null || returns
.length
== 0) {
1662 * Retrieve MAS header
1667 public ModuleIdentification
getMsaHeader() {
1668 String
[] xPath
= new String
[] { "/" };
1669 Object
[] returns
= get("MsaHeader", xPath
);
1671 if (returns
== null || returns
.length
== 0) {
1675 MsaHeader msaHeader
= (MsaHeader
) returns
[0];
1677 // Get BaseName, ModuleType, GuidValue, Version
1678 // which in MsaHeader.
1680 String name
= msaHeader
.getModuleName();
1681 String moduleType
= msaHeader
.getModuleType().toString();
1682 String guid
= msaHeader
.getGuidValue();
1683 String version
= msaHeader
.getVersion();
1685 ModuleIdentification moduleId
= new ModuleIdentification(name
, guid
,
1688 moduleId
.setModuleType(moduleType
);
1694 * Retrieve Extern Specification
1698 * @return String[] If have specification element in the <extern> String[0]
1699 * If no specification element in the <extern>
1703 public String
[] getExternSpecificaiton() {
1704 String
[] xPath
= new String
[] { "/Specification" };
1706 Object
[] queryResult
= get("Externs", xPath
);
1707 if (queryResult
== null) {
1708 return new String
[0];
1711 String
[] specificationList
= new String
[queryResult
.length
];
1712 for (int i
= 0; i
< queryResult
.length
; i
++) {
1713 specificationList
[i
] = ((Sentence
)queryResult
[i
])
1716 return specificationList
;
1720 * Retreive MsaFile which in SPD
1723 * @return String[][3] The string sequence is ModuleName, ModuleGuid,
1724 * ModuleVersion, MsaFile String[0][] If no msafile in SPD
1726 public String
[] getSpdMsaFile() {
1727 String
[] xPath
= new String
[] { "/MsaFiles" };
1729 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1730 if (returns
== null) {
1731 return new String
[0];
1734 List
<String
> filenameList
= ((MsaFilesDocument
.MsaFiles
) returns
[0])
1736 return filenameList
.toArray(new String
[filenameList
.size()]);
1742 public Map
<String
, String
[]> getSpdLibraryClasses() {
1743 String
[] xPath
= new String
[] { "/LibraryClassDeclarations/LibraryClass" };
1745 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1748 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
1750 Map
<String
, String
[]> libClassHeaderMap
= new HashMap
<String
, String
[]>();
1752 if (returns
== null) {
1753 return libClassHeaderMap
;
1756 for (int i
= 0; i
< returns
.length
; i
++) {
1757 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass library
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) returns
[i
];
1758 libClassHeaderMap
.put(library
.getName(), new String
[] { library
1759 .getIncludeHeader() });
1761 return libClassHeaderMap
;
1767 public Map
<String
, String
> getSpdPackageHeaderFiles() {
1768 String
[] xPath
= new String
[] { "/PackageHeaders/IncludePkgHeader" };
1770 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1773 // Create Map, Key - ModuleType, String - PackageInclude Header file.
1775 Map
<String
, String
> packageIncludeMap
= new HashMap
<String
, String
>();
1777 if (returns
== null) {
1778 return packageIncludeMap
;
1781 for (int i
= 0; i
< returns
.length
; i
++) {
1782 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader includeHeader
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) returns
[i
];
1783 packageIncludeMap
.put(includeHeader
.getModuleType().toString(),
1784 includeHeader
.getStringValue());
1786 return packageIncludeMap
;
1789 public PackageIdentification
getSpdHeader() {
1790 String
[] xPath
= new String
[] { "/SpdHeader" };
1792 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1794 if (returns
== null || returns
.length
== 0) {
1798 SpdHeaderDocument
.SpdHeader header
= (SpdHeaderDocument
.SpdHeader
) returns
[0];
1800 String name
= header
.getPackageName();
1802 String guid
= header
.getGuidValue();
1804 String version
= header
.getVersion();
1806 return new PackageIdentification(name
, guid
, version
);
1812 public Map
<String
, String
[]> getSpdGuid() {
1813 String
[] xPath
= new String
[] { "/GuidDeclarations/Entry" };
1815 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1818 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
1820 Map
<String
, String
[]> guidDeclMap
= new HashMap
<String
, String
[]>();
1821 if (returns
== null) {
1825 for (int i
= 0; i
< returns
.length
; i
++) {
1826 GuidDeclarationsDocument
.GuidDeclarations
.Entry entry
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) returns
[i
];
1827 String
[] guidPair
= new String
[2];
1828 guidPair
[0] = entry
.getCName();
1829 guidPair
[1] = entry
.getGuidValue();
1830 guidDeclMap
.put(entry
.getCName(), guidPair
);
1838 public Map
<String
, String
[]> getSpdProtocol() {
1839 String
[] xPath
= new String
[] { "/ProtocolDeclarations/Entry" };
1841 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1844 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1846 Map
<String
, String
[]> protoclMap
= new HashMap
<String
, String
[]>();
1848 if (returns
== null) {
1852 for (int i
= 0; i
< returns
.length
; i
++) {
1853 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry entry
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) returns
[i
];
1854 String
[] protocolPair
= new String
[2];
1856 protocolPair
[0] = entry
.getCName();
1857 protocolPair
[1] = entry
.getGuidValue();
1858 protoclMap
.put(entry
.getCName(), protocolPair
);
1864 * getSpdPpi() Retrieve the SPD PPI Entry
1867 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
1868 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
1871 public Map
<String
, String
[]> getSpdPpi() {
1872 String
[] xPath
= new String
[] { "/PpiDeclarations/Entry" };
1874 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1877 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1879 Map
<String
, String
[]> ppiMap
= new HashMap
<String
, String
[]>();
1881 if (returns
== null) {
1885 for (int i
= 0; i
< returns
.length
; i
++) {
1886 PpiDeclarationsDocument
.PpiDeclarations
.Entry entry
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) returns
[i
];
1887 String
[] ppiPair
= new String
[2];
1888 ppiPair
[0] = entry
.getCName();
1889 ppiPair
[1] = entry
.getGuidValue();
1890 ppiMap
.put(entry
.getCName(), ppiPair
);
1896 * Retrieve module Guid string
1898 * @returns GUILD string if elements are found at the known xpath
1899 * @returns null if nothing is there
1901 public String
getModuleGuid() {
1902 String
[] xPath
= new String
[] { "" };
1904 Object
[] returns
= get("MsaHeader", xPath
);
1905 if (returns
!= null && returns
.length
> 0) {
1906 String guid
= ((MsaHeaderDocument
.MsaHeader
) returns
[0])
1917 public ModuleSADocument
.ModuleSA
[] getFpdModuleSAs() {
1918 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1919 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1920 if (result
!= null) {
1921 return (ModuleSADocument
.ModuleSA
[]) result
;
1923 return new ModuleSADocument
.ModuleSA
[0];
1927 Get name array of PCD in a module. In one module, token space
1928 is same, and token name should not be conflicted.
1932 public String
[] getModulePcdEntryNameArray() {
1933 PcdCodedDocument
.PcdCoded
.PcdEntry
[] pcdEntries
= null;
1936 String
[] xPath
= new String
[] {"/PcdEntry"};
1937 Object
[] returns
= get ("PcdCoded", xPath
);
1939 if (returns
== null) {
1940 return new String
[0];
1943 pcdEntries
= (PcdCodedDocument
.PcdCoded
.PcdEntry
[])returns
;
1944 results
= new String
[pcdEntries
.length
];
1946 for (index
= 0; index
< pcdEntries
.length
; index
++) {
1947 results
[index
] = pcdEntries
[index
].getCName();
1953 Search in a List for a given string
1957 public boolean contains(List list
, String str
) {
1958 if (list
== null || list
.size()== 0) {
1961 Iterator it
= list
.iterator();
1962 while (it
.hasNext()) {
1963 String s
= (String
)it
.next();
1964 if (s
.equalsIgnoreCase(str
)) {
1972 public boolean isHaveTianoR8FlashMap(){
1973 String
[] xPath
= new String
[] {"/"};
1974 Object
[] returns
= get ("Externs", xPath
);
1976 if (returns
== null) {
1980 ExternsDocument
.Externs ext
= (ExternsDocument
.Externs
)returns
[0];
1982 if (ext
.getTianoR8FlashMapH()){
1989 public Node
getFpdModuleSequence(String fvName
) {
1990 String
[] xPath
= new String
[] { "/BuildOptions/UserExtensions[@UserID='IMAGES' and @Identifier='1' and ./FvName='" + fvName
+ "']" };
1991 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1993 if (result
== null || result
.length
== 0) {
1997 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)result
[0];
1999 return a
.getDomNode();