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
.io
.InputStreamReader
;
21 import java
.util
.ArrayList
;
22 import java
.util
.Iterator
;
23 import java
.util
.LinkedList
;
24 import java
.util
.List
;
26 import org
.apache
.tools
.ant
.BuildException
;
27 import org
.apache
.tools
.ant
.Project
;
28 import org
.apache
.tools
.ant
.Task
;
29 import org
.tianocore
.common
.logger
.EdkLog
;
30 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
31 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
32 import org
.apache
.tools
.ant
.types
.Commandline
;
34 import com
.sun
.org
.apache
.bcel
.internal
.generic
.NEW
;
39 SecFixupTask is used to call SecFixup.exe to fix up sec image.
41 public class EfiRomTask
extends Task
implements EfiDefine
{
45 private final static String toolName
= "EfiRom";
50 private ToolArg verbose
= new ToolArg();
55 private ToolArg venderId
= new ToolArg();
60 private ToolArg deviceId
= new ToolArg();
65 private FileArg outputFile
= new FileArg();
70 private Input binaryFileList
= new Input();
73 // Efi PE32 image file
75 private Input pe32FileList
= new Input();
78 // Compress efi PE32 image file
80 private Input pe32ComprFileList
= new Input();
83 // Hex class code in the PCI data strutor header
85 private ToolArg classCode
= new ToolArg();
88 // Hex revision in the PCI data header.
90 private ToolArg revision
= new ToolArg();
93 // Dump the headers of an existing option rom image.
95 private ToolArg dump
= new ToolArg();
100 private String outputDir
= ".";
103 // command and argument list
105 LinkedList
<String
> argList
= new LinkedList
<String
>();
110 EfiRomTask execute function is to assemble tool command line & execute
113 @throws BuidException
115 public void execute() throws BuildException
{
117 Project project
= this.getOwningTarget().getProject();
120 // absolute path of efi tools
122 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
127 command
= path
+ File
.separator
+ toolName
;
130 String argument
= "" + verbose
+ venderId
+ deviceId
+ dump
+ revision
+ classCode
131 + binaryFileList
.toStringWithSinglepPrefix(" -b ")
132 + pe32FileList
.toStringWithSinglepPrefix(" -e ")
133 + pe32ComprFileList
.toStringWithSinglepPrefix(" -ec ")
137 Commandline cmdline
= new Commandline();
138 cmdline
.setExecutable(command
);
139 cmdline
.createArgument().setLine(argument
);
141 LogStreamHandler streamHandler
= new LogStreamHandler(this,
142 Project
.MSG_INFO
, Project
.MSG_WARN
);
143 Execute runner
= new Execute(streamHandler
, null);
145 runner
.setAntRun(project
);
146 runner
.setCommandline(cmdline
.getCommandline());
147 runner
.setWorkingDirectory(new File(outputDir
));
149 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
150 EdkLog
.log(this, EdkLog
.EDK_INFO
, binaryFileList
.toFileList()
151 + pe32FileList
.toFileList() + pe32ComprFileList
.toFileList()
152 + " => " + outputFile
.toFileList());
154 int exitCode
= runner
.execute();
157 // command execution fail
159 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(exitCode
));
160 throw new BuildException(toolName
+ " failed!");
162 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, toolName
+ " succeeded!");
164 } catch (Exception e
) {
165 throw new BuildException(e
.getMessage());
172 This function is to get class member "verbose"
174 @return verbose for verbose output.
176 public String
getVerbose() {
177 return verbose
.getValue();
183 This function is to set class member "verbose"
185 @param verbose for verbose output.
187 public void setVerbose(boolean verbose
) {
189 this.verbose
.setArg(" -", "p");
196 This function is to get class member "venderId"
198 @return venderId String of venderId.
200 public String
getVenderId() {
201 return venderId
.getValue();
207 This function is to set class member "venderId"
209 @param venderId String of venderId.
211 public void setVenderId(String venderId
) {
212 this.venderId
.setArg(" -v ", venderId
);
218 This function is to get class member "deviceId"
220 @return deviceId String of device ID.
222 public String
getDeviceId() {
223 return this.deviceId
.getValue();
229 This function is to set class member "deviceId"
231 @param deviceId String of device ID.
233 public void setDeviceId(String deviceId
) {
234 this.deviceId
.setArg(" -d ", deviceId
);
241 This function is to get class member "outputFile"
243 @return outputFile name of output directory.
245 public String
getOutputFile() {
246 return outputFile
.getValue();
252 This function is to set class member "dscFile"
254 @param outputFile name of DSC file
256 public void setOutputFile(String outputFile
) {
257 this.outputFile
.setArg(" -o ", outputFile
);
263 This function is to get class member "classCode"
265 @return fdImage name of class code file.
267 public String
getClassCode() {
268 return classCode
.getValue();
274 This function is to set class member "classCode"
276 @param fdImage name of class code file.
278 public void setclassCode(String classCode
) {
279 this.classCode
.setArg(" -cc ", classCode
);
285 This function is to get class member "revision".
287 @return revision hex revision in the PDI data header.
289 public String
getRevision() {
290 return revision
.getValue();
296 This function is to set class member "revision"
298 @param revision hex revision in the PDI data header.
300 public void setRevision(String revision
) {
301 this.revision
.setArg(" -rev ", revision
);
307 This function is to get class member "dump"
309 @return flashDeviceImage name of flash device image
311 public String
getDump() {
312 return dump
.getValue();
318 This function is to set class member "dump"
320 @param flashDeviceImage name of flash device image
322 public void setDump(boolean dump
) {
324 this.dump
.setArg(" -", "dump");
331 This function is to get class member "outputDir"
333 @return outputDir string of output directory
335 public String
getOutputDir() {
342 This function is to set class member "outputDir"
344 @param outputDir string of output directory
346 public void setOutputDir(String outputDir
) {
347 this.outputDir
= outputDir
;
353 This function is to add binary file to binaryFile list.
355 @param binaryFile name of binary file.
357 public void addConfiguredBinaryFile(Input binaryFile
){
358 this.binaryFileList
.insert(binaryFile
);
364 This function is to add pe32 file to pe32File list.
366 @param pe32File name of pe32 file.
368 public void addConfiguredPe32File(Input pe32File
){
369 this.pe32FileList
.insert(pe32File
);
375 This function os to add compressed pe32 file to pe32ComprFile list.
377 @param pe32ComprFile name of compressed pe32 file.
379 public void addConfiguredPe32ComprFile(Input pe32ComprFile
){
380 this.pe32ComprFileList
.insert(pe32ComprFile
);