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