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