Home | History | Annotate | Line # | Download | only in compiler
asloptions.c revision 1.18
      1 /******************************************************************************
      2  *
      3  * Module Name: asloptions - compiler command line processing
      4  *
      5  *****************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2023, Intel Corp.
      9  * All rights reserved.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions, and the following disclaimer,
     16  *    without modification.
     17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  *    including a substantially similar Disclaimer requirement for further
     21  *    binary redistribution.
     22  * 3. Neither the names of the above-listed copyright holders nor the names
     23  *    of any contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * Alternatively, this software may be distributed under the terms of the
     27  * GNU General Public License ("GPL") version 2 as published by the Free
     28  * Software Foundation.
     29  *
     30  * NO WARRANTY
     31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  * POSSIBILITY OF SUCH DAMAGES.
     42  */
     43 
     44 #include "aslcompiler.h"
     45 #include "acapps.h"
     46 #include "acdisasm.h"
     47 #include "acglobal.h"
     48 
     49 #define _COMPONENT          ACPI_COMPILER
     50         ACPI_MODULE_NAME    ("asloption")
     51 
     52 
     53 /* Local prototypes */
     54 
     55 static int
     56 AslDoOptions (
     57     int                     argc,
     58     char                    **argv,
     59     BOOLEAN                 IsResponseFile);
     60 
     61 static void
     62 AslMergeOptionTokens (
     63     char                    *InBuffer,
     64     char                    *OutBuffer);
     65 
     66 static int
     67 AslDoResponseFile (
     68     char                    *Filename);
     69 
     70 
     71 #define ASL_TOKEN_SEPARATORS    " \t\n"
     72 #define ASL_SUPPORTED_OPTIONS   "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^q^r:s|:t|T+G^v^w|x:z"
     73 
     74 
     75 /*******************************************************************************
     76  *
     77  * FUNCTION:    AslCommandLine
     78  *
     79  * PARAMETERS:  argc/argv
     80  *
     81  * RETURN:      Last argv index
     82  *
     83  * DESCRIPTION: Command line processing
     84  *
     85  ******************************************************************************/
     86 
     87 int
     88 AslCommandLine (
     89     int                     argc,
     90     char                    **argv)
     91 {
     92     int                     BadCommandLine = 0;
     93     ACPI_STATUS             Status;
     94 
     95 
     96     /* Minimum command line contains at least the command and an input file */
     97 
     98     if (argc < 2)
     99     {
    100         Usage ();
    101         exit (1);
    102     }
    103 
    104     /* Process all command line options */
    105 
    106     BadCommandLine = AslDoOptions (argc, argv, FALSE);
    107 
    108     if (AslGbl_DoTemplates)
    109     {
    110         Status = DtCreateTemplates (argv);
    111         if (ACPI_FAILURE (Status))
    112         {
    113             exit (-1);
    114         }
    115         exit (0);
    116     }
    117 
    118     /* Next parameter must be the input filename */
    119 
    120     if (!argv[AcpiGbl_Optind] &&
    121         !AcpiGbl_DisasmFlag)
    122     {
    123         printf ("Missing input filename\n");
    124         BadCommandLine = TRUE;
    125     }
    126 
    127     if (AslGbl_DoSignon)
    128     {
    129         printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
    130         if (AslGbl_IgnoreErrors)
    131         {
    132             printf ("Ignoring all errors, forcing AML file generation\n\n");
    133         }
    134     }
    135 
    136     if (BadCommandLine)
    137     {
    138         printf ("Use -h option for help information\n");
    139         exit (1);
    140     }
    141 
    142     return (AcpiGbl_Optind);
    143 }
    144 
    145 
    146 /*******************************************************************************
    147  *
    148  * FUNCTION:    AslDoOptions
    149  *
    150  * PARAMETERS:  argc/argv           - Standard argc/argv
    151  *              IsResponseFile      - TRUE if executing a response file.
    152  *
    153  * RETURN:      Status
    154  *
    155  * DESCRIPTION: Command line option processing
    156  *
    157  ******************************************************************************/
    158 
    159 static int
    160 AslDoOptions (
    161     int                     argc,
    162     char                    **argv,
    163     BOOLEAN                 IsResponseFile)
    164 {
    165     ACPI_STATUS             Status;
    166     INT32                  j;
    167 
    168 
    169     /* Get the command line options */
    170 
    171     while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j)
    172     {
    173     case '@':   /* Begin a response file */
    174 
    175         if (IsResponseFile)
    176         {
    177             printf ("Nested command files are not supported\n");
    178             return (-1);
    179         }
    180 
    181         if (AslDoResponseFile (AcpiGbl_Optarg))
    182         {
    183             return (-1);
    184         }
    185         break;
    186 
    187     case 'a':   /* Debug options */
    188 
    189         switch (AcpiGbl_Optarg[0])
    190         {
    191         case 'r':
    192 
    193             AslGbl_EnableReferenceTypechecking = TRUE;
    194             break;
    195 
    196         default:
    197 
    198             printf ("Unknown option: -a%s\n", AcpiGbl_Optarg);
    199             return (-1);
    200         }
    201 
    202         break;
    203 
    204 
    205     case 'b':   /* Debug options */
    206 
    207         switch (AcpiGbl_Optarg[0])
    208         {
    209 
    210         case 'c':
    211 
    212             printf ("Debug ASL to ASL+ conversion\n");
    213 
    214             AslGbl_DoAslConversion = TRUE;
    215             AslGbl_FoldConstants = FALSE;
    216             AslGbl_IntegerOptimizationFlag = FALSE;
    217             AslGbl_ReferenceOptimizationFlag = FALSE;
    218             AslGbl_OptimizeTrivialParseNodes = FALSE;
    219             AcpiGbl_CaptureComments = TRUE;
    220             AcpiGbl_DoDisassemblerOptimizations = FALSE;
    221             AcpiGbl_DebugAslConversion = TRUE;
    222             AcpiGbl_DmEmitExternalOpcodes = TRUE;
    223             AslGbl_DoExternalsInPlace = TRUE;
    224 
    225             return (0);
    226 
    227         case 'f':
    228 
    229             AslCompilerdebug = 1; /* same as yydebug */
    230             DtParserdebug = 1;
    231             PrParserdebug = 1;
    232             AslGbl_DebugFlag = TRUE;
    233             AslGbl_KeepPreprocessorTempFile = TRUE;
    234             break;
    235 
    236         case 'p':   /* Prune ASL parse tree */
    237 
    238             /* Get the required argument */
    239 
    240             if (AcpiGetoptArgument (argc, argv))
    241             {
    242                 return (-1);
    243             }
    244 
    245             AslGbl_PruneParseTree = TRUE;
    246             AslGbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
    247             break;
    248 
    249         case 's':
    250 
    251             AslGbl_DebugFlag = TRUE;
    252             break;
    253 
    254         case 't':
    255 
    256             /* Get the required argument */
    257 
    258             if (AcpiGetoptArgument (argc, argv))
    259             {
    260                 return (-1);
    261             }
    262             AslGbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
    263             break;
    264 
    265         default:
    266 
    267             printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
    268             return (-1);
    269         }
    270 
    271         break;
    272 
    273     case 'c':
    274 
    275         switch (AcpiGbl_Optarg[0])
    276         {
    277 
    278         case 'a':
    279 
    280             printf ("Convert ASL to ASL+ with comments\n");
    281             AslGbl_DoAslConversion = TRUE;
    282             AslGbl_FoldConstants = FALSE;
    283             AslGbl_IntegerOptimizationFlag = FALSE;
    284             AslGbl_ReferenceOptimizationFlag = FALSE;
    285             AslGbl_OptimizeTrivialParseNodes = FALSE;
    286             AcpiGbl_CaptureComments = TRUE;
    287             AcpiGbl_DoDisassemblerOptimizations = FALSE;
    288             AcpiGbl_DmEmitExternalOpcodes = TRUE;
    289             AslGbl_DoExternalsInPlace = TRUE;
    290 
    291             return (0);
    292 
    293         case 'r':
    294 
    295             AslGbl_NoResourceChecking = TRUE;
    296             break;
    297 
    298         default:
    299 
    300             printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
    301             return (-1);
    302         }
    303         break;
    304 
    305     case 'd':   /* Disassembler */
    306 
    307         switch (AcpiGbl_Optarg[0])
    308         {
    309         case '^':
    310 
    311             AslGbl_DoCompile = FALSE;
    312             break;
    313 
    314         case 'a':
    315 
    316             AslGbl_DoCompile = FALSE;
    317             AslGbl_DisassembleAll = TRUE;
    318             break;
    319 
    320         case 'b':   /* Do not convert buffers to resource descriptors */
    321 
    322             AcpiGbl_NoResourceDisassembly = TRUE;
    323             break;
    324 
    325         case 'c':
    326 
    327             break;
    328 
    329         case 'f':
    330 
    331             AcpiGbl_ForceAmlDisassembly = TRUE;
    332             break;
    333 
    334         case 'l':   /* Use legacy ASL code (not ASL+) for disassembly */
    335 
    336             AslGbl_DoCompile = FALSE;
    337             AcpiGbl_CstyleDisassembly = FALSE;
    338             break;
    339 
    340         case 's':   /* Specify table signature (Only supported for CDAT table) */
    341 
    342             /* Get the required argument */
    343 
    344             if (AcpiGetoptArgument (argc, argv))
    345             {
    346                 return (-1);
    347             }
    348 
    349             /* Check for exact string "CDAT" (upper or lower case) */
    350 
    351             AcpiGbl_CDAT = ACPI_CAST_PTR (char, &AcpiGbl_Optarg);
    352             if (AcpiUtStricmp (AcpiGbl_Optarg, ACPI_SIG_CDAT))
    353             {
    354                 printf ("\nUnknown table signature: %s\n", AcpiGbl_Optarg);
    355                 return (-1);
    356             }
    357 
    358             AcpiGbl_CDAT = malloc (5);
    359             AcpiUtSafeStrncpy ((char *) AcpiGbl_CDAT, ACPI_SIG_CDAT, 5);
    360             break;
    361 
    362         default:
    363 
    364             printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
    365             return (-1);
    366         }
    367 
    368         AcpiGbl_DisasmFlag = TRUE;
    369         break;
    370 
    371     case 'D':   /* Define a symbol */
    372 
    373         PrAddDefine (AcpiGbl_Optarg, NULL, TRUE);
    374         break;
    375 
    376     case 'e':   /* External files for disassembler */
    377 
    378         /* Get entire list of external files */
    379 
    380         AcpiGbl_Optind--;
    381         argv[AcpiGbl_Optind] = AcpiGbl_Optarg;
    382 
    383         while (argv[AcpiGbl_Optind] &&
    384               (argv[AcpiGbl_Optind][0] != '-'))
    385         {
    386             Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]);
    387             if (ACPI_FAILURE (Status))
    388             {
    389                 printf ("Could not add %s to external list\n",
    390                     argv[AcpiGbl_Optind]);
    391                 return (-1);
    392             }
    393 
    394             AcpiGbl_Optind++;
    395         }
    396         break;
    397 
    398     case 'f':
    399 
    400         switch (AcpiGbl_Optarg[0])
    401         {
    402         case '^':   /* Ignore errors and force creation of aml file */
    403 
    404             AslGbl_IgnoreErrors = TRUE;
    405             break;
    406 
    407         case 'e':   /* Disassembler: Get external declaration file */
    408 
    409             if (AcpiGetoptArgument (argc, argv))
    410             {
    411                 return (-1);
    412             }
    413 
    414             AslGbl_ExternalRefFilename = AcpiGbl_Optarg;
    415             break;
    416 
    417         default:
    418 
    419             printf ("Unknown option: -f%s\n", AcpiGbl_Optarg);
    420             return (-1);
    421         }
    422         break;
    423 
    424     case 'G':
    425 
    426         AslGbl_CompileGeneric = TRUE;
    427         break;
    428 
    429     case 'g':   /* Get all ACPI tables */
    430 
    431         printf ("-g option is deprecated, use acpidump utility instead\n");
    432         exit (1);
    433 
    434     case 'h':
    435 
    436         switch (AcpiGbl_Optarg[0])
    437         {
    438         case '^':
    439 
    440             Usage ();
    441             exit (0);
    442 
    443         case 'c':
    444 
    445             UtDisplayConstantOpcodes ();
    446             exit (0);
    447 
    448         case 'd':
    449 
    450             AslDisassemblyHelp ();
    451             exit (0);
    452 
    453         case 'f':
    454 
    455             AslFilenameHelp ();
    456             exit (0);
    457 
    458         case 'r':
    459 
    460             /* reserved names */
    461 
    462             ApDisplayReservedNames ();
    463             exit (0);
    464 
    465         case 't':
    466 
    467             UtDisplaySupportedTables ();
    468             exit (0);
    469 
    470         default:
    471 
    472             printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
    473             return (-1);
    474         }
    475 
    476     case 'I':   /* Add an include file search directory */
    477 
    478         FlAddIncludeDirectory (AcpiGbl_Optarg);
    479         break;
    480 
    481     case 'i':   /* Output AML as an include file */
    482 
    483         switch (AcpiGbl_Optarg[0])
    484         {
    485         case 'a':
    486 
    487             /* Produce assembly code include file */
    488 
    489             AslGbl_AsmIncludeOutputFlag = TRUE;
    490             break;
    491 
    492         case 'c':
    493 
    494             /* Produce C include file */
    495 
    496             AslGbl_C_IncludeOutputFlag = TRUE;
    497             break;
    498 
    499         case 'n':
    500 
    501             /* Compiler/Disassembler: Ignore the NOOP operator */
    502 
    503             AcpiGbl_IgnoreNoopOperator = TRUE;
    504             break;
    505 
    506         default:
    507 
    508             printf ("Unknown option: -i%s\n", AcpiGbl_Optarg);
    509             return (-1);
    510         }
    511         break;
    512 
    513     case 'l':   /* Listing files */
    514 
    515         switch (AcpiGbl_Optarg[0])
    516         {
    517         case '^':
    518 
    519             /* Produce listing file (Mixed source/aml) */
    520 
    521             AslGbl_ListingFlag = TRUE;
    522             AcpiGbl_DmOpt_Listing = TRUE;
    523             break;
    524 
    525         case 'd':
    526 
    527             /* Disable deterministic output, enabling timestamp */
    528 
    529             AslGbl_Deterministic = FALSE;
    530             break;
    531 
    532         case 'i':
    533 
    534             /* Produce preprocessor output file */
    535 
    536             AslGbl_PreprocessorOutputFlag = TRUE;
    537             break;
    538 
    539         case 'm':
    540 
    541             /* Produce hardware map summary file */
    542 
    543             AslGbl_MapfileFlag = TRUE;
    544             break;
    545 
    546         case 'n':
    547 
    548             /* Produce namespace file */
    549 
    550             AslGbl_NsOutputFlag = TRUE;
    551             break;
    552 
    553         case 's':
    554 
    555             /* Produce combined source file */
    556 
    557             AslGbl_SourceOutputFlag = TRUE;
    558             break;
    559 
    560         case 'x':
    561 
    562             /* Produce cross-reference file */
    563 
    564             AslGbl_CrossReferenceOutput = TRUE;
    565             break;
    566 
    567         default:
    568 
    569             printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
    570             return (-1);
    571         }
    572         break;
    573 
    574     case 'm':   /* Set line buffer size */
    575 
    576         AslGbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024;
    577         if (AslGbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE)
    578         {
    579             AslGbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE;
    580         }
    581         printf ("Line Buffer Size: %u\n", AslGbl_LineBufferSize);
    582         break;
    583 
    584     case 'n':   /* Parse only */
    585 
    586         AslGbl_ParseOnlyFlag = TRUE;
    587         break;
    588 
    589     case 'o':   /* Control compiler AML optimizations */
    590 
    591         switch (AcpiGbl_Optarg[0])
    592         {
    593         case 'a':
    594 
    595             /* Disable all optimizations */
    596 
    597             AslGbl_FoldConstants = FALSE;
    598             AslGbl_IntegerOptimizationFlag = FALSE;
    599             AslGbl_ReferenceOptimizationFlag = FALSE;
    600             AslGbl_OptimizeTrivialParseNodes = FALSE;
    601 
    602             break;
    603 
    604         case 'c':
    605 
    606             /* Display compile time(s) */
    607 
    608             AslGbl_CompileTimesFlag = TRUE;
    609             break;
    610 
    611         case 'd':
    612 
    613             /* Disable disassembler code optimizations */
    614 
    615             AcpiGbl_DoDisassemblerOptimizations = FALSE;
    616             break;
    617 
    618         case 'e':
    619 
    620             /* Disassembler: Emit embedded external operators */
    621 
    622             AcpiGbl_DmEmitExternalOpcodes = TRUE;
    623             break;
    624 
    625         case 'E':
    626 
    627             /*
    628              * iASL: keep External opcodes in place.
    629              * No affect if Gbl_DoExternals is false.
    630              */
    631 
    632             AslGbl_DoExternalsInPlace = TRUE;
    633             break;
    634 
    635         case 'f':
    636 
    637             /* Disable folding on "normal" expressions */
    638 
    639             AslGbl_FoldConstants = FALSE;
    640             break;
    641 
    642         case 'i':
    643 
    644             /* Disable integer optimization to constants */
    645 
    646             AslGbl_IntegerOptimizationFlag = FALSE;
    647             break;
    648 
    649         case 'n':
    650 
    651             /* Disable named reference optimization */
    652 
    653             AslGbl_ReferenceOptimizationFlag = FALSE;
    654             break;
    655 
    656         case 't':
    657 
    658             /* Disable heavy typechecking */
    659 
    660             AslGbl_DoTypechecking = FALSE;
    661             break;
    662 
    663         default:
    664 
    665             printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
    666             return (-1);
    667         }
    668         break;
    669 
    670     case 'P':   /* Preprocessor options */
    671 
    672         switch (AcpiGbl_Optarg[0])
    673         {
    674         case '^':   /* Proprocess only, emit (.i) file */
    675 
    676             AslGbl_PreprocessOnly = TRUE;
    677             AslGbl_PreprocessorOutputFlag = TRUE;
    678             break;
    679 
    680         case 'n':   /* Disable preprocessor */
    681 
    682             AslGbl_PreprocessFlag = FALSE;
    683             break;
    684 
    685         default:
    686 
    687             printf ("Unknown option: -P%s\n", AcpiGbl_Optarg);
    688             return (-1);
    689         }
    690         break;
    691 
    692     case 'p':   /* Override default AML output filename */
    693 
    694         AslGbl_OutputFilenamePrefix = AcpiGbl_Optarg;
    695         UtConvertBackslashes (AslGbl_OutputFilenamePrefix);
    696         AslGbl_UseDefaultAmlFilename = FALSE;
    697         break;
    698 
    699     case 'q':   /* ASL/ASl+ converter: compile only and leave badaml. */
    700 
    701         printf ("Convert ASL to ASL+ with comments\n");
    702         AslGbl_FoldConstants = FALSE;
    703         AslGbl_IntegerOptimizationFlag = FALSE;
    704         AslGbl_ReferenceOptimizationFlag = FALSE;
    705         AslGbl_OptimizeTrivialParseNodes = FALSE;
    706         AslGbl_DoExternalsInPlace = TRUE;
    707         AcpiGbl_CaptureComments = TRUE;
    708         return (0);
    709 
    710     case 'r':   /* Override revision found in table header */
    711 
    712         AslGbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
    713         break;
    714 
    715     case 's':   /* Create AML in a source code file */
    716 
    717         switch (AcpiGbl_Optarg[0])
    718         {
    719         case 'a':
    720 
    721             /* Produce assembly code output file */
    722 
    723             AslGbl_AsmOutputFlag = TRUE;
    724             break;
    725 
    726         case 'c':
    727 
    728             /* Produce C hex output file */
    729 
    730             AslGbl_C_OutputFlag = TRUE;
    731             break;
    732 
    733         case 'o':
    734 
    735             /* Produce AML offset table in C */
    736 
    737             AslGbl_C_OffsetTableFlag = TRUE;
    738             break;
    739 
    740         default:
    741 
    742             printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
    743             return (-1);
    744         }
    745         break;
    746 
    747     case 't':   /* Produce hex table output file */
    748 
    749         switch (AcpiGbl_Optarg[0])
    750         {
    751         case 'a':
    752 
    753             AslGbl_HexOutputFlag = HEX_OUTPUT_ASM;
    754             break;
    755 
    756         case 'c':
    757 
    758             AslGbl_HexOutputFlag = HEX_OUTPUT_C;
    759             break;
    760 
    761         case 'p': /* data table flex/bison prototype */
    762 
    763             AslGbl_DtLexBisonPrototype = TRUE;
    764             break;
    765 
    766         case 's':
    767 
    768             AslGbl_HexOutputFlag = HEX_OUTPUT_ASL;
    769             break;
    770 
    771         default:
    772 
    773             printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
    774             return (-1);
    775         }
    776         break;
    777 
    778     case 'T':   /* Create a ACPI table template file */
    779 
    780         AslGbl_DoTemplates = TRUE;
    781         break;
    782 
    783     case 'v':   /* Version and verbosity settings */
    784 
    785         switch (AcpiGbl_Optarg[0])
    786         {
    787         case '^':
    788 
    789             printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
    790             exit (0);
    791 
    792         case 'a':
    793 
    794             /* Disable all error/warning/remark messages */
    795 
    796             AslGbl_NoErrors = TRUE;
    797             break;
    798 
    799         case 'd':
    800 
    801             printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
    802             printf (ACPI_COMMON_BUILD_TIME);
    803             exit (0);
    804 
    805         case 'e':
    806 
    807             /* Disable all warning/remark messages (errors only) */
    808 
    809             AslGbl_DisplayRemarks = FALSE;
    810             AslGbl_DisplayWarnings = FALSE;
    811             break;
    812 
    813         case 'i':
    814             /*
    815              * Support for integrated development environment(s).
    816              *
    817              * 1) No compiler signon
    818              * 2) Send stderr messages to stdout
    819              * 3) Less verbose error messages (single line only for each)
    820              * 4) Error/warning messages are formatted appropriately to
    821              *    be recognized by MS Visual Studio
    822              */
    823             AslGbl_VerboseErrors = FALSE;
    824             AslGbl_DoSignon = FALSE;
    825             break;
    826 
    827         case 'o':
    828 
    829             AslGbl_DisplayOptimizations = TRUE;
    830             break;
    831 
    832         case 'r':
    833 
    834             AslGbl_DisplayRemarks = FALSE;
    835             break;
    836 
    837         case 's':
    838 
    839             AslGbl_DoSignon = FALSE;
    840             break;
    841 
    842         case 't':
    843 
    844             AslGbl_VerboseTemplates = TRUE;
    845             break;
    846 
    847         case 'w':
    848 
    849             /* Get the required argument */
    850 
    851             if (AcpiGetoptArgument (argc, argv))
    852             {
    853                 return (-1);
    854             }
    855 
    856             Status = AslDisableException (AcpiGbl_Optarg);
    857             if (ACPI_FAILURE (Status))
    858             {
    859                 return (-1);
    860             }
    861             break;
    862 
    863         case 'x':
    864 
    865             /* Get the required argument */
    866 
    867             if (AcpiGetoptArgument (argc, argv))
    868             {
    869                 return (-1);
    870             }
    871 
    872             Status = AslLogExpectedException (AcpiGbl_Optarg);
    873             if (ACPI_FAILURE (Status))
    874             {
    875                 return (-1);
    876             }
    877             break;
    878 
    879         default:
    880 
    881             printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
    882             return (-1);
    883         }
    884         break;
    885 
    886     case 'w': /* Set warning levels */
    887 
    888         switch (AcpiGbl_Optarg[0])
    889         {
    890         case '1':
    891 
    892             AslGbl_WarningLevel = ASL_WARNING;
    893             break;
    894 
    895         case '2':
    896 
    897             AslGbl_WarningLevel = ASL_WARNING2;
    898             break;
    899 
    900         case '3':
    901 
    902             AslGbl_WarningLevel = ASL_WARNING3;
    903             break;
    904 
    905         case 'e':
    906 
    907             AslGbl_WarningsAsErrors = TRUE;
    908             break;
    909 
    910         case 'w':
    911 
    912             /* Get the required argument */
    913 
    914             if (AcpiGetoptArgument (argc, argv))
    915             {
    916                 return (-1);
    917             }
    918 
    919             Status = AslElevateException (AcpiGbl_Optarg);
    920             if (ACPI_FAILURE (Status))
    921             {
    922                 return (-1);
    923             }
    924             break;
    925 
    926 
    927         default:
    928 
    929             printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);
    930             return (-1);
    931         }
    932         break;
    933 
    934     case 'x':   /* Set debug print output level */
    935 
    936         AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
    937         break;
    938 
    939     case 'z':
    940 
    941         AslGbl_UseOriginalCompilerId = TRUE;
    942         break;
    943 
    944     default:
    945 
    946         return (-1);
    947     }
    948 
    949     return (0);
    950 }
    951 
    952 
    953 /*******************************************************************************
    954  *
    955  * FUNCTION:    AslMergeOptionTokens
    956  *
    957  * PARAMETERS:  InBuffer            - Input containing an option string
    958  *              OutBuffer           - Merged output buffer
    959  *
    960  * RETURN:      None
    961  *
    962  * DESCRIPTION: Remove all whitespace from an option string.
    963  *
    964  ******************************************************************************/
    965 
    966 static void
    967 AslMergeOptionTokens (
    968     char                    *InBuffer,
    969     char                    *OutBuffer)
    970 {
    971     char                    *Token;
    972 
    973 
    974     *OutBuffer = 0;
    975 
    976     Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS);
    977     while (Token)
    978     {
    979         strcat (OutBuffer, Token);
    980         Token = strtok (NULL, ASL_TOKEN_SEPARATORS);
    981     }
    982 }
    983 
    984 
    985 /*******************************************************************************
    986  *
    987  * FUNCTION:    AslDoResponseFile
    988  *
    989  * PARAMETERS:  Filename        - Name of the response file
    990  *
    991  * RETURN:      Status
    992  *
    993  * DESCRIPTION: Open a response file and process all options within.
    994  *
    995  ******************************************************************************/
    996 
    997 static int
    998 AslDoResponseFile (
    999     char                    *Filename)
   1000 {
   1001     char                    *argv = AslGbl_StringBuffer2;
   1002     FILE                    *ResponseFile;
   1003     int                     OptStatus = 0;
   1004     int                     Opterr;
   1005     int                     Optind;
   1006 
   1007 
   1008     ResponseFile = fopen (Filename, "r");
   1009     if (!ResponseFile)
   1010     {
   1011         printf ("Could not open command file %s, %s\n",
   1012             Filename, strerror (errno));
   1013         return (-1);
   1014     }
   1015 
   1016     /* Must save the current GetOpt globals */
   1017 
   1018     Opterr = AcpiGbl_Opterr;
   1019     Optind = AcpiGbl_Optind;
   1020 
   1021     /*
   1022      * Process all lines in the response file. There must be one complete
   1023      * option per line
   1024      */
   1025     while (fgets (AslGbl_StringBuffer, ASL_STRING_BUFFER_SIZE, ResponseFile))
   1026     {
   1027         /* Compress all tokens, allowing us to use a single argv entry */
   1028 
   1029         AslMergeOptionTokens (AslGbl_StringBuffer, AslGbl_StringBuffer2);
   1030 
   1031         /* Process the option */
   1032 
   1033         AcpiGbl_Opterr = 0;
   1034         AcpiGbl_Optind = 0;
   1035 
   1036         OptStatus = AslDoOptions (1, &argv, TRUE);
   1037         if (OptStatus)
   1038         {
   1039             printf ("Invalid option in command file %s: %s\n",
   1040                 Filename, AslGbl_StringBuffer);
   1041             break;
   1042         }
   1043     }
   1044 
   1045     /* Restore the GetOpt globals */
   1046 
   1047     AcpiGbl_Opterr = Opterr;
   1048     AcpiGbl_Optind = Optind;
   1049 
   1050     fclose (ResponseFile);
   1051     return (OptStatus);
   1052 }
   1053