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