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