]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/EfiRomTask.java
0018e2ba849fc9f4e694577db21f3791889d0e18
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());
164 EdkLog
.log(EdkLog
.EDK_INFO
, argList
.toString().replaceAll(",",""));
169 ProcessBuilder pb
= new ProcessBuilder(argList
);
170 pb
.directory(new File(outputDir
));
173 Process cmdProc
= pb
.start();
174 InputStreamReader cmdOut
= new InputStreamReader(cmdProc
.getInputStream());
175 char[] buf
= new char[1024];
177 exitCode
= cmdProc
.waitFor();
179 int len
= cmdOut
.read(buf
, 0, 1024);
180 EdkLog
.log(EdkLog
.EDK_ERROR
,new String(buf
, 0, len
));
182 EdkLog
.log(EdkLog
.EDK_INFO
, "FlashMap succeed!");
184 } catch (Exception e
) {
185 throw new BuildException(e
.getMessage());
188 //throw new BuildException("GenFvImage: failed to generate FV file!");
196 * This function is to get class member "verbose"
198 * @return verbose for verbose output.
200 public String
getVerbose() {
207 * This function is to set class member "verbose"
209 * @param verbose for verbose output.
211 public void setVerbose(boolean verbose
) {
214 argList
.add(this.verbose
);
221 * This function is to get class member "venderId"
223 * @return venderId String of venderId.
225 public String
getVenderId() {
232 * This function is to set class member "venderId"
234 * @param venderId String of venderId.
236 public void setVenderId(String VenderId
) {
237 this.venderId
= VenderId
;
239 argList
.add(this.venderId
);
245 * This function is to get class member "deviceId"
247 * @return deviceId String of device ID.
249 public String
getDeviceId() {
250 return this.deviceId
;
256 * This function is to set class member "deviceId"
258 * @param deviceId String of device ID.
260 public void setDeviceId(String deviceId
) {
261 this.deviceId
= deviceId
;
263 argList
.add(this.deviceId
);
270 * This function is to get class member "outputFile"
272 * @return outputFile name of output directory.
274 public String
getOutputFile() {
281 * This function is to set class member "dscFile"
283 * @param outputFile name of DSC file
285 public void setOutputFile(String outputFile
) {
286 this.outputFile
= outputFile
;
293 * This function is to get class member "classCode"
295 * @return fdImage name of class code file.
297 public String
getClassCode() {
304 * This function is to set class member "classCode"
306 * @param fdImage name of class code file.
308 public void setclassCode(String classCode
) {
309 this.classCode
= classCode
;
311 argList
.add(this.classCode
);
317 * This function is to get class member "revision".
319 * @return revision hex revision in the PDI data header.
321 public String
getRevision() {
328 * This function is to set class member "revision"
330 * @param revision hex revision in the PDI data header.
332 public void setRevision(String revision
) {
333 this.revision
= revision
;
335 argList
.add(this.revision
);
339 * getFlashDeviceImage
341 * This function is to get class member "dump"
343 * @return flashDeviceImage name of flash device image
345 public String
getDump() {
350 * setFlashDeviceImage
352 * This function is to set class member "dump"
354 * @param flashDeviceImage name of flash device image
356 public void setDump(boolean dump
) {
359 argList
.add(this.dump
);
366 * This function is to get class member "outputDir"
368 * @return outputDir string of output directory
370 public String
getOutputDir() {
377 * This function is to set class member "outputDir"
379 * @param outputDir string of output directory
381 public void setOutputDir(String outputDir
) {
382 this.outputDir
= outputDir
;
387 * This function is to add binary file to binaryFile list.
389 * @param binaryFile name of binary file.
391 public void addBinaryFile(Input binaryFile
){
392 this.binaryFileList
.add(binaryFile
);
398 * This function is to add pe32 file to pe32File list.
400 * @param pe32File name of pe32 file.
402 public void addPe32File(Input pe32File
){
403 this.pe32FileList
.add(pe32File
);
409 * This function os to add compressed pe32 file to pe32ComprFile list.
411 * @param pe32ComprFile name of compressed pe32 file.
413 public void addPe32ComprFile(Input pe32ComprFile
){
414 this.pe32ComprFileList
.add(pe32ComprFile
);