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 List
<String
> archList
= sourceFileNames
[i
].getSupArchList();
285 if (arch
== null || arch
.equalsIgnoreCase("") || archList
== null || archList
.contains(arch
)) {
286 outputList
.add(new String
[] {sourceFileNames
[i
].getToolCode(),sourceFileNames
[i
].getStringValue()});
290 String
[][] outputString
= new String
[outputList
.size()][2];
291 for (int index
= 0; index
< outputList
.size(); index
++) {
292 outputString
[index
][0] = outputList
.get(index
)[0];
293 outputString
[index
][1] = outputList
.get(index
)[1];
299 * Retrieve /PlatformDefinitions/OutputDirectory from FPD
301 * @returns Directory names array if elements are found at the known xpath
302 * @returns Empty if nothing is found at the known xpath
304 public static String
getFpdOutputDirectory() {
305 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
307 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
308 if (returns
== null || returns
.length
== 0) {
311 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
312 return item
.getOutputDirectory();
315 public static String
getFpdIntermediateDirectories() {
316 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
318 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
319 if (returns
== null || returns
.length
== 0) {
322 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
323 if(item
.getIntermediateDirectories() == null) {
327 return item
.getIntermediateDirectories().toString();
331 public static String
getModuleFfsKeyword() {
332 String
[] xPath
= new String
[] { "/" };
334 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
335 if (returns
== null || returns
.length
== 0) {
338 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
339 return item
.getFfsFormatKey();
342 public static String
getModuleFvBindingKeyword() {
343 String
[] xPath
= new String
[] { "/" };
345 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
346 if (returns
== null || returns
.length
== 0) {
349 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
350 return item
.getFvBinding();
353 public static List
getModuleSupportedArchs() {
354 String
[] xPath
= new String
[] { "/" };
356 Object
[] returns
= get("ModuleDefinitions", xPath
);
357 if (returns
== null || returns
.length
== 0) {
360 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
361 return item
.getSupportedArchitectures();
364 public static BuildOptionsDocument
.BuildOptions
.Ffs
[] getFpdFfs() {
365 String
[] xPath
= new String
[] {"/Ffs"};
367 Object
[] returns
= get("BuildOptions", xPath
);
368 if (returns
== null || returns
.length
== 0) {
369 return new BuildOptionsDocument
.BuildOptions
.Ffs
[0];
371 return (BuildOptionsDocument
.BuildOptions
.Ffs
[])returns
;
374 public static String
getModuleOutputFileBasename() {
375 String
[] xPath
= new String
[] { "/" };
377 Object
[] returns
= get("ModuleDefinitions", xPath
);
378 if (returns
== null || returns
.length
== 0) {
381 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
382 return item
.getOutputFileBasename();
386 * Retrieve BuildOptions/Option or Arch/Option
388 * @param toolChainFamilyFlag
389 * if true, retrieve options for toolchain family; otherwise for
392 * @returns String[][5] name, target, toolchain, arch, coommand of options
393 * if elements are found at the known xpath. String[0][] if dont
396 * @returns Empty array if nothing is there
398 public static String
[][] getOptions(String from
, String
[] xPath
, boolean toolChainFamilyFlag
) {
399 String target
= null;
400 String toolchain
= null;
401 String toolchainFamily
= null;
402 List
<String
> archList
= null;
404 String targetName
= null;
405 String optionName
= null;
407 Object
[] returns
= get(from
, xPath
);
408 if (returns
== null) {
409 return new String
[0][5];
412 List
<String
[]> optionList
= new ArrayList
<String
[]>();
413 OptionDocument
.Option option
;
415 for (int i
= 0; i
< returns
.length
; i
++) {
416 option
= (OptionDocument
.Option
) returns
[i
];
419 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
421 // put to result[][5] array in above order.
424 if (option
.getBuildTargets() == null) {
428 target
= option
.getBuildTargets().toString();
430 if (target
!= null) {
431 targetList
= target
.split(" ");
433 targetList
= new String
[1];
434 targetList
[0] = null;
437 if (toolChainFamilyFlag
) {
438 toolchainFamily
= option
.getToolChainFamily();
439 if (toolchainFamily
!= null) {
440 toolchain
= toolchainFamily
.toString();
445 toolchain
= option
.getTagName();
448 archList
= new ArrayList
<String
>();
449 List
<String
> archEnumList
= option
.getSupArchList();
450 if (archEnumList
== null) {
453 archList
.addAll(archEnumList
);
455 Iterator it = archEnumList.iterator();
456 while (it.hasNext()) {
457 System.out.println(it.next().getClass().getName());
458 SupportedArchitectures.Enum archType = it.next();
459 archList.add(archType.toString());
464 cmd
= option
.getToolCode();
466 optionName
= option
.getStringValue();
467 for (int t
= 0; t
< targetList
.length
; t
++) {
468 for (int j
= 0; j
< archList
.size(); j
++) {
469 optionList
.add(new String
[] { targetList
[t
],
470 toolchain
, archList
.get(j
), cmd
, optionName
});
475 String
[][] result
= new String
[optionList
.size()][5];
476 for (int i
= 0; i
< optionList
.size(); i
++) {
477 result
[i
][0] = optionList
.get(i
)[0];
478 result
[i
][1] = optionList
.get(i
)[1];
479 result
[i
][2] = optionList
.get(i
)[2];
480 result
[i
][3] = optionList
.get(i
)[3];
481 result
[i
][4] = optionList
.get(i
)[4];
486 public static String
[][] getModuleBuildOptions(boolean toolChainFamilyFlag
) {
489 if (toolChainFamilyFlag
== true) {
490 xPath
= new String
[] {
491 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
492 "/Options/Option[@ToolChainFamily]", };
494 xPath
= new String
[] {
495 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
496 "/Options/Option[@TagName]", };
498 return getOptions("ModuleSaBuildOptions", xPath
, toolChainFamilyFlag
);
501 public static String
[][] getPlatformBuildOptions(boolean toolChainFamilyFlag
) {
504 if (toolChainFamilyFlag
== true) {
505 xPath
= new String
[] {
506 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
507 "/BuildOptions/Options/Option[@ToolChainFamily]", };
509 xPath
= new String
[] {
510 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
511 "/BuildOptions/Options/Option[@TagName]", };
514 return getOptions("PlatformSurfaceArea", xPath
, toolChainFamilyFlag
);
517 public static ToolChainInfo
getFpdToolChainInfo() {
518 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
520 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
521 if (returns
== null || returns
.length
== 0) {
525 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
526 ToolChainInfo toolChainInfo
= new ToolChainInfo();
527 toolChainInfo
.addTargets(item
.getBuildTargets().toString());
528 toolChainInfo
.addArchs(item
.getSupportedArchitectures().toString());
529 toolChainInfo
.addTagnames((String
)null);
530 return toolChainInfo
;
534 * Retrieve <xxxHeader>/ModuleType
536 * @returns The module type name if elements are found at the known xpath
537 * @returns null if nothing is there
539 public static String
getModuleType() {
540 String
[] xPath
= new String
[] { "/ModuleType" };
542 Object
[] returns
= get(xPath
);
543 if (returns
!= null && returns
.length
> 0) {
544 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
545 return type
.enumValue().toString();
552 * Retrieve PackageDependencies/Package
557 * @returns package name list if elements are found at the known xpath
558 * @returns null if nothing is there
560 public static PackageIdentification
[] getDependencePkg(String arch
) {
562 String packageGuid
= null;
563 String packageVersion
= null;
566 xPath
= new String
[] { "/Package" };
568 Object
[] returns
= get("PackageDependencies", xPath
);
569 if (returns
== null) {
570 return new PackageIdentification
[0];
572 PackageIdentification
[] packageIdList
= new PackageIdentification
[returns
.length
];
573 for (int i
= 0; i
< returns
.length
; i
++) {
574 PackageDependenciesDocument
.PackageDependencies
.Package item
= (PackageDependenciesDocument
.PackageDependencies
.Package
) returns
[i
];
575 List
<String
> archList
= item
.getSupArchList();
576 if (arch
== null || archList
== null || archList
.contains(arch
)) {
577 packageGuid
= item
.getPackageGuid();
578 packageVersion
= item
.getPackageVersion();
579 packageIdList
[i
] = (new PackageIdentification(null, packageGuid
,
583 return packageIdList
;
587 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
590 * Library class usage
592 * @returns LibraryClass objects list if elements are found at the known
594 * @returns null if nothing is there
596 public static String
[] getLibraryClasses(String usage
) {
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 String
[] libraryClassName
= new String
[libraryClassList
.length
];
612 for (int i
= 0; i
< libraryClassList
.length
; i
++) {
613 libraryClassName
[i
] = libraryClassList
[i
].getKeyword();
615 return libraryClassName
;
619 * Retrieve ModuleEntryPoint names
621 * @returns ModuleEntryPoint name list if elements are found at the known
623 * @returns null if nothing is there
625 public static String
[] getModuleEntryPointArray() {
626 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
628 Object
[] returns
= get("Externs", xPath
);
630 if (returns
!= null && returns
.length
> 0) {
631 String
[] entryPoints
= new String
[returns
.length
];
633 for (int i
= 0; i
< returns
.length
; ++i
) {
634 entryPoints
[i
] = ((CNameType
) returns
[i
]).getStringValue();
644 * retrieve Protocol for specified usage
647 * Protocol usage arch Architecture
649 * @returns Protocol String list if elements are found at the known xpath
650 * @returns String[0] if nothing is there
652 public static String
[] getProtocolArray(String arch
, String usage
) {
654 String usageXpath
= "";
655 String archXpath
= "";
657 if (arch
== null || arch
.equals("")) {
658 return new String
[0];
660 archXpath
= "/Protocol";
661 if (usage
!= null && !usage
.equals("")) {
662 usageXpath
= "/Protocol[@Usage='" + usage
+ "']";
663 xPath
= new String
[] { usageXpath
, archXpath
};
665 return getProtocolArray(arch
);
670 Object
[] returns
= get("Protocols", xPath
);
671 if (returns
== null) {
672 return new String
[0];
674 Protocol
[] protocolList
= (Protocol
[]) returns
;
676 String
[] protocolArray
= new String
[returns
.length
];
677 for (int i
= 0; i
< returns
.length
; i
++) {
678 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
680 return protocolArray
;
684 * retrieve Protocol for specified usage
689 * @returns Protocol String list if elements are found at the known xpath
690 * @returns String[0] if nothing is there
692 public static String
[] getProtocolArray(String arch
) {
695 if (arch
== null || arch
.equals("")) {
696 return new String
[0];
698 xPath
= new String
[] { "/Protocol" };
701 Object
[] returns
= get("Protocols", xPath
);
702 if (returns
== null) {
703 return new String
[0];
705 Protocol
[] returnlList
= (Protocol
[]) returns
;
707 List
<String
> protocolList
= new ArrayList
<String
>();
709 for (int i
= 0; i
< returns
.length
; i
++) {
710 List
<String
> archList
= returnlList
[i
].getSupArchList();
711 if (archList
== null || archList
.contains(arch
)){
712 protocolList
.add(returnlList
[i
].getProtocolCName());
715 String
[] protocolArray
= new String
[protocolList
.size()];
716 for (int i
= 0; i
< protocolList
.size(); i
++) {
717 protocolArray
[i
] = protocolList
.get(i
);
719 return protocolArray
;
723 * Retrieve ProtocolNotify for specified usage
726 * ProtocolNotify usage
728 * @returns String[] if elements are found at the known xpath
729 * @returns String[0] if nothing is there
731 public static String
[] getProtocolNotifyArray(String arch
) {
734 if (arch
== null || arch
.equals("")) {
735 return new String
[0];
737 xPath
= new String
[] { "/ProtocolNotify" };
740 Object
[] returns
= get("Protocols", xPath
);
741 if (returns
== null) {
742 return new String
[0];
745 List
<String
> protocolNotifyList
= new ArrayList
<String
>();
747 for (int i
= 0; i
< returns
.length
; i
++) {
748 List
<String
> archList
= ((ProtocolNotify
) returns
[i
]).getSupArchList();
749 if (archList
== null || archList
.contains(arch
)){
750 protocolNotifyList
.add(((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName());
754 String
[] protocolNotifyArray
= new String
[protocolNotifyList
.size()];
755 for (int i
= 0; i
< protocolNotifyList
.size(); i
++) {
756 protocolNotifyArray
[i
] = protocolNotifyList
.get(i
);
758 return protocolNotifyArray
;
762 * Retrieve ProtocolNotify for specified usage
765 * ProtocolNotify usage
767 * @returns String[] if elements are found at the known xpath
768 * @returns String[0] if nothing is there
770 public static String
[] getProtocolNotifyArray(String arch
, String usage
) {
776 if (arch
== null || arch
.equals("")) {
777 return new String
[0];
779 archXpath
= "/ProtocolNotify";
780 if (usage
!= null && !usage
.equals("")) {
781 usageXpath
= "/ProtocolNotify[@Usage='" + arch
+ "']";
782 xPath
= new String
[] { archXpath
, usageXpath
};
784 return getProtocolNotifyArray(arch
);
788 Object
[] returns
= get("Protocols", xPath
);
789 if (returns
== null) {
790 return new String
[0];
793 String
[] protocolNotifyList
= new String
[returns
.length
];
795 for (int i
= 0; i
< returns
.length
; i
++) {
796 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
798 return protocolNotifyList
;
802 * Retrieve ModuleUnloadImage names
804 * @returns ModuleUnloadImage name list if elements are found at the known
806 * @returns null if nothing is there
808 public static String
[] getModuleUnloadImageArray() {
809 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
811 Object
[] returns
= get("Externs", xPath
);
812 if (returns
!= null && returns
.length
> 0) {
813 String
[] stringArray
= new String
[returns
.length
];
814 CNameType
[] doc
= (CNameType
[]) returns
;
816 for (int i
= 0; i
< returns
.length
; ++i
) {
817 stringArray
[i
] = doc
[i
].getStringValue();
829 * @returns Extern objects list if elements are found at the known xpath
830 * @returns null if nothing is there
832 public static ExternsDocument
.Externs
.Extern
[] getExternArray() {
833 String
[] xPath
= new String
[] { "/Extern" };
835 Object
[] returns
= get("Externs", xPath
);
836 if (returns
!= null && returns
.length
> 0) {
837 return (ExternsDocument
.Externs
.Extern
[]) returns
;
844 * Retrieve PpiNotify for specified arch
849 * @returns String[] if elements are found at the known xpath
850 * @returns String[0] if nothing is there
852 public static String
[] getPpiNotifyArray(String arch
) {
855 if (arch
== null || arch
.equals("")) {
856 return new String
[0];
858 xPath
= new String
[] { "/PpiNotify" };
861 Object
[] returns
= get("PPIs", xPath
);
862 if (returns
== null) {
863 return new String
[0];
867 List
<String
> ppiNotifyList
= new ArrayList
<String
>();
868 for (int i
= 0; i
< returns
.length
; i
++) {
869 List
<String
> archList
= ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getSupArchList();
870 if (archList
== null || archList
.contains(arch
)){
871 ppiNotifyList
.add(((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName());
875 String
[] ppiNotifyArray
= new String
[ppiNotifyList
.size()];
876 for (int i
= 0; i
< ppiNotifyList
.size(); i
++) {
877 ppiNotifyArray
[i
] = ppiNotifyList
.get(i
);
880 return ppiNotifyArray
;
884 * Retrieve PpiNotify for specified usage and arch
887 * PpiNotify arch usage PpiNotify usage
890 * @returns String[] if elements are found at the known xpath
891 * @returns String[0] if nothing is there
893 public static String
[] getPpiNotifyArray(String arch
, String usage
) {
899 if (arch
== null || arch
.equals("")) {
900 return new String
[0];
902 archXpath
= "/PpiNotify";
903 if (usage
!= null && !usage
.equals("")) {
904 usageXpath
= "/PpiNotify[@Usage='" + arch
+ "']";
905 xPath
= new String
[] { archXpath
, usageXpath
};
907 return getProtocolNotifyArray(arch
);
911 Object
[] returns
= get("PPIs", xPath
);
912 if (returns
== null) {
913 return new String
[0];
916 String
[] ppiNotifyList
= new String
[returns
.length
];
918 for (int i
= 0; i
< returns
.length
; i
++) {
919 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
921 return ppiNotifyList
;
925 * Retrieve Ppi for specified arch
930 * @returns String[] if elements are found at the known xpath
931 * @returns String[0] if nothing is there
933 public static String
[] getPpiArray(String arch
) {
936 if (arch
== null || arch
.equals("")) {
937 return new String
[0];
939 xPath
= new String
[] { "/Ppi" };
942 Object
[] returns
= get("PPIs", xPath
);
943 if (returns
== null) {
944 return new String
[0];
947 List
<String
> ppiList
= new ArrayList
<String
>();
948 for (int i
= 0; i
< returns
.length
; i
++) {
949 List
<String
> archList
= ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getSupArchList();
950 if (archList
== null || archList
.contains(arch
)){
951 ppiList
.add(((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName());
955 String
[] ppiArray
= new String
[ppiList
.size()];
956 for (int i
= 0; i
< ppiList
.size(); i
++) {
957 ppiArray
[i
] = ppiList
.get(i
);
963 * Retrieve PpiNotify for specified usage and arch
966 * PpiNotify arch usage PpiNotify usage
969 * @returns String[] if elements are found at the known xpath
970 * @returns String[0] if nothing is there
972 public static String
[] getPpiArray(String arch
, String usage
) {
978 if (arch
== null || arch
.equals("")) {
979 return new String
[0];
982 if (usage
!= null && !usage
.equals("")) {
983 usageXpath
= "/Ppi[@Usage='" + arch
+ "']";
984 xPath
= new String
[] { archXpath
, usageXpath
};
986 return getProtocolNotifyArray(arch
);
990 Object
[] returns
= get("PPIs", xPath
);
991 if (returns
== null) {
992 return new String
[0];
995 String
[] ppiList
= new String
[returns
.length
];
997 for (int i
= 0; i
< returns
.length
; i
++) {
998 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
1004 * Retrieve GuidEntry information for specified usage
1009 * @returns GuidEntry objects list if elements are found at the known xpath
1010 * @returns null if nothing is there
1012 public static String
[] getGuidEntryArray(String arch
) {
1015 if (arch
== null || arch
.equals("")) {
1016 xPath
= new String
[] { "/GuidCNames" };
1018 xPath
= new String
[] { "/GuidCNames" };
1021 Object
[] returns
= get("Guids", xPath
);
1022 if (returns
== null) {
1023 return new String
[0];
1026 List
<String
> guidList
= new ArrayList
<String
>();
1027 for (int i
= 0; i
< returns
.length
; i
++) {
1028 List
<String
> archList
= ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getSupArchList();
1029 if (archList
== null || archList
.contains(arch
)){
1030 guidList
.add(((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName());
1034 String
[] guidArray
= new String
[guidList
.size()];
1035 for (int i
= 0; i
< guidList
.size(); i
++) {
1036 guidArray
[i
] = guidList
.get(i
);
1043 * Retrieve GuidEntry information for specified usage
1046 * GuidEntry arch usage GuidEntry usage
1048 * @returns GuidEntry objects list if elements are found at the known xpath
1049 * @returns null if nothing is there
1051 public static String
[] getGuidEntryArray(String arch
, String usage
) {
1056 if (arch
== null || arch
.equals("")) {
1057 return new String
[0];
1059 archXpath
= "/GuidEntry";
1060 if (usage
!= null && !usage
.equals("")) {
1061 usageXpath
= "/GuidEntry[@Usage='" + arch
+ "']";
1062 xPath
= new String
[] { archXpath
, usageXpath
};
1064 return getProtocolNotifyArray(arch
);
1068 Object
[] returns
= get("Guids", xPath
);
1069 if (returns
== null) {
1070 return new String
[0];
1073 String
[] guidList
= new String
[returns
.length
];
1075 for (int i
= 0; i
< returns
.length
; i
++) {
1076 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1082 * Retrieve Library instance information
1087 * Library instance usage
1089 * @returns library instance name list if elements are found at the known
1091 * @returns null if nothing is there
1093 public static ModuleIdentification
[] getLibraryInstance(String arch
) {
1095 String saGuid
= null;
1096 String saVersion
= null;
1097 String pkgGuid
= null;
1098 String pkgVersion
= null;
1100 if (arch
== null || arch
.equalsIgnoreCase("")) {
1101 xPath
= new String
[] { "/Instance" };
1104 // Since Schema don't have SupArchList now, so the follow Xpath is
1105 // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]
1106 // don't have effect.
1108 xPath
= new String
[] { "/Instance[not(@SupArchList) or @SupArchList='"
1112 Object
[] returns
= get("Libraries", xPath
);
1113 if (returns
== null || returns
.length
== 0) {
1114 return new ModuleIdentification
[0];
1117 ModuleIdentification
[] saIdList
= new ModuleIdentification
[returns
.length
];
1118 for (int i
= 0; i
< returns
.length
; i
++) {
1119 LibrariesDocument
.Libraries
.Instance library
= (LibrariesDocument
.Libraries
.Instance
) returns
[i
];
1120 saGuid
= library
.getModuleGuid();
1121 saVersion
= library
.getModuleVersion();
1123 pkgGuid
= library
.getPackageGuid();
1124 pkgVersion
= library
.getPackageVersion();
1126 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1128 PackageIdentification pkgId
= new PackageIdentification(null,
1129 pkgGuid
, pkgVersion
);
1130 saId
.setPackage(pkgId
);
1139 // / This method is used for retrieving the elements information which has
1140 // / CName sub-element
1142 private static String
[] getCNames(String from
, String xPath
[]) {
1143 Object
[] returns
= get(from
, xPath
);
1144 if (returns
== null || returns
.length
== 0) {
1148 String
[] strings
= new String
[returns
.length
];
1149 for (int i
= 0; i
< returns
.length
; ++i
) {
1151 strings
[i
] = ((CNameType
) returns
[i
]).getStringValue();
1158 * Retrive library's constructor name
1160 * @returns constructor name list if elements are found at the known xpath
1161 * @returns null if nothing is there
1163 public static String
getLibConstructorName() {
1164 String
[] xPath
= new String
[] { "/Extern/Constructor" };
1166 Object
[] returns
= get("Externs", xPath
);
1167 if (returns
!= null && returns
.length
> 0) {
1168 CNameType constructor
= ((CNameType
) returns
[0]);
1169 return constructor
.getStringValue();
1176 * Retrive library's destructor name
1178 * @returns destructor name list if elements are found at the known xpath
1179 * @returns null if nothing is there
1181 public static String
getLibDestructorName() {
1182 String
[] xPath
= new String
[] { "/Extern/Destructor" };
1184 Object
[] returns
= get("Externs", xPath
);
1185 if (returns
!= null && returns
.length
> 0) {
1187 // Only support one Destructor function.
1189 CNameType destructor
= (CNameType
) returns
[0];
1190 return destructor
.getStringValue();
1197 * Retrive DriverBinding names
1199 * @returns DriverBinding name list if elements are found at the known xpath
1200 * @returns null if nothing is there
1202 public static String
[] getDriverBindingArray() {
1203 String
[] xPath
= new String
[] { "/Extern/DriverBinding" };
1204 return getCNames("Externs", xPath
);
1208 * Retrive ComponentName names
1210 * @returns ComponentName name list if elements are found at the known xpath
1211 * @returns null if nothing is there
1213 public static String
[] getComponentNameArray() {
1214 String
[] xPath
= new String
[] { "/Extern/ComponentName" };
1215 return getCNames("Externs", xPath
);
1219 * Retrive DriverConfig names
1221 * @returns DriverConfig name list if elements are found at the known xpath
1222 * @returns null if nothing is there
1224 public static String
[] getDriverConfigArray() {
1225 String
[] xPath
= new String
[] { "/Extern/DriverConfig" };
1226 return getCNames("Externs", xPath
);
1230 * Retrive DriverDiag names
1232 * @returns DriverDiag name list if elements are found at the known xpath
1233 * @returns null if nothing is there
1235 public static String
[] getDriverDiagArray() {
1236 String
[] xPath
= new String
[] { "/Extern/DriverDiag" };
1237 return getCNames("Externs", xPath
);
1241 * Retrive SetVirtualAddressMapCallBack names
1243 * @returns SetVirtualAddressMapCallBack name list if elements are found at
1245 * @returns null if nothing is there
1247 public static String
[] getSetVirtualAddressMapCallBackArray() {
1248 String
[] xPath
= new String
[] { "/Extern/SetVirtualAddressMapCallBack" };
1249 return getCNames("Externs", xPath
);
1253 * Retrive ExitBootServicesCallBack names
1255 * @returns ExitBootServicesCallBack name list if elements are found at the
1257 * @returns null if nothing is there
1259 public static String
[] getExitBootServicesCallBackArray() {
1260 String
[] xPath
= new String
[] { "/Extern/ExitBootServicesCallBack" };
1261 return getCNames("Externs", xPath
);
1265 * Retrieve module surface area file information
1267 * @returns ModuleSA objects list if elements are found at the known xpath
1268 * @returns Empty ModuleSA list if nothing is there
1270 public static Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> getFpdModules() {
1271 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1272 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1274 String fvBinding
= null;
1275 String saGuid
= null;
1276 String saVersion
= null;
1277 String pkgGuid
= null;
1278 String pkgVersion
= null;
1280 Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleMap
= new LinkedHashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
1282 if (result
== null) {
1283 return fpdModuleMap
;
1286 for (int i
= 0; i
< result
.length
; i
++) {
1288 // Get Fpd SA Module element node and add to ObjectMap.
1290 Map
<String
, XmlObject
> ObjectMap
= new HashMap
<String
, XmlObject
>();
1291 ModuleSADocument
.ModuleSA moduleSA
= (ModuleSADocument
.ModuleSA
) result
[i
];
1292 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getLibraries() != null) {
1293 ObjectMap
.put("Libraries", moduleSA
.getLibraries());
1295 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getPcdBuildDefinition() != null) {
1296 ObjectMap
.put("PcdBuildDefinition", moduleSA
1297 .getPcdBuildDefinition());
1299 if (((ModuleSADocument
.ModuleSA
) result
[i
])
1300 .getModuleSaBuildOptions() != null) {
1301 ObjectMap
.put("ModuleSaBuildOptions", moduleSA
1302 .getModuleSaBuildOptions());
1306 // Get Fpd SA Module attribute and create FpdMoudleIdentification.
1308 arch
= moduleSA
.getSupArchList().toString();
1312 saVersion
= ((ModuleSADocument
.ModuleSA
) result
[i
])
1313 .getModuleVersion();
1315 saGuid
= moduleSA
.getModuleGuid();
1316 pkgGuid
= moduleSA
.getPackageGuid();
1317 pkgVersion
= moduleSA
.getPackageVersion();
1320 // Create Module Identification which have class member of package
1323 PackageIdentification pkgId
= new PackageIdentification(null,
1324 pkgGuid
, pkgVersion
);
1325 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1328 saId
.setPackage(pkgId
);
1331 // Create FpdModule Identification which have class member of module
1335 String
[] archList
= arch
.split(" ");
1336 for (int j
= 0; j
< archList
.length
; j
++) {
1337 FpdModuleIdentification fpdSaId
= new FpdModuleIdentification(saId
, archList
[j
]);
1339 if (fvBinding
!= null) {
1340 fpdSaId
.setFvBinding(fvBinding
);
1344 // Put element to Map<FpdModuleIdentification, Map<String,
1347 fpdModuleMap
.put(fpdSaId
, ObjectMap
);
1351 return fpdModuleMap
;
1355 * Retrieve valid image names
1357 * @returns valid iamges name list if elements are found at the known xpath
1358 * @returns empty list if nothing is there
1360 public static String
[] getFpdValidImageNames() {
1361 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
1363 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1364 if (queryResult
== null) {
1365 return new String
[0];
1368 String
[] result
= new String
[queryResult
.length
];
1369 for (int i
= 0; i
< queryResult
.length
; i
++) {
1370 result
[i
] = ((XmlString
) queryResult
[i
]).getStringValue();
1376 public static XmlObject
getFpdUserExtension() {
1377 String
[] xPath
= new String
[] { "/UserExtensions" };
1379 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1380 if (queryResult
== null) {
1387 * Retrieve FV image option information
1392 * @returns option name/value list if elements are found at the known xpath
1393 * @returns empty list if nothing is there
1395 public static String
[][] getFpdOptions(String fvName
) {
1396 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
1397 + fvName
.toUpperCase() + "']/FvImageOptions" };
1398 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1399 if (queryResult
== null) {
1400 return new String
[0][];
1402 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1403 for (int i
= 0; i
< queryResult
.length
; i
++) {
1404 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1405 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
1406 .getNameValueList();
1407 Iterator iter
= namevalues
.iterator();
1408 while (iter
.hasNext()) {
1409 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1411 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1414 String
[][] result
= new String
[list
.size()][2];
1415 for (int i
= 0; i
< list
.size(); i
++) {
1416 result
[i
][0] = list
.get(i
)[0];
1417 result
[i
][1] = list
.get(i
)[1];
1423 public static XmlObject
getFpdBuildOptions() {
1424 String
[] xPath
= new String
[] { "/BuildOptions" };
1426 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1428 if (queryResult
== null || queryResult
.length
== 0) {
1431 return (XmlObject
)queryResult
[0];
1434 public static PlatformIdentification
getFpdHeader() {
1435 String
[] xPath
= new String
[] { "/PlatformHeader" };
1437 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
1439 if (returns
== null || returns
.length
== 0) {
1442 PlatformHeaderDocument
.PlatformHeader header
= (PlatformHeaderDocument
.PlatformHeader
) returns
[0];
1444 String name
= header
.getPlatformName();
1446 String guid
= header
.getGuidValue();
1448 String version
= header
.getVersion();
1450 return new PlatformIdentification(name
, guid
, version
);
1454 * Retrieve FV image attributes information
1459 * @returns attribute name/value list if elements are found at the known
1461 * @returns empty list if nothing is there
1463 public static String
[][] getFpdAttributes(String fvName
) {
1464 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
1465 + fvName
.toUpperCase() + "']/FvImageOptions" };
1466 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1467 if (queryResult
== null) {
1468 return new String
[0][];
1470 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1471 for (int i
= 0; i
< queryResult
.length
; i
++) {
1473 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1474 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1475 Iterator iter
= namevalues
.iterator();
1476 while (iter
.hasNext()) {
1477 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1479 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1482 String
[][] result
= new String
[list
.size()][2];
1483 for (int i
= 0; i
< list
.size(); i
++) {
1484 result
[i
][0] = list
.get(i
)[0];
1485 result
[i
][1] = list
.get(i
)[1];
1491 * Retrieve flash definition file name
1493 * @returns file name if elements are found at the known xpath
1494 * @returns null if nothing is there
1496 public static String
getFlashDefinitionFile() {
1497 String
[] xPath
= new String
[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
1499 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1500 if (queryResult
== null || queryResult
.length
== 0) {
1504 FileNameConvention filename
= (FileNameConvention
) queryResult
[queryResult
.length
- 1];
1505 return filename
.getStringValue();
1508 public static String
[][] getFpdGlobalVariable() {
1509 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
1510 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1511 if (queryResult
== null) {
1512 return new String
[0][];
1515 String
[][] result
= new String
[queryResult
.length
][2];
1517 for (int i
= 0; i
< queryResult
.length
; i
++) {
1518 FvImagesDocument
.FvImages
.NameValue item
= (FvImagesDocument
.FvImages
.NameValue
)queryResult
[i
];
1519 result
[i
][0] = item
.getName();
1520 result
[i
][1] = item
.getValue();
1526 * Retrieve FV image component options
1531 * @returns name/value pairs list if elements are found at the known xpath
1532 * @returns empty list if nothing is there
1534 public static String
[][] getFpdComponents(String fvName
) {
1535 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName
.toUpperCase() + "']/FvImageOptions" };
1536 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1537 if (queryResult
== null) {
1538 return new String
[0][];
1541 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1542 for (int i
= 0; i
< queryResult
.length
; i
++) {
1543 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1544 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1545 Iterator iter
= namevalues
.iterator();
1546 while (iter
.hasNext()) {
1547 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1549 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1552 String
[][] result
= new String
[list
.size()][2];
1553 for (int i
= 0; i
< list
.size(); i
++) {
1554 result
[i
][0] = list
.get(i
)[0];
1555 result
[i
][1] = list
.get(i
)[1];
1561 * Retrieve PCD tokens
1563 * @returns CName/ItemType pairs list if elements are found at the known
1565 * @returns null if nothing is there
1567 public static String
[][] getPcdTokenArray() {
1568 String
[] xPath
= new String
[] { "/PcdData" };
1570 Object
[] returns
= get("PCDs", xPath
);
1571 if (returns
== null || returns
.length
== 0) {
1575 // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns;
1576 // String[][] result = new String[pcds.length][2];
1577 // for (int i = 0; i < returns.length; ++i) {
1578 // if (pcds[i].getItemType() != null) {
1579 // result[i][1] = pcds[i].getItemType().toString();
1581 // result[i][1] = null;
1583 // result[i][0] = pcds[i].getCName();
1590 * Get the PcdToken array from module's surface area document. The array
1591 * should contains following data:
1593 * -------------------------------------------------------------------
1596 * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText
1599 * -------------------------------------------------------------------
1602 * Note: Until new schema applying, now we can only get CName, ItemType,
1605 * @return 2-array table contains all information of PCD token retrieved
1608 public static Object
[][] etModulePCDTokenArray() {
1611 // Object[][] result;
1612 // PCDs.PcdData[] pcds;
1613 // String[] xPath = new String[] { "/PcdData" };
1614 // Object[] returns = get("PCDs", xPath);
1616 // if ((returns == null) || (returns.length == 0)) {
1620 // pcds = (PCDs.PcdData[]) returns;
1621 // result = new Object[pcds.length][6];
1622 // for (index = 0; index < pcds.length; index++) {
1626 // result[index][0] = pcds[index].getCName();
1628 // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE,
1629 // // DYNAMIC, DYNAMIC_EX
1631 // if (pcds[index].getItemType() != null) {
1632 // result[index][1] = pcds[index].getItemType().toString();
1634 // result[index][1] = null;
1638 // // BUGBUG: following field can *not* be got from current MSA until
1639 // // schema changed.
1641 // // result [index][2] = pcds[index].getTokenSpaceName();
1642 // result[index][2] = null;
1643 // result[index][3] = pcds[index].getDefaultValue();
1644 // // result [index][4] = pcds[index].getUsage ();
1645 // result[index][4] = null;
1646 // // result [index][5] = pcds[index].getHelpText ();
1647 // result[index][5] = null;
1653 * Retrieve MAS header
1658 public static ModuleIdentification
getMsaHeader() {
1659 String
[] xPath
= new String
[] { "/" };
1660 Object
[] returns
= get("MsaHeader", xPath
);
1662 if (returns
== null || returns
.length
== 0) {
1666 MsaHeader msaHeader
= (MsaHeader
) returns
[0];
1668 // Get BaseName, ModuleType, GuidValue, Version
1669 // which in MsaHeader.
1671 String name
= msaHeader
.getModuleName();
1672 String moduleType
= msaHeader
.getModuleType().toString();
1673 String guid
= msaHeader
.getGuidValue();
1674 String version
= msaHeader
.getVersion();
1676 ModuleIdentification moduleId
= new ModuleIdentification(name
, guid
,
1679 moduleId
.setModuleType(moduleType
);
1685 * Retrieve Extern Specification
1689 * @return String[] If have specification element in the <extern> String[0]
1690 * If no specification element in the <extern>
1694 public static String
[] getExternSpecificaiton() {
1695 String
[] xPath
= new String
[] { "/Specification" };
1697 Object
[] queryResult
= get("Externs", xPath
);
1698 if (queryResult
== null) {
1699 return new String
[0];
1702 String
[] specificationList
= new String
[queryResult
.length
];
1703 for (int i
= 0; i
< queryResult
.length
; i
++) {
1704 specificationList
[i
] = ((Sentence
)queryResult
[i
])
1707 return specificationList
;
1711 * Retreive MsaFile which in SPD
1714 * @return String[][3] The string sequence is ModuleName, ModuleGuid,
1715 * ModuleVersion, MsaFile String[0][] If no msafile in SPD
1717 public static String
[] getSpdMsaFile() {
1718 String
[] xPath
= new String
[] { "/MsaFiles" };
1720 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1721 if (returns
== null) {
1722 return new String
[0];
1725 List
<String
> filenameList
= ((MsaFilesDocument
.MsaFiles
) returns
[0])
1727 return filenameList
.toArray(new String
[filenameList
.size()]);
1733 public static Map
<String
, String
[]> getSpdLibraryClasses() {
1734 String
[] xPath
= new String
[] { "/LibraryClassDeclarations/LibraryClass" };
1736 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1739 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
1741 Map
<String
, String
[]> libClassHeaderMap
= new HashMap
<String
, String
[]>();
1743 if (returns
== null) {
1744 return libClassHeaderMap
;
1747 for (int i
= 0; i
< returns
.length
; i
++) {
1748 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass library
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) returns
[i
];
1749 libClassHeaderMap
.put(library
.getName(), new String
[] { library
1750 .getIncludeHeader() });
1752 return libClassHeaderMap
;
1758 public static Map
<String
, String
> getSpdPackageHeaderFiles() {
1759 String
[] xPath
= new String
[] { "/PackageHeaders/IncludePkgHeader" };
1761 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1764 // Create Map, Key - ModuleType, String - PackageInclude Header file.
1766 Map
<String
, String
> packageIncludeMap
= new HashMap
<String
, String
>();
1768 if (returns
== null) {
1769 return packageIncludeMap
;
1771 // GlobalData.log.info("" + returns[0].getClass().getName());
1772 for (int i
= 0; i
< returns
.length
; i
++) {
1773 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader includeHeader
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) returns
[i
];
1774 packageIncludeMap
.put(includeHeader
.getModuleType().toString(),
1775 includeHeader
.getStringValue());
1777 return packageIncludeMap
;
1780 public static PackageIdentification
getSpdHeader() {
1781 String
[] xPath
= new String
[] { "/SpdHeader" };
1783 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1785 if (returns
== null || returns
.length
== 0) {
1789 SpdHeaderDocument
.SpdHeader header
= (SpdHeaderDocument
.SpdHeader
) returns
[0];
1791 String name
= header
.getPackageName();
1793 String guid
= header
.getGuidValue();
1795 String version
= header
.getVersion();
1797 return new PackageIdentification(name
, guid
, version
);
1803 public static Map
<String
, String
[]> getSpdGuid() {
1804 String
[] xPath
= new String
[] { "/GuidDeclarations/Entry" };
1806 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1809 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
1811 Map
<String
, String
[]> guidDeclMap
= new HashMap
<String
, String
[]>();
1812 if (returns
== null) {
1816 for (int i
= 0; i
< returns
.length
; i
++) {
1817 GuidDeclarationsDocument
.GuidDeclarations
.Entry entry
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) returns
[i
];
1818 String
[] guidPair
= new String
[2];
1819 guidPair
[0] = entry
.getCName();
1820 guidPair
[1] = entry
.getGuidValue();
1821 guidDeclMap
.put(entry
.getName(), guidPair
);
1822 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1823 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[0]);
1824 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[1]);
1832 public static Map
<String
, String
[]> getSpdProtocol() {
1833 String
[] xPath
= new String
[] { "/ProtocolDeclarations/Entry" };
1835 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1838 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1840 Map
<String
, String
[]> protoclMap
= new HashMap
<String
, String
[]>();
1842 if (returns
== null) {
1846 for (int i
= 0; i
< returns
.length
; i
++) {
1847 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry entry
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) returns
[i
];
1848 String
[] protocolPair
= new String
[2];
1850 protocolPair
[0] = entry
.getCName();
1851 protocolPair
[1] = entry
.getGuidValue();
1852 protoclMap
.put(entry
.getName(), protocolPair
);
1853 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1854 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[0]);
1855 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[1]);
1861 * getSpdPpi() Retrieve the SPD PPI Entry
1864 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
1865 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
1868 public static Map
<String
, String
[]> getSpdPpi() {
1869 String
[] xPath
= new String
[] { "/PpiDeclarations/Entry" };
1871 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1874 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1876 Map
<String
, String
[]> ppiMap
= new HashMap
<String
, String
[]>();
1878 if (returns
== null) {
1882 for (int i
= 0; i
< returns
.length
; i
++) {
1883 PpiDeclarationsDocument
.PpiDeclarations
.Entry entry
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) returns
[i
];
1884 String
[] ppiPair
= new String
[2];
1885 ppiPair
[0] = entry
.getCName();
1886 ppiPair
[1] = entry
.getGuidValue();
1887 ppiMap
.put(entry
.getName(), ppiPair
);
1893 * getToolChainFamily
1895 * This function is to retrieve ToolChainFamily attribute of FPD
1899 * @return toolChainFamily If find toolChainFamily attribute in
1900 * <BuildOptions> Null If don't have toolChainFamily in
1903 public String
getToolChainFamily() {
1904 String toolChainFamily
;
1905 String
[] xPath
= new String
[] { "/BuildOptions" };
1907 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1908 if (result
== null) {
1911 // toolChainFamily =
1912 // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies();
1913 // return toolChainFamily;
1918 * Retrieve module Guid string
1920 * @returns GUILD string if elements are found at the known xpath
1921 * @returns null if nothing is there
1923 public static String
getModuleGuid() {
1924 String
[] xPath
= new String
[] { "" };
1926 Object
[] returns
= get("MsaHeader", xPath
);
1927 if (returns
!= null && returns
.length
> 0) {
1928 String guid
= ((MsaHeaderDocument
.MsaHeader
) returns
[0])
1939 public static ModuleSADocument
.ModuleSA
[] getFpdModuleSAs() {
1940 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1941 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1942 if (result
!= null) {
1943 return (ModuleSADocument
.ModuleSA
[]) result
;
1945 return new ModuleSADocument
.ModuleSA
[0];
1949 Get name array of PCD in a module. In one module, token space
1950 is same, and token name should not be conflicted.
1954 public static String
[] getModulePcdEntryNameArray() {
1955 PcdCodedDocument
.PcdCoded
.PcdEntry
[] pcdEntries
= null;
1958 String
[] xPath
= new String
[] {"/PcdEntry"};
1959 Object
[] returns
= get ("PcdCoded", xPath
);
1961 if (returns
== null) {
1962 return new String
[0];
1965 pcdEntries
= (PcdCodedDocument
.PcdCoded
.PcdEntry
[])returns
;
1966 results
= new String
[pcdEntries
.length
];
1968 for (index
= 0; index
< pcdEntries
.length
; index
++) {
1969 results
[index
] = pcdEntries
[index
].getCName();