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
.tianocore
.logger
.EdkLog
;
34 * FlashMapTask is used to call FlashMap.exe to generate flash map defition files and fd files.
36 public class FlashMapTask
extends Task
implements EfiDefine
{
40 private final String toolName
= "FlashMap";
43 // / Flash definition file
45 private String flashDefFile
= "";
50 private String flashDevice
= "";
53 // / Flash device Image
55 private String flashDeviceImage
= "";
60 private String mciFile
= "";
65 private String mcoFile
= "";
68 // / Discover FD image
70 private String fdImage
= "";
75 private String dscFile
= "";
80 private String asmIncFile
= "";
85 private String imageOutFile
= "";
90 private String headerFile
= "";
93 // / Input string file
95 private String inStrFile
= "";
98 // / Output string file
100 private String outStrFile
= "";
105 private String baseAddr
= "";
110 private String aligment
= "";
115 private String padValue
= "";
118 // / output directory
120 private String outputDir
= "";
125 List
<Input
> mciFileArray
= new ArrayList
<Input
>();
128 // / command and argument list
130 LinkedList
<String
> argList
= new LinkedList
<String
>();
135 * FlashMapTask execute function is to assemble tool command line & execute
138 * @throws BuidException
140 public void execute() throws BuildException
{
142 Project project
= this.getOwningTarget().getProject();
146 FrameworkLogger logger
= new FrameworkLogger(project
, "flashmap");
147 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
148 EdkLog
.setLogger(logger
);
150 // absolute path of efi tools
152 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
157 command
= path
+ File
.separatorChar
+ toolName
;
159 argList
.addFirst(command
);
162 // add substituted input file and output file
164 if (this.inStrFile
!= null && this.outStrFile
!= null
165 && !this.inStrFile
.equalsIgnoreCase("")
166 && !this.inStrFile
.equalsIgnoreCase("")) {
167 argList
.add("-strsub");
168 argList
.add(this.inStrFile
);
169 argList
.add(this.outStrFile
);
174 // add microcode binary files
176 if (mciFileArray
.size() > 0) {
177 argList
.add("-mcmerge");
178 Iterator mciList
= mciFileArray
.iterator();
179 while (mciList
.hasNext()) {
180 argList
.add(((Input
) mciList
.next()).getFile());
187 ProcessBuilder pb
= new ProcessBuilder(argList
);
188 pb
.directory(new File(outputDir
));
191 Process cmdProc
= pb
.start();
192 InputStreamReader cmdOut
= new InputStreamReader(cmdProc
194 char[] buf
= new char[1024];
196 exitCode
= cmdProc
.waitFor();
198 // log command line string.
200 EdkLog
.log(EdkLog
.EDK_VERBOSE
, cmdProc
.getOutputStream().toString());
201 EdkLog
.log(EdkLog
.EDK_INFO
, (new File(this.flashDefFile
)).getName());
203 int len
= cmdOut
.read(buf
, 0, 1024);
204 EdkLog
.log(EdkLog
.EDK_INFO
, new String(buf
, 0, len
));
206 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "FlashMap succeeded!");
208 } catch (Exception e
) {
209 throw new BuildException(e
.getMessage());
212 throw new BuildException("FlashMap failed!");
220 * This function is to get class member "flashDefFile"
222 * @return flashDeFile Name of flash definition file.
224 public String
getFlashDefFile() {
231 * This function is to set class member "flashDefFile"
233 * @param flashDefFile
234 * Name of flash definition file.
236 public void setFlashDefFile(String flashDefFile
) {
237 this.flashDefFile
= flashDefFile
;
239 argList
.add(this.flashDefFile
);
245 * This function is to get class member "aligment"
247 * @return aligment String of aligment value.
249 public String
getAligment() {
256 * This function is to set class member "aligment"
259 * String of aligment value.
261 public void setAligment(String aligment
) {
262 this.aligment
= aligment
;
263 argList
.add("-align");
264 argList
.add(this.aligment
);
270 * This function is to get class member "asmIncFile"
272 * @return asmIncFile String of ASM include file.
274 public String
getAsmIncFile() {
281 * This function is to set class member "asmIncFile"
284 * String of ASM include file.
286 public void setAsmIncFile(String asmIncFile
) {
287 this.asmIncFile
= asmIncFile
;
288 argList
.add("-asmincfile");
289 argList
.add(this.asmIncFile
);
295 * This function is to get class member "baseAddr"
297 * @return baseAddr String of base address value.
299 public String
getBaseAddr() {
306 * This function is to set class member "baseAddr"
309 * String of base address value.
311 public void setBaseAddr(String baseAddr
) {
312 this.baseAddr
= baseAddr
;
313 argList
.add("-baseaddr");
314 argList
.add(this.baseAddr
);
320 * This function is to get class member "dscFile"
322 * @return dscFile name of DSC file
324 public String
getDscFile() {
331 * This function is to set class member "dscFile"
336 public void setDscFile(String dscFile
) {
337 this.dscFile
= dscFile
;
339 argList
.add(this.dscFile
);
345 * This function is to get class member "fdImage"
347 * @return fdImage name of input FDI image file.
349 public String
getFdImage() {
356 * This function is to set class member "fdImage"
359 * name of input FDI image file.
361 public void setFdImage(String fdImage
) {
362 this.fdImage
= fdImage
;
363 argList
.add("-discover");
364 argList
.add(this.fdImage
);
370 * This function is to get class member "flashDevice".
372 * @return flashDevice name of flash device.
374 public String
getFlashDevice() {
381 * This function is to set class member "flashDevice"
384 * name of flash device.
386 public void setFlashDevice(String flashDevice
) {
387 this.flashDevice
= flashDevice
;
388 argList
.add("-flashdevice");
389 argList
.add(this.flashDevice
);
393 * getFlashDeviceImage
395 * This function is to get class member "flashDeviceImage"
397 * @return flashDeviceImage name of flash device image
399 public String
getFlashDeviceImage() {
400 return flashDeviceImage
;
404 * setFlashDeviceImage
406 * This function is to set class member "flashDeviceImage"
408 * @param flashDeviceImage
409 * name of flash device image
411 public void setFlashDeviceImage(String flashDeviceImage
) {
412 this.flashDeviceImage
= flashDeviceImage
;
413 argList
.add("-flashdeviceimage");
414 argList
.add(this.flashDeviceImage
);
421 * This function is to get class member "headerFile"
423 * @return headerFile name of include file
425 public String
getHeaderFile() {
432 * This function is to set class member "headerFile"
435 * name of include file
437 public void setHeaderFile(String headerFile
) {
438 this.headerFile
= headerFile
;
439 argList
.add("-hfile");
440 argList
.add(this.headerFile
);
446 * This function is to get class member "imageOutFile"
448 * @return imageOutFile name of output image file
450 public String
getImageOutFile() {
457 * This function is to set class member "ImageOutFile"
459 * @param imageOutFile
460 * name of output image file
462 public void setImageOutFile(String imageOutFile
) {
463 this.imageOutFile
= imageOutFile
;
464 argList
.add("-imageout");
465 argList
.add(this.imageOutFile
);
471 * This function is to get class member "inStrFile"
473 * @return inStrFile name of input file which used to replace symbol names.
475 public String
getInStrFile() {
482 * This function is to set class member "inStrFile"
485 * name of input file which used to replace symbol names.
487 public void setInStrFile(String inStrFile
) {
488 this.inStrFile
= inStrFile
;
494 * This function is to get class member "mciFile"
496 * @return mciFile name of input microcode file
498 public String
getMciFile() {
505 * This function is to set class member "mciFile"
508 * name of input microcode file
510 public void setMciFile(String mciFile
) {
511 this.mciFile
= mciFile
;
513 argList
.add(this.mciFile
);
519 * This function is to get class member "mcoFile"
521 * @return mcoFile name of output binary microcode image
523 public String
getMcoFile() {
530 * This function is to set class member "mcoFile"
533 * name of output binary microcode image
535 public void setMcoFile(String mcoFile
) {
536 this.mcoFile
= mcoFile
;
538 argList
.add(this.mcoFile
);
544 * This function is to get class member "outStrFile"
546 * @return outStrFile name of output string substitution file
548 public String
getOutStrFile() {
555 * This function is to set class member "outStrFile"
558 * name of output string substitution file
560 public void setOutStrFile(String outStrFile
) {
561 this.outStrFile
= outStrFile
;
567 * This function is to get class member "padValue"
569 * @return padValue string of byte value to use as padding
571 public String
getPadValue() {
578 * This function is to set class member "padValue"
581 * string of byte value to use as padding
583 public void setPadValue(String padValue
) {
584 this.padValue
= padValue
;
585 argList
.add("-padvalue");
586 argList
.add(this.padValue
);
592 * This function is to add Microcode binary file
595 * instance of input class
597 public void addMciFile(Input mciFile
) {
598 this.mciFileArray
.add(mciFile
);
604 * This function is to get class member "outputDir"
606 * @return outputDir string of output directory
608 public String
getOutputDir() {
615 * This function is to set class member "outputDir"
618 * string of output directory
620 public void setOutputDir(String outputDir
) {
621 this.outputDir
= outputDir
;