Home | History | Annotate | Line # | Download | only in compiler
asloptions.c revision 1.1.1.10
      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         !Gbl_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         Gbl_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             Usage ();
    437             exit (0);
    438 
    439         case 'c':
    440 
    441             UtDisplayConstantOpcodes ();
    442             exit (0);
    443 
    444         case 'd':
    445 
    446             AslDisassemblyHelp ();
    447             exit (0);
    448 
    449         case 'f':
    450 
    451             AslFilenameHelp ();
    452             exit (0);
    453 
    454         case 'r':
    455 
    456             /* reserved names */
    457 
    458             ApDisplayReservedNames ();
    459             exit (0);
    460 
    461         case 't':
    462 
    463             UtDisplaySupportedTables ();
    464             exit (0);
    465 
    466         default:
    467 
    468             printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
    469             return (-1);
    470         }
    471 
    472     case 'I':   /* Add an include file search directory */
    473 
    474         FlAddIncludeDirectory (AcpiGbl_Optarg);
    475         break;
    476 
    477     case 'i':   /* Output AML as an include file */
    478 
    479         switch (AcpiGbl_Optarg[0])
    480         {
    481         case 'a':
    482 
    483             /* Produce assembly code include file */
    484 
    485             Gbl_AsmIncludeOutputFlag = TRUE;
    486             break;
    487 
    488         case 'c':
    489 
    490             /* Produce C include file */
    491 
    492             Gbl_C_IncludeOutputFlag = TRUE;
    493             break;
    494 
    495         case 'n':
    496 
    497             /* Compiler/Disassembler: Ignore the NOOP operator */
    498 
    499             AcpiGbl_IgnoreNoopOperator = TRUE;
    500             break;
    501 
    502         default:
    503 
    504             printf ("Unknown option: -i%s\n", AcpiGbl_Optarg);
    505             return (-1);
    506         }
    507         break;
    508 
    509     case 'l':   /* Listing files */
    510 
    511         switch (AcpiGbl_Optarg[0])
    512         {
    513         case '^':
    514 
    515             /* Produce listing file (Mixed source/aml) */
    516 
    517             Gbl_ListingFlag = TRUE;
    518             AcpiGbl_DmOpt_Listing = TRUE;
    519             break;
    520 
    521         case 'i':
    522 
    523             /* Produce preprocessor output file */
    524 
    525             Gbl_PreprocessorOutputFlag = TRUE;
    526             break;
    527 
    528         case 'm':
    529 
    530             /* Produce hardware map summary file */
    531 
    532             Gbl_MapfileFlag = TRUE;
    533             break;
    534 
    535         case 'n':
    536 
    537             /* Produce namespace file */
    538 
    539             Gbl_NsOutputFlag = TRUE;
    540             break;
    541 
    542         case 's':
    543 
    544             /* Produce combined source file */
    545 
    546             Gbl_SourceOutputFlag = TRUE;
    547             break;
    548 
    549         case 'x':
    550 
    551             /* Produce cross-reference file */
    552 
    553             Gbl_CrossReferenceOutput = TRUE;
    554             break;
    555 
    556         default:
    557 
    558             printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
    559             return (-1);
    560         }
    561         break;
    562 
    563     case 'm':   /* Set line buffer size */
    564 
    565         Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024;
    566         if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE)
    567         {
    568             Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE;
    569         }
    570         printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize);
    571         break;
    572 
    573     case 'n':   /* Parse only */
    574 
    575         Gbl_ParseOnlyFlag = TRUE;
    576         break;
    577 
    578     case 'o':   /* Control compiler AML optimizations */
    579 
    580         switch (AcpiGbl_Optarg[0])
    581         {
    582         case 'a':
    583 
    584             /* Disable all optimizations */
    585 
    586             Gbl_FoldConstants = FALSE;
    587             Gbl_IntegerOptimizationFlag = FALSE;
    588             Gbl_ReferenceOptimizationFlag = FALSE;
    589             Gbl_OptimizeTrivialParseNodes = FALSE;
    590 
    591             break;
    592 
    593         case 'c':
    594 
    595             /* Display compile time(s) */
    596 
    597             Gbl_CompileTimesFlag = TRUE;
    598             break;
    599 
    600         case 'd':
    601 
    602             /* Disable disassembler code optimizations */
    603 
    604             AcpiGbl_DoDisassemblerOptimizations = FALSE;
    605             break;
    606 
    607         case 'e':
    608 
    609             /* Disassembler: Emit embedded external operators */
    610 
    611             AcpiGbl_DmEmitExternalOpcodes = TRUE;
    612             break;
    613 
    614         case 'E':
    615 
    616             /*
    617              * iASL: keep External opcodes in place.
    618              * No affect if Gbl_DoExternals is false.
    619              */
    620 
    621             Gbl_DoExternalsInPlace = TRUE;
    622             break;
    623 
    624         case 'f':
    625 
    626             /* Disable folding on "normal" expressions */
    627 
    628             Gbl_FoldConstants = FALSE;
    629             break;
    630 
    631         case 'i':
    632 
    633             /* Disable integer optimization to constants */
    634 
    635             Gbl_IntegerOptimizationFlag = FALSE;
    636             break;
    637 
    638         case 'n':
    639 
    640             /* Disable named reference optimization */
    641 
    642             Gbl_ReferenceOptimizationFlag = FALSE;
    643             break;
    644 
    645         case 't':
    646 
    647             /* Disable heavy typechecking */
    648 
    649             Gbl_DoTypechecking = FALSE;
    650             break;
    651 
    652         default:
    653 
    654             printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
    655             return (-1);
    656         }
    657         break;
    658 
    659     case 'P':   /* Preprocessor options */
    660 
    661         switch (AcpiGbl_Optarg[0])
    662         {
    663         case '^':   /* Proprocess only, emit (.i) file */
    664 
    665             Gbl_PreprocessOnly = TRUE;
    666             Gbl_PreprocessorOutputFlag = TRUE;
    667             break;
    668 
    669         case 'n':   /* Disable preprocessor */
    670 
    671             Gbl_PreprocessFlag = FALSE;
    672             break;
    673 
    674         default:
    675 
    676             printf ("Unknown option: -P%s\n", AcpiGbl_Optarg);
    677             return (-1);
    678         }
    679         break;
    680 
    681     case 'p':   /* Override default AML output filename */
    682 
    683         Gbl_OutputFilenamePrefix = AcpiGbl_Optarg;
    684         UtConvertBackslashes (Gbl_OutputFilenamePrefix);
    685         Gbl_UseDefaultAmlFilename = FALSE;
    686         break;
    687 
    688     case 'q':   /* ASL/ASl+ converter: compile only and leave badaml. */
    689 
    690         printf ("Convert ASL to ASL+ with comments\n");
    691         Gbl_FoldConstants = FALSE;
    692         Gbl_IntegerOptimizationFlag = FALSE;
    693         Gbl_ReferenceOptimizationFlag = FALSE;
    694         Gbl_OptimizeTrivialParseNodes = FALSE;
    695         Gbl_CaptureComments = TRUE;
    696         Gbl_DoExternalsInPlace = TRUE;
    697         return (0);
    698 
    699     case 'r':   /* Override revision found in table header */
    700 
    701         Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
    702         break;
    703 
    704     case 's':   /* Create AML in a source code file */
    705 
    706         switch (AcpiGbl_Optarg[0])
    707         {
    708         case 'a':
    709 
    710             /* Produce assembly code output file */
    711 
    712             Gbl_AsmOutputFlag = TRUE;
    713             break;
    714 
    715         case 'c':
    716 
    717             /* Produce C hex output file */
    718 
    719             Gbl_C_OutputFlag = TRUE;
    720             break;
    721 
    722         case 'o':
    723 
    724             /* Produce AML offset table in C */
    725 
    726             Gbl_C_OffsetTableFlag = TRUE;
    727             break;
    728 
    729         default:
    730 
    731             printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
    732             return (-1);
    733         }
    734         break;
    735 
    736     case 't':   /* Produce hex table output file */
    737 
    738         switch (AcpiGbl_Optarg[0])
    739         {
    740         case 'a':
    741 
    742             Gbl_HexOutputFlag = HEX_OUTPUT_ASM;
    743             break;
    744 
    745         case 'c':
    746 
    747             Gbl_HexOutputFlag = HEX_OUTPUT_C;
    748             break;
    749 
    750         case 's':
    751 
    752             Gbl_HexOutputFlag = HEX_OUTPUT_ASL;
    753             break;
    754 
    755         default:
    756 
    757             printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
    758             return (-1);
    759         }
    760         break;
    761 
    762     case 'T':   /* Create a ACPI table template file */
    763 
    764         Gbl_DoTemplates = TRUE;
    765         break;
    766 
    767     case 'v':   /* Version and verbosity settings */
    768 
    769         switch (AcpiGbl_Optarg[0])
    770         {
    771         case '^':
    772 
    773             printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
    774             exit (0);
    775 
    776         case 'a':
    777 
    778             /* Disable all error/warning/remark messages */
    779 
    780             Gbl_NoErrors = TRUE;
    781             break;
    782 
    783         case 'd':
    784 
    785             printf ("%s Build date/time: %s %s\n",
    786                 ASL_COMPILER_NAME, ASL_BUILD_DATE, ASL_BUILD_TIME);
    787             exit (0);
    788 
    789         case 'e':
    790 
    791             /* Disable all warning/remark messages (errors only) */
    792 
    793             Gbl_DisplayRemarks = FALSE;
    794             Gbl_DisplayWarnings = FALSE;
    795             break;
    796 
    797         case 'i':
    798             /*
    799              * Support for integrated development environment(s).
    800              *
    801              * 1) No compiler signon
    802              * 2) Send stderr messages to stdout
    803              * 3) Less verbose error messages (single line only for each)
    804              * 4) Error/warning messages are formatted appropriately to
    805              *    be recognized by MS Visual Studio
    806              */
    807             Gbl_VerboseErrors = FALSE;
    808             Gbl_DoSignon = FALSE;
    809             Gbl_Files[ASL_FILE_STDERR].Handle = stdout;
    810             break;
    811 
    812         case 'o':
    813 
    814             Gbl_DisplayOptimizations = TRUE;
    815             break;
    816 
    817         case 'r':
    818 
    819             Gbl_DisplayRemarks = FALSE;
    820             break;
    821 
    822         case 's':
    823 
    824             Gbl_DoSignon = FALSE;
    825             break;
    826 
    827         case 't':
    828 
    829             Gbl_VerboseTemplates = TRUE;
    830             break;
    831 
    832         case 'w':
    833 
    834             /* Get the required argument */
    835 
    836             if (AcpiGetoptArgument (argc, argv))
    837             {
    838                 return (-1);
    839             }
    840 
    841             Status = AslDisableException (AcpiGbl_Optarg);
    842             if (ACPI_FAILURE (Status))
    843             {
    844                 return (-1);
    845             }
    846             break;
    847 
    848         default:
    849 
    850             printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
    851             return (-1);
    852         }
    853         break;
    854 
    855     case 'w': /* Set warning levels */
    856 
    857         switch (AcpiGbl_Optarg[0])
    858         {
    859         case '1':
    860 
    861             Gbl_WarningLevel = ASL_WARNING;
    862             break;
    863 
    864         case '2':
    865 
    866             Gbl_WarningLevel = ASL_WARNING2;
    867             break;
    868 
    869         case '3':
    870 
    871             Gbl_WarningLevel = ASL_WARNING3;
    872             break;
    873 
    874         case 'e':
    875 
    876             Gbl_WarningsAsErrors = TRUE;
    877             break;
    878 
    879         default:
    880 
    881             printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);
    882             return (-1);
    883         }
    884         break;
    885 
    886     case 'x':   /* Set debug print output level */
    887 
    888         AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
    889         break;
    890 
    891     case 'z':
    892 
    893         Gbl_UseOriginalCompilerId = TRUE;
    894         break;
    895 
    896     default:
    897 
    898         return (-1);
    899     }
    900 
    901     return (0);
    902 }
    903 
    904 
    905 /*******************************************************************************
    906  *
    907  * FUNCTION:    AslMergeOptionTokens
    908  *
    909  * PARAMETERS:  InBuffer            - Input containing an option string
    910  *              OutBuffer           - Merged output buffer
    911  *
    912  * RETURN:      None
    913  *
    914  * DESCRIPTION: Remove all whitespace from an option string.
    915  *
    916  ******************************************************************************/
    917 
    918 static void
    919 AslMergeOptionTokens (
    920     char                    *InBuffer,
    921     char                    *OutBuffer)
    922 {
    923     char                    *Token;
    924 
    925 
    926     *OutBuffer = 0;
    927 
    928     Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS);
    929     while (Token)
    930     {
    931         strcat (OutBuffer, Token);
    932         Token = strtok (NULL, ASL_TOKEN_SEPARATORS);
    933     }
    934 }
    935 
    936 
    937 /*******************************************************************************
    938  *
    939  * FUNCTION:    AslDoResponseFile
    940  *
    941  * PARAMETERS:  Filename        - Name of the response file
    942  *
    943  * RETURN:      Status
    944  *
    945  * DESCRIPTION: Open a response file and process all options within.
    946  *
    947  ******************************************************************************/
    948 
    949 static int
    950 AslDoResponseFile (
    951     char                    *Filename)
    952 {
    953     char                    *argv = StringBuffer2;
    954     FILE                    *ResponseFile;
    955     int                     OptStatus = 0;
    956     int                     Opterr;
    957     int                     Optind;
    958 
    959 
    960     ResponseFile = fopen (Filename, "r");
    961     if (!ResponseFile)
    962     {
    963         printf ("Could not open command file %s, %s\n",
    964             Filename, strerror (errno));
    965         return (-1);
    966     }
    967 
    968     /* Must save the current GetOpt globals */
    969 
    970     Opterr = AcpiGbl_Opterr;
    971     Optind = AcpiGbl_Optind;
    972 
    973     /*
    974      * Process all lines in the response file. There must be one complete
    975      * option per line
    976      */
    977     while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile))
    978     {
    979         /* Compress all tokens, allowing us to use a single argv entry */
    980 
    981         AslMergeOptionTokens (StringBuffer, StringBuffer2);
    982 
    983         /* Process the option */
    984 
    985         AcpiGbl_Opterr = 0;
    986         AcpiGbl_Optind = 0;
    987 
    988         OptStatus = AslDoOptions (1, &argv, TRUE);
    989         if (OptStatus)
    990         {
    991             printf ("Invalid option in command file %s: %s\n",
    992                 Filename, StringBuffer);
    993             break;
    994         }
    995     }
    996 
    997     /* Restore the GetOpt globals */
    998 
    999     AcpiGbl_Opterr = Opterr;
   1000     AcpiGbl_Optind = Optind;
   1001 
   1002     fclose (ResponseFile);
   1003     return (OptStatus);
   1004 }
   1005