Home | History | Annotate | Line # | Download | only in compiler
asloptions.c revision 1.1.1.11
      1 /******************************************************************************
      2  *
      3  * Module Name: asloptions - compiler command line processing
      4  *
      5  *****************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2017, 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 MERCHANTIBILITY 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 
     48 #define _COMPONENT          ACPI_COMPILER
     49         ACPI_MODULE_NAME    ("asloption")
     50 
     51 
     52 /* Local prototypes */
     53 
     54 static int
     55 AslDoOptions (
     56     int                     argc,
     57     char                    **argv,
     58     BOOLEAN                 IsResponseFile);
     59 
     60 static void
     61 AslMergeOptionTokens (
     62     char                    *InBuffer,
     63     char                    *OutBuffer);
     64 
     65 static int
     66 AslDoResponseFile (
     67     char                    *Filename);
     68 
     69 
     70 #define ASL_TOKEN_SEPARATORS    " \t\n"
     71 #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"
     72 
     73 static char ASL_BUILD_DATE[] = __DATE__;
     74 static char ASL_BUILD_TIME[] = __TIME__;
     75 
     76 
     77 /*******************************************************************************
     78  *
     79  * FUNCTION:    AslCommandLine
     80  *
     81  * PARAMETERS:  argc/argv
     82  *
     83  * RETURN:      Last argv index
     84  *
     85  * DESCRIPTION: Command line processing
     86  *
     87  ******************************************************************************/
     88 
     89 int
     90 AslCommandLine (
     91     int                     argc,
     92     char                    **argv)
     93 {
     94     int                     BadCommandLine = 0;
     95     ACPI_STATUS             Status;
     96 
     97 
     98     /* Minimum command line contains at least the command and an input file */
     99 
    100     if (argc < 2)
    101     {
    102         printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
    103         Usage ();
    104         exit (1);
    105     }
    106 
    107     /* Process all command line options */
    108 
    109     BadCommandLine = AslDoOptions (argc, argv, FALSE);
    110 
    111     if (Gbl_DoTemplates)
    112     {
    113         Status = DtCreateTemplates (argv);
    114         if (ACPI_FAILURE (Status))
    115         {
    116             exit (-1);
    117         }
    118         exit (1);
    119     }
    120 
    121     /* Next parameter must be the input filename */
    122 
    123     if (!argv[AcpiGbl_Optind] &&
    124         !AcpiGbl_DisasmFlag)
    125     {
    126         printf ("Missing input filename\n");
    127         BadCommandLine = TRUE;
    128     }
    129 
    130     if (Gbl_DoSignon)
    131     {
    132         printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
    133         if (Gbl_IgnoreErrors)
    134         {
    135             printf ("Ignoring all errors, forcing AML file generation\n\n");
    136         }
    137     }
    138 
    139     if (BadCommandLine)
    140     {
    141         printf ("Use -h option for help information\n");
    142         exit (1);
    143     }
    144 
    145     return (AcpiGbl_Optind);
    146 }
    147 
    148 
    149 /*******************************************************************************
    150  *
    151  * FUNCTION:    AslDoOptions
    152  *
    153  * PARAMETERS:  argc/argv           - Standard argc/argv
    154  *              IsResponseFile      - TRUE if executing a response file.
    155  *
    156  * RETURN:      Status
    157  *
    158  * DESCRIPTION: Command line option processing
    159  *
    160  ******************************************************************************/
    161 
    162 static int
    163 AslDoOptions (
    164     int                     argc,
    165     char                    **argv,
    166     BOOLEAN                 IsResponseFile)
    167 {
    168     ACPI_STATUS             Status;
    169     UINT32                  j;
    170 
    171 
    172     /* Get the command line options */
    173 
    174     while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j)
    175     {
    176     case '@':   /* Begin a response file */
    177 
    178         if (IsResponseFile)
    179         {
    180             printf ("Nested command files are not supported\n");
    181             return (-1);
    182         }
    183 
    184         if (AslDoResponseFile (AcpiGbl_Optarg))
    185         {
    186             return (-1);
    187         }
    188         break;
    189 
    190     case 'a':   /* Debug options */
    191 
    192         switch (AcpiGbl_Optarg[0])
    193         {
    194         case 'r':
    195 
    196             Gbl_EnableReferenceTypechecking = TRUE;
    197             break;
    198 
    199         default:
    200 
    201             printf ("Unknown option: -a%s\n", AcpiGbl_Optarg);
    202             return (-1);
    203         }
    204 
    205         break;
    206 
    207 
    208     case 'b':   /* Debug options */
    209 
    210         switch (AcpiGbl_Optarg[0])
    211         {
    212 
    213         case 'c':
    214 
    215             printf ("Debug ASL to ASL+ conversion\n");
    216 
    217             Gbl_DoAslConversion = TRUE;
    218             Gbl_FoldConstants = FALSE;
    219             Gbl_IntegerOptimizationFlag = FALSE;
    220             Gbl_ReferenceOptimizationFlag = FALSE;
    221             Gbl_OptimizeTrivialParseNodes = FALSE;
    222             Gbl_CaptureComments = TRUE;
    223             AcpiGbl_DoDisassemblerOptimizations = FALSE;
    224             AcpiGbl_DebugAslConversion = TRUE;
    225             AcpiGbl_DmEmitExternalOpcodes = TRUE;
    226             Gbl_DoExternalsInPlace = TRUE;
    227 
    228             return (0);
    229 
    230         case 'f':
    231 
    232             AslCompilerdebug = 1; /* same as yydebug */
    233             DtParserdebug = 1;
    234             PrParserdebug = 1;
    235             Gbl_DebugFlag = TRUE;
    236             Gbl_KeepPreprocessorTempFile = TRUE;
    237             break;
    238 
    239         case 'p':   /* Prune ASL parse tree */
    240 
    241             /* Get the required argument */
    242 
    243             if (AcpiGetoptArgument (argc, argv))
    244             {
    245                 return (-1);
    246             }
    247 
    248             Gbl_PruneParseTree = TRUE;
    249             Gbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
    250             break;
    251 
    252         case 's':
    253 
    254             Gbl_DebugFlag = TRUE;
    255             break;
    256 
    257         case 't':
    258 
    259             /* Get the required argument */
    260 
    261             if (AcpiGetoptArgument (argc, argv))
    262             {
    263                 return (-1);
    264             }
    265 
    266             Gbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
    267             break;
    268 
    269         default:
    270 
    271             printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
    272             return (-1);
    273         }
    274 
    275         break;
    276 
    277     case 'c':
    278 
    279         switch (AcpiGbl_Optarg[0])
    280         {
    281 
    282         case 'a':
    283 
    284             printf ("Convert ASL to ASL+ with comments\n");
    285             Gbl_DoAslConversion = TRUE;
    286             Gbl_FoldConstants = FALSE;
    287             Gbl_IntegerOptimizationFlag = FALSE;
    288             Gbl_ReferenceOptimizationFlag = FALSE;
    289             Gbl_OptimizeTrivialParseNodes = FALSE;
    290             Gbl_CaptureComments = TRUE;
    291             AcpiGbl_DoDisassemblerOptimizations = FALSE;
    292             AcpiGbl_DmEmitExternalOpcodes = TRUE;
    293             Gbl_DoExternalsInPlace = TRUE;
    294 
    295             return (0);
    296 
    297         case 'r':
    298 
    299             Gbl_NoResourceChecking = TRUE;
    300             break;
    301 
    302         default:
    303 
    304             printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
    305             return (-1);
    306         }
    307         break;
    308 
    309     case 'd':   /* Disassembler */
    310 
    311         switch (AcpiGbl_Optarg[0])
    312         {
    313         case '^':
    314 
    315             /* Get the required argument */
    316 
    317             if (AcpiGetoptArgument (argc, argv))
    318             {
    319                 return (-1);
    320             }
    321 
    322             Gbl_DoCompile = FALSE;
    323             break;
    324 
    325         case 'a':
    326 
    327             /* Get the required argument */
    328 
    329             if (AcpiGetoptArgument (argc, argv))
    330             {
    331                 return (-1);
    332             }
    333 
    334             Gbl_DoCompile = FALSE;
    335             Gbl_DisassembleAll = TRUE;
    336             break;
    337 
    338         case 'b':   /* Do not convert buffers to resource descriptors */
    339 
    340             AcpiGbl_NoResourceDisassembly = TRUE;
    341             break;
    342 
    343         case 'c':
    344 
    345             break;
    346 
    347         case 'f':
    348 
    349             AcpiGbl_ForceAmlDisassembly = TRUE;
    350             break;
    351 
    352         case 'l':   /* Use legacy ASL code (not ASL+) for disassembly */
    353 
    354             Gbl_DoCompile = FALSE;
    355             AcpiGbl_CstyleDisassembly = FALSE;
    356             break;
    357 
    358         default:
    359 
    360             printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
    361             return (-1);
    362         }
    363 
    364         AcpiGbl_DisasmFlag = TRUE;
    365         break;
    366 
    367     case 'D':   /* Define a symbol */
    368 
    369         PrAddDefine (AcpiGbl_Optarg, NULL, TRUE);
    370         break;
    371 
    372     case 'e':   /* External files for disassembler */
    373 
    374         /* Get entire list of external files */
    375 
    376         AcpiGbl_Optind--;
    377         argv[AcpiGbl_Optind] = AcpiGbl_Optarg;
    378 
    379         while (argv[AcpiGbl_Optind] &&
    380               (argv[AcpiGbl_Optind][0] != '-'))
    381         {
    382             Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]);
    383             if (ACPI_FAILURE (Status))
    384             {
    385                 printf ("Could not add %s to external list\n",
    386                     argv[AcpiGbl_Optind]);
    387                 return (-1);
    388             }
    389 
    390             AcpiGbl_Optind++;
    391         }
    392         break;
    393 
    394     case 'f':
    395 
    396         switch (AcpiGbl_Optarg[0])
    397         {
    398         case '^':   /* Ignore errors and force creation of aml file */
    399 
    400             Gbl_IgnoreErrors = TRUE;
    401             break;
    402 
    403         case 'e':   /* Disassembler: Get external declaration file */
    404 
    405             if (AcpiGetoptArgument (argc, argv))
    406             {
    407                 return (-1);
    408             }
    409 
    410             Gbl_ExternalRefFilename = AcpiGbl_Optarg;
    411             break;
    412 
    413         default:
    414 
    415             printf ("Unknown option: -f%s\n", AcpiGbl_Optarg);
    416             return (-1);
    417         }
    418         break;
    419 
    420     case 'G':
    421 
    422         Gbl_CompileGeneric = TRUE;
    423         break;
    424 
    425     case 'g':   /* Get all ACPI tables */
    426 
    427         printf ("-g option is deprecated, use acpidump utility instead\n");
    428         exit (1);
    429 
    430     case 'h':
    431 
    432         switch (AcpiGbl_Optarg[0])
    433         {
    434         case '^':
    435 
    436             printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
    437             Usage ();
    438             exit (0);
    439 
    440         case 'c':
    441 
    442             UtDisplayConstantOpcodes ();
    443             exit (0);
    444 
    445         case 'd':
    446 
    447             AslDisassemblyHelp ();
    448             exit (0);
    449 
    450         case 'f':
    451 
    452             AslFilenameHelp ();
    453             exit (0);
    454 
    455         case 'r':
    456 
    457             /* reserved names */
    458 
    459             ApDisplayReservedNames ();
    460             exit (0);
    461 
    462         case 't':
    463 
    464             UtDisplaySupportedTables ();
    465             exit (0);
    466 
    467         default:
    468 
    469             printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
    470             return (-1);
    471         }
    472 
    473     case 'I':   /* Add an include file search directory */
    474 
    475         FlAddIncludeDirectory (AcpiGbl_Optarg);
    476         break;
    477 
    478     case 'i':   /* Output AML as an include file */
    479 
    480         switch (AcpiGbl_Optarg[0])
    481         {
    482         case 'a':
    483 
    484             /* Produce assembly code include file */
    485 
    486             Gbl_AsmIncludeOutputFlag = TRUE;
    487             break;
    488 
    489         case 'c':
    490 
    491             /* Produce C include file */
    492 
    493             Gbl_C_IncludeOutputFlag = TRUE;
    494             break;
    495 
    496         case 'n':
    497 
    498             /* Compiler/Disassembler: Ignore the NOOP operator */
    499 
    500             AcpiGbl_IgnoreNoopOperator = TRUE;
    501             break;
    502 
    503         default:
    504 
    505             printf ("Unknown option: -i%s\n", AcpiGbl_Optarg);
    506             return (-1);
    507         }
    508         break;
    509 
    510     case 'l':   /* Listing files */
    511 
    512         switch (AcpiGbl_Optarg[0])
    513         {
    514         case '^':
    515 
    516             /* Produce listing file (Mixed source/aml) */
    517 
    518             Gbl_ListingFlag = TRUE;
    519             AcpiGbl_DmOpt_Listing = TRUE;
    520             break;
    521 
    522         case 'i':
    523 
    524             /* Produce preprocessor output file */
    525 
    526             Gbl_PreprocessorOutputFlag = TRUE;
    527             break;
    528 
    529         case 'm':
    530 
    531             /* Produce hardware map summary file */
    532 
    533             Gbl_MapfileFlag = TRUE;
    534             break;
    535 
    536         case 'n':
    537 
    538             /* Produce namespace file */
    539 
    540             Gbl_NsOutputFlag = TRUE;
    541             break;
    542 
    543         case 's':
    544 
    545             /* Produce combined source file */
    546 
    547             Gbl_SourceOutputFlag = TRUE;
    548             break;
    549 
    550         case 'x':
    551 
    552             /* Produce cross-reference file */
    553 
    554             Gbl_CrossReferenceOutput = TRUE;
    555             break;
    556 
    557         default:
    558 
    559             printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
    560             return (-1);
    561         }
    562         break;
    563 
    564     case 'm':   /* Set line buffer size */
    565 
    566         Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024;
    567         if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE)
    568         {
    569             Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE;
    570         }
    571         printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize);
    572         break;
    573 
    574     case 'n':   /* Parse only */
    575 
    576         Gbl_ParseOnlyFlag = TRUE;
    577         break;
    578 
    579     case 'o':   /* Control compiler AML optimizations */
    580 
    581         switch (AcpiGbl_Optarg[0])
    582         {
    583         case 'a':
    584 
    585             /* Disable all optimizations */
    586 
    587             Gbl_FoldConstants = FALSE;
    588             Gbl_IntegerOptimizationFlag = FALSE;
    589             Gbl_ReferenceOptimizationFlag = FALSE;
    590             Gbl_OptimizeTrivialParseNodes = FALSE;
    591 
    592             break;
    593 
    594         case 'c':
    595 
    596             /* Display compile time(s) */
    597 
    598             Gbl_CompileTimesFlag = TRUE;
    599             break;
    600 
    601         case 'd':
    602 
    603             /* Disable disassembler code optimizations */
    604 
    605             AcpiGbl_DoDisassemblerOptimizations = FALSE;
    606             break;
    607 
    608         case 'e':
    609 
    610             /* Disassembler: Emit embedded external operators */
    611 
    612             AcpiGbl_DmEmitExternalOpcodes = TRUE;
    613             break;
    614 
    615         case 'E':
    616 
    617             /*
    618              * iASL: keep External opcodes in place.
    619              * No affect if Gbl_DoExternals is false.
    620              */
    621 
    622             Gbl_DoExternalsInPlace = TRUE;
    623             break;
    624 
    625         case 'f':
    626 
    627             /* Disable folding on "normal" expressions */
    628 
    629             Gbl_FoldConstants = FALSE;
    630             break;
    631 
    632         case 'i':
    633 
    634             /* Disable integer optimization to constants */
    635 
    636             Gbl_IntegerOptimizationFlag = FALSE;
    637             break;
    638 
    639         case 'n':
    640 
    641             /* Disable named reference optimization */
    642 
    643             Gbl_ReferenceOptimizationFlag = FALSE;
    644             break;
    645 
    646         case 't':
    647 
    648             /* Disable heavy typechecking */
    649 
    650             Gbl_DoTypechecking = FALSE;
    651             break;
    652 
    653         default:
    654 
    655             printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
    656             return (-1);
    657         }
    658         break;
    659 
    660     case 'P':   /* Preprocessor options */
    661 
    662         switch (AcpiGbl_Optarg[0])
    663         {
    664         case '^':   /* Proprocess only, emit (.i) file */
    665 
    666             Gbl_PreprocessOnly = TRUE;
    667             Gbl_PreprocessorOutputFlag = TRUE;
    668             break;
    669 
    670         case 'n':   /* Disable preprocessor */
    671 
    672             Gbl_PreprocessFlag = FALSE;
    673             break;
    674 
    675         default:
    676 
    677             printf ("Unknown option: -P%s\n", AcpiGbl_Optarg);
    678             return (-1);
    679         }
    680         break;
    681 
    682     case 'p':   /* Override default AML output filename */
    683 
    684         Gbl_OutputFilenamePrefix = AcpiGbl_Optarg;
    685         UtConvertBackslashes (Gbl_OutputFilenamePrefix);
    686         Gbl_UseDefaultAmlFilename = FALSE;
    687         break;
    688 
    689     case 'q':   /* ASL/ASl+ converter: compile only and leave badaml. */
    690 
    691         printf ("Convert ASL to ASL+ with comments\n");
    692         Gbl_FoldConstants = FALSE;
    693         Gbl_IntegerOptimizationFlag = FALSE;
    694         Gbl_ReferenceOptimizationFlag = FALSE;
    695         Gbl_OptimizeTrivialParseNodes = FALSE;
    696         Gbl_CaptureComments = TRUE;
    697         Gbl_DoExternalsInPlace = TRUE;
    698         return (0);
    699 
    700     case 'r':   /* Override revision found in table header */
    701 
    702         Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
    703         break;
    704 
    705     case 's':   /* Create AML in a source code file */
    706 
    707         switch (AcpiGbl_Optarg[0])
    708         {
    709         case 'a':
    710 
    711             /* Produce assembly code output file */
    712 
    713             Gbl_AsmOutputFlag = TRUE;
    714             break;
    715 
    716         case 'c':
    717 
    718             /* Produce C hex output file */
    719 
    720             Gbl_C_OutputFlag = TRUE;
    721             break;
    722 
    723         case 'o':
    724 
    725             /* Produce AML offset table in C */
    726 
    727             Gbl_C_OffsetTableFlag = TRUE;
    728             break;
    729 
    730         default:
    731 
    732             printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
    733             return (-1);
    734         }
    735         break;
    736 
    737     case 't':   /* Produce hex table output file */
    738 
    739         switch (AcpiGbl_Optarg[0])
    740         {
    741         case 'a':
    742 
    743             Gbl_HexOutputFlag = HEX_OUTPUT_ASM;
    744             break;
    745 
    746         case 'c':
    747 
    748             Gbl_HexOutputFlag = HEX_OUTPUT_C;
    749             break;
    750 
    751         case 's':
    752 
    753             Gbl_HexOutputFlag = HEX_OUTPUT_ASL;
    754             break;
    755 
    756         default:
    757 
    758             printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
    759             return (-1);
    760         }
    761         break;
    762 
    763     case 'T':   /* Create a ACPI table template file */
    764 
    765         Gbl_DoTemplates = TRUE;
    766         break;
    767 
    768     case 'v':   /* Version and verbosity settings */
    769 
    770         switch (AcpiGbl_Optarg[0])
    771         {
    772         case '^':
    773 
    774             printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
    775             exit (0);
    776 
    777         case 'a':
    778 
    779             /* Disable all error/warning/remark messages */
    780 
    781             Gbl_NoErrors = TRUE;
    782             break;
    783 
    784         case 'd':
    785 
    786             printf ("%s Build date/time: %s %s\n",
    787                 ASL_COMPILER_NAME, ASL_BUILD_DATE, ASL_BUILD_TIME);
    788             exit (0);
    789 
    790         case 'e':
    791 
    792             /* Disable all warning/remark messages (errors only) */
    793 
    794             Gbl_DisplayRemarks = FALSE;
    795             Gbl_DisplayWarnings = FALSE;
    796             break;
    797 
    798         case 'i':
    799             /*
    800              * Support for integrated development environment(s).
    801              *
    802              * 1) No compiler signon
    803              * 2) Send stderr messages to stdout
    804              * 3) Less verbose error messages (single line only for each)
    805              * 4) Error/warning messages are formatted appropriately to
    806              *    be recognized by MS Visual Studio
    807              */
    808             Gbl_VerboseErrors = FALSE;
    809             Gbl_DoSignon = FALSE;
    810             Gbl_Files[ASL_FILE_STDERR].Handle = stdout;
    811             break;
    812 
    813         case 'o':
    814 
    815             Gbl_DisplayOptimizations = TRUE;
    816             break;
    817 
    818         case 'r':
    819 
    820             Gbl_DisplayRemarks = FALSE;
    821             break;
    822 
    823         case 's':
    824 
    825             Gbl_DoSignon = FALSE;
    826             break;
    827 
    828         case 't':
    829 
    830             Gbl_VerboseTemplates = TRUE;
    831             break;
    832 
    833         case 'w':
    834 
    835             /* Get the required argument */
    836 
    837             if (AcpiGetoptArgument (argc, argv))
    838             {
    839                 return (-1);
    840             }
    841 
    842             Status = AslDisableException (AcpiGbl_Optarg);
    843             if (ACPI_FAILURE (Status))
    844             {
    845                 return (-1);
    846             }
    847             break;
    848 
    849         case 'x':
    850 
    851             /* Get the required argument */
    852 
    853             if (AcpiGetoptArgument (argc, argv))
    854             {
    855                 return (-1);
    856             }
    857 
    858             Status = AslExpectException (AcpiGbl_Optarg);
    859             if (ACPI_FAILURE (Status))
    860             {
    861                 return (-1);
    862             }
    863             break;
    864 
    865         default:
    866 
    867             printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
    868             return (-1);
    869         }
    870         break;
    871 
    872     case 'w': /* Set warning levels */
    873 
    874         switch (AcpiGbl_Optarg[0])
    875         {
    876         case '1':
    877 
    878             Gbl_WarningLevel = ASL_WARNING;
    879             break;
    880 
    881         case '2':
    882 
    883             Gbl_WarningLevel = ASL_WARNING2;
    884             break;
    885 
    886         case '3':
    887 
    888             Gbl_WarningLevel = ASL_WARNING3;
    889             break;
    890 
    891         case 'e':
    892 
    893             Gbl_WarningsAsErrors = TRUE;
    894             break;
    895 
    896         default:
    897 
    898             printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);
    899             return (-1);
    900         }
    901         break;
    902 
    903     case 'x':   /* Set debug print output level */
    904 
    905         AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
    906         break;
    907 
    908     case 'z':
    909 
    910         Gbl_UseOriginalCompilerId = TRUE;
    911         break;
    912 
    913     default:
    914 
    915         return (-1);
    916     }
    917 
    918     return (0);
    919 }
    920 
    921 
    922 /*******************************************************************************
    923  *
    924  * FUNCTION:    AslMergeOptionTokens
    925  *
    926  * PARAMETERS:  InBuffer            - Input containing an option string
    927  *              OutBuffer           - Merged output buffer
    928  *
    929  * RETURN:      None
    930  *
    931  * DESCRIPTION: Remove all whitespace from an option string.
    932  *
    933  ******************************************************************************/
    934 
    935 static void
    936 AslMergeOptionTokens (
    937     char                    *InBuffer,
    938     char                    *OutBuffer)
    939 {
    940     char                    *Token;
    941 
    942 
    943     *OutBuffer = 0;
    944 
    945     Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS);
    946     while (Token)
    947     {
    948         strcat (OutBuffer, Token);
    949         Token = strtok (NULL, ASL_TOKEN_SEPARATORS);
    950     }
    951 }
    952 
    953 
    954 /*******************************************************************************
    955  *
    956  * FUNCTION:    AslDoResponseFile
    957  *
    958  * PARAMETERS:  Filename        - Name of the response file
    959  *
    960  * RETURN:      Status
    961  *
    962  * DESCRIPTION: Open a response file and process all options within.
    963  *
    964  ******************************************************************************/
    965 
    966 static int
    967 AslDoResponseFile (
    968     char                    *Filename)
    969 {
    970     char                    *argv = StringBuffer2;
    971     FILE                    *ResponseFile;
    972     int                     OptStatus = 0;
    973     int                     Opterr;
    974     int                     Optind;
    975 
    976 
    977     ResponseFile = fopen (Filename, "r");
    978     if (!ResponseFile)
    979     {
    980         printf ("Could not open command file %s, %s\n",
    981             Filename, strerror (errno));
    982         return (-1);
    983     }
    984 
    985     /* Must save the current GetOpt globals */
    986 
    987     Opterr = AcpiGbl_Opterr;
    988     Optind = AcpiGbl_Optind;
    989 
    990     /*
    991      * Process all lines in the response file. There must be one complete
    992      * option per line
    993      */
    994     while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile))
    995     {
    996         /* Compress all tokens, allowing us to use a single argv entry */
    997 
    998         AslMergeOptionTokens (StringBuffer, StringBuffer2);
    999 
   1000         /* Process the option */
   1001 
   1002         AcpiGbl_Opterr = 0;
   1003         AcpiGbl_Optind = 0;
   1004 
   1005         OptStatus = AslDoOptions (1, &argv, TRUE);
   1006         if (OptStatus)
   1007         {
   1008             printf ("Invalid option in command file %s: %s\n",
   1009                 Filename, StringBuffer);
   1010             break;
   1011         }
   1012     }
   1013 
   1014     /* Restore the GetOpt globals */
   1015 
   1016     AcpiGbl_Opterr = Opterr;
   1017     AcpiGbl_Optind = Optind;
   1018 
   1019     fclose (ResponseFile);
   1020     return (OptStatus);
   1021 }
   1022