4 PeiReBaseTask is used to call PeiReBase.exe to rebase efi fv file.
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
;
21 import org
.apache
.tools
.ant
.Task
;
22 import org
.apache
.tools
.ant
.Project
;
23 import org
.apache
.tools
.ant
.BuildException
;
24 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
25 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
26 import org
.apache
.tools
.ant
.types
.Commandline
;
28 import org
.tianocore
.common
.logger
.EdkLog
;
33 PeiReBaseTask is used to call PeiReBase.exe to rebase efi fv file.
35 public class PeiReBaseTask
extends Task
implements EfiDefine
{
39 private String toolName
= "PeiReBase";
43 private FileArg inputFile
= new FileArg();
47 private FileArg outputFile
= new FileArg();
51 private ToolArg baseAddr
= new ToolArg();
55 private FileArg mapFile
= new FileArg();
59 private String arch
= "IA32";
64 PeiReBaseTask execute function is to assemble tool command line & execute
69 public void execute() throws BuildException
{
71 Project project
= this.getOwningTarget().getProject();
74 // absolute path of efi tools
76 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
79 if (this.arch
.equalsIgnoreCase("IA32")){
80 command
= toolName
+ "_IA32";
81 } else if (this.arch
.equalsIgnoreCase("X64")){
82 command
= toolName
+ "_X64";
83 } else if (this.arch
.equalsIgnoreCase("IPF")){
84 command
= toolName
+ "_IPF";
86 command
= toolName
+ "_IA32";
89 command
= path
+ File
.separator
+ command
;
95 if (mapFile
.getValue().length() == 0) {
96 mapFile
.setArg(" -M ", outputFile
.getValue() + ".map");
98 argument
= "" + inputFile
+ outputFile
+ baseAddr
+ mapFile
;
101 // return value of fwimage execution
106 Commandline cmdline
= new Commandline();
107 cmdline
.setExecutable(command
);
108 cmdline
.createArgument().setLine(argument
);
110 LogStreamHandler streamHandler
= new LogStreamHandler(this,
111 Project
.MSG_INFO
, Project
.MSG_WARN
);
112 Execute runner
= new Execute(streamHandler
, null);
114 runner
.setAntRun(project
);
115 runner
.setCommandline(cmdline
.getCommandline());
117 // Set debug log information.
119 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
120 EdkLog
.log(this, EdkLog
.EDK_INFO
, inputFile
.toFileList() + " => "
121 + outputFile
.toFileList()
122 + mapFile
.toFileList());
124 revl
= runner
.execute();
126 if (EFI_SUCCESS
== revl
) {
128 // command execution success
130 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "PeiReBase succeeded!");
133 // command execution fail
135 EdkLog
.log(this, EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
136 throw new BuildException("PeiReBase failed!");
138 } catch (Exception e
) {
139 throw new BuildException(e
.getMessage());
146 This function is to get class member "inputFile".
148 @return string of input file name.
150 public String
getInputFile() {
151 return inputFile
.getValue();
157 This function is to set class member "inputFile".
160 string of input file name.
162 public void setInputFile(String inputFile
) {
163 this.inputFile
.setArg(" -I ", inputFile
);
169 This function is to get class member "outputFile"
171 @return outputFile string of output file name.
173 public String
getOutputFile() {
174 return outputFile
.getValue();
180 This function is to set class member "outputFile"
183 string of output file name.
185 public void setOutputFile(String outputFile
) {
186 this.outputFile
.setArg(" -O ", outputFile
);
192 This function is to get class member "baseAddr"
194 @return baseAddr string of base address.
196 public String
getBaseAddr() {
197 return baseAddr
.getValue();
203 This function is to set class member "baseAddr"
205 @param baseAddr string of base address
207 public void setBaseAddr(String baseAddr
) {
208 this.baseAddr
.setArg(" -B ", baseAddr
);
214 This function is to get class member "arch".
216 @return arch Architecture
218 public String
getArch() {
225 This function is to set class member "arch"
227 @param arch Architecture
229 public void setArch(String arch
) {
234 Get the value of map file
236 @return String The map file path
238 public String
getMapFile() {
239 return mapFile
.getValue();
243 Set "-M MapFile" argument
245 @param mapFile The path of map file
247 public void setMapFile(String mapFile
) {
248 this.mapFile
.setArg(" -M ", mapFile
);