]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | This file is for surface area information retrieval.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | package org.tianocore.build.global;\r | |
15 | \r | |
16 | import java.util.ArrayList;\r | |
17 | import java.util.HashMap;\r | |
18 | import java.util.Iterator;\r | |
19 | import java.util.LinkedHashMap;\r | |
20 | import java.util.List;\r | |
21 | import java.util.Map;\r | |
22 | import java.util.Stack;\r | |
23 | import java.util.regex.Matcher;\r | |
24 | import java.util.regex.Pattern;\r | |
25 | \r | |
26 | import org.apache.xmlbeans.XmlObject;\r | |
27 | import org.apache.xmlbeans.XmlString;\r | |
28 | import org.tianocore.BuildOptionsDocument;\r | |
29 | import org.tianocore.CNameType;\r | |
30 | import org.tianocore.ExternsDocument;\r | |
31 | import org.tianocore.FileNameConvention;\r | |
32 | import org.tianocore.FvImagesDocument;\r | |
33 | import org.tianocore.GuidDeclarationsDocument;\r | |
34 | import org.tianocore.GuidsDocument;\r | |
35 | import org.tianocore.LibrariesDocument;\r | |
36 | import org.tianocore.LibraryClassDeclarationsDocument;\r | |
37 | import org.tianocore.LibraryClassDocument;\r | |
38 | import org.tianocore.ModuleDefinitionsDocument;\r | |
39 | import org.tianocore.ModuleSADocument;\r | |
40 | import org.tianocore.ModuleSaBuildOptionsDocument;\r | |
41 | import org.tianocore.ModuleTypeDef;\r | |
42 | import org.tianocore.MsaFilesDocument;\r | |
43 | import org.tianocore.MsaHeaderDocument;\r | |
44 | import org.tianocore.OptionDocument;\r | |
45 | import org.tianocore.PPIsDocument;\r | |
46 | import org.tianocore.PackageDependenciesDocument;\r | |
47 | import org.tianocore.PackageHeadersDocument;\r | |
48 | import org.tianocore.PcdCodedDocument;\r | |
49 | import org.tianocore.PlatformDefinitionsDocument;\r | |
50 | import org.tianocore.PlatformHeaderDocument;\r | |
51 | import org.tianocore.PpiDeclarationsDocument;\r | |
52 | import org.tianocore.ProtocolDeclarationsDocument;\r | |
53 | import org.tianocore.Sentence;\r | |
54 | import org.tianocore.SpdHeaderDocument;\r | |
55 | import org.tianocore.UserExtensionsDocument;\r | |
56 | import org.tianocore.FilenameDocument.Filename;\r | |
57 | import org.tianocore.MsaHeaderDocument.MsaHeader;\r | |
58 | import org.tianocore.ProtocolsDocument.Protocols.Protocol;\r | |
59 | import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r | |
60 | import org.tianocore.build.id.FpdModuleIdentification;\r | |
61 | import org.tianocore.build.id.ModuleIdentification;\r | |
62 | import org.tianocore.build.id.PackageIdentification;\r | |
63 | import org.tianocore.build.id.PlatformIdentification;\r | |
64 | import org.tianocore.build.toolchain.ToolChainInfo;\r | |
65 | import org.tianocore.logger.EdkLog;\r | |
66 | import org.w3c.dom.Node;\r | |
67 | \r | |
68 | /**\r | |
69 | * SurfaceAreaQuery class is used to query Surface Area information from msa,\r | |
70 | * mbd, spd and fpd files.\r | |
71 | * \r | |
72 | * This class should not instantiated. All the public interfaces is static.\r | |
73 | * \r | |
74 | * @since GenBuild 1.0\r | |
75 | */\r | |
76 | public class SurfaceAreaQuery {\r | |
77 | \r | |
78 | public static String prefix = "http://www.TianoCore.org/2006/Edk2.0";\r | |
79 | \r | |
80 | // /\r | |
81 | // / Contains name/value pairs of Surface Area document object. The name is\r | |
82 | // / always the top level element name.\r | |
83 | // /\r | |
84 | private static Map<String, XmlObject> map = null;\r | |
85 | \r | |
86 | // /\r | |
87 | // / mapStack is used to do nested query\r | |
88 | // /\r | |
89 | private static Stack<Map<String, XmlObject>> mapStack = new Stack<Map<String, XmlObject>>();\r | |
90 | \r | |
91 | // /\r | |
92 | // / prefix of name space\r | |
93 | // /\r | |
94 | private static String nsPrefix = "sans";\r | |
95 | \r | |
96 | // /\r | |
97 | // / xmlbeans needs a name space for each Xpath element\r | |
98 | // /\r | |
99 | private static String ns = null;\r | |
100 | \r | |
101 | // /\r | |
102 | // / keep the namep declaration for xmlbeans Xpath query\r | |
103 | // /\r | |
104 | private static String queryDeclaration = null;\r | |
105 | \r | |
106 | /**\r | |
107 | * Set a Surface Area document for query later\r | |
108 | * \r | |
109 | * @param map\r | |
110 | * A Surface Area document in TopLevelElementName/XmlObject\r | |
111 | * format.\r | |
112 | */\r | |
113 | public static void setDoc(Map<String, XmlObject> map) {\r | |
114 | ns = prefix;\r | |
115 | queryDeclaration = "declare namespace " + nsPrefix + "='" + ns + "'; ";\r | |
116 | SurfaceAreaQuery.map = map;\r | |
117 | }\r | |
118 | \r | |
119 | /**\r | |
120 | * Push current used Surface Area document into query stack. The given new\r | |
121 | * document will be used for any immediately followed getXXX() callings,\r | |
122 | * untill pop() is called.\r | |
123 | * \r | |
124 | * @param newMap\r | |
125 | * The TopLevelElementName/XmlObject format of a Surface Area\r | |
126 | * document.\r | |
127 | */\r | |
128 | public static void push(Map<String, XmlObject> newMap) {\r | |
129 | mapStack.push(SurfaceAreaQuery.map);\r | |
130 | SurfaceAreaQuery.map = newMap;\r | |
131 | }\r | |
132 | \r | |
133 | /**\r | |
134 | * Discard current used Surface Area document and use the top document in\r | |
135 | * stack instead.\r | |
136 | */\r | |
137 | public static void pop() {\r | |
138 | SurfaceAreaQuery.map = mapStack.pop();\r | |
139 | }\r | |
140 | \r | |
141 | // /\r | |
142 | // / Convert xPath to be namespace qualified, which is necessary for\r | |
143 | // XmlBeans\r | |
144 | // / selectPath(). For example, converting /MsaHeader/ModuleType to\r | |
145 | // / /ns:MsaHeader/ns:ModuleType\r | |
146 | // /\r | |
147 | private static String normalizeQueryString(String[] exp, String from) {\r | |
148 | StringBuffer normQueryString = new StringBuffer(4096);\r | |
149 | \r | |
150 | int i = 0;\r | |
151 | while (i < exp.length) {\r | |
152 | String newExp = from + exp[i];\r | |
153 | Pattern pattern = Pattern.compile("([^/]*)(/|//)([^/]+)");\r | |
154 | Matcher matcher = pattern.matcher(newExp);\r | |
155 | \r | |
156 | while (matcher.find()) {\r | |
157 | String starter = newExp.substring(matcher.start(1), matcher\r | |
158 | .end(1));\r | |
159 | String seperator = newExp.substring(matcher.start(2), matcher\r | |
160 | .end(2));\r | |
161 | String token = newExp.substring(matcher.start(3), matcher\r | |
162 | .end(3));\r | |
163 | \r | |
164 | normQueryString.append(starter);\r | |
165 | normQueryString.append(seperator);\r | |
166 | normQueryString.append(nsPrefix);\r | |
167 | normQueryString.append(":");\r | |
168 | normQueryString.append(token);\r | |
169 | }\r | |
170 | \r | |
171 | ++i;\r | |
172 | if (i < exp.length) {\r | |
173 | normQueryString.append(" | ");\r | |
174 | }\r | |
175 | }\r | |
176 | \r | |
177 | return normQueryString.toString();\r | |
178 | }\r | |
179 | \r | |
180 | /**\r | |
181 | * Search all XML documents stored in "map" for the specified xPath, using\r | |
182 | * relative path (starting with '$this')\r | |
183 | * \r | |
184 | * @param xPath\r | |
185 | * xpath query string array\r | |
186 | * @returns An array of XmlObject if elements are found at the specified\r | |
187 | * xpath\r | |
188 | * @returns NULL if nothing is at the specified xpath\r | |
189 | */\r | |
190 | public static Object[] get(String[] xPath) {\r | |
191 | if (map == null) {\r | |
192 | return null;\r | |
193 | }\r | |
194 | \r | |
195 | String[] keys = (String[]) map.keySet().toArray(new String[map.size()]);\r | |
196 | List<Object> result = new ArrayList<Object>();\r | |
197 | for (int i = 0; i < keys.length; ++i) {\r | |
198 | XmlObject rootNode = (XmlObject) map.get(keys[i]);\r | |
199 | if (rootNode == null) {\r | |
200 | continue;\r | |
201 | }\r | |
202 | \r | |
203 | String query = queryDeclaration\r | |
204 | + normalizeQueryString(xPath, "$this/" + keys[i]);\r | |
205 | XmlObject[] tmp = rootNode.selectPath(query);\r | |
206 | for (int j = 0; j < tmp.length; ++j) {\r | |
207 | result.add((Object)tmp[j]);\r | |
208 | }\r | |
209 | }\r | |
210 | \r | |
211 | int size = result.size();\r | |
212 | if (size <= 0) {\r | |
213 | return null;\r | |
214 | }\r | |
215 | \r | |
216 | return (Object[]) result.toArray(new Object[size]);\r | |
217 | }\r | |
218 | \r | |
219 | /**\r | |
220 | * Search XML documents named by "rootName" for the given xPath, using\r | |
221 | * relative path (starting with '$this')\r | |
222 | * \r | |
223 | * @param rootName\r | |
224 | * The top level element name\r | |
225 | * @param xPath\r | |
226 | * The xpath query string array\r | |
227 | * @returns An array of XmlObject if elements are found at the given xpath\r | |
228 | * @returns NULL if nothing is found at the given xpath\r | |
229 | */\r | |
230 | public static Object[] get(String rootName, String[] xPath) {\r | |
231 | if (map == null) {\r | |
232 | return null;\r | |
233 | }\r | |
234 | \r | |
235 | XmlObject root = (XmlObject) map.get(rootName);\r | |
236 | if (root == null) {\r | |
237 | return null;\r | |
238 | }\r | |
239 | \r | |
240 | String query = queryDeclaration\r | |
241 | + normalizeQueryString(xPath, "$this/" + rootName);\r | |
242 | XmlObject[] result = root.selectPath(query);\r | |
243 | if (result.length > 0) {\r | |
244 | return (Object[])result;\r | |
245 | }\r | |
246 | \r | |
247 | query = queryDeclaration + normalizeQueryString(xPath, "/" + rootName);\r | |
248 | result = root.selectPath(query);\r | |
249 | if (result.length > 0) {\r | |
250 | return (Object[])result;\r | |
251 | }\r | |
252 | \r | |
253 | return null;\r | |
254 | }\r | |
255 | \r | |
256 | /**\r | |
257 | * Retrieve SourceFiles/Filename for specified ARCH type\r | |
258 | * \r | |
259 | * @param arch\r | |
260 | * architecture name\r | |
261 | * @returns An 2 dimension string array if elements are found at the known\r | |
262 | * xpath\r | |
263 | * @returns NULL if nothing is found at the known xpath\r | |
264 | */\r | |
265 | public static String[][] getSourceFiles(String arch) {\r | |
266 | String[] xPath;\r | |
267 | Object[] returns;\r | |
268 | \r | |
269 | xPath = new String[] { "/Filename" };\r | |
270 | \r | |
271 | returns = get("SourceFiles", xPath);\r | |
272 | \r | |
273 | if (returns == null || returns.length == 0) {\r | |
274 | return new String[0][0];\r | |
275 | }\r | |
276 | \r | |
277 | Filename[] sourceFileNames = (Filename[]) returns;\r | |
278 | List<String[]> outputList = new ArrayList<String[]>();\r | |
279 | for (int i = 0; i < sourceFileNames.length; i++) {\r | |
280 | List archList = sourceFileNames[i].getSupArchList();\r | |
281 | if (arch == null || arch.equalsIgnoreCase("") || archList == null || contains(archList, arch)) {\r | |
282 | outputList.add(new String[] {sourceFileNames[i].getToolCode(),sourceFileNames[i].getStringValue()});\r | |
283 | }\r | |
284 | }\r | |
285 | \r | |
286 | String[][] outputString = new String[outputList.size()][2];\r | |
287 | for (int index = 0; index < outputList.size(); index++) {\r | |
288 | outputString[index][0] = outputList.get(index)[0];\r | |
289 | outputString[index][1] = outputList.get(index)[1];\r | |
290 | }\r | |
291 | return outputString;\r | |
292 | }\r | |
293 | \r | |
294 | /**\r | |
295 | * Retrieve /PlatformDefinitions/OutputDirectory from FPD\r | |
296 | * \r | |
297 | * @returns Directory names array if elements are found at the known xpath\r | |
298 | * @returns Empty if nothing is found at the known xpath\r | |
299 | */\r | |
300 | public static String getFpdOutputDirectory() {\r | |
301 | String[] xPath = new String[] { "/PlatformDefinitions" };\r | |
302 | \r | |
303 | Object[] returns = get("PlatformSurfaceArea", xPath);\r | |
304 | if (returns == null || returns.length == 0) {\r | |
305 | return null;\r | |
306 | }\r | |
307 | PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];\r | |
308 | return item.getOutputDirectory();\r | |
309 | }\r | |
310 | \r | |
311 | public static String getFpdIntermediateDirectories() {\r | |
312 | String[] xPath = new String[] { "/PlatformDefinitions" };\r | |
313 | \r | |
314 | Object[] returns = get("PlatformSurfaceArea", xPath);\r | |
315 | if (returns == null || returns.length == 0) {\r | |
316 | return "UNIFIED";\r | |
317 | }\r | |
318 | PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];\r | |
319 | if(item.getIntermediateDirectories() == null) {\r | |
320 | return null; \r | |
321 | }\r | |
322 | else {\r | |
323 | return item.getIntermediateDirectories().toString();\r | |
324 | }\r | |
325 | }\r | |
326 | \r | |
327 | public static String getModuleFfsKeyword() {\r | |
328 | String[] xPath = new String[] { "/" };\r | |
329 | \r | |
330 | Object[] returns = get("ModuleSaBuildOptions", xPath);\r | |
331 | if (returns == null || returns.length == 0) {\r | |
332 | return null;\r | |
333 | }\r | |
334 | ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0];\r | |
335 | return item.getFfsFormatKey();\r | |
336 | }\r | |
337 | \r | |
338 | public static String getModuleFvBindingKeyword() {\r | |
339 | String[] xPath = new String[] { "/" };\r | |
340 | \r | |
341 | Object[] returns = get("ModuleSaBuildOptions", xPath);\r | |
342 | if (returns == null || returns.length == 0) {\r | |
343 | return null;\r | |
344 | }\r | |
345 | ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0];\r | |
346 | return item.getFvBinding();\r | |
347 | }\r | |
348 | \r | |
349 | public static List getModuleSupportedArchs() {\r | |
350 | String[] xPath = new String[] { "/" };\r | |
351 | \r | |
352 | Object[] returns = get("ModuleDefinitions", xPath);\r | |
353 | if (returns == null || returns.length == 0) {\r | |
354 | return null;\r | |
355 | }\r | |
356 | ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0];\r | |
357 | return item.getSupportedArchitectures();\r | |
358 | }\r | |
359 | \r | |
360 | public static BuildOptionsDocument.BuildOptions.Ffs[] getFpdFfs() {\r | |
361 | String[] xPath = new String[] {"/Ffs"};\r | |
362 | \r | |
363 | Object[] returns = get("BuildOptions", xPath);\r | |
364 | if (returns == null || returns.length == 0) {\r | |
365 | return new BuildOptionsDocument.BuildOptions.Ffs[0];\r | |
366 | }\r | |
367 | return (BuildOptionsDocument.BuildOptions.Ffs[])returns;\r | |
368 | }\r | |
369 | \r | |
370 | public static String getModuleOutputFileBasename() {\r | |
371 | String[] xPath = new String[] { "/" };\r | |
372 | \r | |
373 | Object[] returns = get("ModuleDefinitions", xPath);\r | |
374 | if (returns == null || returns.length == 0) {\r | |
375 | return null;\r | |
376 | }\r | |
377 | ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0];\r | |
378 | return item.getOutputFileBasename();\r | |
379 | }\r | |
380 | \r | |
381 | /**\r | |
382 | * Retrieve BuildOptions/Option or Arch/Option\r | |
383 | * \r | |
384 | * @param toolChainFamilyFlag\r | |
385 | * if true, retrieve options for toolchain family; otherwise for\r | |
386 | * toolchain\r | |
387 | * \r | |
388 | * @returns String[][5] name, target, toolchain, arch, coommand of options\r | |
389 | * if elements are found at the known xpath. String[0][] if dont\r | |
390 | * find element.\r | |
391 | * \r | |
392 | * @returns Empty array if nothing is there\r | |
393 | */\r | |
394 | public static String[][] getOptions(String from, String[] xPath, boolean toolChainFamilyFlag) {\r | |
395 | String target = null;\r | |
396 | String toolchain = null;\r | |
397 | String toolchainFamily = null;\r | |
398 | List<String> archList = null;\r | |
399 | String cmd = null;\r | |
400 | String optionName = null;\r | |
401 | \r | |
402 | Object[] returns = get(from, xPath);\r | |
403 | if (returns == null) {\r | |
404 | return new String[0][5];\r | |
405 | }\r | |
406 | \r | |
407 | List<String[]> optionList = new ArrayList<String[]>();\r | |
408 | OptionDocument.Option option;\r | |
409 | \r | |
410 | for (int i = 0; i < returns.length; i++) {\r | |
411 | option = (OptionDocument.Option) returns[i];\r | |
412 | \r | |
413 | //\r | |
414 | // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,\r | |
415 | // then\r | |
416 | // put to result[][5] array in above order.\r | |
417 | //\r | |
418 | String[] targetList;\r | |
419 | if (option.getBuildTargets() == null) {\r | |
420 | target = null;\r | |
421 | }\r | |
422 | else {\r | |
423 | target = option.getBuildTargets().toString();\r | |
424 | }\r | |
425 | if (target != null) {\r | |
426 | targetList = target.split(" ");\r | |
427 | } else {\r | |
428 | targetList = new String[1];\r | |
429 | targetList[0] = null;\r | |
430 | }\r | |
431 | \r | |
432 | if (toolChainFamilyFlag) {\r | |
433 | toolchainFamily = option.getToolChainFamily();\r | |
434 | if (toolchainFamily != null) {\r | |
435 | toolchain = toolchainFamily.toString();\r | |
436 | } else {\r | |
437 | toolchain = null;\r | |
438 | }\r | |
439 | } else {\r | |
440 | toolchain = option.getTagName();\r | |
441 | }\r | |
442 | \r | |
443 | archList = new ArrayList<String>();\r | |
444 | List archEnumList = option.getSupArchList(); \r | |
445 | if (archEnumList == null) {\r | |
446 | archList.add(null);\r | |
447 | } else {\r | |
448 | //archList.addAll(archEnumList);\r | |
449 | Iterator it = archEnumList.iterator();\r | |
450 | while (it.hasNext()) {\r | |
451 | String archType = (String)it.next();\r | |
452 | archList.add(archType);\r | |
453 | }\r | |
454 | }\r | |
455 | \r | |
456 | cmd = option.getToolCode();\r | |
457 | \r | |
458 | optionName = option.getStringValue();\r | |
459 | for (int t = 0; t < targetList.length; t++) {\r | |
460 | for (int j = 0; j < archList.size(); j++) {\r | |
461 | optionList.add(new String[] { targetList[t],\r | |
462 | toolchain, archList.get(j), cmd, optionName});\r | |
463 | }\r | |
464 | }\r | |
465 | }\r | |
466 | \r | |
467 | String[][] result = new String[optionList.size()][5];\r | |
468 | for (int i = 0; i < optionList.size(); i++) {\r | |
469 | result[i][0] = optionList.get(i)[0];\r | |
470 | result[i][1] = optionList.get(i)[1];\r | |
471 | result[i][2] = optionList.get(i)[2];\r | |
472 | result[i][3] = optionList.get(i)[3];\r | |
473 | result[i][4] = optionList.get(i)[4];\r | |
474 | }\r | |
475 | return result;\r | |
476 | }\r | |
477 | \r | |
478 | public static String[][] getModuleBuildOptions(boolean toolChainFamilyFlag) {\r | |
479 | String[] xPath;\r | |
480 | \r | |
481 | if (toolChainFamilyFlag == true) {\r | |
482 | xPath = new String[] {\r | |
483 | "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r | |
484 | "/Options/Option[@ToolChainFamily]", };\r | |
485 | } else {\r | |
486 | xPath = new String[] {\r | |
487 | "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r | |
488 | "/Options/Option[@TagName]", };\r | |
489 | }\r | |
490 | return getOptions("ModuleSaBuildOptions", xPath, toolChainFamilyFlag);\r | |
491 | } \r | |
492 | \r | |
493 | public static String[][] getPlatformBuildOptions(boolean toolChainFamilyFlag) {\r | |
494 | String[] xPath;\r | |
495 | \r | |
496 | if (toolChainFamilyFlag == true) {\r | |
497 | xPath = new String[] {\r | |
498 | "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r | |
499 | "/BuildOptions/Options/Option[@ToolChainFamily]", };\r | |
500 | } else {\r | |
501 | xPath = new String[] {\r | |
502 | "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r | |
503 | "/BuildOptions/Options/Option[@TagName]", };\r | |
504 | }\r | |
505 | \r | |
506 | return getOptions("PlatformSurfaceArea", xPath, toolChainFamilyFlag);\r | |
507 | }\r | |
508 | \r | |
509 | public static ToolChainInfo getFpdToolChainInfo() {\r | |
510 | String[] xPath = new String[] { "/PlatformDefinitions" };\r | |
511 | \r | |
512 | Object[] returns = get("PlatformSurfaceArea", xPath);\r | |
513 | if (returns == null || returns.length == 0) {\r | |
514 | return null;\r | |
515 | }\r | |
516 | \r | |
517 | PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];\r | |
518 | ToolChainInfo toolChainInfo = new ToolChainInfo();\r | |
519 | toolChainInfo.addTargets(item.getBuildTargets().toString());\r | |
520 | toolChainInfo.addArchs(item.getSupportedArchitectures().toString());\r | |
521 | toolChainInfo.addTagnames((String)null);\r | |
522 | return toolChainInfo;\r | |
523 | }\r | |
524 | \r | |
525 | /**\r | |
526 | * Retrieve <xxxHeader>/ModuleType\r | |
527 | * \r | |
528 | * @returns The module type name if elements are found at the known xpath\r | |
529 | * @returns null if nothing is there\r | |
530 | */\r | |
531 | public static String getModuleType() {\r | |
532 | String[] xPath = new String[] { "/ModuleType" };\r | |
533 | \r | |
534 | Object[] returns = get(xPath);\r | |
535 | if (returns != null && returns.length > 0) {\r | |
536 | ModuleTypeDef type = (ModuleTypeDef) returns[0];\r | |
537 | return type.enumValue().toString();\r | |
538 | }\r | |
539 | \r | |
540 | return null;\r | |
541 | }\r | |
542 | \r | |
543 | /**\r | |
544 | * Retrieve PackageDependencies/Package\r | |
545 | * \r | |
546 | * @param arch\r | |
547 | * Architecture name\r | |
548 | * \r | |
549 | * @returns package name list if elements are found at the known xpath\r | |
550 | * @returns null if nothing is there\r | |
551 | */\r | |
552 | public static PackageIdentification[] getDependencePkg(String arch) {\r | |
553 | String[] xPath;\r | |
554 | String packageGuid = null;\r | |
555 | String packageVersion = null;\r | |
556 | \r | |
557 | \r | |
558 | xPath = new String[] { "/Package" };\r | |
559 | \r | |
560 | Object[] returns = get("PackageDependencies", xPath);\r | |
561 | if (returns == null) {\r | |
562 | return new PackageIdentification[0];\r | |
563 | }\r | |
564 | \r | |
565 | //\r | |
566 | // Get packageIdentification \r | |
567 | // \r | |
568 | List<PackageIdentification> packageIdList = new ArrayList<PackageIdentification>();\r | |
569 | for (int i = 0; i < returns.length; i++) {\r | |
570 | PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i];\r | |
571 | List archList = item.getSupArchList();\r | |
572 | if (arch == null || archList == null || contains(archList, arch)) {\r | |
573 | packageGuid = item.getPackageGuid();\r | |
574 | packageVersion = item.getPackageVersion();\r | |
575 | packageIdList.add(new PackageIdentification(null, packageGuid,\r | |
576 | packageVersion));\r | |
577 | }\r | |
578 | }\r | |
579 | \r | |
580 | //\r | |
581 | // transfer packageIdentification list to array.\r | |
582 | // \r | |
583 | PackageIdentification[] packageIdArray = new PackageIdentification[packageIdList.size()];\r | |
584 | for (int i = 0; i < packageIdList.size(); i++) {\r | |
585 | packageIdArray[i] = new PackageIdentification(null, packageIdList.get(i).getGuid(),packageIdList.get(i).getVersion());\r | |
586 | }\r | |
587 | return packageIdArray;\r | |
588 | }\r | |
589 | \r | |
590 | /**\r | |
591 | * Retrieve LibraryClassDefinitions/LibraryClass for specified usage\r | |
592 | * \r | |
593 | * @param usage\r | |
594 | * Library class usage\r | |
595 | * \r | |
596 | * @returns LibraryClass objects list if elements are found at the known\r | |
597 | * xpath\r | |
598 | * @returns null if nothing is there\r | |
599 | */\r | |
600 | public static String[] getLibraryClasses(String usage, String arch) {\r | |
601 | String[] xPath;\r | |
602 | if (usage == null || usage.equals("")) {\r | |
603 | xPath = new String[] { "/LibraryClass" };\r | |
604 | } else {\r | |
605 | xPath = new String[] { "/LibraryClass[@Usage='" + usage + "']" };\r | |
606 | }\r | |
607 | \r | |
608 | Object[] returns = get("LibraryClassDefinitions", xPath);\r | |
609 | if (returns == null || returns.length == 0) {\r | |
610 | return new String[0];\r | |
611 | }\r | |
612 | \r | |
613 | LibraryClassDocument.LibraryClass[] libraryClassList = (LibraryClassDocument.LibraryClass[]) returns;\r | |
614 | List<String> libraryClassName = new ArrayList<String>();\r | |
615 | for (int i = 0; i < libraryClassList.length; i++) {\r | |
616 | List archList = libraryClassList[i].getSupArchList();\r | |
617 | \r | |
618 | if (arch == null || contains(archList, arch)) {\r | |
619 | libraryClassName.add(libraryClassList[i].getKeyword());\r | |
620 | }\r | |
621 | }\r | |
622 | String[] libraryArray = new String[libraryClassName.size()];\r | |
623 | for (int i = 0; i < libraryClassName.size(); i++) {\r | |
624 | libraryArray[i] = libraryClassName.get(i);\r | |
625 | }\r | |
626 | return libraryArray;\r | |
627 | }\r | |
628 | \r | |
629 | /**\r | |
630 | * Retrieve ModuleEntryPoint names\r | |
631 | * \r | |
632 | * @returns ModuleEntryPoint name list if elements are found at the known\r | |
633 | * xpath\r | |
634 | * @returns null if nothing is there\r | |
635 | */\r | |
636 | public static String[] getModuleEntryPointArray() {\r | |
637 | String[] xPath = new String[] { "/Extern/ModuleEntryPoint" };\r | |
638 | \r | |
639 | Object[] returns = get("Externs", xPath);\r | |
640 | \r | |
641 | if (returns != null && returns.length > 0) {\r | |
642 | String[] entryPoints = new String[returns.length];\r | |
643 | \r | |
644 | for (int i = 0; i < returns.length; ++i) {\r | |
645 | entryPoints[i] = ((CNameType) returns[i]).getStringValue();\r | |
646 | }\r | |
647 | \r | |
648 | return entryPoints;\r | |
649 | }\r | |
650 | \r | |
651 | return null;\r | |
652 | }\r | |
653 | \r | |
654 | /**\r | |
655 | * retrieve Protocol for specified usage\r | |
656 | * \r | |
657 | * @param usage\r | |
658 | * Protocol usage arch Architecture\r | |
659 | * \r | |
660 | * @returns Protocol String list if elements are found at the known xpath\r | |
661 | * @returns String[0] if nothing is there\r | |
662 | */\r | |
663 | public static String[] getProtocolArray(String arch, String usage) {\r | |
664 | String[] xPath;\r | |
665 | String usageXpath = "";\r | |
666 | String archXpath = "";\r | |
667 | \r | |
668 | if (arch == null || arch.equals("")) {\r | |
669 | return new String[0];\r | |
670 | } else {\r | |
671 | archXpath = "/Protocol";\r | |
672 | if (usage != null && !usage.equals("")) {\r | |
673 | usageXpath = "/Protocol[@Usage='" + usage + "']";\r | |
674 | xPath = new String[] { usageXpath, archXpath };\r | |
675 | } else {\r | |
676 | return getProtocolArray(arch);\r | |
677 | }\r | |
678 | \r | |
679 | }\r | |
680 | \r | |
681 | Object[] returns = get("Protocols", xPath);\r | |
682 | if (returns == null) {\r | |
683 | return new String[0];\r | |
684 | }\r | |
685 | Protocol[] protocolList = (Protocol[]) returns;\r | |
686 | \r | |
687 | String[] protocolArray = new String[returns.length];\r | |
688 | for (int i = 0; i < returns.length; i++) {\r | |
689 | protocolArray[i] = protocolList[i].getProtocolCName();\r | |
690 | }\r | |
691 | return protocolArray;\r | |
692 | }\r | |
693 | \r | |
694 | /**\r | |
695 | * retrieve Protocol for specified usage\r | |
696 | * \r | |
697 | * @param arch\r | |
698 | * Architecture\r | |
699 | * \r | |
700 | * @returns Protocol String list if elements are found at the known xpath\r | |
701 | * @returns String[0] if nothing is there\r | |
702 | */\r | |
703 | public static String[] getProtocolArray(String arch) {\r | |
704 | String[] xPath;\r | |
705 | \r | |
706 | if (arch == null || arch.equals("")) {\r | |
707 | return new String[0];\r | |
708 | } else {\r | |
709 | xPath = new String[] { "/Protocol" };\r | |
710 | }\r | |
711 | \r | |
712 | Object[] returns = get("Protocols", xPath);\r | |
713 | if (returns == null) {\r | |
714 | return new String[0];\r | |
715 | }\r | |
716 | Protocol[] returnlList = (Protocol[]) returns;\r | |
717 | \r | |
718 | List<String> protocolList = new ArrayList<String>();\r | |
719 | \r | |
720 | for (int i = 0; i < returns.length; i++) {\r | |
721 | List archList = returnlList[i].getSupArchList();\r | |
722 | if (archList == null || contains(archList, arch)){\r | |
723 | protocolList.add(returnlList[i].getProtocolCName());\r | |
724 | }\r | |
725 | }\r | |
726 | String[] protocolArray = new String[protocolList.size()];\r | |
727 | for (int i = 0; i < protocolList.size(); i++) {\r | |
728 | protocolArray[i] = protocolList.get(i);\r | |
729 | }\r | |
730 | return protocolArray;\r | |
731 | }\r | |
732 | \r | |
733 | /**\r | |
734 | * Retrieve ProtocolNotify for specified usage\r | |
735 | * \r | |
736 | * @param usage\r | |
737 | * ProtocolNotify usage\r | |
738 | * \r | |
739 | * @returns String[] if elements are found at the known xpath\r | |
740 | * @returns String[0] if nothing is there\r | |
741 | */\r | |
742 | public static String[] getProtocolNotifyArray(String arch) {\r | |
743 | String[] xPath;\r | |
744 | \r | |
745 | if (arch == null || arch.equals("")) {\r | |
746 | return new String[0];\r | |
747 | } else {\r | |
748 | xPath = new String[] { "/ProtocolNotify" };\r | |
749 | }\r | |
750 | \r | |
751 | Object[] returns = get("Protocols", xPath);\r | |
752 | if (returns == null) {\r | |
753 | return new String[0];\r | |
754 | }\r | |
755 | \r | |
756 | List<String> protocolNotifyList = new ArrayList<String>();\r | |
757 | \r | |
758 | for (int i = 0; i < returns.length; i++) {\r | |
759 | List archList = ((ProtocolNotify) returns[i]).getSupArchList();\r | |
760 | if (archList == null || contains(archList, arch)){\r | |
761 | protocolNotifyList.add(((ProtocolNotify) returns[i]).getProtocolNotifyCName());\r | |
762 | }\r | |
763 | \r | |
764 | }\r | |
765 | String[] protocolNotifyArray = new String[protocolNotifyList.size()];\r | |
766 | for (int i = 0; i < protocolNotifyList.size(); i++) {\r | |
767 | protocolNotifyArray[i] = protocolNotifyList.get(i);\r | |
768 | }\r | |
769 | return protocolNotifyArray;\r | |
770 | }\r | |
771 | \r | |
772 | /**\r | |
773 | * Retrieve ProtocolNotify for specified usage\r | |
774 | * \r | |
775 | * @param usage\r | |
776 | * ProtocolNotify usage\r | |
777 | * \r | |
778 | * @returns String[] if elements are found at the known xpath\r | |
779 | * @returns String[0] if nothing is there\r | |
780 | */\r | |
781 | public static String[] getProtocolNotifyArray(String arch, String usage) {\r | |
782 | \r | |
783 | String[] xPath;\r | |
784 | String usageXpath;\r | |
785 | String archXpath;\r | |
786 | \r | |
787 | if (arch == null || arch.equals("")) {\r | |
788 | return new String[0];\r | |
789 | } else {\r | |
790 | archXpath = "/ProtocolNotify";\r | |
791 | if (usage != null && !usage.equals("")) {\r | |
792 | usageXpath = "/ProtocolNotify[@Usage='" + arch + "']";\r | |
793 | xPath = new String[] { archXpath, usageXpath };\r | |
794 | } else {\r | |
795 | return getProtocolNotifyArray(arch);\r | |
796 | }\r | |
797 | }\r | |
798 | \r | |
799 | Object[] returns = get("Protocols", xPath);\r | |
800 | if (returns == null) {\r | |
801 | return new String[0];\r | |
802 | }\r | |
803 | \r | |
804 | String[] protocolNotifyList = new String[returns.length];\r | |
805 | \r | |
806 | for (int i = 0; i < returns.length; i++) {\r | |
807 | protocolNotifyList[i] = ((ProtocolNotify) returns[i]).getProtocolNotifyCName();\r | |
808 | }\r | |
809 | return protocolNotifyList;\r | |
810 | }\r | |
811 | \r | |
812 | /**\r | |
813 | * Retrieve ModuleUnloadImage names\r | |
814 | * \r | |
815 | * @returns ModuleUnloadImage name list if elements are found at the known\r | |
816 | * xpath\r | |
817 | * @returns null if nothing is there\r | |
818 | */\r | |
819 | public static String[] getModuleUnloadImageArray() {\r | |
820 | String[] xPath = new String[] { "/Extern/ModuleUnloadImage" };\r | |
821 | \r | |
822 | Object[] returns = get("Externs", xPath);\r | |
823 | if (returns != null && returns.length > 0) {\r | |
824 | String[] stringArray = new String[returns.length];\r | |
825 | CNameType[] doc = (CNameType[]) returns;\r | |
826 | \r | |
827 | for (int i = 0; i < returns.length; ++i) {\r | |
828 | stringArray[i] = doc[i].getStringValue();\r | |
829 | }\r | |
830 | \r | |
831 | return stringArray;\r | |
832 | }\r | |
833 | \r | |
834 | return null;\r | |
835 | }\r | |
836 | \r | |
837 | /**\r | |
838 | * Retrieve Extern\r | |
839 | * \r | |
840 | * @returns Extern objects list if elements are found at the known xpath\r | |
841 | * @returns null if nothing is there\r | |
842 | */\r | |
843 | public static ExternsDocument.Externs.Extern[] getExternArray() {\r | |
844 | String[] xPath = new String[] { "/Extern" };\r | |
845 | \r | |
846 | Object[] returns = get("Externs", xPath);\r | |
847 | if (returns != null && returns.length > 0) {\r | |
848 | return (ExternsDocument.Externs.Extern[]) returns;\r | |
849 | }\r | |
850 | \r | |
851 | return null;\r | |
852 | }\r | |
853 | \r | |
854 | /**\r | |
855 | * Retrieve PpiNotify for specified arch\r | |
856 | * \r | |
857 | * @param arch\r | |
858 | * PpiNotify arch\r | |
859 | * \r | |
860 | * @returns String[] if elements are found at the known xpath\r | |
861 | * @returns String[0] if nothing is there\r | |
862 | */\r | |
863 | public static String[] getPpiNotifyArray(String arch) {\r | |
864 | String[] xPath;\r | |
865 | \r | |
866 | if (arch == null || arch.equals("")) {\r | |
867 | return new String[0];\r | |
868 | } else {\r | |
869 | xPath = new String[] { "/PpiNotify" };\r | |
870 | }\r | |
871 | \r | |
872 | Object[] returns = get("PPIs", xPath);\r | |
873 | if (returns == null) {\r | |
874 | return new String[0];\r | |
875 | }\r | |
876 | \r | |
877 | \r | |
878 | List<String> ppiNotifyList = new ArrayList<String>();\r | |
879 | for (int i = 0; i < returns.length; i++) {\r | |
880 | List archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList();\r | |
881 | if (archList == null || contains(archList, arch)){\r | |
882 | ppiNotifyList.add(((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName()); \r | |
883 | }\r | |
884 | \r | |
885 | }\r | |
886 | String[] ppiNotifyArray = new String[ppiNotifyList.size()];\r | |
887 | for (int i = 0; i < ppiNotifyList.size(); i++) {\r | |
888 | ppiNotifyArray[i] = ppiNotifyList.get(i);\r | |
889 | }\r | |
890 | \r | |
891 | return ppiNotifyArray;\r | |
892 | }\r | |
893 | \r | |
894 | /**\r | |
895 | * Retrieve PpiNotify for specified usage and arch\r | |
896 | * \r | |
897 | * @param arch\r | |
898 | * PpiNotify arch usage PpiNotify usage\r | |
899 | * \r | |
900 | * \r | |
901 | * @returns String[] if elements are found at the known xpath\r | |
902 | * @returns String[0] if nothing is there\r | |
903 | */\r | |
904 | public static String[] getPpiNotifyArray(String arch, String usage) {\r | |
905 | \r | |
906 | String[] xPath;\r | |
907 | String usageXpath;\r | |
908 | String archXpath;\r | |
909 | \r | |
910 | if (arch == null || arch.equals("")) {\r | |
911 | return new String[0];\r | |
912 | } else {\r | |
913 | archXpath = "/PpiNotify";\r | |
914 | if (usage != null && !usage.equals("")) {\r | |
915 | usageXpath = "/PpiNotify[@Usage='" + arch + "']";\r | |
916 | xPath = new String[] { archXpath, usageXpath };\r | |
917 | } else {\r | |
918 | return getProtocolNotifyArray(arch);\r | |
919 | }\r | |
920 | }\r | |
921 | \r | |
922 | Object[] returns = get("PPIs", xPath);\r | |
923 | if (returns == null) {\r | |
924 | return new String[0];\r | |
925 | }\r | |
926 | \r | |
927 | String[] ppiNotifyList = new String[returns.length];\r | |
928 | \r | |
929 | for (int i = 0; i < returns.length; i++) {\r | |
930 | ppiNotifyList[i] = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName();\r | |
931 | }\r | |
932 | return ppiNotifyList;\r | |
933 | }\r | |
934 | \r | |
935 | /**\r | |
936 | * Retrieve Ppi for specified arch\r | |
937 | * \r | |
938 | * @param arch\r | |
939 | * Ppi arch\r | |
940 | * \r | |
941 | * @returns String[] if elements are found at the known xpath\r | |
942 | * @returns String[0] if nothing is there\r | |
943 | */\r | |
944 | public static String[] getPpiArray(String arch) {\r | |
945 | String[] xPath;\r | |
946 | \r | |
947 | if (arch == null || arch.equals("")) {\r | |
948 | return new String[0];\r | |
949 | } else {\r | |
950 | xPath = new String[] { "/Ppi" };\r | |
951 | }\r | |
952 | \r | |
953 | Object[] returns = get("PPIs", xPath);\r | |
954 | if (returns == null) {\r | |
955 | return new String[0];\r | |
956 | }\r | |
957 | \r | |
958 | List<String> ppiList = new ArrayList<String>();\r | |
959 | for (int i = 0; i < returns.length; i++) {\r | |
960 | List archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList();\r | |
961 | if (archList == null || contains(archList, arch)){\r | |
962 | ppiList.add(((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName()); \r | |
963 | }\r | |
964 | \r | |
965 | }\r | |
966 | String[] ppiArray = new String[ppiList.size()];\r | |
967 | for (int i = 0; i < ppiList.size(); i++) {\r | |
968 | ppiArray[i] = ppiList.get(i);\r | |
969 | }\r | |
970 | return ppiArray;\r | |
971 | }\r | |
972 | \r | |
973 | /**\r | |
974 | * Retrieve PpiNotify for specified usage and arch\r | |
975 | * \r | |
976 | * @param arch\r | |
977 | * PpiNotify arch usage PpiNotify usage\r | |
978 | * \r | |
979 | * \r | |
980 | * @returns String[] if elements are found at the known xpath\r | |
981 | * @returns String[0] if nothing is there\r | |
982 | */\r | |
983 | public static String[] getPpiArray(String arch, String usage) {\r | |
984 | \r | |
985 | String[] xPath;\r | |
986 | String usageXpath;\r | |
987 | String archXpath;\r | |
988 | \r | |
989 | if (arch == null || arch.equals("")) {\r | |
990 | return new String[0];\r | |
991 | } else {\r | |
992 | archXpath = "/Ppi";\r | |
993 | if (usage != null && !usage.equals("")) {\r | |
994 | usageXpath = "/Ppi[@Usage='" + arch + "']";\r | |
995 | xPath = new String[] { archXpath, usageXpath };\r | |
996 | } else {\r | |
997 | return getProtocolNotifyArray(arch);\r | |
998 | }\r | |
999 | }\r | |
1000 | \r | |
1001 | Object[] returns = get("PPIs", xPath);\r | |
1002 | if (returns == null) {\r | |
1003 | return new String[0];\r | |
1004 | }\r | |
1005 | \r | |
1006 | String[] ppiList = new String[returns.length];\r | |
1007 | \r | |
1008 | for (int i = 0; i < returns.length; i++) {\r | |
1009 | ppiList[i] = ((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName();\r | |
1010 | }\r | |
1011 | return ppiList;\r | |
1012 | }\r | |
1013 | \r | |
1014 | /**\r | |
1015 | * Retrieve GuidEntry information for specified usage\r | |
1016 | * \r | |
1017 | * @param arch\r | |
1018 | * GuidEntry arch\r | |
1019 | * \r | |
1020 | * @returns GuidEntry objects list if elements are found at the known xpath\r | |
1021 | * @returns null if nothing is there\r | |
1022 | */\r | |
1023 | public static String[] getGuidEntryArray(String arch) {\r | |
1024 | String[] xPath;\r | |
1025 | \r | |
1026 | if (arch == null || arch.equals("")) {\r | |
1027 | xPath = new String[] { "/GuidCNames" };\r | |
1028 | } else {\r | |
1029 | xPath = new String[] { "/GuidCNames" };\r | |
1030 | }\r | |
1031 | \r | |
1032 | Object[] returns = get("Guids", xPath);\r | |
1033 | if (returns == null) {\r | |
1034 | return new String[0];\r | |
1035 | }\r | |
1036 | \r | |
1037 | List<String> guidList = new ArrayList<String>();\r | |
1038 | for (int i = 0; i < returns.length; i++) {\r | |
1039 | List archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList();\r | |
1040 | if (archList == null || contains(archList, arch)){\r | |
1041 | guidList.add(((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName()); \r | |
1042 | }\r | |
1043 | \r | |
1044 | }\r | |
1045 | String[] guidArray = new String[guidList.size()];\r | |
1046 | for (int i = 0; i < guidList.size(); i++) {\r | |
1047 | guidArray[i] = guidList.get(i);\r | |
1048 | }\r | |
1049 | return guidArray;\r | |
1050 | \r | |
1051 | }\r | |
1052 | \r | |
1053 | /**\r | |
1054 | * Retrieve GuidEntry information for specified usage\r | |
1055 | * \r | |
1056 | * @param arch\r | |
1057 | * GuidEntry arch usage GuidEntry usage\r | |
1058 | * \r | |
1059 | * @returns GuidEntry objects list if elements are found at the known xpath\r | |
1060 | * @returns null if nothing is there\r | |
1061 | */\r | |
1062 | public static String[] getGuidEntryArray(String arch, String usage) {\r | |
1063 | String[] xPath;\r | |
1064 | String archXpath;\r | |
1065 | String usageXpath;\r | |
1066 | \r | |
1067 | if (arch == null || arch.equals("")) {\r | |
1068 | return new String[0];\r | |
1069 | } else {\r | |
1070 | archXpath = "/GuidEntry";\r | |
1071 | if (usage != null && !usage.equals("")) {\r | |
1072 | usageXpath = "/GuidEntry[@Usage='" + arch + "']";\r | |
1073 | xPath = new String[] { archXpath, usageXpath };\r | |
1074 | } else {\r | |
1075 | return getProtocolNotifyArray(arch);\r | |
1076 | }\r | |
1077 | }\r | |
1078 | \r | |
1079 | Object[] returns = get("Guids", xPath);\r | |
1080 | if (returns == null) {\r | |
1081 | return new String[0];\r | |
1082 | }\r | |
1083 | \r | |
1084 | String[] guidList = new String[returns.length];\r | |
1085 | \r | |
1086 | for (int i = 0; i < returns.length; i++) {\r | |
1087 | guidList[i] = ((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName();\r | |
1088 | }\r | |
1089 | return guidList;\r | |
1090 | }\r | |
1091 | \r | |
1092 | /**\r | |
1093 | * Retrieve Library instance information\r | |
1094 | * \r | |
1095 | * @param arch\r | |
1096 | * Architecture name\r | |
1097 | * @param usage\r | |
1098 | * Library instance usage\r | |
1099 | * \r | |
1100 | * @returns library instance name list if elements are found at the known\r | |
1101 | * xpath\r | |
1102 | * @returns null if nothing is there\r | |
1103 | */\r | |
1104 | public static ModuleIdentification[] getLibraryInstance(String arch) {\r | |
1105 | String[] xPath;\r | |
1106 | String saGuid = null;\r | |
1107 | String saVersion = null;\r | |
1108 | String pkgGuid = null;\r | |
1109 | String pkgVersion = null;\r | |
1110 | \r | |
1111 | if (arch == null || arch.equalsIgnoreCase("")) {\r | |
1112 | xPath = new String[] { "/Instance" };\r | |
1113 | } else {\r | |
1114 | //\r | |
1115 | // Since Schema don't have SupArchList now, so the follow Xpath is \r | |
1116 | // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]\r | |
1117 | // don't have effect.\r | |
1118 | //\r | |
1119 | xPath = new String[] { "/Instance[not(@SupArchList) or @SupArchList='"\r | |
1120 | + arch + "']" };\r | |
1121 | }\r | |
1122 | \r | |
1123 | Object[] returns = get("Libraries", xPath);\r | |
1124 | if (returns == null || returns.length == 0) {\r | |
1125 | return new ModuleIdentification[0];\r | |
1126 | }\r | |
1127 | \r | |
1128 | ModuleIdentification[] saIdList = new ModuleIdentification[returns.length];\r | |
1129 | for (int i = 0; i < returns.length; i++) {\r | |
1130 | LibrariesDocument.Libraries.Instance library = (LibrariesDocument.Libraries.Instance) returns[i];\r | |
1131 | saGuid = library.getModuleGuid();\r | |
1132 | saVersion = library.getModuleVersion();\r | |
1133 | \r | |
1134 | pkgGuid = library.getPackageGuid();\r | |
1135 | pkgVersion = library.getPackageVersion();\r | |
1136 | \r | |
1137 | ModuleIdentification saId = new ModuleIdentification(null, saGuid,\r | |
1138 | saVersion);\r | |
1139 | PackageIdentification pkgId = new PackageIdentification(null,\r | |
1140 | pkgGuid, pkgVersion);\r | |
1141 | saId.setPackage(pkgId);\r | |
1142 | \r | |
1143 | saIdList[i] = saId;\r | |
1144 | \r | |
1145 | }\r | |
1146 | return saIdList;\r | |
1147 | }\r | |
1148 | \r | |
1149 | // /\r | |
1150 | // / This method is used for retrieving the elements information which has\r | |
1151 | // / CName sub-element\r | |
1152 | // /\r | |
1153 | private static String[] getCNames(String from, String xPath[]) {\r | |
1154 | Object[] returns = get(from, xPath);\r | |
1155 | if (returns == null || returns.length == 0) {\r | |
1156 | return null;\r | |
1157 | }\r | |
1158 | \r | |
1159 | String[] strings = new String[returns.length];\r | |
1160 | for (int i = 0; i < returns.length; ++i) {\r | |
1161 | // TBD\r | |
1162 | strings[i] = ((CNameType) returns[i]).getStringValue();\r | |
1163 | }\r | |
1164 | \r | |
1165 | return strings;\r | |
1166 | }\r | |
1167 | \r | |
1168 | /**\r | |
1169 | * Retrive library's constructor name\r | |
1170 | * \r | |
1171 | * @returns constructor name list if elements are found at the known xpath\r | |
1172 | * @returns null if nothing is there\r | |
1173 | */\r | |
1174 | public static String getLibConstructorName() {\r | |
1175 | String[] xPath = new String[] { "/Extern/Constructor" };\r | |
1176 | \r | |
1177 | Object[] returns = get("Externs", xPath);\r | |
1178 | if (returns != null && returns.length > 0) {\r | |
1179 | CNameType constructor = ((CNameType) returns[0]);\r | |
1180 | return constructor.getStringValue();\r | |
1181 | }\r | |
1182 | \r | |
1183 | return null;\r | |
1184 | }\r | |
1185 | \r | |
1186 | /**\r | |
1187 | * Retrive library's destructor name\r | |
1188 | * \r | |
1189 | * @returns destructor name list if elements are found at the known xpath\r | |
1190 | * @returns null if nothing is there\r | |
1191 | */\r | |
1192 | public static String getLibDestructorName() {\r | |
1193 | String[] xPath = new String[] { "/Extern/Destructor" };\r | |
1194 | \r | |
1195 | Object[] returns = get("Externs", xPath);\r | |
1196 | if (returns != null && returns.length > 0) {\r | |
1197 | //\r | |
1198 | // Only support one Destructor function.\r | |
1199 | //\r | |
1200 | CNameType destructor = (CNameType) returns[0];\r | |
1201 | return destructor.getStringValue();\r | |
1202 | }\r | |
1203 | \r | |
1204 | return null;\r | |
1205 | }\r | |
1206 | \r | |
1207 | /**\r | |
1208 | * Retrive DriverBinding names\r | |
1209 | * \r | |
1210 | * @returns DriverBinding name list if elements are found at the known xpath\r | |
1211 | * @returns null if nothing is there\r | |
1212 | */\r | |
1213 | public static String[] getDriverBindingArray() {\r | |
1214 | String[] xPath = new String[] { "/Extern/DriverBinding" };\r | |
1215 | return getCNames("Externs", xPath);\r | |
1216 | }\r | |
1217 | \r | |
1218 | /**\r | |
1219 | * Retrive ComponentName names\r | |
1220 | * \r | |
1221 | * @returns ComponentName name list if elements are found at the known xpath\r | |
1222 | * @returns null if nothing is there\r | |
1223 | */\r | |
1224 | public static String[] getComponentNameArray() {\r | |
1225 | String[] xPath = new String[] { "/Extern/ComponentName" };\r | |
1226 | return getCNames("Externs", xPath);\r | |
1227 | }\r | |
1228 | \r | |
1229 | /**\r | |
1230 | * Retrive DriverConfig names\r | |
1231 | * \r | |
1232 | * @returns DriverConfig name list if elements are found at the known xpath\r | |
1233 | * @returns null if nothing is there\r | |
1234 | */\r | |
1235 | public static String[] getDriverConfigArray() {\r | |
1236 | String[] xPath = new String[] { "/Extern/DriverConfig" };\r | |
1237 | return getCNames("Externs", xPath);\r | |
1238 | }\r | |
1239 | \r | |
1240 | /**\r | |
1241 | * Retrive DriverDiag names\r | |
1242 | * \r | |
1243 | * @returns DriverDiag name list if elements are found at the known xpath\r | |
1244 | * @returns null if nothing is there\r | |
1245 | */\r | |
1246 | public static String[] getDriverDiagArray() {\r | |
1247 | String[] xPath = new String[] { "/Extern/DriverDiag" };\r | |
1248 | return getCNames("Externs", xPath);\r | |
1249 | }\r | |
1250 | \r | |
1251 | /**\r | |
1252 | * Retrive SetVirtualAddressMapCallBack names\r | |
1253 | * \r | |
1254 | * @returns SetVirtualAddressMapCallBack name list if elements are found at\r | |
1255 | * the known xpath\r | |
1256 | * @returns null if nothing is there\r | |
1257 | */\r | |
1258 | public static String[] getSetVirtualAddressMapCallBackArray() {\r | |
1259 | String[] xPath = new String[] { "/Extern/SetVirtualAddressMapCallBack" };\r | |
1260 | return getCNames("Externs", xPath);\r | |
1261 | }\r | |
1262 | \r | |
1263 | /**\r | |
1264 | * Retrive ExitBootServicesCallBack names\r | |
1265 | * \r | |
1266 | * @returns ExitBootServicesCallBack name list if elements are found at the\r | |
1267 | * known xpath\r | |
1268 | * @returns null if nothing is there\r | |
1269 | */\r | |
1270 | public static String[] getExitBootServicesCallBackArray() {\r | |
1271 | String[] xPath = new String[] { "/Extern/ExitBootServicesCallBack" };\r | |
1272 | return getCNames("Externs", xPath);\r | |
1273 | }\r | |
1274 | \r | |
1275 | /**\r | |
1276 | * Retrieve module surface area file information\r | |
1277 | * \r | |
1278 | * @returns ModuleSA objects list if elements are found at the known xpath\r | |
1279 | * @returns Empty ModuleSA list if nothing is there\r | |
1280 | */\r | |
1281 | public static Map<FpdModuleIdentification, Map<String, XmlObject>> getFpdModules() {\r | |
1282 | String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r | |
1283 | Object[] result = get("PlatformSurfaceArea", xPath);\r | |
1284 | String arch = null;\r | |
1285 | String fvBinding = null;\r | |
1286 | String saGuid = null;\r | |
1287 | String saVersion = null;\r | |
1288 | String pkgGuid = null;\r | |
1289 | String pkgVersion = null;\r | |
1290 | \r | |
1291 | Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleMap = new LinkedHashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r | |
1292 | \r | |
1293 | if (result == null) {\r | |
1294 | return fpdModuleMap;\r | |
1295 | }\r | |
1296 | \r | |
1297 | for (int i = 0; i < result.length; i++) {\r | |
1298 | //\r | |
1299 | // Get Fpd SA Module element node and add to ObjectMap.\r | |
1300 | //\r | |
1301 | Map<String, XmlObject> ObjectMap = new HashMap<String, XmlObject>();\r | |
1302 | ModuleSADocument.ModuleSA moduleSA = (ModuleSADocument.ModuleSA) result[i];\r | |
1303 | if (((ModuleSADocument.ModuleSA) result[i]).getLibraries() != null) {\r | |
1304 | ObjectMap.put("Libraries", moduleSA.getLibraries());\r | |
1305 | }\r | |
1306 | if (((ModuleSADocument.ModuleSA) result[i]).getPcdBuildDefinition() != null) {\r | |
1307 | ObjectMap.put("PcdBuildDefinition", moduleSA\r | |
1308 | .getPcdBuildDefinition());\r | |
1309 | }\r | |
1310 | if (((ModuleSADocument.ModuleSA) result[i])\r | |
1311 | .getModuleSaBuildOptions() != null) {\r | |
1312 | ObjectMap.put("ModuleSaBuildOptions", moduleSA\r | |
1313 | .getModuleSaBuildOptions());\r | |
1314 | }\r | |
1315 | \r | |
1316 | //\r | |
1317 | // Get Fpd SA Module attribute and create FpdMoudleIdentification.\r | |
1318 | //\r | |
1319 | if (moduleSA.getSupArchList() != null) {\r | |
1320 | arch = moduleSA.getSupArchList().toString();\r | |
1321 | }\r | |
1322 | \r | |
1323 | // TBD\r | |
1324 | fvBinding = null;\r | |
1325 | saVersion = ((ModuleSADocument.ModuleSA) result[i])\r | |
1326 | .getModuleVersion();\r | |
1327 | \r | |
1328 | saGuid = moduleSA.getModuleGuid();\r | |
1329 | pkgGuid = moduleSA.getPackageGuid();\r | |
1330 | pkgVersion = moduleSA.getPackageVersion();\r | |
1331 | \r | |
1332 | //\r | |
1333 | // Create Module Identification which have class member of package\r | |
1334 | // identification.\r | |
1335 | //\r | |
1336 | PackageIdentification pkgId = new PackageIdentification(null,\r | |
1337 | pkgGuid, pkgVersion);\r | |
1338 | ModuleIdentification saId = new ModuleIdentification(null, saGuid,\r | |
1339 | saVersion);\r | |
1340 | \r | |
1341 | saId.setPackage(pkgId);\r | |
1342 | \r | |
1343 | //\r | |
1344 | // Create FpdModule Identification which have class member of module\r | |
1345 | // identification\r | |
1346 | //\r | |
1347 | String[] archList = new String[0];\r | |
1348 | if (arch == null || arch.trim().length() == 0) {\r | |
1349 | archList = GlobalData.getToolChainInfo().getArchs();\r | |
1350 | }\r | |
1351 | else{\r | |
1352 | archList = arch.split(" ");\r | |
1353 | }\r | |
1354 | for (int j = 0; j < archList.length; j++) {\r | |
1355 | FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId, archList[j]);\r | |
1356 | \r | |
1357 | if (fvBinding != null) {\r | |
1358 | fpdSaId.setFvBinding(fvBinding);\r | |
1359 | }\r | |
1360 | \r | |
1361 | //\r | |
1362 | // Put element to Map<FpdModuleIdentification, Map<String,\r | |
1363 | // Object>>.\r | |
1364 | //\r | |
1365 | fpdModuleMap.put(fpdSaId, ObjectMap);\r | |
1366 | }\r | |
1367 | }\r | |
1368 | return fpdModuleMap;\r | |
1369 | }\r | |
1370 | \r | |
1371 | /**\r | |
1372 | * Retrieve valid image names\r | |
1373 | * \r | |
1374 | * @returns valid iamges name list if elements are found at the known xpath\r | |
1375 | * @returns empty list if nothing is there\r | |
1376 | */\r | |
1377 | public static String[] getFpdValidImageNames() {\r | |
1378 | String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };\r | |
1379 | \r | |
1380 | Object[] queryResult = get("PlatformSurfaceArea", xPath);\r | |
1381 | if (queryResult == null) {\r | |
1382 | return new String[0];\r | |
1383 | }\r | |
1384 | \r | |
1385 | String[] result = new String[queryResult.length];\r | |
1386 | for (int i = 0; i < queryResult.length; i++) {\r | |
1387 | result[i] = ((XmlString) queryResult[i]).getStringValue();\r | |
1388 | }\r | |
1389 | \r | |
1390 | return result;\r | |
1391 | }\r | |
1392 | \r | |
1393 | public static Node getFpdUserExtensionPreBuild() {\r | |
1394 | String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" }; \r | |
1395 | \r | |
1396 | Object[] queryResult = get("PlatformSurfaceArea", xPath);\r | |
1397 | if (queryResult == null || queryResult.length == 0) {\r | |
1398 | return null;\r | |
1399 | }\r | |
1400 | UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0];\r | |
1401 | \r | |
1402 | return a.getDomNode();\r | |
1403 | }\r | |
1404 | \r | |
1405 | public static Node getFpdUserExtensionPostBuild() {\r | |
1406 | String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" }; \r | |
1407 | \r | |
1408 | Object[] queryResult = get("PlatformSurfaceArea", xPath);\r | |
1409 | if (queryResult == null || queryResult.length == 0) {\r | |
1410 | return null;\r | |
1411 | }\r | |
1412 | UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0];\r | |
1413 | \r | |
1414 | return a.getDomNode();\r | |
1415 | }\r | |
1416 | \r | |
1417 | /**\r | |
1418 | * Retrieve FV image option information\r | |
1419 | * \r | |
1420 | * @param fvName\r | |
1421 | * FV image name\r | |
1422 | * \r | |
1423 | * @returns option name/value list if elements are found at the known xpath\r | |
1424 | * @returns empty list if nothing is there\r | |
1425 | */\r | |
1426 | public static String[][] getFpdOptions(String fvName) {\r | |
1427 | String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"\r | |
1428 | + fvName.toUpperCase() + "']/FvImageOptions" };\r | |
1429 | Object[] queryResult = get("PlatformSurfaceArea", xPath);\r | |
1430 | if (queryResult == null) {\r | |
1431 | return new String[0][];\r | |
1432 | }\r | |
1433 | ArrayList<String[]> list = new ArrayList<String[]>();\r | |
1434 | for (int i = 0; i < queryResult.length; i++) {\r | |
1435 | FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r | |
1436 | List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item\r | |
1437 | .getNameValueList();\r | |
1438 | Iterator iter = namevalues.iterator();\r | |
1439 | while (iter.hasNext()) {\r | |
1440 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r | |
1441 | .next();\r | |
1442 | list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r | |
1443 | }\r | |
1444 | }\r | |
1445 | String[][] result = new String[list.size()][2];\r | |
1446 | for (int i = 0; i < list.size(); i++) {\r | |
1447 | result[i][0] = list.get(i)[0];\r | |
1448 | result[i][1] = list.get(i)[1];\r | |
1449 | }\r | |
1450 | return result;\r | |
1451 | \r | |
1452 | }\r | |
1453 | \r | |
1454 | public static XmlObject getFpdBuildOptions() {\r | |
1455 | String[] xPath = new String[] { "/BuildOptions" };\r | |
1456 | \r | |
1457 | Object[] queryResult = get("PlatformSurfaceArea", xPath);\r | |
1458 | \r | |
1459 | if (queryResult == null || queryResult.length == 0) {\r | |
1460 | return null;\r | |
1461 | }\r | |
1462 | return (XmlObject)queryResult[0];\r | |
1463 | }\r | |
1464 | \r | |
1465 | public static PlatformIdentification getFpdHeader() {\r | |
1466 | String[] xPath = new String[] { "/PlatformHeader" };\r | |
1467 | \r | |
1468 | Object[] returns = get("PlatformSurfaceArea", xPath);\r | |
1469 | \r | |
1470 | if (returns == null || returns.length == 0) {\r | |
1471 | return null;\r | |
1472 | }\r | |
1473 | PlatformHeaderDocument.PlatformHeader header = (PlatformHeaderDocument.PlatformHeader) returns[0];\r | |
1474 | \r | |
1475 | String name = header.getPlatformName();\r | |
1476 | \r | |
1477 | String guid = header.getGuidValue();\r | |
1478 | \r | |
1479 | String version = header.getVersion();\r | |
1480 | \r | |
1481 | return new PlatformIdentification(name, guid, version);\r | |
1482 | }\r | |
1483 | \r | |
1484 | /**\r | |
1485 | * Retrieve FV image attributes information\r | |
1486 | * \r | |
1487 | * @param fvName\r | |
1488 | * FV image name\r | |
1489 | * \r | |
1490 | * @returns attribute name/value list if elements are found at the known\r | |
1491 | * xpath\r | |
1492 | * @returns empty list if nothing is there\r | |
1493 | */\r | |
1494 | public static String[][] getFpdAttributes(String fvName) {\r | |
1495 | String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"\r | |
1496 | + fvName.toUpperCase() + "']/FvImageOptions" };\r | |
1497 | Object[] queryResult = get("PlatformSurfaceArea", xPath);\r | |
1498 | if (queryResult == null) {\r | |
1499 | return new String[0][];\r | |
1500 | }\r | |
1501 | ArrayList<String[]> list = new ArrayList<String[]>();\r | |
1502 | for (int i = 0; i < queryResult.length; i++) {\r | |
1503 | \r | |
1504 | FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r | |
1505 | List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item.getNameValueList();\r | |
1506 | Iterator iter = namevalues.iterator();\r | |
1507 | while (iter.hasNext()) {\r | |
1508 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r | |
1509 | .next();\r | |
1510 | list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r | |
1511 | }\r | |
1512 | }\r | |
1513 | String[][] result = new String[list.size()][2];\r | |
1514 | for (int i = 0; i < list.size(); i++) {\r | |
1515 | result[i][0] = list.get(i)[0];\r | |
1516 | result[i][1] = list.get(i)[1];\r | |
1517 | }\r | |
1518 | return result;\r | |
1519 | }\r | |
1520 | \r | |
1521 | /**\r | |
1522 | * Retrieve flash definition file name\r | |
1523 | * \r | |
1524 | * @returns file name if elements are found at the known xpath\r | |
1525 | * @returns null if nothing is there\r | |
1526 | */\r | |
1527 | public static String getFlashDefinitionFile() {\r | |
1528 | String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };\r | |
1529 | \r | |
1530 | Object[] queryResult = get("PlatformSurfaceArea", xPath);\r | |
1531 | if (queryResult == null || queryResult.length == 0) {\r | |
1532 | return null;\r | |
1533 | }\r | |
1534 | \r | |
1535 | FileNameConvention filename = (FileNameConvention) queryResult[queryResult.length - 1];\r | |
1536 | return filename.getStringValue();\r | |
1537 | }\r | |
1538 | \r | |
1539 | public static String[][] getFpdGlobalVariable() {\r | |
1540 | String[] xPath = new String[] { "/Flash/FvImages/NameValue" };\r | |
1541 | Object[] queryResult = get("PlatformSurfaceArea", xPath);\r | |
1542 | if (queryResult == null) {\r | |
1543 | return new String[0][];\r | |
1544 | }\r | |
1545 | \r | |
1546 | String[][] result = new String[queryResult.length][2];\r | |
1547 | \r | |
1548 | for (int i = 0; i < queryResult.length; i++) {\r | |
1549 | FvImagesDocument.FvImages.NameValue item = (FvImagesDocument.FvImages.NameValue)queryResult[i];\r | |
1550 | result[i][0] = item.getName();\r | |
1551 | result[i][1] = item.getValue();\r | |
1552 | }\r | |
1553 | return result; \r | |
1554 | }\r | |
1555 | \r | |
1556 | /**\r | |
1557 | * Retrieve FV image component options\r | |
1558 | * \r | |
1559 | * @param fvName\r | |
1560 | * FV image name\r | |
1561 | * \r | |
1562 | * @returns name/value pairs list if elements are found at the known xpath\r | |
1563 | * @returns empty list if nothing is there\r | |
1564 | */\r | |
1565 | public static String[][] getFpdComponents(String fvName) {\r | |
1566 | String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName.toUpperCase() + "']/FvImageOptions" };\r | |
1567 | Object[] queryResult = get("PlatformSurfaceArea", xPath);\r | |
1568 | if (queryResult == null) {\r | |
1569 | return new String[0][];\r | |
1570 | }\r | |
1571 | \r | |
1572 | ArrayList<String[]> list = new ArrayList<String[]>();\r | |
1573 | for (int i = 0; i < queryResult.length; i++) {\r | |
1574 | FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r | |
1575 | List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item.getNameValueList();\r | |
1576 | Iterator iter = namevalues.iterator();\r | |
1577 | while (iter.hasNext()) {\r | |
1578 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r | |
1579 | .next();\r | |
1580 | list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r | |
1581 | }\r | |
1582 | }\r | |
1583 | String[][] result = new String[list.size()][2];\r | |
1584 | for (int i = 0; i < list.size(); i++) {\r | |
1585 | result[i][0] = list.get(i)[0];\r | |
1586 | result[i][1] = list.get(i)[1];\r | |
1587 | }\r | |
1588 | return result; \r | |
1589 | }\r | |
1590 | \r | |
1591 | /**\r | |
1592 | * Retrieve PCD tokens\r | |
1593 | * \r | |
1594 | * @returns CName/ItemType pairs list if elements are found at the known\r | |
1595 | * xpath\r | |
1596 | * @returns null if nothing is there\r | |
1597 | */\r | |
1598 | public static String[][] getPcdTokenArray() {\r | |
1599 | String[] xPath = new String[] { "/PcdData" };\r | |
1600 | \r | |
1601 | Object[] returns = get("PCDs", xPath);\r | |
1602 | if (returns == null || returns.length == 0) {\r | |
1603 | return null;\r | |
1604 | }\r | |
1605 | \r | |
1606 | return null;\r | |
1607 | }\r | |
1608 | \r | |
1609 | /**\r | |
1610 | * Retrieve MAS header\r | |
1611 | * \r | |
1612 | * @return\r | |
1613 | * @return\r | |
1614 | */\r | |
1615 | public static ModuleIdentification getMsaHeader() {\r | |
1616 | String[] xPath = new String[] { "/" };\r | |
1617 | Object[] returns = get("MsaHeader", xPath);\r | |
1618 | \r | |
1619 | if (returns == null || returns.length == 0) {\r | |
1620 | return null;\r | |
1621 | }\r | |
1622 | \r | |
1623 | MsaHeader msaHeader = (MsaHeader) returns[0];\r | |
1624 | //\r | |
1625 | // Get BaseName, ModuleType, GuidValue, Version\r | |
1626 | // which in MsaHeader.\r | |
1627 | //\r | |
1628 | String name = msaHeader.getModuleName();\r | |
1629 | String moduleType = msaHeader.getModuleType().toString();\r | |
1630 | String guid = msaHeader.getGuidValue();\r | |
1631 | String version = msaHeader.getVersion();\r | |
1632 | \r | |
1633 | ModuleIdentification moduleId = new ModuleIdentification(name, guid,\r | |
1634 | version);\r | |
1635 | \r | |
1636 | moduleId.setModuleType(moduleType);\r | |
1637 | \r | |
1638 | return moduleId;\r | |
1639 | }\r | |
1640 | \r | |
1641 | /**\r | |
1642 | * Retrieve Extern Specification\r | |
1643 | * \r | |
1644 | * @param\r | |
1645 | * \r | |
1646 | * @return String[] If have specification element in the <extern> String[0]\r | |
1647 | * If no specification element in the <extern>\r | |
1648 | * \r | |
1649 | */\r | |
1650 | \r | |
1651 | public static String[] getExternSpecificaiton() {\r | |
1652 | String[] xPath = new String[] { "/Specification" };\r | |
1653 | \r | |
1654 | Object[] queryResult = get("Externs", xPath);\r | |
1655 | if (queryResult == null) {\r | |
1656 | return new String[0];\r | |
1657 | }\r | |
1658 | \r | |
1659 | String[] specificationList = new String[queryResult.length];\r | |
1660 | for (int i = 0; i < queryResult.length; i++) {\r | |
1661 | specificationList[i] = ((Sentence)queryResult[i])\r | |
1662 | .getStringValue();\r | |
1663 | }\r | |
1664 | return specificationList;\r | |
1665 | }\r | |
1666 | \r | |
1667 | /**\r | |
1668 | * Retreive MsaFile which in SPD\r | |
1669 | * \r | |
1670 | * @param\r | |
1671 | * @return String[][3] The string sequence is ModuleName, ModuleGuid,\r | |
1672 | * ModuleVersion, MsaFile String[0][] If no msafile in SPD\r | |
1673 | */\r | |
1674 | public static String[] getSpdMsaFile() {\r | |
1675 | String[] xPath = new String[] { "/MsaFiles" };\r | |
1676 | \r | |
1677 | Object[] returns = get("PackageSurfaceArea", xPath);\r | |
1678 | if (returns == null) {\r | |
1679 | return new String[0];\r | |
1680 | }\r | |
1681 | \r | |
1682 | List<String> filenameList = ((MsaFilesDocument.MsaFiles) returns[0])\r | |
1683 | .getFilenameList();\r | |
1684 | return filenameList.toArray(new String[filenameList.size()]);\r | |
1685 | }\r | |
1686 | \r | |
1687 | /**\r | |
1688 | * Reteive\r | |
1689 | */\r | |
1690 | public static Map<String, String[]> getSpdLibraryClasses() {\r | |
1691 | String[] xPath = new String[] { "/LibraryClassDeclarations/LibraryClass" };\r | |
1692 | \r | |
1693 | Object[] returns = get("PackageSurfaceArea", xPath);\r | |
1694 | \r | |
1695 | //\r | |
1696 | // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.\r | |
1697 | //\r | |
1698 | Map<String, String[]> libClassHeaderMap = new HashMap<String, String[]>();\r | |
1699 | \r | |
1700 | if (returns == null) {\r | |
1701 | return libClassHeaderMap;\r | |
1702 | }\r | |
1703 | \r | |
1704 | for (int i = 0; i < returns.length; i++) {\r | |
1705 | LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass library = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass) returns[i];\r | |
1706 | libClassHeaderMap.put(library.getName(), new String[] { library\r | |
1707 | .getIncludeHeader() });\r | |
1708 | }\r | |
1709 | return libClassHeaderMap;\r | |
1710 | }\r | |
1711 | \r | |
1712 | /**\r | |
1713 | * Reteive\r | |
1714 | */\r | |
1715 | public static Map<String, String> getSpdPackageHeaderFiles() {\r | |
1716 | String[] xPath = new String[] { "/PackageHeaders/IncludePkgHeader" };\r | |
1717 | \r | |
1718 | Object[] returns = get("PackageSurfaceArea", xPath);\r | |
1719 | \r | |
1720 | //\r | |
1721 | // Create Map, Key - ModuleType, String - PackageInclude Header file.\r | |
1722 | //\r | |
1723 | Map<String, String> packageIncludeMap = new HashMap<String, String>();\r | |
1724 | \r | |
1725 | if (returns == null) {\r | |
1726 | return packageIncludeMap;\r | |
1727 | }\r | |
1728 | \r | |
1729 | for (int i = 0; i < returns.length; i++) {\r | |
1730 | PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i];\r | |
1731 | packageIncludeMap.put(includeHeader.getModuleType().toString(),\r | |
1732 | includeHeader.getStringValue());\r | |
1733 | }\r | |
1734 | return packageIncludeMap;\r | |
1735 | }\r | |
1736 | \r | |
1737 | public static PackageIdentification getSpdHeader() {\r | |
1738 | String[] xPath = new String[] { "/SpdHeader" };\r | |
1739 | \r | |
1740 | Object[] returns = get("PackageSurfaceArea", xPath);\r | |
1741 | \r | |
1742 | if (returns == null || returns.length == 0) {\r | |
1743 | return null;\r | |
1744 | }\r | |
1745 | \r | |
1746 | SpdHeaderDocument.SpdHeader header = (SpdHeaderDocument.SpdHeader) returns[0];\r | |
1747 | \r | |
1748 | String name = header.getPackageName();\r | |
1749 | \r | |
1750 | String guid = header.getGuidValue();\r | |
1751 | \r | |
1752 | String version = header.getVersion();\r | |
1753 | \r | |
1754 | return new PackageIdentification(name, guid, version);\r | |
1755 | }\r | |
1756 | \r | |
1757 | /**\r | |
1758 | * Reteive\r | |
1759 | */\r | |
1760 | public static Map<String, String[]> getSpdGuid() {\r | |
1761 | String[] xPath = new String[] { "/GuidDeclarations/Entry" };\r | |
1762 | \r | |
1763 | Object[] returns = get("PackageSurfaceArea", xPath);\r | |
1764 | \r | |
1765 | //\r | |
1766 | // Create Map, Key - GuidName, String[] - C_NAME & GUID value.\r | |
1767 | //\r | |
1768 | Map<String, String[]> guidDeclMap = new HashMap<String, String[]>();\r | |
1769 | if (returns == null) {\r | |
1770 | return guidDeclMap;\r | |
1771 | }\r | |
1772 | \r | |
1773 | for (int i = 0; i < returns.length; i++) {\r | |
1774 | GuidDeclarationsDocument.GuidDeclarations.Entry entry = (GuidDeclarationsDocument.GuidDeclarations.Entry) returns[i];\r | |
1775 | String[] guidPair = new String[2];\r | |
1776 | guidPair[0] = entry.getCName();\r | |
1777 | guidPair[1] = entry.getGuidValue();\r | |
1778 | guidDeclMap.put(entry.getCName(), guidPair);\r | |
1779 | EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());\r | |
1780 | EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[0]);\r | |
1781 | EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[1]);\r | |
1782 | }\r | |
1783 | return guidDeclMap;\r | |
1784 | }\r | |
1785 | \r | |
1786 | /**\r | |
1787 | * Reteive\r | |
1788 | */\r | |
1789 | public static Map<String, String[]> getSpdProtocol() {\r | |
1790 | String[] xPath = new String[] { "/ProtocolDeclarations/Entry" };\r | |
1791 | \r | |
1792 | Object[] returns = get("PackageSurfaceArea", xPath);\r | |
1793 | \r | |
1794 | //\r | |
1795 | // Create Map, Key - protocolName, String[] - C_NAME & GUID value.\r | |
1796 | //\r | |
1797 | Map<String, String[]> protoclMap = new HashMap<String, String[]>();\r | |
1798 | \r | |
1799 | if (returns == null) {\r | |
1800 | return protoclMap;\r | |
1801 | }\r | |
1802 | \r | |
1803 | for (int i = 0; i < returns.length; i++) {\r | |
1804 | ProtocolDeclarationsDocument.ProtocolDeclarations.Entry entry = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) returns[i];\r | |
1805 | String[] protocolPair = new String[2];\r | |
1806 | \r | |
1807 | protocolPair[0] = entry.getCName();\r | |
1808 | protocolPair[1] = entry.getGuidValue();\r | |
1809 | protoclMap.put(entry.getCName(), protocolPair);\r | |
1810 | EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());\r | |
1811 | EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[0]);\r | |
1812 | EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[1]);\r | |
1813 | }\r | |
1814 | return protoclMap;\r | |
1815 | }\r | |
1816 | \r | |
1817 | /**\r | |
1818 | * getSpdPpi() Retrieve the SPD PPI Entry\r | |
1819 | * \r | |
1820 | * @param\r | |
1821 | * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI\r | |
1822 | * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI\r | |
1823 | * entry in SPD.\r | |
1824 | */\r | |
1825 | public static Map<String, String[]> getSpdPpi() {\r | |
1826 | String[] xPath = new String[] { "/PpiDeclarations/Entry" };\r | |
1827 | \r | |
1828 | Object[] returns = get("PackageSurfaceArea", xPath);\r | |
1829 | \r | |
1830 | //\r | |
1831 | // Create Map, Key - protocolName, String[] - C_NAME & GUID value.\r | |
1832 | //\r | |
1833 | Map<String, String[]> ppiMap = new HashMap<String, String[]>();\r | |
1834 | \r | |
1835 | if (returns == null) {\r | |
1836 | return ppiMap;\r | |
1837 | }\r | |
1838 | \r | |
1839 | for (int i = 0; i < returns.length; i++) {\r | |
1840 | PpiDeclarationsDocument.PpiDeclarations.Entry entry = (PpiDeclarationsDocument.PpiDeclarations.Entry) returns[i];\r | |
1841 | String[] ppiPair = new String[2];\r | |
1842 | ppiPair[0] = entry.getCName();\r | |
1843 | ppiPair[1] = entry.getGuidValue();\r | |
1844 | ppiMap.put(entry.getCName(), ppiPair);\r | |
1845 | }\r | |
1846 | return ppiMap;\r | |
1847 | }\r | |
1848 | \r | |
1849 | /**\r | |
1850 | * Retrieve module Guid string\r | |
1851 | * \r | |
1852 | * @returns GUILD string if elements are found at the known xpath\r | |
1853 | * @returns null if nothing is there\r | |
1854 | */\r | |
1855 | public static String getModuleGuid() {\r | |
1856 | String[] xPath = new String[] { "" };\r | |
1857 | \r | |
1858 | Object[] returns = get("MsaHeader", xPath);\r | |
1859 | if (returns != null && returns.length > 0) {\r | |
1860 | String guid = ((MsaHeaderDocument.MsaHeader) returns[0])\r | |
1861 | .getGuidValue();\r | |
1862 | return guid;\r | |
1863 | }\r | |
1864 | \r | |
1865 | return null;\r | |
1866 | }\r | |
1867 | \r | |
1868 | //\r | |
1869 | // For new Pcd\r | |
1870 | //\r | |
1871 | public static ModuleSADocument.ModuleSA[] getFpdModuleSAs() {\r | |
1872 | String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r | |
1873 | Object[] result = get("PlatformSurfaceArea", xPath);\r | |
1874 | if (result != null) {\r | |
1875 | return (ModuleSADocument.ModuleSA[]) result;\r | |
1876 | }\r | |
1877 | return new ModuleSADocument.ModuleSA[0];\r | |
1878 | \r | |
1879 | }\r | |
1880 | /**\r | |
1881 | Get name array of PCD in a module. In one module, token space\r | |
1882 | is same, and token name should not be conflicted.\r | |
1883 | \r | |
1884 | @return String[]\r | |
1885 | **/\r | |
1886 | public static String[] getModulePcdEntryNameArray() {\r | |
1887 | PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null;\r | |
1888 | String[] results;\r | |
1889 | int index;\r | |
1890 | String[] xPath = new String[] {"/PcdEntry"};\r | |
1891 | Object[] returns = get ("PcdCoded", xPath);\r | |
1892 | \r | |
1893 | if (returns == null) {\r | |
1894 | return new String[0];\r | |
1895 | }\r | |
1896 | \r | |
1897 | pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns;\r | |
1898 | results = new String[pcdEntries.length];\r | |
1899 | \r | |
1900 | for (index = 0; index < pcdEntries.length; index ++) {\r | |
1901 | results[index] = pcdEntries[index].getCName();\r | |
1902 | }\r | |
1903 | return results;\r | |
1904 | }\r | |
1905 | \r | |
1906 | /**\r | |
1907 | Search in a List for a given string\r | |
1908 | \r | |
1909 | @return boolean\r | |
1910 | **/\r | |
1911 | public static boolean contains(List list, String str) {\r | |
1912 | if (list == null || list.size()== 0) {\r | |
1913 | return true;\r | |
1914 | }\r | |
1915 | Iterator it = list.iterator();\r | |
1916 | while (it.hasNext()) {\r | |
1917 | String s = (String)it.next();\r | |
1918 | if (s.equalsIgnoreCase(str)) {\r | |
1919 | return true;\r | |
1920 | }\r | |
1921 | }\r | |
1922 | \r | |
1923 | return false;\r | |
1924 | }\r | |
1925 | \r | |
1926 | public static boolean isHaveTianoR8FlashMap(){\r | |
1927 | PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null;\r | |
1928 | String[] results;\r | |
1929 | int index;\r | |
1930 | String[] xPath = new String[] {"/"};\r | |
1931 | Object[] returns = get ("Externs", xPath);\r | |
1932 | \r | |
1933 | if (returns == null) {\r | |
1934 | return false;\r | |
1935 | }\r | |
1936 | \r | |
1937 | ExternsDocument.Externs ext = (ExternsDocument.Externs)returns[0];\r | |
1938 | \r | |
1939 | if (ext.getTianoR8FlashMapH()){\r | |
1940 | return true;\r | |
1941 | }else {\r | |
1942 | return false;\r | |
1943 | }\r | |
1944 | }\r | |
1945 | }\r |