]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SecApResetVectorFixupTask.java
Add follows warpped tianotools to frameworktask:
[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_INFO, Commandline.toString(cmdline.getCommandline()));
115
116 revl = runner.execute();
117
118 if (EFI_SUCCESS == revl) {
119 //
120 // command execution success
121 //
122 EdkLog.log(EdkLog.EDK_INFO,"SecApResetVectorFixup succeeded!");
123 } else {
124 //
125 // command execution fail
126 //
127 EdkLog.log(EdkLog.EDK_ERROR, "SecApResetVectorFixup failed. (error="
128 + Integer.toHexString(revl) + ")");
129 throw new BuildException("SecApResetVectorFixup failed. (error="
130 + Integer.toHexString(revl) + ")");
131
132 }
133 } catch (Exception e) {
134 throw new BuildException(e.getMessage());
135 }
136 }
137
138 /**
139 * getInputFile
140 *
141 * This function is to get class member "fvInputFile".
142 *
143 * @return string of input file name.
144 */
145 public String getfvInputFile() {
146 return this.fvInputFile;
147 }
148
149 /**
150 * setComponentType
151 *
152 * This function is to set class member "fvInputFile".
153 *
154 * @param inputFile
155 * string of input file name.
156 */
157 public void setFvInputFile(String inputFile) {
158 this.fvInputFile = inputFile;
159 }
160
161 /**
162 * getOutputFile
163 *
164 * This function is to get class member "fvOutputFile"
165 *
166 * @return outputFile string of output file name.
167 */
168 public String getOutputFile() {
169 return this.fvOutputFile;
170 }
171
172 /**
173 * setOutputFile
174 *
175 * This function is to set class member "fvOutputFile"
176 *
177 * @param outputFile
178 * string of output file name.
179 */
180 public void setFvOutputFile(String outputFile) {
181 this.fvOutputFile = outputFile;
182 }
183
184 /**
185 * getOutputDir
186 *
187 * This function is to get class member "outputDir"
188 *
189 * @return outputDir string of output directory.
190 */
191 public String getOutputDir() {
192 return outputDir;
193 }
194
195 /**
196 * setOutputDir
197 *
198 * This function is to set class member "outputDir"
199 *
200 * @param outputDir
201 * string of output directory.
202 */
203 public void setOutputDir(String outputDir) {
204 this.outputDir = outputDir;
205 }
206 }