]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/EfiRomTask.java
4 EfiRomTask 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 EfiRomTask
extends Task
implements EfiDefine
{
40 private final String toolName
= "EfiRom";
43 /// Flash default file
45 private String verbose
= "";
50 private String venderId
= "";
53 /// Flash device Image
55 private String deviceId
= "";
60 private String outputFile
= "";
65 private List
<Input
> binaryFileList
= new ArrayList
<Input
>();
68 /// Efi PE32 image file
70 private List
<Input
> pe32FileList
= new ArrayList
<Input
>();
73 /// Compress efi PE32 image file
75 private List
<Input
> pe32ComprFileList
= new ArrayList
<Input
>();
78 /// Hex class code in the PCI data strutor header
80 private String classCode
= "";
83 /// Hex revision in the PCI data header.
85 private String revision
= "";
88 /// Dump the headers of an existing option rom image.
90 private String dump
= "";
96 private String outputDir
= ".";
100 /// command and argument list
102 LinkedList
<String
> argList
= new LinkedList
<String
>();
106 * EfiRomTask execute function is to assemble tool command line & execute
109 * @throws BuidException
111 public void execute() throws BuildException
{
113 Project project
= this.getOwningTarget().getProject();
117 FrameworkLogger logger
= new FrameworkLogger(project
, "efirom");
118 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
119 EdkLog
.setLogger(logger
);
121 // absolute path of efi tools
123 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
128 command
= path
+ File
.separatorChar
+ toolName
;
130 argList
.addFirst(command
);
133 // add microcode binary files
135 if (this.binaryFileList
.size() > 0){
137 Iterator binList
= this.binaryFileList
.iterator();
138 while (binList
.hasNext()){
139 argList
.add(((Input
)binList
.next()).getFile());
146 if (this.pe32FileList
.size() > 0){
148 Iterator pe32List
= this.pe32FileList
.iterator();
149 while (pe32List
.hasNext()){
150 argList
.add(((Input
)pe32List
.next()).getFile());
155 // add compressed pe32 file
157 if (this.pe32ComprFileList
.size() > 0){
159 Iterator pe32ComprList
= this.pe32ComprFileList
.iterator();
160 while (pe32ComprList
.hasNext()){
161 argList
.add(((Input
)pe32ComprList
.next()).getFile());
165 EdkLog
.log(EdkLog
.EDK_VERBOSE
, argList
.toString().replaceAll(",",""));
166 EdkLog
.log(EdkLog
.EDK_INFO
, " ");
171 ProcessBuilder pb
= new ProcessBuilder(argList
);
172 pb
.directory(new File(outputDir
));
175 Process cmdProc
= pb
.start();
176 InputStreamReader cmdOut
= new InputStreamReader(cmdProc
.getInputStream());
177 char[] buf
= new char[1024];
179 exitCode
= cmdProc
.waitFor();
181 int len
= cmdOut
.read(buf
, 0, 1024);
182 EdkLog
.log(EdkLog
.EDK_INFO
, new String(buf
, 0, len
));
184 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "EfiRom succeeded!");
186 } catch (Exception e
) {
187 throw new BuildException(e
.getMessage());
190 throw new BuildException("EfiRom failed!");
198 * This function is to get class member "verbose"
200 * @return verbose for verbose output.
202 public String
getVerbose() {
209 * This function is to set class member "verbose"
211 * @param verbose for verbose output.
213 public void setVerbose(boolean verbose
) {
216 argList
.add(this.verbose
);
223 * This function is to get class member "venderId"
225 * @return venderId String of venderId.
227 public String
getVenderId() {
234 * This function is to set class member "venderId"
236 * @param venderId String of venderId.
238 public void setVenderId(String VenderId
) {
239 this.venderId
= VenderId
;
241 argList
.add(this.venderId
);
247 * This function is to get class member "deviceId"
249 * @return deviceId String of device ID.
251 public String
getDeviceId() {
252 return this.deviceId
;
258 * This function is to set class member "deviceId"
260 * @param deviceId String of device ID.
262 public void setDeviceId(String deviceId
) {
263 this.deviceId
= deviceId
;
265 argList
.add(this.deviceId
);
272 * This function is to get class member "outputFile"
274 * @return outputFile name of output directory.
276 public String
getOutputFile() {
283 * This function is to set class member "dscFile"
285 * @param outputFile name of DSC file
287 public void setOutputFile(String outputFile
) {
288 this.outputFile
= outputFile
;
295 * This function is to get class member "classCode"
297 * @return fdImage name of class code file.
299 public String
getClassCode() {
306 * This function is to set class member "classCode"
308 * @param fdImage name of class code file.
310 public void setclassCode(String classCode
) {
311 this.classCode
= classCode
;
313 argList
.add(this.classCode
);
319 * This function is to get class member "revision".
321 * @return revision hex revision in the PDI data header.
323 public String
getRevision() {
330 * This function is to set class member "revision"
332 * @param revision hex revision in the PDI data header.
334 public void setRevision(String revision
) {
335 this.revision
= revision
;
337 argList
.add(this.revision
);
341 * getFlashDeviceImage
343 * This function is to get class member "dump"
345 * @return flashDeviceImage name of flash device image
347 public String
getDump() {
352 * setFlashDeviceImage
354 * This function is to set class member "dump"
356 * @param flashDeviceImage name of flash device image
358 public void setDump(boolean dump
) {
361 argList
.add(this.dump
);
368 * This function is to get class member "outputDir"
370 * @return outputDir string of output directory
372 public String
getOutputDir() {
379 * This function is to set class member "outputDir"
381 * @param outputDir string of output directory
383 public void setOutputDir(String outputDir
) {
384 this.outputDir
= outputDir
;
389 * This function is to add binary file to binaryFile list.
391 * @param binaryFile name of binary file.
393 public void addBinaryFile(Input binaryFile
){
394 this.binaryFileList
.add(binaryFile
);
400 * This function is to add pe32 file to pe32File list.
402 * @param pe32File name of pe32 file.
404 public void addPe32File(Input pe32File
){
405 this.pe32FileList
.add(pe32File
);
411 * This function os to add compressed pe32 file to pe32ComprFile list.
413 * @param pe32ComprFile name of compressed pe32 file.
415 public void addPe32ComprFile(Input pe32ComprFile
){
416 this.pe32ComprFileList
.add(pe32ComprFile
);