Home | History | Annotate | Line # | Download | only in compiler
aslmain.c revision 1.1.1.5.2.3
      1          1.1    jruoho /******************************************************************************
      2          1.1    jruoho  *
      3          1.1    jruoho  * Module Name: aslmain - compiler main and utilities
      4          1.1    jruoho  *
      5          1.1    jruoho  *****************************************************************************/
      6          1.1    jruoho 
      7      1.1.1.2    jruoho /*
      8  1.1.1.5.2.3     skrll  * Copyright (C) 2000 - 2016, Intel Corp.
      9          1.1    jruoho  * All rights reserved.
     10          1.1    jruoho  *
     11      1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
     12      1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
     13      1.1.1.2    jruoho  * are met:
     14      1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
     15      1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16      1.1.1.2    jruoho  *    without modification.
     17      1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18      1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19      1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20      1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
     21      1.1.1.2    jruoho  *    binary redistribution.
     22      1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23      1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
     24      1.1.1.2    jruoho  *    from this software without specific prior written permission.
     25      1.1.1.2    jruoho  *
     26      1.1.1.2    jruoho  * Alternatively, this software may be distributed under the terms of the
     27      1.1.1.2    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28      1.1.1.2    jruoho  * Software Foundation.
     29      1.1.1.2    jruoho  *
     30      1.1.1.2    jruoho  * NO WARRANTY
     31      1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32      1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33      1.1.1.2    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34      1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35      1.1.1.2    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36      1.1.1.2    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37      1.1.1.2    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38      1.1.1.2    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39      1.1.1.2    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40      1.1.1.2    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41      1.1.1.2    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42      1.1.1.2    jruoho  */
     43          1.1    jruoho 
     44          1.1    jruoho #define _DECLARE_GLOBALS
     45          1.1    jruoho 
     46          1.1    jruoho #include "aslcompiler.h"
     47          1.1    jruoho #include "acapps.h"
     48      1.1.1.2    jruoho #include "acdisasm.h"
     49      1.1.1.4  christos #include <signal.h>
     50          1.1    jruoho 
     51          1.1    jruoho #define _COMPONENT          ACPI_COMPILER
     52          1.1    jruoho         ACPI_MODULE_NAME    ("aslmain")
     53          1.1    jruoho 
     54      1.1.1.4  christos /*
     55      1.1.1.4  christos  * Main routine for the iASL compiler.
     56      1.1.1.4  christos  *
     57      1.1.1.4  christos  * Portability note: The compiler depends upon the host for command-line
     58      1.1.1.4  christos  * wildcard support - it is not implemented locally. For example:
     59      1.1.1.4  christos  *
     60      1.1.1.4  christos  * Linux/Unix systems: Shell expands wildcards automatically.
     61      1.1.1.4  christos  *
     62      1.1.1.4  christos  * Windows: The setargv.obj module must be linked in to automatically
     63      1.1.1.4  christos  * expand wildcards.
     64      1.1.1.4  christos  */
     65          1.1    jruoho 
     66      1.1.1.4  christos /* Local prototypes */
     67          1.1    jruoho 
     68      1.1.1.4  christos static void ACPI_SYSTEM_XFACE
     69      1.1.1.4  christos AslSignalHandler (
     70      1.1.1.4  christos     int                     Sig);
     71          1.1    jruoho 
     72          1.1    jruoho static void
     73          1.1    jruoho AslInitialize (
     74          1.1    jruoho     void);
     75          1.1    jruoho 
     76      1.1.1.5  christos UINT8
     77      1.1.1.5  christos AcpiIsBigEndianMachine (
     78      1.1.1.5  christos     void);
     79      1.1.1.5  christos 
     80      1.1.1.5  christos 
     81      1.1.1.5  christos /*******************************************************************************
     82      1.1.1.5  christos  *
     83      1.1.1.5  christos  * FUNCTION:    AcpiIsBigEndianMachine
     84      1.1.1.5  christos  *
     85      1.1.1.5  christos  * PARAMETERS:  None
     86      1.1.1.5  christos  *
     87      1.1.1.5  christos  * RETURN:      TRUE if machine is big endian
     88      1.1.1.5  christos  *              FALSE if machine is little endian
     89      1.1.1.5  christos  *
     90      1.1.1.5  christos  * DESCRIPTION: Detect whether machine is little endian or big endian.
     91      1.1.1.5  christos  *
     92      1.1.1.5  christos  ******************************************************************************/
     93      1.1.1.5  christos 
     94      1.1.1.5  christos UINT8
     95      1.1.1.5  christos AcpiIsBigEndianMachine (
     96      1.1.1.5  christos     void)
     97      1.1.1.5  christos {
     98      1.1.1.5  christos     union {
     99      1.1.1.5  christos         UINT32              Integer;
    100      1.1.1.5  christos         UINT8               Bytes[4];
    101      1.1.1.5  christos     } Overlay = {0xFF000000};
    102      1.1.1.5  christos 
    103      1.1.1.5  christos     return (Overlay.Bytes[0]); /* Returns 0xFF (TRUE) for big endian */
    104      1.1.1.5  christos }
    105      1.1.1.5  christos 
    106          1.1    jruoho 
    107          1.1    jruoho /*******************************************************************************
    108          1.1    jruoho  *
    109      1.1.1.4  christos  * FUNCTION:    Usage
    110          1.1    jruoho  *
    111          1.1    jruoho  * PARAMETERS:  None
    112          1.1    jruoho  *
    113          1.1    jruoho  * RETURN:      None
    114          1.1    jruoho  *
    115      1.1.1.4  christos  * DESCRIPTION: Display option help message.
    116      1.1.1.4  christos  *              Optional items in square brackets.
    117          1.1    jruoho  *
    118          1.1    jruoho  ******************************************************************************/
    119          1.1    jruoho 
    120      1.1.1.4  christos void
    121      1.1.1.4  christos Usage (
    122          1.1    jruoho     void)
    123          1.1    jruoho {
    124      1.1.1.4  christos     printf ("%s\n\n", ASL_COMPLIANCE);
    125      1.1.1.4  christos     ACPI_USAGE_HEADER ("iasl [Options] [Files]");
    126          1.1    jruoho 
    127      1.1.1.4  christos     printf ("\nGeneral:\n");
    128      1.1.1.4  christos     ACPI_OPTION ("-@ <file>",       "Specify command file");
    129      1.1.1.4  christos     ACPI_OPTION ("-I <dir>",        "Specify additional include directory");
    130  1.1.1.5.2.3     skrll     ACPI_OPTION ("-T <sig list>|ALL",   "Create ACPI table template/example files");
    131  1.1.1.5.2.3     skrll     ACPI_OPTION ("-T <count>",      "Emit DSDT and <count> SSDTs to same file");
    132      1.1.1.4  christos     ACPI_OPTION ("-p <prefix>",     "Specify path/filename prefix for all output files");
    133      1.1.1.4  christos     ACPI_OPTION ("-v",              "Display compiler version");
    134      1.1.1.4  christos     ACPI_OPTION ("-vo",             "Enable optimization comments");
    135      1.1.1.4  christos     ACPI_OPTION ("-vs",             "Disable signon");
    136          1.1    jruoho 
    137          1.1    jruoho     printf ("\nHelp:\n");
    138      1.1.1.4  christos     ACPI_OPTION ("-h",              "This message");
    139      1.1.1.4  christos     ACPI_OPTION ("-hc",             "Display operators allowed in constant expressions");
    140      1.1.1.4  christos     ACPI_OPTION ("-hf",             "Display help for output filename generation");
    141      1.1.1.4  christos     ACPI_OPTION ("-hr",             "Display ACPI reserved method names");
    142      1.1.1.4  christos     ACPI_OPTION ("-ht",             "Display currently supported ACPI table names");
    143      1.1.1.4  christos 
    144      1.1.1.4  christos     printf ("\nPreprocessor:\n");
    145      1.1.1.4  christos     ACPI_OPTION ("-D <symbol>",     "Define symbol for preprocessor use");
    146      1.1.1.4  christos     ACPI_OPTION ("-li",             "Create preprocessed output file (*.i)");
    147      1.1.1.4  christos     ACPI_OPTION ("-P",              "Preprocess only and create preprocessor output file (*.i)");
    148      1.1.1.4  christos     ACPI_OPTION ("-Pn",             "Disable preprocessor");
    149      1.1.1.4  christos 
    150      1.1.1.4  christos     printf ("\nErrors, Warnings, and Remarks:\n");
    151      1.1.1.4  christos     ACPI_OPTION ("-va",             "Disable all errors/warnings/remarks");
    152      1.1.1.4  christos     ACPI_OPTION ("-ve",             "Report only errors (ignore warnings and remarks)");
    153      1.1.1.4  christos     ACPI_OPTION ("-vi",             "Less verbose errors and warnings for use with IDEs");
    154      1.1.1.4  christos     ACPI_OPTION ("-vr",             "Disable remarks");
    155      1.1.1.4  christos     ACPI_OPTION ("-vw <messageid>", "Disable specific warning or remark");
    156      1.1.1.4  christos     ACPI_OPTION ("-w1 -w2 -w3",     "Set warning reporting level");
    157      1.1.1.4  christos     ACPI_OPTION ("-we",             "Report warnings as errors");
    158      1.1.1.4  christos 
    159      1.1.1.4  christos     printf ("\nAML Code Generation (*.aml):\n");
    160      1.1.1.4  christos     ACPI_OPTION ("-oa",             "Disable all optimizations (compatibility mode)");
    161      1.1.1.4  christos     ACPI_OPTION ("-of",             "Disable constant folding");
    162      1.1.1.4  christos     ACPI_OPTION ("-oi",             "Disable integer optimization to Zero/One/Ones");
    163      1.1.1.4  christos     ACPI_OPTION ("-on",             "Disable named reference string optimization");
    164  1.1.1.5.2.3     skrll     ACPI_OPTION ("-ot",             "Disable typechecking");
    165      1.1.1.4  christos     ACPI_OPTION ("-cr",             "Disable Resource Descriptor error checking");
    166      1.1.1.4  christos     ACPI_OPTION ("-in",             "Ignore NoOp operators");
    167      1.1.1.4  christos     ACPI_OPTION ("-r <revision>",   "Override table header Revision (1-255)");
    168      1.1.1.4  christos 
    169      1.1.1.4  christos     printf ("\nOptional Source Code Output Files:\n");
    170      1.1.1.4  christos     ACPI_OPTION ("-sc -sa",         "Create source file in C or assembler (*.c or *.asm)");
    171      1.1.1.4  christos     ACPI_OPTION ("-ic -ia",         "Create include file in C or assembler (*.h or *.inc)");
    172      1.1.1.4  christos     ACPI_OPTION ("-tc -ta -ts",     "Create hex AML table in C, assembler, or ASL (*.hex)");
    173      1.1.1.4  christos     ACPI_OPTION ("-so",             "Create offset table in C (*.offset.h)");
    174      1.1.1.4  christos 
    175      1.1.1.4  christos     printf ("\nOptional Listing Files:\n");
    176      1.1.1.4  christos     ACPI_OPTION ("-l",              "Create mixed listing file (ASL source and AML) (*.lst)");
    177      1.1.1.5  christos     ACPI_OPTION ("-lm",             "Create hardware summary map file (*.map)");
    178      1.1.1.4  christos     ACPI_OPTION ("-ln",             "Create namespace file (*.nsp)");
    179      1.1.1.4  christos     ACPI_OPTION ("-ls",             "Create combined source file (expanded includes) (*.src)");
    180      1.1.1.4  christos 
    181      1.1.1.4  christos     printf ("\nData Table Compiler:\n");
    182      1.1.1.4  christos     ACPI_OPTION ("-G",              "Compile custom table that contains generic operators");
    183      1.1.1.4  christos     ACPI_OPTION ("-vt",             "Create verbose template files (full disassembly)");
    184      1.1.1.4  christos 
    185      1.1.1.4  christos     printf ("\nAML Disassembler:\n");
    186      1.1.1.4  christos     ACPI_OPTION ("-d  <f1 f2 ...>", "Disassemble or decode binary ACPI tables to file (*.dsl)");
    187      1.1.1.4  christos     ACPI_OPTION ("",                "  (Optional, file type is automatically detected)");
    188      1.1.1.4  christos     ACPI_OPTION ("-da <f1 f2 ...>", "Disassemble multiple tables from single namespace");
    189      1.1.1.4  christos     ACPI_OPTION ("-db",             "Do not translate Buffers to Resource Templates");
    190      1.1.1.4  christos     ACPI_OPTION ("-dc <f1 f2 ...>", "Disassemble AML and immediately compile it");
    191      1.1.1.4  christos     ACPI_OPTION ("",                "  (Obtain DSDT from current system if no input file)");
    192  1.1.1.5.2.1     skrll     ACPI_OPTION ("-df",             "Force disassembler to assume table contains valid AML");
    193  1.1.1.5.2.1     skrll     ACPI_OPTION ("-dl",             "Emit legacy ASL code only (no C-style operators)");
    194      1.1.1.4  christos     ACPI_OPTION ("-e  <f1 f2 ...>", "Include ACPI table(s) for external symbol resolution");
    195      1.1.1.4  christos     ACPI_OPTION ("-fe <file>",      "Specify external symbol declaration file");
    196      1.1.1.4  christos     ACPI_OPTION ("-in",             "Ignore NoOp opcodes");
    197  1.1.1.5.2.3     skrll     ACPI_OPTION ("-l",              "Disassemble to mixed ASL and AML code");
    198      1.1.1.4  christos     ACPI_OPTION ("-vt",             "Dump binary table data in hex format within output file");
    199      1.1.1.4  christos 
    200      1.1.1.4  christos     printf ("\nDebug Options:\n");
    201  1.1.1.5.2.1     skrll     ACPI_OPTION ("-bf",             "Create debug file (full output) (*.txt)");
    202  1.1.1.5.2.1     skrll     ACPI_OPTION ("-bs",             "Create debug file (parse tree only) (*.txt)");
    203  1.1.1.5.2.1     skrll     ACPI_OPTION ("-bp <depth>",     "Prune ASL parse tree");
    204  1.1.1.5.2.1     skrll     ACPI_OPTION ("-bt <type>",      "Object type to be pruned from the parse tree");
    205      1.1.1.4  christos     ACPI_OPTION ("-f",              "Ignore errors, force creation of AML output file(s)");
    206      1.1.1.4  christos     ACPI_OPTION ("-m <size>",       "Set internal line buffer size (in Kbytes)");
    207      1.1.1.4  christos     ACPI_OPTION ("-n",              "Parse only, no output generation");
    208  1.1.1.5.2.3     skrll     ACPI_OPTION ("-oc",             "Display compile times and statistics");
    209      1.1.1.4  christos     ACPI_OPTION ("-x <level>",      "Set debug level for trace output");
    210      1.1.1.4  christos     ACPI_OPTION ("-z",              "Do not insert new compiler ID for DataTables");
    211          1.1    jruoho }
    212          1.1    jruoho 
    213          1.1    jruoho 
    214          1.1    jruoho /*******************************************************************************
    215          1.1    jruoho  *
    216      1.1.1.4  christos  * FUNCTION:    FilenameHelp
    217          1.1    jruoho  *
    218          1.1    jruoho  * PARAMETERS:  None
    219          1.1    jruoho  *
    220          1.1    jruoho  * RETURN:      None
    221          1.1    jruoho  *
    222      1.1.1.4  christos  * DESCRIPTION: Display help message for output filename generation
    223          1.1    jruoho  *
    224          1.1    jruoho  ******************************************************************************/
    225          1.1    jruoho 
    226      1.1.1.4  christos void
    227      1.1.1.4  christos AslFilenameHelp (
    228          1.1    jruoho     void)
    229          1.1    jruoho {
    230          1.1    jruoho 
    231      1.1.1.4  christos     printf ("\nAML output filename generation:\n");
    232          1.1    jruoho     printf ("  Output filenames are generated by appending an extension to a common\n");
    233      1.1.1.4  christos     printf ("  filename prefix. The filename prefix is obtained via one of the\n");
    234          1.1    jruoho     printf ("  following methods (in priority order):\n");
    235          1.1    jruoho     printf ("    1) The -p option specifies the prefix\n");
    236          1.1    jruoho     printf ("    2) The prefix of the AMLFileName in the ASL Definition Block\n");
    237          1.1    jruoho     printf ("    3) The prefix of the input filename\n");
    238          1.1    jruoho     printf ("\n");
    239          1.1    jruoho }
    240          1.1    jruoho 
    241          1.1    jruoho 
    242      1.1.1.4  christos /******************************************************************************
    243          1.1    jruoho  *
    244      1.1.1.4  christos  * FUNCTION:    AslSignalHandler
    245          1.1    jruoho  *
    246      1.1.1.4  christos  * PARAMETERS:  Sig                 - Signal that invoked this handler
    247          1.1    jruoho  *
    248          1.1    jruoho  * RETURN:      None
    249          1.1    jruoho  *
    250      1.1.1.4  christos  * DESCRIPTION: Control-C handler. Delete any intermediate files and any
    251      1.1.1.4  christos  *              output files that may be left in an indeterminate state.
    252          1.1    jruoho  *
    253      1.1.1.4  christos  *****************************************************************************/
    254          1.1    jruoho 
    255      1.1.1.4  christos static void ACPI_SYSTEM_XFACE
    256      1.1.1.4  christos AslSignalHandler (
    257      1.1.1.4  christos     int                     Sig)
    258          1.1    jruoho {
    259      1.1.1.4  christos     UINT32                  i;
    260      1.1.1.4  christos 
    261      1.1.1.4  christos 
    262      1.1.1.4  christos     signal (Sig, SIG_IGN);
    263      1.1.1.4  christos     printf ("Aborting\n\n");
    264      1.1.1.4  christos 
    265      1.1.1.4  christos     /* Close all open files */
    266      1.1.1.4  christos 
    267  1.1.1.5.2.2     skrll     Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .pre file is same as source file */
    268      1.1.1.4  christos 
    269      1.1.1.4  christos     for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++)
    270      1.1.1.4  christos     {
    271      1.1.1.4  christos         FlCloseFile (i);
    272      1.1.1.4  christos     }
    273      1.1.1.4  christos 
    274      1.1.1.4  christos     /* Delete any output files */
    275          1.1    jruoho 
    276      1.1.1.4  christos     for (i = ASL_FILE_AML_OUTPUT; i < ASL_MAX_FILE_TYPE; i++)
    277      1.1.1.4  christos     {
    278      1.1.1.4  christos         FlDeleteFile (i);
    279      1.1.1.4  christos     }
    280      1.1.1.4  christos 
    281      1.1.1.4  christos     exit (0);
    282          1.1    jruoho }
    283          1.1    jruoho 
    284          1.1    jruoho 
    285          1.1    jruoho /*******************************************************************************
    286          1.1    jruoho  *
    287          1.1    jruoho  * FUNCTION:    AslInitialize
    288          1.1    jruoho  *
    289          1.1    jruoho  * PARAMETERS:  None
    290          1.1    jruoho  *
    291          1.1    jruoho  * RETURN:      None
    292          1.1    jruoho  *
    293          1.1    jruoho  * DESCRIPTION: Initialize compiler globals
    294          1.1    jruoho  *
    295          1.1    jruoho  ******************************************************************************/
    296          1.1    jruoho 
    297          1.1    jruoho static void
    298          1.1    jruoho AslInitialize (
    299          1.1    jruoho     void)
    300          1.1    jruoho {
    301          1.1    jruoho     UINT32                  i;
    302          1.1    jruoho 
    303          1.1    jruoho 
    304  1.1.1.5.2.3     skrll     AcpiGbl_DmOpt_Verbose = FALSE;
    305  1.1.1.5.2.3     skrll 
    306          1.1    jruoho     for (i = 0; i < ASL_NUM_FILES; i++)
    307          1.1    jruoho     {
    308          1.1    jruoho         Gbl_Files[i].Handle = NULL;
    309          1.1    jruoho         Gbl_Files[i].Filename = NULL;
    310          1.1    jruoho     }
    311          1.1    jruoho 
    312          1.1    jruoho     Gbl_Files[ASL_FILE_STDOUT].Handle   = stdout;
    313          1.1    jruoho     Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT";
    314          1.1    jruoho 
    315          1.1    jruoho     Gbl_Files[ASL_FILE_STDERR].Handle   = stderr;
    316          1.1    jruoho     Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR";
    317          1.1    jruoho }
    318          1.1    jruoho 
    319          1.1    jruoho 
    320          1.1    jruoho /*******************************************************************************
    321          1.1    jruoho  *
    322          1.1    jruoho  * FUNCTION:    main
    323          1.1    jruoho  *
    324          1.1    jruoho  * PARAMETERS:  Standard argc/argv
    325          1.1    jruoho  *
    326          1.1    jruoho  * RETURN:      Program termination code
    327          1.1    jruoho  *
    328          1.1    jruoho  * DESCRIPTION: C main routine for the Asl Compiler. Handle command line
    329          1.1    jruoho  *              options and begin the compile for each file on the command line
    330          1.1    jruoho  *
    331          1.1    jruoho  ******************************************************************************/
    332          1.1    jruoho 
    333          1.1    jruoho int ACPI_SYSTEM_XFACE
    334          1.1    jruoho main (
    335          1.1    jruoho     int                     argc,
    336          1.1    jruoho     char                    **argv)
    337          1.1    jruoho {
    338          1.1    jruoho     ACPI_STATUS             Status;
    339      1.1.1.2    jruoho     int                     Index1;
    340      1.1.1.2    jruoho     int                     Index2;
    341      1.1.1.5  christos     int                     ReturnStatus = 0;
    342      1.1.1.2    jruoho 
    343          1.1    jruoho 
    344      1.1.1.5  christos     /*
    345      1.1.1.5  christos      * Big-endian machines are not currently supported. ACPI tables must
    346      1.1.1.5  christos      * be little-endian, and support for big-endian machines needs to
    347      1.1.1.5  christos      * be implemented.
    348      1.1.1.5  christos      */
    349      1.1.1.5  christos     if (AcpiIsBigEndianMachine ())
    350      1.1.1.5  christos     {
    351      1.1.1.5  christos         fprintf (stderr,
    352      1.1.1.5  christos             "iASL is not currently supported on big-endian machines.\n");
    353      1.1.1.5  christos         return (-1);
    354      1.1.1.5  christos     }
    355      1.1.1.5  christos 
    356      1.1.1.5  christos     AcpiOsInitialize ();
    357      1.1.1.4  christos     ACPI_DEBUG_INITIALIZE (); /* For debug version only */
    358          1.1    jruoho 
    359      1.1.1.4  christos     /* Initialize preprocessor and compiler before command line processing */
    360          1.1    jruoho 
    361      1.1.1.4  christos     signal (SIGINT, AslSignalHandler);
    362      1.1.1.4  christos     AcpiGbl_ExternalFileList = NULL;
    363      1.1.1.4  christos     AcpiDbgLevel = 0;
    364      1.1.1.4  christos     PrInitializePreprocessor ();
    365          1.1    jruoho     AslInitialize ();
    366      1.1.1.4  christos 
    367      1.1.1.2    jruoho     Index1 = Index2 = AslCommandLine (argc, argv);
    368          1.1    jruoho 
    369      1.1.1.4  christos     /* Allocate the line buffer(s), must be after command line */
    370      1.1.1.4  christos 
    371      1.1.1.4  christos     Gbl_LineBufferSize /= 2;
    372      1.1.1.4  christos     UtExpandLineBuffers ();
    373      1.1.1.4  christos 
    374      1.1.1.4  christos     /* Perform global actions first/only */
    375          1.1    jruoho 
    376      1.1.1.2    jruoho     if (Gbl_DisassembleAll)
    377      1.1.1.2    jruoho     {
    378      1.1.1.2    jruoho         while (argv[Index1])
    379      1.1.1.2    jruoho         {
    380      1.1.1.4  christos             Status = AcpiDmAddToExternalFileList (argv[Index1]);
    381      1.1.1.2    jruoho             if (ACPI_FAILURE (Status))
    382      1.1.1.2    jruoho             {
    383      1.1.1.2    jruoho                 return (-1);
    384      1.1.1.2    jruoho             }
    385      1.1.1.2    jruoho 
    386      1.1.1.2    jruoho             Index1++;
    387      1.1.1.2    jruoho         }
    388      1.1.1.2    jruoho     }
    389      1.1.1.2    jruoho 
    390          1.1    jruoho     /* Process each pathname/filename in the list, with possible wildcards */
    391          1.1    jruoho 
    392      1.1.1.2    jruoho     while (argv[Index2])
    393          1.1    jruoho     {
    394      1.1.1.4  christos         /*
    395      1.1.1.4  christos          * If -p not specified, we will use the input filename as the
    396      1.1.1.4  christos          * output filename prefix
    397      1.1.1.4  christos          */
    398      1.1.1.4  christos         if (Gbl_UseDefaultAmlFilename)
    399      1.1.1.4  christos         {
    400      1.1.1.4  christos             Gbl_OutputFilenamePrefix = argv[Index2];
    401      1.1.1.4  christos             UtConvertBackslashes (Gbl_OutputFilenamePrefix);
    402      1.1.1.4  christos         }
    403      1.1.1.4  christos 
    404      1.1.1.4  christos         Status = AslDoOneFile (argv[Index2]);
    405          1.1    jruoho         if (ACPI_FAILURE (Status))
    406          1.1    jruoho         {
    407      1.1.1.5  christos             ReturnStatus = -1;
    408      1.1.1.5  christos             goto CleanupAndExit;
    409          1.1    jruoho         }
    410          1.1    jruoho 
    411      1.1.1.2    jruoho         Index2++;
    412      1.1.1.2    jruoho     }
    413      1.1.1.2    jruoho 
    414      1.1.1.5  christos 
    415      1.1.1.5  christos CleanupAndExit:
    416      1.1.1.5  christos 
    417      1.1.1.5  christos     UtFreeLineBuffers ();
    418      1.1.1.5  christos     AslParserCleanup ();
    419      1.1.1.5  christos 
    420      1.1.1.2    jruoho     if (AcpiGbl_ExternalFileList)
    421      1.1.1.2    jruoho     {
    422      1.1.1.2    jruoho         AcpiDmClearExternalFileList();
    423          1.1    jruoho     }
    424          1.1    jruoho 
    425      1.1.1.5  christos     return (ReturnStatus);
    426          1.1    jruoho }
    427