]>
Commit | Line | Data |
---|---|---|
a15bb0d3 | 1 | /** @file\r |
2 | EfiRomTask class.\r | |
3 | \r | |
4 | EfiRomTask is used to call FlashMap.exe to lay out the flash.\r | |
ff225cbb | 5 | \r |
6 | \r | |
a15bb0d3 | 7 | Copyright (c) 2006, Intel Corporation\r |
8 | All rights reserved. This program and the accompanying materials\r | |
9 | are licensed and made available under the terms and conditions of the BSD License\r | |
10 | which accompanies this distribution. The full text of the license may be found at\r | |
11 | http://opensource.org/licenses/bsd-license.php\r | |
ff225cbb | 12 | \r |
a15bb0d3 | 13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
15 | \r | |
16 | **/\r | |
17 | package org.tianocore.framework.tasks;\r | |
18 | \r | |
19 | import java.io.File;\r | |
a15bb0d3 | 20 | import java.util.LinkedList;\r |
a15bb0d3 | 21 | \r |
a15bb0d3 | 22 | import org.apache.tools.ant.BuildException;\r |
0fdb42ac | 23 | import org.apache.tools.ant.Project;\r |
24 | import org.apache.tools.ant.Task;\r | |
ff225cbb | 25 | import org.tianocore.common.logger.EdkLog;\r |
0fdb42ac | 26 | import org.apache.tools.ant.taskdefs.Execute;\r |
27 | import org.apache.tools.ant.taskdefs.LogStreamHandler;\r | |
28 | import org.apache.tools.ant.types.Commandline;\r | |
29 | \r | |
a15bb0d3 | 30 | /**\r |
0fdb42ac | 31 | SecFixupTask class.\r |
32 | \r | |
33 | SecFixupTask is used to call SecFixup.exe to fix up sec image.\r | |
34 | **/\r | |
a15bb0d3 | 35 | public class EfiRomTask extends Task implements EfiDefine {\r |
0fdb42ac | 36 | //\r |
37 | // tool name\r | |
38 | //\r | |
39 | private final static String toolName = "EfiRom";\r | |
40 | \r | |
41 | //\r | |
42 | // Flash default file\r | |
43 | //\r | |
44 | private ToolArg verbose = new ToolArg();\r | |
45 | \r | |
46 | //\r | |
47 | // Flash device\r | |
48 | //\r | |
49 | private ToolArg venderId = new ToolArg();\r | |
50 | \r | |
51 | //\r | |
52 | // Flash device Image\r | |
53 | //\r | |
54 | private ToolArg deviceId = new ToolArg();\r | |
55 | \r | |
56 | //\r | |
57 | // output file\r | |
58 | //\r | |
59 | private FileArg outputFile = new FileArg();\r | |
60 | \r | |
61 | //\r | |
62 | // binary file\r | |
63 | //\r | |
64 | private Input binaryFileList = new Input();\r | |
65 | \r | |
66 | //\r | |
67 | // Efi PE32 image file\r | |
68 | //\r | |
69 | private Input pe32FileList = new Input();\r | |
70 | \r | |
71 | //\r | |
72 | // Compress efi PE32 image file\r | |
73 | //\r | |
74 | private Input pe32ComprFileList = new Input();\r | |
75 | \r | |
76 | //\r | |
77 | // Hex class code in the PCI data strutor header\r | |
78 | //\r | |
79 | private ToolArg classCode = new ToolArg();\r | |
80 | \r | |
81 | //\r | |
82 | // Hex revision in the PCI data header.\r | |
83 | //\r | |
84 | private ToolArg revision = new ToolArg();\r | |
85 | \r | |
86 | //\r | |
87 | // Dump the headers of an existing option rom image.\r | |
88 | //\r | |
89 | private ToolArg dump = new ToolArg();\r | |
90 | \r | |
91 | //\r | |
92 | // output directory\r | |
93 | //\r | |
57cc2ee7 | 94 | private String outputDir = ".";\r |
ff225cbb | 95 | \r |
0fdb42ac | 96 | //\r |
97 | // command and argument list\r | |
98 | //\r | |
a15bb0d3 | 99 | LinkedList<String> argList = new LinkedList<String>();\r |
0fdb42ac | 100 | \r |
a15bb0d3 | 101 | /**\r |
0fdb42ac | 102 | execute\r |
103 | \r | |
104 | EfiRomTask execute function is to assemble tool command line & execute\r | |
105 | tool command line\r | |
106 | \r | |
107 | @throws BuidException\r | |
108 | **/\r | |
a15bb0d3 | 109 | public void execute() throws BuildException {\r |
110 | \r | |
111 | Project project = this.getOwningTarget().getProject();\r | |
91f7d582 | 112 | \r |
a15bb0d3 | 113 | //\r |
114 | // absolute path of efi tools\r | |
115 | //\r | |
116 | String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r | |
117 | String command;\r | |
118 | if (path == null) {\r | |
119 | command = toolName;\r | |
120 | } else {\r | |
0fdb42ac | 121 | command = path + File.separator + toolName;\r |
a15bb0d3 | 122 | }\r |
ff225cbb | 123 | \r |
0fdb42ac | 124 | String argument = "" + verbose + venderId + deviceId + dump + revision + classCode \r |
125 | + binaryFileList.toStringWithSinglepPrefix(" -b ")\r | |
126 | + pe32FileList.toStringWithSinglepPrefix(" -e ")\r | |
127 | + pe32ComprFileList.toStringWithSinglepPrefix(" -ec ")\r | |
128 | + outputFile;\r | |
ff225cbb | 129 | \r |
0fdb42ac | 130 | try {\r |
131 | Commandline cmdline = new Commandline();\r | |
132 | cmdline.setExecutable(command);\r | |
133 | cmdline.createArgument().setLine(argument);\r | |
ff225cbb | 134 | \r |
0fdb42ac | 135 | LogStreamHandler streamHandler = new LogStreamHandler(this,\r |
136 | Project.MSG_INFO, Project.MSG_WARN);\r | |
137 | Execute runner = new Execute(streamHandler, null);\r | |
219e2247 | 138 | \r |
0fdb42ac | 139 | runner.setAntRun(project);\r |
140 | runner.setCommandline(cmdline.getCommandline());\r | |
141 | runner.setWorkingDirectory(new File(outputDir));\r | |
219e2247 | 142 | \r |
0fdb42ac | 143 | EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r |
144 | EdkLog.log(this, EdkLog.EDK_INFO, binaryFileList.toFileList() \r | |
145 | + pe32FileList.toFileList() + pe32ComprFileList.toFileList()\r | |
146 | + " => " + outputFile.toFileList());\r | |
a15bb0d3 | 147 | \r |
0fdb42ac | 148 | int exitCode = runner.execute();\r |
a15bb0d3 | 149 | if (exitCode != 0) {\r |
0fdb42ac | 150 | //\r |
151 | // command execution fail\r | |
152 | //\r | |
153 | EdkLog.log(this, "ERROR = " + Integer.toHexString(exitCode));\r | |
154 | throw new BuildException(toolName + " failed!");\r | |
a15bb0d3 | 155 | } else {\r |
0fdb42ac | 156 | EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r |
a15bb0d3 | 157 | }\r |
158 | } catch (Exception e) {\r | |
159 | throw new BuildException(e.getMessage());\r | |
a15bb0d3 | 160 | }\r |
161 | }\r | |
ff225cbb | 162 | \r |
a15bb0d3 | 163 | /**\r |
0fdb42ac | 164 | getVerbose\r |
165 | \r | |
166 | This function is to get class member "verbose"\r | |
167 | \r | |
168 | @return verbose for verbose output.\r | |
169 | **/\r | |
a15bb0d3 | 170 | public String getVerbose() {\r |
0fdb42ac | 171 | return verbose.getValue();\r |
a15bb0d3 | 172 | }\r |
ff225cbb | 173 | \r |
a15bb0d3 | 174 | /**\r |
0fdb42ac | 175 | setVerbose\r |
176 | \r | |
177 | This function is to set class member "verbose"\r | |
178 | \r | |
179 | @param verbose for verbose output.\r | |
180 | **/\r | |
a15bb0d3 | 181 | public void setVerbose(boolean verbose) {\r |
182 | if (verbose){\r | |
0fdb42ac | 183 | this.verbose.setArg(" -", "p");\r |
a15bb0d3 | 184 | }\r |
185 | }\r | |
ff225cbb | 186 | \r |
a15bb0d3 | 187 | /**\r |
0fdb42ac | 188 | getVenderId\r |
189 | \r | |
190 | This function is to get class member "venderId"\r | |
191 | \r | |
192 | @return venderId String of venderId.\r | |
193 | **/\r | |
a15bb0d3 | 194 | public String getVenderId() {\r |
0fdb42ac | 195 | return venderId.getValue();\r |
a15bb0d3 | 196 | }\r |
ff225cbb | 197 | \r |
a15bb0d3 | 198 | /**\r |
0fdb42ac | 199 | setVenderId\r |
200 | \r | |
201 | This function is to set class member "venderId"\r | |
202 | \r | |
203 | @param venderId String of venderId.\r | |
204 | **/\r | |
205 | public void setVenderId(String venderId) {\r | |
206 | this.venderId.setArg(" -v ", venderId);\r | |
a15bb0d3 | 207 | }\r |
ff225cbb | 208 | \r |
a15bb0d3 | 209 | /**\r |
0fdb42ac | 210 | getDeviceId\r |
211 | \r | |
212 | This function is to get class member "deviceId"\r | |
213 | \r | |
214 | @return deviceId String of device ID.\r | |
215 | **/\r | |
a15bb0d3 | 216 | public String getDeviceId() {\r |
0fdb42ac | 217 | return this.deviceId.getValue();\r |
a15bb0d3 | 218 | }\r |
ff225cbb | 219 | \r |
a15bb0d3 | 220 | /**\r |
0fdb42ac | 221 | setDeviceId\r |
222 | \r | |
223 | This function is to set class member "deviceId"\r | |
224 | \r | |
225 | @param deviceId String of device ID.\r | |
226 | **/\r | |
a15bb0d3 | 227 | public void setDeviceId(String deviceId) {\r |
0fdb42ac | 228 | this.deviceId.setArg(" -d ", deviceId);\r |
a15bb0d3 | 229 | }\r |
230 | \r | |
ff225cbb | 231 | \r |
a15bb0d3 | 232 | /**\r |
0fdb42ac | 233 | getOutputFile\r |
234 | \r | |
235 | This function is to get class member "outputFile"\r | |
236 | \r | |
237 | @return outputFile name of output directory.\r | |
238 | **/\r | |
a15bb0d3 | 239 | public String getOutputFile() {\r |
0fdb42ac | 240 | return outputFile.getValue();\r |
a15bb0d3 | 241 | }\r |
ff225cbb | 242 | \r |
a15bb0d3 | 243 | /**\r |
0fdb42ac | 244 | setOutputFile\r |
245 | \r | |
246 | This function is to set class member "dscFile"\r | |
247 | \r | |
248 | @param outputFile name of DSC file\r | |
249 | **/\r | |
a15bb0d3 | 250 | public void setOutputFile(String outputFile) {\r |
0fdb42ac | 251 | this.outputFile.setArg(" -o ", outputFile);\r |
a15bb0d3 | 252 | }\r |
ff225cbb | 253 | \r |
a15bb0d3 | 254 | /**\r |
0fdb42ac | 255 | getClassCode\r |
256 | \r | |
257 | This function is to get class member "classCode"\r | |
258 | \r | |
259 | @return fdImage name of class code file.\r | |
260 | **/\r | |
a15bb0d3 | 261 | public String getClassCode() {\r |
0fdb42ac | 262 | return classCode.getValue();\r |
a15bb0d3 | 263 | }\r |
ff225cbb | 264 | \r |
a15bb0d3 | 265 | /**\r |
0fdb42ac | 266 | setclassCode\r |
267 | \r | |
268 | This function is to set class member "classCode"\r | |
269 | \r | |
270 | @param fdImage name of class code file.\r | |
271 | **/\r | |
a15bb0d3 | 272 | public void setclassCode(String classCode) {\r |
0fdb42ac | 273 | this.classCode.setArg(" -cc ", classCode);\r |
a15bb0d3 | 274 | }\r |
ff225cbb | 275 | \r |
a15bb0d3 | 276 | /**\r |
0fdb42ac | 277 | getRevision\r |
278 | \r | |
279 | This function is to get class member "revision".\r | |
280 | \r | |
281 | @return revision hex revision in the PDI data header.\r | |
282 | **/\r | |
a15bb0d3 | 283 | public String getRevision() {\r |
0fdb42ac | 284 | return revision.getValue();\r |
a15bb0d3 | 285 | }\r |
ff225cbb | 286 | \r |
a15bb0d3 | 287 | /**\r |
0fdb42ac | 288 | setRevision\r |
289 | \r | |
290 | This function is to set class member "revision"\r | |
291 | \r | |
292 | @param revision hex revision in the PDI data header.\r | |
293 | **/\r | |
a15bb0d3 | 294 | public void setRevision(String revision) {\r |
0fdb42ac | 295 | this.revision.setArg(" -rev ", revision);\r |
a15bb0d3 | 296 | }\r |
ff225cbb | 297 | \r |
a15bb0d3 | 298 | /**\r |
0fdb42ac | 299 | getFlashDeviceImage\r |
300 | \r | |
301 | This function is to get class member "dump"\r | |
302 | \r | |
303 | @return flashDeviceImage name of flash device image\r | |
304 | **/\r | |
a15bb0d3 | 305 | public String getDump() {\r |
0fdb42ac | 306 | return dump.getValue();\r |
a15bb0d3 | 307 | }\r |
ff225cbb | 308 | \r |
a15bb0d3 | 309 | /**\r |
0fdb42ac | 310 | setFlashDeviceImage\r |
311 | \r | |
312 | This function is to set class member "dump"\r | |
313 | \r | |
314 | @param flashDeviceImage name of flash device image\r | |
315 | **/\r | |
a15bb0d3 | 316 | public void setDump(boolean dump) {\r |
0fdb42ac | 317 | if (dump) {\r |
318 | this.dump.setArg(" -", "dump");\r | |
a15bb0d3 | 319 | }\r |
320 | }\r | |
321 | \r | |
322 | /**\r | |
0fdb42ac | 323 | getOutputDir\r |
324 | \r | |
325 | This function is to get class member "outputDir"\r | |
326 | \r | |
327 | @return outputDir string of output directory\r | |
328 | **/\r | |
a15bb0d3 | 329 | public String getOutputDir() {\r |
330 | return outputDir;\r | |
331 | }\r | |
ff225cbb | 332 | \r |
a15bb0d3 | 333 | /**\r |
0fdb42ac | 334 | setOutputDir\r |
335 | \r | |
336 | This function is to set class member "outputDir"\r | |
337 | \r | |
338 | @param outputDir string of output directory\r | |
339 | **/\r | |
a15bb0d3 | 340 | public void setOutputDir(String outputDir) {\r |
341 | this.outputDir = outputDir;\r | |
342 | }\r | |
0fdb42ac | 343 | \r |
a15bb0d3 | 344 | /**\r |
0fdb42ac | 345 | addBinaryFile\r |
346 | \r | |
347 | This function is to add binary file to binaryFile list.\r | |
348 | \r | |
349 | @param binaryFile name of binary file.\r | |
350 | **/\r | |
351 | public void addConfiguredBinaryFile(Input binaryFile){\r | |
352 | this.binaryFileList.insert(binaryFile);\r | |
a15bb0d3 | 353 | }\r |
ff225cbb | 354 | \r |
a15bb0d3 | 355 | /**\r |
0fdb42ac | 356 | addPe32File\r |
357 | \r | |
358 | This function is to add pe32 file to pe32File list.\r | |
359 | \r | |
360 | @param pe32File name of pe32 file.\r | |
361 | **/\r | |
362 | public void addConfiguredPe32File(Input pe32File){\r | |
363 | this.pe32FileList.insert(pe32File);\r | |
a15bb0d3 | 364 | }\r |
ff225cbb | 365 | \r |
a15bb0d3 | 366 | /**\r |
0fdb42ac | 367 | addPe32ComprFile\r |
368 | \r | |
369 | This function os to add compressed pe32 file to pe32ComprFile list.\r | |
370 | \r | |
371 | @param pe32ComprFile name of compressed pe32 file.\r | |
372 | **/\r | |
373 | public void addConfiguredPe32ComprFile(Input pe32ComprFile){\r | |
374 | this.pe32ComprFileList.insert(pe32ComprFile);\r | |
a15bb0d3 | 375 | }\r |
376 | }\r |