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