]>
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
;
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();
145 // absolute path of efi tools
147 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
152 command
= path
+ File
.separatorChar
+ toolName
;
154 argList
.addFirst(command
);
157 // add substituted input file and output file
159 if (this.inStrFile
!= null && this.outStrFile
!= null
160 && !this.inStrFile
.equalsIgnoreCase("")
161 && !this.inStrFile
.equalsIgnoreCase("")) {
162 argList
.add("-strsub");
163 argList
.add(this.inStrFile
);
164 argList
.add(this.outStrFile
);
169 // add microcode binary files
171 if (mciFileArray
.size() > 0) {
172 argList
.add("-mcmerge");
173 Iterator mciList
= mciFileArray
.iterator();
174 while (mciList
.hasNext()) {
175 argList
.addAll(((Input
) mciList
.next()).getNameList());
182 ProcessBuilder pb
= new ProcessBuilder(argList
);
183 pb
.directory(new File(outputDir
));
186 Process cmdProc
= pb
.start();
187 InputStreamReader cmdOut
= new InputStreamReader(cmdProc
189 char[] buf
= new char[1024];
191 exitCode
= cmdProc
.waitFor();
193 // log command line string.
195 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, cmdProc
.getOutputStream().toString());
196 EdkLog
.log(this, EdkLog
.EDK_INFO
, (new File(this.flashDefFile
)).getName());
198 int len
= cmdOut
.read(buf
, 0, 1024);
199 EdkLog
.log(this, EdkLog
.EDK_INFO
, new String(buf
, 0, len
));
201 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "FlashMap succeeded!");
203 } catch (Exception e
) {
204 throw new BuildException(e
.getMessage());
207 throw new BuildException("FlashMap failed!");
215 * This function is to get class member "flashDefFile"
217 * @return flashDeFile Name of flash definition file.
219 public String
getFlashDefFile() {
226 * This function is to set class member "flashDefFile"
228 * @param flashDefFile
229 * Name of flash definition file.
231 public void setFlashDefFile(String flashDefFile
) {
232 this.flashDefFile
= flashDefFile
;
234 argList
.add(this.flashDefFile
);
240 * This function is to get class member "aligment"
242 * @return aligment String of aligment value.
244 public String
getAligment() {
251 * This function is to set class member "aligment"
254 * String of aligment value.
256 public void setAligment(String aligment
) {
257 this.aligment
= aligment
;
258 argList
.add("-align");
259 argList
.add(this.aligment
);
265 * This function is to get class member "asmIncFile"
267 * @return asmIncFile String of ASM include file.
269 public String
getAsmIncFile() {
276 * This function is to set class member "asmIncFile"
279 * String of ASM include file.
281 public void setAsmIncFile(String asmIncFile
) {
282 this.asmIncFile
= asmIncFile
;
283 argList
.add("-asmincfile");
284 argList
.add(this.asmIncFile
);
290 * This function is to get class member "baseAddr"
292 * @return baseAddr String of base address value.
294 public String
getBaseAddr() {
301 * This function is to set class member "baseAddr"
304 * String of base address value.
306 public void setBaseAddr(String baseAddr
) {
307 this.baseAddr
= baseAddr
;
308 argList
.add("-baseaddr");
309 argList
.add(this.baseAddr
);
315 * This function is to get class member "dscFile"
317 * @return dscFile name of DSC file
319 public String
getDscFile() {
326 * This function is to set class member "dscFile"
331 public void setDscFile(String dscFile
) {
332 this.dscFile
= dscFile
;
334 argList
.add(this.dscFile
);
340 * This function is to get class member "fdImage"
342 * @return fdImage name of input FDI image file.
344 public String
getFdImage() {
351 * This function is to set class member "fdImage"
354 * name of input FDI image file.
356 public void setFdImage(String fdImage
) {
357 this.fdImage
= fdImage
;
358 argList
.add("-discover");
359 argList
.add(this.fdImage
);
365 * This function is to get class member "flashDevice".
367 * @return flashDevice name of flash device.
369 public String
getFlashDevice() {
376 * This function is to set class member "flashDevice"
379 * name of flash device.
381 public void setFlashDevice(String flashDevice
) {
382 this.flashDevice
= flashDevice
;
383 argList
.add("-flashdevice");
384 argList
.add(this.flashDevice
);
388 * getFlashDeviceImage
390 * This function is to get class member "flashDeviceImage"
392 * @return flashDeviceImage name of flash device image
394 public String
getFlashDeviceImage() {
395 return flashDeviceImage
;
399 * setFlashDeviceImage
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
= flashDeviceImage
;
408 argList
.add("-flashdeviceimage");
409 argList
.add(this.flashDeviceImage
);
416 * This function is to get class member "headerFile"
418 * @return headerFile name of include file
420 public String
getHeaderFile() {
427 * This function is to set class member "headerFile"
430 * name of include file
432 public void setHeaderFile(String headerFile
) {
433 this.headerFile
= headerFile
;
434 argList
.add("-hfile");
435 argList
.add(this.headerFile
);
441 * This function is to get class member "imageOutFile"
443 * @return imageOutFile name of output image file
445 public String
getImageOutFile() {
452 * This function is to set class member "ImageOutFile"
454 * @param imageOutFile
455 * name of output image file
457 public void setImageOutFile(String imageOutFile
) {
458 this.imageOutFile
= imageOutFile
;
459 argList
.add("-imageout");
460 argList
.add(this.imageOutFile
);
466 * This function is to get class member "inStrFile"
468 * @return inStrFile name of input file which used to replace symbol names.
470 public String
getInStrFile() {
477 * This function is to set class member "inStrFile"
480 * name of input file which used to replace symbol names.
482 public void setInStrFile(String inStrFile
) {
483 this.inStrFile
= inStrFile
;
489 * This function is to get class member "mciFile"
491 * @return mciFile name of input microcode file
493 public String
getMciFile() {
500 * This function is to set class member "mciFile"
503 * name of input microcode file
505 public void setMciFile(String mciFile
) {
506 this.mciFile
= mciFile
;
508 argList
.add(this.mciFile
);
514 * This function is to get class member "mcoFile"
516 * @return mcoFile name of output binary microcode image
518 public String
getMcoFile() {
525 * This function is to set class member "mcoFile"
528 * name of output binary microcode image
530 public void setMcoFile(String mcoFile
) {
531 this.mcoFile
= mcoFile
;
533 argList
.add(this.mcoFile
);
539 * This function is to get class member "outStrFile"
541 * @return outStrFile name of output string substitution file
543 public String
getOutStrFile() {
550 * This function is to set class member "outStrFile"
553 * name of output string substitution file
555 public void setOutStrFile(String outStrFile
) {
556 this.outStrFile
= outStrFile
;
562 * This function is to get class member "padValue"
564 * @return padValue string of byte value to use as padding
566 public String
getPadValue() {
573 * This function is to set class member "padValue"
576 * string of byte value to use as padding
578 public void setPadValue(String padValue
) {
579 this.padValue
= padValue
;
580 argList
.add("-padvalue");
581 argList
.add(this.padValue
);
587 * This function is to add Microcode binary file
590 * instance of input class
592 public void addMciFile(Input mciFile
) {
593 this.mciFileArray
.add(mciFile
);
599 * This function is to get class member "outputDir"
601 * @return outputDir string of output directory
603 public String
getOutputDir() {
610 * This function is to set class member "outputDir"
613 * string of output directory
615 public void setOutputDir(String outputDir
) {
616 this.outputDir
= outputDir
;