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