2 This file is for surface area information retrieval.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 package org
.tianocore
.build
.global
;
16 import java
.util
.ArrayList
;
17 import java
.util
.HashMap
;
18 import java
.util
.Iterator
;
19 import java
.util
.LinkedHashMap
;
20 import java
.util
.List
;
22 import java
.util
.Stack
;
23 import java
.util
.regex
.Matcher
;
24 import java
.util
.regex
.Pattern
;
26 import org
.apache
.xmlbeans
.XmlNormalizedString
;
27 import org
.apache
.xmlbeans
.XmlObject
;
28 import org
.apache
.xmlbeans
.XmlString
;
29 import org
.tianocore
.BuildOptionsDocument
;
30 import org
.tianocore
.CNameType
;
31 import org
.tianocore
.DataIdDocument
;
32 import org
.tianocore
.ExternsDocument
;
33 import org
.tianocore
.FileNameConvention
;
34 import org
.tianocore
.FvAttributeDocument
;
35 import org
.tianocore
.FvImagesDocument
;
36 import org
.tianocore
.FvOptionDocument
;
37 import org
.tianocore
.GuidDeclarationsDocument
;
38 import org
.tianocore
.GuidsDocument
;
39 import org
.tianocore
.LibrariesDocument
;
40 import org
.tianocore
.LibraryClassDeclarationsDocument
;
41 import org
.tianocore
.LibraryClassDocument
;
42 import org
.tianocore
.ModuleDefinitionsDocument
;
43 import org
.tianocore
.ModuleSADocument
;
44 import org
.tianocore
.ModuleSaBuildOptionsDocument
;
45 import org
.tianocore
.ModuleTypeDef
;
46 import org
.tianocore
.MsaFilesDocument
;
47 import org
.tianocore
.MsaHeaderDocument
;
48 import org
.tianocore
.OptionDocument
;
49 import org
.tianocore
.PPIsDocument
;
50 import org
.tianocore
.PackageDependenciesDocument
;
51 import org
.tianocore
.PackageHeadersDocument
;
52 import org
.tianocore
.PcdCodedDocument
;
53 import org
.tianocore
.PlatformDefinitionsDocument
;
54 import org
.tianocore
.PlatformHeaderDocument
;
55 import org
.tianocore
.PpiDeclarationsDocument
;
56 import org
.tianocore
.ProtocolDeclarationsDocument
;
57 import org
.tianocore
.Sentence
;
58 import org
.tianocore
.SpdHeaderDocument
;
59 import org
.tianocore
.SupportedArchitectures
;
60 import org
.tianocore
.FilenameDocument
.Filename
;
61 import org
.tianocore
.MsaHeaderDocument
.MsaHeader
;
62 import org
.tianocore
.ProtocolsDocument
.Protocols
.Protocol
;
63 import org
.tianocore
.ProtocolsDocument
.Protocols
.ProtocolNotify
;
64 import org
.tianocore
.SupportedArchitectures
.Enum
;
65 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
66 import org
.tianocore
.build
.id
.ModuleIdentification
;
67 import org
.tianocore
.build
.id
.PackageIdentification
;
68 import org
.tianocore
.build
.id
.PlatformIdentification
;
69 import org
.tianocore
.build
.toolchain
.ToolChainInfo
;
70 import org
.tianocore
.logger
.EdkLog
;
73 * SurfaceAreaQuery class is used to query Surface Area information from msa,
74 * mbd, spd and fpd files.
76 * This class should not instantiated. All the public interfaces is static.
80 public class SurfaceAreaQuery
{
82 public static String prefix
= "http://www.TianoCore.org/2006/Edk2.0";
85 // / Contains name/value pairs of Surface Area document object. The name is
86 // / always the top level element name.
88 private static Map
<String
, XmlObject
> map
= null;
91 // / mapStack is used to do nested query
93 private static Stack
<Map
<String
, XmlObject
>> mapStack
= new Stack
<Map
<String
, XmlObject
>>();
96 // / prefix of name space
98 private static String nsPrefix
= "sans";
101 // / xmlbeans needs a name space for each Xpath element
103 private static String ns
= null;
106 // / keep the namep declaration for xmlbeans Xpath query
108 private static String queryDeclaration
= null;
111 * Set a Surface Area document for query later
114 * A Surface Area document in TopLevelElementName/XmlObject
117 public static void setDoc(Map
<String
, XmlObject
> map
) {
119 queryDeclaration
= "declare namespace " + nsPrefix
+ "='" + ns
+ "'; ";
120 SurfaceAreaQuery
.map
= map
;
124 * Push current used Surface Area document into query stack. The given new
125 * document will be used for any immediately followed getXXX() callings,
126 * untill pop() is called.
129 * The TopLevelElementName/XmlObject format of a Surface Area
132 public static void push(Map
<String
, XmlObject
> newMap
) {
133 mapStack
.push(SurfaceAreaQuery
.map
);
134 SurfaceAreaQuery
.map
= newMap
;
138 * Discard current used Surface Area document and use the top document in
141 public static void pop() {
142 SurfaceAreaQuery
.map
= mapStack
.pop();
146 // / Convert xPath to be namespace qualified, which is necessary for
148 // / selectPath(). For example, converting /MsaHeader/ModuleType to
149 // / /ns:MsaHeader/ns:ModuleType
151 private static String
normalizeQueryString(String
[] exp
, String from
) {
152 StringBuffer normQueryString
= new StringBuffer(4096);
155 while (i
< exp
.length
) {
156 String newExp
= from
+ exp
[i
];
157 Pattern pattern
= Pattern
.compile("([^/]*)(/|//)([^/]+)");
158 Matcher matcher
= pattern
.matcher(newExp
);
160 while (matcher
.find()) {
161 String starter
= newExp
.substring(matcher
.start(1), matcher
163 String seperator
= newExp
.substring(matcher
.start(2), matcher
165 String token
= newExp
.substring(matcher
.start(3), matcher
168 normQueryString
.append(starter
);
169 normQueryString
.append(seperator
);
170 normQueryString
.append(nsPrefix
);
171 normQueryString
.append(":");
172 normQueryString
.append(token
);
176 if (i
< exp
.length
) {
177 normQueryString
.append(" | ");
181 return normQueryString
.toString();
185 * Search all XML documents stored in "map" for the specified xPath, using
186 * relative path (starting with '$this')
189 * xpath query string array
190 * @returns An array of XmlObject if elements are found at the specified
192 * @returns NULL if nothing is at the specified xpath
194 public static Object
[] get(String
[] xPath
) {
199 String
[] keys
= (String
[]) map
.keySet().toArray(new String
[map
.size()]);
200 List
<Object
> result
= new ArrayList
<Object
>();
201 for (int i
= 0; i
< keys
.length
; ++i
) {
202 XmlObject rootNode
= (XmlObject
) map
.get(keys
[i
]);
203 if (rootNode
== null) {
207 String query
= queryDeclaration
208 + normalizeQueryString(xPath
, "$this/" + keys
[i
]);
209 XmlObject
[] tmp
= rootNode
.selectPath(query
);
210 for (int j
= 0; j
< tmp
.length
; ++j
) {
211 result
.add((Object
)tmp
[j
]);
215 int size
= result
.size();
220 return (Object
[]) result
.toArray(new Object
[size
]);
224 * Search XML documents named by "rootName" for the given xPath, using
225 * relative path (starting with '$this')
228 * The top level element name
230 * The xpath query string array
231 * @returns An array of XmlObject if elements are found at the given xpath
232 * @returns NULL if nothing is found at the given xpath
234 public static Object
[] get(String rootName
, String
[] xPath
) {
239 XmlObject root
= (XmlObject
) map
.get(rootName
);
244 String query
= queryDeclaration
245 + normalizeQueryString(xPath
, "$this/" + rootName
);
246 XmlObject
[] result
= root
.selectPath(query
);
247 if (result
.length
> 0) {
248 return (Object
[])result
;
251 query
= queryDeclaration
+ normalizeQueryString(xPath
, "/" + rootName
);
252 result
= root
.selectPath(query
);
253 if (result
.length
> 0) {
254 return (Object
[])result
;
261 * Retrieve SourceFiles/Filename for specified ARCH type
265 * @returns An 2 dimension string array if elements are found at the known
267 * @returns NULL if nothing is found at the known xpath
269 public static String
[][] getSourceFiles(String arch
) {
273 xPath
= new String
[] { "/Filename" };
275 returns
= get("SourceFiles", xPath
);
277 if (returns
== null || returns
.length
== 0) {
278 return new String
[0][0];
281 Filename
[] sourceFileNames
= (Filename
[]) returns
;
282 List
<String
[]> outputList
= new ArrayList
<String
[]>();
283 for (int i
= 0; i
< sourceFileNames
.length
; i
++) {
284 @SuppressWarnings("unchecked")
285 List
<String
> archList
= sourceFileNames
[i
].getSupArchList();
286 if (arch
== null || arch
.equalsIgnoreCase("") || archList
== null || archList
.contains(arch
)) {
287 outputList
.add(new String
[] {sourceFileNames
[i
].getToolCode(),sourceFileNames
[i
].getStringValue()});
291 String
[][] outputString
= new String
[outputList
.size()][2];
292 for (int index
= 0; index
< outputList
.size(); index
++) {
293 outputString
[index
][0] = outputList
.get(index
)[0];
294 outputString
[index
][1] = outputList
.get(index
)[1];
300 * Retrieve /PlatformDefinitions/OutputDirectory from FPD
302 * @returns Directory names array if elements are found at the known xpath
303 * @returns Empty if nothing is found at the known xpath
305 public static String
getFpdOutputDirectory() {
306 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
308 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
309 if (returns
== null || returns
.length
== 0) {
312 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
313 return item
.getOutputDirectory();
316 public static String
getFpdIntermediateDirectories() {
317 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
319 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
320 if (returns
== null || returns
.length
== 0) {
323 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
324 if(item
.getIntermediateDirectories() == null) {
328 return item
.getIntermediateDirectories().toString();
332 public static String
getModuleFfsKeyword() {
333 String
[] xPath
= new String
[] { "/" };
335 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
336 if (returns
== null || returns
.length
== 0) {
339 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
340 return item
.getFfsFormatKey();
343 public static String
getModuleFvBindingKeyword() {
344 String
[] xPath
= new String
[] { "/" };
346 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
347 if (returns
== null || returns
.length
== 0) {
350 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
351 return item
.getFvBinding();
354 public static List
getModuleSupportedArchs() {
355 String
[] xPath
= new String
[] { "/" };
357 Object
[] returns
= get("ModuleDefinitions", xPath
);
358 if (returns
== null || returns
.length
== 0) {
361 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
362 return item
.getSupportedArchitectures();
365 public static BuildOptionsDocument
.BuildOptions
.Ffs
[] getFpdFfs() {
366 String
[] xPath
= new String
[] {"/Ffs"};
368 Object
[] returns
= get("BuildOptions", xPath
);
369 if (returns
== null || returns
.length
== 0) {
370 return new BuildOptionsDocument
.BuildOptions
.Ffs
[0];
372 return (BuildOptionsDocument
.BuildOptions
.Ffs
[])returns
;
375 public static String
getModuleOutputFileBasename() {
376 String
[] xPath
= new String
[] { "/" };
378 Object
[] returns
= get("ModuleDefinitions", xPath
);
379 if (returns
== null || returns
.length
== 0) {
382 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
383 return item
.getOutputFileBasename();
387 * Retrieve BuildOptions/Option or Arch/Option
389 * @param toolChainFamilyFlag
390 * if true, retrieve options for toolchain family; otherwise for
393 * @returns String[][5] name, target, toolchain, arch, coommand of options
394 * if elements are found at the known xpath. String[0][] if dont
397 * @returns Empty array if nothing is there
399 public static String
[][] getOptions(String from
, String
[] xPath
, boolean toolChainFamilyFlag
) {
400 String target
= null;
401 String toolchain
= null;
402 String toolchainFamily
= null;
403 List
<String
> archList
= null;
405 String targetName
= null;
406 String optionName
= null;
408 Object
[] returns
= get(from
, xPath
);
409 if (returns
== null) {
410 return new String
[0][5];
413 List
<String
[]> optionList
= new ArrayList
<String
[]>();
414 OptionDocument
.Option option
;
416 for (int i
= 0; i
< returns
.length
; i
++) {
417 option
= (OptionDocument
.Option
) returns
[i
];
420 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
422 // put to result[][5] array in above order.
425 if (option
.getBuildTargets() == null) {
429 target
= option
.getBuildTargets().toString();
431 if (target
!= null) {
432 targetList
= target
.split(" ");
434 targetList
= new String
[1];
435 targetList
[0] = null;
438 if (toolChainFamilyFlag
) {
439 toolchainFamily
= option
.getToolChainFamily();
440 if (toolchainFamily
!= null) {
441 toolchain
= toolchainFamily
.toString();
446 toolchain
= option
.getTagName();
449 archList
= new ArrayList
<String
>();
450 @SuppressWarnings("unchecked")
451 List
<String
> archEnumList
= option
.getSupArchList();
452 if (archEnumList
== null) {
455 archList
.addAll(archEnumList
);
457 Iterator it = archEnumList.iterator();
458 while (it.hasNext()) {
459 System.out.println(it.next().getClass().getName());
460 SupportedArchitectures.Enum archType = it.next();
461 archList.add(archType.toString());
466 cmd
= option
.getToolCode();
468 optionName
= option
.getStringValue();
469 for (int t
= 0; t
< targetList
.length
; t
++) {
470 for (int j
= 0; j
< archList
.size(); j
++) {
471 optionList
.add(new String
[] { targetList
[t
],
472 toolchain
, archList
.get(j
), cmd
, optionName
});
477 String
[][] result
= new String
[optionList
.size()][5];
478 for (int i
= 0; i
< optionList
.size(); i
++) {
479 result
[i
][0] = optionList
.get(i
)[0];
480 result
[i
][1] = optionList
.get(i
)[1];
481 result
[i
][2] = optionList
.get(i
)[2];
482 result
[i
][3] = optionList
.get(i
)[3];
483 result
[i
][4] = optionList
.get(i
)[4];
488 public static String
[][] getModuleBuildOptions(boolean toolChainFamilyFlag
) {
491 if (toolChainFamilyFlag
== true) {
492 xPath
= new String
[] {
493 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
494 "/Options/Option[@ToolChainFamily]", };
496 xPath
= new String
[] {
497 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
498 "/Options/Option[@TagName]", };
500 return getOptions("ModuleSaBuildOptions", xPath
, toolChainFamilyFlag
);
503 public static String
[][] getPlatformBuildOptions(boolean toolChainFamilyFlag
) {
506 if (toolChainFamilyFlag
== true) {
507 xPath
= new String
[] {
508 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
509 "/BuildOptions/Options/Option[@ToolChainFamily]", };
511 xPath
= new String
[] {
512 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
513 "/BuildOptions/Options/Option[@TagName]", };
516 return getOptions("PlatformSurfaceArea", xPath
, toolChainFamilyFlag
);
519 public static ToolChainInfo
getFpdToolChainInfo() {
520 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
522 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
523 if (returns
== null || returns
.length
== 0) {
527 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
528 ToolChainInfo toolChainInfo
= new ToolChainInfo();
529 toolChainInfo
.addTargets(item
.getBuildTargets().toString());
530 toolChainInfo
.addArchs(item
.getSupportedArchitectures().toString());
531 toolChainInfo
.addTagnames((String
)null);
532 return toolChainInfo
;
536 * Retrieve <xxxHeader>/ModuleType
538 * @returns The module type name if elements are found at the known xpath
539 * @returns null if nothing is there
541 public static String
getModuleType() {
542 String
[] xPath
= new String
[] { "/ModuleType" };
544 Object
[] returns
= get(xPath
);
545 if (returns
!= null && returns
.length
> 0) {
546 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
547 return type
.enumValue().toString();
554 * Retrieve PackageDependencies/Package
559 * @returns package name list if elements are found at the known xpath
560 * @returns null if nothing is there
562 public static PackageIdentification
[] getDependencePkg(String arch
) {
564 String packageGuid
= null;
565 String packageVersion
= null;
568 xPath
= new String
[] { "/Package" };
570 Object
[] returns
= get("PackageDependencies", xPath
);
571 if (returns
== null) {
572 return new PackageIdentification
[0];
574 PackageIdentification
[] packageIdList
= new PackageIdentification
[returns
.length
];
575 for (int i
= 0; i
< returns
.length
; i
++) {
576 PackageDependenciesDocument
.PackageDependencies
.Package item
= (PackageDependenciesDocument
.PackageDependencies
.Package
) returns
[i
];
577 @SuppressWarnings("unchecked")
578 List
<String
> archList
= item
.getSupArchList();
579 if (arch
== null || archList
== null || archList
.contains(arch
)) {
580 packageGuid
= item
.getPackageGuid();
581 packageVersion
= item
.getPackageVersion();
582 packageIdList
[i
] = (new PackageIdentification(null, packageGuid
,
586 return packageIdList
;
590 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
593 * Library class usage
595 * @returns LibraryClass objects list if elements are found at the known
597 * @returns null if nothing is there
599 public static String
[] getLibraryClasses(String usage
) {
602 if (usage
== null || usage
.equals("")) {
603 xPath
= new String
[] { "/LibraryClass" };
605 xPath
= new String
[] { "/LibraryClass[@Usage='" + usage
+ "']" };
608 Object
[] returns
= get("LibraryClassDefinitions", xPath
);
609 if (returns
== null || returns
.length
== 0) {
610 return new String
[0];
613 LibraryClassDocument
.LibraryClass
[] libraryClassList
= (LibraryClassDocument
.LibraryClass
[]) returns
;
614 String
[] libraryClassName
= new String
[libraryClassList
.length
];
615 for (int i
= 0; i
< libraryClassList
.length
; i
++) {
616 libraryClassName
[i
] = libraryClassList
[i
].getKeyword();
618 return libraryClassName
;
622 * Retrieve ModuleEntryPoint names
624 * @returns ModuleEntryPoint name list if elements are found at the known
626 * @returns null if nothing is there
628 public static String
[] getModuleEntryPointArray() {
629 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
631 Object
[] returns
= get("Externs", xPath
);
633 if (returns
!= null && returns
.length
> 0) {
634 String
[] entryPoints
= new String
[returns
.length
];
636 for (int i
= 0; i
< returns
.length
; ++i
) {
637 entryPoints
[i
] = ((CNameType
) returns
[i
]).getStringValue();
647 * retrieve Protocol for specified usage
650 * Protocol usage arch Architecture
652 * @returns Protocol String list if elements are found at the known xpath
653 * @returns String[0] if nothing is there
655 public static String
[] getProtocolArray(String arch
, String usage
) {
657 String usageXpath
= "";
658 String archXpath
= "";
660 if (arch
== null || arch
.equals("")) {
661 return new String
[0];
663 archXpath
= "/Protocol";
664 if (usage
!= null && !usage
.equals("")) {
665 usageXpath
= "/Protocol[@Usage='" + usage
+ "']";
666 xPath
= new String
[] { usageXpath
, archXpath
};
668 return getProtocolArray(arch
);
673 Object
[] returns
= get("Protocols", xPath
);
674 if (returns
== null) {
675 return new String
[0];
677 Protocol
[] protocolList
= (Protocol
[]) returns
;
679 String
[] protocolArray
= new String
[returns
.length
];
680 for (int i
= 0; i
< returns
.length
; i
++) {
681 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
683 return protocolArray
;
687 * retrieve Protocol for specified usage
692 * @returns Protocol String list if elements are found at the known xpath
693 * @returns String[0] if nothing is there
695 public static String
[] getProtocolArray(String arch
) {
698 if (arch
== null || arch
.equals("")) {
699 return new String
[0];
701 xPath
= new String
[] { "/Protocol" };
704 Object
[] returns
= get("Protocols", xPath
);
705 if (returns
== null) {
706 return new String
[0];
708 Protocol
[] returnlList
= (Protocol
[]) returns
;
710 List
<String
> protocolList
= new ArrayList
<String
>();
712 for (int i
= 0; i
< returns
.length
; i
++) {
713 @SuppressWarnings("unchecked")
714 List
<String
> archList
= returnlList
[i
].getSupArchList();
715 if (archList
== null || archList
.contains(arch
)){
716 protocolList
.add(returnlList
[i
].getProtocolCName());
719 String
[] protocolArray
= new String
[protocolList
.size()];
720 for (int i
= 0; i
< protocolList
.size(); i
++) {
721 protocolArray
[i
] = protocolList
.get(i
);
723 return protocolArray
;
727 * Retrieve ProtocolNotify for specified usage
730 * ProtocolNotify usage
732 * @returns String[] if elements are found at the known xpath
733 * @returns String[0] if nothing is there
735 public static String
[] getProtocolNotifyArray(String arch
) {
738 if (arch
== null || arch
.equals("")) {
739 return new String
[0];
741 xPath
= new String
[] { "/ProtocolNotify" };
744 Object
[] returns
= get("Protocols", xPath
);
745 if (returns
== null) {
746 return new String
[0];
749 List
<String
> protocolNotifyList
= new ArrayList
<String
>();
751 for (int i
= 0; i
< returns
.length
; i
++) {
752 @SuppressWarnings("unchecked")
753 List
<String
> archList
= ((ProtocolNotify
) returns
[i
]).getSupArchList();
754 if (archList
== null || archList
.contains(arch
)){
755 protocolNotifyList
.add(((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName());
759 String
[] protocolNotifyArray
= new String
[protocolNotifyList
.size()];
760 for (int i
= 0; i
< protocolNotifyList
.size(); i
++) {
761 protocolNotifyArray
[i
] = protocolNotifyList
.get(i
);
763 return protocolNotifyArray
;
767 * Retrieve ProtocolNotify for specified usage
770 * ProtocolNotify usage
772 * @returns String[] if elements are found at the known xpath
773 * @returns String[0] if nothing is there
775 public static String
[] getProtocolNotifyArray(String arch
, String usage
) {
781 if (arch
== null || arch
.equals("")) {
782 return new String
[0];
784 archXpath
= "/ProtocolNotify";
785 if (usage
!= null && !usage
.equals("")) {
786 usageXpath
= "/ProtocolNotify[@Usage='" + arch
+ "']";
787 xPath
= new String
[] { archXpath
, usageXpath
};
789 return getProtocolNotifyArray(arch
);
793 Object
[] returns
= get("Protocols", xPath
);
794 if (returns
== null) {
795 return new String
[0];
798 String
[] protocolNotifyList
= new String
[returns
.length
];
800 for (int i
= 0; i
< returns
.length
; i
++) {
801 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
803 return protocolNotifyList
;
807 * Retrieve ModuleUnloadImage names
809 * @returns ModuleUnloadImage name list if elements are found at the known
811 * @returns null if nothing is there
813 public static String
[] getModuleUnloadImageArray() {
814 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
816 Object
[] returns
= get("Externs", xPath
);
817 if (returns
!= null && returns
.length
> 0) {
818 String
[] stringArray
= new String
[returns
.length
];
819 CNameType
[] doc
= (CNameType
[]) returns
;
821 for (int i
= 0; i
< returns
.length
; ++i
) {
822 stringArray
[i
] = doc
[i
].getStringValue();
834 * @returns Extern objects list if elements are found at the known xpath
835 * @returns null if nothing is there
837 public static ExternsDocument
.Externs
.Extern
[] getExternArray() {
838 String
[] xPath
= new String
[] { "/Extern" };
840 Object
[] returns
= get("Externs", xPath
);
841 if (returns
!= null && returns
.length
> 0) {
842 return (ExternsDocument
.Externs
.Extern
[]) returns
;
849 * Retrieve PpiNotify for specified arch
854 * @returns String[] if elements are found at the known xpath
855 * @returns String[0] if nothing is there
857 public static String
[] getPpiNotifyArray(String arch
) {
860 if (arch
== null || arch
.equals("")) {
861 return new String
[0];
863 xPath
= new String
[] { "/PpiNotify" };
866 Object
[] returns
= get("PPIs", xPath
);
867 if (returns
== null) {
868 return new String
[0];
872 List
<String
> ppiNotifyList
= new ArrayList
<String
>();
873 for (int i
= 0; i
< returns
.length
; i
++) {
874 @SuppressWarnings("unchecked")
875 List
<String
> archList
= ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getSupArchList();
876 if (archList
== null || archList
.contains(arch
)){
877 ppiNotifyList
.add(((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName());
881 String
[] ppiNotifyArray
= new String
[ppiNotifyList
.size()];
882 for (int i
= 0; i
< ppiNotifyList
.size(); i
++) {
883 ppiNotifyArray
[i
] = ppiNotifyList
.get(i
);
886 return ppiNotifyArray
;
890 * Retrieve PpiNotify for specified usage and arch
893 * PpiNotify arch usage PpiNotify usage
896 * @returns String[] if elements are found at the known xpath
897 * @returns String[0] if nothing is there
899 public static String
[] getPpiNotifyArray(String arch
, String usage
) {
905 if (arch
== null || arch
.equals("")) {
906 return new String
[0];
908 archXpath
= "/PpiNotify";
909 if (usage
!= null && !usage
.equals("")) {
910 usageXpath
= "/PpiNotify[@Usage='" + arch
+ "']";
911 xPath
= new String
[] { archXpath
, usageXpath
};
913 return getProtocolNotifyArray(arch
);
917 Object
[] returns
= get("PPIs", xPath
);
918 if (returns
== null) {
919 return new String
[0];
922 String
[] ppiNotifyList
= new String
[returns
.length
];
924 for (int i
= 0; i
< returns
.length
; i
++) {
925 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
927 return ppiNotifyList
;
931 * Retrieve Ppi for specified arch
936 * @returns String[] if elements are found at the known xpath
937 * @returns String[0] if nothing is there
939 public static String
[] getPpiArray(String arch
) {
942 if (arch
== null || arch
.equals("")) {
943 return new String
[0];
945 xPath
= new String
[] { "/Ppi" };
948 Object
[] returns
= get("PPIs", xPath
);
949 if (returns
== null) {
950 return new String
[0];
953 List
<String
> ppiList
= new ArrayList
<String
>();
954 for (int i
= 0; i
< returns
.length
; i
++) {
955 @SuppressWarnings("unchecked")
956 List
<String
> archList
= ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getSupArchList();
957 if (archList
== null || archList
.contains(arch
)){
958 ppiList
.add(((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName());
962 String
[] ppiArray
= new String
[ppiList
.size()];
963 for (int i
= 0; i
< ppiList
.size(); i
++) {
964 ppiArray
[i
] = ppiList
.get(i
);
970 * Retrieve PpiNotify for specified usage and arch
973 * PpiNotify arch usage PpiNotify usage
976 * @returns String[] if elements are found at the known xpath
977 * @returns String[0] if nothing is there
979 public static String
[] getPpiArray(String arch
, String usage
) {
985 if (arch
== null || arch
.equals("")) {
986 return new String
[0];
989 if (usage
!= null && !usage
.equals("")) {
990 usageXpath
= "/Ppi[@Usage='" + arch
+ "']";
991 xPath
= new String
[] { archXpath
, usageXpath
};
993 return getProtocolNotifyArray(arch
);
997 Object
[] returns
= get("PPIs", xPath
);
998 if (returns
== null) {
999 return new String
[0];
1002 String
[] ppiList
= new String
[returns
.length
];
1004 for (int i
= 0; i
< returns
.length
; i
++) {
1005 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
1011 * Retrieve GuidEntry information for specified usage
1016 * @returns GuidEntry objects list if elements are found at the known xpath
1017 * @returns null if nothing is there
1019 public static String
[] getGuidEntryArray(String arch
) {
1022 if (arch
== null || arch
.equals("")) {
1023 xPath
= new String
[] { "/GuidCNames" };
1025 xPath
= new String
[] { "/GuidCNames" };
1028 Object
[] returns
= get("Guids", xPath
);
1029 if (returns
== null) {
1030 return new String
[0];
1033 List
<String
> guidList
= new ArrayList
<String
>();
1034 for (int i
= 0; i
< returns
.length
; i
++) {
1035 @SuppressWarnings("unchecked")
1036 List
<String
> archList
= ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getSupArchList();
1037 if (archList
== null || archList
.contains(arch
)){
1038 guidList
.add(((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName());
1042 String
[] guidArray
= new String
[guidList
.size()];
1043 for (int i
= 0; i
< guidList
.size(); i
++) {
1044 guidArray
[i
] = guidList
.get(i
);
1051 * Retrieve GuidEntry information for specified usage
1054 * GuidEntry arch usage GuidEntry usage
1056 * @returns GuidEntry objects list if elements are found at the known xpath
1057 * @returns null if nothing is there
1059 public static String
[] getGuidEntryArray(String arch
, String usage
) {
1064 if (arch
== null || arch
.equals("")) {
1065 return new String
[0];
1067 archXpath
= "/GuidEntry";
1068 if (usage
!= null && !usage
.equals("")) {
1069 usageXpath
= "/GuidEntry[@Usage='" + arch
+ "']";
1070 xPath
= new String
[] { archXpath
, usageXpath
};
1072 return getProtocolNotifyArray(arch
);
1076 Object
[] returns
= get("Guids", xPath
);
1077 if (returns
== null) {
1078 return new String
[0];
1081 String
[] guidList
= new String
[returns
.length
];
1083 for (int i
= 0; i
< returns
.length
; i
++) {
1084 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1090 * Retrieve Library instance information
1095 * Library instance usage
1097 * @returns library instance name list if elements are found at the known
1099 * @returns null if nothing is there
1101 public static ModuleIdentification
[] getLibraryInstance(String arch
) {
1103 String saGuid
= null;
1104 String saVersion
= null;
1105 String pkgGuid
= null;
1106 String pkgVersion
= null;
1108 if (arch
== null || arch
.equalsIgnoreCase("")) {
1109 xPath
= new String
[] { "/Instance" };
1112 // Since Schema don't have SupArchList now, so the follow Xpath is
1113 // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]
1114 // don't have effect.
1116 xPath
= new String
[] { "/Instance[not(@SupArchList) or @SupArchList='"
1120 Object
[] returns
= get("Libraries", xPath
);
1121 if (returns
== null || returns
.length
== 0) {
1122 return new ModuleIdentification
[0];
1125 ModuleIdentification
[] saIdList
= new ModuleIdentification
[returns
.length
];
1126 for (int i
= 0; i
< returns
.length
; i
++) {
1127 LibrariesDocument
.Libraries
.Instance library
= (LibrariesDocument
.Libraries
.Instance
) returns
[i
];
1128 saGuid
= library
.getModuleGuid();
1129 saVersion
= library
.getModuleVersion();
1131 pkgGuid
= library
.getPackageGuid();
1132 pkgVersion
= library
.getPackageVersion();
1134 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1136 PackageIdentification pkgId
= new PackageIdentification(null,
1137 pkgGuid
, pkgVersion
);
1138 saId
.setPackage(pkgId
);
1147 // / This method is used for retrieving the elements information which has
1148 // / CName sub-element
1150 private static String
[] getCNames(String from
, String xPath
[]) {
1151 Object
[] returns
= get(from
, xPath
);
1152 if (returns
== null || returns
.length
== 0) {
1156 String
[] strings
= new String
[returns
.length
];
1157 for (int i
= 0; i
< returns
.length
; ++i
) {
1159 strings
[i
] = ((CNameType
) returns
[i
]).getStringValue();
1166 * Retrive library's constructor name
1168 * @returns constructor name list if elements are found at the known xpath
1169 * @returns null if nothing is there
1171 public static String
getLibConstructorName() {
1172 String
[] xPath
= new String
[] { "/Extern/Constructor" };
1174 Object
[] returns
= get("Externs", xPath
);
1175 if (returns
!= null && returns
.length
> 0) {
1176 CNameType constructor
= ((CNameType
) returns
[0]);
1177 return constructor
.getStringValue();
1184 * Retrive library's destructor name
1186 * @returns destructor name list if elements are found at the known xpath
1187 * @returns null if nothing is there
1189 public static String
getLibDestructorName() {
1190 String
[] xPath
= new String
[] { "/Extern/Destructor" };
1192 Object
[] returns
= get("Externs", xPath
);
1193 if (returns
!= null && returns
.length
> 0) {
1195 // Only support one Destructor function.
1197 CNameType destructor
= (CNameType
) returns
[0];
1198 return destructor
.getStringValue();
1205 * Retrive DriverBinding names
1207 * @returns DriverBinding name list if elements are found at the known xpath
1208 * @returns null if nothing is there
1210 public static String
[] getDriverBindingArray() {
1211 String
[] xPath
= new String
[] { "/Extern/DriverBinding" };
1212 return getCNames("Externs", xPath
);
1216 * Retrive ComponentName names
1218 * @returns ComponentName name list if elements are found at the known xpath
1219 * @returns null if nothing is there
1221 public static String
[] getComponentNameArray() {
1222 String
[] xPath
= new String
[] { "/Extern/ComponentName" };
1223 return getCNames("Externs", xPath
);
1227 * Retrive DriverConfig names
1229 * @returns DriverConfig name list if elements are found at the known xpath
1230 * @returns null if nothing is there
1232 public static String
[] getDriverConfigArray() {
1233 String
[] xPath
= new String
[] { "/Extern/DriverConfig" };
1234 return getCNames("Externs", xPath
);
1238 * Retrive DriverDiag names
1240 * @returns DriverDiag name list if elements are found at the known xpath
1241 * @returns null if nothing is there
1243 public static String
[] getDriverDiagArray() {
1244 String
[] xPath
= new String
[] { "/Extern/DriverDiag" };
1245 return getCNames("Externs", xPath
);
1249 * Retrive SetVirtualAddressMapCallBack names
1251 * @returns SetVirtualAddressMapCallBack name list if elements are found at
1253 * @returns null if nothing is there
1255 public static String
[] getSetVirtualAddressMapCallBackArray() {
1256 String
[] xPath
= new String
[] { "/Extern/SetVirtualAddressMapCallBack" };
1257 return getCNames("Externs", xPath
);
1261 * Retrive ExitBootServicesCallBack names
1263 * @returns ExitBootServicesCallBack name list if elements are found at the
1265 * @returns null if nothing is there
1267 public static String
[] getExitBootServicesCallBackArray() {
1268 String
[] xPath
= new String
[] { "/Extern/ExitBootServicesCallBack" };
1269 return getCNames("Externs", xPath
);
1273 * Retrieve module surface area file information
1275 * @returns ModuleSA objects list if elements are found at the known xpath
1276 * @returns Empty ModuleSA list if nothing is there
1278 public static Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> getFpdModules() {
1279 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1280 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1282 String fvBinding
= null;
1283 String saGuid
= null;
1284 String saVersion
= null;
1285 String pkgGuid
= null;
1286 String pkgVersion
= null;
1288 Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleMap
= new LinkedHashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
1290 if (result
== null) {
1291 return fpdModuleMap
;
1294 for (int i
= 0; i
< result
.length
; i
++) {
1296 // Get Fpd SA Module element node and add to ObjectMap.
1298 Map
<String
, XmlObject
> ObjectMap
= new HashMap
<String
, XmlObject
>();
1299 ModuleSADocument
.ModuleSA moduleSA
= (ModuleSADocument
.ModuleSA
) result
[i
];
1300 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getLibraries() != null) {
1301 ObjectMap
.put("Libraries", moduleSA
.getLibraries());
1303 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getPcdBuildDefinition() != null) {
1304 ObjectMap
.put("PcdBuildDefinition", moduleSA
1305 .getPcdBuildDefinition());
1307 if (((ModuleSADocument
.ModuleSA
) result
[i
])
1308 .getModuleSaBuildOptions() != null) {
1309 ObjectMap
.put("ModuleSaBuildOptions", moduleSA
1310 .getModuleSaBuildOptions());
1314 // Get Fpd SA Module attribute and create FpdMoudleIdentification.
1316 arch
= moduleSA
.getSupArchList().toString();
1320 saVersion
= ((ModuleSADocument
.ModuleSA
) result
[i
])
1321 .getModuleVersion();
1323 saGuid
= moduleSA
.getModuleGuid();
1324 pkgGuid
= moduleSA
.getPackageGuid();
1325 pkgVersion
= moduleSA
.getPackageVersion();
1328 // Create Module Identification which have class member of package
1331 PackageIdentification pkgId
= new PackageIdentification(null,
1332 pkgGuid
, pkgVersion
);
1333 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1336 saId
.setPackage(pkgId
);
1339 // Create FpdModule Identification which have class member of module
1343 String
[] archList
= arch
.split(" ");
1344 for (int j
= 0; j
< archList
.length
; j
++) {
1345 FpdModuleIdentification fpdSaId
= new FpdModuleIdentification(saId
, archList
[j
]);
1347 if (fvBinding
!= null) {
1348 fpdSaId
.setFvBinding(fvBinding
);
1352 // Put element to Map<FpdModuleIdentification, Map<String,
1355 fpdModuleMap
.put(fpdSaId
, ObjectMap
);
1359 return fpdModuleMap
;
1363 * Retrieve valid image names
1365 * @returns valid iamges name list if elements are found at the known xpath
1366 * @returns empty list if nothing is there
1368 public static String
[] getFpdValidImageNames() {
1369 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
1371 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1372 if (queryResult
== null) {
1373 return new String
[0];
1376 String
[] result
= new String
[queryResult
.length
];
1377 for (int i
= 0; i
< queryResult
.length
; i
++) {
1378 result
[i
] = ((XmlString
) queryResult
[i
]).getStringValue();
1384 public static XmlObject
getFpdUserExtension() {
1385 String
[] xPath
= new String
[] { "/UserExtensions" };
1387 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1388 if (queryResult
== null) {
1395 * Retrieve FV image option information
1400 * @returns option name/value list if elements are found at the known xpath
1401 * @returns empty list if nothing is there
1403 public static String
[][] getFpdOptions(String fvName
) {
1404 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
1405 + fvName
.toUpperCase() + "']/FvImageOptions" };
1406 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1407 if (queryResult
== null) {
1408 return new String
[0][];
1410 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1411 for (int i
= 0; i
< queryResult
.length
; i
++) {
1412 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1413 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
1414 .getNameValueList();
1415 Iterator iter
= namevalues
.iterator();
1416 while (iter
.hasNext()) {
1417 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1419 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1422 String
[][] result
= new String
[list
.size()][2];
1423 for (int i
= 0; i
< list
.size(); i
++) {
1424 result
[i
][0] = list
.get(i
)[0];
1425 result
[i
][1] = list
.get(i
)[1];
1431 public static XmlObject
getFpdBuildOptions() {
1432 String
[] xPath
= new String
[] { "/BuildOptions" };
1434 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1436 if (queryResult
== null || queryResult
.length
== 0) {
1439 return (XmlObject
)queryResult
[0];
1442 public static PlatformIdentification
getFpdHeader() {
1443 String
[] xPath
= new String
[] { "/PlatformHeader" };
1445 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
1447 if (returns
== null || returns
.length
== 0) {
1450 PlatformHeaderDocument
.PlatformHeader header
= (PlatformHeaderDocument
.PlatformHeader
) returns
[0];
1452 String name
= header
.getPlatformName();
1454 String guid
= header
.getGuidValue();
1456 String version
= header
.getVersion();
1458 return new PlatformIdentification(name
, guid
, version
);
1462 * Retrieve FV image attributes information
1467 * @returns attribute name/value list if elements are found at the known
1469 * @returns empty list if nothing is there
1471 public static String
[][] getFpdAttributes(String fvName
) {
1472 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
1473 + fvName
.toUpperCase() + "']/FvImageOptions" };
1474 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1475 if (queryResult
== null) {
1476 return new String
[0][];
1478 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1479 for (int i
= 0; i
< queryResult
.length
; i
++) {
1481 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1482 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1483 Iterator iter
= namevalues
.iterator();
1484 while (iter
.hasNext()) {
1485 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1487 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1490 String
[][] result
= new String
[list
.size()][2];
1491 for (int i
= 0; i
< list
.size(); i
++) {
1492 result
[i
][0] = list
.get(i
)[0];
1493 result
[i
][1] = list
.get(i
)[1];
1499 * Retrieve flash definition file name
1501 * @returns file name if elements are found at the known xpath
1502 * @returns null if nothing is there
1504 public static String
getFlashDefinitionFile() {
1505 String
[] xPath
= new String
[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
1507 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1508 if (queryResult
== null || queryResult
.length
== 0) {
1512 FileNameConvention filename
= (FileNameConvention
) queryResult
[queryResult
.length
- 1];
1513 return filename
.getStringValue();
1516 public static String
[][] getFpdGlobalVariable() {
1517 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
1518 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1519 if (queryResult
== null) {
1520 return new String
[0][];
1523 String
[][] result
= new String
[queryResult
.length
][2];
1525 for (int i
= 0; i
< queryResult
.length
; i
++) {
1526 FvImagesDocument
.FvImages
.NameValue item
= (FvImagesDocument
.FvImages
.NameValue
)queryResult
[i
];
1527 result
[i
][0] = item
.getName();
1528 result
[i
][1] = item
.getValue();
1534 * Retrieve FV image component options
1539 * @returns name/value pairs list if elements are found at the known xpath
1540 * @returns empty list if nothing is there
1542 public static String
[][] getFpdComponents(String fvName
) {
1543 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName
.toUpperCase() + "']/FvImageOptions" };
1544 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1545 if (queryResult
== null) {
1546 return new String
[0][];
1549 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1550 for (int i
= 0; i
< queryResult
.length
; i
++) {
1551 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1552 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1553 Iterator iter
= namevalues
.iterator();
1554 while (iter
.hasNext()) {
1555 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1557 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1560 String
[][] result
= new String
[list
.size()][2];
1561 for (int i
= 0; i
< list
.size(); i
++) {
1562 result
[i
][0] = list
.get(i
)[0];
1563 result
[i
][1] = list
.get(i
)[1];
1569 * Retrieve PCD tokens
1571 * @returns CName/ItemType pairs list if elements are found at the known
1573 * @returns null if nothing is there
1575 public static String
[][] getPcdTokenArray() {
1576 String
[] xPath
= new String
[] { "/PcdData" };
1578 Object
[] returns
= get("PCDs", xPath
);
1579 if (returns
== null || returns
.length
== 0) {
1583 // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns;
1584 // String[][] result = new String[pcds.length][2];
1585 // for (int i = 0; i < returns.length; ++i) {
1586 // if (pcds[i].getItemType() != null) {
1587 // result[i][1] = pcds[i].getItemType().toString();
1589 // result[i][1] = null;
1591 // result[i][0] = pcds[i].getCName();
1598 * Get the PcdToken array from module's surface area document. The array
1599 * should contains following data:
1601 * -------------------------------------------------------------------
1604 * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText
1607 * -------------------------------------------------------------------
1610 * Note: Until new schema applying, now we can only get CName, ItemType,
1613 * @return 2-array table contains all information of PCD token retrieved
1616 public static Object
[][] etModulePCDTokenArray() {
1619 // Object[][] result;
1620 // PCDs.PcdData[] pcds;
1621 // String[] xPath = new String[] { "/PcdData" };
1622 // Object[] returns = get("PCDs", xPath);
1624 // if ((returns == null) || (returns.length == 0)) {
1628 // pcds = (PCDs.PcdData[]) returns;
1629 // result = new Object[pcds.length][6];
1630 // for (index = 0; index < pcds.length; index++) {
1634 // result[index][0] = pcds[index].getCName();
1636 // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE,
1637 // // DYNAMIC, DYNAMIC_EX
1639 // if (pcds[index].getItemType() != null) {
1640 // result[index][1] = pcds[index].getItemType().toString();
1642 // result[index][1] = null;
1646 // // BUGBUG: following field can *not* be got from current MSA until
1647 // // schema changed.
1649 // // result [index][2] = pcds[index].getTokenSpaceName();
1650 // result[index][2] = null;
1651 // result[index][3] = pcds[index].getDefaultValue();
1652 // // result [index][4] = pcds[index].getUsage ();
1653 // result[index][4] = null;
1654 // // result [index][5] = pcds[index].getHelpText ();
1655 // result[index][5] = null;
1661 * Retrieve MAS header
1666 public static ModuleIdentification
getMsaHeader() {
1667 String
[] xPath
= new String
[] { "/" };
1668 Object
[] returns
= get("MsaHeader", xPath
);
1670 if (returns
== null || returns
.length
== 0) {
1674 MsaHeader msaHeader
= (MsaHeader
) returns
[0];
1676 // Get BaseName, ModuleType, GuidValue, Version
1677 // which in MsaHeader.
1679 String name
= msaHeader
.getModuleName();
1680 String moduleType
= msaHeader
.getModuleType().toString();
1681 String guid
= msaHeader
.getGuidValue();
1682 String version
= msaHeader
.getVersion();
1684 ModuleIdentification moduleId
= new ModuleIdentification(name
, guid
,
1687 moduleId
.setModuleType(moduleType
);
1693 * Retrieve Extern Specification
1697 * @return String[] If have specification element in the <extern> String[0]
1698 * If no specification element in the <extern>
1702 public static String
[] getExternSpecificaiton() {
1703 String
[] xPath
= new String
[] { "/Specification" };
1705 Object
[] queryResult
= get("Externs", xPath
);
1706 if (queryResult
== null) {
1707 return new String
[0];
1710 String
[] specificationList
= new String
[queryResult
.length
];
1711 for (int i
= 0; i
< queryResult
.length
; i
++) {
1712 specificationList
[i
] = ((Sentence
)queryResult
[i
])
1715 return specificationList
;
1719 * Retreive MsaFile which in SPD
1722 * @return String[][3] The string sequence is ModuleName, ModuleGuid,
1723 * ModuleVersion, MsaFile String[0][] If no msafile in SPD
1725 public static String
[] getSpdMsaFile() {
1726 String
[] xPath
= new String
[] { "/MsaFiles" };
1728 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1729 if (returns
== null) {
1730 return new String
[0];
1733 List
<String
> filenameList
= ((MsaFilesDocument
.MsaFiles
) returns
[0])
1735 return filenameList
.toArray(new String
[filenameList
.size()]);
1741 public static Map
<String
, String
[]> getSpdLibraryClasses() {
1742 String
[] xPath
= new String
[] { "/LibraryClassDeclarations/LibraryClass" };
1744 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1747 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
1749 Map
<String
, String
[]> libClassHeaderMap
= new HashMap
<String
, String
[]>();
1751 if (returns
== null) {
1752 return libClassHeaderMap
;
1755 for (int i
= 0; i
< returns
.length
; i
++) {
1756 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass library
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) returns
[i
];
1757 libClassHeaderMap
.put(library
.getName(), new String
[] { library
1758 .getIncludeHeader() });
1760 return libClassHeaderMap
;
1766 public static Map
<String
, String
> getSpdPackageHeaderFiles() {
1767 String
[] xPath
= new String
[] { "/PackageHeaders/IncludePkgHeader" };
1769 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1772 // Create Map, Key - ModuleType, String - PackageInclude Header file.
1774 Map
<String
, String
> packageIncludeMap
= new HashMap
<String
, String
>();
1776 if (returns
== null) {
1777 return packageIncludeMap
;
1779 // GlobalData.log.info("" + returns[0].getClass().getName());
1780 for (int i
= 0; i
< returns
.length
; i
++) {
1781 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader includeHeader
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) returns
[i
];
1782 packageIncludeMap
.put(includeHeader
.getModuleType().toString(),
1783 includeHeader
.getStringValue());
1785 return packageIncludeMap
;
1788 public static PackageIdentification
getSpdHeader() {
1789 String
[] xPath
= new String
[] { "/SpdHeader" };
1791 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1793 if (returns
== null || returns
.length
== 0) {
1797 SpdHeaderDocument
.SpdHeader header
= (SpdHeaderDocument
.SpdHeader
) returns
[0];
1799 String name
= header
.getPackageName();
1801 String guid
= header
.getGuidValue();
1803 String version
= header
.getVersion();
1805 return new PackageIdentification(name
, guid
, version
);
1811 public static Map
<String
, String
[]> getSpdGuid() {
1812 String
[] xPath
= new String
[] { "/GuidDeclarations/Entry" };
1814 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1817 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
1819 Map
<String
, String
[]> guidDeclMap
= new HashMap
<String
, String
[]>();
1820 if (returns
== null) {
1824 for (int i
= 0; i
< returns
.length
; i
++) {
1825 GuidDeclarationsDocument
.GuidDeclarations
.Entry entry
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) returns
[i
];
1826 String
[] guidPair
= new String
[2];
1827 guidPair
[0] = entry
.getCName();
1828 guidPair
[1] = entry
.getGuidValue();
1829 guidDeclMap
.put(entry
.getName(), guidPair
);
1830 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1831 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[0]);
1832 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[1]);
1840 public static Map
<String
, String
[]> getSpdProtocol() {
1841 String
[] xPath
= new String
[] { "/ProtocolDeclarations/Entry" };
1843 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1846 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1848 Map
<String
, String
[]> protoclMap
= new HashMap
<String
, String
[]>();
1850 if (returns
== null) {
1854 for (int i
= 0; i
< returns
.length
; i
++) {
1855 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry entry
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) returns
[i
];
1856 String
[] protocolPair
= new String
[2];
1858 protocolPair
[0] = entry
.getCName();
1859 protocolPair
[1] = entry
.getGuidValue();
1860 protoclMap
.put(entry
.getName(), protocolPair
);
1861 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1862 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[0]);
1863 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[1]);
1869 * getSpdPpi() Retrieve the SPD PPI Entry
1872 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
1873 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
1876 public static Map
<String
, String
[]> getSpdPpi() {
1877 String
[] xPath
= new String
[] { "/PpiDeclarations/Entry" };
1879 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1882 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1884 Map
<String
, String
[]> ppiMap
= new HashMap
<String
, String
[]>();
1886 if (returns
== null) {
1890 for (int i
= 0; i
< returns
.length
; i
++) {
1891 PpiDeclarationsDocument
.PpiDeclarations
.Entry entry
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) returns
[i
];
1892 String
[] ppiPair
= new String
[2];
1893 ppiPair
[0] = entry
.getCName();
1894 ppiPair
[1] = entry
.getGuidValue();
1895 ppiMap
.put(entry
.getName(), ppiPair
);
1901 * getToolChainFamily
1903 * This function is to retrieve ToolChainFamily attribute of FPD
1907 * @return toolChainFamily If find toolChainFamily attribute in
1908 * <BuildOptions> Null If don't have toolChainFamily in
1911 public String
getToolChainFamily() {
1912 String toolChainFamily
;
1913 String
[] xPath
= new String
[] { "/BuildOptions" };
1915 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1916 if (result
== null) {
1919 // toolChainFamily =
1920 // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies();
1921 // return toolChainFamily;
1926 * Retrieve module Guid string
1928 * @returns GUILD string if elements are found at the known xpath
1929 * @returns null if nothing is there
1931 public static String
getModuleGuid() {
1932 String
[] xPath
= new String
[] { "" };
1934 Object
[] returns
= get("MsaHeader", xPath
);
1935 if (returns
!= null && returns
.length
> 0) {
1936 String guid
= ((MsaHeaderDocument
.MsaHeader
) returns
[0])
1947 public static ModuleSADocument
.ModuleSA
[] getFpdModuleSAs() {
1948 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1949 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1950 if (result
!= null) {
1951 return (ModuleSADocument
.ModuleSA
[]) result
;
1953 return new ModuleSADocument
.ModuleSA
[0];
1957 Get name array of PCD in a module. In one module, token space
1958 is same, and token name should not be conflicted.
1962 public static String
[] getModulePcdEntryNameArray() {
1963 PcdCodedDocument
.PcdCoded
.PcdEntry
[] pcdEntries
= null;
1966 String
[] xPath
= new String
[] {"/PcdEntry"};
1967 Object
[] returns
= get ("PcdCoded", xPath
);
1969 if (returns
== null) {
1970 return new String
[0];
1973 pcdEntries
= (PcdCodedDocument
.PcdCoded
.PcdEntry
[])returns
;
1974 results
= new String
[pcdEntries
.length
];
1976 for (index
= 0; index
< pcdEntries
.length
; index
++) {
1977 results
[index
] = pcdEntries
[index
].getCName();