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