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