4 EfiRomTask is used to call FlashMap.exe to lay out the flash.
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
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.
17 package org
.tianocore
.framework
.tasks
;
20 import java
.util
.LinkedList
;
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
;
33 SecFixupTask is used to call SecFixup.exe to fix up sec image.
35 public class EfiRomTask
extends Task
implements EfiDefine
{
39 private final static String toolName
= "EfiRom";
44 private ToolArg verbose
= new ToolArg();
49 private ToolArg venderId
= new ToolArg();
54 private ToolArg deviceId
= new ToolArg();
59 private FileArg outputFile
= new FileArg();
64 private Input binaryFileList
= new Input();
67 // Efi PE32 image file
69 private Input pe32FileList
= new Input();
72 // Compress efi PE32 image file
74 private Input pe32ComprFileList
= new Input();
77 // Hex class code in the PCI data strutor header
79 private ToolArg classCode
= new ToolArg();
82 // Hex revision in the PCI data header.
84 private ToolArg revision
= new ToolArg();
87 // Dump the headers of an existing option rom image.
89 private ToolArg dump
= new ToolArg();
94 private String outputDir
= ".";
97 // command and argument list
99 LinkedList
<String
> argList
= new LinkedList
<String
>();
104 EfiRomTask execute function is to assemble tool command line & execute
107 @throws BuidException
109 public void execute() throws BuildException
{
111 Project project
= this.getOwningTarget().getProject();
114 // absolute path of efi tools
116 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
121 command
= path
+ File
.separator
+ toolName
;
124 String argument
= "" + verbose
+ venderId
+ deviceId
+ dump
+ revision
+ classCode
125 + binaryFileList
.toStringWithSinglepPrefix(" -b ")
126 + pe32FileList
.toStringWithSinglepPrefix(" -e ")
127 + pe32ComprFileList
.toStringWithSinglepPrefix(" -ec ")
131 Commandline cmdline
= new Commandline();
132 cmdline
.setExecutable(command
);
133 cmdline
.createArgument().setLine(argument
);
135 LogStreamHandler streamHandler
= new LogStreamHandler(this,
136 Project
.MSG_INFO
, Project
.MSG_WARN
);
137 Execute runner
= new Execute(streamHandler
, null);
139 runner
.setAntRun(project
);
140 runner
.setCommandline(cmdline
.getCommandline());
141 runner
.setWorkingDirectory(new File(outputDir
));
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());
148 int exitCode
= runner
.execute();
151 // command execution fail
153 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(exitCode
));
154 throw new BuildException(toolName
+ " failed!");
156 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, toolName
+ " succeeded!");
158 } catch (Exception e
) {
159 throw new BuildException(e
.getMessage());
166 This function is to get class member "verbose"
168 @return verbose for verbose output.
170 public String
getVerbose() {
171 return verbose
.getValue();
177 This function is to set class member "verbose"
179 @param verbose for verbose output.
181 public void setVerbose(boolean verbose
) {
183 this.verbose
.setArg(" -", "p");
190 This function is to get class member "venderId"
192 @return venderId String of venderId.
194 public String
getVenderId() {
195 return venderId
.getValue();
201 This function is to set class member "venderId"
203 @param venderId String of venderId.
205 public void setVenderId(String venderId
) {
206 this.venderId
.setArg(" -v ", venderId
);
212 This function is to get class member "deviceId"
214 @return deviceId String of device ID.
216 public String
getDeviceId() {
217 return this.deviceId
.getValue();
223 This function is to set class member "deviceId"
225 @param deviceId String of device ID.
227 public void setDeviceId(String deviceId
) {
228 this.deviceId
.setArg(" -d ", deviceId
);
235 This function is to get class member "outputFile"
237 @return outputFile name of output directory.
239 public String
getOutputFile() {
240 return outputFile
.getValue();
246 This function is to set class member "dscFile"
248 @param outputFile name of DSC file
250 public void setOutputFile(String outputFile
) {
251 this.outputFile
.setArg(" -o ", outputFile
);
257 This function is to get class member "classCode"
259 @return fdImage name of class code file.
261 public String
getClassCode() {
262 return classCode
.getValue();
268 This function is to set class member "classCode"
270 @param fdImage name of class code file.
272 public void setclassCode(String classCode
) {
273 this.classCode
.setArg(" -cc ", classCode
);
279 This function is to get class member "revision".
281 @return revision hex revision in the PDI data header.
283 public String
getRevision() {
284 return revision
.getValue();
290 This function is to set class member "revision"
292 @param revision hex revision in the PDI data header.
294 public void setRevision(String revision
) {
295 this.revision
.setArg(" -rev ", revision
);
301 This function is to get class member "dump"
303 @return flashDeviceImage name of flash device image
305 public String
getDump() {
306 return dump
.getValue();
312 This function is to set class member "dump"
314 @param flashDeviceImage name of flash device image
316 public void setDump(boolean dump
) {
318 this.dump
.setArg(" -", "dump");
325 This function is to get class member "outputDir"
327 @return outputDir string of output directory
329 public String
getOutputDir() {
336 This function is to set class member "outputDir"
338 @param outputDir string of output directory
340 public void setOutputDir(String outputDir
) {
341 this.outputDir
= outputDir
;
347 This function is to add binary file to binaryFile list.
349 @param binaryFile name of binary file.
351 public void addConfiguredBinaryFile(Input binaryFile
){
352 this.binaryFileList
.insert(binaryFile
);
358 This function is to add pe32 file to pe32File list.
360 @param pe32File name of pe32 file.
362 public void addConfiguredPe32File(Input pe32File
){
363 this.pe32FileList
.insert(pe32File
);
369 This function os to add compressed pe32 file to pe32ComprFile list.
371 @param pe32ComprFile name of compressed pe32 file.
373 public void addConfiguredPe32ComprFile(Input pe32ComprFile
){
374 this.pe32ComprFileList
.insert(pe32ComprFile
);