]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SecApResetVectorFixupTask.java
1bcfacf2f0d5c73fd6e20047de10d5b0b3c4a301
[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 // absolute path of efi tools
71 //
72 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
73 String command;
74 String argument;
75 if (path == null) {
76 command = toolName;
77 } else {
78 command = path + File.separatorChar + toolName;
79 }
80 //
81 // argument of tools
82 //
83 File file = new File(this.fvOutputFile);
84 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
85 argument = this.fvInputFile + " " + outputDir + File.separatorChar
86 + this.fvOutputFile;
87 } else {
88 argument = this.fvInputFile + " " + this.fvOutputFile;
89 }
90 //
91 // return value of fwimage execution
92 //
93 int revl = -1;
94
95 try {
96 Commandline cmdline = new Commandline();
97 cmdline.setExecutable(command);
98 cmdline.createArgument().setLine(argument);
99
100 LogStreamHandler streamHandler = new LogStreamHandler(this,
101 Project.MSG_INFO, Project.MSG_WARN);
102 Execute runner = new Execute(streamHandler, null);
103
104 runner.setAntRun(project);
105 runner.setCommandline(cmdline.getCommandline());
106 //
107 // Set debug log information.
108 //
109 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
110 EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.fvInputFile)).getName());
111
112 revl = runner.execute();
113
114 if (EFI_SUCCESS == revl) {
115 //
116 // command execution success
117 //
118 EdkLog.log(this, EdkLog.EDK_VERBOSE, "SecApResetVectorFixup succeeded!");
119 } else {
120 //
121 // command execution fail
122 //
123 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
124 throw new BuildException("SecApResetVectorFixup failed!");
125 }
126 } catch (Exception e) {
127 throw new BuildException(e.getMessage());
128 }
129 }
130
131 /**
132 * getInputFile
133 *
134 * This function is to get class member "fvInputFile".
135 *
136 * @return string of input file name.
137 */
138 public String getfvInputFile() {
139 return this.fvInputFile;
140 }
141
142 /**
143 * setComponentType
144 *
145 * This function is to set class member "fvInputFile".
146 *
147 * @param inputFile
148 * string of input file name.
149 */
150 public void setFvInputFile(String inputFile) {
151 this.fvInputFile = inputFile;
152 }
153
154 /**
155 * getOutputFile
156 *
157 * This function is to get class member "fvOutputFile"
158 *
159 * @return outputFile string of output file name.
160 */
161 public String getOutputFile() {
162 return this.fvOutputFile;
163 }
164
165 /**
166 * setOutputFile
167 *
168 * This function is to set class member "fvOutputFile"
169 *
170 * @param outputFile
171 * string of output file name.
172 */
173 public void setFvOutputFile(String outputFile) {
174 this.fvOutputFile = outputFile;
175 }
176
177 /**
178 * getOutputDir
179 *
180 * This function is to get class member "outputDir"
181 *
182 * @return outputDir string of output directory.
183 */
184 public String getOutputDir() {
185 return outputDir;
186 }
187
188 /**
189 * setOutputDir
190 *
191 * This function is to set class member "outputDir"
192 *
193 * @param outputDir
194 * string of output directory.
195 */
196 public void setOutputDir(String outputDir) {
197 this.outputDir = outputDir;
198 }
199 }