]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java
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 * SecFixupTask is used to call SecFixup.exe to fix up sec image.
36 public class FlashMapTask
extends Task
implements EfiDefine
{
40 private final String toolName
= "FlashMap";
43 // / Flash default 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());
184 EdkLog
.log(EdkLog
.EDK_INFO
, argList
.toString().replace(",",""));
188 ProcessBuilder pb
= new ProcessBuilder(argList
);
189 pb
.directory(new File(outputDir
));
192 Process cmdProc
= pb
.start();
193 InputStreamReader cmdOut
= new InputStreamReader(cmdProc
195 char[] buf
= new char[1024];
197 exitCode
= cmdProc
.waitFor();
199 // log command line string.
201 EdkLog
.log(EdkLog
.EDK_INFO
, cmdProc
.getOutputStream().toString());
203 int len
= cmdOut
.read(buf
, 0, 1024);
204 EdkLog
.log(EdkLog
.EDK_ERROR
, new String(buf
, 0, len
));
206 EdkLog
.log(EdkLog
.EDK_INFO
, "FlashMap succeed!");
208 } catch (Exception e
) {
209 throw new BuildException(e
.getMessage());
212 // throw new BuildException("GenFvImage: failed to generate FV
221 * This function is to get class member "flashDefFile"
223 * @return flashDeFile Name of flash definition file.
225 public String
getFlashDefFile() {
232 * This function is to set class member "flashDefFile"
234 * @param flashDefFile
235 * Name of flash definition file.
237 public void setFlashDefFile(String flashDefFile
) {
238 this.flashDefFile
= flashDefFile
;
240 argList
.add(this.flashDefFile
);
246 * This function is to get class member "aligment"
248 * @return aligment String of aligment value.
250 public String
getAligment() {
257 * This function is to set class member "aligment"
260 * String of aligment value.
262 public void setAligment(String aligment
) {
263 this.aligment
= aligment
;
264 argList
.add("-align");
265 argList
.add(this.aligment
);
271 * This function is to get class member "asmIncFile"
273 * @return asmIncFile String of ASM include file.
275 public String
getAsmIncFile() {
282 * This function is to set class member "asmIncFile"
285 * String of ASM include file.
287 public void setAsmIncFile(String asmIncFile
) {
288 this.asmIncFile
= asmIncFile
;
289 argList
.add("-asmincfile");
290 argList
.add(this.asmIncFile
);
296 * This function is to get class member "baseAddr"
298 * @return baseAddr String of base address value.
300 public String
getBaseAddr() {
307 * This function is to set class member "baseAddr"
310 * String of base address value.
312 public void setBaseAddr(String baseAddr
) {
313 this.baseAddr
= baseAddr
;
314 argList
.add("-baseaddr");
315 argList
.add(this.baseAddr
);
321 * This function is to get class member "dscFile"
323 * @return dscFile name of DSC file
325 public String
getDscFile() {
332 * This function is to set class member "dscFile"
337 public void setDscFile(String dscFile
) {
338 this.dscFile
= dscFile
;
340 argList
.add(this.dscFile
);
346 * This function is to get class member "fdImage"
348 * @return fdImage name of input FDI image file.
350 public String
getFdImage() {
357 * This function is to set class member "fdImage"
360 * name of input FDI image file.
362 public void setFdImage(String fdImage
) {
363 this.fdImage
= fdImage
;
364 argList
.add("-discover");
365 argList
.add(this.fdImage
);
371 * This function is to get class member "flashDevice".
373 * @return flashDevice name of flash device.
375 public String
getFlashDevice() {
382 * This function is to set class member "flashDevice"
385 * name of flash device.
387 public void setFlashDevice(String flashDevice
) {
388 this.flashDevice
= flashDevice
;
389 argList
.add("-flashdevice");
390 argList
.add(this.flashDevice
);
394 * getFlashDeviceImage
396 * This function is to get class member "flashDeviceImage"
398 * @return flashDeviceImage name of flash device image
400 public String
getFlashDeviceImage() {
401 return flashDeviceImage
;
405 * setFlashDeviceImage
407 * This function is to set class member "flashDeviceImage"
409 * @param flashDeviceImage
410 * name of flash device image
412 public void setFlashDeviceImage(String flashDeviceImage
) {
413 this.flashDeviceImage
= flashDeviceImage
;
414 argList
.add("-flashdeviceimage");
415 argList
.add(this.flashDeviceImage
);
422 * This function is to get class member "headerFile"
424 * @return headerFile name of include file
426 public String
getHeaderFile() {
433 * This function is to set class member "headerFile"
436 * name of include file
438 public void setHeaderFile(String headerFile
) {
439 this.headerFile
= headerFile
;
440 argList
.add("-hfile");
441 argList
.add(this.headerFile
);
447 * This function is to get class member "imageOutFile"
449 * @return imageOutFile name of output image file
451 public String
getImageOutFile() {
458 * This function is to set class member "ImageOutFile"
460 * @param imageOutFile
461 * name of output image file
463 public void setImageOutFile(String imageOutFile
) {
464 this.imageOutFile
= imageOutFile
;
465 argList
.add("-imageout");
466 argList
.add(this.imageOutFile
);
472 * This function is to get class member "inStrFile"
474 * @return inStrFile name of input file which used to replace symbol names.
476 public String
getInStrFile() {
483 * This function is to set class member "inStrFile"
486 * name of input file which used to replace symbol names.
488 public void setInStrFile(String inStrFile
) {
489 this.inStrFile
= inStrFile
;
495 * This function is to get class member "mciFile"
497 * @return mciFile name of input microcode file
499 public String
getMciFile() {
506 * This function is to set class member "mciFile"
509 * name of input microcode file
511 public void setMciFile(String mciFile
) {
512 this.mciFile
= mciFile
;
514 argList
.add(this.mciFile
);
520 * This function is to get class member "mcoFile"
522 * @return mcoFile name of output binary microcode image
524 public String
getMcoFile() {
531 * This function is to set class member "mcoFile"
534 * name of output binary microcode image
536 public void setMcoFile(String mcoFile
) {
537 this.mcoFile
= mcoFile
;
539 argList
.add(this.mcoFile
);
545 * This function is to get class member "outStrFile"
547 * @return outStrFile name of output string substitution file
549 public String
getOutStrFile() {
556 * This function is to set class member "outStrFile"
559 * name of output string substitution file
561 public void setOutStrFile(String outStrFile
) {
562 this.outStrFile
= outStrFile
;
568 * This function is to get class member "padValue"
570 * @return padValue string of byte value to use as padding
572 public String
getPadValue() {
579 * This function is to set class member "padValue"
582 * string of byte value to use as padding
584 public void setPadValue(String padValue
) {
585 this.padValue
= padValue
;
586 argList
.add("-padvalue");
587 argList
.add(this.padValue
);
593 * This function is to add Microcode binary file
596 * instance of input class
598 public void addMciFile(Input mciFile
) {
599 this.mciFileArray
.add(mciFile
);
605 * This function is to get class member "outputDir"
607 * @return outputDir string of output directory
609 public String
getOutputDir() {
616 * This function is to set class member "outputDir"
619 * string of output directory
621 public void setOutputDir(String outputDir
) {
622 this.outputDir
= outputDir
;