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