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