4 FlashMapTask 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
.Task
;
27 import org
.apache
.tools
.ant
.Project
;
28 import org
.apache
.tools
.ant
.BuildException
;
29 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
30 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
31 import org
.apache
.tools
.ant
.types
.Commandline
;
33 import org
.tianocore
.common
.logger
.EdkLog
;
38 * FlashMapTask is used to call FlashMap.exe to generate flash map defition files and fd files.
40 public class FlashMapTask
extends Task
implements EfiDefine
{
44 private final String toolName
= "FlashMap";
47 // Flash definition file
49 private FileArg flashDefFile
= new FileArg();
54 private ToolArg flashDevice
= new ToolArg();
59 private ToolArg flashDeviceImage
= new ToolArg();
64 private FileArg mciFile
= new FileArg();
69 private FileArg mcoFile
= new FileArg();
74 private ToolArg fdImage
= new ToolArg();
79 private FileArg dscFile
= new FileArg();
84 private FileArg asmIncFile
= new FileArg();
89 private FileArg imageOutFile
= new FileArg();
94 private FileArg headerFile
= new FileArg();
99 private String inStrFile
= "";
102 // Output string file
104 private String outStrFile
= "";
109 private FileArg strFile
= new FileArg();
113 private ToolArg baseAddr
= new ToolArg();
118 private ToolArg aligment
= new ToolArg();
123 private ToolArg padValue
= new ToolArg();
128 private String outputDir
= ".";
133 FileArg mciFileArray
= new FileArg();
138 FlashMapTask execute function is to assemble tool command line & execute
141 @throws BuidException
143 public void execute() throws BuildException
{
145 Project project
= this.getOwningTarget().getProject();
147 // absolute path of efi tools
149 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
154 command
= path
+ File
.separator
+ toolName
;
158 // add substituted input file and output file
160 if (this.inStrFile
!= null && this.outStrFile
!= null
161 && this.inStrFile
.length() > 0 && this.outStrFile
.length() > 0) {
162 strFile
.setPrefix(" -strsub ");
163 strFile
.insValue(this.inStrFile
);
164 strFile
.insValue(this.outStrFile
);
167 String argument
= "" + flashDefFile
+ flashDevice
+ flashDeviceImage
168 + mciFile
+ mcoFile
+ fdImage
+ dscFile
+ asmIncFile
169 + imageOutFile
+ headerFile
+ strFile
+ baseAddr
170 + aligment
+ padValue
+ mciFileArray
;
176 // ProcessBuilder pb = new ProcessBuilder(argList);
177 // pb.directory(new File(outputDir));
180 Commandline cmdline
= new Commandline();
181 cmdline
.setExecutable(command
);
182 cmdline
.createArgument().setLine(argument
);
184 LogStreamHandler streamHandler
= new LogStreamHandler(this,
185 Project
.MSG_INFO
, Project
.MSG_WARN
);
186 Execute runner
= new Execute(streamHandler
, null);
188 runner
.setAntRun(project
);
189 runner
.setCommandline(cmdline
.getCommandline());
191 if (outputDir
!= null) {
192 runner
.setWorkingDirectory(new File(outputDir
));
195 // log command line string.
197 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
198 EdkLog
.log(this, flashDefFile
.toFileList()
199 + mciFile
.toFileList()
200 + mciFileArray
.toFileList()
201 + fdImage
.toFileList()
204 + headerFile
.toFileList()
205 + imageOutFile
.toFileList()
206 + mcoFile
.toFileList()
207 + dscFile
.toFileList()
208 + asmIncFile
.toFileList()
211 exitCode
= runner
.execute();
213 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(exitCode
));
215 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "FlashMap succeeded!");
217 } catch (Exception e
) {
218 throw new BuildException(e
.getMessage());
221 throw new BuildException("FlashMap failed!");
229 This function is to get class member "flashDefFile"
231 @return flashDeFile Name of flash definition file.
233 public String
getFlashDefFile() {
234 return this.flashDefFile
.getValue();
240 This function is to set class member "flashDefFile"
243 Name of flash definition file.
245 public void setFlashDefFile(String flashDefFile
) {
246 this.flashDefFile
.setArg(" -fdf ", flashDefFile
);
252 This function is to get class member "aligment"
254 @return aligment String of aligment value.
256 public String
getAligment() {
257 return this.aligment
.getValue();
263 This function is to set class member "aligment"
266 String of aligment value.
268 public void setAligment(String aligment
) {
269 this.aligment
.setArg(" -align ", aligment
);
275 This function is to get class member "asmIncFile"
277 @return asmIncFile String of ASM include file.
279 public String
getAsmIncFile() {
280 return this.asmIncFile
.getValue();
286 This function is to set class member "asmIncFile"
289 String of ASM include file.
291 public void setAsmIncFile(String asmIncFile
) {
292 this.asmIncFile
.setArg(" -asmincfile ", asmIncFile
);
298 This function is to get class member "baseAddr"
300 @return baseAddr String of base address value.
302 public String
getBaseAddr() {
303 return this.baseAddr
.getValue();
309 This function is to set class member "baseAddr"
312 String of base address value.
314 public void setBaseAddr(String baseAddr
) {
315 this.baseAddr
.setArg(" -baseaddr ", baseAddr
);
321 This function is to get class member "dscFile"
323 @return dscFile name of DSC file
325 public String
getDscFile() {
326 return this.dscFile
.getValue();
332 This function is to set class member "dscFile"
337 public void setDscFile(String dscFile
) {
338 this.dscFile
.setArg(" -dsc ", dscFile
);
344 This function is to get class member "fdImage"
346 @return fdImage name of input FDI image file.
348 public String
getFdImage() {
349 return this.fdImage
.getValue();
355 This function is to set class member "fdImage"
358 name of input FDI image file.
360 public void setFdImage(String fdImage
) {
361 this.fdImage
.setArg(" -discover ", fdImage
);
367 This function is to get class member "flashDevice".
369 @return flashDevice name of flash device.
371 public String
getFlashDevice() {
372 return this.flashDevice
.getValue();
378 This function is to set class member "flashDevice"
381 name of flash device.
383 public void setFlashDevice(String flashDevice
) {
384 this.flashDevice
.setArg(" -flashdevice ", flashDevice
);
390 This function is to get class member "flashDeviceImage"
392 @return flashDeviceImage name of flash device image
394 public String
getFlashDeviceImage() {
395 return this.flashDeviceImage
.getValue();
401 This function is to set class member "flashDeviceImage"
403 @param flashDeviceImage
404 name of flash device image
406 public void setFlashDeviceImage(String flashDeviceImage
) {
407 this.flashDeviceImage
.setArg(" -flashdeviceimage ", flashDeviceImage
);
414 This function is to get class member "headerFile"
416 @return headerFile name of include file
418 public String
getHeaderFile() {
419 return this.headerFile
.getValue();
425 This function is to set class member "headerFile"
430 public void setHeaderFile(String headerFile
) {
431 this.headerFile
.setArg(" -hfile ", headerFile
);
437 This function is to get class member "imageOutFile"
439 @return imageOutFile name of output image file
441 public String
getImageOutFile() {
442 return this.imageOutFile
.getValue();
448 This function is to set class member "ImageOutFile"
451 name of output image file
453 public void setImageOutFile(String imageOutFile
) {
454 this.imageOutFile
.setArg(" -imageout ", imageOutFile
);
460 This function is to get class member "inStrFile"
462 @return inStrFile name of input file which used to replace symbol names.
464 public String
getInStrFile() {
465 return this.inStrFile
;
471 This function is to set class member "inStrFile"
474 name of input file which used to replace symbol names.
476 public void setInStrFile(String inStrFile
) {
477 this.inStrFile
= inStrFile
;
483 This function is to get class member "mciFile"
485 @return mciFile name of input microcode file
487 public String
getMciFile() {
488 return this.mciFile
.getValue();
494 This function is to set class member "mciFile"
497 name of input microcode file
499 public void setMciFile(String mciFile
) {
500 this.mciFile
.setArg(" -mci ", mciFile
);
506 This function is to get class member "mcoFile"
508 @return mcoFile name of output binary microcode image
510 public String
getMcoFile() {
511 return this.mcoFile
.getValue();
517 This function is to set class member "mcoFile"
520 name of output binary microcode image
522 public void setMcoFile(String mcoFile
) {
523 this.mcoFile
.setArg(" -mco ", mcoFile
);
529 This function is to get class member "outStrFile"
531 @return outStrFile name of output string substitution file
533 public String
getOutStrFile() {
534 return this.outStrFile
;
540 This function is to set class member "outStrFile"
543 name of output string substitution file
545 public void setOutStrFile(String outStrFile
) {
546 this.outStrFile
= outStrFile
;
552 This function is to get class member "padValue"
554 @return padValue string of byte value to use as padding
556 public String
getPadValue() {
557 return this.padValue
.getValue();
563 This function is to set class member "padValue"
566 string of byte value to use as padding
568 public void setPadValue(String padValue
) {
569 this.padValue
.setArg(" -padvalue ", padValue
);
575 This function is to add Microcode binary file
578 instance of input class
580 public void addConfiguredMciFile(FileArg mciFile
) {
581 this.mciFileArray
.setPrefix(" -mcmerge ");
582 this.mciFileArray
.insert(mciFile
);
588 This function is to get class member "outputDir"
590 @return outputDir string of output directory
592 public String
getOutputDir() {
599 This function is to set class member "outputDir"
602 string of output directory
604 public void setOutputDir(String outputDir
) {
605 this.outputDir
= outputDir
;