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