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