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