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
.definitions
.EdkDefinitions
;
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;
81 private StringBuffer normQueryString
= new StringBuffer(4096);
82 private Pattern xPathPattern
= Pattern
.compile("([^/]*)(/|//)([^/]+)");
85 * Set a Surface Area document for query later
88 * A Surface Area document in TopLevelElementName/XmlObject
91 public SurfaceAreaQuery(Map
<String
, XmlObject
> map
) {
93 queryDeclaration
= "declare namespace " + nsPrefix
+ "='" + ns
+ "'; ";
98 * Push current used Surface Area document into query stack. The given new
99 * document will be used for any immediately followed getXXX() callings,
100 * untill pop() is called.
103 * The TopLevelElementName/XmlObject format of a Surface Area
106 public void push(Map
<String
, XmlObject
> newMap
) {
107 mapStack
.push(this.map
);
112 * Discard current used Surface Area document and use the top document in
116 this.map
= mapStack
.pop();
120 // / Convert xPath to be namespace qualified, which is necessary for
122 // / selectPath(). For example, converting /MsaHeader/ModuleType to
123 // / /ns:MsaHeader/ns:ModuleType
125 private String
normalizeQueryString(String
[] exp
, String from
) {
126 normQueryString
.setLength(0);
129 while (i
< exp
.length
) {
130 String newExp
= from
+ exp
[i
];
131 Matcher matcher
= xPathPattern
.matcher(newExp
);
133 while (matcher
.find()) {
134 String starter
= newExp
.substring(matcher
.start(1), matcher
136 String seperator
= newExp
.substring(matcher
.start(2), matcher
138 String token
= newExp
.substring(matcher
.start(3), matcher
141 normQueryString
.append(starter
);
142 normQueryString
.append(seperator
);
143 normQueryString
.append(nsPrefix
);
144 normQueryString
.append(":");
145 normQueryString
.append(token
);
149 if (i
< exp
.length
) {
150 normQueryString
.append(" | ");
154 return normQueryString
.toString();
158 * Search all XML documents stored in "map" for the specified xPath, using
159 * relative path (starting with '$this')
162 * xpath query string array
163 * @returns An array of XmlObject if elements are found at the specified
165 * @returns NULL if nothing is at the specified xpath
167 public Object
[] get(String
[] xPath
) {
172 String
[] keys
= (String
[]) map
.keySet().toArray(new String
[map
.size()]);
173 List
<Object
> result
= new ArrayList
<Object
>();
174 for (int i
= 0; i
< keys
.length
; ++i
) {
175 XmlObject rootNode
= (XmlObject
) map
.get(keys
[i
]);
176 if (rootNode
== null) {
180 String query
= queryDeclaration
181 + normalizeQueryString(xPath
, "$this/" + keys
[i
]);
182 XmlObject
[] tmp
= rootNode
.selectPath(query
);
183 for (int j
= 0; j
< tmp
.length
; ++j
) {
184 result
.add((Object
)tmp
[j
]);
188 int size
= result
.size();
193 return (Object
[]) result
.toArray(new Object
[size
]);
197 * Search XML documents named by "rootName" for the given xPath, using
198 * relative path (starting with '$this')
201 * The top level element name
203 * The xpath query string array
204 * @returns An array of XmlObject if elements are found at the given xpath
205 * @returns NULL if nothing is found at the given xpath
207 public Object
[] get(String rootName
, String
[] xPath
) {
212 XmlObject root
= (XmlObject
) map
.get(rootName
);
217 String query
= queryDeclaration
218 + normalizeQueryString(xPath
, "$this/" + rootName
);
219 XmlObject
[] result
= root
.selectPath(query
);
220 if (result
.length
> 0) {
221 return (Object
[])result
;
224 query
= queryDeclaration
+ normalizeQueryString(xPath
, "/" + rootName
);
225 result
= root
.selectPath(query
);
226 if (result
.length
> 0) {
227 return (Object
[])result
;
234 * Retrieve SourceFiles/Filename for specified ARCH type
238 * @returns An 2 dimension string array if elements are found at the known
240 * @returns NULL if nothing is found at the known xpath
242 public String
[][] getSourceFiles(String arch
) {
246 xPath
= new String
[] { "/Filename" };
248 returns
= get("SourceFiles", xPath
);
250 if (returns
== null || returns
.length
== 0) {
251 return new String
[0][3];
254 Filename
[] sourceFileNames
= (Filename
[]) returns
;
255 List
<String
[]> outputList
= new ArrayList
<String
[]>();
256 for (int i
= 0; i
< sourceFileNames
.length
; i
++) {
257 List archList
= sourceFileNames
[i
].getSupArchList();
258 if (arch
== null || arch
.trim().equalsIgnoreCase("") || archList
== null || contains(archList
, arch
)) {
259 outputList
.add(new String
[] {sourceFileNames
[i
].getToolCode(), sourceFileNames
[i
].getStringValue(), sourceFileNames
[i
].getToolChainFamily()});
263 String
[][] outputString
= new String
[outputList
.size()][3];
264 for (int index
= 0; index
< outputList
.size(); index
++) {
266 // ToolCode (FileType)
268 outputString
[index
][0] = outputList
.get(index
)[0];
270 // File name (relative to MODULE_DIR)
272 outputString
[index
][1] = outputList
.get(index
)[1];
276 outputString
[index
][2] = outputList
.get(index
)[2];
282 * Retrieve /PlatformDefinitions/OutputDirectory from FPD
284 * @returns Directory names array if elements are found at the known xpath
285 * @returns Empty if nothing is found at the known xpath
287 public String
getFpdOutputDirectory() {
288 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
290 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
291 if (returns
== null || returns
.length
== 0) {
294 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
295 return item
.getOutputDirectory();
298 public String
getFpdIntermediateDirectories() {
299 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
301 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
302 if (returns
== null || returns
.length
== 0) {
305 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
306 if(item
.getIntermediateDirectories() == null) {
310 return item
.getIntermediateDirectories().toString();
314 public String
getModuleFfsKeyword() {
315 String
[] xPath
= new String
[] { "/" };
317 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
318 if (returns
== null || returns
.length
== 0) {
321 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
322 return item
.getFfsFormatKey();
325 public String
getModuleFvBindingKeyword() {
326 String
[] xPath
= new String
[] { "/" };
328 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
329 if (returns
== null || returns
.length
== 0) {
332 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
333 return item
.getFvBinding();
336 public List
getModuleSupportedArchs() {
337 String
[] xPath
= new String
[] { "/" };
339 Object
[] returns
= get("ModuleDefinitions", xPath
);
340 if (returns
== null || returns
.length
== 0) {
343 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
344 return item
.getSupportedArchitectures();
347 public BuildOptionsDocument
.BuildOptions
.Ffs
[] getFpdFfs() {
348 String
[] xPath
= new String
[] {"/Ffs"};
350 Object
[] returns
= get("BuildOptions", xPath
);
351 if (returns
== null || returns
.length
== 0) {
352 return new BuildOptionsDocument
.BuildOptions
.Ffs
[0];
354 return (BuildOptionsDocument
.BuildOptions
.Ffs
[])returns
;
357 public String
getModuleOutputFileBasename() {
358 String
[] xPath
= new String
[] { "/" };
360 Object
[] returns
= get("ModuleDefinitions", xPath
);
361 if (returns
== null || returns
.length
== 0) {
364 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
365 return item
.getOutputFileBasename();
369 * Retrieve BuildOptions/Option or Arch/Option
371 * @param toolChainFamilyFlag
372 * if true, retrieve options for toolchain family; otherwise for
375 * @returns String[][5] name, target, toolchain, arch, coommand of options
376 * if elements are found at the known xpath. String[0][] if dont
379 * @returns Empty array if nothing is there
381 public String
[][] getOptions(String from
, String
[] xPath
, boolean toolChainFamilyFlag
) {
382 String target
= null;
383 String toolchain
= null;
384 String toolchainFamily
= null;
385 List
<String
> archList
= null;
387 String optionName
= null;
389 Object
[] returns
= get(from
, xPath
);
390 if (returns
== null) {
391 return new String
[0][5];
394 List
<String
[]> optionList
= new ArrayList
<String
[]>();
395 OptionDocument
.Option option
;
397 for (int i
= 0; i
< returns
.length
; i
++) {
398 option
= (OptionDocument
.Option
) returns
[i
];
401 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
403 // put to result[][5] array in above order.
406 if (option
.getBuildTargets() == null) {
410 target
= option
.getBuildTargets().toString();
412 if (target
!= null) {
413 targetList
= target
.split(" ");
415 targetList
= new String
[1];
416 targetList
[0] = null;
419 if (toolChainFamilyFlag
) {
420 toolchainFamily
= option
.getToolChainFamily();
421 if (toolchainFamily
!= null) {
422 toolchain
= toolchainFamily
.toString();
427 toolchain
= option
.getTagName();
430 archList
= new ArrayList
<String
>();
431 List archEnumList
= option
.getSupArchList();
432 if (archEnumList
== null) {
435 //archList.addAll(archEnumList);
436 Iterator it
= archEnumList
.iterator();
437 while (it
.hasNext()) {
438 String archType
= (String
)it
.next();
439 archList
.add(archType
);
443 cmd
= option
.getToolCode();
445 optionName
= option
.getStringValue();
446 for (int t
= 0; t
< targetList
.length
; t
++) {
447 for (int j
= 0; j
< archList
.size(); j
++) {
448 optionList
.add(new String
[] { targetList
[t
],
449 toolchain
, archList
.get(j
), cmd
, optionName
});
454 String
[][] result
= new String
[optionList
.size()][5];
455 for (int i
= 0; i
< optionList
.size(); i
++) {
456 result
[i
][0] = optionList
.get(i
)[0];
457 result
[i
][1] = optionList
.get(i
)[1];
458 result
[i
][2] = optionList
.get(i
)[2];
459 result
[i
][3] = optionList
.get(i
)[3];
460 result
[i
][4] = optionList
.get(i
)[4];
465 public String
[][] getModuleBuildOptions(boolean toolChainFamilyFlag
) {
468 if (toolChainFamilyFlag
== true) {
469 xPath
= new String
[] {
470 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
471 "/Options/Option[@ToolChainFamily]", };
473 xPath
= new String
[] {
474 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
475 "/Options/Option[@TagName]", };
477 return getOptions("ModuleSaBuildOptions", xPath
, toolChainFamilyFlag
);
480 public String
[][] getPlatformBuildOptions(boolean toolChainFamilyFlag
) {
483 if (toolChainFamilyFlag
== true) {
484 xPath
= new String
[] {
485 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
486 "/BuildOptions/Options/Option[@ToolChainFamily]", };
488 xPath
= new String
[] {
489 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
490 "/BuildOptions/Options/Option[@TagName]", };
493 return getOptions("PlatformSurfaceArea", xPath
, toolChainFamilyFlag
);
496 public String
[][] getMsaBuildOptions(boolean toolChainFamilyFlag
) {
499 if (toolChainFamilyFlag
== true) {
500 xPath
= new String
[] {
501 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
502 "/Options/Option[@ToolChainFamily]", };
504 xPath
= new String
[] {
505 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
506 "/Options/Option[@TagName]", };
509 return getOptions("ModuleBuildOptions", xPath
, toolChainFamilyFlag
);
512 public ToolChainInfo
getFpdToolChainInfo() {
513 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
515 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
516 if (returns
== null || returns
.length
== 0) {
520 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
521 ToolChainInfo toolChainInfo
= new ToolChainInfo();
522 toolChainInfo
.addTargets(item
.getBuildTargets().toString());
523 toolChainInfo
.addArchs(item
.getSupportedArchitectures().toString());
524 toolChainInfo
.addTagnames((String
)null);
525 return toolChainInfo
;
529 * Retrieve <xxxHeader>/ModuleType
531 * @returns The module type name if elements are found at the known xpath
532 * @returns null if nothing is there
534 public String
getModuleType() {
535 String
[] xPath
= new String
[] { "/ModuleType" };
537 Object
[] returns
= get(xPath
);
538 if (returns
!= null && returns
.length
> 0) {
539 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
540 return type
.enumValue().toString();
547 * Retrieve PackageDependencies/Package
552 * @returns package name list if elements are found at the known xpath
553 * @returns null if nothing is there
555 public PackageIdentification
[] getDependencePkg(String arch
) throws EdkException
{
557 String packageGuid
= null;
558 String packageVersion
= null;
561 xPath
= new String
[] { "/Package" };
563 Object
[] returns
= get("PackageDependencies", xPath
);
564 if (returns
== null) {
565 return new PackageIdentification
[0];
569 // Get packageIdentification
571 List
<PackageIdentification
> packageIdList
= new ArrayList
<PackageIdentification
>();
572 for (int i
= 0; i
< returns
.length
; i
++) {
573 PackageDependenciesDocument
.PackageDependencies
.Package item
= (PackageDependenciesDocument
.PackageDependencies
.Package
) returns
[i
];
574 List archList
= item
.getSupArchList();
575 if (arch
== null || archList
== null || contains(archList
, arch
)) {
576 packageGuid
= item
.getPackageGuid();
577 packageVersion
= item
.getPackageVersion();
578 PackageIdentification pkgId
= new PackageIdentification(null, packageGuid
, packageVersion
);
579 GlobalData
.refreshPackageIdentification(pkgId
);
580 packageIdList
.add(pkgId
);
584 return packageIdList
.toArray(new PackageIdentification
[packageIdList
.size()]);
588 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
591 * Library class usage
593 * @returns LibraryClass objects list if elements are found at the known
595 * @returns null if nothing is there
597 public String
[] getLibraryClasses(String usage
, String arch
, String moduleType
) {
599 if (usage
== null || usage
.equals("")) {
600 xPath
= new String
[] { "/LibraryClass" };
602 xPath
= new String
[] { "/LibraryClass[@Usage='" + usage
+ "']" };
605 Object
[] returns
= get("LibraryClassDefinitions", xPath
);
606 if (returns
== null || returns
.length
== 0) {
607 return new String
[0];
610 LibraryClassDocument
.LibraryClass
[] libraryClassList
= (LibraryClassDocument
.LibraryClass
[]) returns
;
611 List
<String
> libraryClassName
= new ArrayList
<String
>();
612 for (int i
= 0; i
< libraryClassList
.length
; i
++) {
613 List archList
= libraryClassList
[i
].getSupArchList();
614 List moduleTypeList
= libraryClassList
[i
].getSupModuleList();
615 if ((arch
== null || contains(archList
, arch
))
616 && (moduleType
== null || contains(moduleTypeList
, moduleType
)
617 || contains(moduleTypeList
, EdkDefinitions
.MODULE_TYPE_BASE
))) {
618 libraryClassName
.add(libraryClassList
[i
].getKeyword());
622 String
[] libraryArray
= new String
[libraryClassName
.size()];
623 libraryClassName
.toArray(libraryArray
);
628 * Retrieve ModuleEntryPoint names
630 * @returns ModuleEntryPoint name list if elements are found at the known
632 * @returns null if nothing is there
634 public String
[] getModuleEntryPointArray() {
635 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
637 Object
[] returns
= get("Externs", xPath
);
639 if (returns
!= null && returns
.length
> 0) {
640 String
[] entryPoints
= new String
[returns
.length
];
642 for (int i
= 0; i
< returns
.length
; ++i
) {
643 entryPoints
[i
] = ((CNameType
) returns
[i
]).getStringValue();
653 * retrieve Protocol for specified usage
656 * Protocol usage arch Architecture
658 * @returns Protocol String list if elements are found at the known xpath
659 * @returns String[0] if nothing is there
661 public String
[] getProtocolArray(String arch
, String usage
) {
663 String usageXpath
= "";
664 String archXpath
= "";
666 if (arch
== null || arch
.equals("")) {
667 return new String
[0];
669 archXpath
= "/Protocol";
670 if (usage
!= null && !usage
.equals("")) {
671 usageXpath
= "/Protocol[@Usage='" + usage
+ "']";
672 xPath
= new String
[] { usageXpath
, archXpath
};
674 return getProtocolArray(arch
);
679 Object
[] returns
= get("Protocols", xPath
);
680 if (returns
== null) {
681 return new String
[0];
683 Protocol
[] protocolList
= (Protocol
[]) returns
;
685 String
[] protocolArray
= new String
[returns
.length
];
686 for (int i
= 0; i
< returns
.length
; i
++) {
687 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
689 return protocolArray
;
693 * retrieve Protocol for specified usage
698 * @returns Protocol String list if elements are found at the known xpath
699 * @returns String[0] if nothing is there
701 public String
[] getProtocolArray(String arch
) {
704 if (arch
== null || arch
.equals("")) {
705 return new String
[0];
707 xPath
= new String
[] { "/Protocol" };
710 Object
[] returns
= get("Protocols", xPath
);
711 if (returns
== null) {
712 return new String
[0];
714 Protocol
[] returnlList
= (Protocol
[]) returns
;
716 List
<String
> protocolList
= new ArrayList
<String
>();
718 for (int i
= 0; i
< returns
.length
; i
++) {
719 List archList
= returnlList
[i
].getSupArchList();
720 if (archList
== null || contains(archList
, arch
)){
721 protocolList
.add(returnlList
[i
].getProtocolCName());
724 String
[] protocolArray
= new String
[protocolList
.size()];
725 for (int i
= 0; i
< protocolList
.size(); i
++) {
726 protocolArray
[i
] = protocolList
.get(i
);
728 return protocolArray
;
732 * Retrieve ProtocolNotify for specified usage
735 * ProtocolNotify usage
737 * @returns String[] if elements are found at the known xpath
738 * @returns String[0] if nothing is there
740 public String
[] getProtocolNotifyArray(String arch
) {
743 if (arch
== null || arch
.equals("")) {
744 return new String
[0];
746 xPath
= new String
[] { "/ProtocolNotify" };
749 Object
[] returns
= get("Protocols", xPath
);
750 if (returns
== null) {
751 return new String
[0];
754 List
<String
> protocolNotifyList
= new ArrayList
<String
>();
756 for (int i
= 0; i
< returns
.length
; i
++) {
757 List archList
= ((ProtocolNotify
) returns
[i
]).getSupArchList();
758 if (archList
== null || contains(archList
, arch
)){
759 protocolNotifyList
.add(((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName());
763 String
[] protocolNotifyArray
= new String
[protocolNotifyList
.size()];
764 for (int i
= 0; i
< protocolNotifyList
.size(); i
++) {
765 protocolNotifyArray
[i
] = protocolNotifyList
.get(i
);
767 return protocolNotifyArray
;
771 * Retrieve ProtocolNotify for specified usage
774 * ProtocolNotify usage
776 * @returns String[] if elements are found at the known xpath
777 * @returns String[0] if nothing is there
779 public String
[] getProtocolNotifyArray(String arch
, String usage
) {
785 if (arch
== null || arch
.equals("")) {
786 return new String
[0];
788 archXpath
= "/ProtocolNotify";
789 if (usage
!= null && !usage
.equals("")) {
790 usageXpath
= "/ProtocolNotify[@Usage='" + arch
+ "']";
791 xPath
= new String
[] { archXpath
, usageXpath
};
793 return getProtocolNotifyArray(arch
);
797 Object
[] returns
= get("Protocols", xPath
);
798 if (returns
== null) {
799 return new String
[0];
802 String
[] protocolNotifyList
= new String
[returns
.length
];
804 for (int i
= 0; i
< returns
.length
; i
++) {
805 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
807 return protocolNotifyList
;
811 * Retrieve ModuleUnloadImage names
813 * @returns ModuleUnloadImage name list if elements are found at the known
815 * @returns null if nothing is there
817 public String
[] getModuleUnloadImageArray() {
818 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
820 Object
[] returns
= get("Externs", xPath
);
821 if (returns
!= null && returns
.length
> 0) {
822 String
[] stringArray
= new String
[returns
.length
];
823 CNameType
[] doc
= (CNameType
[]) returns
;
825 for (int i
= 0; i
< returns
.length
; ++i
) {
826 stringArray
[i
] = doc
[i
].getStringValue();
838 * @returns Extern objects list if elements are found at the known xpath
839 * @returns null if nothing is there
841 public ExternsDocument
.Externs
.Extern
[] getExternArray() {
842 String
[] xPath
= new String
[] { "/Extern" };
844 Object
[] returns
= get("Externs", xPath
);
845 if (returns
!= null && returns
.length
> 0) {
846 return (ExternsDocument
.Externs
.Extern
[]) returns
;
853 * Retrieve PpiNotify for specified arch
858 * @returns String[] if elements are found at the known xpath
859 * @returns String[0] if nothing is there
861 public String
[] getPpiNotifyArray(String arch
) {
864 if (arch
== null || arch
.equals("")) {
865 return new String
[0];
867 xPath
= new String
[] { "/PpiNotify" };
870 Object
[] returns
= get("PPIs", xPath
);
871 if (returns
== null) {
872 return new String
[0];
876 List
<String
> ppiNotifyList
= new ArrayList
<String
>();
877 for (int i
= 0; i
< returns
.length
; i
++) {
878 List archList
= ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getSupArchList();
879 if (archList
== null || contains(archList
, arch
)){
880 ppiNotifyList
.add(((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName());
884 String
[] ppiNotifyArray
= new String
[ppiNotifyList
.size()];
885 for (int i
= 0; i
< ppiNotifyList
.size(); i
++) {
886 ppiNotifyArray
[i
] = ppiNotifyList
.get(i
);
889 return ppiNotifyArray
;
893 * Retrieve PpiNotify for specified usage and arch
896 * PpiNotify arch usage PpiNotify usage
899 * @returns String[] if elements are found at the known xpath
900 * @returns String[0] if nothing is there
902 public String
[] getPpiNotifyArray(String arch
, String usage
) {
908 if (arch
== null || arch
.equals("")) {
909 return new String
[0];
911 archXpath
= "/PpiNotify";
912 if (usage
!= null && !usage
.equals("")) {
913 usageXpath
= "/PpiNotify[@Usage='" + arch
+ "']";
914 xPath
= new String
[] { archXpath
, usageXpath
};
916 return getProtocolNotifyArray(arch
);
920 Object
[] returns
= get("PPIs", xPath
);
921 if (returns
== null) {
922 return new String
[0];
925 String
[] ppiNotifyList
= new String
[returns
.length
];
927 for (int i
= 0; i
< returns
.length
; i
++) {
928 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
930 return ppiNotifyList
;
934 * Retrieve Ppi for specified arch
939 * @returns String[] if elements are found at the known xpath
940 * @returns String[0] if nothing is there
942 public String
[] getPpiArray(String arch
) {
945 if (arch
== null || arch
.equals("")) {
946 return new String
[0];
948 xPath
= new String
[] { "/Ppi" };
951 Object
[] returns
= get("PPIs", xPath
);
952 if (returns
== null) {
953 return new String
[0];
956 List
<String
> ppiList
= new ArrayList
<String
>();
957 for (int i
= 0; i
< returns
.length
; i
++) {
958 List archList
= ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getSupArchList();
959 if (archList
== null || contains(archList
, arch
)){
960 ppiList
.add(((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName());
964 String
[] ppiArray
= new String
[ppiList
.size()];
965 for (int i
= 0; i
< ppiList
.size(); i
++) {
966 ppiArray
[i
] = ppiList
.get(i
);
972 * Retrieve PpiNotify for specified usage and arch
975 * PpiNotify arch usage PpiNotify usage
978 * @returns String[] if elements are found at the known xpath
979 * @returns String[0] if nothing is there
981 public String
[] getPpiArray(String arch
, String usage
) {
987 if (arch
== null || arch
.equals("")) {
988 return new String
[0];
991 if (usage
!= null && !usage
.equals("")) {
992 usageXpath
= "/Ppi[@Usage='" + arch
+ "']";
993 xPath
= new String
[] { archXpath
, usageXpath
};
995 return getProtocolNotifyArray(arch
);
999 Object
[] returns
= get("PPIs", xPath
);
1000 if (returns
== null) {
1001 return new String
[0];
1004 String
[] ppiList
= new String
[returns
.length
];
1006 for (int i
= 0; i
< returns
.length
; i
++) {
1007 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
1013 * Retrieve GuidEntry information for specified usage
1018 * @returns GuidEntry objects list if elements are found at the known xpath
1019 * @returns null if nothing is there
1021 public String
[] getGuidEntryArray(String arch
) {
1024 if (arch
== null || arch
.equals("")) {
1025 xPath
= new String
[] { "/GuidCNames" };
1027 xPath
= new String
[] { "/GuidCNames" };
1030 Object
[] returns
= get("Guids", xPath
);
1031 if (returns
== null) {
1032 return new String
[0];
1035 List
<String
> guidList
= new ArrayList
<String
>();
1036 for (int i
= 0; i
< returns
.length
; i
++) {
1037 List archList
= ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getSupArchList();
1038 if (archList
== null || contains(archList
, arch
)){
1039 guidList
.add(((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName());
1043 String
[] guidArray
= new String
[guidList
.size()];
1044 for (int i
= 0; i
< guidList
.size(); i
++) {
1045 guidArray
[i
] = guidList
.get(i
);
1052 * Retrieve GuidEntry information for specified usage
1055 * GuidEntry arch usage GuidEntry usage
1057 * @returns GuidEntry objects list if elements are found at the known xpath
1058 * @returns null if nothing is there
1060 public String
[] getGuidEntryArray(String arch
, String usage
) {
1065 if (arch
== null || arch
.equals("")) {
1066 return new String
[0];
1068 archXpath
= "/GuidEntry";
1069 if (usage
!= null && !usage
.equals("")) {
1070 usageXpath
= "/GuidEntry[@Usage='" + arch
+ "']";
1071 xPath
= new String
[] { archXpath
, usageXpath
};
1073 return getProtocolNotifyArray(arch
);
1077 Object
[] returns
= get("Guids", xPath
);
1078 if (returns
== null) {
1079 return new String
[0];
1082 String
[] guidList
= new String
[returns
.length
];
1084 for (int i
= 0; i
< returns
.length
; i
++) {
1085 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1091 * Retrieve Library instance information
1096 * Library instance usage
1098 * @returns library instance name list if elements are found at the known
1100 * @returns null if nothing is there
1102 public ModuleIdentification
[] getLibraryInstance(String arch
) throws EdkException
{
1104 String saGuid
= null;
1105 String saVersion
= null;
1106 String pkgGuid
= null;
1107 String pkgVersion
= null;
1109 if (arch
== null || arch
.equalsIgnoreCase("")) {
1110 xPath
= new String
[] { "/Instance" };
1113 // Since Schema don't have SupArchList now, so the follow Xpath is
1114 // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]
1115 // don't have effect.
1117 xPath
= new String
[] { "/Instance[not(@SupArchList) or @SupArchList='"
1121 Object
[] returns
= get("Libraries", xPath
);
1122 if (returns
== null || returns
.length
== 0) {
1123 return new ModuleIdentification
[0];
1126 ModuleIdentification
[] saIdList
= new ModuleIdentification
[returns
.length
];
1127 for (int i
= 0; i
< returns
.length
; i
++) {
1128 LibrariesDocument
.Libraries
.Instance library
= (LibrariesDocument
.Libraries
.Instance
) returns
[i
];
1129 saGuid
= library
.getModuleGuid();
1130 saVersion
= library
.getModuleVersion();
1132 pkgGuid
= library
.getPackageGuid();
1133 pkgVersion
= library
.getPackageVersion();
1135 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1137 PackageIdentification pkgId
= new PackageIdentification(null,
1138 pkgGuid
, pkgVersion
);
1139 GlobalData
.refreshPackageIdentification(pkgId
);
1140 saId
.setPackage(pkgId
);
1141 GlobalData
.refreshModuleIdentification(saId
);
1150 // / This method is used for retrieving the elements information which has
1151 // / CName sub-element
1153 private String
[] getCNames(String from
, String xPath
[]) {
1154 Object
[] returns
= get(from
, xPath
);
1155 if (returns
== null || returns
.length
== 0) {
1159 String
[] strings
= new String
[returns
.length
];
1160 for (int i
= 0; i
< returns
.length
; ++i
) {
1162 strings
[i
] = ((CNameType
) returns
[i
]).getStringValue();
1169 * Retrive library's constructor name
1171 * @returns constructor name list if elements are found at the known xpath
1172 * @returns null if nothing is there
1174 public String
getLibConstructorName() {
1175 String
[] xPath
= new String
[] { "/Extern/Constructor" };
1177 Object
[] returns
= get("Externs", xPath
);
1178 if (returns
!= null && returns
.length
> 0) {
1179 CNameType constructor
= ((CNameType
) returns
[0]);
1180 return constructor
.getStringValue();
1187 * Retrive library's destructor name
1189 * @returns destructor name list if elements are found at the known xpath
1190 * @returns null if nothing is there
1192 public String
getLibDestructorName() {
1193 String
[] xPath
= new String
[] { "/Extern/Destructor" };
1195 Object
[] returns
= get("Externs", xPath
);
1196 if (returns
!= null && returns
.length
> 0) {
1198 // Only support one Destructor function.
1200 CNameType destructor
= (CNameType
) returns
[0];
1201 return destructor
.getStringValue();
1208 * Retrive DriverBinding names
1210 * @returns DriverBinding name list if elements are found at the known xpath
1211 * @returns null if nothing is there
1213 public String
[] getDriverBindingArray() {
1214 String
[] xPath
= new String
[] { "/Extern/DriverBinding" };
1215 return getCNames("Externs", xPath
);
1219 * Retrive ComponentName names
1221 * @returns ComponentName name list if elements are found at the known xpath
1222 * @returns null if nothing is there
1224 public String
[] getComponentNameArray() {
1225 String
[] xPath
= new String
[] { "/Extern/ComponentName" };
1226 return getCNames("Externs", xPath
);
1230 * Retrive DriverConfig names
1232 * @returns DriverConfig name list if elements are found at the known xpath
1233 * @returns null if nothing is there
1235 public String
[] getDriverConfigArray() {
1236 String
[] xPath
= new String
[] { "/Extern/DriverConfig" };
1237 return getCNames("Externs", xPath
);
1241 * Retrive DriverDiag names
1243 * @returns DriverDiag name list if elements are found at the known xpath
1244 * @returns null if nothing is there
1246 public String
[] getDriverDiagArray() {
1247 String
[] xPath
= new String
[] { "/Extern/DriverDiag" };
1248 return getCNames("Externs", xPath
);
1252 * Retrive DriverBinding, ComponentName, DriverConfig,
1253 * DriverDiag group array
1255 * @returns DriverBinding group name list if elements are found
1256 * at the known xpath
1257 * @returns null if nothing is there
1259 public String
[][] getExternProtocolGroup() {
1260 String
[] xPath
= new String
[] {"/Extern"};
1261 Object
[] returns
= get("Externs",xPath
);
1263 if (returns
== null) {
1264 return new String
[0][4];
1266 List
<Extern
> externList
= new ArrayList
<Extern
>();
1267 for (int i
= 0; i
< returns
.length
; i
++) {
1268 org
.tianocore
.ExternsDocument
.Externs
.Extern extern
= (org
.tianocore
.ExternsDocument
.Externs
.Extern
)returns
[i
];
1269 if (extern
.getDriverBinding() != null) {
1270 externList
.add(extern
);
1274 String
[][] externGroup
= new String
[externList
.size()][4];
1275 for (int i
= 0; i
< externList
.size(); i
++) {
1276 String driverBindingStr
= externList
.get(i
).getDriverBinding();
1277 if ( driverBindingStr
!= null){
1278 externGroup
[i
][0] = driverBindingStr
;
1280 externGroup
[i
][0] = null;
1283 String componentNameStr
= externList
.get(i
).getComponentName();
1284 if (componentNameStr
!= null) {
1285 externGroup
[i
][1] = componentNameStr
;
1287 externGroup
[i
][1] = null;
1290 String driverConfigStr
= externList
.get(i
).getDriverConfig();
1291 if (driverConfigStr
!= null) {
1292 externGroup
[i
][2] = driverConfigStr
;
1294 externGroup
[i
][2] = null;
1297 String driverDiagStr
= externList
.get(i
).getDriverDiag();
1298 if (driverDiagStr
!= null) {
1299 externGroup
[i
][3] = driverDiagStr
;
1301 externGroup
[i
][3] = null;
1308 * Retrive SetVirtualAddressMapCallBack names
1310 * @returns SetVirtualAddressMapCallBack name list if elements are found at
1312 * @returns null if nothing is there
1314 public String
[] getSetVirtualAddressMapCallBackArray() {
1315 String
[] xPath
= new String
[] { "/Extern/SetVirtualAddressMapCallBack" };
1316 return getCNames("Externs", xPath
);
1320 * Retrive ExitBootServicesCallBack names
1322 * @returns ExitBootServicesCallBack name list if elements are found at the
1324 * @returns null if nothing is there
1326 public String
[] getExitBootServicesCallBackArray() {
1327 String
[] xPath
= new String
[] { "/Extern/ExitBootServicesCallBack" };
1328 return getCNames("Externs", xPath
);
1332 Judge whether current driver is PEI_PCD_DRIVER or DXE_PCD_DRIVER or
1335 @return CommonDefinition.PCD_DRIVER_TYPE the type of current driver
1337 public CommonDefinition
.PCD_DRIVER_TYPE
getPcdDriverType() {
1338 String
[] xPath
= new String
[] {"/PcdIsDriver"};
1339 Object
[] results
= get ("Externs", xPath
);
1341 if (results
!= null && results
.length
!= 0) {
1342 PcdDriverTypes type
= (PcdDriverTypes
) results
[0];
1343 String typeStr
= type
.enumValue().toString();
1344 if (typeStr
.equals(CommonDefinition
.PCD_DRIVER_TYPE
.PEI_PCD_DRIVER
.toString())) {
1345 return CommonDefinition
.PCD_DRIVER_TYPE
.PEI_PCD_DRIVER
;
1346 } else if (typeStr
.equals(CommonDefinition
.PCD_DRIVER_TYPE
.DXE_PCD_DRIVER
.toString())) {
1347 return CommonDefinition
.PCD_DRIVER_TYPE
.DXE_PCD_DRIVER
;
1349 return CommonDefinition
.PCD_DRIVER_TYPE
.UNKNOWN_PCD_DRIVER
;
1352 return CommonDefinition
.PCD_DRIVER_TYPE
.NOT_PCD_DRIVER
;
1356 * Retrieve module surface area file information
1358 * @returns ModuleSA objects list if elements are found at the known xpath
1359 * @returns Empty ModuleSA list if nothing is there
1361 public Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> getFpdModules() throws EdkException
{
1362 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1363 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1365 String fvBinding
= null;
1366 String saGuid
= null;
1367 String saVersion
= null;
1368 String pkgGuid
= null;
1369 String pkgVersion
= null;
1371 Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleMap
= new LinkedHashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
1373 if (result
== null) {
1374 return fpdModuleMap
;
1377 for (int i
= 0; i
< result
.length
; i
++) {
1379 // Get Fpd SA Module element node and add to ObjectMap.
1381 Map
<String
, XmlObject
> ObjectMap
= new HashMap
<String
, XmlObject
>();
1382 ModuleSADocument
.ModuleSA moduleSA
= (ModuleSADocument
.ModuleSA
) result
[i
];
1383 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getLibraries() != null) {
1384 ObjectMap
.put("Libraries", moduleSA
.getLibraries());
1386 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getPcdBuildDefinition() != null) {
1387 ObjectMap
.put("PcdBuildDefinition", moduleSA
.getPcdBuildDefinition());
1389 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getModuleSaBuildOptions() != null) {
1390 ObjectMap
.put("ModuleSaBuildOptions", moduleSA
.getModuleSaBuildOptions());
1394 // Get Fpd SA Module attribute and create FpdMoudleIdentification.
1396 if (moduleSA
.isSetSupArchList()) {
1397 arch
= moduleSA
.getSupArchList().toString();
1404 saVersion
= ((ModuleSADocument
.ModuleSA
) result
[i
]).getModuleVersion();
1406 saGuid
= moduleSA
.getModuleGuid();
1407 pkgGuid
= moduleSA
.getPackageGuid();
1408 pkgVersion
= moduleSA
.getPackageVersion();
1411 // Create Module Identification which have class member of package
1414 PackageIdentification pkgId
= new PackageIdentification(null, pkgGuid
, pkgVersion
);
1415 GlobalData
.refreshPackageIdentification(pkgId
);
1417 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
, saVersion
);
1418 saId
.setPackage(pkgId
);
1419 GlobalData
.refreshModuleIdentification(saId
);
1424 // Create FpdModule Identification which have class member of module
1427 String
[] archList
= new String
[0];
1428 if (arch
== null || arch
.trim().length() == 0) {
1429 archList
= GlobalData
.getToolChainInfo().getArchs();
1431 archList
= arch
.split(" ");
1433 for (int j
= 0; j
< archList
.length
; j
++) {
1434 FpdModuleIdentification fpdSaId
= new FpdModuleIdentification(saId
, archList
[j
]);
1436 if (fvBinding
!= null) {
1437 fpdSaId
.setFvBinding(fvBinding
);
1441 // Put element to Map<FpdModuleIdentification, Map<String,
1444 fpdModuleMap
.put(fpdSaId
, ObjectMap
);
1447 return fpdModuleMap
;
1451 * Retrieve valid image names
1453 * @returns valid iamges name list if elements are found at the known xpath
1454 * @returns empty list if nothing is there
1456 public String
[] getFpdValidImageNames() {
1457 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
1459 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1460 if (queryResult
== null) {
1461 return new String
[0];
1464 String
[] result
= new String
[queryResult
.length
];
1465 for (int i
= 0; i
< queryResult
.length
; i
++) {
1466 result
[i
] = ((XmlString
) queryResult
[i
]).getStringValue();
1472 public Node
getFpdUserExtensionPreBuild() {
1473 String
[] xPath
= new String
[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" };
1475 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1476 if (queryResult
== null || queryResult
.length
== 0) {
1479 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)queryResult
[0];
1481 return a
.getDomNode();
1484 public Node
getFpdUserExtensionPostBuild() {
1485 String
[] xPath
= new String
[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" };
1487 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1488 if (queryResult
== null || queryResult
.length
== 0) {
1491 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)queryResult
[0];
1493 return a
.getDomNode();
1497 * Retrieve FV image option information
1502 * @returns option name/value list if elements are found at the known xpath
1503 * @returns empty list if nothing is there
1505 public String
[][] getFpdOptions(String fvName
) {
1506 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
1507 + fvName
+ "']/FvImageOptions" };
1508 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1509 if (queryResult
== null) {
1510 return new String
[0][];
1512 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1513 for (int i
= 0; i
< queryResult
.length
; i
++) {
1514 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1515 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
1516 .getNameValueList();
1517 Iterator iter
= namevalues
.iterator();
1518 while (iter
.hasNext()) {
1519 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1521 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1524 String
[][] result
= new String
[list
.size()][2];
1525 for (int i
= 0; i
< list
.size(); i
++) {
1526 result
[i
][0] = list
.get(i
)[0];
1527 result
[i
][1] = list
.get(i
)[1];
1533 public XmlObject
getFpdBuildOptions() {
1534 String
[] xPath
= new String
[] { "/BuildOptions" };
1536 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1538 if (queryResult
== null || queryResult
.length
== 0) {
1541 return (XmlObject
)queryResult
[0];
1544 public PlatformIdentification
getFpdHeader() {
1545 String
[] xPath
= new String
[] { "/PlatformHeader" };
1547 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
1549 if (returns
== null || returns
.length
== 0) {
1552 PlatformHeaderDocument
.PlatformHeader header
= (PlatformHeaderDocument
.PlatformHeader
) returns
[0];
1554 String name
= header
.getPlatformName();
1556 String guid
= header
.getGuidValue();
1558 String version
= header
.getVersion();
1560 return new PlatformIdentification(name
, guid
, version
);
1564 * Retrieve FV image attributes information
1569 * @returns attribute name/value list if elements are found at the known
1571 * @returns empty list if nothing is there
1573 public String
[][] getFpdAttributes(String fvName
) {
1574 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
1575 + fvName
+ "']/FvImageOptions" };
1576 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1577 if (queryResult
== null) {
1578 return new String
[0][];
1580 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1581 for (int i
= 0; i
< queryResult
.length
; i
++) {
1583 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1584 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1585 Iterator iter
= namevalues
.iterator();
1586 while (iter
.hasNext()) {
1587 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1589 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1592 String
[][] result
= new String
[list
.size()][2];
1593 for (int i
= 0; i
< list
.size(); i
++) {
1594 result
[i
][0] = list
.get(i
)[0];
1595 result
[i
][1] = list
.get(i
)[1];
1601 * Retrieve flash definition file name
1603 * @returns file name if elements are found at the known xpath
1604 * @returns null if nothing is there
1606 public String
getFlashDefinitionFile() {
1607 String
[] xPath
= new String
[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
1609 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1610 if (queryResult
== null || queryResult
.length
== 0) {
1614 FileNameConvention filename
= (FileNameConvention
) queryResult
[queryResult
.length
- 1];
1615 return filename
.getStringValue();
1618 public String
[][] getFpdGlobalVariable() {
1619 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
1620 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1621 if (queryResult
== null) {
1622 return new String
[0][];
1625 String
[][] result
= new String
[queryResult
.length
][2];
1627 for (int i
= 0; i
< queryResult
.length
; i
++) {
1628 FvImagesDocument
.FvImages
.NameValue item
= (FvImagesDocument
.FvImages
.NameValue
)queryResult
[i
];
1629 result
[i
][0] = item
.getName();
1630 result
[i
][1] = item
.getValue();
1636 * Retrieve FV image component options
1641 * @returns name/value pairs list if elements are found at the known xpath
1642 * @returns empty list if nothing is there
1644 public String
[][] getFpdComponents(String fvName
) {
1645 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName
+ "']/FvImageOptions" };
1646 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1647 if (queryResult
== null) {
1648 return new String
[0][];
1651 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1652 for (int i
= 0; i
< queryResult
.length
; i
++) {
1653 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1654 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1655 Iterator iter
= namevalues
.iterator();
1656 while (iter
.hasNext()) {
1657 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1659 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1662 String
[][] result
= new String
[list
.size()][2];
1663 for (int i
= 0; i
< list
.size(); i
++) {
1664 result
[i
][0] = list
.get(i
)[0];
1665 result
[i
][1] = list
.get(i
)[1];
1671 * Retrieve PCD tokens
1673 * @returns CName/ItemType pairs list if elements are found at the known
1675 * @returns null if nothing is there
1677 public String
[][] getPcdTokenArray() {
1678 String
[] xPath
= new String
[] { "/PcdData" };
1680 Object
[] returns
= get("PCDs", xPath
);
1681 if (returns
== null || returns
.length
== 0) {
1689 * Retrieve MAS header
1694 public ModuleIdentification
getMsaHeader() {
1695 String
[] xPath
= new String
[] { "/" };
1696 Object
[] returns
= get("MsaHeader", xPath
);
1698 if (returns
== null || returns
.length
== 0) {
1702 MsaHeader msaHeader
= (MsaHeader
) returns
[0];
1704 // Get BaseName, ModuleType, GuidValue, Version
1705 // which in MsaHeader.
1707 String name
= msaHeader
.getModuleName();
1708 String moduleType
= msaHeader
.getModuleType().toString();
1709 String guid
= msaHeader
.getGuidValue();
1710 String version
= msaHeader
.getVersion();
1712 ModuleIdentification moduleId
= new ModuleIdentification(name
, guid
,
1715 moduleId
.setModuleType(moduleType
);
1721 * Retrieve Extern Specification
1725 * @return String[] If have specification element in the <extern> String[0]
1726 * If no specification element in the <extern>
1730 public String
[] getExternSpecificaiton() {
1731 String
[] xPath
= new String
[] { "/Specification" };
1733 Object
[] queryResult
= get("Externs", xPath
);
1734 if (queryResult
== null) {
1735 return new String
[0];
1738 String
[] specificationList
= new String
[queryResult
.length
];
1739 for (int i
= 0; i
< queryResult
.length
; i
++) {
1740 specificationList
[i
] = ((Sentence
)queryResult
[i
])
1743 return specificationList
;
1747 * Retreive MsaFile which in SPD
1750 * @return String[][3] The string sequence is ModuleName, ModuleGuid,
1751 * ModuleVersion, MsaFile String[0][] If no msafile in SPD
1753 public String
[] getSpdMsaFile() {
1754 String
[] xPath
= new String
[] { "/MsaFiles" };
1756 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1757 if (returns
== null) {
1758 return new String
[0];
1761 List
<String
> filenameList
= ((MsaFilesDocument
.MsaFiles
) returns
[0])
1763 return filenameList
.toArray(new String
[filenameList
.size()]);
1769 public Map
<String
, String
[]> getSpdLibraryClasses() {
1770 String
[] xPath
= new String
[] { "/LibraryClassDeclarations/LibraryClass" };
1772 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1775 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
1777 Map
<String
, String
[]> libClassHeaderMap
= new HashMap
<String
, String
[]>();
1779 if (returns
== null) {
1780 return libClassHeaderMap
;
1783 for (int i
= 0; i
< returns
.length
; i
++) {
1784 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass library
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) returns
[i
];
1785 libClassHeaderMap
.put(library
.getName(), new String
[] { library
1786 .getIncludeHeader() });
1788 return libClassHeaderMap
;
1794 public Map
<String
, String
> getSpdPackageHeaderFiles() {
1795 String
[] xPath
= new String
[] { "/PackageHeaders/IncludePkgHeader" };
1797 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1800 // Create Map, Key - ModuleType, String - PackageInclude Header file.
1802 Map
<String
, String
> packageIncludeMap
= new HashMap
<String
, String
>();
1804 if (returns
== null) {
1805 return packageIncludeMap
;
1808 for (int i
= 0; i
< returns
.length
; i
++) {
1809 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader includeHeader
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) returns
[i
];
1810 packageIncludeMap
.put(includeHeader
.getModuleType().toString(),
1811 includeHeader
.getStringValue());
1813 return packageIncludeMap
;
1816 public PackageIdentification
getSpdHeader() {
1817 String
[] xPath
= new String
[] { "/SpdHeader" };
1819 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1821 if (returns
== null || returns
.length
== 0) {
1825 SpdHeaderDocument
.SpdHeader header
= (SpdHeaderDocument
.SpdHeader
) returns
[0];
1827 String name
= header
.getPackageName();
1829 String guid
= header
.getGuidValue();
1831 String version
= header
.getVersion();
1833 return new PackageIdentification(name
, guid
, version
);
1839 public Map
<String
, String
[]> getSpdGuid() {
1840 String
[] xPath
= new String
[] { "/GuidDeclarations/Entry" };
1842 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1845 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
1847 Map
<String
, String
[]> guidDeclMap
= new HashMap
<String
, String
[]>();
1848 if (returns
== null) {
1852 for (int i
= 0; i
< returns
.length
; i
++) {
1853 GuidDeclarationsDocument
.GuidDeclarations
.Entry entry
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) returns
[i
];
1854 String
[] guidPair
= new String
[2];
1855 guidPair
[0] = entry
.getCName();
1856 guidPair
[1] = entry
.getGuidValue();
1857 guidDeclMap
.put(entry
.getCName(), guidPair
);
1865 public Map
<String
, String
[]> getSpdProtocol() {
1866 String
[] xPath
= new String
[] { "/ProtocolDeclarations/Entry" };
1868 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1871 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1873 Map
<String
, String
[]> protoclMap
= new HashMap
<String
, String
[]>();
1875 if (returns
== null) {
1879 for (int i
= 0; i
< returns
.length
; i
++) {
1880 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry entry
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) returns
[i
];
1881 String
[] protocolPair
= new String
[2];
1883 protocolPair
[0] = entry
.getCName();
1884 protocolPair
[1] = entry
.getGuidValue();
1885 protoclMap
.put(entry
.getCName(), protocolPair
);
1891 * getSpdPpi() Retrieve the SPD PPI Entry
1894 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
1895 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
1898 public Map
<String
, String
[]> getSpdPpi() {
1899 String
[] xPath
= new String
[] { "/PpiDeclarations/Entry" };
1901 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1904 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1906 Map
<String
, String
[]> ppiMap
= new HashMap
<String
, String
[]>();
1908 if (returns
== null) {
1912 for (int i
= 0; i
< returns
.length
; i
++) {
1913 PpiDeclarationsDocument
.PpiDeclarations
.Entry entry
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) returns
[i
];
1914 String
[] ppiPair
= new String
[2];
1915 ppiPair
[0] = entry
.getCName();
1916 ppiPair
[1] = entry
.getGuidValue();
1917 ppiMap
.put(entry
.getCName(), ppiPair
);
1923 * Retrieve module Guid string
1925 * @returns GUILD string if elements are found at the known xpath
1926 * @returns null if nothing is there
1928 public String
getModuleGuid() {
1929 String
[] xPath
= new String
[] { "" };
1931 Object
[] returns
= get("MsaHeader", xPath
);
1932 if (returns
!= null && returns
.length
> 0) {
1933 String guid
= ((MsaHeaderDocument
.MsaHeader
) returns
[0])
1944 public ModuleSADocument
.ModuleSA
[] getFpdModuleSAs() {
1945 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1946 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1947 if (result
!= null) {
1948 return (ModuleSADocument
.ModuleSA
[]) result
;
1950 return new ModuleSADocument
.ModuleSA
[0];
1955 Get name array who contains all PCDs in a module according to specified arch.
1957 @param arch The specified architecture type.
1959 @return String[] return all PCDs name into array, if no any PCD used by
1960 this module, a String[0] array is returned.
1962 public String
[] getModulePcdEntryNameArray(String arch
) {
1963 PcdCodedDocument
.PcdCoded
.PcdEntry
[] pcdEntries
= null;
1964 java
.util
.List archList
= null;
1965 java
.util
.List
<String
> results
= new java
.util
.ArrayList
<String
> ();
1967 String
[] xPath
= new String
[] {"/PcdEntry"};
1968 Object
[] returns
= get ("PcdCoded", xPath
);
1970 if (returns
== null) {
1971 return new String
[0];
1974 pcdEntries
= (PcdCodedDocument
.PcdCoded
.PcdEntry
[])returns
;
1976 for (index
= 0; index
< pcdEntries
.length
; index
++) {
1977 archList
= pcdEntries
[index
].getSupArchList();
1979 // If the ArchList is specified in MSA for this PCD, need check
1980 // current arch whether can support by this PCD.
1982 if (archList
!= null) {
1983 if (archList
.contains(arch
)) {
1984 results
.add(new String(pcdEntries
[index
].getCName()));
1988 // If no ArchList is specificied in MSA for this PCD, that means
1989 // this PCD support all architectures.
1991 results
.add(new String(pcdEntries
[index
].getCName()));
1995 if (results
.size() == 0) {
1996 return new String
[0];
1999 String
[] retArray
= new String
[results
.size()];
2000 results
.toArray(retArray
);
2006 Search in a List for a given string
2010 public boolean contains(List list
, String str
) {
2011 if (list
== null || list
.size()== 0) {
2015 return list
.contains(str
);
2018 public boolean isHaveTianoR8FlashMap(){
2019 String
[] xPath
= new String
[] {"/"};
2020 Object
[] returns
= get ("Externs", xPath
);
2022 if (returns
== null) {
2026 ExternsDocument
.Externs ext
= (ExternsDocument
.Externs
)returns
[0];
2028 if (ext
.getTianoR8FlashMapH()){
2035 public Node
getPeiApriori(String fvName
) {
2036 String
[] xPath
= new String
[] { "/BuildOptions/UserExtensions[@UserID='APRIORI' and @Identifier='0' and ./FvName='" + fvName
+ "']" };
2037 Object
[] result
= get("PlatformSurfaceArea", xPath
);
2039 if (result
== null || result
.length
== 0) {
2043 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)result
[0];
2045 return a
.getDomNode();
2048 public Node
getDxeApriori(String fvName
) {
2049 String
[] xPath
= new String
[] { "/BuildOptions/UserExtensions[@UserID='APRIORI' and @Identifier='1' and ./FvName='" + fvName
+ "']" };
2050 Object
[] result
= get("PlatformSurfaceArea", xPath
);
2052 if (result
== null || result
.length
== 0) {
2056 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)result
[0];
2058 return a
.getDomNode();
2061 public Node
getFpdModuleSequence(String fvName
) {
2062 String
[] xPath
= new String
[] { "/BuildOptions/UserExtensions[@UserID='IMAGES' and @Identifier='1' and ./FvName='" + fvName
+ "']" };
2063 Object
[] result
= get("PlatformSurfaceArea", xPath
);
2065 if (result
== null || result
.length
== 0) {
2069 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)result
[0];
2071 return a
.getDomNode();
2075 Get the value of PCD by PCD cName
2077 @return PcdValue String of PcdComponentName
2078 null If don't find ComponentName Pcd
2080 public String
getPcdValueBycName(String cName
){
2081 String
[] xPath
= new String
[] { "/PcdData" };
2082 Object
[] returns
= get("PcdBuildDefinition", xPath
);
2083 if (returns
== null || returns
.length
== 0) {
2086 for (int i
= 0; i
< returns
.length
; i
++) {
2087 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)returns
[i
];
2088 if (pcdData
.getCName().equalsIgnoreCase(cName
)){
2089 return pcdData
.getValue();