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