aslmain.c revision 1.1 1
2 /******************************************************************************
3 *
4 * Module Name: aslmain - compiler main and utilities
5 *
6 *****************************************************************************/
7
8 /******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117
118 #define _DECLARE_GLOBALS
119
120 #include "aslcompiler.h"
121 #include "acapps.h"
122
123 #ifdef _DEBUG
124 #include <crtdbg.h>
125 #endif
126
127 #define _COMPONENT ACPI_COMPILER
128 ACPI_MODULE_NAME ("aslmain")
129
130 /* Local prototypes */
131
132 static void
133 Options (
134 void);
135
136 static void
137 HelpMessage (
138 void);
139
140 static void
141 Usage (
142 void);
143
144 static void
145 AslInitialize (
146 void);
147
148 static int
149 AslCommandLine (
150 int argc,
151 char **argv);
152
153 static int
154 AslDoOptions (
155 int argc,
156 char **argv,
157 BOOLEAN IsResponseFile);
158
159 static void
160 AslMergeOptionTokens (
161 char *InBuffer,
162 char *OutBuffer);
163
164 static int
165 AslDoResponseFile (
166 char *Filename);
167
168
169 #define ASL_TOKEN_SEPARATORS " \t\n"
170 #define ASL_SUPPORTED_OPTIONS "@:2b:c:d^e:fgh^i^I:l^no:p:r:s:t:v:w:x:yz"
171
172
173 /*******************************************************************************
174 *
175 * FUNCTION: Options
176 *
177 * PARAMETERS: None
178 *
179 * RETURN: None
180 *
181 * DESCRIPTION: Display option help message
182 *
183 ******************************************************************************/
184
185 static void
186 Options (
187 void)
188 {
189
190 printf ("Global:\n");
191 printf (" -@<file> Specify command file\n");
192 printf (" -I<dir> Specify additional include directory\n");
193
194 printf ("\nGeneral Output:\n");
195 printf (" -p<prefix> Specify path/filename prefix for all output files\n");
196 printf (" -va Disable all errors and warnings (summary only)\n");
197 printf (" -vi Less verbose errors and warnings for use with IDEs\n");
198 printf (" -vo Enable optimization comments\n");
199 printf (" -vr Disable remarks\n");
200 printf (" -vs Disable signon\n");
201 printf (" -w<1|2|3> Set warning reporting level\n");
202
203 printf ("\nAML Output Files:\n");
204 printf (" -s<a|c> Create AML in assembler or C source file (*.asm or *.c)\n");
205 printf (" -i<a|c> Create assembler or C include file (*.inc or *.h)\n");
206 printf (" -t<a|c|s> Create AML in assembler, C, or ASL hex table (*.hex)\n");
207
208 printf ("\nAML Code Generation:\n");
209 printf (" -oa Disable all optimizations (compatibility mode)\n");
210 printf (" -of Disable constant folding\n");
211 printf (" -oi Disable integer optimization to Zero/One/Ones\n");
212 printf (" -on Disable named reference string optimization\n");
213 printf (" -cr Disable Resource Descriptor error checking\n");
214 printf (" -r<Revision> Override table header Revision (1-255)\n");
215
216 printf ("\nListings:\n");
217 printf (" -l Create mixed listing file (ASL source and AML) (*.lst)\n");
218 printf (" -ln Create namespace file (*.nsp)\n");
219 printf (" -ls Create combined source file (expanded includes) (*.src)\n");
220
221 printf ("\nAML Disassembler:\n");
222 printf (" -d [file] Disassemble or decode binary ACPI table to file (*.dsl)\n");
223 printf (" -dc [file] Disassemble AML and immediately compile it\n");
224 printf (" (Obtain DSDT from current system if no input file)\n");
225 printf (" -e [f1,f2] Include ACPI table(s) for external symbol resolution\n");
226 printf (" -2 Emit ACPI 2.0 compatible ASL code\n");
227 printf (" -g Get ACPI tables and write to files (*.dat)\n");
228
229 printf ("\nHelp:\n");
230 printf (" -h Additional help and compiler debug options\n");
231 printf (" -hc Display operators allowed in constant expressions\n");
232 printf (" -hr Display ACPI reserved method names\n");
233 }
234
235
236 /*******************************************************************************
237 *
238 * FUNCTION: HelpMessage
239 *
240 * PARAMETERS: None
241 *
242 * RETURN: None
243 *
244 * DESCRIPTION: Display help message
245 *
246 ******************************************************************************/
247
248 static void
249 HelpMessage (
250 void)
251 {
252
253 printf ("AML output filename generation:\n");
254 printf (" Output filenames are generated by appending an extension to a common\n");
255 printf (" filename prefix. The filename prefix is obtained via one of the\n");
256 printf (" following methods (in priority order):\n");
257 printf (" 1) The -p option specifies the prefix\n");
258 printf (" 2) The prefix of the AMLFileName in the ASL Definition Block\n");
259 printf (" 3) The prefix of the input filename\n");
260 printf ("\n");
261
262 Options ();
263
264 printf ("\nCompiler/Disassembler Debug Options:\n");
265 printf (" -b<p|t|b> Create compiler debug/trace file (*.txt)\n");
266 printf (" Types: Parse/Tree/Both\n");
267 printf (" -f Ignore errors, force creation of AML output file(s)\n");
268 printf (" -n Parse only, no output generation\n");
269 printf (" -ot Display compile times\n");
270 printf (" -x<level> Set debug level for trace output\n");
271 printf (" -y Temporary: Enable data table compiler\n");
272 printf (" -z Do not insert new compiler ID for DataTables\n");
273 }
274
275
276 /*******************************************************************************
277 *
278 * FUNCTION: Usage
279 *
280 * PARAMETERS: None
281 *
282 * RETURN: None
283 *
284 * DESCRIPTION: Display usage and option message
285 *
286 ******************************************************************************/
287
288 static void
289 Usage (
290 void)
291 {
292
293 printf ("Usage: %s [Options] [Files]\n\n", CompilerName);
294 Options ();
295 }
296
297
298 /*******************************************************************************
299 *
300 * FUNCTION: AslInitialize
301 *
302 * PARAMETERS: None
303 *
304 * RETURN: None
305 *
306 * DESCRIPTION: Initialize compiler globals
307 *
308 ******************************************************************************/
309
310 static void
311 AslInitialize (
312 void)
313 {
314 UINT32 i;
315
316
317 #ifdef _DEBUG
318 _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0));
319 #endif
320
321 AcpiDbgLevel = 0;
322
323 for (i = 0; i < ASL_NUM_FILES; i++)
324 {
325 Gbl_Files[i].Handle = NULL;
326 Gbl_Files[i].Filename = NULL;
327 }
328
329 Gbl_Files[ASL_FILE_STDOUT].Handle = stdout;
330 Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT";
331
332 Gbl_Files[ASL_FILE_STDERR].Handle = stderr;
333 Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR";
334 }
335
336
337 /*******************************************************************************
338 *
339 * FUNCTION: AslMergeOptionTokens
340 *
341 * PARAMETERS: InBuffer - Input containing an option string
342 * OutBuffer - Merged output buffer
343 *
344 * RETURN: None
345 *
346 * DESCRIPTION: Remove all whitespace from an option string.
347 *
348 ******************************************************************************/
349
350 static void
351 AslMergeOptionTokens (
352 char *InBuffer,
353 char *OutBuffer)
354 {
355 char *Token;
356
357
358 *OutBuffer = 0;
359
360 Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS);
361 while (Token)
362 {
363 strcat (OutBuffer, Token);
364 Token = strtok (NULL, ASL_TOKEN_SEPARATORS);
365 }
366 }
367
368
369 /*******************************************************************************
370 *
371 * FUNCTION: AslDoResponseFile
372 *
373 * PARAMETERS: Filename - Name of the response file
374 *
375 * RETURN: Status
376 *
377 * DESCRIPTION: Open a response file and process all options within.
378 *
379 ******************************************************************************/
380
381 static int
382 AslDoResponseFile (
383 char *Filename)
384 {
385 char *argv = StringBuffer2;
386 FILE *ResponseFile;
387 int OptStatus = 0;
388 int Opterr;
389 int Optind;
390
391
392 ResponseFile = fopen (Filename, "r");
393 if (!ResponseFile)
394 {
395 printf ("Could not open command file %s, %s\n",
396 Filename, strerror (errno));
397 return -1;
398 }
399
400 /* Must save the current GetOpt globals */
401
402 Opterr = AcpiGbl_Opterr;
403 Optind = AcpiGbl_Optind;
404
405 /*
406 * Process all lines in the response file. There must be one complete
407 * option per line
408 */
409 while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile))
410 {
411 /* Compress all tokens, allowing us to use a single argv entry */
412
413 AslMergeOptionTokens (StringBuffer, StringBuffer2);
414
415 /* Process the option */
416
417 AcpiGbl_Opterr = 0;
418 AcpiGbl_Optind = 0;
419
420 OptStatus = AslDoOptions (1, &argv, TRUE);
421 if (OptStatus)
422 {
423 printf ("Invalid option in command file %s: %s\n",
424 Filename, StringBuffer);
425 break;
426 }
427 }
428
429 /* Restore the GetOpt globals */
430
431 AcpiGbl_Opterr = Opterr;
432 AcpiGbl_Optind = Optind;
433
434 fclose (ResponseFile);
435 return (OptStatus);
436 }
437
438
439 /*******************************************************************************
440 *
441 * FUNCTION: AslDoOptions
442 *
443 * PARAMETERS: argc/argv - Standard argc/argv
444 * IsResponseFile - TRUE if executing a response file.
445 *
446 * RETURN: Status
447 *
448 * DESCRIPTION: Command line option processing
449 *
450 ******************************************************************************/
451
452 static int
453 AslDoOptions (
454 int argc,
455 char **argv,
456 BOOLEAN IsResponseFile)
457 {
458 int j;
459
460
461 /* Get the command line options */
462
463 while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j)
464 {
465 case '@': /* Begin a response file */
466
467 if (IsResponseFile)
468 {
469 printf ("Nested command files are not supported\n");
470 return -1;
471 }
472
473 if (AslDoResponseFile (AcpiGbl_Optarg))
474 {
475 return -1;
476 }
477 break;
478
479
480 case '2':
481
482 Gbl_Acpi2 = TRUE;
483 break;
484
485
486 case 'b':
487
488 switch (AcpiGbl_Optarg[0])
489 {
490 case 'b':
491 AslCompilerdebug = 1; /* same as yydebug */
492 break;
493
494 case 'p':
495 AslCompilerdebug = 1; /* same as yydebug */
496 break;
497
498 case 't':
499 break;
500
501 default:
502 printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
503 return (-1);
504 }
505
506 /* Produce debug output file */
507
508 Gbl_DebugFlag = TRUE;
509 break;
510
511
512 case 'c':
513 switch (AcpiGbl_Optarg[0])
514 {
515 case 'r':
516 Gbl_NoResourceChecking = TRUE;
517 break;
518
519 default:
520 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
521 return (-1);
522 }
523 break;
524
525
526 case 'd':
527 switch (AcpiGbl_Optarg[0])
528 {
529 case '^':
530 Gbl_DoCompile = FALSE;
531 break;
532
533 case 'c':
534 break;
535
536 default:
537 printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
538 return (-1);
539 }
540
541 Gbl_DisasmFlag = TRUE;
542 break;
543
544
545 case 'e':
546 Gbl_ExternalFilename = AcpiGbl_Optarg;
547 break;
548
549
550 case 'f':
551
552 /* Ignore errors and force creation of aml file */
553
554 Gbl_IgnoreErrors = TRUE;
555 break;
556
557
558 case 'g':
559
560 /* Get all ACPI tables */
561
562 Gbl_GetAllTables = TRUE;
563 Gbl_DoCompile = FALSE;
564 break;
565
566
567 case 'h':
568
569 switch (AcpiGbl_Optarg[0])
570 {
571 case '^':
572 HelpMessage ();
573 exit (0);
574
575 case 'c':
576 UtDisplayConstantOpcodes ();
577 exit (0);
578
579 case 'r':
580 /* reserved names */
581
582 ApDisplayReservedNames ();
583 exit (0);
584
585 default:
586 printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
587 return (-1);
588 }
589 break;
590
591
592 case 'I': /* Add an include file search directory */
593
594 FlAddIncludeDirectory (AcpiGbl_Optarg);
595 break;
596
597
598 case 'i':
599
600 switch (AcpiGbl_Optarg[0])
601 {
602 case 'a':
603
604 /* Produce assembly code include file */
605
606 Gbl_AsmIncludeOutputFlag = TRUE;
607 break;
608
609 case 'c':
610
611 /* Produce C include file */
612
613 Gbl_C_IncludeOutputFlag = TRUE;
614 break;
615
616 default:
617 printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
618 return (-1);
619 }
620 break;
621
622
623 case 'l':
624
625 switch (AcpiGbl_Optarg[0])
626 {
627 case '^':
628 /* Produce listing file (Mixed source/aml) */
629
630 Gbl_ListingFlag = TRUE;
631 break;
632
633 case 'n':
634 /* Produce namespace file */
635
636 Gbl_NsOutputFlag = TRUE;
637 break;
638
639 case 's':
640 /* Produce combined source file */
641
642 Gbl_SourceOutputFlag = TRUE;
643 break;
644
645 default:
646 printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
647 return (-1);
648 }
649 break;
650
651
652 case 'o':
653
654 switch (AcpiGbl_Optarg[0])
655 {
656 case 'a':
657
658 /* Disable all optimizations */
659
660 Gbl_FoldConstants = FALSE;
661 Gbl_IntegerOptimizationFlag = FALSE;
662 Gbl_ReferenceOptimizationFlag = FALSE;
663 break;
664
665 case 'f':
666
667 /* Disable folding on "normal" expressions */
668
669 Gbl_FoldConstants = FALSE;
670 break;
671
672 case 'i':
673
674 /* Disable integer optimization to constants */
675
676 Gbl_IntegerOptimizationFlag = FALSE;
677 break;
678
679 case 'n':
680
681 /* Disable named reference optimization */
682
683 Gbl_ReferenceOptimizationFlag = FALSE;
684 break;
685
686 case 't':
687
688 /* Display compile time(s) */
689
690 Gbl_CompileTimesFlag = TRUE;
691 break;
692
693 default:
694 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
695 return (-1);
696 }
697 break;
698
699
700 case 'n':
701
702 /* Parse only */
703
704 Gbl_ParseOnlyFlag = TRUE;
705 break;
706
707
708 case 'p':
709
710 /* Override default AML output filename */
711
712 Gbl_OutputFilenamePrefix = AcpiGbl_Optarg;
713 Gbl_UseDefaultAmlFilename = FALSE;
714 break;
715
716
717 case 'r':
718 Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
719 break;
720
721
722 case 's':
723
724 switch (AcpiGbl_Optarg[0])
725 {
726 case 'a':
727
728 /* Produce assembly code output file */
729
730 Gbl_AsmOutputFlag = TRUE;
731 break;
732
733 case 'c':
734
735 /* Produce C hex output file */
736
737 Gbl_C_OutputFlag = TRUE;
738 break;
739
740 default:
741 printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
742 return (-1);
743 }
744 break;
745
746
747 case 't':
748
749 /* Produce hex table output file */
750
751 switch (AcpiGbl_Optarg[0])
752 {
753 case 'a':
754 Gbl_HexOutputFlag = HEX_OUTPUT_ASM;
755 break;
756
757 case 'c':
758 Gbl_HexOutputFlag = HEX_OUTPUT_C;
759 break;
760
761 case 's':
762 Gbl_HexOutputFlag = HEX_OUTPUT_ASL;
763 break;
764
765 default:
766 printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
767 return (-1);
768 }
769 break;
770
771
772 case 'v':
773
774 switch (AcpiGbl_Optarg[0])
775 {
776 case 'a':
777 /* Disable All error/warning messages */
778
779 Gbl_NoErrors = TRUE;
780 break;
781
782 case 'i':
783 /* Less verbose error messages */
784
785 Gbl_VerboseErrors = FALSE;
786 break;
787
788 case 'o':
789 Gbl_DisplayOptimizations = TRUE;
790 break;
791
792 case 'r':
793 Gbl_DisplayRemarks = FALSE;
794 break;
795
796 case 's':
797 Gbl_DoSignon = FALSE;
798 break;
799
800 default:
801 printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
802 return (-1);
803 }
804 break;
805
806
807 case 'w': /* Set warning levels */
808
809 switch (AcpiGbl_Optarg[0])
810 {
811 case '1':
812 Gbl_WarningLevel = ASL_WARNING;
813 break;
814
815 case '2':
816 Gbl_WarningLevel = ASL_WARNING2;
817 break;
818
819 case '3':
820 Gbl_WarningLevel = ASL_WARNING3;
821 break;
822
823 default:
824 printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);
825 return (-1);
826 }
827 break;
828
829
830 case 'x':
831
832 AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
833 break;
834
835
836 case 'y':
837
838 Gbl_DataTableCompilerAvailable = TRUE;
839 break;
840
841
842 case 'z':
843
844 Gbl_UseOriginalCompilerId = TRUE;
845 break;
846
847
848 default:
849
850 return (-1);
851 }
852
853 return (0);
854 }
855
856
857 /*******************************************************************************
858 *
859 * FUNCTION: AslCommandLine
860 *
861 * PARAMETERS: argc/argv
862 *
863 * RETURN: Last argv index
864 *
865 * DESCRIPTION: Command line processing
866 *
867 ******************************************************************************/
868
869 static int
870 AslCommandLine (
871 int argc,
872 char **argv)
873 {
874 int BadCommandLine = 0;
875
876
877 /* Minimum command line contains at least the command and an input file */
878
879 if (argc < 2)
880 {
881 AslCompilerSignon (ASL_FILE_STDOUT);
882 Usage ();
883 exit (1);
884 }
885
886 /* Process all command line options */
887
888 BadCommandLine = AslDoOptions (argc, argv, FALSE);
889
890 /* Next parameter must be the input filename */
891
892 if (!argv[AcpiGbl_Optind] &&
893 !Gbl_DisasmFlag &&
894 !Gbl_GetAllTables)
895 {
896 printf ("Missing input filename\n");
897 BadCommandLine = TRUE;
898 }
899
900 if (Gbl_DoSignon)
901 {
902 AslCompilerSignon (ASL_FILE_STDOUT);
903 }
904
905 /* Abort if anything went wrong on the command line */
906
907 if (BadCommandLine)
908 {
909 printf ("\n");
910 Usage ();
911 exit (1);
912 }
913
914 return (AcpiGbl_Optind);
915 }
916
917
918 /*******************************************************************************
919 *
920 * FUNCTION: main
921 *
922 * PARAMETERS: Standard argc/argv
923 *
924 * RETURN: Program termination code
925 *
926 * DESCRIPTION: C main routine for the Asl Compiler. Handle command line
927 * options and begin the compile for each file on the command line
928 *
929 ******************************************************************************/
930
931 int ACPI_SYSTEM_XFACE
932 main (
933 int argc,
934 char **argv)
935 {
936 ACPI_STATUS Status;
937 int Index;
938
939
940 #ifdef _DEBUG
941 _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF |
942 _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
943 #endif
944
945 /* Init and command line */
946
947 AslInitialize ();
948 Index = AslCommandLine (argc, argv);
949
950 /* Options that have no additional parameters or pathnames */
951
952 if (Gbl_GetAllTables)
953 {
954 Status = AslDoOneFile (NULL);
955 if (ACPI_FAILURE (Status))
956 {
957 return (-1);
958 }
959 return (0);
960 }
961
962 /* Process each pathname/filename in the list, with possible wildcards */
963
964 while (argv[Index])
965 {
966 Status = AslDoOnePathname (argv[Index]);
967 if (ACPI_FAILURE (Status))
968 {
969 return (-1);
970 }
971
972 Index++;
973 }
974
975 return (0);
976 }
977
978
979