]>
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 | |
0fdb42ac | 38 | //\r |
39 | // tool name\r | |
40 | //\r | |
a15bb0d3 | 41 | private String toolName = "SecApResetVectorFixup";\r |
0fdb42ac | 42 | //\r |
43 | // input FV recovery file\r | |
44 | //\r | |
45 | private FileArg fvInputFile = new FileArg();\r | |
a15bb0d3 | 46 | \r |
0fdb42ac | 47 | //\r |
48 | // output file\r | |
49 | //\r | |
50 | private FileArg fvOutputFile = new FileArg();\r | |
a15bb0d3 | 51 | \r |
0fdb42ac | 52 | //\r |
53 | // output directory, this variable is added by jave wrap\r | |
54 | //\r | |
55 | private String outputDir = ".";\r | |
a15bb0d3 | 56 | \r |
57 | \r | |
58 | /**\r | |
0fdb42ac | 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 | |
a15bb0d3 | 66 | public void execute() throws BuildException {\r |
67 | \r | |
68 | Project project = this.getOwningTarget().getProject();\r | |
69 | //\r | |
a15bb0d3 | 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 | |
0fdb42ac | 78 | command = path + File.separator + toolName;\r |
a15bb0d3 | 79 | }\r |
80 | //\r | |
81 | // argument of tools\r | |
82 | //\r | |
0fdb42ac | 83 | argument = "" + this.fvInputFile + this.fvOutputFile;\r |
a15bb0d3 | 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 | |
0fdb42ac | 100 | runner.setWorkingDirectory(new File(outputDir));\r |
101 | \r | |
a15bb0d3 | 102 | //\r |
103 | // Set debug log information.\r | |
104 | //\r | |
91f7d582 | 105 | EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r |
0fdb42ac | 106 | EdkLog.log(this, EdkLog.EDK_INFO, this.fvInputFile.toFileList() \r |
107 | + " => " + this.fvOutputFile.toFileList());\r | |
ff225cbb | 108 | \r |
a15bb0d3 | 109 | revl = runner.execute();\r |
ff225cbb | 110 | \r |
a15bb0d3 | 111 | if (EFI_SUCCESS == revl) {\r |
112 | //\r | |
113 | // command execution success\r | |
114 | //\r | |
0fdb42ac | 115 | EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r |
a15bb0d3 | 116 | } else {\r |
117 | //\r | |
118 | // command execution fail\r | |
119 | //\r | |
91f7d582 | 120 | EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r |
0fdb42ac | 121 | throw new BuildException(toolName + " failed!");\r |
a15bb0d3 | 122 | }\r |
123 | } catch (Exception e) {\r | |
124 | throw new BuildException(e.getMessage());\r | |
125 | }\r | |
126 | }\r | |
127 | \r | |
128 | /**\r | |
0fdb42ac | 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 | |
a15bb0d3 | 135 | public String getfvInputFile() {\r |
0fdb42ac | 136 | return this.fvInputFile.getValue();\r |
a15bb0d3 | 137 | }\r |
138 | \r | |
139 | /**\r | |
0fdb42ac | 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 | |
a15bb0d3 | 147 | public void setFvInputFile(String inputFile) {\r |
0fdb42ac | 148 | this.fvInputFile.setArg(" ", inputFile);\r |
a15bb0d3 | 149 | }\r |
150 | \r | |
151 | /**\r | |
0fdb42ac | 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 | |
a15bb0d3 | 158 | public String getOutputFile() {\r |
0fdb42ac | 159 | return this.fvOutputFile.getValue();\r |
a15bb0d3 | 160 | }\r |
161 | \r | |
162 | /**\r | |
0fdb42ac | 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 | |
a15bb0d3 | 170 | public void setFvOutputFile(String outputFile) {\r |
0fdb42ac | 171 | this.fvOutputFile.setArg(" ", outputFile);\r |
a15bb0d3 | 172 | }\r |
173 | \r | |
174 | /**\r | |
0fdb42ac | 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 | |
a15bb0d3 | 181 | public String getOutputDir() {\r |
182 | return outputDir;\r | |
183 | }\r | |
184 | \r | |
185 | /**\r | |
0fdb42ac | 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 | |
a15bb0d3 | 193 | public void setOutputDir(String outputDir) {\r |
194 | this.outputDir = outputDir;\r | |
195 | }\r | |
196 | }\r |