e54fd06d6797bfe6b2d380a407f66019d30f2114
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
;
30 import org
.tianocore
.common
.logger
.EdkLog
;
35 * SecFixupTask is used to call SecFixup.exe to fix up sec image.
37 public class EfiRomTask
extends Task
implements EfiDefine
{
41 private final String toolName
= "EfiRom";
44 /// Flash default file
46 private String verbose
= "";
51 private String venderId
= "";
54 /// Flash device Image
56 private String deviceId
= "";
61 private String outputFile
= "";
66 private List
<Input
> binaryFileList
= new ArrayList
<Input
>();
69 /// Efi PE32 image file
71 private List
<Input
> pe32FileList
= new ArrayList
<Input
>();
74 /// Compress efi PE32 image file
76 private List
<Input
> pe32ComprFileList
= new ArrayList
<Input
>();
79 /// Hex class code in the PCI data strutor header
81 private String classCode
= "";
84 /// Hex revision in the PCI data header.
86 private String revision
= "";
89 /// Dump the headers of an existing option rom image.
91 private String dump
= "";
97 private String outputDir
= ".";
101 /// command and argument list
103 LinkedList
<String
> argList
= new LinkedList
<String
>();
107 * EfiRomTask execute function is to assemble tool command line & execute
110 * @throws BuidException
112 public void execute() throws BuildException
{
114 Project project
= this.getOwningTarget().getProject();
118 FrameworkLogger logger
= new FrameworkLogger(project
, "efirom");
119 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
120 EdkLog
.setLogger(logger
);
122 // absolute path of efi tools
124 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
129 command
= path
+ File
.separatorChar
+ toolName
;
131 argList
.addFirst(command
);
134 // add microcode binary files
136 if (this.binaryFileList
.size() > 0){
138 Iterator binList
= this.binaryFileList
.iterator();
139 while (binList
.hasNext()){
140 argList
.add(((Input
)binList
.next()).getFile());
147 if (this.pe32FileList
.size() > 0){
149 Iterator pe32List
= this.pe32FileList
.iterator();
150 while (pe32List
.hasNext()){
151 argList
.add(((Input
)pe32List
.next()).getFile());
156 // add compressed pe32 file
158 if (this.pe32ComprFileList
.size() > 0){
160 Iterator pe32ComprList
= this.pe32ComprFileList
.iterator();
161 while (pe32ComprList
.hasNext()){
162 argList
.add(((Input
)pe32ComprList
.next()).getFile());
166 EdkLog
.log(EdkLog
.EDK_VERBOSE
, argList
.toString().replaceAll(",",""));
167 EdkLog
.log(EdkLog
.EDK_INFO
, " ");
172 ProcessBuilder pb
= new ProcessBuilder(argList
);
173 pb
.directory(new File(outputDir
));
176 Process cmdProc
= pb
.start();
177 InputStreamReader cmdOut
= new InputStreamReader(cmdProc
.getInputStream());
178 char[] buf
= new char[1024];
180 exitCode
= cmdProc
.waitFor();
182 int len
= cmdOut
.read(buf
, 0, 1024);
183 EdkLog
.log(EdkLog
.EDK_INFO
, new String(buf
, 0, len
));
185 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "EfiRom succeeded!");
187 } catch (Exception e
) {
188 throw new BuildException(e
.getMessage());
191 throw new BuildException("EfiRom failed!");
199 * This function is to get class member "verbose"
201 * @return verbose for verbose output.
203 public String
getVerbose() {
210 * This function is to set class member "verbose"
212 * @param verbose for verbose output.
214 public void setVerbose(boolean verbose
) {
217 argList
.add(this.verbose
);
224 * This function is to get class member "venderId"
226 * @return venderId String of venderId.
228 public String
getVenderId() {
235 * This function is to set class member "venderId"
237 * @param venderId String of venderId.
239 public void setVenderId(String VenderId
) {
240 this.venderId
= VenderId
;
242 argList
.add(this.venderId
);
248 * This function is to get class member "deviceId"
250 * @return deviceId String of device ID.
252 public String
getDeviceId() {
253 return this.deviceId
;
259 * This function is to set class member "deviceId"
261 * @param deviceId String of device ID.
263 public void setDeviceId(String deviceId
) {
264 this.deviceId
= deviceId
;
266 argList
.add(this.deviceId
);
273 * This function is to get class member "outputFile"
275 * @return outputFile name of output directory.
277 public String
getOutputFile() {
284 * This function is to set class member "dscFile"
286 * @param outputFile name of DSC file
288 public void setOutputFile(String outputFile
) {
289 this.outputFile
= outputFile
;
296 * This function is to get class member "classCode"
298 * @return fdImage name of class code file.
300 public String
getClassCode() {
307 * This function is to set class member "classCode"
309 * @param fdImage name of class code file.
311 public void setclassCode(String classCode
) {
312 this.classCode
= classCode
;
314 argList
.add(this.classCode
);
320 * This function is to get class member "revision".
322 * @return revision hex revision in the PDI data header.
324 public String
getRevision() {
331 * This function is to set class member "revision"
333 * @param revision hex revision in the PDI data header.
335 public void setRevision(String revision
) {
336 this.revision
= revision
;
338 argList
.add(this.revision
);
342 * getFlashDeviceImage
344 * This function is to get class member "dump"
346 * @return flashDeviceImage name of flash device image
348 public String
getDump() {
353 * setFlashDeviceImage
355 * This function is to set class member "dump"
357 * @param flashDeviceImage name of flash device image
359 public void setDump(boolean dump
) {
362 argList
.add(this.dump
);
369 * This function is to get class member "outputDir"
371 * @return outputDir string of output directory
373 public String
getOutputDir() {
380 * This function is to set class member "outputDir"
382 * @param outputDir string of output directory
384 public void setOutputDir(String outputDir
) {
385 this.outputDir
= outputDir
;
390 * This function is to add binary file to binaryFile list.
392 * @param binaryFile name of binary file.
394 public void addBinaryFile(Input binaryFile
){
395 this.binaryFileList
.add(binaryFile
);
401 * This function is to add pe32 file to pe32File list.
403 * @param pe32File name of pe32 file.
405 public void addPe32File(Input pe32File
){
406 this.pe32FileList
.add(pe32File
);
412 * This function os to add compressed pe32 file to pe32ComprFile list.
414 * @param pe32ComprFile name of compressed pe32 file.
416 public void addPe32ComprFile(Input pe32ComprFile
){
417 this.pe32ComprFileList
.add(pe32ComprFile
);