Home | History | Annotate | Line # | Download | only in acpiexec
      1       1.1    jruoho /******************************************************************************
      2       1.1    jruoho  *
      3       1.1    jruoho  * Module Name: aemain - Main routine for the AcpiExec utility
      4       1.1    jruoho  *
      5       1.1    jruoho  *****************************************************************************/
      6       1.1    jruoho 
      7  1.1.1.25  christos /******************************************************************************
      8  1.1.1.25  christos  *
      9  1.1.1.25  christos  * 1. Copyright Notice
     10  1.1.1.25  christos  *
     11  1.1.1.26  christos  * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
     12       1.1    jruoho  * All rights reserved.
     13       1.1    jruoho  *
     14  1.1.1.25  christos  * 2. License
     15  1.1.1.25  christos  *
     16  1.1.1.25  christos  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.1.1.25  christos  * rights. You may have additional license terms from the party that provided
     18  1.1.1.25  christos  * you this software, covering your right to use that party's intellectual
     19  1.1.1.25  christos  * property rights.
     20  1.1.1.25  christos  *
     21  1.1.1.25  christos  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.1.1.25  christos  * copy of the source code appearing in this file ("Covered Code") an
     23  1.1.1.25  christos  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.1.1.25  christos  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.1.1.25  christos  * make derivatives, distribute, use and display any portion of the Covered
     26  1.1.1.25  christos  * Code in any form, with the right to sublicense such rights; and
     27  1.1.1.25  christos  *
     28  1.1.1.25  christos  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.1.1.25  christos  * license (with the right to sublicense), under only those claims of Intel
     30  1.1.1.25  christos  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.1.1.25  christos  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.1.1.25  christos  * solely to the minimum extent necessary to exercise the above copyright
     33  1.1.1.25  christos  * license, and in no event shall the patent license extend to any additions
     34  1.1.1.25  christos  * to or modifications of the Original Intel Code. No other license or right
     35  1.1.1.25  christos  * is granted directly or by implication, estoppel or otherwise;
     36  1.1.1.25  christos  *
     37  1.1.1.25  christos  * The above copyright and patent license is granted only if the following
     38  1.1.1.25  christos  * conditions are met:
     39  1.1.1.25  christos  *
     40  1.1.1.25  christos  * 3. Conditions
     41  1.1.1.25  christos  *
     42  1.1.1.25  christos  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.1.1.25  christos  * Redistribution of source code of any substantial portion of the Covered
     44  1.1.1.25  christos  * Code or modification with rights to further distribute source must include
     45  1.1.1.25  christos  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.1.1.25  christos  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.1.1.25  christos  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.1.1.25  christos  * contain a file documenting the changes Licensee made to create that Covered
     49  1.1.1.25  christos  * Code and the date of any change. Licensee must include in that file the
     50  1.1.1.25  christos  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.1.1.25  christos  * must include a prominent statement that the modification is derived,
     52  1.1.1.25  christos  * directly or indirectly, from Original Intel Code.
     53  1.1.1.25  christos  *
     54  1.1.1.25  christos  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.1.1.25  christos  * Redistribution of source code of any substantial portion of the Covered
     56  1.1.1.25  christos  * Code or modification without rights to further distribute source must
     57  1.1.1.25  christos  * include the following Disclaimer and Export Compliance provision in the
     58  1.1.1.25  christos  * documentation and/or other materials provided with distribution. In
     59  1.1.1.25  christos  * addition, Licensee may not authorize further sublicense of source of any
     60  1.1.1.25  christos  * portion of the Covered Code, and must include terms to the effect that the
     61  1.1.1.25  christos  * license from Licensee to its licensee is limited to the intellectual
     62  1.1.1.25  christos  * property embodied in the software Licensee provides to its licensee, and
     63  1.1.1.25  christos  * not to intellectual property embodied in modifications its licensee may
     64  1.1.1.25  christos  * make.
     65  1.1.1.25  christos  *
     66  1.1.1.25  christos  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.1.1.25  christos  * substantial portion of the Covered Code or modification must reproduce the
     68  1.1.1.25  christos  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.1.1.25  christos  * provision in the documentation and/or other materials provided with the
     70  1.1.1.25  christos  * distribution.
     71  1.1.1.25  christos  *
     72  1.1.1.25  christos  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.1.1.25  christos  * Intel Code.
     74  1.1.1.25  christos  *
     75  1.1.1.25  christos  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.1.1.25  christos  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.1.1.25  christos  * other dealings in products derived from or relating to the Covered Code
     78  1.1.1.25  christos  * without prior written authorization from Intel.
     79  1.1.1.25  christos  *
     80  1.1.1.25  christos  * 4. Disclaimer and Export Compliance
     81  1.1.1.25  christos  *
     82  1.1.1.25  christos  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.1.1.25  christos  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.1.1.25  christos  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.1.1.25  christos  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.1.1.25  christos  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.1.1.25  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.1.1.25  christos  * PARTICULAR PURPOSE.
     89  1.1.1.25  christos  *
     90  1.1.1.25  christos  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.1.1.25  christos  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.1.1.25  christos  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.1.1.25  christos  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.1.1.25  christos  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.1.1.25  christos  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.1.1.25  christos  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.1.1.25  christos  * LIMITED REMEDY.
     98  1.1.1.25  christos  *
     99  1.1.1.25  christos  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.1.1.25  christos  * software or system incorporating such software without first obtaining any
    101  1.1.1.25  christos  * required license or other approval from the U. S. Department of Commerce or
    102  1.1.1.25  christos  * any other agency or department of the United States Government. In the
    103  1.1.1.25  christos  * event Licensee exports any such software from the United States or
    104  1.1.1.25  christos  * re-exports any such software from a foreign destination, Licensee shall
    105  1.1.1.25  christos  * ensure that the distribution and export/re-export of the software is in
    106  1.1.1.25  christos  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.1.1.25  christos  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.1.1.25  christos  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.1.1.25  christos  * software, or service, directly or indirectly, to any country for which the
    110  1.1.1.25  christos  * United States government or any agency thereof requires an export license,
    111  1.1.1.25  christos  * other governmental approval, or letter of assurance, without first obtaining
    112  1.1.1.25  christos  * such license, approval or letter.
    113  1.1.1.25  christos  *
    114  1.1.1.25  christos  *****************************************************************************
    115  1.1.1.25  christos  *
    116  1.1.1.25  christos  * Alternatively, you may choose to be licensed under the terms of the
    117  1.1.1.25  christos  * following license:
    118  1.1.1.25  christos  *
    119   1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
    120   1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
    121   1.1.1.2    jruoho  * are met:
    122   1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
    123   1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
    124   1.1.1.2    jruoho  *    without modification.
    125   1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
    126   1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
    127   1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
    128   1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
    129   1.1.1.2    jruoho  *    binary redistribution.
    130   1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
    131   1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
    132   1.1.1.2    jruoho  *    from this software without specific prior written permission.
    133   1.1.1.2    jruoho  *
    134   1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    135   1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    136  1.1.1.22  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    137   1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    138  1.1.1.25  christos  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.1.1.25  christos  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.1.1.25  christos  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.1.1.25  christos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.1.1.25  christos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.1.1.25  christos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.1.1.25  christos  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.1.1.25  christos  *
    146  1.1.1.25  christos  * Alternatively, you may choose to be licensed under the terms of the
    147  1.1.1.25  christos  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.1.1.25  christos  * Software Foundation.
    149  1.1.1.25  christos  *
    150  1.1.1.25  christos  *****************************************************************************/
    151       1.1    jruoho 
    152       1.1    jruoho #include "aecommon.h"
    153       1.1    jruoho 
    154   1.1.1.4  christos #define _COMPONENT          ACPI_TOOLS
    155       1.1    jruoho         ACPI_MODULE_NAME    ("aemain")
    156       1.1    jruoho 
    157   1.1.1.2    jruoho 
    158   1.1.1.4  christos /*
    159   1.1.1.4  christos  * Main routine for the ACPI user-space execution utility.
    160       1.1    jruoho  *
    161   1.1.1.4  christos  * Portability note: The utility depends upon the host for command-line
    162   1.1.1.4  christos  * wildcard support - it is not implemented locally. For example:
    163       1.1    jruoho  *
    164   1.1.1.4  christos  * Linux/Unix systems: Shell expands wildcards automatically.
    165       1.1    jruoho  *
    166   1.1.1.4  christos  * Windows: The setargv.obj module must be linked in to automatically
    167   1.1.1.4  christos  * expand wildcards.
    168   1.1.1.4  christos  */
    169       1.1    jruoho 
    170   1.1.1.4  christos /* Local prototypes */
    171       1.1    jruoho 
    172   1.1.1.4  christos static int
    173   1.1.1.4  christos AeDoOptions (
    174   1.1.1.4  christos     int                     argc,
    175   1.1.1.4  christos     char                    **argv);
    176       1.1    jruoho 
    177       1.1    jruoho 
    178   1.1.1.4  christos #define AE_BUFFER_SIZE              1024
    179   1.1.1.4  christos #define ASL_MAX_FILES               256
    180       1.1    jruoho 
    181   1.1.1.4  christos /* Execution modes */
    182       1.1    jruoho 
    183   1.1.1.4  christos #define AE_MODE_COMMAND_LOOP        0   /* Normal command execution loop */
    184   1.1.1.4  christos #define AE_MODE_BATCH_MULTIPLE      1   /* -b option to execute a command line */
    185   1.1.1.4  christos #define AE_MODE_BATCH_SINGLE        2   /* -m option to execute a single control method */
    186       1.1    jruoho 
    187       1.1    jruoho 
    188   1.1.1.4  christos /* Globals */
    189       1.1    jruoho 
    190  1.1.1.14  christos BOOLEAN                     AcpiGbl_UseLocalFaultHandler = TRUE;
    191  1.1.1.15  christos BOOLEAN                     AcpiGbl_VerboseHandlers = FALSE;
    192   1.1.1.4  christos UINT8                       AcpiGbl_RegionFillValue = 0;
    193   1.1.1.4  christos BOOLEAN                     AcpiGbl_IgnoreErrors = FALSE;
    194  1.1.1.12  christos BOOLEAN                     AcpiGbl_AbortLoopOnTimeout = FALSE;
    195   1.1.1.4  christos UINT8                       AcpiGbl_UseHwReducedFadt = FALSE;
    196   1.1.1.4  christos BOOLEAN                     AcpiGbl_DoInterfaceTests = FALSE;
    197   1.1.1.5  christos BOOLEAN                     AcpiGbl_LoadTestTables = FALSE;
    198   1.1.1.7  christos BOOLEAN                     AcpiGbl_AeLoadOnly = FALSE;
    199   1.1.1.4  christos static UINT8                AcpiGbl_ExecutionMode = AE_MODE_COMMAND_LOOP;
    200   1.1.1.4  christos static char                 BatchBuffer[AE_BUFFER_SIZE];    /* Batch command buffer */
    201  1.1.1.15  christos INIT_FILE_ENTRY             *AcpiGbl_InitEntries = NULL;
    202  1.1.1.15  christos UINT32                      AcpiGbl_InitFileLineCount = 0;
    203       1.1    jruoho 
    204   1.1.1.4  christos #define ACPIEXEC_NAME               "AML Execution/Debug Utility"
    205  1.1.1.12  christos #define AE_SUPPORTED_OPTIONS        "?b:d:e:f^ghlm^rt^v^:x:"
    206       1.1    jruoho 
    207       1.1    jruoho 
    208   1.1.1.5  christos /* Stubs for the disassembler */
    209   1.1.1.5  christos 
    210   1.1.1.5  christos void
    211   1.1.1.5  christos MpSaveGpioInfo (
    212   1.1.1.5  christos     ACPI_PARSE_OBJECT       *Op,
    213   1.1.1.5  christos     AML_RESOURCE            *Resource,
    214   1.1.1.5  christos     UINT32                  PinCount,
    215   1.1.1.5  christos     UINT16                  *PinList,
    216   1.1.1.5  christos     char                    *DeviceName)
    217   1.1.1.5  christos {
    218   1.1.1.5  christos }
    219   1.1.1.5  christos 
    220   1.1.1.5  christos void
    221   1.1.1.5  christos MpSaveSerialInfo (
    222   1.1.1.5  christos     ACPI_PARSE_OBJECT       *Op,
    223   1.1.1.5  christos     AML_RESOURCE            *Resource,
    224   1.1.1.5  christos     char                    *DeviceName)
    225   1.1.1.5  christos {
    226   1.1.1.5  christos }
    227   1.1.1.5  christos 
    228   1.1.1.5  christos 
    229       1.1    jruoho /******************************************************************************
    230       1.1    jruoho  *
    231   1.1.1.4  christos  * FUNCTION:    usage
    232       1.1    jruoho  *
    233   1.1.1.4  christos  * PARAMETERS:  None
    234       1.1    jruoho  *
    235   1.1.1.4  christos  * RETURN:      None
    236       1.1    jruoho  *
    237   1.1.1.4  christos  * DESCRIPTION: Print a usage message
    238       1.1    jruoho  *
    239   1.1.1.4  christos  *****************************************************************************/
    240       1.1    jruoho 
    241   1.1.1.4  christos static void
    242   1.1.1.4  christos usage (
    243   1.1.1.4  christos     void)
    244       1.1    jruoho {
    245       1.1    jruoho 
    246   1.1.1.4  christos     ACPI_USAGE_HEADER ("acpiexec [options] AMLfile1 AMLfile2 ...");
    247       1.1    jruoho 
    248   1.1.1.4  christos     ACPI_OPTION ("-b \"CommandLine\"",  "Batch mode command line execution (cmd1;cmd2;...)");
    249   1.1.1.4  christos     ACPI_OPTION ("-h -?",               "Display this help message");
    250   1.1.1.4  christos     ACPI_OPTION ("-m [Method]",         "Batch mode method execution. Default=MAIN");
    251   1.1.1.4  christos     printf ("\n");
    252       1.1    jruoho 
    253   1.1.1.4  christos     ACPI_OPTION ("-da",                 "Disable method abort on error");
    254  1.1.1.14  christos     ACPI_OPTION ("-df",                 "Disable Local fault handler");
    255   1.1.1.4  christos     ACPI_OPTION ("-di",                 "Disable execution of STA/INI methods during init");
    256   1.1.1.4  christos     ACPI_OPTION ("-do",                 "Disable Operation Region address simulation");
    257   1.1.1.4  christos     ACPI_OPTION ("-dr",                 "Disable repair of method return values");
    258   1.1.1.5  christos     ACPI_OPTION ("-ds",                 "Disable method auto-serialization");
    259   1.1.1.4  christos     ACPI_OPTION ("-dt",                 "Disable allocation tracking (performance)");
    260   1.1.1.4  christos     printf ("\n");
    261       1.1    jruoho 
    262   1.1.1.7  christos     ACPI_OPTION ("-ed",                 "Enable timer output for Debug Object");
    263   1.1.1.4  christos     ACPI_OPTION ("-ef",                 "Enable display of final memory statistics");
    264   1.1.1.4  christos     ACPI_OPTION ("-ei",                 "Enable additional tests for ACPICA interfaces");
    265   1.1.1.5  christos     ACPI_OPTION ("-el",                 "Enable loading of additional test tables");
    266  1.1.1.16  christos     ACPI_OPTION ("-eo",                 "Enable object evaluation log");
    267   1.1.1.4  christos     ACPI_OPTION ("-es",                 "Enable Interpreter Slack Mode");
    268   1.1.1.4  christos     ACPI_OPTION ("-et",                 "Enable debug semaphore timeout");
    269   1.1.1.4  christos     printf ("\n");
    270       1.1    jruoho 
    271   1.1.1.7  christos     ACPI_OPTION ("-fi <File>",          "Specify namespace initialization file");
    272   1.1.1.6  christos     ACPI_OPTION ("-fv <Value>",         "Operation Region initialization fill value");
    273   1.1.1.7  christos     printf ("\n");
    274   1.1.1.7  christos 
    275   1.1.1.7  christos     ACPI_OPTION ("-l",                  "Load tables and namespace only");
    276   1.1.1.4  christos     ACPI_OPTION ("-r",                  "Use hardware-reduced FADT V5");
    277  1.1.1.12  christos     ACPI_OPTION ("-te",                 "Exit loop on timeout instead of aborting method");
    278  1.1.1.12  christos     ACPI_OPTION ("-to <Seconds>",       "Set timeout period for AML while loops");
    279  1.1.1.12  christos     printf ("\n");
    280  1.1.1.12  christos 
    281   1.1.1.4  christos     ACPI_OPTION ("-v",                  "Display version information");
    282  1.1.1.17  christos     ACPI_OPTION ("-va",                 "Display verbose dump of any memory leaks");
    283   1.1.1.9  christos     ACPI_OPTION ("-vd",                 "Display build date and time");
    284  1.1.1.15  christos     ACPI_OPTION ("-vh",                 "Verbose exception handler output");
    285   1.1.1.4  christos     ACPI_OPTION ("-vi",                 "Verbose initialization output");
    286   1.1.1.4  christos     ACPI_OPTION ("-vr",                 "Verbose region handler output");
    287   1.1.1.4  christos     ACPI_OPTION ("-x <DebugLevel>",     "Debug output level");
    288   1.1.1.6  christos 
    289   1.1.1.6  christos     printf ("\n  From within the interactive mode, use '?' or \"help\" to see\n"
    290   1.1.1.6  christos         "  a list of available AML Debugger commands\n");
    291       1.1    jruoho }
    292       1.1    jruoho 
    293       1.1    jruoho 
    294       1.1    jruoho /******************************************************************************
    295       1.1    jruoho  *
    296   1.1.1.4  christos  * FUNCTION:    AeDoOptions
    297       1.1    jruoho  *
    298   1.1.1.4  christos  * PARAMETERS:  argc/argv           - Standard argc/argv
    299       1.1    jruoho  *
    300       1.1    jruoho  * RETURN:      Status
    301       1.1    jruoho  *
    302   1.1.1.4  christos  * DESCRIPTION: Command line option processing
    303       1.1    jruoho  *
    304       1.1    jruoho  *****************************************************************************/
    305       1.1    jruoho 
    306   1.1.1.4  christos static int
    307   1.1.1.4  christos AeDoOptions (
    308       1.1    jruoho     int                     argc,
    309       1.1    jruoho     char                    **argv)
    310       1.1    jruoho {
    311       1.1    jruoho     int                     j;
    312   1.1.1.7  christos     UINT32                  Temp;
    313       1.1    jruoho 
    314       1.1    jruoho 
    315   1.1.1.5  christos     while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j)
    316       1.1    jruoho     {
    317       1.1    jruoho     case 'b':
    318   1.1.1.4  christos 
    319   1.1.1.4  christos         if (strlen (AcpiGbl_Optarg) > (AE_BUFFER_SIZE -1))
    320       1.1    jruoho         {
    321  1.1.1.16  christos             printf ("**** The length of command line (%u) exceeded maximum (%d)\n",
    322   1.1.1.4  christos                 (UINT32) strlen (AcpiGbl_Optarg), (AE_BUFFER_SIZE -1));
    323   1.1.1.2    jruoho             return (-1);
    324       1.1    jruoho         }
    325   1.1.1.4  christos         AcpiGbl_ExecutionMode = AE_MODE_BATCH_MULTIPLE;
    326       1.1    jruoho         strcpy (BatchBuffer, AcpiGbl_Optarg);
    327       1.1    jruoho         break;
    328       1.1    jruoho 
    329       1.1    jruoho     case 'd':
    330   1.1.1.4  christos 
    331       1.1    jruoho         switch (AcpiGbl_Optarg[0])
    332       1.1    jruoho         {
    333       1.1    jruoho         case 'a':
    334   1.1.1.4  christos 
    335       1.1    jruoho             AcpiGbl_IgnoreErrors = TRUE;
    336       1.1    jruoho             break;
    337       1.1    jruoho 
    338  1.1.1.14  christos         case 'f':
    339  1.1.1.14  christos 
    340  1.1.1.14  christos             AcpiGbl_UseLocalFaultHandler = FALSE;
    341  1.1.1.14  christos             break;
    342  1.1.1.14  christos 
    343       1.1    jruoho         case 'i':
    344   1.1.1.4  christos 
    345   1.1.1.6  christos             AcpiGbl_DbOpt_NoIniMethods = TRUE;
    346       1.1    jruoho             break;
    347       1.1    jruoho 
    348       1.1    jruoho         case 'o':
    349   1.1.1.4  christos 
    350       1.1    jruoho             AcpiGbl_DbOpt_NoRegionSupport = TRUE;
    351       1.1    jruoho             break;
    352       1.1    jruoho 
    353   1.1.1.3    jruoho         case 'r':
    354   1.1.1.4  christos 
    355   1.1.1.3    jruoho             AcpiGbl_DisableAutoRepair = TRUE;
    356   1.1.1.3    jruoho             break;
    357   1.1.1.3    jruoho 
    358   1.1.1.5  christos         case 's':
    359   1.1.1.5  christos 
    360   1.1.1.5  christos             AcpiGbl_AutoSerializeMethods = FALSE;
    361   1.1.1.5  christos             break;
    362   1.1.1.5  christos 
    363       1.1    jruoho         case 't':
    364   1.1.1.4  christos 
    365       1.1    jruoho             #ifdef ACPI_DBG_TRACK_ALLOCATIONS
    366       1.1    jruoho                 AcpiGbl_DisableMemTracking = TRUE;
    367       1.1    jruoho             #endif
    368       1.1    jruoho             break;
    369       1.1    jruoho 
    370       1.1    jruoho         default:
    371   1.1.1.4  christos 
    372       1.1    jruoho             printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
    373       1.1    jruoho             return (-1);
    374       1.1    jruoho         }
    375       1.1    jruoho         break;
    376       1.1    jruoho 
    377       1.1    jruoho     case 'e':
    378   1.1.1.4  christos 
    379       1.1    jruoho         switch (AcpiGbl_Optarg[0])
    380       1.1    jruoho         {
    381   1.1.1.7  christos         case 'd':
    382   1.1.1.7  christos 
    383   1.1.1.7  christos             AcpiGbl_DisplayDebugTimer = TRUE;
    384   1.1.1.7  christos             break;
    385   1.1.1.7  christos 
    386       1.1    jruoho         case 'f':
    387   1.1.1.4  christos 
    388       1.1    jruoho             #ifdef ACPI_DBG_TRACK_ALLOCATIONS
    389       1.1    jruoho                 AcpiGbl_DisplayFinalMemStats = TRUE;
    390       1.1    jruoho             #endif
    391       1.1    jruoho             break;
    392       1.1    jruoho 
    393   1.1.1.4  christos         case 'i':
    394   1.1.1.4  christos 
    395   1.1.1.4  christos             AcpiGbl_DoInterfaceTests = TRUE;
    396   1.1.1.4  christos             break;
    397   1.1.1.4  christos 
    398   1.1.1.5  christos         case 'l':
    399   1.1.1.4  christos 
    400   1.1.1.5  christos             AcpiGbl_LoadTestTables = TRUE;
    401       1.1    jruoho             break;
    402       1.1    jruoho 
    403  1.1.1.16  christos         case 'o':
    404   1.1.1.7  christos 
    405  1.1.1.16  christos             AcpiDbgLevel |= ACPI_LV_EVALUATION;
    406  1.1.1.16  christos             AcpiGbl_DbConsoleDebugLevel |= ACPI_LV_EVALUATION;
    407   1.1.1.7  christos             break;
    408   1.1.1.7  christos 
    409       1.1    jruoho         case 's':
    410   1.1.1.4  christos 
    411       1.1    jruoho             AcpiGbl_EnableInterpreterSlack = TRUE;
    412       1.1    jruoho             printf ("Enabling AML Interpreter slack mode\n");
    413       1.1    jruoho             break;
    414       1.1    jruoho 
    415       1.1    jruoho         case 't':
    416   1.1.1.4  christos 
    417       1.1    jruoho             AcpiGbl_DebugTimeout = TRUE;
    418       1.1    jruoho             break;
    419       1.1    jruoho 
    420       1.1    jruoho         default:
    421   1.1.1.4  christos 
    422       1.1    jruoho             printf ("Unknown option: -e%s\n", AcpiGbl_Optarg);
    423       1.1    jruoho             return (-1);
    424       1.1    jruoho         }
    425       1.1    jruoho         break;
    426       1.1    jruoho 
    427       1.1    jruoho     case 'f':
    428   1.1.1.4  christos 
    429   1.1.1.6  christos         switch (AcpiGbl_Optarg[0])
    430   1.1.1.6  christos         {
    431   1.1.1.6  christos         case 'v':   /* -fv: region fill value */
    432   1.1.1.6  christos 
    433   1.1.1.6  christos             if (AcpiGetoptArgument (argc, argv))
    434   1.1.1.6  christos             {
    435   1.1.1.6  christos                 return (-1);
    436   1.1.1.6  christos             }
    437   1.1.1.6  christos 
    438   1.1.1.6  christos             AcpiGbl_RegionFillValue = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
    439   1.1.1.6  christos             break;
    440   1.1.1.6  christos 
    441   1.1.1.6  christos         case 'i':   /* -fi: specify initialization file */
    442   1.1.1.6  christos 
    443   1.1.1.6  christos             if (AcpiGetoptArgument (argc, argv))
    444   1.1.1.6  christos             {
    445   1.1.1.6  christos                 return (-1);
    446   1.1.1.6  christos             }
    447   1.1.1.6  christos 
    448   1.1.1.6  christos             if (AeOpenInitializationFile (AcpiGbl_Optarg))
    449   1.1.1.6  christos             {
    450   1.1.1.6  christos                 return (-1);
    451   1.1.1.6  christos             }
    452   1.1.1.6  christos             break;
    453   1.1.1.6  christos 
    454   1.1.1.6  christos         default:
    455   1.1.1.6  christos 
    456   1.1.1.6  christos             printf ("Unknown option: -f%s\n", AcpiGbl_Optarg);
    457   1.1.1.6  christos             return (-1);
    458   1.1.1.6  christos         }
    459       1.1    jruoho         break;
    460       1.1    jruoho 
    461       1.1    jruoho     case 'g':
    462   1.1.1.4  christos 
    463       1.1    jruoho         AcpiGbl_DbFilename = NULL;
    464       1.1    jruoho         break;
    465       1.1    jruoho 
    466   1.1.1.4  christos     case 'h':
    467   1.1.1.4  christos     case '?':
    468   1.1.1.4  christos 
    469   1.1.1.4  christos         usage();
    470   1.1.1.7  christos         return (1);
    471   1.1.1.7  christos 
    472   1.1.1.7  christos     case 'l':
    473   1.1.1.7  christos 
    474   1.1.1.7  christos         AcpiGbl_AeLoadOnly = TRUE;
    475   1.1.1.7  christos         break;
    476   1.1.1.4  christos 
    477       1.1    jruoho     case 'm':
    478   1.1.1.4  christos 
    479   1.1.1.4  christos         AcpiGbl_ExecutionMode = AE_MODE_BATCH_SINGLE;
    480       1.1    jruoho         switch (AcpiGbl_Optarg[0])
    481       1.1    jruoho         {
    482       1.1    jruoho         case '^':
    483   1.1.1.4  christos 
    484       1.1    jruoho             strcpy (BatchBuffer, "MAIN");
    485       1.1    jruoho             break;
    486       1.1    jruoho 
    487       1.1    jruoho         default:
    488   1.1.1.4  christos 
    489       1.1    jruoho             strcpy (BatchBuffer, AcpiGbl_Optarg);
    490       1.1    jruoho             break;
    491       1.1    jruoho         }
    492       1.1    jruoho         break;
    493       1.1    jruoho 
    494   1.1.1.4  christos     case 'r':
    495   1.1.1.4  christos 
    496   1.1.1.4  christos         AcpiGbl_UseHwReducedFadt = TRUE;
    497   1.1.1.4  christos         printf ("Using ACPI 5.0 Hardware Reduced Mode via version 5 FADT\n");
    498   1.1.1.4  christos         break;
    499   1.1.1.4  christos 
    500  1.1.1.12  christos     case 't':
    501  1.1.1.12  christos 
    502  1.1.1.12  christos         switch (AcpiGbl_Optarg[0])
    503  1.1.1.12  christos         {
    504  1.1.1.12  christos         case 'o':  /* -to: Set loop timeout in seconds */
    505  1.1.1.12  christos 
    506  1.1.1.12  christos             if (AcpiGetoptArgument (argc, argv))
    507  1.1.1.12  christos             {
    508  1.1.1.12  christos                 return (-1);
    509  1.1.1.12  christos             }
    510  1.1.1.12  christos 
    511  1.1.1.12  christos             Temp = strtoul (AcpiGbl_Optarg, NULL, 0);
    512  1.1.1.12  christos             if (!Temp || (Temp > ACPI_UINT16_MAX))
    513  1.1.1.12  christos             {
    514  1.1.1.12  christos                 printf ("%s: Invalid loop timeout value\n",
    515  1.1.1.12  christos                     AcpiGbl_Optarg);
    516  1.1.1.12  christos                 return (-1);
    517  1.1.1.12  christos             }
    518  1.1.1.12  christos 
    519  1.1.1.12  christos             AcpiGbl_MaxLoopIterations = (UINT16) Temp;
    520  1.1.1.12  christos             printf ("Automatic loop timeout after %u seconds\n",
    521  1.1.1.12  christos                 AcpiGbl_MaxLoopIterations);
    522  1.1.1.12  christos             break;
    523  1.1.1.12  christos 
    524  1.1.1.12  christos         case 'e':
    525  1.1.1.12  christos 
    526  1.1.1.12  christos             AcpiGbl_AbortLoopOnTimeout = TRUE;
    527  1.1.1.12  christos             break;
    528  1.1.1.12  christos 
    529  1.1.1.12  christos         default:
    530  1.1.1.12  christos 
    531  1.1.1.12  christos             printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
    532  1.1.1.12  christos             return (-1);
    533  1.1.1.12  christos         }
    534  1.1.1.12  christos         break;
    535  1.1.1.12  christos 
    536       1.1    jruoho     case 'v':
    537   1.1.1.4  christos 
    538   1.1.1.4  christos         switch (AcpiGbl_Optarg[0])
    539   1.1.1.4  christos         {
    540   1.1.1.4  christos         case '^':  /* -v: (Version): signon already emitted, just exit */
    541   1.1.1.4  christos 
    542   1.1.1.7  christos             return (1);
    543   1.1.1.4  christos 
    544  1.1.1.17  christos         case 'a':
    545  1.1.1.17  christos 
    546  1.1.1.17  christos             AcpiGbl_VerboseLeakDump = TRUE;
    547  1.1.1.17  christos             break;
    548  1.1.1.17  christos 
    549   1.1.1.9  christos         case 'd':
    550   1.1.1.9  christos 
    551  1.1.1.12  christos             printf (ACPI_COMMON_BUILD_TIME);
    552   1.1.1.9  christos             return (1);
    553   1.1.1.9  christos 
    554  1.1.1.15  christos         case 'h':
    555  1.1.1.15  christos 
    556  1.1.1.15  christos             AcpiGbl_VerboseHandlers = TRUE;
    557  1.1.1.15  christos             break;
    558  1.1.1.15  christos 
    559   1.1.1.4  christos         case 'i':
    560   1.1.1.4  christos 
    561   1.1.1.4  christos             AcpiDbgLevel |= ACPI_LV_INIT_NAMES;
    562   1.1.1.4  christos             break;
    563   1.1.1.4  christos 
    564   1.1.1.4  christos         case 'r':
    565   1.1.1.4  christos 
    566   1.1.1.4  christos             AcpiGbl_DisplayRegionAccess = TRUE;
    567   1.1.1.4  christos             break;
    568   1.1.1.4  christos 
    569   1.1.1.4  christos         default:
    570   1.1.1.4  christos 
    571   1.1.1.4  christos             printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
    572   1.1.1.4  christos             return (-1);
    573   1.1.1.4  christos         }
    574       1.1    jruoho         break;
    575       1.1    jruoho 
    576       1.1    jruoho     case 'x':
    577   1.1.1.4  christos 
    578  1.1.1.15  christos         AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
    579       1.1    jruoho         AcpiGbl_DbConsoleDebugLevel = AcpiDbgLevel;
    580       1.1    jruoho         printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel);
    581       1.1    jruoho         break;
    582       1.1    jruoho 
    583       1.1    jruoho     default:
    584   1.1.1.4  christos 
    585       1.1    jruoho         usage();
    586   1.1.1.2    jruoho         return (-1);
    587       1.1    jruoho     }
    588       1.1    jruoho 
    589   1.1.1.4  christos     return (0);
    590   1.1.1.4  christos }
    591       1.1    jruoho 
    592       1.1    jruoho 
    593   1.1.1.4  christos /******************************************************************************
    594   1.1.1.4  christos  *
    595   1.1.1.4  christos  * FUNCTION:    main
    596   1.1.1.4  christos  *
    597   1.1.1.4  christos  * PARAMETERS:  argc, argv
    598   1.1.1.4  christos  *
    599   1.1.1.4  christos  * RETURN:      Status
    600   1.1.1.4  christos  *
    601   1.1.1.4  christos  * DESCRIPTION: Main routine for AcpiExec utility
    602   1.1.1.4  christos  *
    603   1.1.1.4  christos  *****************************************************************************/
    604       1.1    jruoho 
    605   1.1.1.4  christos int ACPI_SYSTEM_XFACE
    606   1.1.1.4  christos main (
    607   1.1.1.4  christos     int                     argc,
    608   1.1.1.4  christos     char                    **argv)
    609   1.1.1.4  christos {
    610   1.1.1.7  christos     ACPI_NEW_TABLE_DESC     *ListHead = NULL;
    611   1.1.1.4  christos     ACPI_STATUS             Status;
    612   1.1.1.4  christos     UINT32                  InitFlags;
    613   1.1.1.7  christos     int                     ExitCode = 0;
    614       1.1    jruoho 
    615       1.1    jruoho 
    616   1.1.1.4  christos     ACPI_DEBUG_INITIALIZE (); /* For debug version only */
    617  1.1.1.11  christos 
    618  1.1.1.11  christos     signal (SIGINT, AeSignalHandler);
    619       1.1    jruoho 
    620   1.1.1.5  christos     /* Init debug globals */
    621       1.1    jruoho 
    622   1.1.1.4  christos     AcpiDbgLevel = ACPI_NORMAL_DEFAULT;
    623   1.1.1.4  christos     AcpiDbgLayer = 0xFFFFFFFF;
    624       1.1    jruoho 
    625   1.1.1.9  christos     /*
    626   1.1.1.9  christos      * Initialize ACPICA and start debugger thread.
    627   1.1.1.9  christos      *
    628   1.1.1.9  christos      * NOTE: After ACPICA initialization, AcpiTerminate MUST be called
    629   1.1.1.9  christos      * before this procedure exits -- otherwise, the console may be
    630   1.1.1.9  christos      * left in an incorrect state.
    631   1.1.1.9  christos      */
    632   1.1.1.4  christos     Status = AcpiInitializeSubsystem ();
    633   1.1.1.7  christos     ACPI_CHECK_OK (AcpiInitializeSubsystem, Status);
    634   1.1.1.7  christos     if (ACPI_FAILURE (Status))
    635   1.1.1.7  christos     {
    636  1.1.1.20  christos         ExitCode = -1;
    637   1.1.1.7  christos         goto ErrorExit;
    638   1.1.1.7  christos     }
    639   1.1.1.7  christos 
    640  1.1.1.12  christos     /* Use a shorter timeout value for acpiexec */
    641  1.1.1.12  christos 
    642  1.1.1.21  christos     AcpiGbl_MaxLoopIterations = 10;
    643  1.1.1.12  christos 
    644   1.1.1.7  christos     /* Initialize the AML debugger */
    645   1.1.1.7  christos 
    646   1.1.1.7  christos     Status = AcpiInitializeDebugger ();
    647   1.1.1.7  christos     ACPI_CHECK_OK (AcpiInitializeDebugger, Status);
    648   1.1.1.4  christos     if (ACPI_FAILURE (Status))
    649   1.1.1.4  christos     {
    650  1.1.1.20  christos         ExitCode = -1;
    651   1.1.1.4  christos         goto ErrorExit;
    652   1.1.1.4  christos     }
    653       1.1    jruoho 
    654   1.1.1.5  christos     printf (ACPI_COMMON_SIGNON (ACPIEXEC_NAME));
    655   1.1.1.5  christos     if (argc < 2)
    656   1.1.1.5  christos     {
    657   1.1.1.5  christos         usage ();
    658   1.1.1.9  christos         goto NormalExit;
    659   1.1.1.5  christos     }
    660   1.1.1.5  christos 
    661   1.1.1.4  christos     /* Get the command line options */
    662       1.1    jruoho 
    663   1.1.1.7  christos     ExitCode = AeDoOptions (argc, argv);
    664   1.1.1.7  christos     if (ExitCode)
    665   1.1.1.4  christos     {
    666   1.1.1.7  christos         if (ExitCode > 0)
    667   1.1.1.7  christos         {
    668   1.1.1.7  christos             ExitCode = 0;
    669   1.1.1.7  christos         }
    670   1.1.1.7  christos 
    671   1.1.1.4  christos         goto ErrorExit;
    672   1.1.1.4  christos     }
    673       1.1    jruoho 
    674  1.1.1.15  christos     if (AcpiGbl_UseLocalFaultHandler)
    675  1.1.1.15  christos     {
    676  1.1.1.15  christos         signal (SIGSEGV, AeSignalHandler);
    677  1.1.1.15  christos     }
    678  1.1.1.15  christos 
    679   1.1.1.4  christos     /* The remaining arguments are filenames for ACPI tables */
    680       1.1    jruoho 
    681   1.1.1.4  christos     if (!argv[AcpiGbl_Optind])
    682   1.1.1.4  christos     {
    683   1.1.1.4  christos         goto EnterDebugger;
    684   1.1.1.4  christos     }
    685       1.1    jruoho 
    686   1.1.1.6  christos     AcpiGbl_CstyleDisassembly = FALSE; /* Not supported for AcpiExec */
    687       1.1    jruoho 
    688   1.1.1.4  christos     /* Get each of the ACPI table files on the command line */
    689       1.1    jruoho 
    690   1.1.1.4  christos     while (argv[AcpiGbl_Optind])
    691   1.1.1.4  christos     {
    692   1.1.1.7  christos         /* Get all ACPI AML tables in this file */
    693       1.1    jruoho 
    694   1.1.1.7  christos         Status = AcGetAllTablesFromFile (argv[AcpiGbl_Optind],
    695   1.1.1.9  christos             ACPI_GET_ALL_TABLES, &ListHead);
    696       1.1    jruoho         if (ACPI_FAILURE (Status))
    697       1.1    jruoho         {
    698   1.1.1.7  christos             ExitCode = -1;
    699   1.1.1.4  christos             goto ErrorExit;
    700       1.1    jruoho         }
    701       1.1    jruoho 
    702   1.1.1.4  christos         AcpiGbl_Optind++;
    703       1.1    jruoho     }
    704       1.1    jruoho 
    705   1.1.1.5  christos     printf ("\n");
    706   1.1.1.5  christos 
    707   1.1.1.4  christos     /* Build a local RSDT with all tables and let ACPICA process the RSDT */
    708       1.1    jruoho 
    709   1.1.1.7  christos     Status = AeBuildLocalTables (ListHead);
    710   1.1.1.4  christos     if (ACPI_FAILURE (Status))
    711       1.1    jruoho     {
    712  1.1.1.20  christos         ExitCode = -1;
    713   1.1.1.4  christos         goto ErrorExit;
    714       1.1    jruoho     }
    715   1.1.1.4  christos 
    716   1.1.1.7  christos     /* Install all of the ACPI tables */
    717   1.1.1.7  christos 
    718   1.1.1.4  christos     Status = AeInstallTables ();
    719   1.1.1.4  christos     if (ACPI_FAILURE (Status))
    720       1.1    jruoho     {
    721   1.1.1.7  christos         printf ("**** Could not install ACPI tables, %s\n",
    722   1.1.1.4  christos             AcpiFormatException (Status));
    723   1.1.1.4  christos         goto EnterDebugger;
    724   1.1.1.4  christos     }
    725   1.1.1.4  christos 
    726   1.1.1.4  christos     /*
    727   1.1.1.7  christos      * Install most of the handlers (Regions, Notify, Table, etc.)
    728   1.1.1.7  christos      * Override the default region handlers, especially SystemMemory,
    729   1.1.1.7  christos      * which is simulated in this utility.
    730   1.1.1.4  christos      */
    731   1.1.1.4  christos     Status = AeInstallEarlyHandlers ();
    732   1.1.1.4  christos     if (ACPI_FAILURE (Status))
    733   1.1.1.4  christos     {
    734   1.1.1.4  christos         goto EnterDebugger;
    735   1.1.1.4  christos     }
    736   1.1.1.4  christos 
    737  1.1.1.19  christos     /* Read the entire namespace initialization file if requested */
    738  1.1.1.19  christos 
    739  1.1.1.19  christos     Status = AeProcessInitFile();
    740  1.1.1.19  christos     if (ACPI_FAILURE (Status))
    741  1.1.1.19  christos     {
    742  1.1.1.19  christos         ExitCode = -1;
    743  1.1.1.19  christos         goto ErrorExit;
    744  1.1.1.19  christos     }
    745  1.1.1.19  christos 
    746  1.1.1.13  christos     Status = AeLoadTables ();
    747  1.1.1.19  christos     if (ACPI_FAILURE (Status))
    748  1.1.1.19  christos     {
    749  1.1.1.20  christos         printf ("**** Could not load ACPI tables, %s\n",
    750  1.1.1.20  christos             AcpiFormatException (Status));
    751  1.1.1.20  christos         goto EnterDebugger;
    752  1.1.1.19  christos     }
    753  1.1.1.13  christos 
    754  1.1.1.13  christos     /*
    755  1.1.1.13  christos      * Exit namespace initialization for the "load namespace only" option.
    756  1.1.1.13  christos      * No control methods will be executed. However, still enter the
    757  1.1.1.13  christos      * the debugger.
    758  1.1.1.13  christos      */
    759  1.1.1.13  christos     if (AcpiGbl_AeLoadOnly)
    760  1.1.1.13  christos     {
    761  1.1.1.13  christos         goto EnterDebugger;
    762  1.1.1.13  christos     }
    763  1.1.1.13  christos 
    764   1.1.1.4  christos     /* Setup initialization flags for ACPICA */
    765   1.1.1.4  christos 
    766   1.1.1.4  christos     InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE);
    767   1.1.1.6  christos     if (AcpiGbl_DbOpt_NoIniMethods)
    768   1.1.1.4  christos     {
    769   1.1.1.4  christos         InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT);
    770   1.1.1.4  christos     }
    771   1.1.1.4  christos 
    772   1.1.1.4  christos     /*
    773   1.1.1.4  christos      * Main initialization for ACPICA subsystem
    774   1.1.1.9  christos      * TBD: Need a way to call this after the ACPI table "LOAD" command?
    775   1.1.1.9  christos      *
    776   1.1.1.9  christos      * NOTE: This initialization does not match the _Lxx and _Exx methods
    777   1.1.1.9  christos      * to individual GPEs, as there are no real GPEs when the hardware
    778   1.1.1.9  christos      * is simulated - because there is no namespace until AeLoadTables is
    779   1.1.1.9  christos      * executed. This may have to change if AcpiExec is ever run natively
    780   1.1.1.9  christos      * on actual hardware (such as under UEFI).
    781   1.1.1.4  christos      */
    782   1.1.1.4  christos     Status = AcpiEnableSubsystem (InitFlags);
    783   1.1.1.4  christos     if (ACPI_FAILURE (Status))
    784   1.1.1.4  christos     {
    785   1.1.1.4  christos         printf ("**** Could not EnableSubsystem, %s\n",
    786   1.1.1.4  christos             AcpiFormatException (Status));
    787   1.1.1.4  christos         goto EnterDebugger;
    788   1.1.1.4  christos     }
    789   1.1.1.4  christos 
    790   1.1.1.4  christos     /*
    791   1.1.1.4  christos      * Install handlers for "device driver" space IDs (EC,SMBus, etc.)
    792   1.1.1.4  christos      * and fixed event handlers
    793   1.1.1.4  christos      */
    794   1.1.1.4  christos     AeInstallLateHandlers ();
    795   1.1.1.4  christos 
    796   1.1.1.4  christos     /* Finish the ACPICA initialization */
    797   1.1.1.4  christos 
    798   1.1.1.4  christos     Status = AcpiInitializeObjects (InitFlags);
    799   1.1.1.4  christos     if (ACPI_FAILURE (Status))
    800   1.1.1.4  christos     {
    801   1.1.1.4  christos         printf ("**** Could not InitializeObjects, %s\n",
    802   1.1.1.4  christos             AcpiFormatException (Status));
    803   1.1.1.4  christos         goto EnterDebugger;
    804   1.1.1.4  christos     }
    805   1.1.1.4  christos 
    806  1.1.1.19  christos     AeDisplayUnusedInitFileItems ();
    807   1.1.1.4  christos     AeMiscellaneousTests ();
    808   1.1.1.4  christos 
    809   1.1.1.4  christos 
    810   1.1.1.4  christos EnterDebugger:
    811   1.1.1.4  christos 
    812   1.1.1.4  christos     /* Exit if error above and we are in one of the batch modes */
    813   1.1.1.4  christos 
    814   1.1.1.4  christos     if (ACPI_FAILURE (Status) && (AcpiGbl_ExecutionMode > 0))
    815   1.1.1.4  christos     {
    816   1.1.1.4  christos         goto ErrorExit;
    817       1.1    jruoho     }
    818   1.1.1.4  christos 
    819   1.1.1.4  christos     /* Run a batch command or enter the command loop */
    820   1.1.1.4  christos 
    821   1.1.1.4  christos     switch (AcpiGbl_ExecutionMode)
    822       1.1    jruoho     {
    823   1.1.1.4  christos     default:
    824   1.1.1.4  christos     case AE_MODE_COMMAND_LOOP:
    825       1.1    jruoho 
    826  1.1.1.10  christos         AcpiRunDebugger (NULL);
    827   1.1.1.4  christos         break;
    828   1.1.1.4  christos 
    829   1.1.1.4  christos     case AE_MODE_BATCH_MULTIPLE:
    830   1.1.1.4  christos 
    831  1.1.1.10  christos         AcpiRunDebugger (BatchBuffer);
    832   1.1.1.4  christos         break;
    833   1.1.1.4  christos 
    834   1.1.1.4  christos     case AE_MODE_BATCH_SINGLE:
    835   1.1.1.4  christos 
    836   1.1.1.4  christos         AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP);
    837   1.1.1.4  christos         break;
    838       1.1    jruoho     }
    839       1.1    jruoho 
    840   1.1.1.9  christos     /* Shut down the debugger and ACPICA */
    841   1.1.1.4  christos 
    842   1.1.1.9  christos     AcpiTerminateDebugger ();
    843   1.1.1.9  christos 
    844  1.1.1.12  christos     /* re-enable debug output for AcpiTerminate output */
    845  1.1.1.12  christos 
    846  1.1.1.12  christos     AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT;
    847  1.1.1.12  christos 
    848   1.1.1.9  christos NormalExit:
    849   1.1.1.9  christos     ExitCode = 0;
    850   1.1.1.4  christos 
    851   1.1.1.4  christos ErrorExit:
    852  1.1.1.17  christos     AeLateTest ();
    853  1.1.1.19  christos 
    854  1.1.1.19  christos     AeDeleteInitFileList ();
    855  1.1.1.19  christos 
    856  1.1.1.12  christos     (void) AcpiTerminate ();
    857  1.1.1.11  christos     AcDeleteTableList (ListHead);
    858   1.1.1.7  christos     return (ExitCode);
    859       1.1    jruoho }
    860