aslmain.c revision 197104
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 - 2009, 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
132static void
133Options (
134    void);
135
136static void
137HelpMessage (
138    void);
139
140static void
141Usage (
142    void);
143
144static void
145AslInitialize (
146    void);
147
148static int
149AslCommandLine (
150    int                     argc,
151    char                    **argv);
152
153static int
154AslDoOptions (
155    int                     argc,
156    char                    **argv,
157    BOOLEAN                 IsResponseFile);
158
159static void
160AslMergeOptionTokens (
161    char                    *InBuffer,
162    char                    *OutBuffer);
163
164static int
165AslDoResponseFile (
166    char                    *Filename);
167
168extern int   AcpiGbl_Opterr;
169extern int   AcpiGbl_Optind;
170
171
172#define ASL_TOKEN_SEPARATORS    " \t\n"
173#define ASL_SUPPORTED_OPTIONS   "@:2b:cd^e:fgh^i^I:l^o:p:r:s:t:v:w:x:"
174
175
176/*******************************************************************************
177 *
178 * FUNCTION:    Options
179 *
180 * PARAMETERS:  None
181 *
182 * RETURN:      None
183 *
184 * DESCRIPTION: Display option help message
185 *
186 ******************************************************************************/
187
188static void
189Options (
190    void)
191{
192
193    printf ("Global:\n");
194    printf ("  -@<file>       Specify command file\n");
195    printf ("  -I<dir>        Specify additional include directory\n");
196
197    printf ("\nGeneral Output:\n");
198    printf ("  -p<prefix>     Specify path/filename prefix for all output files\n");
199    printf ("  -va            Disable all errors and warnings (summary only)\n");
200    printf ("  -vi            Less verbose errors and warnings for use with IDEs\n");
201    printf ("  -vo            Enable optimization comments\n");
202    printf ("  -vr            Disable remarks\n");
203    printf ("  -vs            Disable signon\n");
204    printf ("  -w<1|2|3>      Set warning reporting level\n");
205
206    printf ("\nAML Output Files:\n");
207    printf ("  -s<a|c>        Create AML in assembler or C source file (*.asm or *.c)\n");
208    printf ("  -i<a|c>        Create assembler or C include file (*.inc or *.h)\n");
209    printf ("  -t<a|c>        Create AML in assembler or C hex table (*.hex)\n");
210
211    printf ("\nAML Code Generation:\n");
212    printf ("  -oa            Disable all optimizations (compatibility mode)\n");
213    printf ("  -of            Disable constant folding\n");
214    printf ("  -oi            Disable integer optimization to Zero/One/Ones\n");
215    printf ("  -on            Disable named reference string optimization\n");
216    printf ("  -r<Revision>   Override table header Revision (1-255)\n");
217
218    printf ("\nListings:\n");
219    printf ("  -l             Create mixed listing file (ASL source and AML) (*.lst)\n");
220    printf ("  -ln            Create namespace file (*.nsp)\n");
221    printf ("  -ls            Create combined source file (expanded includes) (*.src)\n");
222
223    printf ("\nAML Disassembler:\n");
224    printf ("  -d  [file]     Disassemble or decode binary ACPI table to file (*.dsl)\n");
225    printf ("  -dc [file]     Disassemble AML and immediately compile it\n");
226    printf ("                 (Obtain DSDT from current system if no input file)\n");
227    printf ("  -e  [f1,f2]    Include ACPI table(s) for external symbol resolution\n");
228    printf ("  -2             Emit ACPI 2.0 compatible ASL code\n");
229    printf ("  -g             Get ACPI tables and write to files (*.dat)\n");
230
231    printf ("\nHelp:\n");
232    printf ("  -h             Additional help and compiler debug options\n");
233    printf ("  -hc            Display operators allowed in constant expressions\n");
234    printf ("  -hr            Display ACPI reserved method names\n");
235}
236
237
238/*******************************************************************************
239 *
240 * FUNCTION:    HelpMessage
241 *
242 * PARAMETERS:  None
243 *
244 * RETURN:      None
245 *
246 * DESCRIPTION: Display help message
247 *
248 ******************************************************************************/
249
250static void
251HelpMessage (
252    void)
253{
254
255    printf ("AML output filename generation:\n");
256    printf ("  Output filenames are generated by appending an extension to a common\n");
257    printf ("  filename prefix.  The filename prefix is obtained via one of the\n");
258    printf ("  following methods (in priority order):\n");
259    printf ("    1) The -p option specifies the prefix\n");
260    printf ("    2) The prefix of the AMLFileName in the ASL Definition Block\n");
261    printf ("    3) The prefix of the input filename\n");
262    printf ("\n");
263
264    Options ();
265
266    printf ("\nCompiler/Disassembler Debug Options:\n");
267    printf ("  -b<p|t|b>      Create compiler debug/trace file (*.txt)\n");
268    printf ("                   Types: Parse/Tree/Both\n");
269    printf ("  -f             Ignore errors, force creation of AML output file(s)\n");
270    printf ("  -c             Parse only, no output generation\n");
271    printf ("  -ot            Display compile times\n");
272    printf ("  -x<level>      Set debug level for trace output\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
288static void
289Usage (
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
310static void
311AslInitialize (
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
350static void
351AslMergeOptionTokens (
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
381static int
382AslDoResponseFile (
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
452static int
453AslDoOptions (
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
514        /* Parse only */
515
516        Gbl_ParseOnlyFlag = TRUE;
517        break;
518
519
520    case 'd':
521        switch (AcpiGbl_Optarg[0])
522        {
523        case '^':
524            Gbl_DoCompile = FALSE;
525            break;
526
527        case 'c':
528            break;
529
530        default:
531            printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
532            return (-1);
533        }
534
535        Gbl_DisasmFlag = TRUE;
536        break;
537
538
539    case 'e':
540        Gbl_ExternalFilename = AcpiGbl_Optarg;
541        break;
542
543
544    case 'f':
545
546        /* Ignore errors and force creation of aml file */
547
548        Gbl_IgnoreErrors = TRUE;
549        break;
550
551
552    case 'g':
553
554        /* Get all ACPI tables */
555
556        Gbl_GetAllTables = TRUE;
557        Gbl_DoCompile = FALSE;
558        break;
559
560
561    case 'h':
562
563        switch (AcpiGbl_Optarg[0])
564        {
565        case '^':
566            HelpMessage ();
567            exit (0);
568
569        case 'c':
570            UtDisplayConstantOpcodes ();
571            exit (0);
572
573        case 'r':
574            /* reserved names */
575
576            MpDisplayReservedNames ();
577            exit (0);
578
579        default:
580            printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
581            return (-1);
582        }
583        break;
584
585
586    case 'I': /* Add an include file search directory */
587
588        FlAddIncludeDirectory (AcpiGbl_Optarg);
589        break;
590
591
592    case 'i':
593
594        switch (AcpiGbl_Optarg[0])
595        {
596        case 'a':
597
598            /* Produce assembly code include file */
599
600            Gbl_AsmIncludeOutputFlag = TRUE;
601            break;
602
603        case 'c':
604
605            /* Produce C include file */
606
607            Gbl_C_IncludeOutputFlag = TRUE;
608            break;
609
610        default:
611            printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
612            return (-1);
613        }
614        break;
615
616
617    case 'l':
618
619        switch (AcpiGbl_Optarg[0])
620        {
621        case '^':
622            /* Produce listing file (Mixed source/aml) */
623
624            Gbl_ListingFlag = TRUE;
625            break;
626
627        case 'n':
628            /* Produce namespace file */
629
630            Gbl_NsOutputFlag = TRUE;
631            break;
632
633        case 's':
634            /* Produce combined source file */
635
636            Gbl_SourceOutputFlag = TRUE;
637            break;
638
639        default:
640            printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
641            return (-1);
642        }
643        break;
644
645
646    case 'o':
647
648        switch (AcpiGbl_Optarg[0])
649        {
650        case 'a':
651
652            /* Disable all optimizations */
653
654            Gbl_FoldConstants = FALSE;
655            Gbl_IntegerOptimizationFlag = FALSE;
656            Gbl_ReferenceOptimizationFlag = FALSE;
657            break;
658
659        case 'f':
660
661            /* Disable folding on "normal" expressions */
662
663            Gbl_FoldConstants = FALSE;
664            break;
665
666        case 'i':
667
668            /* Disable integer optimization to constants */
669
670            Gbl_IntegerOptimizationFlag = FALSE;
671            break;
672
673        case 'n':
674
675            /* Disable named reference optimization */
676
677            Gbl_ReferenceOptimizationFlag = FALSE;
678            break;
679
680        case 't':
681
682            /* Display compile time(s) */
683
684            Gbl_CompileTimesFlag = TRUE;
685            break;
686
687        default:
688            printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
689            return (-1);
690        }
691        break;
692
693
694    case 'p':
695
696        /* Override default AML output filename */
697
698        Gbl_OutputFilenamePrefix = AcpiGbl_Optarg;
699        Gbl_UseDefaultAmlFilename = FALSE;
700        break;
701
702
703    case 'r':
704        Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
705        break;
706
707
708    case 's':
709
710        switch (AcpiGbl_Optarg[0])
711        {
712        case 'a':
713
714            /* Produce assembly code output file */
715
716            Gbl_AsmOutputFlag = TRUE;
717            break;
718
719        case 'c':
720
721            /* Produce C hex output file */
722
723            Gbl_C_OutputFlag = TRUE;
724            break;
725
726        default:
727            printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
728            return (-1);
729        }
730        break;
731
732
733    case 't':
734
735        /* Produce hex table output file */
736
737        switch (AcpiGbl_Optarg[0])
738        {
739        case 'a':
740            Gbl_HexOutputFlag = HEX_OUTPUT_ASM;
741            break;
742
743        case 'c':
744            Gbl_HexOutputFlag = HEX_OUTPUT_C;
745            break;
746
747        default:
748            printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
749            return (-1);
750        }
751        break;
752
753
754    case 'v':
755
756        switch (AcpiGbl_Optarg[0])
757        {
758        case 'a':
759            /* Disable All error/warning messages */
760
761            Gbl_NoErrors = TRUE;
762            break;
763
764        case 'i':
765            /* Less verbose error messages */
766
767            Gbl_VerboseErrors = FALSE;
768            break;
769
770        case 'o':
771            Gbl_DisplayOptimizations = TRUE;
772            break;
773
774        case 'r':
775            Gbl_DisplayRemarks = FALSE;
776            break;
777
778        case 's':
779            Gbl_DoSignon = FALSE;
780            break;
781
782        default:
783            printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
784            return (-1);
785        }
786        break;
787
788
789    case 'w': /* Set warning levels */
790
791        switch (AcpiGbl_Optarg[0])
792        {
793        case '1':
794            Gbl_WarningLevel = ASL_WARNING;
795            break;
796
797        case '2':
798            Gbl_WarningLevel = ASL_WARNING2;
799            break;
800
801        case '3':
802            Gbl_WarningLevel = ASL_WARNING3;
803            break;
804
805        default:
806            printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);
807            return (-1);
808        }
809        break;
810
811
812    case 'x':
813
814        AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
815        break;
816
817
818    default:
819
820        return (-1);
821    }
822
823    return (0);
824}
825
826
827/*******************************************************************************
828 *
829 * FUNCTION:    AslCommandLine
830 *
831 * PARAMETERS:  argc/argv
832 *
833 * RETURN:      Last argv index
834 *
835 * DESCRIPTION: Command line processing
836 *
837 ******************************************************************************/
838
839static int
840AslCommandLine (
841    int                     argc,
842    char                    **argv)
843{
844    int                     BadCommandLine = 0;
845
846
847    /* Minimum command line contains at least the command and an input file */
848
849    if (argc < 2)
850    {
851        AslCompilerSignon (ASL_FILE_STDOUT);
852        Usage ();
853        exit (1);
854    }
855
856    /* Process all command line options */
857
858    BadCommandLine = AslDoOptions (argc, argv, FALSE);
859
860    /* Next parameter must be the input filename */
861
862    if (!argv[AcpiGbl_Optind] &&
863        !Gbl_DisasmFlag &&
864        !Gbl_GetAllTables)
865    {
866        printf ("Missing input filename\n");
867        BadCommandLine = TRUE;
868    }
869
870    if (Gbl_DoSignon)
871    {
872        AslCompilerSignon (ASL_FILE_STDOUT);
873    }
874
875    /* Abort if anything went wrong on the command line */
876
877    if (BadCommandLine)
878    {
879        printf ("\n");
880        Usage ();
881        exit (1);
882    }
883
884    return (AcpiGbl_Optind);
885}
886
887
888/*******************************************************************************
889 *
890 * FUNCTION:    main
891 *
892 * PARAMETERS:  Standard argc/argv
893 *
894 * RETURN:      Program termination code
895 *
896 * DESCRIPTION: C main routine for the Asl Compiler. Handle command line
897 *              options and begin the compile for each file on the command line
898 *
899 ******************************************************************************/
900
901int ACPI_SYSTEM_XFACE
902main (
903    int                     argc,
904    char                    **argv)
905{
906    ACPI_STATUS             Status;
907    int                     Index;
908
909
910#ifdef _DEBUG
911    _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF |
912                    _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
913#endif
914
915    /* Init and command line */
916
917    AslInitialize ();
918    Index = AslCommandLine (argc, argv);
919
920    /* Options that have no additional parameters or pathnames */
921
922    if (Gbl_GetAllTables)
923    {
924        Status = AslDoOneFile (NULL);
925        if (ACPI_FAILURE (Status))
926        {
927            return (-1);
928        }
929        return (0);
930    }
931
932    /* Process each pathname/filename in the list, with possible wildcards */
933
934    while (argv[Index])
935    {
936        Status = AslDoOnePathname (argv[Index]);
937        if (ACPI_FAILURE (Status))
938        {
939            return (-1);
940        }
941
942        Index++;
943    }
944
945    return (0);
946}
947
948
949