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
.Iterator
;
18 import java
.util
.List
;
20 import java
.util
.Stack
;
21 import java
.util
.regex
.Matcher
;
22 import java
.util
.regex
.Pattern
;
24 import org
.apache
.xmlbeans
.XmlNormalizedString
;
25 import org
.apache
.xmlbeans
.XmlObject
;
26 import org
.apache
.xmlbeans
.XmlString
;
27 import org
.tianocore
.BuildOptionsDocument
;
28 import org
.tianocore
.CName
;
29 import org
.tianocore
.ExternsDocument
;
30 import org
.tianocore
.FfsDocument
;
31 import org
.tianocore
.FileNameConvention
;
32 import org
.tianocore
.FrameworkComponentTypes
;
33 import org
.tianocore
.FvImageOptionsDocument
;
34 import org
.tianocore
.GuidDocument
;
35 import org
.tianocore
.GuidsDocument
;
36 import org
.tianocore
.LibrariesDocument
;
37 import org
.tianocore
.LibraryClassDocument
;
38 import org
.tianocore
.LibraryUsage
;
39 import org
.tianocore
.ModuleSADocument
;
40 import org
.tianocore
.ModuleTypeDef
;
41 import org
.tianocore
.NameValueDocument
;
42 import org
.tianocore
.OutputDirectoryDocument
;
43 import org
.tianocore
.PPIsDocument
;
44 import org
.tianocore
.PackageNameDocument
;
45 import org
.tianocore
.ProtocolsDocument
;
46 import org
.tianocore
.PcdCodedDocument
.PcdCoded
;
47 import org
.tianocore
.MsaHeaderDocument
;
48 import org
.tianocore
.MsaHeaderDocument
.MsaHeader
;
51 SurfaceAreaQuery class is used to query Surface Area information from msa, mbd,
54 This class should not instantiated. All the public interfaces is static.
58 public class SurfaceAreaQuery
{
60 /// Contains name/value pairs of Surface Area document object. The name is
61 /// always the top level element name.
63 private static Map
<String
, XmlObject
> map
= null;
66 /// mapStack is used to do nested query
68 private static Stack
< Map
<String
, XmlObject
> > mapStack
= new Stack
< Map
<String
, XmlObject
> >();
71 /// prefix of name space
73 private static String nsPrefix
= "sans";
76 /// xmlbeans needs a name space for each Xpath element
78 private static String ns
= null;
81 /// keep the namep declaration for xmlbeans Xpath query
83 private static String queryDeclaration
= null;
86 Set a Surface Area document for query later
88 @param map A Surface Area document in TopLevelElementName/XmlObject format.
90 public static void setDoc(Map
<String
, XmlObject
> map
) {
91 ns
= OverrideProcess
.prefix
;
92 queryDeclaration
= "declare namespace " + nsPrefix
+ "='" + ns
+ "'; ";
93 SurfaceAreaQuery
.map
= map
;
97 Push current used Surface Area document into query stack. The given new
98 document will be used for any immediately followed getXXX() callings,
99 untill pop() is called.
101 @param newMap The TopLevelElementName/XmlObject format of a Surface Area document.
103 public static void push(Map
<String
, XmlObject
> newMap
) {
104 mapStack
.push(SurfaceAreaQuery
.map
);
105 SurfaceAreaQuery
.map
= newMap
;
109 Discard current used Surface Area document and use the top document in stack
112 public static void pop() {
113 SurfaceAreaQuery
.map
= mapStack
.pop();
117 /// Convert xPath to be namespace qualified, which is necessary for XmlBeans
118 /// selectPath(). For example, converting /MsaHeader/ModuleType to
119 /// /ns:MsaHeader/ns:ModuleType
121 private static String
normalizeQueryString(String
[] exp
, String from
) {
122 StringBuffer normQueryString
= new StringBuffer(4096);
125 while (i
< exp
.length
) {
126 String newExp
= from
+ exp
[i
];
127 Pattern pattern
= Pattern
.compile("([^/]*)(/|//)([^/]+)");
128 Matcher matcher
= pattern
.matcher(newExp
);
130 while (matcher
.find()) {
131 String starter
= newExp
.substring(matcher
.start(1), matcher
.end(1));
132 String seperator
= newExp
.substring(matcher
.start(2), matcher
.end(2));
133 String token
= newExp
.substring(matcher
.start(3), matcher
.end(3));
135 normQueryString
.append(starter
);
136 normQueryString
.append(seperator
);
137 normQueryString
.append(nsPrefix
);
138 normQueryString
.append(":");
139 normQueryString
.append(token
);
143 if (i
< exp
.length
) {
144 normQueryString
.append(" | ");
148 return normQueryString
.toString();
152 Search all XML documents stored in "map" for the specified xPath, using
153 relative path (starting with '$this')
155 @param xPath xpath query string array
156 @returns An array of XmlObject if elements are found at the specified xpath
157 @returns NULL if nothing is at the specified xpath
159 public static XmlObject
[] get(String
[] xPath
) {
164 String
[] keys
= (String
[]) map
.keySet().toArray(new String
[map
.size()]);
165 List
<XmlObject
> result
= new ArrayList
<XmlObject
>();
166 for (int i
= 0; i
< keys
.length
; ++i
) {
167 XmlObject rootNode
= (XmlObject
) map
.get(keys
[i
]);
168 if (rootNode
== null) {
172 String query
= queryDeclaration
+ normalizeQueryString(xPath
, "$this/" + keys
[i
]);
173 XmlObject
[] tmp
= rootNode
.selectPath(query
);
174 for (int j
= 0; j
< tmp
.length
; ++j
) {
179 int size
= result
.size();
184 return (XmlObject
[]) result
.toArray(new XmlObject
[size
]);
188 Search XML documents named by "rootName" for the given xPath, using
189 relative path (starting with '$this')
191 @param rootName The top level element name
192 @param xPath The xpath query string array
193 @returns An array of XmlObject if elements are found at the given xpath
194 @returns NULL if nothing is found at the given xpath
196 public static XmlObject
[] get(String rootName
, String
[] xPath
) {
201 XmlObject root
= (XmlObject
) map
.get(rootName
);
206 String query
= queryDeclaration
+ normalizeQueryString(xPath
, "$this/" + rootName
);
207 XmlObject
[] result
= root
.selectPath(query
);
208 if (result
.length
> 0) {
212 query
= queryDeclaration
+ normalizeQueryString(xPath
, "/" + rootName
);
213 result
= root
.selectPath(query
);
214 if (result
.length
> 0) {
222 Retrieve SourceFiles/Filename for specified ARCH type
224 @param arch architecture name
225 @returns An array of XmlObject if elements are found at the known xpath
226 @returns NULL if nothing is found at the known xpath
228 public static XmlObject
[] getSourceFiles(String arch
) {
231 if (arch
== null || arch
.equals("")) {
232 xPath
= new String
[] {
237 xPath
= new String
[] {
238 "/Filename[not(@SupArchList) and not(@ArchType) or @SupArchList='ALL' or @SupArchList='" + arch
+ "' or @ArchType='ALL' or @ArchType='" + arch
+ "']",
239 "/Filename[not(@SupArchList) and not(@ArchType) or @ArchType='ALL' or @ArchType='" + arch
+ "']",
240 "/Arch[@ArchType='ALL' or @ArchType='" + arch
+ "']/Filename"
244 return get("SourceFiles", xPath
);
248 Retrieve BuildOptions/Ffs
250 @returns FfsDocument.Ffs object if elements are found at the known xpath
251 @returns NULL if nothing is found at the known xpath
253 public static FfsDocument
.Ffs
getFfs() {
254 String
[] xPath
= new String
[] { "/Ffs" };
256 XmlObject
[] returns
= get("BuildOptions", xPath
);
257 if (returns
!= null && returns
.length
> 0) {
258 return (FfsDocument
.Ffs
) returns
[0];
265 Retrieve BuildOptions/OutputDirectory
267 @returns Directory names array if elements are found at the known xpath
268 @returns Empty if nothing is found at the known xpath
270 public static String
[] getOutputDirectory() {
271 String
[] xPath
= new String
[] { "/OutputDirectory" };
273 XmlObject
[] returns
= get("BuildOptions", xPath
);
274 if (returns
!= null && returns
.length
> 0) {
275 String
[] dirString
= new String
[2];
277 OutputDirectoryDocument
.OutputDirectory
[] dir
= (OutputDirectoryDocument
.OutputDirectory
[]) returns
;
278 dirString
[0] = dir
[0].getIntermediateDirectories().toString();
279 dirString
[1] = dir
[0].getStringValue();
284 return new String
[] { "UNIFIED", null };
288 Retrieve BuildOptions/Option or Arch/Option
290 @param arch architecture name
292 @returns name/value pairs of options if elements are found at the known xpath
293 @returns Empty array if nothing is there
295 public static String
[][] getOptions(String arch
){
298 if (arch
== null || arch
.equals("")) {
299 xPath
= new String
[] {
304 xPath
= new String
[] {
306 "/Option[@SupArchList='ALL' or @SupArchList='" + arch
+ "']",
307 "/Arch[@ArchType='ALL' or @ArchType='" + arch
+ "']/Option"
311 XmlObject
[] returns
= get("BuildOptions", xPath
);
312 if (returns
== null){
313 return new String
[0][2];
316 String
[][] result
= new String
[returns
.length
][2];
317 for (int i
= 0; i
< returns
.length
; i
++){
322 if (returns
[i
] instanceof BuildOptionsDocument
.BuildOptions
.Option
) {
323 BuildOptionsDocument
.BuildOptions
.Option option
= (BuildOptionsDocument
.BuildOptions
.Option
)returns
[i
];
324 str
= option
.getStringValue();
325 } else if (returns
[i
] instanceof BuildOptionsDocument
.BuildOptions
.Arch
.Option
) {
326 BuildOptionsDocument
.BuildOptions
.Arch
.Option archOption
= (BuildOptionsDocument
.BuildOptions
.Arch
.Option
)returns
[i
];
327 str
= archOption
.getStringValue();
332 int equalIndex
= str
.indexOf('=');
333 if ( equalIndex
> 0) {
334 name
= str
.substring(0, equalIndex
).trim();
335 value
= str
.substring(equalIndex
+ 1).trim();
336 // TBD remove some forbidden name: BASE_NAME, ARCH and so on
337 if (name
.length() == 0){
342 result
[i
][1] = value
;
348 public static String
getModuleName() {
349 String
[] xPath
= new String
[] { "/ModuleName", "/BaseName" };
351 XmlObject
[] returns
= get(xPath
);
352 if (returns
!= null && returns
.length
> 0) {
353 return returns
[0].toString();
360 Retrieve <xxxHeader>/ModuleType
362 @returns The module type name if elements are found at the known xpath
363 @returns null if nothing is there
365 public static String
getModuleType() {
366 String
[] xPath
= new String
[] { "/ModuleType" };
368 XmlObject
[] returns
= get(xPath
);
369 if (returns
!= null && returns
.length
> 0) {
370 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
371 return type
.enumValue().toString();
378 Retrieve <xxxHeader>/ComponentType
380 @returns The component type name if elements are found at the known xpath
381 @returns null if nothing is there
383 public static String
getComponentType() {
384 String
[] xPath
= new String
[] { "/ComponentType" };
386 XmlObject
[] returns
= get(xPath
);
387 if (returns
!= null && returns
.length
> 0) {
388 FrameworkComponentTypes type
= (FrameworkComponentTypes
) returns
[0];
389 return type
.enumValue().toString();
396 Retrieve Includes/PackageName
398 @param arch Architecture name
400 @returns package name list if elements are found at the known xpath
401 @returns null if nothing is there
403 public static List
<String
> getIncludePackageName(String arch
) {
406 if (arch
== null || arch
.equals("")) {
407 xPath
= new String
[] {
412 xPath
= new String
[] {
414 "/PackageName[@SupArchList='ALL' or @SupArchList='" + arch
+ "']",
415 "/PackageName[@Arch='ALL' or @Arch='" + arch
+ "']",
416 "/Arch[@ArchType='ALL' or @ArchType='" + arch
+ "']/PackageName"
420 XmlObject
[] returns
= get("Includes", xPath
);
421 if (returns
== null || returns
.length
== 0) {
422 returns
= get("PackageDependencies", xPath
);
423 if (returns
== null || returns
.length
== 0) {
428 List
<String
> packageNames
= new ArrayList
<String
>();
429 PackageNameDocument
.PackageName
[] nameObj
= (PackageNameDocument
.PackageName
[])returns
;
430 for (int i
= 0; i
< returns
.length
; ++i
) {
431 packageNames
.add(nameObj
[i
].getStringValue());
438 Retrieve LibraryClassDefinitions/LibraryClass for specified usage
440 @param usage Library class usage
442 @returns LibraryClass objects list if elements are found at the known xpath
443 @returns null if nothing is there
445 public static LibraryClassDocument
.LibraryClass
[] getLibraryClassArray(String usage
) {
448 if (usage
== null || usage
.equals("")) {
449 xPath
= new String
[] {"/LibraryClass"};
451 xPath
= new String
[] {"/LibraryClass[@Usage='" + usage
+ "']"};
454 XmlObject
[] returns
= get("LibraryClassDefinitions", xPath
);
455 if (returns
!= null && returns
.length
> 0) {
456 return (LibraryClassDocument
.LibraryClass
[]) returns
;
463 Retrieve ModuleEntryPoint names
465 @returns ModuleEntryPoint name list if elements are found at the known xpath
466 @returns null if nothing is there
468 public static String
[] getModuleEntryPointArray() {
469 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
471 XmlObject
[] returns
= get("Externs", xPath
);
473 if (returns
!= null && returns
.length
> 0) {
474 String
[] entryPoints
= new String
[returns
.length
];
476 for (int i
= 0; i
< returns
.length
; ++i
) {
477 entryPoints
[i
] = ((XmlNormalizedString
) returns
[i
])
488 Retrieve module Guid string
490 @returns GUILD string if elements are found at the known xpath
491 @returns null if nothing is there
493 public static String
getModuleGuid() {
494 String
[] xPath
= new String
[] { "" };
496 XmlObject
[] returns
= get("MsaHeader", xPath
);
497 if (returns
!= null && returns
.length
> 0) {
498 MsaHeaderDocument
.MsaHeader moduleHeader
= (MsaHeaderDocument
.MsaHeader
) returns
[0];
499 if (moduleHeader
.isSetGuid()) {
500 return moduleHeader
.getGuid().getStringValue();
501 } else if (moduleHeader
.isSetGuidValue()) {
502 return moduleHeader
.getGuidValue();
510 Retrieve module Guid string
512 @returns GUILD string if elements are found at the known xpath
513 @returns null if nothing is there
515 public static String
getModuleGuidValue() {
516 String
[] xPath
= new String
[] { "" };
518 XmlObject
[] returns
= get("MsaHeader", xPath
);
519 if (returns
!= null && returns
.length
> 0) {
520 MsaHeaderDocument
.MsaHeader moduleHeader
= (MsaHeaderDocument
.MsaHeader
) returns
[0];
521 return moduleHeader
.getGuidValue();
528 retrieve Protocol for specified usage
530 @param usage Protocol usage
532 @returns Protocol objects list if elements are found at the known xpath
533 @returns null if nothing is there
535 public static ProtocolsDocument
.Protocols
.Protocol
[] getProtocolArray(String usage
) {
538 if (usage
== null || usage
.equals("")) {
539 xPath
= new String
[] {"/Protocol"};
541 xPath
= new String
[] {"/Protocol[@Usage='" + usage
+ "']"};
544 XmlObject
[] returns
= get("Protocols", xPath
);
545 if (returns
!= null && returns
.length
> 0) {
546 return (ProtocolsDocument
.Protocols
.Protocol
[]) returns
;
553 Retrieve ProtocolNotify for specified usage
555 @param usage ProtocolNotify usage
557 @returns ProtocolNotify objects list if elements are found at the known xpath
558 @returns null if nothing is there
560 public static ProtocolsDocument
.Protocols
.ProtocolNotify
[] getProtocolNotifyArray(String usage
) {
563 if (usage
== null || usage
.equals("")) {
564 xPath
= new String
[] {"/ProtocolNotify"};
566 xPath
= new String
[] {"/ProtocolNotify[@Usage='" + usage
+ "']"};
569 XmlObject
[] returns
= get("Protocols", xPath
);
570 if (returns
!= null && returns
.length
> 0) {
571 return (ProtocolsDocument
.Protocols
.ProtocolNotify
[]) returns
;
578 Retrieve ModuleUnloadImage names
580 @returns ModuleUnloadImage name list if elements are found at the known xpath
581 @returns null if nothing is there
583 public static String
[] getModuleUnloadImageArray() {
584 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
586 XmlObject
[] returns
= get("Externs", xPath
);
587 if (returns
!= null && returns
.length
> 0) {
588 String
[] stringArray
= new String
[returns
.length
];
589 XmlNormalizedString
[] doc
= (XmlNormalizedString
[])returns
;
591 for (int i
= 0; i
< returns
.length
; ++i
) {
592 stringArray
[i
] = doc
[i
].getStringValue();
604 @returns Extern objects list if elements are found at the known xpath
605 @returns null if nothing is there
607 public static ExternsDocument
.Externs
.Extern
[] getExternArray() {
608 String
[] xPath
= new String
[] { "/Extern" };
610 XmlObject
[] returns
= get("Externs", xPath
);
611 if (returns
!= null && returns
.length
> 0) {
612 return (ExternsDocument
.Externs
.Extern
[]) returns
;
619 Retrieve Ppi information
621 @param usage Ppi usage
623 @returns Ppi objects list if elements are found at the known xpath
624 @returns null if nothing is there
626 public static PPIsDocument
.PPIs
.Ppi
[] getPpiArray(String usage
) {
629 if (usage
== null || usage
.equals("")) {
630 xPath
= new String
[] { "/Ppi" };
632 xPath
= new String
[] { "/Ppi[@Usage='" + usage
+ "']" };
635 XmlObject
[] returns
= get("PPIs", xPath
);
636 if (returns
!= null && returns
.length
> 0) {
637 return (PPIsDocument
.PPIs
.Ppi
[])returns
;
644 Retrive PpiNotify information
648 @returns PpiNotify objects list if elements are found at the known xpath
649 @returns null if nothing is there
651 public static PPIsDocument
.PPIs
.PpiNotify
[] getPpiNotifyArray(String usage
) {
654 if (usage
== null || usage
.equals("")) {
655 xPath
= new String
[] { "/PpiNotify" };
657 xPath
= new String
[] { "/PpiNotify[@Usage='" + usage
+ "']" };
660 XmlObject
[] returns
= get("PPIs", xPath
);
661 if (returns
!= null && returns
.length
> 0) {
662 return (PPIsDocument
.PPIs
.PpiNotify
[])returns
;
669 Retrieve GuidEntry information for specified usage
671 @param usage GuidEntry usage
673 @returns GuidEntry objects list if elements are found at the known xpath
674 @returns null if nothing is there
676 public static GuidsDocument
.Guids
.GuidEntry
[] getGuidEntryArray(String usage
) {
679 if (usage
== null || usage
.equals("")) {
680 xPath
= new String
[] { "/GuidEntry" };
682 xPath
= new String
[] { "/GuidEntry[@Usage='" + usage
+ "']" };
685 XmlObject
[] returns
= get("Guids", xPath
);
686 if (returns
!= null && returns
.length
> 0) {
687 return (GuidsDocument
.Guids
.GuidEntry
[])returns
;
694 Retrieve Library instance information
696 @param arch Architecture name
697 @param usage Library instance usage
699 @returns library instance name list if elements are found at the known xpath
700 @returns null if nothing is there
702 public static List
<String
> getLibraryInstance(String arch
, String usage
) {
704 String archAttribute
= "";
705 String usageAttribute
= "";
707 if ((arch
!= null) || (!arch
.equals(""))) {
708 archAttribute
= "[@ArchType='ALL' or @ArchType='" + arch
+ "']";
711 if ((usage
!= null) || (!usage
.equals(""))) {
712 // if no Usage attribute specified, default to ALWAYS_CONSUMED
713 if (usage
.equals(LibraryUsage
.ALWAYS_CONSUMED
.toString())) {
714 usageAttribute
= "[not(@Usage) or @Usage='" + usage
+ "']";
716 usageAttribute
= "[@Usage='" + usage
+ "']";
720 xPath
= new String
[] {
721 "/Library" + archAttribute
, //usageAttribute,
722 "/Library[not(@SupArchList) or @SupArchList='" + arch
+ "']",
723 "/Arch" + archAttribute
+ "/Library" + usageAttribute
726 XmlObject
[] returns
= get("Libraries", xPath
);
727 if (returns
== null || returns
.length
== 0) {
731 List
<String
> instances
= new ArrayList
<String
>();
732 for (int i
= 0; i
< returns
.length
; ++i
) {
733 if (returns
[i
] instanceof LibrariesDocument
.Libraries
.Library
) {
734 LibrariesDocument
.Libraries
.Library lib
= (LibrariesDocument
.Libraries
.Library
)returns
[i
];
735 instances
.add(lib
.getStringValue());
736 } else if (returns
[i
] instanceof LibrariesDocument
.Libraries
.Arch
.Library
) {
737 LibrariesDocument
.Libraries
.Arch
.Library lib
= (LibrariesDocument
.Libraries
.Arch
.Library
)returns
[i
];
738 instances
.add(lib
.getStringValue());
746 /// This method is used for retrieving the elements information which has
747 /// CName sub-element
749 private static String
[] getCNames(String from
, String xPath
[]) {
750 XmlObject
[] returns
= get(from
, xPath
);
751 if (returns
== null || returns
.length
== 0) {
755 String
[] strings
= new String
[returns
.length
];
756 for (int i
= 0; i
< returns
.length
; ++i
) {
757 strings
[i
] = ((CName
)returns
[i
]).getStringValue();
764 Retrive library's constructor name
766 @returns constructor name list if elements are found at the known xpath
767 @returns null if nothing is there
769 public static String
getLibConstructorName() {
770 String
[] xPath
= new String
[] {"/Extern/Constructor"};
772 XmlObject
[] returns
= get("Externs", xPath
);
773 if (returns
!= null && returns
.length
> 0) {
774 CName constructor
= (CName
)returns
[0];
775 return constructor
.getStringValue();
782 Retrive library's destructor name
784 @returns destructor name list if elements are found at the known xpath
785 @returns null if nothing is there
787 public static String
getLibDestructorName() {
788 String
[] xPath
= new String
[] {"/Extern/Destructor"};
790 XmlObject
[] returns
= get("Externs", xPath
);
791 if (returns
!= null && returns
.length
> 0) {
792 CName destructor
= (CName
)returns
[0];
793 return destructor
.getStringValue();
800 Retrive DriverBinding names
802 @returns DriverBinding name list if elements are found at the known xpath
803 @returns null if nothing is there
805 public static String
[] getDriverBindingArray() {
806 String
[] xPath
= new String
[] {"/Extern/DriverBinding"};
807 return getCNames("Externs", xPath
);
811 Retrive ComponentName names
813 @returns ComponentName name list if elements are found at the known xpath
814 @returns null if nothing is there
816 public static String
[] getComponentNameArray() {
817 String
[] xPath
= new String
[] {"/Extern/ComponentName"};
818 return getCNames("Externs", xPath
);
822 Retrive DriverConfig names
824 @returns DriverConfig name list if elements are found at the known xpath
825 @returns null if nothing is there
827 public static String
[] getDriverConfigArray() {
828 String
[] xPath
= new String
[] {"/Extern/DriverConfig"};
829 return getCNames("Externs", xPath
);
833 Retrive DriverDiag names
835 @returns DriverDiag name list if elements are found at the known xpath
836 @returns null if nothing is there
838 public static String
[] getDriverDiagArray() {
839 String
[] xPath
= new String
[] {"/Extern/DriverDiag"};
840 return getCNames("Externs", xPath
);
844 Retrive SetVirtualAddressMapCallBack names
846 @returns SetVirtualAddressMapCallBack name list
847 if elements are found at the known xpath
848 @returns null if nothing is there
850 public static String
[] getSetVirtualAddressMapCallBackArray() {
851 String
[] xPath
= new String
[] {"/Extern/SetVirtualAddressMapCallBack"};
852 return getCNames("Externs", xPath
);
856 Retrive ExitBootServicesCallBack names
858 @returns ExitBootServicesCallBack name list
859 if elements are found at the known xpath
860 @returns null if nothing is there
862 public static String
[] getExitBootServicesCallBackArray() {
863 String
[] xPath
= new String
[] {"/Extern/ExitBootServicesCallBack"};
864 return getCNames("Externs", xPath
);
868 Retrieve module surface area file information
870 @returns ModuleSA objects list if elements are found at the known xpath
871 @returns Empty ModuleSA list if nothing is there
873 public static ModuleSADocument
.ModuleSA
[] getFpdModules() {
874 String
[] xPath
= new String
[] { "/TianoImage/*/ModuleSA" };
876 XmlObject
[] result
= get("FrameworkPlatformDescription", xPath
);
877 if (result
== null) {
878 xPath
= new String
[] { "/FrameworkModules/*/ModuleSA" };
879 result
= get("FrameworkPlatformDescription", xPath
);
880 if (result
!= null) {
881 return (ModuleSADocument
.ModuleSA
[]) result
;
883 return new ModuleSADocument
.ModuleSA
[0];
886 return (ModuleSADocument
.ModuleSA
[]) result
;
890 Retrieve variables for FV images
892 @returns name/value list if elements are found at the known xpath
893 @returns empty list if nothing is there
895 public static String
[][] getFpdGlobalVariable() {
896 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
898 XmlObject
[] queryResult
= get("FrameworkPlatformDescription", xPath
);
899 if (queryResult
== null) {
900 return new String
[0][];
903 String
[][] result
= new String
[queryResult
.length
][2];
904 for (int i
= 0; i
< queryResult
.length
; i
++){
905 result
[i
][0] = ((NameValueDocument
.NameValue
)queryResult
[i
]).getName();
906 result
[i
][1] = ((NameValueDocument
.NameValue
)queryResult
[i
]).getValue();
913 Retrieve valid image names
915 @returns valid iamges name list if elements are found at the known xpath
916 @returns empty list if nothing is there
918 public static String
[] getFpdValidImageNames(){
919 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ValidImageNames']/FvImageNames" };
921 XmlObject
[] queryResult
= get("FrameworkPlatformDescription", xPath
);
922 if (queryResult
== null) {
923 return new String
[0];
926 String
[] result
= new String
[queryResult
.length
];
927 for (int i
= 0; i
< queryResult
.length
; i
++){
928 result
[i
] = ((XmlString
)queryResult
[i
]).getStringValue();
935 Retrieve FV image option information
937 @param fvName FV image name
939 @returns option name/value list if elements are found at the known xpath
940 @returns empty list if nothing is there
942 public static String
[][] getFpdOptions(String fvName
){
943 String
[] xPath
= new String
[] {"/Flash/FvImages/FvImageName[@Name='" + fvName
.toUpperCase() + "']/FvImageOptions/NameValue" };
945 XmlObject
[] queryResult
= get("FrameworkPlatformDescription", xPath
);
946 if (queryResult
== null) {
947 return new String
[0][];
950 String
[][] result
= new String
[queryResult
.length
][2];
951 for (int i
= 0; i
< queryResult
.length
; i
++){
952 result
[i
][0] = ((NameValueDocument
.NameValue
)queryResult
[i
]).getName();
953 result
[i
][1] = ((NameValueDocument
.NameValue
)queryResult
[i
]).getValue();
960 Retrieve FV image attributes information
962 @param fvName FV image name
964 @returns attribute name/value list if elements are found at the known xpath
965 @returns empty list if nothing is there
967 public static String
[][] getFpdAttributes(String fvName
){
968 String
[] xPath
= new String
[] {"/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='" + fvName
.toUpperCase() + "']/FvImageOptions" };
970 XmlObject
[] queryResult
= get("FrameworkPlatformDescription", xPath
);
971 if (queryResult
== null) {
972 return new String
[0][];
975 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
976 for (int i
= 0 ; i
< queryResult
.length
; i
++){
977 FvImageOptionsDocument
.FvImageOptions item
= (FvImageOptionsDocument
.FvImageOptions
)queryResult
[i
];
979 List
<NameValueDocument
.NameValue
> namevalues
= item
.getNameValueList();
980 Iterator iter
= namevalues
.iterator();
981 while (iter
.hasNext()) {
982 NameValueDocument
.NameValue nvItem
= (NameValueDocument
.NameValue
)iter
.next();
983 list
.add(new String
[]{nvItem
.getName(), nvItem
.getValue()});
986 List
<String
> enables
= item
.getEnableList();
987 iter
= enables
.iterator();
988 while (iter
.hasNext()) {
989 String enableItem
= (String
)iter
.next();
990 list
.add(new String
[]{enableItem
, "TRUE"});
993 List
<String
> disables
= item
.getDisableList();
994 iter
= disables
.iterator();
995 while (iter
.hasNext()) {
996 String disableItem
= (String
)iter
.next();
997 list
.add(new String
[]{disableItem
, "FALSE"});
1001 String
[][] result
= new String
[list
.size()][2];
1002 for (int i
= 0; i
< list
.size(); i
++){
1003 result
[i
][0] = list
.get(i
)[0];
1004 result
[i
][1] = list
.get(i
)[1];
1011 Retrieve flash definition file name
1013 @returns file name if elements are found at the known xpath
1014 @returns null if nothing is there
1016 public static String
getFlashDefinitionFile(){
1017 String
[] xPath
= new String
[] {"/Flash/FlashDefinitionFile" };
1019 XmlObject
[] queryResult
= get("FrameworkPlatformDescription", xPath
);
1020 if (queryResult
== null || queryResult
.length
== 0) {
1024 FileNameConvention filename
= (FileNameConvention
)queryResult
[queryResult
.length
- 1];
1025 return filename
.getStringValue();
1029 Retrieve FV image component options
1031 @param fvName FV image name
1033 @returns name/value pairs list if elements are found at the known xpath
1034 @returns empty list if nothing is there
1036 public static String
[][] getFpdComponents(String fvName
){
1037 String
[] xPath
= new String
[] {"/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='" + fvName
.toUpperCase() + "']/FvImageOptions" };
1039 XmlObject
[] queryResult
= get("FrameworkPlatformDescription", xPath
);
1040 if (queryResult
== null) {
1041 return new String
[0][];
1044 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1045 for (int i
= 0 ; i
< queryResult
.length
; i
++){
1046 FvImageOptionsDocument
.FvImageOptions item
= (FvImageOptionsDocument
.FvImageOptions
)queryResult
[i
];
1048 List
<NameValueDocument
.NameValue
> namevalues
= item
.getNameValueList();
1049 Iterator iter
= namevalues
.iterator();
1050 while (iter
.hasNext()) {
1051 NameValueDocument
.NameValue nvItem
= (NameValueDocument
.NameValue
)iter
.next();
1052 list
.add(new String
[]{nvItem
.getName(), nvItem
.getValue()});
1055 List
<String
> enables
= item
.getEnableList();
1056 iter
= enables
.iterator();
1057 while (iter
.hasNext()) {
1058 String enableItem
= (String
)iter
.next();
1059 list
.add(new String
[]{enableItem
, "TRUE"});
1062 List
<String
> disables
= item
.getDisableList();
1063 iter
= disables
.iterator();
1064 while (iter
.hasNext()) {
1065 String disableItem
= (String
)iter
.next();
1066 list
.add(new String
[]{disableItem
, "FALSE"});
1070 String
[][] result
= new String
[list
.size()][2];
1071 for (int i
= 0; i
< list
.size(); i
++){
1072 result
[i
][0] = list
.get(i
)[0];
1073 result
[i
][1] = list
.get(i
)[1];
1080 Get name array of PCD in a module. In one module, token space
1081 is same, and token name should not be conflicted.
1085 public static String
[] getModulePcdEntryNameArray() {
1086 PcdCoded
.PcdEntry
[] pcdEntries
= null;
1089 String
[] xPath
= new String
[] {"/PcdEntry"};
1090 XmlObject
[] returns
= get ("PcdCoded", xPath
);
1091 if (returns
== null) {
1095 pcdEntries
= (PcdCoded
.PcdEntry
[])returns
;
1096 results
= new String
[pcdEntries
.length
];
1098 for (index
= 0; index
< pcdEntries
.length
; index
++) {
1099 results
[index
] = pcdEntries
[index
].getCName();