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