]>
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
;
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();
117 // absolute path of efi tools
119 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
124 command
= path
+ File
.separatorChar
+ toolName
;
126 argList
.addFirst(command
);
129 // add microcode binary files
131 if (this.binaryFileList
.size() > 0){
133 Iterator binList
= this.binaryFileList
.iterator();
134 while (binList
.hasNext()){
135 argList
.addAll(((Input
)binList
.next()).getNameList());
142 if (this.pe32FileList
.size() > 0){
144 Iterator pe32List
= this.pe32FileList
.iterator();
145 while (pe32List
.hasNext()){
146 argList
.addAll(((Input
)pe32List
.next()).getNameList());
151 // add compressed pe32 file
153 if (this.pe32ComprFileList
.size() > 0){
155 Iterator pe32ComprList
= this.pe32ComprFileList
.iterator();
156 while (pe32ComprList
.hasNext()){
157 argList
.addAll(((Input
)pe32ComprList
.next()).getNameList());
161 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, argList
.toString().replaceAll(",",""));
162 EdkLog
.log(this, EdkLog
.EDK_INFO
, " ");
167 ProcessBuilder pb
= new ProcessBuilder(argList
);
168 pb
.directory(new File(outputDir
));
171 Process cmdProc
= pb
.start();
172 InputStreamReader cmdOut
= new InputStreamReader(cmdProc
.getInputStream());
173 char[] buf
= new char[1024];
175 exitCode
= cmdProc
.waitFor();
177 int len
= cmdOut
.read(buf
, 0, 1024);
178 EdkLog
.log(EdkLog
.EDK_INFO
, new String(buf
, 0, len
));
180 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "EfiRom succeeded!");
182 } catch (Exception e
) {
183 throw new BuildException(e
.getMessage());
186 throw new BuildException("EfiRom failed!");
194 * This function is to get class member "verbose"
196 * @return verbose for verbose output.
198 public String
getVerbose() {
205 * This function is to set class member "verbose"
207 * @param verbose for verbose output.
209 public void setVerbose(boolean verbose
) {
212 argList
.add(this.verbose
);
219 * This function is to get class member "venderId"
221 * @return venderId String of venderId.
223 public String
getVenderId() {
230 * This function is to set class member "venderId"
232 * @param venderId String of venderId.
234 public void setVenderId(String VenderId
) {
235 this.venderId
= VenderId
;
237 argList
.add(this.venderId
);
243 * This function is to get class member "deviceId"
245 * @return deviceId String of device ID.
247 public String
getDeviceId() {
248 return this.deviceId
;
254 * This function is to set class member "deviceId"
256 * @param deviceId String of device ID.
258 public void setDeviceId(String deviceId
) {
259 this.deviceId
= deviceId
;
261 argList
.add(this.deviceId
);
268 * This function is to get class member "outputFile"
270 * @return outputFile name of output directory.
272 public String
getOutputFile() {
279 * This function is to set class member "dscFile"
281 * @param outputFile name of DSC file
283 public void setOutputFile(String outputFile
) {
284 this.outputFile
= outputFile
;
291 * This function is to get class member "classCode"
293 * @return fdImage name of class code file.
295 public String
getClassCode() {
302 * This function is to set class member "classCode"
304 * @param fdImage name of class code file.
306 public void setclassCode(String classCode
) {
307 this.classCode
= classCode
;
309 argList
.add(this.classCode
);
315 * This function is to get class member "revision".
317 * @return revision hex revision in the PDI data header.
319 public String
getRevision() {
326 * This function is to set class member "revision"
328 * @param revision hex revision in the PDI data header.
330 public void setRevision(String revision
) {
331 this.revision
= revision
;
333 argList
.add(this.revision
);
337 * getFlashDeviceImage
339 * This function is to get class member "dump"
341 * @return flashDeviceImage name of flash device image
343 public String
getDump() {
348 * setFlashDeviceImage
350 * This function is to set class member "dump"
352 * @param flashDeviceImage name of flash device image
354 public void setDump(boolean dump
) {
357 argList
.add(this.dump
);
364 * This function is to get class member "outputDir"
366 * @return outputDir string of output directory
368 public String
getOutputDir() {
375 * This function is to set class member "outputDir"
377 * @param outputDir string of output directory
379 public void setOutputDir(String outputDir
) {
380 this.outputDir
= outputDir
;
385 * This function is to add binary file to binaryFile list.
387 * @param binaryFile name of binary file.
389 public void addBinaryFile(Input binaryFile
){
390 this.binaryFileList
.add(binaryFile
);
396 * This function is to add pe32 file to pe32File list.
398 * @param pe32File name of pe32 file.
400 public void addPe32File(Input pe32File
){
401 this.pe32FileList
.add(pe32File
);
407 * This function os to add compressed pe32 file to pe32ComprFile list.
409 * @param pe32ComprFile name of compressed pe32 file.
411 public void addPe32ComprFile(Input pe32ComprFile
){
412 this.pe32ComprFileList
.add(pe32ComprFile
);