]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SecApResetVectorFixupTask.java
e1b9bd1b63735c1dabd3dbd11011e2fe466a39a5
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / SecApResetVectorFixupTask.java
1 /** @file
2 SecApResetVectorFixupTask class.
3
4 SecApResetVectorFixupTask is used to call SecApResetVectorFixup.exe to place
5 Ap reset vector.
6
7
8 Copyright (c) 2006, Intel Corporation
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 **/
18 package org.tianocore.framework.tasks;
19
20 import java.io.File;
21
22 import org.apache.tools.ant.Task;
23 import org.apache.tools.ant.Project;
24 import org.apache.tools.ant.BuildException;
25 import org.apache.tools.ant.taskdefs.Execute;
26 import org.apache.tools.ant.taskdefs.LogStreamHandler;
27 import org.apache.tools.ant.types.Commandline;
28 import org.tianocore.logger.EdkLog;
29
30 /**
31 SecApResetVectorFixupTask class.
32
33 SecApResetVectorFixupTask is used to call SecApResetVectorFixup.exe to place
34 Ap reset vector.
35 **/
36 public class SecApResetVectorFixupTask extends Task implements EfiDefine {
37 ///
38 /// tool name
39 ///
40 private String toolName = "SecApResetVectorFixup";
41 // /
42 // / input FV recovery file
43 // /
44 private String fvInputFile = "";
45
46 // /
47 // / output file
48 // /
49 private String fvOutputFile = "";
50
51 // /
52 // / output directory, this variable is added by jave wrap
53 // /
54 private String outputDir = "";
55
56
57 /**
58 * execute
59 *
60 * SecApResetVectorFixupTask execute function is to assemble tool command line & execute
61 * tool command line
62 *
63 * @throws BuidException
64 */
65 public void execute() throws BuildException {
66
67 Project project = this.getOwningTarget().getProject();
68 //
69 // set Logger
70 //
71 FrameworkLogger logger = new FrameworkLogger(project, "secapresetvectorfixup");
72 EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
73 EdkLog.setLogger(logger);
74 //
75 // absolute path of efi tools
76 //
77 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
78 String command;
79 String argument;
80 if (path == null) {
81 command = toolName;
82 } else {
83 command = path + File.separatorChar + toolName;
84 }
85 //
86 // argument of tools
87 //
88 File file = new File(this.fvOutputFile);
89 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
90 argument = this.fvInputFile + " " + outputDir + File.separatorChar
91 + this.fvOutputFile;
92 } else {
93 argument = this.fvInputFile + " " + this.fvOutputFile;
94 }
95 //
96 // return value of fwimage execution
97 //
98 int revl = -1;
99
100 try {
101 Commandline cmdline = new Commandline();
102 cmdline.setExecutable(command);
103 cmdline.createArgument().setLine(argument);
104
105 LogStreamHandler streamHandler = new LogStreamHandler(this,
106 Project.MSG_INFO, Project.MSG_WARN);
107 Execute runner = new Execute(streamHandler, null);
108
109 runner.setAntRun(project);
110 runner.setCommandline(cmdline.getCommandline());
111 //
112 // Set debug log information.
113 //
114 EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
115 EdkLog.log(EdkLog.EDK_INFO, (new File(this.fvInputFile)).getName());
116
117 revl = runner.execute();
118
119 if (EFI_SUCCESS == revl) {
120 //
121 // command execution success
122 //
123 EdkLog.log(EdkLog.EDK_VERBOSE, "SecApResetVectorFixup succeeded!");
124 } else {
125 //
126 // command execution fail
127 //
128 EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
129 throw new BuildException("SecApResetVectorFixup failed!");
130 }
131 } catch (Exception e) {
132 throw new BuildException(e.getMessage());
133 }
134 }
135
136 /**
137 * getInputFile
138 *
139 * This function is to get class member "fvInputFile".
140 *
141 * @return string of input file name.
142 */
143 public String getfvInputFile() {
144 return this.fvInputFile;
145 }
146
147 /**
148 * setComponentType
149 *
150 * This function is to set class member "fvInputFile".
151 *
152 * @param inputFile
153 * string of input file name.
154 */
155 public void setFvInputFile(String inputFile) {
156 this.fvInputFile = inputFile;
157 }
158
159 /**
160 * getOutputFile
161 *
162 * This function is to get class member "fvOutputFile"
163 *
164 * @return outputFile string of output file name.
165 */
166 public String getOutputFile() {
167 return this.fvOutputFile;
168 }
169
170 /**
171 * setOutputFile
172 *
173 * This function is to set class member "fvOutputFile"
174 *
175 * @param outputFile
176 * string of output file name.
177 */
178 public void setFvOutputFile(String outputFile) {
179 this.fvOutputFile = outputFile;
180 }
181
182 /**
183 * getOutputDir
184 *
185 * This function is to get class member "outputDir"
186 *
187 * @return outputDir string of output directory.
188 */
189 public String getOutputDir() {
190 return outputDir;
191 }
192
193 /**
194 * setOutputDir
195 *
196 * This function is to set class member "outputDir"
197 *
198 * @param outputDir
199 * string of output directory.
200 */
201 public void setOutputDir(String outputDir) {
202 this.outputDir = outputDir;
203 }
204 }