]>
Commit | Line | Data |
---|---|---|
a15bb0d3 | 1 | /** @file\r |
2 | PeiReBaseTask class.\r | |
3 | \r | |
4 | PeiReBaseTask is used to call PeiReBase.exe to rebase efi fv file.\r | |
ff225cbb | 5 | \r |
6 | \r | |
a15bb0d3 | 7 | Copyright (c) 2006, Intel Corporation\r |
8 | All rights reserved. This program and the accompanying materials\r | |
9 | are licensed and made available under the terms and conditions of the BSD License\r | |
10 | which accompanies this distribution. The full text of the license may be found at\r | |
11 | http://opensource.org/licenses/bsd-license.php\r | |
ff225cbb | 12 | \r |
a15bb0d3 | 13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
15 | \r | |
16 | **/\r | |
17 | package org.tianocore.framework.tasks;\r | |
18 | \r | |
19 | import java.io.File;\r | |
20 | \r | |
21 | import org.apache.tools.ant.Task;\r | |
22 | import org.apache.tools.ant.Project;\r | |
23 | import org.apache.tools.ant.BuildException;\r | |
24 | import org.apache.tools.ant.taskdefs.Execute;\r | |
25 | import org.apache.tools.ant.taskdefs.LogStreamHandler;\r | |
26 | import org.apache.tools.ant.types.Commandline;\r | |
ff225cbb | 27 | \r |
28 | import org.tianocore.common.logger.EdkLog;\r | |
a15bb0d3 | 29 | \r |
30 | /**\r | |
31 | PeiReBaseTask class.\r | |
32 | \r | |
33 | PeiReBaseTask is used to call PeiReBase.exe to rebase efi fv file.\r | |
34 | **/\r | |
35 | public class PeiReBaseTask extends Task implements EfiDefine {\r | |
93f5dd0a | 36 | //\r |
37 | // tool name\r | |
38 | //\r | |
a15bb0d3 | 39 | private String toolName = "PeiReBase";\r |
93f5dd0a | 40 | //\r |
41 | // Input file\r | |
42 | //\r | |
43 | private FileArg inputFile = new FileArg();\r | |
44 | //\r | |
45 | // Output file\r | |
46 | //\r | |
47 | private FileArg outputFile = new FileArg();\r | |
48 | //\r | |
49 | // Base address\r | |
50 | //\r | |
51 | private ToolArg baseAddr = new ToolArg();\r | |
52 | //\r | |
53 | // \r | |
54 | // \r | |
55 | private FileArg mapFile = new FileArg();\r | |
56 | //\r | |
57 | // Architecture\r | |
58 | //\r | |
59 | private String arch = "IA32";\r | |
ff225cbb | 60 | \r |
a15bb0d3 | 61 | /**\r |
93f5dd0a | 62 | execute\r |
63 | \r | |
64 | PeiReBaseTask execute function is to assemble tool command line & execute\r | |
65 | tool command line\r | |
66 | \r | |
67 | @throws BuidException\r | |
68 | **/\r | |
a15bb0d3 | 69 | public void execute() throws BuildException {\r |
70 | \r | |
71 | Project project = this.getOwningTarget().getProject();\r | |
ff225cbb | 72 | \r |
a15bb0d3 | 73 | //\r |
74 | // absolute path of efi tools\r | |
75 | //\r | |
76 | String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r | |
77 | String command;\r | |
78 | String argument;\r | |
79 | if (this.arch.equalsIgnoreCase("IA32")){\r | |
80 | command = toolName + "_IA32";\r | |
93f5dd0a | 81 | } else if (this.arch.equalsIgnoreCase("X64")){\r |
a15bb0d3 | 82 | command = toolName + "_X64";\r |
93f5dd0a | 83 | } else if (this.arch.equalsIgnoreCase("IPF")){\r |
a15bb0d3 | 84 | command = toolName + "_IPF";\r |
93f5dd0a | 85 | } else {\r |
a15bb0d3 | 86 | command = toolName + "_IA32";\r |
87 | }\r | |
88 | if (path != null) {\r | |
93f5dd0a | 89 | command = path + File.separator + command;\r |
a15bb0d3 | 90 | }\r |
ff225cbb | 91 | \r |
a15bb0d3 | 92 | //\r |
93 | // argument of tools\r | |
94 | //\r | |
93f5dd0a | 95 | if (mapFile.getValue().length() == 0) {\r |
96 | mapFile.setArg(" -M ", outputFile.getValue() + ".map");\r | |
a15bb0d3 | 97 | }\r |
93f5dd0a | 98 | argument = "" + inputFile + outputFile + baseAddr + mapFile;\r |
ff225cbb | 99 | \r |
a15bb0d3 | 100 | //\r |
101 | // return value of fwimage execution\r | |
102 | //\r | |
103 | int revl = -1;\r | |
104 | \r | |
105 | try {\r | |
106 | Commandline cmdline = new Commandline();\r | |
107 | cmdline.setExecutable(command);\r | |
108 | cmdline.createArgument().setLine(argument);\r | |
109 | \r | |
110 | LogStreamHandler streamHandler = new LogStreamHandler(this,\r | |
111 | Project.MSG_INFO, Project.MSG_WARN);\r | |
112 | Execute runner = new Execute(streamHandler, null);\r | |
113 | \r | |
114 | runner.setAntRun(project);\r | |
115 | runner.setCommandline(cmdline.getCommandline());\r | |
116 | //\r | |
117 | // Set debug log information.\r | |
118 | //\r | |
91f7d582 | 119 | EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r |
93f5dd0a | 120 | EdkLog.log(this, EdkLog.EDK_INFO, inputFile.toFileList() + " => " \r |
121 | + outputFile.toFileList()\r | |
122 | + mapFile.toFileList());\r | |
ff225cbb | 123 | \r |
a15bb0d3 | 124 | revl = runner.execute();\r |
ff225cbb | 125 | \r |
a15bb0d3 | 126 | if (EFI_SUCCESS == revl) {\r |
127 | //\r | |
128 | // command execution success\r | |
129 | //\r | |
91f7d582 | 130 | EdkLog.log(this, EdkLog.EDK_VERBOSE, "PeiReBase succeeded!");\r |
a15bb0d3 | 131 | } else {\r |
132 | //\r | |
133 | // command execution fail\r | |
134 | //\r | |
91f7d582 | 135 | EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r |
219e2247 | 136 | throw new BuildException("PeiReBase failed!");\r |
a15bb0d3 | 137 | }\r |
138 | } catch (Exception e) {\r | |
139 | throw new BuildException(e.getMessage());\r | |
140 | }\r | |
141 | }\r | |
142 | \r | |
143 | /**\r | |
93f5dd0a | 144 | getInputFile\r |
145 | \r | |
146 | This function is to get class member "inputFile".\r | |
147 | \r | |
148 | @return string of input file name.\r | |
149 | **/\r | |
a15bb0d3 | 150 | public String getInputFile() {\r |
93f5dd0a | 151 | return inputFile.getValue();\r |
a15bb0d3 | 152 | }\r |
153 | \r | |
154 | /**\r | |
93f5dd0a | 155 | setComponentType\r |
156 | \r | |
157 | This function is to set class member "inputFile".\r | |
158 | \r | |
159 | @param inputFile\r | |
160 | string of input file name.\r | |
161 | **/\r | |
a15bb0d3 | 162 | public void setInputFile(String inputFile) {\r |
93f5dd0a | 163 | this.inputFile.setArg(" -I ", inputFile);\r |
a15bb0d3 | 164 | }\r |
165 | \r | |
166 | /**\r | |
93f5dd0a | 167 | getOutputFile\r |
168 | \r | |
169 | This function is to get class member "outputFile"\r | |
170 | \r | |
171 | @return outputFile string of output file name.\r | |
172 | **/\r | |
a15bb0d3 | 173 | public String getOutputFile() {\r |
93f5dd0a | 174 | return outputFile.getValue();\r |
a15bb0d3 | 175 | }\r |
176 | \r | |
177 | /**\r | |
93f5dd0a | 178 | setOutputFile\r |
179 | \r | |
180 | This function is to set class member "outputFile"\r | |
181 | \r | |
182 | @param outputFile\r | |
183 | string of output file name.\r | |
184 | **/\r | |
a15bb0d3 | 185 | public void setOutputFile(String outputFile) {\r |
93f5dd0a | 186 | this.outputFile.setArg(" -O ", outputFile);\r |
a15bb0d3 | 187 | }\r |
188 | \r | |
189 | /**\r | |
93f5dd0a | 190 | getBaseAddr\r |
191 | \r | |
192 | This function is to get class member "baseAddr"\r | |
193 | \r | |
194 | @return baseAddr string of base address.\r | |
195 | **/\r | |
a15bb0d3 | 196 | public String getBaseAddr() {\r |
93f5dd0a | 197 | return baseAddr.getValue();\r |
a15bb0d3 | 198 | }\r |
199 | \r | |
200 | /**\r | |
93f5dd0a | 201 | setBaseAddr\r |
202 | \r | |
203 | This function is to set class member "baseAddr"\r | |
204 | \r | |
205 | @param baseAddr string of base address\r | |
206 | **/\r | |
a15bb0d3 | 207 | public void setBaseAddr(String baseAddr) {\r |
93f5dd0a | 208 | this.baseAddr.setArg(" -B ", baseAddr);\r |
a15bb0d3 | 209 | }\r |
210 | \r | |
211 | /**\r | |
93f5dd0a | 212 | getArch\r |
213 | \r | |
214 | This function is to get class member "arch".\r | |
215 | \r | |
216 | @return arch Architecture\r | |
217 | **/\r | |
a15bb0d3 | 218 | public String getArch() {\r |
219 | return arch;\r | |
220 | }\r | |
221 | \r | |
222 | /**\r | |
93f5dd0a | 223 | setArch\r |
224 | \r | |
225 | This function is to set class member "arch"\r | |
226 | \r | |
227 | @param arch Architecture\r | |
228 | **/\r | |
a15bb0d3 | 229 | public void setArch(String arch) {\r |
230 | this.arch = arch;\r | |
231 | }\r | |
93f5dd0a | 232 | \r |
233 | /**\r | |
234 | Get the value of map file\r | |
235 | \r | |
236 | @return String The map file path\r | |
237 | **/\r | |
238 | public String getMapFile() {\r | |
239 | return mapFile.getValue();\r | |
240 | }\r | |
241 | \r | |
242 | /**\r | |
243 | Set "-M MapFile" argument\r | |
244 | \r | |
245 | @param mapFile The path of map file\r | |
246 | **/\r | |
247 | public void setMapFile(String mapFile) {\r | |
248 | this.mapFile.setArg(" -M ", mapFile);\r | |
249 | }\r | |
a15bb0d3 | 250 | }\r |