xref: /freebsd/sys/contrib/dev/acpica/compiler/aslmain.c (revision 7aa383846770374466b1dcb2cefd71bde9acf463)
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 <contrib/dev/acpica/compiler/aslcompiler.h>
121 #include <contrib/dev/acpica/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:T:v:w:x:z"
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 ("\nACPI Data Tables:\n");
222     printf ("  -T <Sig>       Create table template file for <Sig> (or \"ALL\")\n");
223     printf ("  -vt            Create verbose templates (full disassembly)\n");
224 
225     printf ("\nAML Disassembler:\n");
226     printf ("  -d  [file]     Disassemble or decode binary ACPI table to file (*.dsl)\n");
227     printf ("  -dc [file]     Disassemble AML and immediately compile it\n");
228     printf ("                 (Obtain DSDT from current system if no input file)\n");
229     printf ("  -e  [f1,f2]    Include ACPI table(s) for external symbol resolution\n");
230     printf ("  -2             Emit ACPI 2.0 compatible ASL code\n");
231     printf ("  -g             Get ACPI tables and write to files (*.dat)\n");
232 
233     printf ("\nHelp:\n");
234     printf ("  -h             Additional help and compiler debug options\n");
235     printf ("  -hc            Display operators allowed in constant expressions\n");
236     printf ("  -hr            Display ACPI reserved method names\n");
237     printf ("  -ht            Display currently supported ACPI table names\n");
238 }
239 
240 
241 /*******************************************************************************
242  *
243  * FUNCTION:    HelpMessage
244  *
245  * PARAMETERS:  None
246  *
247  * RETURN:      None
248  *
249  * DESCRIPTION: Display help message
250  *
251  ******************************************************************************/
252 
253 static void
254 HelpMessage (
255     void)
256 {
257 
258     printf ("AML output filename generation:\n");
259     printf ("  Output filenames are generated by appending an extension to a common\n");
260     printf ("  filename prefix.  The filename prefix is obtained via one of the\n");
261     printf ("  following methods (in priority order):\n");
262     printf ("    1) The -p option specifies the prefix\n");
263     printf ("    2) The prefix of the AMLFileName in the ASL Definition Block\n");
264     printf ("    3) The prefix of the input filename\n");
265     printf ("\n");
266 
267     Options ();
268 
269     printf ("\nCompiler/Disassembler Debug Options:\n");
270     printf ("  -b<p|t|b>      Create compiler debug/trace file (*.txt)\n");
271     printf ("                   Types: Parse/Tree/Both\n");
272     printf ("  -f             Ignore errors, force creation of AML output file(s)\n");
273     printf ("  -n             Parse only, no output generation\n");
274     printf ("  -ot            Display compile times\n");
275     printf ("  -x<level>      Set debug level for trace output\n");
276     printf ("  -z             Do not insert new compiler ID for DataTables\n");
277 }
278 
279 
280 /*******************************************************************************
281  *
282  * FUNCTION:    Usage
283  *
284  * PARAMETERS:  None
285  *
286  * RETURN:      None
287  *
288  * DESCRIPTION: Display usage and option message
289  *
290  ******************************************************************************/
291 
292 static void
293 Usage (
294     void)
295 {
296 
297     printf ("Usage:    %s [Options] [Files]\n\n", CompilerName);
298     Options ();
299 }
300 
301 
302 /*******************************************************************************
303  *
304  * FUNCTION:    AslInitialize
305  *
306  * PARAMETERS:  None
307  *
308  * RETURN:      None
309  *
310  * DESCRIPTION: Initialize compiler globals
311  *
312  ******************************************************************************/
313 
314 static void
315 AslInitialize (
316     void)
317 {
318     UINT32                  i;
319 
320 
321 #ifdef _DEBUG
322     _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0));
323 #endif
324 
325     AcpiDbgLevel = 0;
326 
327     for (i = 0; i < ASL_NUM_FILES; i++)
328     {
329         Gbl_Files[i].Handle = NULL;
330         Gbl_Files[i].Filename = NULL;
331     }
332 
333     Gbl_Files[ASL_FILE_STDOUT].Handle   = stdout;
334     Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT";
335 
336     Gbl_Files[ASL_FILE_STDERR].Handle   = stderr;
337     Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR";
338 }
339 
340 
341 /*******************************************************************************
342  *
343  * FUNCTION:    AslMergeOptionTokens
344  *
345  * PARAMETERS:  InBuffer            - Input containing an option string
346  *              OutBuffer           - Merged output buffer
347  *
348  * RETURN:      None
349  *
350  * DESCRIPTION: Remove all whitespace from an option string.
351  *
352  ******************************************************************************/
353 
354 static void
355 AslMergeOptionTokens (
356     char                    *InBuffer,
357     char                    *OutBuffer)
358 {
359     char                    *Token;
360 
361 
362     *OutBuffer = 0;
363 
364     Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS);
365     while (Token)
366     {
367         strcat (OutBuffer, Token);
368         Token = strtok (NULL, ASL_TOKEN_SEPARATORS);
369     }
370 }
371 
372 
373 /*******************************************************************************
374  *
375  * FUNCTION:    AslDoResponseFile
376  *
377  * PARAMETERS:  Filename        - Name of the response file
378  *
379  * RETURN:      Status
380  *
381  * DESCRIPTION: Open a response file and process all options within.
382  *
383  ******************************************************************************/
384 
385 static int
386 AslDoResponseFile (
387     char                    *Filename)
388 {
389     char                    *argv = StringBuffer2;
390     FILE                    *ResponseFile;
391     int                     OptStatus = 0;
392     int                     Opterr;
393     int                     Optind;
394 
395 
396     ResponseFile = fopen (Filename, "r");
397     if (!ResponseFile)
398     {
399         printf ("Could not open command file %s, %s\n",
400             Filename, strerror (errno));
401         return -1;
402     }
403 
404     /* Must save the current GetOpt globals */
405 
406     Opterr = AcpiGbl_Opterr;
407     Optind = AcpiGbl_Optind;
408 
409     /*
410      * Process all lines in the response file. There must be one complete
411      * option per line
412      */
413     while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile))
414     {
415         /* Compress all tokens, allowing us to use a single argv entry */
416 
417         AslMergeOptionTokens (StringBuffer, StringBuffer2);
418 
419         /* Process the option */
420 
421         AcpiGbl_Opterr = 0;
422         AcpiGbl_Optind = 0;
423 
424         OptStatus = AslDoOptions (1, &argv, TRUE);
425         if (OptStatus)
426         {
427             printf ("Invalid option in command file %s: %s\n",
428                 Filename, StringBuffer);
429             break;
430         }
431     }
432 
433     /* Restore the GetOpt globals */
434 
435     AcpiGbl_Opterr = Opterr;
436     AcpiGbl_Optind = Optind;
437 
438     fclose (ResponseFile);
439     return (OptStatus);
440 }
441 
442 
443 /*******************************************************************************
444  *
445  * FUNCTION:    AslDoOptions
446  *
447  * PARAMETERS:  argc/argv           - Standard argc/argv
448  *              IsResponseFile      - TRUE if executing a response file.
449  *
450  * RETURN:      Status
451  *
452  * DESCRIPTION: Command line option processing
453  *
454  ******************************************************************************/
455 
456 static int
457 AslDoOptions (
458     int                     argc,
459     char                    **argv,
460     BOOLEAN                 IsResponseFile)
461 {
462     int                     j;
463 
464 
465     /* Get the command line options */
466 
467     while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j)
468     {
469     case '@':   /* Begin a response file */
470 
471         if (IsResponseFile)
472         {
473             printf ("Nested command files are not supported\n");
474             return -1;
475         }
476 
477         if (AslDoResponseFile (AcpiGbl_Optarg))
478         {
479             return -1;
480         }
481         break;
482 
483 
484     case '2':
485 
486         Gbl_Acpi2 = TRUE;
487         break;
488 
489 
490     case 'b':
491 
492         switch (AcpiGbl_Optarg[0])
493         {
494         case 'b':
495             AslCompilerdebug = 1; /* same as yydebug */
496             break;
497 
498         case 'p':
499             AslCompilerdebug = 1; /* same as yydebug */
500             break;
501 
502         case 't':
503             break;
504 
505         default:
506             printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
507             return (-1);
508         }
509 
510         /* Produce debug output file */
511 
512         Gbl_DebugFlag = TRUE;
513         break;
514 
515 
516     case 'c':
517         switch (AcpiGbl_Optarg[0])
518         {
519         case 'r':
520             Gbl_NoResourceChecking = TRUE;
521             break;
522 
523         default:
524             printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
525             return (-1);
526         }
527         break;
528 
529 
530     case 'd':
531         switch (AcpiGbl_Optarg[0])
532         {
533         case '^':
534             Gbl_DoCompile = FALSE;
535             break;
536 
537         case 'c':
538             break;
539 
540         default:
541             printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
542             return (-1);
543         }
544 
545         Gbl_DisasmFlag = TRUE;
546         break;
547 
548 
549     case 'e':
550         Gbl_ExternalFilename = AcpiGbl_Optarg;
551         break;
552 
553 
554     case 'f':
555 
556         /* Ignore errors and force creation of aml file */
557 
558         Gbl_IgnoreErrors = TRUE;
559         break;
560 
561 
562     case 'g':
563 
564         /* Get all ACPI tables */
565 
566         Gbl_GetAllTables = TRUE;
567         Gbl_DoCompile = FALSE;
568         break;
569 
570 
571     case 'h':
572 
573         switch (AcpiGbl_Optarg[0])
574         {
575         case '^':
576             HelpMessage ();
577             exit (0);
578 
579         case 'c':
580             UtDisplayConstantOpcodes ();
581             exit (0);
582 
583         case 'r':
584             /* reserved names */
585 
586             ApDisplayReservedNames ();
587             exit (0);
588 
589         case 't':
590             UtDisplaySupportedTables ();
591             exit (0);
592 
593         default:
594             printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
595             return (-1);
596         }
597         break;
598 
599 
600     case 'I': /* Add an include file search directory */
601 
602         FlAddIncludeDirectory (AcpiGbl_Optarg);
603         break;
604 
605 
606     case 'i':
607 
608         switch (AcpiGbl_Optarg[0])
609         {
610         case 'a':
611 
612             /* Produce assembly code include file */
613 
614             Gbl_AsmIncludeOutputFlag = TRUE;
615             break;
616 
617         case 'c':
618 
619             /* Produce C include file */
620 
621             Gbl_C_IncludeOutputFlag = TRUE;
622             break;
623 
624         default:
625             printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
626             return (-1);
627         }
628         break;
629 
630 
631     case 'l':
632 
633         switch (AcpiGbl_Optarg[0])
634         {
635         case '^':
636             /* Produce listing file (Mixed source/aml) */
637 
638             Gbl_ListingFlag = TRUE;
639             break;
640 
641         case 'n':
642             /* Produce namespace file */
643 
644             Gbl_NsOutputFlag = TRUE;
645             break;
646 
647         case 's':
648             /* Produce combined source file */
649 
650             Gbl_SourceOutputFlag = TRUE;
651             break;
652 
653         default:
654             printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
655             return (-1);
656         }
657         break;
658 
659 
660     case 'o':
661 
662         switch (AcpiGbl_Optarg[0])
663         {
664         case 'a':
665 
666             /* Disable all optimizations */
667 
668             Gbl_FoldConstants = FALSE;
669             Gbl_IntegerOptimizationFlag = FALSE;
670             Gbl_ReferenceOptimizationFlag = FALSE;
671             break;
672 
673         case 'f':
674 
675             /* Disable folding on "normal" expressions */
676 
677             Gbl_FoldConstants = FALSE;
678             break;
679 
680         case 'i':
681 
682             /* Disable integer optimization to constants */
683 
684             Gbl_IntegerOptimizationFlag = FALSE;
685             break;
686 
687         case 'n':
688 
689             /* Disable named reference optimization */
690 
691             Gbl_ReferenceOptimizationFlag = FALSE;
692             break;
693 
694         case 't':
695 
696             /* Display compile time(s) */
697 
698             Gbl_CompileTimesFlag = TRUE;
699             break;
700 
701         default:
702             printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
703             return (-1);
704         }
705         break;
706 
707 
708     case 'n':
709 
710         /* Parse only */
711 
712         Gbl_ParseOnlyFlag = TRUE;
713         break;
714 
715 
716     case 'p':
717 
718         /* Override default AML output filename */
719 
720         Gbl_OutputFilenamePrefix = AcpiGbl_Optarg;
721         Gbl_UseDefaultAmlFilename = FALSE;
722         break;
723 
724 
725     case 'r':
726         Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
727         break;
728 
729 
730     case 's':
731 
732         switch (AcpiGbl_Optarg[0])
733         {
734         case 'a':
735 
736             /* Produce assembly code output file */
737 
738             Gbl_AsmOutputFlag = TRUE;
739             break;
740 
741         case 'c':
742 
743             /* Produce C hex output file */
744 
745             Gbl_C_OutputFlag = TRUE;
746             break;
747 
748         default:
749             printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
750             return (-1);
751         }
752         break;
753 
754 
755     case 't':
756 
757         /* Produce hex table output file */
758 
759         switch (AcpiGbl_Optarg[0])
760         {
761         case 'a':
762             Gbl_HexOutputFlag = HEX_OUTPUT_ASM;
763             break;
764 
765         case 'c':
766             Gbl_HexOutputFlag = HEX_OUTPUT_C;
767             break;
768 
769         case 's':
770             Gbl_HexOutputFlag = HEX_OUTPUT_ASL;
771             break;
772 
773         default:
774             printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
775             return (-1);
776         }
777         break;
778 
779 
780     case 'T':
781         Gbl_DoTemplates = TRUE;
782         Gbl_TemplateSignature = AcpiGbl_Optarg;
783         break;
784 
785 
786     case 'v':
787 
788         switch (AcpiGbl_Optarg[0])
789         {
790         case 'a':
791             /* Disable All error/warning messages */
792 
793             Gbl_NoErrors = TRUE;
794             break;
795 
796         case 'i':
797             /* Less verbose error messages */
798 
799             Gbl_VerboseErrors = FALSE;
800             break;
801 
802         case 'o':
803             Gbl_DisplayOptimizations = TRUE;
804             break;
805 
806         case 'r':
807             Gbl_DisplayRemarks = FALSE;
808             break;
809 
810         case 's':
811             Gbl_DoSignon = FALSE;
812             break;
813 
814         case 't':
815             Gbl_VerboseTemplates = TRUE;
816             break;
817 
818         default:
819             printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
820             return (-1);
821         }
822         break;
823 
824 
825     case 'w': /* Set warning levels */
826 
827         switch (AcpiGbl_Optarg[0])
828         {
829         case '1':
830             Gbl_WarningLevel = ASL_WARNING;
831             break;
832 
833         case '2':
834             Gbl_WarningLevel = ASL_WARNING2;
835             break;
836 
837         case '3':
838             Gbl_WarningLevel = ASL_WARNING3;
839             break;
840 
841         default:
842             printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);
843             return (-1);
844         }
845         break;
846 
847 
848     case 'x':
849 
850         AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
851         break;
852 
853 
854     case 'z':
855 
856         Gbl_UseOriginalCompilerId = TRUE;
857         break;
858 
859 
860     default:
861 
862         return (-1);
863     }
864 
865     return (0);
866 }
867 
868 
869 /*******************************************************************************
870  *
871  * FUNCTION:    AslCommandLine
872  *
873  * PARAMETERS:  argc/argv
874  *
875  * RETURN:      Last argv index
876  *
877  * DESCRIPTION: Command line processing
878  *
879  ******************************************************************************/
880 
881 static int
882 AslCommandLine (
883     int                     argc,
884     char                    **argv)
885 {
886     int                     BadCommandLine = 0;
887 
888 
889     /* Minimum command line contains at least the command and an input file */
890 
891     if (argc < 2)
892     {
893         AslCompilerSignon (ASL_FILE_STDOUT);
894         Usage ();
895         exit (1);
896     }
897 
898     /* Process all command line options */
899 
900     BadCommandLine = AslDoOptions (argc, argv, FALSE);
901 
902     if (Gbl_DoTemplates)
903     {
904         DtCreateTemplates (Gbl_TemplateSignature);
905         exit (1);
906     }
907 
908     /* Next parameter must be the input filename */
909 
910     if (!argv[AcpiGbl_Optind] &&
911         !Gbl_DisasmFlag &&
912         !Gbl_GetAllTables)
913     {
914         printf ("Missing input filename\n");
915         BadCommandLine = TRUE;
916     }
917 
918     if (Gbl_DoSignon)
919     {
920         AslCompilerSignon (ASL_FILE_STDOUT);
921     }
922 
923     /* Abort if anything went wrong on the command line */
924 
925     if (BadCommandLine)
926     {
927         printf ("\n");
928         Usage ();
929         exit (1);
930     }
931 
932     return (AcpiGbl_Optind);
933 }
934 
935 
936 /*******************************************************************************
937  *
938  * FUNCTION:    main
939  *
940  * PARAMETERS:  Standard argc/argv
941  *
942  * RETURN:      Program termination code
943  *
944  * DESCRIPTION: C main routine for the Asl Compiler. Handle command line
945  *              options and begin the compile for each file on the command line
946  *
947  ******************************************************************************/
948 
949 int ACPI_SYSTEM_XFACE
950 main (
951     int                     argc,
952     char                    **argv)
953 {
954     ACPI_STATUS             Status;
955     int                     Index;
956 
957 
958 #ifdef _DEBUG
959     _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF |
960                     _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
961 #endif
962 
963     /* Init and command line */
964 
965     AslInitialize ();
966     Index = AslCommandLine (argc, argv);
967 
968     /* Options that have no additional parameters or pathnames */
969 
970     if (Gbl_GetAllTables)
971     {
972         Status = AslDoOneFile (NULL);
973         if (ACPI_FAILURE (Status))
974         {
975             return (-1);
976         }
977         return (0);
978     }
979 
980     /* Process each pathname/filename in the list, with possible wildcards */
981 
982     while (argv[Index])
983     {
984         Status = AslDoOnePathname (argv[Index]);
985         if (ACPI_FAILURE (Status))
986         {
987             return (-1);
988         }
989 
990         Index++;
991     }
992 
993     return (0);
994 }
995 
996 
997