]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java
ce0939f4b15a8844850dfd16f22e90d66f9f10ef
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
;
30 import org
.tianocore
.common
.logger
.EdkLog
;
35 * FlashMapTask is used to call FlashMap.exe to generate flash map defition files and fd files.
37 public class FlashMapTask
extends Task
implements EfiDefine
{
41 private final String toolName
= "FlashMap";
44 // / Flash definition file
46 private String flashDefFile
= "";
51 private String flashDevice
= "";
54 // / Flash device Image
56 private String flashDeviceImage
= "";
61 private String mciFile
= "";
66 private String mcoFile
= "";
69 // / Discover FD image
71 private String fdImage
= "";
76 private String dscFile
= "";
81 private String asmIncFile
= "";
86 private String imageOutFile
= "";
91 private String headerFile
= "";
94 // / Input string file
96 private String inStrFile
= "";
99 // / Output string file
101 private String outStrFile
= "";
106 private String baseAddr
= "";
111 private String aligment
= "";
116 private String padValue
= "";
119 // / output directory
121 private String outputDir
= ".";
126 List
<Input
> mciFileArray
= new ArrayList
<Input
>();
129 // / command and argument list
131 LinkedList
<String
> argList
= new LinkedList
<String
>();
136 * FlashMapTask execute function is to assemble tool command line & execute
139 * @throws BuidException
141 public void execute() throws BuildException
{
143 Project project
= this.getOwningTarget().getProject();
147 FrameworkLogger logger
= new FrameworkLogger(project
, "flashmap");
148 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
149 EdkLog
.setLogger(logger
);
151 // absolute path of efi tools
153 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
158 command
= path
+ File
.separatorChar
+ toolName
;
160 argList
.addFirst(command
);
163 // add substituted input file and output file
165 if (this.inStrFile
!= null && this.outStrFile
!= null
166 && !this.inStrFile
.equalsIgnoreCase("")
167 && !this.inStrFile
.equalsIgnoreCase("")) {
168 argList
.add("-strsub");
169 argList
.add(this.inStrFile
);
170 argList
.add(this.outStrFile
);
175 // add microcode binary files
177 if (mciFileArray
.size() > 0) {
178 argList
.add("-mcmerge");
179 Iterator mciList
= mciFileArray
.iterator();
180 while (mciList
.hasNext()) {
181 argList
.addAll(((Input
) mciList
.next()).getNameList());
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_VERBOSE
, cmdProc
.getOutputStream().toString());
202 EdkLog
.log(EdkLog
.EDK_INFO
, (new File(this.flashDefFile
)).getName());
204 int len
= cmdOut
.read(buf
, 0, 1024);
205 EdkLog
.log(EdkLog
.EDK_INFO
, new String(buf
, 0, len
));
207 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "FlashMap succeeded!");
209 } catch (Exception e
) {
210 throw new BuildException(e
.getMessage());
213 throw new BuildException("FlashMap failed!");
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
;