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