]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java
Modify GenFfsTask to make it don't create ORG file.
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / FlashMapTask.java
CommitLineData
a15bb0d3 1/** @file\r
2 FlashMapTask class.\r
3\r
4 FlashMapTask is used to call FlashMap.exe to lay out the flash.\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
17package org.tianocore.framework.tasks;\r
18\r
19import java.io.File;\r
20import java.io.InputStreamReader;\r
21import java.util.ArrayList;\r
22import java.util.Iterator;\r
23import java.util.LinkedList;\r
24import java.util.List;\r
25\r
26import org.apache.tools.ant.Task;\r
27import org.apache.tools.ant.Project;\r
28import org.apache.tools.ant.BuildException;\r
ff225cbb 29\r
30import org.tianocore.common.logger.EdkLog;\r
a15bb0d3 31\r
32/**\r
219e2247 33 * FlashMapTask class.\r
ff225cbb 34 *\r
219e2247 35 * FlashMapTask is used to call FlashMap.exe to generate flash map defition files and fd files.\r
a15bb0d3 36 */\r
37public class FlashMapTask extends Task implements EfiDefine {\r
38 // /\r
39 // / tool name\r
40 // /\r
41 private final String toolName = "FlashMap";\r
42\r
43 // /\r
219e2247 44 // / Flash definition file\r
a15bb0d3 45 // /\r
46 private String flashDefFile = "";\r
47\r
48 // /\r
49 // / Flash device\r
50 // /\r
51 private String flashDevice = "";\r
52\r
53 // /\r
54 // / Flash device Image\r
55 // /\r
56 private String flashDeviceImage = "";\r
57\r
58 // /\r
59 // / MCI file\r
60 // /\r
61 private String mciFile = "";\r
62\r
63 // /\r
64 // / MCO file\r
65 // /\r
66 private String mcoFile = "";\r
67\r
68 // /\r
69 // / Discover FD image\r
70 // /\r
71 private String fdImage = "";\r
72\r
73 // /\r
74 // / Dsc file\r
75 // /\r
76 private String dscFile = "";\r
77\r
78 // /\r
79 // / Asm INC file\r
80 // /\r
81 private String asmIncFile = "";\r
82\r
83 // /\r
84 // / Image out file\r
85 // /\r
86 private String imageOutFile = "";\r
87\r
88 // /\r
89 // / Header file\r
90 // /\r
91 private String headerFile = "";\r
92\r
93 // /\r
94 // / Input string file\r
95 // /\r
96 private String inStrFile = "";\r
97\r
98 // /\r
99 // / Output string file\r
100 // /\r
101 private String outStrFile = "";\r
102\r
103 // /\r
104 // / Base address\r
105 // /\r
106 private String baseAddr = "";\r
107\r
108 // /\r
109 // / Aligment\r
110 // /\r
111 private String aligment = "";\r
112\r
113 // /\r
114 // / Padding value\r
115 // /\r
116 private String padValue = "";\r
117\r
118 // /\r
119 // / output directory\r
120 // /\r
57cc2ee7 121 private String outputDir = ".";\r
a15bb0d3 122\r
123 // /\r
124 // / MCI file array\r
125 // /\r
126 List<Input> mciFileArray = new ArrayList<Input>();\r
127\r
128 // /\r
129 // / command and argument list\r
130 // /\r
131 LinkedList<String> argList = new LinkedList<String>();\r
132\r
133 /**\r
134 * execute\r
ff225cbb 135 *\r
a15bb0d3 136 * FlashMapTask execute function is to assemble tool command line & execute\r
137 * tool command line\r
ff225cbb 138 *\r
a15bb0d3 139 * @throws BuidException\r
140 */\r
141 public void execute() throws BuildException {\r
142\r
143 Project project = this.getOwningTarget().getProject();\r
144 //\r
145 // set Logger\r
146 //\r
147 FrameworkLogger logger = new FrameworkLogger(project, "flashmap");\r
148 EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));\r
149 EdkLog.setLogger(logger);\r
150 //\r
151 // absolute path of efi tools\r
152 //\r
153 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
154 String command;\r
155 if (path == null) {\r
156 command = toolName;\r
157 } else {\r
158 command = path + File.separatorChar + toolName;\r
159 }\r
160 argList.addFirst(command);\r
161\r
162 //\r
163 // add substituted input file and output file\r
164 //\r
165 if (this.inStrFile != null && this.outStrFile != null\r
166 && !this.inStrFile.equalsIgnoreCase("")\r
167 && !this.inStrFile.equalsIgnoreCase("")) {\r
168 argList.add("-strsub");\r
169 argList.add(this.inStrFile);\r
170 argList.add(this.outStrFile);\r
171 }\r
ff225cbb 172\r
173\r
a15bb0d3 174 //\r
175 // add microcode binary files\r
176 //\r
177 if (mciFileArray.size() > 0) {\r
178 argList.add("-mcmerge");\r
179 Iterator mciList = mciFileArray.iterator();\r
180 while (mciList.hasNext()) {\r
181 argList.add(((Input) mciList.next()).getFile());\r
182 }\r
183 }\r
184\r
a15bb0d3 185 //\r
186 // lauch the program\r
187 //\r
188 ProcessBuilder pb = new ProcessBuilder(argList);\r
189 pb.directory(new File(outputDir));\r
190 int exitCode = 0;\r
191 try {\r
192 Process cmdProc = pb.start();\r
193 InputStreamReader cmdOut = new InputStreamReader(cmdProc\r
194 .getInputStream());\r
195 char[] buf = new char[1024];\r
196\r
197 exitCode = cmdProc.waitFor();\r
198 //\r
199 // log command line string.\r
200 //\r
219e2247 201 EdkLog.log(EdkLog.EDK_VERBOSE, cmdProc.getOutputStream().toString());\r
202 EdkLog.log(EdkLog.EDK_INFO, (new File(this.flashDefFile)).getName());\r
a15bb0d3 203 if (exitCode != 0) {\r
204 int len = cmdOut.read(buf, 0, 1024);\r
219e2247 205 EdkLog.log(EdkLog.EDK_INFO, new String(buf, 0, len));\r
a15bb0d3 206 } else {\r
219e2247 207 EdkLog.log(EdkLog.EDK_VERBOSE, "FlashMap succeeded!");\r
a15bb0d3 208 }\r
209 } catch (Exception e) {\r
210 throw new BuildException(e.getMessage());\r
211 } finally {\r
212 if (exitCode != 0) {\r
219e2247 213 throw new BuildException("FlashMap failed!");\r
a15bb0d3 214 }\r
215 }\r
216 }\r
217\r
218 /**\r
219 * getFlashDefFile\r
ff225cbb 220 *\r
a15bb0d3 221 * This function is to get class member "flashDefFile"\r
ff225cbb 222 *\r
a15bb0d3 223 * @return flashDeFile Name of flash definition file.\r
224 */\r
225 public String getFlashDefFile() {\r
226 return flashDefFile;\r
227 }\r
228\r
229 /**\r
230 * setFlashDefFile\r
ff225cbb 231 *\r
a15bb0d3 232 * This function is to set class member "flashDefFile"\r
ff225cbb 233 *\r
a15bb0d3 234 * @param flashDefFile\r
235 * Name of flash definition file.\r
236 */\r
237 public void setFlashDefFile(String flashDefFile) {\r
238 this.flashDefFile = flashDefFile;\r
239 argList.add("-fdf");\r
240 argList.add(this.flashDefFile);\r
241 }\r
242\r
243 /**\r
244 * getAligment\r
ff225cbb 245 *\r
a15bb0d3 246 * This function is to get class member "aligment"\r
ff225cbb 247 *\r
a15bb0d3 248 * @return aligment String of aligment value.\r
249 */\r
250 public String getAligment() {\r
251 return aligment;\r
252 }\r
253\r
254 /**\r
255 * setAligment\r
ff225cbb 256 *\r
a15bb0d3 257 * This function is to set class member "aligment"\r
ff225cbb 258 *\r
a15bb0d3 259 * @param aligment\r
260 * String of aligment value.\r
261 */\r
262 public void setAligment(String aligment) {\r
263 this.aligment = aligment;\r
264 argList.add("-align");\r
265 argList.add(this.aligment);\r
266 }\r
267\r
268 /**\r
269 * getAsmIncFile\r
ff225cbb 270 *\r
a15bb0d3 271 * This function is to get class member "asmIncFile"\r
ff225cbb 272 *\r
a15bb0d3 273 * @return asmIncFile String of ASM include file.\r
274 */\r
275 public String getAsmIncFile() {\r
276 return asmIncFile;\r
277 }\r
278\r
279 /**\r
280 * setAsmIncFile\r
ff225cbb 281 *\r
a15bb0d3 282 * This function is to set class member "asmIncFile"\r
ff225cbb 283 *\r
a15bb0d3 284 * @param asmIncFile\r
285 * String of ASM include file.\r
286 */\r
287 public void setAsmIncFile(String asmIncFile) {\r
288 this.asmIncFile = asmIncFile;\r
289 argList.add("-asmincfile");\r
290 argList.add(this.asmIncFile);\r
291 }\r
292\r
293 /**\r
294 * getBaseAddr\r
ff225cbb 295 *\r
a15bb0d3 296 * This function is to get class member "baseAddr"\r
ff225cbb 297 *\r
a15bb0d3 298 * @return baseAddr String of base address value.\r
299 */\r
300 public String getBaseAddr() {\r
301 return baseAddr;\r
302 }\r
303\r
304 /**\r
305 * setBaseAddr\r
ff225cbb 306 *\r
a15bb0d3 307 * This function is to set class member "baseAddr"\r
ff225cbb 308 *\r
a15bb0d3 309 * @param baseAddr\r
310 * String of base address value.\r
311 */\r
312 public void setBaseAddr(String baseAddr) {\r
313 this.baseAddr = baseAddr;\r
314 argList.add("-baseaddr");\r
315 argList.add(this.baseAddr);\r
316 }\r
317\r
318 /**\r
319 * getDscFile\r
ff225cbb 320 *\r
a15bb0d3 321 * This function is to get class member "dscFile"\r
ff225cbb 322 *\r
a15bb0d3 323 * @return dscFile name of DSC file\r
324 */\r
325 public String getDscFile() {\r
326 return dscFile;\r
327 }\r
328\r
329 /**\r
330 * setDscFile\r
ff225cbb 331 *\r
a15bb0d3 332 * This function is to set class member "dscFile"\r
ff225cbb 333 *\r
a15bb0d3 334 * @param dscFile\r
335 * name of DSC file\r
336 */\r
337 public void setDscFile(String dscFile) {\r
338 this.dscFile = dscFile;\r
339 argList.add("-dsc");\r
340 argList.add(this.dscFile);\r
341 }\r
342\r
343 /**\r
344 * getFdImage\r
ff225cbb 345 *\r
a15bb0d3 346 * This function is to get class member "fdImage"\r
ff225cbb 347 *\r
a15bb0d3 348 * @return fdImage name of input FDI image file.\r
349 */\r
350 public String getFdImage() {\r
351 return fdImage;\r
352 }\r
353\r
354 /**\r
355 * setFdImage\r
ff225cbb 356 *\r
a15bb0d3 357 * This function is to set class member "fdImage"\r
ff225cbb 358 *\r
a15bb0d3 359 * @param fdImage\r
360 * name of input FDI image file.\r
361 */\r
362 public void setFdImage(String fdImage) {\r
363 this.fdImage = fdImage;\r
364 argList.add("-discover");\r
365 argList.add(this.fdImage);\r
366 }\r
367\r
368 /**\r
369 * getFlashDevice\r
ff225cbb 370 *\r
a15bb0d3 371 * This function is to get class member "flashDevice".\r
ff225cbb 372 *\r
a15bb0d3 373 * @return flashDevice name of flash device.\r
374 */\r
375 public String getFlashDevice() {\r
376 return flashDevice;\r
377 }\r
378\r
379 /**\r
380 * setFlashDevice\r
ff225cbb 381 *\r
a15bb0d3 382 * This function is to set class member "flashDevice"\r
ff225cbb 383 *\r
a15bb0d3 384 * @param flashDevice\r
385 * name of flash device.\r
386 */\r
387 public void setFlashDevice(String flashDevice) {\r
388 this.flashDevice = flashDevice;\r
389 argList.add("-flashdevice");\r
390 argList.add(this.flashDevice);\r
391 }\r
392\r
393 /**\r
394 * getFlashDeviceImage\r
ff225cbb 395 *\r
a15bb0d3 396 * This function is to get class member "flashDeviceImage"\r
ff225cbb 397 *\r
a15bb0d3 398 * @return flashDeviceImage name of flash device image\r
399 */\r
400 public String getFlashDeviceImage() {\r
401 return flashDeviceImage;\r
402 }\r
403\r
404 /**\r
405 * setFlashDeviceImage\r
ff225cbb 406 *\r
a15bb0d3 407 * This function is to set class member "flashDeviceImage"\r
ff225cbb 408 *\r
a15bb0d3 409 * @param flashDeviceImage\r
410 * name of flash device image\r
411 */\r
412 public void setFlashDeviceImage(String flashDeviceImage) {\r
413 this.flashDeviceImage = flashDeviceImage;\r
414 argList.add("-flashdeviceimage");\r
415 argList.add(this.flashDeviceImage);\r
416\r
417 }\r
418\r
419 /**\r
420 * getHeaderFile\r
ff225cbb 421 *\r
a15bb0d3 422 * This function is to get class member "headerFile"\r
ff225cbb 423 *\r
a15bb0d3 424 * @return headerFile name of include file\r
425 */\r
426 public String getHeaderFile() {\r
427 return headerFile;\r
428 }\r
429\r
430 /**\r
431 * setHeaderFile\r
ff225cbb 432 *\r
a15bb0d3 433 * This function is to set class member "headerFile"\r
ff225cbb 434 *\r
a15bb0d3 435 * @param headerFile\r
436 * name of include file\r
437 */\r
438 public void setHeaderFile(String headerFile) {\r
439 this.headerFile = headerFile;\r
440 argList.add("-hfile");\r
441 argList.add(this.headerFile);\r
442 }\r
443\r
444 /**\r
445 * getImageOutFile\r
ff225cbb 446 *\r
a15bb0d3 447 * This function is to get class member "imageOutFile"\r
ff225cbb 448 *\r
a15bb0d3 449 * @return imageOutFile name of output image file\r
450 */\r
451 public String getImageOutFile() {\r
452 return imageOutFile;\r
453 }\r
454\r
455 /**\r
456 * setImageOutFile\r
ff225cbb 457 *\r
a15bb0d3 458 * This function is to set class member "ImageOutFile"\r
ff225cbb 459 *\r
a15bb0d3 460 * @param imageOutFile\r
461 * name of output image file\r
462 */\r
463 public void setImageOutFile(String imageOutFile) {\r
464 this.imageOutFile = imageOutFile;\r
465 argList.add("-imageout");\r
466 argList.add(this.imageOutFile);\r
467 }\r
468\r
469 /**\r
470 * getInStrFile\r
ff225cbb 471 *\r
a15bb0d3 472 * This function is to get class member "inStrFile"\r
ff225cbb 473 *\r
a15bb0d3 474 * @return inStrFile name of input file which used to replace symbol names.\r
475 */\r
476 public String getInStrFile() {\r
477 return inStrFile;\r
478 }\r
479\r
480 /**\r
481 * setInStrFile\r
ff225cbb 482 *\r
a15bb0d3 483 * This function is to set class member "inStrFile"\r
ff225cbb 484 *\r
a15bb0d3 485 * @param inStrFile\r
486 * name of input file which used to replace symbol names.\r
487 */\r
488 public void setInStrFile(String inStrFile) {\r
489 this.inStrFile = inStrFile;\r
490 }\r
491\r
492 /**\r
493 * getMciFile\r
ff225cbb 494 *\r
a15bb0d3 495 * This function is to get class member "mciFile"\r
ff225cbb 496 *\r
a15bb0d3 497 * @return mciFile name of input microcode file\r
498 */\r
499 public String getMciFile() {\r
500 return mciFile;\r
501 }\r
502\r
503 /**\r
504 * setMciFile\r
ff225cbb 505 *\r
a15bb0d3 506 * This function is to set class member "mciFile"\r
ff225cbb 507 *\r
a15bb0d3 508 * @param mciFile\r
509 * name of input microcode file\r
510 */\r
511 public void setMciFile(String mciFile) {\r
512 this.mciFile = mciFile;\r
513 argList.add("-mci");\r
514 argList.add(this.mciFile);\r
515 }\r
516\r
517 /**\r
518 * getMcoFile\r
ff225cbb 519 *\r
a15bb0d3 520 * This function is to get class member "mcoFile"\r
ff225cbb 521 *\r
a15bb0d3 522 * @return mcoFile name of output binary microcode image\r
523 */\r
524 public String getMcoFile() {\r
525 return mcoFile;\r
526 }\r
527\r
528 /**\r
529 * setMcoFile\r
ff225cbb 530 *\r
a15bb0d3 531 * This function is to set class member "mcoFile"\r
ff225cbb 532 *\r
a15bb0d3 533 * @param mcoFile\r
534 * name of output binary microcode image\r
535 */\r
536 public void setMcoFile(String mcoFile) {\r
537 this.mcoFile = mcoFile;\r
538 argList.add("-mco");\r
539 argList.add(this.mcoFile);\r
540 }\r
541\r
542 /**\r
543 * getOutStrFile\r
ff225cbb 544 *\r
a15bb0d3 545 * This function is to get class member "outStrFile"\r
ff225cbb 546 *\r
a15bb0d3 547 * @return outStrFile name of output string substitution file\r
548 */\r
549 public String getOutStrFile() {\r
550 return outStrFile;\r
551 }\r
552\r
553 /**\r
554 * setOutStrFile\r
ff225cbb 555 *\r
a15bb0d3 556 * This function is to set class member "outStrFile"\r
ff225cbb 557 *\r
a15bb0d3 558 * @param outStrFile\r
559 * name of output string substitution file\r
560 */\r
561 public void setOutStrFile(String outStrFile) {\r
562 this.outStrFile = outStrFile;\r
563 }\r
564\r
565 /**\r
566 * getPadValue\r
ff225cbb 567 *\r
a15bb0d3 568 * This function is to get class member "padValue"\r
ff225cbb 569 *\r
a15bb0d3 570 * @return padValue string of byte value to use as padding\r
571 */\r
572 public String getPadValue() {\r
573 return padValue;\r
574 }\r
575\r
576 /**\r
577 * setPadValue\r
ff225cbb 578 *\r
a15bb0d3 579 * This function is to set class member "padValue"\r
ff225cbb 580 *\r
a15bb0d3 581 * @param padValue\r
582 * string of byte value to use as padding\r
583 */\r
584 public void setPadValue(String padValue) {\r
585 this.padValue = padValue;\r
586 argList.add("-padvalue");\r
587 argList.add(this.padValue);\r
588 }\r
589\r
590 /**\r
591 * addMciFile\r
ff225cbb 592 *\r
a15bb0d3 593 * This function is to add Microcode binary file\r
ff225cbb 594 *\r
a15bb0d3 595 * @param mciFile\r
596 * instance of input class\r
597 */\r
598 public void addMciFile(Input mciFile) {\r
599 this.mciFileArray.add(mciFile);\r
600 }\r
601\r
602 /**\r
603 * getOutputDir\r
ff225cbb 604 *\r
a15bb0d3 605 * This function is to get class member "outputDir"\r
ff225cbb 606 *\r
a15bb0d3 607 * @return outputDir string of output directory\r
608 */\r
609 public String getOutputDir() {\r
610 return outputDir;\r
611 }\r
612\r
613 /**\r
614 * setOutputDir\r
ff225cbb 615 *\r
a15bb0d3 616 * This function is to set class member "outputDir"\r
ff225cbb 617 *\r
a15bb0d3 618 * @param outputDir\r
619 * string of output directory\r
620 */\r
621 public void setOutputDir(String outputDir) {\r
622 this.outputDir = outputDir;\r
623 }\r
624}\r