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
.PpiDeclarationsDocument
;
55 import org
.tianocore
.ProtocolDeclarationsDocument
;
56 import org
.tianocore
.Sentence
;
57 import org
.tianocore
.SpdHeaderDocument
;
58 import org
.tianocore
.SupportedArchitectures
;
59 import org
.tianocore
.FilenameDocument
.Filename
;
60 import org
.tianocore
.MsaHeaderDocument
.MsaHeader
;
61 import org
.tianocore
.ProtocolsDocument
.Protocols
.Protocol
;
62 import org
.tianocore
.ProtocolsDocument
.Protocols
.ProtocolNotify
;
63 import org
.tianocore
.PlatformHeaderDocument
;
64 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
65 import org
.tianocore
.build
.id
.ModuleIdentification
;
66 import org
.tianocore
.build
.id
.PackageIdentification
;
67 import org
.tianocore
.build
.id
.PlatformIdentification
;
68 import org
.tianocore
.build
.toolchain
.ToolChainInfo
;
69 import org
.tianocore
.logger
.EdkLog
;
72 * SurfaceAreaQuery class is used to query Surface Area information from msa,
73 * mbd, spd and fpd files.
75 * This class should not instantiated. All the public interfaces is static.
79 public class SurfaceAreaQuery
{
81 public static String prefix
= "http://www.TianoCore.org/2006/Edk2.0";
84 // / Contains name/value pairs of Surface Area document object. The name is
85 // / always the top level element name.
87 private static Map
<String
, XmlObject
> map
= null;
90 // / mapStack is used to do nested query
92 private static Stack
<Map
<String
, XmlObject
>> mapStack
= new Stack
<Map
<String
, XmlObject
>>();
95 // / prefix of name space
97 private static String nsPrefix
= "sans";
100 // / xmlbeans needs a name space for each Xpath element
102 private static String ns
= null;
105 // / keep the namep declaration for xmlbeans Xpath query
107 private static String queryDeclaration
= null;
110 * Set a Surface Area document for query later
113 * A Surface Area document in TopLevelElementName/XmlObject
116 public static void setDoc(Map
<String
, XmlObject
> map
) {
118 queryDeclaration
= "declare namespace " + nsPrefix
+ "='" + ns
+ "'; ";
119 SurfaceAreaQuery
.map
= map
;
123 * Push current used Surface Area document into query stack. The given new
124 * document will be used for any immediately followed getXXX() callings,
125 * untill pop() is called.
128 * The TopLevelElementName/XmlObject format of a Surface Area
131 public static void push(Map
<String
, XmlObject
> newMap
) {
132 mapStack
.push(SurfaceAreaQuery
.map
);
133 SurfaceAreaQuery
.map
= newMap
;
137 * Discard current used Surface Area document and use the top document in
140 public static void pop() {
141 SurfaceAreaQuery
.map
= mapStack
.pop();
145 // / Convert xPath to be namespace qualified, which is necessary for
147 // / selectPath(). For example, converting /MsaHeader/ModuleType to
148 // / /ns:MsaHeader/ns:ModuleType
150 private static String
normalizeQueryString(String
[] exp
, String from
) {
151 StringBuffer normQueryString
= new StringBuffer(4096);
154 while (i
< exp
.length
) {
155 String newExp
= from
+ exp
[i
];
156 Pattern pattern
= Pattern
.compile("([^/]*)(/|//)([^/]+)");
157 Matcher matcher
= pattern
.matcher(newExp
);
159 while (matcher
.find()) {
160 String starter
= newExp
.substring(matcher
.start(1), matcher
162 String seperator
= newExp
.substring(matcher
.start(2), matcher
164 String token
= newExp
.substring(matcher
.start(3), matcher
167 normQueryString
.append(starter
);
168 normQueryString
.append(seperator
);
169 normQueryString
.append(nsPrefix
);
170 normQueryString
.append(":");
171 normQueryString
.append(token
);
175 if (i
< exp
.length
) {
176 normQueryString
.append(" | ");
180 return normQueryString
.toString();
184 * Search all XML documents stored in "map" for the specified xPath, using
185 * relative path (starting with '$this')
188 * xpath query string array
189 * @returns An array of XmlObject if elements are found at the specified
191 * @returns NULL if nothing is at the specified xpath
193 public static Object
[] get(String
[] xPath
) {
198 String
[] keys
= (String
[]) map
.keySet().toArray(new String
[map
.size()]);
199 List
<Object
> result
= new ArrayList
<Object
>();
200 for (int i
= 0; i
< keys
.length
; ++i
) {
201 XmlObject rootNode
= (XmlObject
) map
.get(keys
[i
]);
202 if (rootNode
== null) {
206 String query
= queryDeclaration
207 + normalizeQueryString(xPath
, "$this/" + keys
[i
]);
208 XmlObject
[] tmp
= rootNode
.selectPath(query
);
209 for (int j
= 0; j
< tmp
.length
; ++j
) {
210 result
.add((Object
)tmp
[j
]);
214 int size
= result
.size();
219 return (Object
[]) result
.toArray(new Object
[size
]);
223 * Search XML documents named by "rootName" for the given xPath, using
224 * relative path (starting with '$this')
227 * The top level element name
229 * The xpath query string array
230 * @returns An array of XmlObject if elements are found at the given xpath
231 * @returns NULL if nothing is found at the given xpath
233 public static Object
[] get(String rootName
, String
[] xPath
) {
238 XmlObject root
= (XmlObject
) map
.get(rootName
);
243 String query
= queryDeclaration
244 + normalizeQueryString(xPath
, "$this/" + rootName
);
245 XmlObject
[] result
= root
.selectPath(query
);
246 if (result
.length
> 0) {
247 return (Object
[])result
;
250 query
= queryDeclaration
+ normalizeQueryString(xPath
, "/" + rootName
);
251 result
= root
.selectPath(query
);
252 if (result
.length
> 0) {
253 return (Object
[])result
;
260 * Retrieve SourceFiles/Filename for specified ARCH type
264 * @returns An 2 dimension string array if elements are found at the known
266 * @returns NULL if nothing is found at the known xpath
268 public static String
[][] getSourceFiles(String arch
) {
272 if (arch
== null || arch
.equals("")) {
273 xPath
= new String
[] { "/Filename" };
275 xPath
= new String
[] { "/Filename[not(@SupArchList) or @SupArchList='"
279 returns
= get("SourceFiles", xPath
);
281 if (returns
== null || returns
.length
== 0) {
282 return new String
[0][0];
285 Filename
[] sourceFileNames
= (Filename
[]) returns
;
286 String
[][] outputString
= new String
[sourceFileNames
.length
][2];
287 for (int i
= 0; i
< sourceFileNames
.length
; i
++) {
288 outputString
[i
][0] = sourceFileNames
[i
].getToolCode();
289 outputString
[i
][1] = sourceFileNames
[i
].getStringValue();
295 * Retrieve /PlatformDefinitions/OutputDirectory from FPD
297 * @returns Directory names array if elements are found at the known xpath
298 * @returns Empty if nothing is found at the known xpath
300 public static String
getFpdOutputDirectory() {
301 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
303 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
304 if (returns
== null || returns
.length
== 0) {
307 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
308 return item
.getOutputDirectory();
311 public static String
getFpdIntermediateDirectories() {
312 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
314 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
315 if (returns
== null || returns
.length
== 0) {
318 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
319 if(item
.getIntermediateDirectories() == null) {
323 return item
.getIntermediateDirectories().toString();
327 public static String
getModuleFfsKeyword() {
328 String
[] xPath
= new String
[] { "/" };
330 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
331 if (returns
== null || returns
.length
== 0) {
334 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
335 return item
.getFfsFormatKey();
338 public static String
getModuleFvBindingKeyword() {
339 String
[] xPath
= new String
[] { "/" };
341 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
342 if (returns
== null || returns
.length
== 0) {
345 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
346 return item
.getFvBinding();
349 public static List
getModuleSupportedArchs() {
350 String
[] xPath
= new String
[] { "/" };
352 Object
[] returns
= get("ModuleDefinitions", xPath
);
353 if (returns
== null || returns
.length
== 0) {
356 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
357 return item
.getSupportedArchitectures();
360 public static BuildOptionsDocument
.BuildOptions
.Ffs
[] getFpdFfs() {
361 String
[] xPath
= new String
[] {"/Ffs"};
363 Object
[] returns
= get("BuildOptions", xPath
);
364 if (returns
== null || returns
.length
== 0) {
365 return new BuildOptionsDocument
.BuildOptions
.Ffs
[0];
367 return (BuildOptionsDocument
.BuildOptions
.Ffs
[])returns
;
370 public static String
getModuleOutputFileBasename() {
371 String
[] xPath
= new String
[] { "/" };
373 Object
[] returns
= get("ModuleDefinitions", xPath
);
374 if (returns
== null || returns
.length
== 0) {
377 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
378 return item
.getOutputFileBasename();
382 * Retrieve BuildOptions/Option or Arch/Option
384 * @param toolChainFamilyFlag
385 * if true, retrieve options for toolchain family; otherwise for
388 * @returns String[][5] name, target, toolchain, arch, coommand of options
389 * if elements are found at the known xpath. String[0][] if dont
392 * @returns Empty array if nothing is there
394 public static String
[][] getOptions(String from
, String
[] xPath
, boolean toolChainFamilyFlag
) {
395 String target
= null;
396 String toolchain
= null;
397 String toolchainFamily
= null;
398 List
<String
> archList
= null;
400 String targetName
= null;
401 String optionName
= null;
403 Object
[] returns
= get(from
, xPath
);
404 if (returns
== null) {
405 return new String
[0][5];
408 List
<String
[]> optionList
= new ArrayList
<String
[]>();
409 OptionDocument
.Option option
;
411 for (int i
= 0; i
< returns
.length
; i
++) {
412 option
= (OptionDocument
.Option
) returns
[i
];
415 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
417 // put to result[][5] array in above order.
420 if (option
.getBuildTargets() == null) {
424 target
= option
.getBuildTargets().toString();
426 if (target
!= null) {
427 targetList
= target
.split(" ");
429 targetList
= new String
[1];
430 targetList
[0] = null;
433 if (toolChainFamilyFlag
) {
434 toolchainFamily
= option
.getToolChainFamily();
435 if (toolchainFamily
!= null) {
436 toolchain
= toolchainFamily
.toString();
441 toolchain
= option
.getTagName();
444 archList
= new ArrayList
<String
>();
445 List
<String
> archEnumList
= option
.getSupArchList();
446 if (archEnumList
== null) {
449 archList
.addAll(archEnumList
);
451 Iterator it = archEnumList.iterator();
452 while (it.hasNext()) {
453 System.out.println(it.next().getClass().getName());
454 SupportedArchitectures.Enum archType = it.next();
455 archList.add(archType.toString());
460 cmd
= option
.getToolCode();
462 optionName
= option
.getStringValue();
463 for (int t
= 0; t
< targetList
.length
; t
++) {
464 for (int j
= 0; j
< archList
.size(); j
++) {
465 optionList
.add(new String
[] { targetList
[t
],
466 toolchain
, archList
.get(j
), cmd
, optionName
});
471 String
[][] result
= new String
[optionList
.size()][5];
472 for (int i
= 0; i
< optionList
.size(); i
++) {
473 result
[i
][0] = optionList
.get(i
)[0];
474 result
[i
][1] = optionList
.get(i
)[1];
475 result
[i
][2] = optionList
.get(i
)[2];
476 result
[i
][3] = optionList
.get(i
)[3];
477 result
[i
][4] = optionList
.get(i
)[4];
482 public static String
[][] getModuleBuildOptions(boolean toolChainFamilyFlag
) {
485 if (toolChainFamilyFlag
== true) {
486 xPath
= new String
[] {
487 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
488 "/Options/Option[@ToolChainFamily]", };
490 xPath
= new String
[] {
491 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
492 "/Options/Option[@TagName]", };
494 return getOptions("ModuleSaBuildOptions", xPath
, toolChainFamilyFlag
);
497 public static String
[][] getPlatformBuildOptions(boolean toolChainFamilyFlag
) {
500 if (toolChainFamilyFlag
== true) {
501 xPath
= new String
[] {
502 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
503 "/BuildOptions/Options/Option[@ToolChainFamily]", };
505 xPath
= new String
[] {
506 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
507 "/BuildOptions/Options/Option[@TagName]", };
510 return getOptions("PlatformSurfaceArea", xPath
, toolChainFamilyFlag
);
513 public static ToolChainInfo
getFpdToolChainInfo() {
514 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
516 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
517 if (returns
== null || returns
.length
== 0) {
521 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
522 ToolChainInfo toolChainInfo
= new ToolChainInfo();
523 toolChainInfo
.addTargets(item
.getBuildTargets().toString());
524 toolChainInfo
.addArchs(item
.getSupportedArchitectures().toString());
525 toolChainInfo
.addTagnames((String
)null);
526 return toolChainInfo
;
530 * Retrieve <xxxHeader>/ModuleType
532 * @returns The module type name if elements are found at the known xpath
533 * @returns null if nothing is there
535 public static String
getModuleType() {
536 String
[] xPath
= new String
[] { "/ModuleType" };
538 Object
[] returns
= get(xPath
);
539 if (returns
!= null && returns
.length
> 0) {
540 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
541 return type
.enumValue().toString();
548 * Retrieve PackageDependencies/Package
553 * @returns package name list if elements are found at the known xpath
554 * @returns null if nothing is there
556 public static PackageIdentification
[] getDependencePkg(String arch
) {
558 String packageGuid
= null;
559 String packageVersion
= null;
561 if (arch
== null || arch
.equals("")) {
562 xPath
= new String
[] { "/Package" };
564 xPath
= new String
[] { "/Package[not(@SupArchList) or @SupArchList='"
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 packageGuid
= item
.getPackageGuid();
576 packageVersion
= item
.getPackageVersion();
577 packageIdList
[i
] = (new PackageIdentification(null, packageGuid
,
580 return packageIdList
;
584 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
587 * Library class usage
589 * @returns LibraryClass objects list if elements are found at the known
591 * @returns null if nothing is there
593 public static String
[] getLibraryClasses(String usage
) {
596 if (usage
== null || usage
.equals("")) {
597 xPath
= new String
[] { "/LibraryClass" };
599 xPath
= new String
[] { "/LibraryClass[@Usage='" + usage
+ "']" };
602 Object
[] returns
= get("LibraryClassDefinitions", xPath
);
603 if (returns
== null || returns
.length
== 0) {
604 return new String
[0];
607 LibraryClassDocument
.LibraryClass
[] libraryClassList
= (LibraryClassDocument
.LibraryClass
[]) returns
;
608 String
[] libraryClassName
= new String
[libraryClassList
.length
];
609 for (int i
= 0; i
< libraryClassList
.length
; i
++) {
610 libraryClassName
[i
] = libraryClassList
[i
].getKeyword();
612 return libraryClassName
;
616 * Retrieve ModuleEntryPoint names
618 * @returns ModuleEntryPoint name list if elements are found at the known
620 * @returns null if nothing is there
622 public static String
[] getModuleEntryPointArray() {
623 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
625 Object
[] returns
= get("Externs", xPath
);
627 if (returns
!= null && returns
.length
> 0) {
628 String
[] entryPoints
= new String
[returns
.length
];
630 for (int i
= 0; i
< returns
.length
; ++i
) {
631 entryPoints
[i
] = ((CNameType
) returns
[i
]).getStringValue();
641 * retrieve Protocol for specified usage
644 * Protocol usage arch Architecture
646 * @returns Protocol String list if elements are found at the known xpath
647 * @returns String[0] if nothing is there
649 public static String
[] getProtocolArray(String arch
, String usage
) {
651 String usageXpath
= "";
652 String archXpath
= "";
654 if (arch
== null || arch
.equals("")) {
655 return new String
[0];
657 archXpath
= "/Protocol[@SupArchList='" + arch
+ "']";
658 if (usage
!= null && !usage
.equals("")) {
659 usageXpath
= "/Protocol[@Usage='" + usage
+ "']";
660 xPath
= new String
[] { usageXpath
, archXpath
};
662 return getProtocolArray(arch
);
667 Object
[] returns
= get("Protocols", xPath
);
668 if (returns
== null) {
669 return new String
[0];
671 Protocol
[] protocolList
= (Protocol
[]) returns
;
673 String
[] protocolArray
= new String
[returns
.length
];
674 for (int i
= 0; i
< returns
.length
; i
++) {
675 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
677 return protocolArray
;
681 * retrieve Protocol for specified usage
686 * @returns Protocol String list if elements are found at the known xpath
687 * @returns String[0] if nothing is there
689 public static String
[] getProtocolArray(String arch
) {
692 if (arch
== null || arch
.equals("")) {
693 return new String
[0];
695 xPath
= new String
[] { "/Protocol" };
698 Object
[] returns
= get("Protocols", xPath
);
699 if (returns
== null) {
700 return new String
[0];
702 Protocol
[] protocolList
= (Protocol
[]) returns
;
704 String
[] protocolArray
= new String
[returns
.length
];
705 for (int i
= 0; i
< returns
.length
; i
++) {
706 List
<String
> archList
= protocolList
[i
].getSupArchList();
707 if (archList
== null || archList
.contains(arch
)){
708 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
711 return protocolArray
;
715 * Retrieve ProtocolNotify for specified usage
718 * ProtocolNotify usage
720 * @returns String[] if elements are found at the known xpath
721 * @returns String[0] if nothing is there
723 public static String
[] getProtocolNotifyArray(String arch
) {
726 if (arch
== null || arch
.equals("")) {
727 return new String
[0];
729 xPath
= new String
[] { "/ProtocolNotify" };
732 Object
[] returns
= get("Protocols", xPath
);
733 if (returns
== null) {
734 return new String
[0];
737 String
[] protocolNotifyList
= new String
[returns
.length
];
738 for (int i
= 0; i
< returns
.length
; i
++) {
739 List
<String
> archList
= ((ProtocolNotify
) returns
[i
]).getSupArchList();
740 if (archList
== null || archList
.contains(arch
)){
741 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
746 return protocolNotifyList
;
750 * Retrieve ProtocolNotify for specified usage
753 * ProtocolNotify usage
755 * @returns String[] if elements are found at the known xpath
756 * @returns String[0] if nothing is there
758 public static String
[] getProtocolNotifyArray(String arch
, String usage
) {
764 if (arch
== null || arch
.equals("")) {
765 return new String
[0];
767 archXpath
= "/ProtocolNotify[@SupArchList='" + arch
+ "']";
768 if (usage
!= null && !usage
.equals("")) {
769 usageXpath
= "/ProtocolNotify[@Usage='" + arch
+ "']";
770 xPath
= new String
[] { archXpath
, usageXpath
};
772 return getProtocolNotifyArray(arch
);
776 Object
[] returns
= get("Protocols", xPath
);
777 if (returns
== null) {
778 return new String
[0];
781 String
[] protocolNotifyList
= new String
[returns
.length
];
783 for (int i
= 0; i
< returns
.length
; i
++) {
784 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
786 return protocolNotifyList
;
790 * Retrieve ModuleUnloadImage names
792 * @returns ModuleUnloadImage name list if elements are found at the known
794 * @returns null if nothing is there
796 public static String
[] getModuleUnloadImageArray() {
797 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
799 Object
[] returns
= get("Externs", xPath
);
800 if (returns
!= null && returns
.length
> 0) {
801 String
[] stringArray
= new String
[returns
.length
];
802 CNameType
[] doc
= (CNameType
[]) returns
;
804 for (int i
= 0; i
< returns
.length
; ++i
) {
805 stringArray
[i
] = doc
[i
].getStringValue();
817 * @returns Extern objects list if elements are found at the known xpath
818 * @returns null if nothing is there
820 public static ExternsDocument
.Externs
.Extern
[] getExternArray() {
821 String
[] xPath
= new String
[] { "/Extern" };
823 Object
[] returns
= get("Externs", xPath
);
824 if (returns
!= null && returns
.length
> 0) {
825 return (ExternsDocument
.Externs
.Extern
[]) returns
;
832 * Retrieve PpiNotify for specified arch
837 * @returns String[] if elements are found at the known xpath
838 * @returns String[0] if nothing is there
840 public static String
[] getPpiNotifyArray(String arch
) {
843 if (arch
== null || arch
.equals("")) {
844 return new String
[0];
846 xPath
= new String
[] { "/PpiNotify" };
849 Object
[] returns
= get("PPIs", xPath
);
850 if (returns
== null) {
851 return new String
[0];
854 String
[] ppiNotifyList
= new String
[returns
.length
];
855 for (int i
= 0; i
< returns
.length
; i
++) {
856 List
<String
> archList
= ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getSupArchList();
857 if (archList
== null || archList
.contains(arch
)){
858 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
863 return ppiNotifyList
;
867 * Retrieve PpiNotify for specified usage and arch
870 * PpiNotify arch usage PpiNotify usage
873 * @returns String[] if elements are found at the known xpath
874 * @returns String[0] if nothing is there
876 public static String
[] getPpiNotifyArray(String arch
, String usage
) {
882 if (arch
== null || arch
.equals("")) {
883 return new String
[0];
885 archXpath
= "/PpiNotify";
886 if (usage
!= null && !usage
.equals("")) {
887 usageXpath
= "/PpiNotify[@Usage='" + arch
+ "']";
888 xPath
= new String
[] { archXpath
, usageXpath
};
890 return getProtocolNotifyArray(arch
);
894 Object
[] returns
= get("PPIs", xPath
);
895 if (returns
== null) {
896 return new String
[0];
899 String
[] ppiNotifyList
= new String
[returns
.length
];
901 for (int i
= 0; i
< returns
.length
; i
++) {
902 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
904 return ppiNotifyList
;
908 * Retrieve Ppi for specified arch
913 * @returns String[] if elements are found at the known xpath
914 * @returns String[0] if nothing is there
916 public static String
[] getPpiArray(String arch
) {
919 if (arch
== null || arch
.equals("")) {
920 return new String
[0];
922 xPath
= new String
[] { "/Ppi" };
925 Object
[] returns
= get("PPIs", xPath
);
926 if (returns
== null) {
927 return new String
[0];
930 String
[] ppiList
= new String
[returns
.length
];
931 for (int i
= 0; i
< returns
.length
; i
++) {
932 List
<String
> archList
= ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getSupArchList();
933 if (archList
== null || archList
.contains(arch
)){
934 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
942 * Retrieve PpiNotify for specified usage and arch
945 * PpiNotify arch usage PpiNotify usage
948 * @returns String[] if elements are found at the known xpath
949 * @returns String[0] if nothing is there
951 public static String
[] getPpiArray(String arch
, String usage
) {
957 if (arch
== null || arch
.equals("")) {
958 return new String
[0];
961 if (usage
!= null && !usage
.equals("")) {
962 usageXpath
= "/Ppi[@Usage='" + arch
+ "']";
963 xPath
= new String
[] { archXpath
, usageXpath
};
965 return getProtocolNotifyArray(arch
);
969 Object
[] returns
= get("PPIs", xPath
);
970 if (returns
== null) {
971 return new String
[0];
974 String
[] ppiList
= new String
[returns
.length
];
976 for (int i
= 0; i
< returns
.length
; i
++) {
977 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
983 * Retrieve GuidEntry information for specified usage
988 * @returns GuidEntry objects list if elements are found at the known xpath
989 * @returns null if nothing is there
991 public static String
[] getGuidEntryArray(String arch
) {
994 if (arch
== null || arch
.equals("")) {
995 xPath
= new String
[] { "/GuidCNames" };
997 xPath
= new String
[] { "/GuidCNames" };
1000 Object
[] returns
= get("Guids", xPath
);
1001 if (returns
== null) {
1002 return new String
[0];
1004 String
[] guidList
= new String
[returns
.length
];
1005 for (int i
= 0; i
< returns
.length
; i
++) {
1006 List
<String
> archList
= ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getSupArchList();
1007 if (archList
== null || archList
.contains(arch
)){
1008 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1017 * Retrieve GuidEntry information for specified usage
1020 * GuidEntry arch usage GuidEntry usage
1022 * @returns GuidEntry objects list if elements are found at the known xpath
1023 * @returns null if nothing is there
1025 public static String
[] getGuidEntryArray(String arch
, String usage
) {
1030 if (arch
== null || arch
.equals("")) {
1031 return new String
[0];
1033 archXpath
= "/GuidEntry";
1034 if (usage
!= null && !usage
.equals("")) {
1035 usageXpath
= "/GuidEntry[@Usage='" + arch
+ "']";
1036 xPath
= new String
[] { archXpath
, usageXpath
};
1038 return getProtocolNotifyArray(arch
);
1042 Object
[] returns
= get("Guids", xPath
);
1043 if (returns
== null) {
1044 return new String
[0];
1047 String
[] guidList
= new String
[returns
.length
];
1049 for (int i
= 0; i
< returns
.length
; i
++) {
1050 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1056 * Retrieve Library instance information
1061 * Library instance usage
1063 * @returns library instance name list if elements are found at the known
1065 * @returns null if nothing is there
1067 public static ModuleIdentification
[] getLibraryInstance(String arch
) {
1069 String saGuid
= null;
1070 String saVersion
= null;
1071 String pkgGuid
= null;
1072 String pkgVersion
= null;
1074 if (arch
== null || arch
.equalsIgnoreCase("")) {
1075 xPath
= new String
[] { "/Instance" };
1077 xPath
= new String
[] { "/Instance[not(@SupArchList) or @SupArchList='"
1081 Object
[] returns
= get("Libraries", xPath
);
1082 if (returns
== null || returns
.length
== 0) {
1083 return new ModuleIdentification
[0];
1086 ModuleIdentification
[] saIdList
= new ModuleIdentification
[returns
.length
];
1087 for (int i
= 0; i
< returns
.length
; i
++) {
1088 LibrariesDocument
.Libraries
.Instance library
= (LibrariesDocument
.Libraries
.Instance
) returns
[i
];
1089 saGuid
= library
.getModuleGuid();
1090 saVersion
= library
.getModuleVersion();
1092 pkgGuid
= library
.getPackageGuid();
1093 pkgVersion
= library
.getPackageVersion();
1095 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1097 PackageIdentification pkgId
= new PackageIdentification(null,
1098 pkgGuid
, pkgVersion
);
1099 saId
.setPackage(pkgId
);
1108 // / This method is used for retrieving the elements information which has
1109 // / CName sub-element
1111 private static String
[] getCNames(String from
, String xPath
[]) {
1112 Object
[] returns
= get(from
, xPath
);
1113 if (returns
== null || returns
.length
== 0) {
1117 String
[] strings
= new String
[returns
.length
];
1118 for (int i
= 0; i
< returns
.length
; ++i
) {
1120 strings
[i
] = ((CNameType
) returns
[i
]).getStringValue();
1127 * Retrive library's constructor name
1129 * @returns constructor name list if elements are found at the known xpath
1130 * @returns null if nothing is there
1132 public static String
getLibConstructorName() {
1133 String
[] xPath
= new String
[] { "/Extern/Constructor" };
1135 Object
[] returns
= get("Externs", xPath
);
1136 if (returns
!= null && returns
.length
> 0) {
1137 CNameType constructor
= ((CNameType
) returns
[0]);
1138 return constructor
.getStringValue();
1145 * Retrive library's destructor name
1147 * @returns destructor name list if elements are found at the known xpath
1148 * @returns null if nothing is there
1150 public static String
getLibDestructorName() {
1151 String
[] xPath
= new String
[] { "/Extern/Destructor" };
1153 Object
[] returns
= get("Externs", xPath
);
1154 if (returns
!= null && returns
.length
> 0) {
1156 // Only support one Destructor function.
1158 CNameType destructor
= (CNameType
) returns
[0];
1159 return destructor
.getStringValue();
1166 * Retrive DriverBinding names
1168 * @returns DriverBinding name list if elements are found at the known xpath
1169 * @returns null if nothing is there
1171 public static String
[] getDriverBindingArray() {
1172 String
[] xPath
= new String
[] { "/Extern/DriverBinding" };
1173 return getCNames("Externs", xPath
);
1177 * Retrive ComponentName names
1179 * @returns ComponentName name list if elements are found at the known xpath
1180 * @returns null if nothing is there
1182 public static String
[] getComponentNameArray() {
1183 String
[] xPath
= new String
[] { "/Extern/ComponentName" };
1184 return getCNames("Externs", xPath
);
1188 * Retrive DriverConfig names
1190 * @returns DriverConfig name list if elements are found at the known xpath
1191 * @returns null if nothing is there
1193 public static String
[] getDriverConfigArray() {
1194 String
[] xPath
= new String
[] { "/Extern/DriverConfig" };
1195 return getCNames("Externs", xPath
);
1199 * Retrive DriverDiag names
1201 * @returns DriverDiag name list if elements are found at the known xpath
1202 * @returns null if nothing is there
1204 public static String
[] getDriverDiagArray() {
1205 String
[] xPath
= new String
[] { "/Extern/DriverDiag" };
1206 return getCNames("Externs", xPath
);
1210 * Retrive SetVirtualAddressMapCallBack names
1212 * @returns SetVirtualAddressMapCallBack name list if elements are found at
1214 * @returns null if nothing is there
1216 public static String
[] getSetVirtualAddressMapCallBackArray() {
1217 String
[] xPath
= new String
[] { "/Extern/SetVirtualAddressMapCallBack" };
1218 return getCNames("Externs", xPath
);
1222 * Retrive ExitBootServicesCallBack names
1224 * @returns ExitBootServicesCallBack name list if elements are found at the
1226 * @returns null if nothing is there
1228 public static String
[] getExitBootServicesCallBackArray() {
1229 String
[] xPath
= new String
[] { "/Extern/ExitBootServicesCallBack" };
1230 return getCNames("Externs", xPath
);
1234 * Retrieve module surface area file information
1236 * @returns ModuleSA objects list if elements are found at the known xpath
1237 * @returns Empty ModuleSA list if nothing is there
1239 public static Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> getFpdModules() {
1240 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1241 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1243 String fvBinding
= null;
1244 String saGuid
= null;
1245 String saVersion
= null;
1246 String pkgGuid
= null;
1247 String pkgVersion
= null;
1249 Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleMap
= new LinkedHashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
1251 if (result
== null) {
1252 return fpdModuleMap
;
1255 for (int i
= 0; i
< result
.length
; i
++) {
1257 // Get Fpd SA Module element node and add to ObjectMap.
1259 Map
<String
, XmlObject
> ObjectMap
= new HashMap
<String
, XmlObject
>();
1260 ModuleSADocument
.ModuleSA moduleSA
= (ModuleSADocument
.ModuleSA
) result
[i
];
1261 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getLibraries() != null) {
1262 ObjectMap
.put("Libraries", moduleSA
.getLibraries());
1264 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getPcdBuildDefinition() != null) {
1265 ObjectMap
.put("PcdBuildDefinition", moduleSA
1266 .getPcdBuildDefinition());
1268 if (((ModuleSADocument
.ModuleSA
) result
[i
])
1269 .getModuleSaBuildOptions() != null) {
1270 ObjectMap
.put("ModuleSaBuildOptions", moduleSA
1271 .getModuleSaBuildOptions());
1275 // Get Fpd SA Module attribute and create FpdMoudleIdentification.
1277 arch
= moduleSA
.getSupArchList().toString();
1281 saVersion
= ((ModuleSADocument
.ModuleSA
) result
[i
])
1282 .getModuleVersion();
1284 saGuid
= moduleSA
.getModuleGuid();
1285 pkgGuid
= moduleSA
.getPackageGuid();
1286 pkgVersion
= moduleSA
.getPackageVersion();
1289 // Create Module Identification which have class member of package
1292 PackageIdentification pkgId
= new PackageIdentification(null,
1293 pkgGuid
, pkgVersion
);
1294 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1297 saId
.setPackage(pkgId
);
1300 // Create FpdModule Identification which have class member of module
1304 String
[] archList
= arch
.split(" ");
1305 for (int j
= 0; j
< archList
.length
; j
++) {
1306 FpdModuleIdentification fpdSaId
= new FpdModuleIdentification(saId
, archList
[j
]);
1308 if (fvBinding
!= null) {
1309 fpdSaId
.setFvBinding(fvBinding
);
1313 // Put element to Map<FpdModuleIdentification, Map<String,
1316 fpdModuleMap
.put(fpdSaId
, ObjectMap
);
1320 return fpdModuleMap
;
1324 * Retrieve valid image names
1326 * @returns valid iamges name list if elements are found at the known xpath
1327 * @returns empty list if nothing is there
1329 public static String
[] getFpdValidImageNames() {
1330 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
1332 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1333 if (queryResult
== null) {
1334 return new String
[0];
1337 String
[] result
= new String
[queryResult
.length
];
1338 for (int i
= 0; i
< queryResult
.length
; i
++) {
1339 result
[i
] = ((XmlString
) queryResult
[i
]).getStringValue();
1345 public static XmlObject
getFpdUserExtension() {
1346 String
[] xPath
= new String
[] { "" };
1348 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1349 if (queryResult
== null) {
1356 * Retrieve FV image option information
1361 * @returns option name/value list if elements are found at the known xpath
1362 * @returns empty list if nothing is there
1364 public static String
[][] getFpdOptions(String fvName
) {
1365 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
1366 + fvName
.toUpperCase() + "']/FvImageOptions" };
1367 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1368 if (queryResult
== null) {
1369 return new String
[0][];
1371 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1372 for (int i
= 0; i
< queryResult
.length
; i
++) {
1373 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1374 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
1375 .getNameValueList();
1376 Iterator iter
= namevalues
.iterator();
1377 while (iter
.hasNext()) {
1378 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1380 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1383 String
[][] result
= new String
[list
.size()][2];
1384 for (int i
= 0; i
< list
.size(); i
++) {
1385 result
[i
][0] = list
.get(i
)[0];
1386 result
[i
][1] = list
.get(i
)[1];
1392 public static XmlObject
getFpdBuildOptions() {
1393 String
[] xPath
= new String
[] { "/BuildOptions" };
1395 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1397 if (queryResult
== null || queryResult
.length
== 0) {
1400 return (XmlObject
)queryResult
[0];
1403 public static PlatformIdentification
getFpdHeader() {
1404 String
[] xPath
= new String
[] { "/PlatformHeader" };
1406 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
1408 if (returns
== null || returns
.length
== 0) {
1411 PlatformHeaderDocument
.PlatformHeader header
= (PlatformHeaderDocument
.PlatformHeader
) returns
[0];
1413 String name
= header
.getPlatformName();
1415 String guid
= header
.getGuidValue();
1417 String version
= header
.getVersion();
1419 return new PlatformIdentification(name
, guid
, version
);
1423 * Retrieve FV image attributes information
1428 * @returns attribute name/value list if elements are found at the known
1430 * @returns empty list if nothing is there
1432 public static String
[][] getFpdAttributes(String fvName
) {
1433 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
1434 + fvName
.toUpperCase() + "']/FvImageOptions" };
1435 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1436 if (queryResult
== null) {
1437 return new String
[0][];
1439 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1440 for (int i
= 0; i
< queryResult
.length
; i
++) {
1442 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1443 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1444 Iterator iter
= namevalues
.iterator();
1445 while (iter
.hasNext()) {
1446 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1448 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1451 String
[][] result
= new String
[list
.size()][2];
1452 for (int i
= 0; i
< list
.size(); i
++) {
1453 result
[i
][0] = list
.get(i
)[0];
1454 result
[i
][1] = list
.get(i
)[1];
1460 * Retrieve flash definition file name
1462 * @returns file name if elements are found at the known xpath
1463 * @returns null if nothing is there
1465 public static String
getFlashDefinitionFile() {
1466 String
[] xPath
= new String
[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
1468 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1469 if (queryResult
== null || queryResult
.length
== 0) {
1473 FileNameConvention filename
= (FileNameConvention
) queryResult
[queryResult
.length
- 1];
1474 return filename
.getStringValue();
1477 public static String
[][] getFpdGlobalVariable() {
1478 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
1479 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1480 if (queryResult
== null) {
1481 return new String
[0][];
1484 String
[][] result
= new String
[queryResult
.length
][2];
1486 for (int i
= 0; i
< queryResult
.length
; i
++) {
1487 FvImagesDocument
.FvImages
.NameValue item
= (FvImagesDocument
.FvImages
.NameValue
)queryResult
[i
];
1488 result
[i
][0] = item
.getName();
1489 result
[i
][1] = item
.getValue();
1495 * Retrieve FV image component options
1500 * @returns name/value pairs list if elements are found at the known xpath
1501 * @returns empty list if nothing is there
1503 public static String
[][] getFpdComponents(String fvName
) {
1504 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName
.toUpperCase() + "']/FvImageOptions" };
1505 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1506 if (queryResult
== null) {
1507 return new String
[0][];
1510 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1511 for (int i
= 0; i
< queryResult
.length
; i
++) {
1512 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1513 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1514 Iterator iter
= namevalues
.iterator();
1515 while (iter
.hasNext()) {
1516 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1518 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1521 String
[][] result
= new String
[list
.size()][2];
1522 for (int i
= 0; i
< list
.size(); i
++) {
1523 result
[i
][0] = list
.get(i
)[0];
1524 result
[i
][1] = list
.get(i
)[1];
1530 * Retrieve PCD tokens
1532 * @returns CName/ItemType pairs list if elements are found at the known
1534 * @returns null if nothing is there
1536 public static String
[][] getPcdTokenArray() {
1537 String
[] xPath
= new String
[] { "/PcdData" };
1539 Object
[] returns
= get("PCDs", xPath
);
1540 if (returns
== null || returns
.length
== 0) {
1544 // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns;
1545 // String[][] result = new String[pcds.length][2];
1546 // for (int i = 0; i < returns.length; ++i) {
1547 // if (pcds[i].getItemType() != null) {
1548 // result[i][1] = pcds[i].getItemType().toString();
1550 // result[i][1] = null;
1552 // result[i][0] = pcds[i].getCName();
1559 * Get the PcdToken array from module's surface area document. The array
1560 * should contains following data:
1562 * -------------------------------------------------------------------
1565 * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText
1568 * -------------------------------------------------------------------
1571 * Note: Until new schema applying, now we can only get CName, ItemType,
1574 * @return 2-array table contains all information of PCD token retrieved
1577 public static Object
[][] etModulePCDTokenArray() {
1580 // Object[][] result;
1581 // PCDs.PcdData[] pcds;
1582 // String[] xPath = new String[] { "/PcdData" };
1583 // Object[] returns = get("PCDs", xPath);
1585 // if ((returns == null) || (returns.length == 0)) {
1589 // pcds = (PCDs.PcdData[]) returns;
1590 // result = new Object[pcds.length][6];
1591 // for (index = 0; index < pcds.length; index++) {
1595 // result[index][0] = pcds[index].getCName();
1597 // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE,
1598 // // DYNAMIC, DYNAMIC_EX
1600 // if (pcds[index].getItemType() != null) {
1601 // result[index][1] = pcds[index].getItemType().toString();
1603 // result[index][1] = null;
1607 // // BUGBUG: following field can *not* be got from current MSA until
1608 // // schema changed.
1610 // // result [index][2] = pcds[index].getTokenSpaceName();
1611 // result[index][2] = null;
1612 // result[index][3] = pcds[index].getDefaultValue();
1613 // // result [index][4] = pcds[index].getUsage ();
1614 // result[index][4] = null;
1615 // // result [index][5] = pcds[index].getHelpText ();
1616 // result[index][5] = null;
1622 * Retrieve MAS header
1627 public static ModuleIdentification
getMsaHeader() {
1628 String
[] xPath
= new String
[] { "/" };
1629 Object
[] returns
= get("MsaHeader", xPath
);
1631 if (returns
== null || returns
.length
== 0) {
1635 MsaHeader msaHeader
= (MsaHeader
) returns
[0];
1637 // Get BaseName, ModuleType, GuidValue, Version
1638 // which in MsaHeader.
1640 String name
= msaHeader
.getModuleName();
1641 String moduleType
= msaHeader
.getModuleType().toString();
1642 String guid
= msaHeader
.getGuidValue();
1643 String version
= msaHeader
.getVersion();
1645 ModuleIdentification moduleId
= new ModuleIdentification(name
, guid
,
1648 moduleId
.setModuleType(moduleType
);
1654 * Retrieve Extern Specification
1658 * @return String[] If have specification element in the <extern> String[0]
1659 * If no specification element in the <extern>
1663 public static String
[] getExternSpecificaiton() {
1664 String
[] xPath
= new String
[] { "/Specification" };
1666 Object
[] queryResult
= get("Externs", xPath
);
1667 if (queryResult
== null) {
1668 return new String
[0];
1671 String
[] specificationList
= new String
[queryResult
.length
];
1672 for (int i
= 0; i
< queryResult
.length
; i
++) {
1673 specificationList
[i
] = ((Sentence
)queryResult
[i
])
1676 return specificationList
;
1680 * Retreive MsaFile which in SPD
1683 * @return String[][3] The string sequence is ModuleName, ModuleGuid,
1684 * ModuleVersion, MsaFile String[0][] If no msafile in SPD
1686 public static String
[] getSpdMsaFile() {
1687 String
[] xPath
= new String
[] { "/MsaFiles" };
1689 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1690 if (returns
== null) {
1691 return new String
[0];
1694 List
<String
> filenameList
= ((MsaFilesDocument
.MsaFiles
) returns
[0])
1696 return filenameList
.toArray(new String
[filenameList
.size()]);
1702 public static Map
<String
, String
[]> getSpdLibraryClasses() {
1703 String
[] xPath
= new String
[] { "/LibraryClassDeclarations/LibraryClass" };
1705 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1708 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
1710 Map
<String
, String
[]> libClassHeaderMap
= new HashMap
<String
, String
[]>();
1712 if (returns
== null) {
1713 return libClassHeaderMap
;
1716 for (int i
= 0; i
< returns
.length
; i
++) {
1717 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass library
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) returns
[i
];
1718 libClassHeaderMap
.put(library
.getName(), new String
[] { library
1719 .getIncludeHeader() });
1721 return libClassHeaderMap
;
1727 public static Map
<String
, String
> getSpdPackageHeaderFiles() {
1728 String
[] xPath
= new String
[] { "/PackageHeaders/IncludePkgHeader" };
1730 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1733 // Create Map, Key - ModuleType, String - PackageInclude Header file.
1735 Map
<String
, String
> packageIncludeMap
= new HashMap
<String
, String
>();
1737 if (returns
== null) {
1738 return packageIncludeMap
;
1740 // GlobalData.log.info("" + returns[0].getClass().getName());
1741 for (int i
= 0; i
< returns
.length
; i
++) {
1742 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader includeHeader
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) returns
[i
];
1743 packageIncludeMap
.put(includeHeader
.getModuleType().toString(),
1744 includeHeader
.getStringValue());
1746 return packageIncludeMap
;
1749 public static PackageIdentification
getSpdHeader() {
1750 String
[] xPath
= new String
[] { "/SpdHeader" };
1752 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1754 if (returns
== null || returns
.length
== 0) {
1758 SpdHeaderDocument
.SpdHeader header
= (SpdHeaderDocument
.SpdHeader
) returns
[0];
1760 String name
= header
.getPackageName();
1762 String guid
= header
.getGuidValue();
1764 String version
= header
.getVersion();
1766 return new PackageIdentification(name
, guid
, version
);
1772 public static Map
<String
, String
[]> getSpdGuid() {
1773 String
[] xPath
= new String
[] { "/GuidDeclarations/Entry" };
1775 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1778 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
1780 Map
<String
, String
[]> guidDeclMap
= new HashMap
<String
, String
[]>();
1781 if (returns
== null) {
1785 for (int i
= 0; i
< returns
.length
; i
++) {
1786 GuidDeclarationsDocument
.GuidDeclarations
.Entry entry
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) returns
[i
];
1787 String
[] guidPair
= new String
[2];
1788 guidPair
[0] = entry
.getCName();
1789 guidPair
[1] = entry
.getGuidValue();
1790 guidDeclMap
.put(entry
.getName(), guidPair
);
1791 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1792 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[0]);
1793 EdkLog
.log(EdkLog
.EDK_VERBOSE
, guidPair
[1]);
1801 public static Map
<String
, String
[]> getSpdProtocol() {
1802 String
[] xPath
= new String
[] { "/ProtocolDeclarations/Entry" };
1804 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1807 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1809 Map
<String
, String
[]> protoclMap
= new HashMap
<String
, String
[]>();
1811 if (returns
== null) {
1815 for (int i
= 0; i
< returns
.length
; i
++) {
1816 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry entry
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) returns
[i
];
1817 String
[] protocolPair
= new String
[2];
1819 protocolPair
[0] = entry
.getCName();
1820 protocolPair
[1] = entry
.getGuidValue();
1821 protoclMap
.put(entry
.getName(), protocolPair
);
1822 EdkLog
.log(EdkLog
.EDK_VERBOSE
, entry
.getName());
1823 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[0]);
1824 EdkLog
.log(EdkLog
.EDK_VERBOSE
, protocolPair
[1]);
1830 * getSpdPpi() Retrieve the SPD PPI Entry
1833 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
1834 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
1837 public static Map
<String
, String
[]> getSpdPpi() {
1838 String
[] xPath
= new String
[] { "/PpiDeclarations/Entry" };
1840 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1843 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1845 Map
<String
, String
[]> ppiMap
= new HashMap
<String
, String
[]>();
1847 if (returns
== null) {
1851 for (int i
= 0; i
< returns
.length
; i
++) {
1852 PpiDeclarationsDocument
.PpiDeclarations
.Entry entry
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) returns
[i
];
1853 String
[] ppiPair
= new String
[2];
1854 ppiPair
[0] = entry
.getCName();
1855 ppiPair
[1] = entry
.getGuidValue();
1856 ppiMap
.put(entry
.getName(), ppiPair
);
1862 * getToolChainFamily
1864 * This function is to retrieve ToolChainFamily attribute of FPD
1868 * @return toolChainFamily If find toolChainFamily attribute in
1869 * <BuildOptions> Null If don't have toolChainFamily in
1872 public String
getToolChainFamily() {
1873 String toolChainFamily
;
1874 String
[] xPath
= new String
[] { "/BuildOptions" };
1876 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1877 if (result
== null) {
1880 // toolChainFamily =
1881 // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies();
1882 // return toolChainFamily;
1887 * Retrieve module Guid string
1889 * @returns GUILD string if elements are found at the known xpath
1890 * @returns null if nothing is there
1892 public static String
getModuleGuid() {
1893 String
[] xPath
= new String
[] { "" };
1895 Object
[] returns
= get("MsaHeader", xPath
);
1896 if (returns
!= null && returns
.length
> 0) {
1897 String guid
= ((MsaHeaderDocument
.MsaHeader
) returns
[0])
1908 public static ModuleSADocument
.ModuleSA
[] getFpdModuleSAs() {
1909 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1910 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1911 if (result
!= null) {
1912 return (ModuleSADocument
.ModuleSA
[]) result
;
1914 return new ModuleSADocument
.ModuleSA
[0];
1918 Get name array of PCD in a module. In one module, token space
1919 is same, and token name should not be conflicted.
1923 public static String
[] getModulePcdEntryNameArray() {
1924 PcdCodedDocument
.PcdCoded
.PcdEntry
[] pcdEntries
= null;
1927 String
[] xPath
= new String
[] {"/PcdEntry"};
1928 Object
[] returns
= get ("PcdCoded", xPath
);
1930 if (returns
== null) {
1931 return new String
[0];
1934 pcdEntries
= (PcdCodedDocument
.PcdCoded
.PcdEntry
[])returns
;
1935 results
= new String
[pcdEntries
.length
];
1937 for (index
= 0; index
< pcdEntries
.length
; index
++) {
1938 results
[index
] = pcdEntries
[index
].getCName();