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 org
.apache
.tools
.ant
.Task
;
21 import org
.apache
.tools
.ant
.Project
;
22 import org
.apache
.tools
.ant
.BuildException
;
23 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
24 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
25 import org
.apache
.tools
.ant
.types
.Commandline
;
27 import org
.tianocore
.common
.logger
.EdkLog
;
32 * FlashMapTask is used to call FlashMap.exe to generate flash map defition files and fd files.
34 public class FlashMapTask
extends Task
implements EfiDefine
{
38 private final String toolName
= "FlashMap";
41 // Flash definition file
43 private FileArg flashDefFile
= new FileArg();
48 private ToolArg flashDevice
= new ToolArg();
53 private ToolArg flashDeviceImage
= new ToolArg();
58 private FileArg mciFile
= new FileArg();
63 private FileArg mcoFile
= new FileArg();
68 private ToolArg fdImage
= new ToolArg();
73 private FileArg dscFile
= new FileArg();
78 private FileArg asmIncFile
= new FileArg();
83 private FileArg imageOutFile
= new FileArg();
88 private FileArg headerFile
= new FileArg();
93 private String inStrFile
= "";
98 private String outStrFile
= "";
103 private FileArg strFile
= new FileArg();
107 private ToolArg baseAddr
= new ToolArg();
112 private ToolArg aligment
= new ToolArg();
117 private ToolArg padValue
= new ToolArg();
122 private String outputDir
= ".";
127 FileArg mciFileArray
= new FileArg();
132 FlashMapTask execute function is to assemble tool command line & execute
135 @throws BuidException
137 public void execute() throws BuildException
{
139 Project project
= this.getOwningTarget().getProject();
141 // absolute path of efi tools
143 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
148 command
= path
+ File
.separator
+ toolName
;
152 // add substituted input file and output file
154 if (this.inStrFile
!= null && this.outStrFile
!= null
155 && this.inStrFile
.length() > 0 && this.outStrFile
.length() > 0) {
156 strFile
.setPrefix(" -strsub ");
157 strFile
.insValue(this.inStrFile
);
158 strFile
.insValue(this.outStrFile
);
161 String argument
= "" + flashDefFile
+ flashDevice
+ flashDeviceImage
162 + mciFile
+ mcoFile
+ fdImage
+ dscFile
+ asmIncFile
163 + imageOutFile
+ headerFile
+ strFile
+ baseAddr
164 + aligment
+ padValue
+ mciFileArray
;
170 // ProcessBuilder pb = new ProcessBuilder(argList);
171 // pb.directory(new File(outputDir));
174 Commandline cmdline
= new Commandline();
175 cmdline
.setExecutable(command
);
176 cmdline
.createArgument().setLine(argument
);
178 LogStreamHandler streamHandler
= new LogStreamHandler(this,
179 Project
.MSG_INFO
, Project
.MSG_WARN
);
180 Execute runner
= new Execute(streamHandler
, null);
182 runner
.setAntRun(project
);
183 runner
.setCommandline(cmdline
.getCommandline());
185 if (outputDir
!= null) {
186 runner
.setWorkingDirectory(new File(outputDir
));
189 // log command line string.
191 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
192 EdkLog
.log(this, flashDefFile
.toFileList()
193 + mciFile
.toFileList()
194 + mciFileArray
.toFileList()
195 + fdImage
.toFileList()
198 + headerFile
.toFileList()
199 + imageOutFile
.toFileList()
200 + mcoFile
.toFileList()
201 + dscFile
.toFileList()
202 + asmIncFile
.toFileList()
205 exitCode
= runner
.execute();
207 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(exitCode
));
209 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "FlashMap succeeded!");
211 } catch (Exception e
) {
212 throw new BuildException(e
.getMessage());
215 throw new BuildException("FlashMap failed!");
223 This function is to get class member "flashDefFile"
225 @return flashDeFile Name of flash definition file.
227 public String
getFlashDefFile() {
228 return this.flashDefFile
.getValue();
234 This function is to set class member "flashDefFile"
237 Name of flash definition file.
239 public void setFlashDefFile(String flashDefFile
) {
240 this.flashDefFile
.setArg(" -fdf ", flashDefFile
);
246 This function is to get class member "aligment"
248 @return aligment String of aligment value.
250 public String
getAligment() {
251 return this.aligment
.getValue();
257 This function is to set class member "aligment"
260 String of aligment value.
262 public void setAligment(String aligment
) {
263 this.aligment
.setArg(" -align ", aligment
);
269 This function is to get class member "asmIncFile"
271 @return asmIncFile String of ASM include file.
273 public String
getAsmIncFile() {
274 return this.asmIncFile
.getValue();
280 This function is to set class member "asmIncFile"
283 String of ASM include file.
285 public void setAsmIncFile(String asmIncFile
) {
286 this.asmIncFile
.setArg(" -asmincfile ", asmIncFile
);
292 This function is to get class member "baseAddr"
294 @return baseAddr String of base address value.
296 public String
getBaseAddr() {
297 return this.baseAddr
.getValue();
303 This function is to set class member "baseAddr"
306 String of base address value.
308 public void setBaseAddr(String baseAddr
) {
309 this.baseAddr
.setArg(" -baseaddr ", baseAddr
);
315 This function is to get class member "dscFile"
317 @return dscFile name of DSC file
319 public String
getDscFile() {
320 return this.dscFile
.getValue();
326 This function is to set class member "dscFile"
331 public void setDscFile(String dscFile
) {
332 this.dscFile
.setArg(" -dsc ", dscFile
);
338 This function is to get class member "fdImage"
340 @return fdImage name of input FDI image file.
342 public String
getFdImage() {
343 return this.fdImage
.getValue();
349 This function is to set class member "fdImage"
352 name of input FDI image file.
354 public void setFdImage(String fdImage
) {
355 this.fdImage
.setArg(" -discover ", fdImage
);
361 This function is to get class member "flashDevice".
363 @return flashDevice name of flash device.
365 public String
getFlashDevice() {
366 return this.flashDevice
.getValue();
372 This function is to set class member "flashDevice"
375 name of flash device.
377 public void setFlashDevice(String flashDevice
) {
378 this.flashDevice
.setArg(" -flashdevice ", flashDevice
);
384 This function is to get class member "flashDeviceImage"
386 @return flashDeviceImage name of flash device image
388 public String
getFlashDeviceImage() {
389 return this.flashDeviceImage
.getValue();
395 This function is to set class member "flashDeviceImage"
397 @param flashDeviceImage
398 name of flash device image
400 public void setFlashDeviceImage(String flashDeviceImage
) {
401 this.flashDeviceImage
.setArg(" -flashdeviceimage ", flashDeviceImage
);
408 This function is to get class member "headerFile"
410 @return headerFile name of include file
412 public String
getHeaderFile() {
413 return this.headerFile
.getValue();
419 This function is to set class member "headerFile"
424 public void setHeaderFile(String headerFile
) {
425 this.headerFile
.setArg(" -hfile ", headerFile
);
431 This function is to get class member "imageOutFile"
433 @return imageOutFile name of output image file
435 public String
getImageOutFile() {
436 return this.imageOutFile
.getValue();
442 This function is to set class member "ImageOutFile"
445 name of output image file
447 public void setImageOutFile(String imageOutFile
) {
448 this.imageOutFile
.setArg(" -imageout ", imageOutFile
);
454 This function is to get class member "inStrFile"
456 @return inStrFile name of input file which used to replace symbol names.
458 public String
getInStrFile() {
459 return this.inStrFile
;
465 This function is to set class member "inStrFile"
468 name of input file which used to replace symbol names.
470 public void setInStrFile(String inStrFile
) {
471 this.inStrFile
= inStrFile
;
477 This function is to get class member "mciFile"
479 @return mciFile name of input microcode file
481 public String
getMciFile() {
482 return this.mciFile
.getValue();
488 This function is to set class member "mciFile"
491 name of input microcode file
493 public void setMciFile(String mciFile
) {
494 this.mciFile
.setArg(" -mci ", mciFile
);
500 This function is to get class member "mcoFile"
502 @return mcoFile name of output binary microcode image
504 public String
getMcoFile() {
505 return this.mcoFile
.getValue();
511 This function is to set class member "mcoFile"
514 name of output binary microcode image
516 public void setMcoFile(String mcoFile
) {
517 this.mcoFile
.setArg(" -mco ", mcoFile
);
523 This function is to get class member "outStrFile"
525 @return outStrFile name of output string substitution file
527 public String
getOutStrFile() {
528 return this.outStrFile
;
534 This function is to set class member "outStrFile"
537 name of output string substitution file
539 public void setOutStrFile(String outStrFile
) {
540 this.outStrFile
= outStrFile
;
546 This function is to get class member "padValue"
548 @return padValue string of byte value to use as padding
550 public String
getPadValue() {
551 return this.padValue
.getValue();
557 This function is to set class member "padValue"
560 string of byte value to use as padding
562 public void setPadValue(String padValue
) {
563 this.padValue
.setArg(" -padvalue ", padValue
);
569 This function is to add Microcode binary file
572 instance of input class
574 public void addConfiguredMciFile(FileArg mciFile
) {
575 this.mciFileArray
.setPrefix(" -mcmerge ");
576 this.mciFileArray
.insert(mciFile
);
582 This function is to get class member "outputDir"
584 @return outputDir string of output directory
586 public String
getOutputDir() {
593 This function is to set class member "outputDir"
596 string of output directory
598 public void setOutputDir(String outputDir
) {
599 this.outputDir
= outputDir
;