]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SecApResetVectorFixupTask.java
moved exception and logger classes to org.tianocore.common package
[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
29 import org.tianocore.common.logger.EdkLog;
30
31 /**
32 SecApResetVectorFixupTask class.
33
34 SecApResetVectorFixupTask is used to call SecApResetVectorFixup.exe to place
35 Ap reset vector.
36 **/
37 public class SecApResetVectorFixupTask extends Task implements EfiDefine {
38 ///
39 /// tool name
40 ///
41 private String toolName = "SecApResetVectorFixup";
42 // /
43 // / input FV recovery file
44 // /
45 private String fvInputFile = "";
46
47 // /
48 // / output file
49 // /
50 private String fvOutputFile = "";
51
52 // /
53 // / output directory, this variable is added by jave wrap
54 // /
55 private String outputDir = "";
56
57
58 /**
59 * execute
60 *
61 * SecApResetVectorFixupTask execute function is to assemble tool command line & execute
62 * tool command line
63 *
64 * @throws BuidException
65 */
66 public void execute() throws BuildException {
67
68 Project project = this.getOwningTarget().getProject();
69 //
70 // set Logger
71 //
72 FrameworkLogger logger = new FrameworkLogger(project, "secapresetvectorfixup");
73 EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
74 EdkLog.setLogger(logger);
75 //
76 // absolute path of efi tools
77 //
78 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
79 String command;
80 String argument;
81 if (path == null) {
82 command = toolName;
83 } else {
84 command = path + File.separatorChar + toolName;
85 }
86 //
87 // argument of tools
88 //
89 File file = new File(this.fvOutputFile);
90 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
91 argument = this.fvInputFile + " " + outputDir + File.separatorChar
92 + this.fvOutputFile;
93 } else {
94 argument = this.fvInputFile + " " + this.fvOutputFile;
95 }
96 //
97 // return value of fwimage execution
98 //
99 int revl = -1;
100
101 try {
102 Commandline cmdline = new Commandline();
103 cmdline.setExecutable(command);
104 cmdline.createArgument().setLine(argument);
105
106 LogStreamHandler streamHandler = new LogStreamHandler(this,
107 Project.MSG_INFO, Project.MSG_WARN);
108 Execute runner = new Execute(streamHandler, null);
109
110 runner.setAntRun(project);
111 runner.setCommandline(cmdline.getCommandline());
112 //
113 // Set debug log information.
114 //
115 EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
116 EdkLog.log(EdkLog.EDK_INFO, (new File(this.fvInputFile)).getName());
117
118 revl = runner.execute();
119
120 if (EFI_SUCCESS == revl) {
121 //
122 // command execution success
123 //
124 EdkLog.log(EdkLog.EDK_VERBOSE, "SecApResetVectorFixup succeeded!");
125 } else {
126 //
127 // command execution fail
128 //
129 EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
130 throw new BuildException("SecApResetVectorFixup failed!");
131 }
132 } catch (Exception e) {
133 throw new BuildException(e.getMessage());
134 }
135 }
136
137 /**
138 * getInputFile
139 *
140 * This function is to get class member "fvInputFile".
141 *
142 * @return string of input file name.
143 */
144 public String getfvInputFile() {
145 return this.fvInputFile;
146 }
147
148 /**
149 * setComponentType
150 *
151 * This function is to set class member "fvInputFile".
152 *
153 * @param inputFile
154 * string of input file name.
155 */
156 public void setFvInputFile(String inputFile) {
157 this.fvInputFile = inputFile;
158 }
159
160 /**
161 * getOutputFile
162 *
163 * This function is to get class member "fvOutputFile"
164 *
165 * @return outputFile string of output file name.
166 */
167 public String getOutputFile() {
168 return this.fvOutputFile;
169 }
170
171 /**
172 * setOutputFile
173 *
174 * This function is to set class member "fvOutputFile"
175 *
176 * @param outputFile
177 * string of output file name.
178 */
179 public void setFvOutputFile(String outputFile) {
180 this.fvOutputFile = outputFile;
181 }
182
183 /**
184 * getOutputDir
185 *
186 * This function is to get class member "outputDir"
187 *
188 * @return outputDir string of output directory.
189 */
190 public String getOutputDir() {
191 return outputDir;
192 }
193
194 /**
195 * setOutputDir
196 *
197 * This function is to set class member "outputDir"
198 *
199 * @param outputDir
200 * string of output directory.
201 */
202 public void setOutputDir(String outputDir) {
203 this.outputDir = outputDir;
204 }
205 }