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