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