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 |
18 | package org.tianocore.framework.tasks;\r |
19 | \r |
20 | import java.io.File;\r |
21 | \r |
22 | import org.apache.tools.ant.Task;\r |
23 | import org.apache.tools.ant.Project;\r |
24 | import org.apache.tools.ant.BuildException;\r |
25 | import org.apache.tools.ant.taskdefs.Execute;\r |
26 | import org.apache.tools.ant.taskdefs.LogStreamHandler;\r |
27 | import org.apache.tools.ant.types.Commandline;\r |
28 | import 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 |
36 | public 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 |
114 | EdkLog.log(EdkLog.EDK_INFO, Commandline.toString(cmdline.getCommandline()));\r |
115 | \r |
116 | revl = runner.execute();\r |
117 | \r |
118 | if (EFI_SUCCESS == revl) {\r |
119 | //\r |
120 | // command execution success\r |
121 | //\r |
122 | EdkLog.log(EdkLog.EDK_INFO,"SecApResetVectorFixup succeeded!");\r |
123 | } else {\r |
124 | //\r |
125 | // command execution fail\r |
126 | //\r |
127 | EdkLog.log(EdkLog.EDK_ERROR, "SecApResetVectorFixup failed. (error="\r |
128 | + Integer.toHexString(revl) + ")");\r |
129 | throw new BuildException("SecApResetVectorFixup failed. (error="\r |
130 | + Integer.toHexString(revl) + ")");\r |
131 | \r |
132 | }\r |
133 | } catch (Exception e) {\r |
134 | throw new BuildException(e.getMessage());\r |
135 | }\r |
136 | }\r |
137 | \r |
138 | /**\r |
139 | * getInputFile\r |
140 | * \r |
141 | * This function is to get class member "fvInputFile".\r |
142 | * \r |
143 | * @return string of input file name.\r |
144 | */\r |
145 | public String getfvInputFile() {\r |
146 | return this.fvInputFile;\r |
147 | }\r |
148 | \r |
149 | /**\r |
150 | * setComponentType\r |
151 | * \r |
152 | * This function is to set class member "fvInputFile".\r |
153 | * \r |
154 | * @param inputFile\r |
155 | * string of input file name.\r |
156 | */\r |
157 | public void setFvInputFile(String inputFile) {\r |
158 | this.fvInputFile = inputFile;\r |
159 | }\r |
160 | \r |
161 | /**\r |
162 | * getOutputFile\r |
163 | * \r |
164 | * This function is to get class member "fvOutputFile"\r |
165 | * \r |
166 | * @return outputFile string of output file name.\r |
167 | */\r |
168 | public String getOutputFile() {\r |
169 | return this.fvOutputFile;\r |
170 | }\r |
171 | \r |
172 | /**\r |
173 | * setOutputFile\r |
174 | * \r |
175 | * This function is to set class member "fvOutputFile"\r |
176 | * \r |
177 | * @param outputFile\r |
178 | * string of output file name.\r |
179 | */\r |
180 | public void setFvOutputFile(String outputFile) {\r |
181 | this.fvOutputFile = outputFile;\r |
182 | }\r |
183 | \r |
184 | /**\r |
185 | * getOutputDir\r |
186 | * \r |
187 | * This function is to get class member "outputDir"\r |
188 | * \r |
189 | * @return outputDir string of output directory.\r |
190 | */\r |
191 | public String getOutputDir() {\r |
192 | return outputDir;\r |
193 | }\r |
194 | \r |
195 | /**\r |
196 | * setOutputDir\r |
197 | * \r |
198 | * This function is to set class member "outputDir"\r |
199 | * \r |
200 | * @param outputDir\r |
201 | * string of output directory.\r |
202 | */\r |
203 | public void setOutputDir(String outputDir) {\r |
204 | this.outputDir = outputDir;\r |
205 | }\r |
206 | }\r |