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