]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/TianoTools/FlashMap/FlashMap.c
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@242 6f19259b...
[mirror_edk2.git] / Tools / Source / TianoTools / FlashMap / FlashMap.c
CommitLineData
d25c4bf0 1/*++\r
2\r
3Copyright (c) 2004-2005 Intel Corporation. All rights reserved\r
4This software and associated documentation (if any) is furnished\r
5under a license and may only be used or copied in accordance\r
6with the terms of the license. Except as permitted by such\r
7license, no part of this software or documentation may be\r
8reproduced, stored in a retrieval system, or transmitted in any\r
9form or by any means without the express written consent of\r
10Intel Corporation.\r
11\r
12Module Name:\r
13\r
14 FlashMap.c\r
15\r
16Abstract:\r
17\r
18 Utility for flash management in the Intel Platform Innovation Framework\r
19 for EFI build environment.\r
20\r
21--*/\r
22\r
23#include <stdio.h>\r
24#include <string.h>\r
25#include <stdlib.h>\r
26#include <ctype.h>\r
27\r
28#include "Tiano.h"\r
29\r
30#ifndef INT8\r
31#define INT8 char\r
32#endif\r
33\r
34#include "EfiUtilityMsgs.h"\r
35#include "Microcode.h"\r
36#include "FlashDefFile.h"\r
37#include "Symbols.h"\r
38\r
39#define UTILITY_NAME "FlashMap"\r
40\r
41typedef struct _STRING_LIST {\r
42 struct _STRING_LIST *Next;\r
43 char *Str;\r
44} STRING_LIST;\r
45\r
46//\r
47// Keep our globals in one of these structures\r
48//\r
49static struct {\r
50 char *CIncludeFileName;\r
51 char *FlashDevice;\r
52 char *FlashDeviceImage;\r
53 char *MCIFileName;\r
54 char *MCOFileName;\r
55 char *ImageOutFileName;\r
56 char *DscFileName;\r
57 char *AsmIncludeFileName;\r
58 char *FlashDefinitionFileName;\r
59 char *StringReplaceInFileName;\r
60 char *StringReplaceOutFileName;\r
61 char *DiscoverFDImageName;\r
62 char MicrocodePadByteValue;\r
63 unsigned int MicrocodeAlignment;\r
64 STRING_LIST *MCIFileNames;\r
65 STRING_LIST *LastMCIFileNames;\r
66 unsigned int BaseAddress;\r
67} mGlobals;\r
68\r
69#define DEFAULT_MC_PAD_BYTE_VALUE 0xFF\r
70#define DEFAULT_MC_ALIGNMENT 16\r
71\r
72static\r
73STATUS\r
74ProcessCommandLine (\r
75 int argc,\r
76 char *argv[]\r
77 );\r
78\r
79static\r
80STATUS\r
81MergeMicrocodeFiles (\r
82 char *OutFileName,\r
83 STRING_LIST *FileNames,\r
84 unsigned int Alignment,\r
85 char PadByteValue\r
86 );\r
87\r
88static\r
89void\r
90Usage (\r
91 VOID\r
92 );\r
93\r
94int\r
95main (\r
96 int argc,\r
97 char *argv[]\r
98 )\r
99/*++\r
100\r
101Routine Description:\r
102 Parse the command line arguments and then call worker functions to do the work\r
103 \r
104Arguments:\r
105 argc - number of elements in argv\r
106 argv - array of command-line arguments\r
107\r
108Returns:\r
109 STATUS_SUCCESS - no problems encountered while processing\r
110 STATUS_WARNING - warnings, but no errors, were encountered while processing\r
111 STATUS_ERROR - errors were encountered while processing\r
112 \r
113--*/\r
114{\r
115 STATUS Status;\r
116\r
117 SetUtilityName (UTILITY_NAME);\r
118 Status = ProcessCommandLine (argc, argv);\r
119 if (Status != STATUS_SUCCESS) {\r
120 return Status;\r
121 }\r
122 //\r
123 // Check for discovery of an FD (command line option)\r
124 //\r
125 if (mGlobals.DiscoverFDImageName != NULL) {\r
126 Status = FDDiscover (mGlobals.DiscoverFDImageName, mGlobals.BaseAddress);\r
127 goto Done;\r
128 }\r
129 //\r
130 // If they're doing microcode file parsing, then do that\r
131 //\r
132 if (mGlobals.MCIFileName != NULL) {\r
133 MicrocodeConstructor ();\r
134 MicrocodeParseFile (mGlobals.MCIFileName, mGlobals.MCOFileName);\r
135 MicrocodeDestructor ();\r
136 }\r
137 //\r
138 // If they're doing microcode file merging, then do that now\r
139 //\r
140 if (mGlobals.MCIFileNames != NULL) {\r
141 MergeMicrocodeFiles (\r
142 mGlobals.MCOFileName,\r
143 mGlobals.MCIFileNames,\r
144 mGlobals.MicrocodeAlignment,\r
145 mGlobals.MicrocodePadByteValue\r
146 );\r
147 }\r
148 //\r
149 // If using a flash definition file, then process that and return\r
150 //\r
151 if (mGlobals.FlashDefinitionFileName != NULL) {\r
152 FDFConstructor ();\r
153 SymbolsConstructor ();\r
154 Status = FDFParseFile (mGlobals.FlashDefinitionFileName);\r
155 if (GetUtilityStatus () != STATUS_ERROR) {\r
156 //\r
157 // If they want us to do a string-replace on a file, then add the symbol definitions to\r
158 // the symbol table, and then do the string replace.\r
159 //\r
160 if (mGlobals.StringReplaceInFileName != NULL) {\r
161 Status = FDFCreateSymbols (mGlobals.FlashDevice);\r
162 Status = SymbolsFileStringsReplace (mGlobals.StringReplaceInFileName, mGlobals.StringReplaceOutFileName);\r
163 }\r
164 //\r
165 // If they want us to create a .h defines file or .c flashmap data file, then do so now\r
166 //\r
167 if (mGlobals.CIncludeFileName != NULL) {\r
168 Status = FDFCreateCIncludeFile (mGlobals.FlashDevice, mGlobals.CIncludeFileName);\r
169 }\r
170 if (mGlobals.AsmIncludeFileName != NULL) {\r
171 Status = FDFCreateAsmIncludeFile (mGlobals.FlashDevice, mGlobals.AsmIncludeFileName);\r
172 }\r
173 //\r
174 // If they want us to create an image, do that now\r
175 //\r
176 if (mGlobals.ImageOutFileName != NULL) {\r
177 Status = FDFCreateImage (mGlobals.FlashDevice, mGlobals.FlashDeviceImage, mGlobals.ImageOutFileName);\r
178 }\r
179 //\r
180 // If they want to create an output DSC file, do that now\r
181 //\r
182 if (mGlobals.DscFileName != NULL) {\r
183 Status = FDFCreateDscFile (mGlobals.FlashDevice, mGlobals.DscFileName);\r
184 }\r
185 }\r
186 SymbolsDestructor ();\r
187 FDFDestructor ();\r
188 }\r
189Done:\r
190 //\r
191 // Free up memory\r
192 //\r
193 while (mGlobals.MCIFileNames != NULL) {\r
194 mGlobals.LastMCIFileNames = mGlobals.MCIFileNames->Next;\r
195 _free (mGlobals.MCIFileNames);\r
196 mGlobals.MCIFileNames = mGlobals.LastMCIFileNames;\r
197 }\r
198 return GetUtilityStatus ();\r
199}\r
200\r
201static\r
202STATUS\r
203MergeMicrocodeFiles (\r
204 char *OutFileName,\r
205 STRING_LIST *FileNames,\r
206 unsigned int Alignment,\r
207 char PadByteValue\r
208 )\r
209/*++\r
210\r
211Routine Description:\r
212\r
213 Merge binary microcode files into a single file, taking into consideration\r
214 the alignment and pad value.\r
215\r
216Arguments:\r
217\r
218 OutFileName - name of the output file to create\r
219 FileNames - linked list of input microcode files to merge\r
220 Alignment - alignment for each microcode file in the output image\r
221 PadByteValue - value to use when padding to meet alignment requirements\r
222\r
223Returns:\r
224\r
225 STATUS_SUCCESS - merge completed successfully or with acceptable warnings\r
226 STATUS_ERROR - merge failed, output file not created\r
227\r
228--*/\r
229{\r
230 long FileSize;\r
231 long TotalFileSize;\r
232 FILE *InFptr;\r
233 FILE *OutFptr;\r
234 char *Buffer;\r
235 STATUS Status;\r
236\r
237 //\r
238 // Open the output file\r
239 //\r
240 if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {\r
241 Error (NULL, 0, 0, OutFileName, "failed to open output file for writing");\r
242 return STATUS_ERROR;\r
243 }\r
244 //\r
245 // Walk the list of files\r
246 //\r
247 Status = STATUS_ERROR;\r
248 Buffer = NULL;\r
249 InFptr = NULL;\r
250 TotalFileSize = 0;\r
251 while (FileNames != NULL) {\r
252 //\r
253 // Open the file, determine the size, then read it in and write\r
254 // it back out.\r
255 //\r
256 if ((InFptr = fopen (FileNames->Str, "rb")) == NULL) {\r
257 Error (NULL, 0, 0, FileNames->Str, "failed to open input file for reading");\r
258 goto Done;\r
259 }\r
260 fseek (InFptr, 0, SEEK_END);\r
261 FileSize = ftell (InFptr);\r
262 fseek (InFptr, 0, SEEK_SET);\r
263 if (FileSize != 0) {\r
264 Buffer = (char *) _malloc (FileSize);\r
265 if (Buffer == NULL) {\r
266 Error (NULL, 0, 0, "memory allocation failure", NULL);\r
267 goto Done;\r
268 }\r
269 if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
270 Error (NULL, 0, 0, FileNames->Str, "failed to read file contents");\r
271 goto Done;\r
272 }\r
273 //\r
274 // Align\r
275 //\r
276 if (Alignment != 0) {\r
277 while ((TotalFileSize % Alignment) != 0) {\r
278 if (fwrite (&PadByteValue, 1, 1, OutFptr) != 1) {\r
279 Error (NULL, 0, 0, OutFileName, "failed to write pad bytes to output file");\r
280 goto Done;\r
281 }\r
282 TotalFileSize++;\r
283 }\r
284 }\r
285 TotalFileSize += FileSize;\r
286 if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {\r
287 Error (NULL, 0, 0, OutFileName, "failed to write to output file");\r
288 goto Done;\r
289 }\r
290 _free (Buffer);\r
291 Buffer = NULL;\r
292 } else {\r
293 Warning (NULL, 0, 0, FileNames->Str, "0-size file encountered");\r
294 }\r
295 fclose (InFptr);\r
296 InFptr = NULL;\r
297 FileNames = FileNames->Next;\r
298 }\r
299 Status = STATUS_SUCCESS;\r
300Done:\r
301 fclose (OutFptr);\r
302 if (InFptr != NULL) {\r
303 fclose (InFptr);\r
304 }\r
305 if (Buffer != NULL) {\r
306 _free (Buffer);\r
307 }\r
308 if (Status == STATUS_ERROR) {\r
309 remove (OutFileName);\r
310 }\r
311 return Status;\r
312}\r
313\r
314static\r
315STATUS\r
316ProcessCommandLine (\r
317 int argc,\r
318 char *argv[]\r
319 )\r
320/*++\r
321\r
322Routine Description:\r
323 Process the command line arguments\r
324 \r
325Arguments:\r
326 argc - Standard C entry point arguments\r
327 argv[] - Standard C entry point arguments\r
328\r
329Returns:\r
330 STATUS_SUCCESS - no problems encountered while processing\r
331 STATUS_WARNING - warnings, but no errors, were encountered while processing\r
332 STATUS_ERROR - errors were encountered while processing\r
333 \r
334--*/\r
335{\r
336 int ThingsToDo;\r
337 unsigned int Temp;\r
338 STRING_LIST *Str;\r
339 //\r
340 // Skip program name arg, process others\r
341 //\r
342 argc--;\r
343 argv++;\r
344 if (argc == 0) {\r
345 Usage ();\r
346 return STATUS_ERROR;\r
347 }\r
348 //\r
349 // Clear out our globals, then start walking the arguments\r
350 //\r
351 memset ((void *) &mGlobals, 0, sizeof (mGlobals));\r
352 mGlobals.MicrocodePadByteValue = DEFAULT_MC_PAD_BYTE_VALUE;\r
353 mGlobals.MicrocodeAlignment = DEFAULT_MC_ALIGNMENT;\r
354 ThingsToDo = 0;\r
355 while (argc > 0) {\r
356 if (strcmp (argv[0], "-?") == 0) {\r
357 Usage ();\r
358 return STATUS_ERROR;\r
359 } else if (strcmp (argv[0], "-hfile") == 0) {\r
360 //\r
361 // -hfile FileName\r
362 //\r
363 // Used to specify an output C #include file to create that contains\r
364 // #define statements for all the flashmap region offsets and sizes.\r
365 // Check for additional argument.\r
366 //\r
367 if (argc < 2) {\r
368 Error (NULL, 0, 0, argv[0], "option requires an output file name");\r
369 return STATUS_ERROR;\r
370 }\r
371 argc--;\r
372 argv++;\r
373 mGlobals.CIncludeFileName = argv[0];\r
374 ThingsToDo++;\r
375 } else if (strcmp (argv[0], "-flashdevice") == 0) {\r
376 //\r
377 // -flashdevice FLASH_DEVICE_NAME\r
378 //\r
379 // Used to select which flash device definition to operate on.\r
380 // Check for additional argument\r
381 //\r
382 if (argc < 2) {\r
383 Error (NULL, 0, 0, argv[0], "option requires a flash device name to use");\r
384 return STATUS_ERROR;\r
385 }\r
386 argc--;\r
387 argv++;\r
388 mGlobals.FlashDevice = argv[0];\r
389 } else if (strcmp (argv[0], "-mco") == 0) {\r
390 //\r
391 // -mco OutFileName\r
392 //\r
393 // Used to specify a microcode output binary file to create.\r
394 // Check for additional argument.\r
395 //\r
396 if (argc < 2) {\r
397 Error (NULL, 0, 0, (INT8 *) argv[0], (INT8 *) "option requires an output microcode file name to create");\r
398 return STATUS_ERROR;\r
399 }\r
400 argc--;\r
401 argv++;\r
402 mGlobals.MCOFileName = argv[0];\r
403 ThingsToDo++;\r
404 } else if (strcmp (argv[0], "-asmincfile") == 0) {\r
405 //\r
406 // -asmincfile FileName\r
407 //\r
408 // Used to specify the name of the output assembly include file that contains\r
409 // equates for the flash region addresses and sizes.\r
410 // Check for additional argument.\r
411 //\r
412 if (argc < 2) {\r
413 Error (NULL, 0, 0, argv[0], "option requires an output ASM include file name to create");\r
414 return STATUS_ERROR;\r
415 }\r
416 argc--;\r
417 argv++;\r
418 mGlobals.AsmIncludeFileName = argv[0];\r
419 ThingsToDo++;\r
420 } else if (strcmp (argv[0], "-mci") == 0) {\r
421 //\r
422 // -mci FileName\r
423 //\r
424 // Used to specify an input microcode text file to parse.\r
425 // Check for additional argument\r
426 //\r
427 if (argc < 2) {\r
428 Error (NULL, 0, 0, (INT8 *) argv[0], (INT8 *) "option requires an input microcode text file name to parse");\r
429 return STATUS_ERROR;\r
430 }\r
431 argc--;\r
432 argv++;\r
433 mGlobals.MCIFileName = argv[0];\r
434 } else if (strcmp (argv[0], "-flashdeviceimage") == 0) {\r
435 //\r
436 // -flashdeviceimage FlashDeviceImage\r
437 //\r
438 // Used to specify which flash device image definition from the input flash definition file\r
439 // to create.\r
440 // Check for additional argument.\r
441 //\r
442 if (argc < 2) {\r
443 Error (NULL, 0, 0, argv[0], "option requires the name of a flash definition image to use");\r
444 return STATUS_ERROR;\r
445 }\r
446 argc--;\r
447 argv++;\r
448 mGlobals.FlashDeviceImage = argv[0];\r
449 } else if (strcmp (argv[0], "-imageout") == 0) {\r
450 //\r
451 // -imageout FileName\r
452 //\r
453 // Used to specify the name of the output FD image file to create.\r
454 // Check for additional argument.\r
455 //\r
456 if (argc < 2) {\r
457 Error (NULL, 0, 0, argv[0], "option requires an output image filename to create");\r
458 return STATUS_ERROR;\r
459 }\r
460 argc--;\r
461 argv++;\r
462 mGlobals.ImageOutFileName = argv[0];\r
463 ThingsToDo++;\r
464 } else if (strcmp (argv[0], "-dsc") == 0) {\r
465 //\r
466 // -dsc FileName\r
467 //\r
468 // Used to specify the name of the output DSC file to create.\r
469 // Check for additional argument.\r
470 //\r
471 if (argc < 2) {\r
472 Error (NULL, 0, 0, argv[0], "option requires an output DSC filename to create");\r
473 return STATUS_ERROR;\r
474 }\r
475 argc--;\r
476 argv++;\r
477 mGlobals.DscFileName = argv[0];\r
478 ThingsToDo++;\r
479 } else if (strcmp (argv[0], "-fdf") == 0) {\r
480 //\r
481 // -fdf FileName\r
482 //\r
483 // Used to specify the name of the input flash definition file.\r
484 // Check for additional argument.\r
485 //\r
486 if (argc < 2) {\r
487 Error (NULL, 0, 0, argv[0], "option requires an input flash definition file name");\r
488 return STATUS_ERROR;\r
489 }\r
490 argc--;\r
491 argv++;\r
492 mGlobals.FlashDefinitionFileName = argv[0];\r
493 } else if (strcmp (argv[0], "-discover") == 0) {\r
494 //\r
495 // -discover FDFileName\r
496 //\r
497 // Debug functionality used to scan an existing FD image, trying to find\r
498 // firmware volumes at 64K boundaries.\r
499 // Check for additional argument.\r
500 //\r
501 if (argc < 2) {\r
502 Error (NULL, 0, 0, argv[0], "option requires an input FD image file name");\r
503 return STATUS_ERROR;\r
504 }\r
505 argc--;\r
506 argv++;\r
507 mGlobals.DiscoverFDImageName = argv[0];\r
508 ThingsToDo++;\r
509 } else if (strcmp (argv[0], "-baseaddr") == 0) {\r
510 //\r
511 // -baseaddr Addr\r
512 //\r
513 // Used to specify a base address when doing a discover of an FD image.\r
514 // Check for additional argument.\r
515 //\r
516 if (argc < 2) {\r
517 Error (NULL, 0, 0, argv[0], "option requires a base address");\r
518 return STATUS_ERROR;\r
519 }\r
520 argc--;\r
521 argv++;\r
522 if (tolower (argv[0][1]) == 'x') {\r
523 sscanf (argv[0] + 2, "%x", &mGlobals.BaseAddress);\r
524 } else {\r
525 sscanf (argv[0], "%d", &mGlobals.BaseAddress);\r
526 }\r
527 } else if (strcmp (argv[0], "-padvalue") == 0) {\r
528 //\r
529 // -padvalue Value\r
530 //\r
531 // Used to specify the value to pad with when aligning data while\r
532 // creating an FD image. Check for additional argument.\r
533 //\r
534 if (argc < 2) {\r
535 Error (NULL, 0, 0, argv[0], "option requires a byte value");\r
536 return STATUS_ERROR;\r
537 }\r
538 argc--;\r
539 argv++;\r
540 if (tolower (argv[0][1]) == 'x') {\r
541 sscanf (argv[0] + 2, "%x", &Temp);\r
542 mGlobals.MicrocodePadByteValue = (char) Temp;\r
543 } else {\r
544 sscanf (argv[0], "%d", &Temp);\r
545 mGlobals.MicrocodePadByteValue = (char) Temp;\r
546 }\r
547 } else if (strcmp (argv[0], "-align") == 0) {\r
548 //\r
549 // -align Alignment\r
550 //\r
551 // Used to specify how each data file is aligned in the region\r
552 // when creating an FD image. Check for additional argument.\r
553 //\r
554 if (argc < 2) {\r
555 Error (NULL, 0, 0, argv[0], "option requires an alignment");\r
556 return STATUS_ERROR;\r
557 }\r
558 argc--;\r
559 argv++;\r
560 if (tolower (argv[0][1]) == 'x') {\r
561 sscanf (argv[0] + 2, "%x", &mGlobals.MicrocodeAlignment);\r
562 } else {\r
563 sscanf (argv[0], "%d", &mGlobals.MicrocodeAlignment);\r
564 }\r
565 } else if (strcmp (argv[0], "-mcmerge") == 0) {\r
566 //\r
567 // -mcmerge FileName(s)\r
568 //\r
569 // Used to concatenate multiple microde binary files. Can specify\r
570 // multiple file names with the one -mcmerge flag. Check for additional argument.\r
571 //\r
572 if ((argc < 2) || (argv[1][0] == '-')) {\r
573 Error (NULL, 0, 0, argv[0], "option requires one or more input file names");\r
574 return STATUS_ERROR;\r
575 }\r
576 //\r
577 // Take input files until another option or end of list\r
578 //\r
579 ThingsToDo++;\r
580 while ((argc > 1) && (argv[1][0] != '-')) {\r
581 Str = (STRING_LIST *) _malloc (sizeof (STRING_LIST));\r
582 if (Str == NULL) {\r
583 Error (NULL, 0, 0, "memory allocation failure", NULL);\r
584 return STATUS_ERROR;\r
585 }\r
586 memset (Str, 0, sizeof (STRING_LIST));\r
587 Str->Str = argv[1];\r
588 if (mGlobals.MCIFileNames == NULL) {\r
589 mGlobals.MCIFileNames = Str;\r
590 } else {\r
591 mGlobals.LastMCIFileNames->Next = Str;\r
592 }\r
593 mGlobals.LastMCIFileNames = Str;\r
594 argc--;\r
595 argv++;\r
596 }\r
597 } else if (strcmp (argv[0], "-strsub") == 0) {\r
598 //\r
599 // -strsub SrcFile DestFile\r
600 //\r
601 // Used to perform string substitutions on a file, writing the result to a new\r
602 // file. Check for two additional arguments.\r
603 //\r
604 if (argc < 3) {\r
605 Error (NULL, 0, 0, argv[0], "option requires input and output file names for string substitution");\r
606 return STATUS_ERROR;\r
607 }\r
608 argc--;\r
609 argv++;\r
610 mGlobals.StringReplaceInFileName = argv[0];\r
611 argc--;\r
612 argv++;\r
613 mGlobals.StringReplaceOutFileName = argv[0];\r
614 ThingsToDo++;\r
615 } else {\r
616 Error (NULL, 0, 0, argv[0], "invalid option");\r
617 return STATUS_ERROR;\r
618 }\r
619 argc--;\r
620 argv++;\r
621 }\r
622 //\r
623 // If no outputs requested, then report an error\r
624 //\r
625 if (ThingsToDo == 0) {\r
626 Error (NULL, 0, 0, "nothing to do", NULL);\r
627 return STATUS_ERROR;\r
628 }\r
629 //\r
630 // If they want an asm file, #include file, or C file to be created, then they have to specify a\r
631 // flash device name and flash definition file name.\r
632 //\r
633 if ((mGlobals.CIncludeFileName != NULL) &&\r
634 ((mGlobals.FlashDevice == NULL) || (mGlobals.FlashDefinitionFileName == NULL))) {\r
635 Error (NULL, 0, 0, "must specify -flashdevice and -fdf with -hfile", NULL);\r
636 return STATUS_ERROR;\r
637 }\r
638 if ((mGlobals.AsmIncludeFileName != NULL) &&\r
639 ((mGlobals.FlashDevice == NULL) || (mGlobals.FlashDefinitionFileName == NULL))) {\r
640 Error (NULL, 0, 0, "must specify -flashdevice and -fdf with -asmincfile", NULL);\r
641 return STATUS_ERROR;\r
642 }\r
643 //\r
644 // If they want a dsc file to be created, then they have to specify a\r
645 // flash device name and a flash definition file name\r
646 //\r
647 if (mGlobals.DscFileName != NULL) {\r
648 if (mGlobals.FlashDevice == NULL) {\r
649 Error (NULL, 0, 0, "must specify -flashdevice with -dsc", NULL);\r
650 return STATUS_ERROR;\r
651 }\r
652 if (mGlobals.FlashDefinitionFileName == NULL) {\r
653 Error (NULL, 0, 0, "must specify -fdf with -dsc", NULL);\r
654 return STATUS_ERROR;\r
655 }\r
656 }\r
657 //\r
658 // If they specified an output microcode file name, then they have to specify an input\r
659 // file name, and vice versa.\r
660 //\r
661 if ((mGlobals.MCIFileName != NULL) && (mGlobals.MCOFileName == NULL)) {\r
662 Error (NULL, 0, 0, "must specify output microcode file name", NULL);\r
663 return STATUS_ERROR;\r
664 }\r
665 if ((mGlobals.MCOFileName != NULL) && (mGlobals.MCIFileName == NULL) && (mGlobals.MCIFileNames == NULL)) {\r
666 Error (NULL, 0, 0, "must specify input microcode file name", NULL);\r
667 return STATUS_ERROR;\r
668 }\r
669 //\r
670 // If doing merge, then have to specify output file name\r
671 //\r
672 if ((mGlobals.MCIFileNames != NULL) && (mGlobals.MCOFileName == NULL)) {\r
673 Error (NULL, 0, 0, "must specify output microcode file name", NULL);\r
674 return STATUS_ERROR;\r
675 }\r
676 //\r
677 // If they want an output image to be created, then they have to specify\r
678 // the flash device and the flash device image to use.\r
679 //\r
680 if (mGlobals.ImageOutFileName != NULL) {\r
681 if (mGlobals.FlashDevice == NULL) {\r
682 Error (NULL, 0, 0, "must specify -flashdevice with -imageout", NULL);\r
683 return STATUS_ERROR;\r
684 }\r
685 if (mGlobals.FlashDeviceImage == NULL) {\r
686 Error (NULL, 0, 0, "must specify -flashdeviceimage with -imageout", NULL);\r
687 return STATUS_ERROR;\r
688 }\r
689 if (mGlobals.FlashDefinitionFileName == NULL) {\r
690 Error (NULL, 0, 0, "must specify -c or -fdf with -imageout", NULL);\r
691 return STATUS_ERROR;\r
692 }\r
693 }\r
694 return STATUS_SUCCESS;\r
695}\r
696\r
697static\r
698void\r
699Usage (\r
700 VOID\r
701 )\r
702/*++\r
703\r
704Routine Description:\r
705 Print utility command line help\r
706 \r
707Arguments:\r
708 None\r
709\r
710Returns:\r
711 NA\r
712\r
713--*/\r
714{\r
715 int i;\r
716 char *Msg[] = {\r
717 "Usage: FlashTool -fdf FlashDefFile -flashdevice FlashDevice",\r
718 " -flashdeviceimage FlashDeviceImage -mci MCIFile -mco MCOFile",\r
719 " -discover FDImage -dsc DscFile -asmincfile AsmIncFile",\r
720 " -imageOut ImageOutFile -hfile HFile -strsub InStrFile OutStrFile",\r
721 " -baseaddr BaseAddr -align Alignment -padvalue PadValue",\r
722 " -mcmerge MCIFile(s)",\r
723 " where",\r
724 " FlashDefFile - input Flash Definition File",\r
725 " FlashDevice - flash device to use (from flash definition file)",\r
726 " FlashDeviceImage - flash device image to use (from flash definition file)",\r
727 " MCIFile - input microcode file to parse",\r
728 " MCOFile - output binary microcode image to create from MCIFile",\r
729 " HFile - output #include file to create",\r
730 " FDImage - name of input FDImage file to scan",\r
731 " ImageOutFile - output image file to create",\r
732 " DscFile - output DSC file to create",\r
733 " AsmIncFile - output ASM include file to create",\r
734 " InStrFile - input file to replace symbol names, writing result to OutStrFile",\r
735 " BaseAddr - base address of FDImage (used with -discover)",\r
736 " Alignment - alignment to use when merging microcode binaries",\r
737 " PadValue - byte value to use as pad value when aligning microcode binaries",\r
738 " MCIFile(s) - one or more microcode binary files to merge/concatenate",\r
739 "",\r
740 NULL\r
741 };\r
742 for (i = 0; Msg[i] != NULL; i++) {\r
743 fprintf (stdout, "%s\n", Msg[i]);\r
744 }\r
745}\r