Home | History | Annotate | Line # | Download | only in debugger
dbinput.c revision 1.1.1.25
      1       1.1    jruoho /*******************************************************************************
      2       1.1    jruoho  *
      3       1.1    jruoho  * Module Name: dbinput - user front-end to the AML debugger
      4       1.1    jruoho  *
      5       1.1    jruoho  ******************************************************************************/
      6       1.1    jruoho 
      7  1.1.1.24  christos /******************************************************************************
      8  1.1.1.24  christos  *
      9  1.1.1.24  christos  * 1. Copyright Notice
     10  1.1.1.24  christos  *
     11  1.1.1.25  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.24  christos  * 2. License
     15  1.1.1.24  christos  *
     16  1.1.1.24  christos  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.1.1.24  christos  * rights. You may have additional license terms from the party that provided
     18  1.1.1.24  christos  * you this software, covering your right to use that party's intellectual
     19  1.1.1.24  christos  * property rights.
     20  1.1.1.24  christos  *
     21  1.1.1.24  christos  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.1.1.24  christos  * copy of the source code appearing in this file ("Covered Code") an
     23  1.1.1.24  christos  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.1.1.24  christos  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.1.1.24  christos  * make derivatives, distribute, use and display any portion of the Covered
     26  1.1.1.24  christos  * Code in any form, with the right to sublicense such rights; and
     27  1.1.1.24  christos  *
     28  1.1.1.24  christos  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.1.1.24  christos  * license (with the right to sublicense), under only those claims of Intel
     30  1.1.1.24  christos  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.1.1.24  christos  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.1.1.24  christos  * solely to the minimum extent necessary to exercise the above copyright
     33  1.1.1.24  christos  * license, and in no event shall the patent license extend to any additions
     34  1.1.1.24  christos  * to or modifications of the Original Intel Code. No other license or right
     35  1.1.1.24  christos  * is granted directly or by implication, estoppel or otherwise;
     36  1.1.1.24  christos  *
     37  1.1.1.24  christos  * The above copyright and patent license is granted only if the following
     38  1.1.1.24  christos  * conditions are met:
     39  1.1.1.24  christos  *
     40  1.1.1.24  christos  * 3. Conditions
     41  1.1.1.24  christos  *
     42  1.1.1.24  christos  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.1.1.24  christos  * Redistribution of source code of any substantial portion of the Covered
     44  1.1.1.24  christos  * Code or modification with rights to further distribute source must include
     45  1.1.1.24  christos  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.1.1.24  christos  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.1.1.24  christos  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.1.1.24  christos  * contain a file documenting the changes Licensee made to create that Covered
     49  1.1.1.24  christos  * Code and the date of any change. Licensee must include in that file the
     50  1.1.1.24  christos  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.1.1.24  christos  * must include a prominent statement that the modification is derived,
     52  1.1.1.24  christos  * directly or indirectly, from Original Intel Code.
     53  1.1.1.24  christos  *
     54  1.1.1.24  christos  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.1.1.24  christos  * Redistribution of source code of any substantial portion of the Covered
     56  1.1.1.24  christos  * Code or modification without rights to further distribute source must
     57  1.1.1.24  christos  * include the following Disclaimer and Export Compliance provision in the
     58  1.1.1.24  christos  * documentation and/or other materials provided with distribution. In
     59  1.1.1.24  christos  * addition, Licensee may not authorize further sublicense of source of any
     60  1.1.1.24  christos  * portion of the Covered Code, and must include terms to the effect that the
     61  1.1.1.24  christos  * license from Licensee to its licensee is limited to the intellectual
     62  1.1.1.24  christos  * property embodied in the software Licensee provides to its licensee, and
     63  1.1.1.24  christos  * not to intellectual property embodied in modifications its licensee may
     64  1.1.1.24  christos  * make.
     65  1.1.1.24  christos  *
     66  1.1.1.24  christos  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.1.1.24  christos  * substantial portion of the Covered Code or modification must reproduce the
     68  1.1.1.24  christos  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.1.1.24  christos  * provision in the documentation and/or other materials provided with the
     70  1.1.1.24  christos  * distribution.
     71  1.1.1.24  christos  *
     72  1.1.1.24  christos  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.1.1.24  christos  * Intel Code.
     74  1.1.1.24  christos  *
     75  1.1.1.24  christos  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.1.1.24  christos  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.1.1.24  christos  * other dealings in products derived from or relating to the Covered Code
     78  1.1.1.24  christos  * without prior written authorization from Intel.
     79  1.1.1.24  christos  *
     80  1.1.1.24  christos  * 4. Disclaimer and Export Compliance
     81  1.1.1.24  christos  *
     82  1.1.1.24  christos  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.1.1.24  christos  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.1.1.24  christos  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.1.1.24  christos  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.1.1.24  christos  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.1.1.24  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.1.1.24  christos  * PARTICULAR PURPOSE.
     89  1.1.1.24  christos  *
     90  1.1.1.24  christos  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.1.1.24  christos  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.1.1.24  christos  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.1.1.24  christos  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.1.1.24  christos  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.1.1.24  christos  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.1.1.24  christos  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.1.1.24  christos  * LIMITED REMEDY.
     98  1.1.1.24  christos  *
     99  1.1.1.24  christos  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.1.1.24  christos  * software or system incorporating such software without first obtaining any
    101  1.1.1.24  christos  * required license or other approval from the U. S. Department of Commerce or
    102  1.1.1.24  christos  * any other agency or department of the United States Government. In the
    103  1.1.1.24  christos  * event Licensee exports any such software from the United States or
    104  1.1.1.24  christos  * re-exports any such software from a foreign destination, Licensee shall
    105  1.1.1.24  christos  * ensure that the distribution and export/re-export of the software is in
    106  1.1.1.24  christos  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.1.1.24  christos  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.1.1.24  christos  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.1.1.24  christos  * software, or service, directly or indirectly, to any country for which the
    110  1.1.1.24  christos  * United States government or any agency thereof requires an export license,
    111  1.1.1.24  christos  * other governmental approval, or letter of assurance, without first obtaining
    112  1.1.1.24  christos  * such license, approval or letter.
    113  1.1.1.24  christos  *
    114  1.1.1.24  christos  *****************************************************************************
    115  1.1.1.24  christos  *
    116  1.1.1.24  christos  * Alternatively, you may choose to be licensed under the terms of the
    117  1.1.1.24  christos  * following license:
    118  1.1.1.24  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.21  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.24  christos  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.1.1.24  christos  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.1.1.24  christos  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.1.1.24  christos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.1.1.24  christos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.1.1.24  christos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.1.1.24  christos  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.1.1.24  christos  *
    146  1.1.1.24  christos  * Alternatively, you may choose to be licensed under the terms of the
    147  1.1.1.24  christos  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.1.1.24  christos  * Software Foundation.
    149  1.1.1.24  christos  *
    150  1.1.1.24  christos  *****************************************************************************/
    151       1.1    jruoho 
    152       1.1    jruoho #include "acpi.h"
    153       1.1    jruoho #include "accommon.h"
    154       1.1    jruoho #include "acdebug.h"
    155       1.1    jruoho 
    156   1.1.1.8  christos #ifdef ACPI_APPLICATION
    157   1.1.1.8  christos #include "acapps.h"
    158   1.1.1.8  christos #endif
    159       1.1    jruoho 
    160       1.1    jruoho #define _COMPONENT          ACPI_CA_DEBUGGER
    161       1.1    jruoho         ACPI_MODULE_NAME    ("dbinput")
    162       1.1    jruoho 
    163   1.1.1.8  christos 
    164       1.1    jruoho /* Local prototypes */
    165       1.1    jruoho 
    166       1.1    jruoho static UINT32
    167       1.1    jruoho AcpiDbGetLine (
    168       1.1    jruoho     char                    *InputBuffer);
    169       1.1    jruoho 
    170       1.1    jruoho static UINT32
    171       1.1    jruoho AcpiDbMatchCommand (
    172       1.1    jruoho     char                    *UserCommand);
    173       1.1    jruoho 
    174       1.1    jruoho static void
    175   1.1.1.4  christos AcpiDbDisplayCommandInfo (
    176   1.1.1.9  christos     const char              *Command,
    177   1.1.1.4  christos     BOOLEAN                 DisplayAll);
    178   1.1.1.4  christos 
    179   1.1.1.4  christos static void
    180       1.1    jruoho AcpiDbDisplayHelp (
    181   1.1.1.4  christos     char                    *Command);
    182   1.1.1.4  christos 
    183   1.1.1.4  christos static BOOLEAN
    184   1.1.1.4  christos AcpiDbMatchCommandHelp (
    185   1.1.1.9  christos     const char                  *Command,
    186   1.1.1.4  christos     const ACPI_DB_COMMAND_HELP  *Help);
    187       1.1    jruoho 
    188       1.1    jruoho 
    189       1.1    jruoho /*
    190       1.1    jruoho  * Top-level debugger commands.
    191       1.1    jruoho  *
    192       1.1    jruoho  * This list of commands must match the string table below it
    193       1.1    jruoho  */
    194       1.1    jruoho enum AcpiExDebuggerCommands
    195       1.1    jruoho {
    196       1.1    jruoho     CMD_NOT_FOUND = 0,
    197       1.1    jruoho     CMD_NULL,
    198  1.1.1.20  christos     CMD_ALL,
    199       1.1    jruoho     CMD_ALLOCATIONS,
    200       1.1    jruoho     CMD_ARGS,
    201       1.1    jruoho     CMD_ARGUMENTS,
    202       1.1    jruoho     CMD_BREAKPOINT,
    203       1.1    jruoho     CMD_BUSINFO,
    204       1.1    jruoho     CMD_CALL,
    205       1.1    jruoho     CMD_DEBUG,
    206       1.1    jruoho     CMD_DISASSEMBLE,
    207   1.1.1.4  christos     CMD_DISASM,
    208       1.1    jruoho     CMD_DUMP,
    209   1.1.1.4  christos     CMD_EVALUATE,
    210       1.1    jruoho     CMD_EXECUTE,
    211       1.1    jruoho     CMD_EXIT,
    212  1.1.1.18  christos     CMD_FIELDS,
    213       1.1    jruoho     CMD_FIND,
    214       1.1    jruoho     CMD_GO,
    215   1.1.1.2    jruoho     CMD_HANDLERS,
    216       1.1    jruoho     CMD_HELP,
    217       1.1    jruoho     CMD_HELP2,
    218       1.1    jruoho     CMD_HISTORY,
    219       1.1    jruoho     CMD_HISTORY_EXE,
    220       1.1    jruoho     CMD_HISTORY_LAST,
    221       1.1    jruoho     CMD_INFORMATION,
    222       1.1    jruoho     CMD_INTEGRITY,
    223       1.1    jruoho     CMD_INTO,
    224       1.1    jruoho     CMD_LEVEL,
    225       1.1    jruoho     CMD_LIST,
    226       1.1    jruoho     CMD_LOCALS,
    227       1.1    jruoho     CMD_LOCKS,
    228       1.1    jruoho     CMD_METHODS,
    229       1.1    jruoho     CMD_NAMESPACE,
    230       1.1    jruoho     CMD_NOTIFY,
    231   1.1.1.4  christos     CMD_OBJECTS,
    232   1.1.1.2    jruoho     CMD_OSI,
    233       1.1    jruoho     CMD_OWNER,
    234   1.1.1.4  christos     CMD_PATHS,
    235       1.1    jruoho     CMD_PREDEFINED,
    236       1.1    jruoho     CMD_PREFIX,
    237       1.1    jruoho     CMD_QUIT,
    238       1.1    jruoho     CMD_REFERENCES,
    239       1.1    jruoho     CMD_RESOURCES,
    240       1.1    jruoho     CMD_RESULTS,
    241       1.1    jruoho     CMD_SET,
    242       1.1    jruoho     CMD_STATS,
    243       1.1    jruoho     CMD_STOP,
    244       1.1    jruoho     CMD_TABLES,
    245   1.1.1.4  christos     CMD_TEMPLATE,
    246       1.1    jruoho     CMD_TRACE,
    247       1.1    jruoho     CMD_TREE,
    248       1.1    jruoho     CMD_TYPE,
    249   1.1.1.8  christos #ifdef ACPI_APPLICATION
    250   1.1.1.8  christos     CMD_ENABLEACPI,
    251   1.1.1.8  christos     CMD_EVENT,
    252   1.1.1.8  christos     CMD_GPE,
    253   1.1.1.8  christos     CMD_GPES,
    254   1.1.1.8  christos     CMD_SCI,
    255   1.1.1.8  christos     CMD_SLEEP,
    256   1.1.1.8  christos 
    257   1.1.1.8  christos     CMD_CLOSE,
    258   1.1.1.8  christos     CMD_LOAD,
    259   1.1.1.8  christos     CMD_OPEN,
    260   1.1.1.8  christos     CMD_UNLOAD,
    261   1.1.1.8  christos 
    262   1.1.1.8  christos     CMD_TERMINATE,
    263  1.1.1.12  christos     CMD_BACKGROUND,
    264   1.1.1.8  christos     CMD_THREADS,
    265   1.1.1.8  christos 
    266   1.1.1.8  christos     CMD_TEST,
    267  1.1.1.23  christos 	CMD_INTERRUPT,
    268   1.1.1.8  christos #endif
    269       1.1    jruoho };
    270       1.1    jruoho 
    271       1.1    jruoho #define CMD_FIRST_VALID     2
    272       1.1    jruoho 
    273       1.1    jruoho 
    274       1.1    jruoho /* Second parameter is the required argument count */
    275       1.1    jruoho 
    276   1.1.1.4  christos static const ACPI_DB_COMMAND_INFO   AcpiGbl_DbCommands[] =
    277       1.1    jruoho {
    278       1.1    jruoho     {"<NOT FOUND>",  0},
    279       1.1    jruoho     {"<NULL>",       0},
    280  1.1.1.20  christos     {"ALL",          1},
    281       1.1    jruoho     {"ALLOCATIONS",  0},
    282       1.1    jruoho     {"ARGS",         0},
    283       1.1    jruoho     {"ARGUMENTS",    0},
    284       1.1    jruoho     {"BREAKPOINT",   1},
    285       1.1    jruoho     {"BUSINFO",      0},
    286       1.1    jruoho     {"CALL",         0},
    287       1.1    jruoho     {"DEBUG",        1},
    288       1.1    jruoho     {"DISASSEMBLE",  1},
    289   1.1.1.4  christos     {"DISASM",       1},
    290       1.1    jruoho     {"DUMP",         1},
    291   1.1.1.4  christos     {"EVALUATE",     1},
    292       1.1    jruoho     {"EXECUTE",      1},
    293       1.1    jruoho     {"EXIT",         0},
    294  1.1.1.18  christos     {"FIELDS",       1},
    295       1.1    jruoho     {"FIND",         1},
    296       1.1    jruoho     {"GO",           0},
    297   1.1.1.2    jruoho     {"HANDLERS",     0},
    298       1.1    jruoho     {"HELP",         0},
    299       1.1    jruoho     {"?",            0},
    300       1.1    jruoho     {"HISTORY",      0},
    301       1.1    jruoho     {"!",            1},
    302       1.1    jruoho     {"!!",           0},
    303       1.1    jruoho     {"INFORMATION",  0},
    304       1.1    jruoho     {"INTEGRITY",    0},
    305       1.1    jruoho     {"INTO",         0},
    306       1.1    jruoho     {"LEVEL",        0},
    307       1.1    jruoho     {"LIST",         0},
    308       1.1    jruoho     {"LOCALS",       0},
    309       1.1    jruoho     {"LOCKS",        0},
    310       1.1    jruoho     {"METHODS",      0},
    311       1.1    jruoho     {"NAMESPACE",    0},
    312       1.1    jruoho     {"NOTIFY",       2},
    313   1.1.1.8  christos     {"OBJECTS",      0},
    314   1.1.1.2    jruoho     {"OSI",          0},
    315       1.1    jruoho     {"OWNER",        1},
    316   1.1.1.4  christos     {"PATHS",        0},
    317       1.1    jruoho     {"PREDEFINED",   0},
    318       1.1    jruoho     {"PREFIX",       0},
    319       1.1    jruoho     {"QUIT",         0},
    320       1.1    jruoho     {"REFERENCES",   1},
    321   1.1.1.4  christos     {"RESOURCES",    0},
    322       1.1    jruoho     {"RESULTS",      0},
    323       1.1    jruoho     {"SET",          3},
    324   1.1.1.4  christos     {"STATS",        1},
    325       1.1    jruoho     {"STOP",         0},
    326       1.1    jruoho     {"TABLES",       0},
    327   1.1.1.4  christos     {"TEMPLATE",     1},
    328       1.1    jruoho     {"TRACE",        1},
    329       1.1    jruoho     {"TREE",         0},
    330       1.1    jruoho     {"TYPE",         1},
    331   1.1.1.8  christos #ifdef ACPI_APPLICATION
    332   1.1.1.8  christos     {"ENABLEACPI",   0},
    333   1.1.1.8  christos     {"EVENT",        1},
    334   1.1.1.8  christos     {"GPE",          1},
    335   1.1.1.8  christos     {"GPES",         0},
    336   1.1.1.8  christos     {"SCI",          0},
    337   1.1.1.8  christos     {"SLEEP",        0},
    338   1.1.1.8  christos 
    339   1.1.1.8  christos     {"CLOSE",        0},
    340   1.1.1.8  christos     {"LOAD",         1},
    341   1.1.1.8  christos     {"OPEN",         1},
    342       1.1    jruoho     {"UNLOAD",       1},
    343   1.1.1.8  christos 
    344   1.1.1.8  christos     {"TERMINATE",    0},
    345  1.1.1.12  christos     {"BACKGROUND",   1},
    346   1.1.1.8  christos     {"THREADS",      3},
    347   1.1.1.8  christos 
    348   1.1.1.8  christos     {"TEST",         1},
    349  1.1.1.23  christos     {"INTERRUPT",    1},
    350   1.1.1.8  christos #endif
    351       1.1    jruoho     {NULL,           0}
    352       1.1    jruoho };
    353       1.1    jruoho 
    354   1.1.1.4  christos /*
    355   1.1.1.4  christos  * Help for all debugger commands. First argument is the number of lines
    356   1.1.1.4  christos  * of help to output for the command.
    357  1.1.1.12  christos  *
    358  1.1.1.12  christos  * Note: Some commands are not supported by the kernel-level version of
    359  1.1.1.12  christos  * the debugger.
    360   1.1.1.4  christos  */
    361   1.1.1.4  christos static const ACPI_DB_COMMAND_HELP   AcpiGbl_DbCommandHelp[] =
    362   1.1.1.4  christos {
    363  1.1.1.12  christos     {0, "\nNamespace Access:",                  "\n"},
    364  1.1.1.12  christos     {1, "  Businfo",                            "Display system bus info\n"},
    365  1.1.1.12  christos     {1, "  Disassemble <Method>",               "Disassemble a control method\n"},
    366  1.1.1.12  christos     {1, "  Find <AcpiName> (? is wildcard)",    "Find ACPI name(s) with wildcards\n"},
    367  1.1.1.12  christos     {1, "  Integrity",                          "Validate namespace integrity\n"},
    368  1.1.1.12  christos     {1, "  Methods",                            "Display list of loaded control methods\n"},
    369  1.1.1.18  christos     {1, "  Fields <AddressSpaceId>",            "Display list of loaded field units by space ID\n"},
    370  1.1.1.12  christos     {1, "  Namespace [Object] [Depth]",         "Display loaded namespace tree/subtree\n"},
    371  1.1.1.12  christos     {1, "  Notify <Object> <Value>",            "Send a notification on Object\n"},
    372  1.1.1.12  christos     {1, "  Objects [ObjectType]",               "Display summary of all objects or just given type\n"},
    373  1.1.1.12  christos     {1, "  Owner <OwnerId> [Depth]",            "Display loaded namespace by object owner\n"},
    374  1.1.1.12  christos     {1, "  Paths",                              "Display full pathnames of namespace objects\n"},
    375  1.1.1.12  christos     {1, "  Predefined",                         "Check all predefined names\n"},
    376  1.1.1.12  christos     {1, "  Prefix [<Namepath>]",                "Set or Get current execution prefix\n"},
    377  1.1.1.12  christos     {1, "  References <Addr>",                  "Find all references to object at addr\n"},
    378  1.1.1.12  christos     {1, "  Resources [DeviceName]",             "Display Device resources (no arg = all devices)\n"},
    379  1.1.1.12  christos     {1, "  Set N <NamedObject> <Value>",        "Set value for named integer\n"},
    380  1.1.1.12  christos     {1, "  Template <Object>",                  "Format/dump a Buffer/ResourceTemplate\n"},
    381  1.1.1.12  christos     {1, "  Type <Object>",                      "Display object type\n"},
    382  1.1.1.12  christos 
    383  1.1.1.12  christos     {0, "\nControl Method Execution:",          "\n"},
    384  1.1.1.20  christos     {1, "  All <NameSeg>",                      "Evaluate all objects named NameSeg\n"},
    385  1.1.1.12  christos     {1, "  Evaluate <Namepath> [Arguments]",    "Evaluate object or control method\n"},
    386  1.1.1.12  christos     {1, "  Execute <Namepath> [Arguments]",     "Synonym for Evaluate\n"},
    387  1.1.1.12  christos #ifdef ACPI_APPLICATION
    388  1.1.1.12  christos     {1, "  Background <Namepath> [Arguments]",  "Evaluate object/method in a separate thread\n"},
    389  1.1.1.12  christos     {1, "  Thread <Threads><Loops><NamePath>",  "Spawn threads to execute method(s)\n"},
    390  1.1.1.12  christos #endif
    391  1.1.1.12  christos     {1, "  Debug <Namepath> [Arguments]",       "Single-Step a control method\n"},
    392  1.1.1.12  christos     {7, "  [Arguments] formats:",               "Control method argument formats\n"},
    393  1.1.1.12  christos     {1, "     Hex Integer",                     "Integer\n"},
    394  1.1.1.12  christos     {1, "     \"Ascii String\"",                "String\n"},
    395  1.1.1.12  christos     {1, "     (Hex Byte List)",                 "Buffer\n"},
    396  1.1.1.12  christos     {1, "         (01 42 7A BF)",               "Buffer example (4 bytes)\n"},
    397  1.1.1.12  christos     {1, "     [Package Element List]",          "Package\n"},
    398  1.1.1.12  christos     {1, "         [0x01 0x1234 \"string\"]",    "Package example (3 elements)\n"},
    399  1.1.1.12  christos 
    400  1.1.1.12  christos     {0, "\nMiscellaneous:",                     "\n"},
    401  1.1.1.12  christos     {1, "  Allocations",                        "Display list of current memory allocations\n"},
    402  1.1.1.12  christos     {2, "  Dump <Address>|<Namepath>",          "\n"},
    403  1.1.1.12  christos     {0, "       [Byte|Word|Dword|Qword]",       "Display ACPI objects or memory\n"},
    404  1.1.1.12  christos     {1, "  Handlers",                           "Info about global handlers\n"},
    405  1.1.1.12  christos     {1, "  Help [Command]",                     "This help screen or individual command\n"},
    406  1.1.1.12  christos     {1, "  History",                            "Display command history buffer\n"},
    407  1.1.1.12  christos     {1, "  Level <DebugLevel>] [console]",      "Get/Set debug level for file or console\n"},
    408  1.1.1.12  christos     {1, "  Locks",                              "Current status of internal mutexes\n"},
    409  1.1.1.12  christos     {1, "  Osi [Install|Remove <name>]",        "Display or modify global _OSI list\n"},
    410  1.1.1.12  christos     {1, "  Quit or Exit",                       "Exit this command\n"},
    411  1.1.1.12  christos     {8, "  Stats <SubCommand>",                 "Display namespace and memory statistics\n"},
    412  1.1.1.12  christos     {1, "     Allocations",                     "Display list of current memory allocations\n"},
    413  1.1.1.12  christos     {1, "     Memory",                          "Dump internal memory lists\n"},
    414  1.1.1.12  christos     {1, "     Misc",                            "Namespace search and mutex stats\n"},
    415  1.1.1.12  christos     {1, "     Objects",                         "Summary of namespace objects\n"},
    416  1.1.1.12  christos     {1, "     Sizes",                           "Sizes for each of the internal objects\n"},
    417  1.1.1.12  christos     {1, "     Stack",                           "Display CPU stack usage\n"},
    418  1.1.1.12  christos     {1, "     Tables",                          "Info about current ACPI table(s)\n"},
    419  1.1.1.12  christos     {1, "  Tables",                             "Display info about loaded ACPI tables\n"},
    420  1.1.1.12  christos #ifdef ACPI_APPLICATION
    421  1.1.1.12  christos     {1, "  Terminate",                          "Delete namespace and all internal objects\n"},
    422  1.1.1.12  christos #endif
    423  1.1.1.12  christos     {1, "  ! <CommandNumber>",                  "Execute command from history buffer\n"},
    424  1.1.1.12  christos     {1, "  !!",                                 "Execute last command again\n"},
    425  1.1.1.12  christos 
    426  1.1.1.12  christos     {0, "\nMethod and Namespace Debugging:",    "\n"},
    427  1.1.1.12  christos     {5, "  Trace <State> [<Namepath>] [Once]",  "Trace control method execution\n"},
    428  1.1.1.12  christos     {1, "     Enable",                          "Enable all messages\n"},
    429  1.1.1.12  christos     {1, "     Disable",                         "Disable tracing\n"},
    430  1.1.1.12  christos     {1, "     Method",                          "Enable method execution messages\n"},
    431  1.1.1.12  christos     {1, "     Opcode",                          "Enable opcode execution messages\n"},
    432  1.1.1.12  christos     {3, "  Test <TestName>",                    "Invoke a debug test\n"},
    433  1.1.1.12  christos     {1, "     Objects",                         "Read/write/compare all namespace data objects\n"},
    434  1.1.1.12  christos     {1, "     Predefined",                      "Validate all ACPI predefined names (_STA, etc.)\n"},
    435  1.1.1.12  christos     {1, "  Execute predefined",                 "Execute all predefined (public) methods\n"},
    436  1.1.1.12  christos 
    437  1.1.1.12  christos     {0, "\nControl Method Single-Step Execution:","\n"},
    438  1.1.1.12  christos     {1, "  Arguments (or Args)",                "Display method arguments\n"},
    439  1.1.1.12  christos     {1, "  Breakpoint <AmlOffset>",             "Set an AML execution breakpoint\n"},
    440  1.1.1.12  christos     {1, "  Call",                               "Run to next control method invocation\n"},
    441  1.1.1.12  christos     {1, "  Go",                                 "Allow method to run to completion\n"},
    442  1.1.1.12  christos     {1, "  Information",                        "Display info about the current method\n"},
    443  1.1.1.12  christos     {1, "  Into",                               "Step into (not over) a method call\n"},
    444  1.1.1.12  christos     {1, "  List [# of Aml Opcodes]",            "Display method ASL statements\n"},
    445  1.1.1.12  christos     {1, "  Locals",                             "Display method local variables\n"},
    446  1.1.1.12  christos     {1, "  Results",                            "Display method result stack\n"},
    447  1.1.1.12  christos     {1, "  Set <A|L> <#> <Value>",              "Set method data (Arguments/Locals)\n"},
    448  1.1.1.12  christos     {1, "  Stop",                               "Terminate control method\n"},
    449  1.1.1.12  christos     {1, "  Tree",                               "Display control method calling tree\n"},
    450  1.1.1.12  christos     {1, "  <Enter>",                            "Single step next AML opcode (over calls)\n"},
    451   1.1.1.4  christos 
    452   1.1.1.8  christos #ifdef ACPI_APPLICATION
    453  1.1.1.12  christos     {0, "\nFile Operations:",                   "\n"},
    454  1.1.1.12  christos     {1, "  Close",                              "Close debug output file\n"},
    455  1.1.1.12  christos     {1, "  Load <Input Filename>",              "Load ACPI table from a file\n"},
    456  1.1.1.12  christos     {1, "  Open <Output Filename>",             "Open a file for debug output\n"},
    457  1.1.1.12  christos     {1, "  Unload <Namepath>",                  "Unload an ACPI table via namespace object\n"},
    458  1.1.1.12  christos 
    459  1.1.1.12  christos     {0, "\nHardware Simulation:",               "\n"},
    460  1.1.1.12  christos     {1, "  EnableAcpi",                         "Enable ACPI (hardware) mode\n"},
    461  1.1.1.12  christos     {1, "  Event <F|G> <Value>",                "Generate AcpiEvent (Fixed/GPE)\n"},
    462  1.1.1.12  christos     {1, "  Gpe <GpeNum> [GpeBlockDevice]",      "Simulate a GPE\n"},
    463  1.1.1.12  christos     {1, "  Gpes",                               "Display info on all GPE devices\n"},
    464  1.1.1.12  christos     {1, "  Sci",                                "Generate an SCI\n"},
    465  1.1.1.12  christos     {1, "  Sleep [SleepState]",                 "Simulate sleep/wake sequence(s) (0-5)\n"},
    466  1.1.1.23  christos     {1, "  Interrupt <GSIV>",                   "Simulate an interrupt\n"},
    467   1.1.1.8  christos #endif
    468   1.1.1.4  christos     {0, NULL, NULL}
    469   1.1.1.4  christos };
    470   1.1.1.4  christos 
    471   1.1.1.4  christos 
    472   1.1.1.4  christos /*******************************************************************************
    473   1.1.1.4  christos  *
    474   1.1.1.4  christos  * FUNCTION:    AcpiDbMatchCommandHelp
    475   1.1.1.4  christos  *
    476   1.1.1.4  christos  * PARAMETERS:  Command             - Command string to match
    477   1.1.1.4  christos  *              Help                - Help table entry to attempt match
    478   1.1.1.4  christos  *
    479   1.1.1.4  christos  * RETURN:      TRUE if command matched, FALSE otherwise
    480   1.1.1.4  christos  *
    481   1.1.1.4  christos  * DESCRIPTION: Attempt to match a command in the help table in order to
    482   1.1.1.4  christos  *              print help information for a single command.
    483   1.1.1.4  christos  *
    484   1.1.1.4  christos  ******************************************************************************/
    485   1.1.1.4  christos 
    486   1.1.1.4  christos static BOOLEAN
    487   1.1.1.4  christos AcpiDbMatchCommandHelp (
    488   1.1.1.9  christos     const char                  *Command,
    489   1.1.1.4  christos     const ACPI_DB_COMMAND_HELP  *Help)
    490   1.1.1.4  christos {
    491   1.1.1.4  christos     char                    *Invocation = Help->Invocation;
    492   1.1.1.4  christos     UINT32                  LineCount;
    493   1.1.1.4  christos 
    494   1.1.1.4  christos 
    495   1.1.1.4  christos     /* Valid commands in the help table begin with a couple of spaces */
    496   1.1.1.4  christos 
    497   1.1.1.4  christos     if (*Invocation != ' ')
    498   1.1.1.4  christos     {
    499   1.1.1.4  christos         return (FALSE);
    500   1.1.1.4  christos     }
    501   1.1.1.4  christos 
    502   1.1.1.4  christos     while (*Invocation == ' ')
    503   1.1.1.4  christos     {
    504   1.1.1.4  christos         Invocation++;
    505   1.1.1.4  christos     }
    506   1.1.1.4  christos 
    507   1.1.1.4  christos     /* Match command name (full command or substring) */
    508   1.1.1.4  christos 
    509   1.1.1.4  christos     while ((*Command) && (*Invocation) && (*Invocation != ' '))
    510   1.1.1.4  christos     {
    511   1.1.1.7  christos         if (tolower ((int) *Command) != tolower ((int) *Invocation))
    512   1.1.1.4  christos         {
    513   1.1.1.4  christos             return (FALSE);
    514   1.1.1.4  christos         }
    515   1.1.1.4  christos 
    516   1.1.1.4  christos         Invocation++;
    517   1.1.1.4  christos         Command++;
    518   1.1.1.4  christos     }
    519   1.1.1.4  christos 
    520   1.1.1.4  christos     /* Print the appropriate number of help lines */
    521   1.1.1.4  christos 
    522   1.1.1.4  christos     LineCount = Help->LineCount;
    523   1.1.1.4  christos     while (LineCount)
    524   1.1.1.4  christos     {
    525   1.1.1.4  christos         AcpiOsPrintf ("%-38s : %s", Help->Invocation, Help->Description);
    526   1.1.1.4  christos         Help++;
    527   1.1.1.4  christos         LineCount--;
    528   1.1.1.4  christos     }
    529   1.1.1.4  christos 
    530   1.1.1.4  christos     return (TRUE);
    531   1.1.1.4  christos }
    532   1.1.1.4  christos 
    533   1.1.1.4  christos 
    534   1.1.1.4  christos /*******************************************************************************
    535   1.1.1.4  christos  *
    536   1.1.1.4  christos  * FUNCTION:    AcpiDbDisplayCommandInfo
    537   1.1.1.4  christos  *
    538   1.1.1.4  christos  * PARAMETERS:  Command             - Command string to match
    539   1.1.1.4  christos  *              DisplayAll          - Display all matching commands, or just
    540   1.1.1.4  christos  *                                    the first one (substring match)
    541   1.1.1.4  christos  *
    542   1.1.1.4  christos  * RETURN:      None
    543   1.1.1.4  christos  *
    544   1.1.1.4  christos  * DESCRIPTION: Display help information for a Debugger command.
    545   1.1.1.4  christos  *
    546   1.1.1.4  christos  ******************************************************************************/
    547   1.1.1.4  christos 
    548   1.1.1.4  christos static void
    549   1.1.1.4  christos AcpiDbDisplayCommandInfo (
    550   1.1.1.9  christos     const char              *Command,
    551   1.1.1.4  christos     BOOLEAN                 DisplayAll)
    552   1.1.1.4  christos {
    553   1.1.1.4  christos     const ACPI_DB_COMMAND_HELP  *Next;
    554   1.1.1.4  christos     BOOLEAN                     Matched;
    555   1.1.1.4  christos 
    556   1.1.1.4  christos 
    557   1.1.1.4  christos     Next = AcpiGbl_DbCommandHelp;
    558   1.1.1.4  christos     while (Next->Invocation)
    559   1.1.1.4  christos     {
    560   1.1.1.4  christos         Matched = AcpiDbMatchCommandHelp (Command, Next);
    561   1.1.1.4  christos         if (!DisplayAll && Matched)
    562   1.1.1.4  christos         {
    563   1.1.1.4  christos             return;
    564   1.1.1.4  christos         }
    565   1.1.1.4  christos 
    566   1.1.1.4  christos         Next++;
    567   1.1.1.4  christos     }
    568   1.1.1.4  christos }
    569   1.1.1.4  christos 
    570       1.1    jruoho 
    571       1.1    jruoho /*******************************************************************************
    572       1.1    jruoho  *
    573       1.1    jruoho  * FUNCTION:    AcpiDbDisplayHelp
    574       1.1    jruoho  *
    575   1.1.1.4  christos  * PARAMETERS:  Command             - Optional command string to display help.
    576   1.1.1.4  christos  *                                    if not specified, all debugger command
    577   1.1.1.4  christos  *                                    help strings are displayed
    578       1.1    jruoho  *
    579       1.1    jruoho  * RETURN:      None
    580       1.1    jruoho  *
    581   1.1.1.4  christos  * DESCRIPTION: Display help for a single debugger command, or all of them.
    582       1.1    jruoho  *
    583       1.1    jruoho  ******************************************************************************/
    584       1.1    jruoho 
    585       1.1    jruoho static void
    586       1.1    jruoho AcpiDbDisplayHelp (
    587   1.1.1.4  christos     char                    *Command)
    588       1.1    jruoho {
    589   1.1.1.4  christos     const ACPI_DB_COMMAND_HELP  *Next = AcpiGbl_DbCommandHelp;
    590       1.1    jruoho 
    591   1.1.1.4  christos 
    592   1.1.1.4  christos     if (!Command)
    593   1.1.1.4  christos     {
    594   1.1.1.4  christos         /* No argument to help, display help for all commands */
    595   1.1.1.4  christos 
    596  1.1.1.12  christos         AcpiOsPrintf ("\nSummary of AML Debugger Commands\n\n");
    597  1.1.1.12  christos 
    598   1.1.1.4  christos         while (Next->Invocation)
    599   1.1.1.4  christos         {
    600   1.1.1.4  christos             AcpiOsPrintf ("%-38s%s", Next->Invocation, Next->Description);
    601   1.1.1.4  christos             Next++;
    602   1.1.1.4  christos         }
    603  1.1.1.12  christos         AcpiOsPrintf ("\n");
    604  1.1.1.12  christos 
    605   1.1.1.4  christos     }
    606   1.1.1.4  christos     else
    607   1.1.1.4  christos     {
    608  1.1.1.20  christos         /* Display help for all commands that match the substring */
    609   1.1.1.4  christos 
    610   1.1.1.4  christos         AcpiDbDisplayCommandInfo (Command, TRUE);
    611   1.1.1.4  christos     }
    612       1.1    jruoho }
    613       1.1    jruoho 
    614       1.1    jruoho 
    615       1.1    jruoho /*******************************************************************************
    616       1.1    jruoho  *
    617       1.1    jruoho  * FUNCTION:    AcpiDbGetNextToken
    618       1.1    jruoho  *
    619       1.1    jruoho  * PARAMETERS:  String          - Command buffer
    620       1.1    jruoho  *              Next            - Return value, end of next token
    621       1.1    jruoho  *
    622       1.1    jruoho  * RETURN:      Pointer to the start of the next token.
    623       1.1    jruoho  *
    624   1.1.1.4  christos  * DESCRIPTION: Command line parsing. Get the next token on the command line
    625       1.1    jruoho  *
    626       1.1    jruoho  ******************************************************************************/
    627       1.1    jruoho 
    628   1.1.1.3    jruoho char *
    629       1.1    jruoho AcpiDbGetNextToken (
    630       1.1    jruoho     char                    *String,
    631   1.1.1.3    jruoho     char                    **Next,
    632   1.1.1.3    jruoho     ACPI_OBJECT_TYPE        *ReturnType)
    633       1.1    jruoho {
    634       1.1    jruoho     char                    *Start;
    635   1.1.1.3    jruoho     UINT32                  Depth;
    636   1.1.1.3    jruoho     ACPI_OBJECT_TYPE        Type = ACPI_TYPE_INTEGER;
    637       1.1    jruoho 
    638       1.1    jruoho 
    639       1.1    jruoho     /* At end of buffer? */
    640       1.1    jruoho 
    641       1.1    jruoho     if (!String || !(*String))
    642       1.1    jruoho     {
    643       1.1    jruoho         return (NULL);
    644       1.1    jruoho     }
    645       1.1    jruoho 
    646  1.1.1.19  christos     /* Remove any spaces at the beginning, ignore blank lines */
    647       1.1    jruoho 
    648  1.1.1.21  christos     while (*String && isspace ((int) *String))
    649       1.1    jruoho     {
    650  1.1.1.19  christos         String++;
    651  1.1.1.19  christos     }
    652       1.1    jruoho 
    653  1.1.1.19  christos     if (!(*String))
    654  1.1.1.19  christos     {
    655  1.1.1.19  christos         return (NULL);
    656       1.1    jruoho     }
    657       1.1    jruoho 
    658   1.1.1.3    jruoho     switch (*String)
    659   1.1.1.2    jruoho     {
    660   1.1.1.3    jruoho     case '"':
    661   1.1.1.3    jruoho 
    662   1.1.1.2    jruoho         /* This is a quoted string, scan until closing quote */
    663       1.1    jruoho 
    664   1.1.1.2    jruoho         String++;
    665   1.1.1.2    jruoho         Start = String;
    666   1.1.1.3    jruoho         Type = ACPI_TYPE_STRING;
    667       1.1    jruoho 
    668   1.1.1.3    jruoho         /* Find end of string */
    669   1.1.1.2    jruoho 
    670   1.1.1.2    jruoho         while (*String && (*String != '"'))
    671   1.1.1.2    jruoho         {
    672   1.1.1.2    jruoho             String++;
    673   1.1.1.2    jruoho         }
    674   1.1.1.3    jruoho         break;
    675   1.1.1.3    jruoho 
    676   1.1.1.3    jruoho     case '(':
    677   1.1.1.3    jruoho 
    678   1.1.1.3    jruoho         /* This is the start of a buffer, scan until closing paren */
    679   1.1.1.3    jruoho 
    680   1.1.1.3    jruoho         String++;
    681   1.1.1.3    jruoho         Start = String;
    682   1.1.1.3    jruoho         Type = ACPI_TYPE_BUFFER;
    683   1.1.1.3    jruoho 
    684   1.1.1.3    jruoho         /* Find end of buffer */
    685   1.1.1.3    jruoho 
    686   1.1.1.3    jruoho         while (*String && (*String != ')'))
    687   1.1.1.3    jruoho         {
    688   1.1.1.3    jruoho             String++;
    689   1.1.1.3    jruoho         }
    690   1.1.1.3    jruoho         break;
    691   1.1.1.3    jruoho 
    692  1.1.1.18  christos     case '{':
    693  1.1.1.18  christos 
    694  1.1.1.18  christos         /* This is the start of a field unit, scan until closing brace */
    695  1.1.1.18  christos 
    696  1.1.1.18  christos         String++;
    697  1.1.1.18  christos         Start = String;
    698  1.1.1.18  christos         Type = ACPI_TYPE_FIELD_UNIT;
    699  1.1.1.18  christos 
    700  1.1.1.18  christos         /* Find end of buffer */
    701  1.1.1.18  christos 
    702  1.1.1.18  christos         while (*String && (*String != '}'))
    703  1.1.1.18  christos         {
    704  1.1.1.18  christos             String++;
    705  1.1.1.18  christos         }
    706  1.1.1.18  christos         break;
    707  1.1.1.18  christos 
    708   1.1.1.3    jruoho     case '[':
    709   1.1.1.3    jruoho 
    710   1.1.1.3    jruoho         /* This is the start of a package, scan until closing bracket */
    711   1.1.1.3    jruoho 
    712   1.1.1.3    jruoho         String++;
    713   1.1.1.3    jruoho         Depth = 1;
    714   1.1.1.3    jruoho         Start = String;
    715   1.1.1.3    jruoho         Type = ACPI_TYPE_PACKAGE;
    716   1.1.1.3    jruoho 
    717   1.1.1.3    jruoho         /* Find end of package (closing bracket) */
    718   1.1.1.3    jruoho 
    719   1.1.1.3    jruoho         while (*String)
    720   1.1.1.3    jruoho         {
    721   1.1.1.3    jruoho             /* Handle String package elements */
    722   1.1.1.3    jruoho 
    723   1.1.1.3    jruoho             if (*String == '"')
    724   1.1.1.3    jruoho             {
    725   1.1.1.3    jruoho                 /* Find end of string */
    726   1.1.1.3    jruoho 
    727   1.1.1.3    jruoho                 String++;
    728   1.1.1.3    jruoho                 while (*String && (*String != '"'))
    729   1.1.1.3    jruoho                 {
    730   1.1.1.3    jruoho                     String++;
    731   1.1.1.3    jruoho                 }
    732   1.1.1.3    jruoho                 if (!(*String))
    733   1.1.1.3    jruoho                 {
    734   1.1.1.3    jruoho                     break;
    735   1.1.1.3    jruoho                 }
    736   1.1.1.3    jruoho             }
    737   1.1.1.3    jruoho             else if (*String == '[')
    738   1.1.1.3    jruoho             {
    739   1.1.1.3    jruoho                 Depth++;         /* A nested package declaration */
    740   1.1.1.3    jruoho             }
    741   1.1.1.3    jruoho             else if (*String == ']')
    742   1.1.1.3    jruoho             {
    743   1.1.1.3    jruoho                 Depth--;
    744   1.1.1.3    jruoho                 if (Depth == 0) /* Found final package closing bracket */
    745   1.1.1.3    jruoho                 {
    746   1.1.1.3    jruoho                     break;
    747   1.1.1.3    jruoho                 }
    748   1.1.1.3    jruoho             }
    749   1.1.1.3    jruoho 
    750   1.1.1.3    jruoho             String++;
    751   1.1.1.3    jruoho         }
    752   1.1.1.3    jruoho         break;
    753   1.1.1.3    jruoho 
    754   1.1.1.3    jruoho     default:
    755   1.1.1.3    jruoho 
    756   1.1.1.2    jruoho         Start = String;
    757   1.1.1.2    jruoho 
    758   1.1.1.2    jruoho         /* Find end of token */
    759   1.1.1.2    jruoho 
    760  1.1.1.21  christos         while (*String && !isspace ((int) *String))
    761   1.1.1.2    jruoho         {
    762   1.1.1.2    jruoho             String++;
    763   1.1.1.2    jruoho         }
    764   1.1.1.3    jruoho         break;
    765       1.1    jruoho     }
    766       1.1    jruoho 
    767       1.1    jruoho     if (!(*String))
    768       1.1    jruoho     {
    769       1.1    jruoho         *Next = NULL;
    770       1.1    jruoho     }
    771       1.1    jruoho     else
    772       1.1    jruoho     {
    773       1.1    jruoho         *String = 0;
    774       1.1    jruoho         *Next = String + 1;
    775       1.1    jruoho     }
    776       1.1    jruoho 
    777   1.1.1.3    jruoho     *ReturnType = Type;
    778       1.1    jruoho     return (Start);
    779       1.1    jruoho }
    780       1.1    jruoho 
    781       1.1    jruoho 
    782       1.1    jruoho /*******************************************************************************
    783       1.1    jruoho  *
    784       1.1    jruoho  * FUNCTION:    AcpiDbGetLine
    785       1.1    jruoho  *
    786       1.1    jruoho  * PARAMETERS:  InputBuffer         - Command line buffer
    787       1.1    jruoho  *
    788       1.1    jruoho  * RETURN:      Count of arguments to the command
    789       1.1    jruoho  *
    790   1.1.1.4  christos  * DESCRIPTION: Get the next command line from the user. Gets entire line
    791       1.1    jruoho  *              up to the next newline
    792       1.1    jruoho  *
    793       1.1    jruoho  ******************************************************************************/
    794       1.1    jruoho 
    795       1.1    jruoho static UINT32
    796       1.1    jruoho AcpiDbGetLine (
    797       1.1    jruoho     char                    *InputBuffer)
    798       1.1    jruoho {
    799       1.1    jruoho     UINT32                  i;
    800       1.1    jruoho     UINT32                  Count;
    801       1.1    jruoho     char                    *Next;
    802       1.1    jruoho     char                    *This;
    803       1.1    jruoho 
    804       1.1    jruoho 
    805   1.1.1.4  christos     if (AcpiUtSafeStrcpy (AcpiGbl_DbParsedBuf, sizeof (AcpiGbl_DbParsedBuf),
    806   1.1.1.4  christos         InputBuffer))
    807   1.1.1.4  christos     {
    808   1.1.1.8  christos         AcpiOsPrintf (
    809   1.1.1.8  christos             "Buffer overflow while parsing input line (max %u characters)\n",
    810  1.1.1.17  christos             (UINT32) sizeof (AcpiGbl_DbParsedBuf));
    811   1.1.1.4  christos         return (0);
    812   1.1.1.4  christos     }
    813       1.1    jruoho 
    814       1.1    jruoho     This = AcpiGbl_DbParsedBuf;
    815       1.1    jruoho     for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
    816       1.1    jruoho     {
    817   1.1.1.3    jruoho         AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next,
    818   1.1.1.3    jruoho             &AcpiGbl_DbArgTypes[i]);
    819       1.1    jruoho         if (!AcpiGbl_DbArgs[i])
    820       1.1    jruoho         {
    821       1.1    jruoho             break;
    822       1.1    jruoho         }
    823       1.1    jruoho 
    824       1.1    jruoho         This = Next;
    825       1.1    jruoho     }
    826       1.1    jruoho 
    827       1.1    jruoho     /* Uppercase the actual command */
    828       1.1    jruoho 
    829   1.1.1.8  christos     AcpiUtStrupr (AcpiGbl_DbArgs[0]);
    830       1.1    jruoho 
    831       1.1    jruoho     Count = i;
    832       1.1    jruoho     if (Count)
    833       1.1    jruoho     {
    834       1.1    jruoho         Count--;  /* Number of args only */
    835       1.1    jruoho     }
    836       1.1    jruoho 
    837       1.1    jruoho     return (Count);
    838       1.1    jruoho }
    839       1.1    jruoho 
    840       1.1    jruoho 
    841       1.1    jruoho /*******************************************************************************
    842       1.1    jruoho  *
    843       1.1    jruoho  * FUNCTION:    AcpiDbMatchCommand
    844       1.1    jruoho  *
    845       1.1    jruoho  * PARAMETERS:  UserCommand             - User command line
    846       1.1    jruoho  *
    847       1.1    jruoho  * RETURN:      Index into command array, -1 if not found
    848       1.1    jruoho  *
    849       1.1    jruoho  * DESCRIPTION: Search command array for a command match
    850       1.1    jruoho  *
    851       1.1    jruoho  ******************************************************************************/
    852       1.1    jruoho 
    853       1.1    jruoho static UINT32
    854       1.1    jruoho AcpiDbMatchCommand (
    855       1.1    jruoho     char                    *UserCommand)
    856       1.1    jruoho {
    857       1.1    jruoho     UINT32                  i;
    858       1.1    jruoho 
    859       1.1    jruoho 
    860       1.1    jruoho     if (!UserCommand || UserCommand[0] == 0)
    861       1.1    jruoho     {
    862       1.1    jruoho         return (CMD_NULL);
    863       1.1    jruoho     }
    864       1.1    jruoho 
    865       1.1    jruoho     for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
    866       1.1    jruoho     {
    867   1.1.1.9  christos         if (strstr (
    868   1.1.1.9  christos             ACPI_CAST_PTR (char, AcpiGbl_DbCommands[i].Name), UserCommand) ==
    869   1.1.1.8  christos             AcpiGbl_DbCommands[i].Name)
    870       1.1    jruoho         {
    871       1.1    jruoho             return (i);
    872       1.1    jruoho         }
    873       1.1    jruoho     }
    874       1.1    jruoho 
    875       1.1    jruoho     /* Command not recognized */
    876       1.1    jruoho 
    877       1.1    jruoho     return (CMD_NOT_FOUND);
    878       1.1    jruoho }
    879       1.1    jruoho 
    880       1.1    jruoho 
    881       1.1    jruoho /*******************************************************************************
    882       1.1    jruoho  *
    883       1.1    jruoho  * FUNCTION:    AcpiDbCommandDispatch
    884       1.1    jruoho  *
    885       1.1    jruoho  * PARAMETERS:  InputBuffer         - Command line buffer
    886       1.1    jruoho  *              WalkState           - Current walk
    887       1.1    jruoho  *              Op                  - Current (executing) parse op
    888       1.1    jruoho  *
    889       1.1    jruoho  * RETURN:      Status
    890       1.1    jruoho  *
    891       1.1    jruoho  * DESCRIPTION: Command dispatcher.
    892       1.1    jruoho  *
    893       1.1    jruoho  ******************************************************************************/
    894       1.1    jruoho 
    895       1.1    jruoho ACPI_STATUS
    896       1.1    jruoho AcpiDbCommandDispatch (
    897       1.1    jruoho     char                    *InputBuffer,
    898       1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    899       1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
    900       1.1    jruoho {
    901       1.1    jruoho     UINT32                  Temp;
    902  1.1.1.18  christos     UINT64                  Temp64;
    903       1.1    jruoho     UINT32                  CommandIndex;
    904       1.1    jruoho     UINT32                  ParamCount;
    905       1.1    jruoho     char                    *CommandLine;
    906       1.1    jruoho     ACPI_STATUS             Status = AE_CTRL_TRUE;
    907       1.1    jruoho 
    908       1.1    jruoho 
    909       1.1    jruoho     /* If AcpiTerminate has been called, terminate this thread */
    910       1.1    jruoho 
    911   1.1.1.8  christos     if (AcpiGbl_DbTerminateLoop)
    912       1.1    jruoho     {
    913       1.1    jruoho         return (AE_CTRL_TERMINATE);
    914       1.1    jruoho     }
    915       1.1    jruoho 
    916   1.1.1.7  christos     /* Find command and add to the history buffer */
    917   1.1.1.4  christos 
    918       1.1    jruoho     ParamCount = AcpiDbGetLine (InputBuffer);
    919       1.1    jruoho     CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]);
    920       1.1    jruoho 
    921   1.1.1.7  christos     /*
    922   1.1.1.7  christos      * We don't want to add the !! command to the history buffer. It
    923   1.1.1.7  christos      * would cause an infinite loop because it would always be the
    924   1.1.1.7  christos      * previous command.
    925   1.1.1.7  christos      */
    926   1.1.1.7  christos     if (CommandIndex != CMD_HISTORY_LAST)
    927   1.1.1.7  christos     {
    928   1.1.1.7  christos         AcpiDbAddToHistory (InputBuffer);
    929   1.1.1.7  christos     }
    930   1.1.1.7  christos 
    931       1.1    jruoho     /* Verify that we have the minimum number of params */
    932       1.1    jruoho 
    933       1.1    jruoho     if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs)
    934       1.1    jruoho     {
    935       1.1    jruoho         AcpiOsPrintf ("%u parameters entered, [%s] requires %u parameters\n",
    936       1.1    jruoho             ParamCount, AcpiGbl_DbCommands[CommandIndex].Name,
    937       1.1    jruoho             AcpiGbl_DbCommands[CommandIndex].MinArgs);
    938       1.1    jruoho 
    939   1.1.1.8  christos         AcpiDbDisplayCommandInfo (
    940   1.1.1.8  christos             AcpiGbl_DbCommands[CommandIndex].Name, FALSE);
    941       1.1    jruoho         return (AE_CTRL_TRUE);
    942       1.1    jruoho     }
    943       1.1    jruoho 
    944       1.1    jruoho     /* Decode and dispatch the command */
    945       1.1    jruoho 
    946       1.1    jruoho     switch (CommandIndex)
    947       1.1    jruoho     {
    948       1.1    jruoho     case CMD_NULL:
    949   1.1.1.4  christos 
    950       1.1    jruoho         if (Op)
    951       1.1    jruoho         {
    952       1.1    jruoho             return (AE_OK);
    953       1.1    jruoho         }
    954       1.1    jruoho         break;
    955       1.1    jruoho 
    956  1.1.1.20  christos     case CMD_ALL:
    957  1.1.1.20  christos 
    958  1.1.1.20  christos         AcpiOsPrintf ("Executing all objects with NameSeg: %s\n", AcpiGbl_DbArgs[1]);
    959  1.1.1.20  christos         AcpiDbExecute (AcpiGbl_DbArgs[1],
    960  1.1.1.20  christos             &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP | EX_ALL);
    961  1.1.1.20  christos         break;
    962  1.1.1.20  christos 
    963       1.1    jruoho     case CMD_ALLOCATIONS:
    964       1.1    jruoho 
    965       1.1    jruoho #ifdef ACPI_DBG_TRACK_ALLOCATIONS
    966       1.1    jruoho         AcpiUtDumpAllocations ((UINT32) -1, NULL);
    967       1.1    jruoho #endif
    968       1.1    jruoho         break;
    969       1.1    jruoho 
    970       1.1    jruoho     case CMD_ARGS:
    971       1.1    jruoho     case CMD_ARGUMENTS:
    972   1.1.1.4  christos 
    973       1.1    jruoho         AcpiDbDisplayArguments ();
    974       1.1    jruoho         break;
    975       1.1    jruoho 
    976       1.1    jruoho     case CMD_BREAKPOINT:
    977   1.1.1.4  christos 
    978       1.1    jruoho         AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
    979       1.1    jruoho         break;
    980       1.1    jruoho 
    981       1.1    jruoho     case CMD_BUSINFO:
    982   1.1.1.4  christos 
    983       1.1    jruoho         AcpiDbGetBusInfo ();
    984       1.1    jruoho         break;
    985       1.1    jruoho 
    986       1.1    jruoho     case CMD_CALL:
    987   1.1.1.4  christos 
    988       1.1    jruoho         AcpiDbSetMethodCallBreakpoint (Op);
    989       1.1    jruoho         Status = AE_OK;
    990       1.1    jruoho         break;
    991       1.1    jruoho 
    992       1.1    jruoho     case CMD_DEBUG:
    993   1.1.1.4  christos 
    994   1.1.1.3    jruoho         AcpiDbExecute (AcpiGbl_DbArgs[1],
    995   1.1.1.3    jruoho             &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_SINGLE_STEP);
    996       1.1    jruoho         break;
    997       1.1    jruoho 
    998       1.1    jruoho     case CMD_DISASSEMBLE:
    999   1.1.1.4  christos     case CMD_DISASM:
   1000   1.1.1.4  christos 
   1001  1.1.1.14  christos #ifdef ACPI_DISASSEMBLER
   1002       1.1    jruoho         (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
   1003  1.1.1.14  christos #else
   1004  1.1.1.14  christos         AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
   1005  1.1.1.14  christos #endif
   1006       1.1    jruoho         break;
   1007       1.1    jruoho 
   1008       1.1    jruoho     case CMD_DUMP:
   1009   1.1.1.4  christos 
   1010       1.1    jruoho         AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
   1011       1.1    jruoho         break;
   1012       1.1    jruoho 
   1013   1.1.1.4  christos     case CMD_EVALUATE:
   1014       1.1    jruoho     case CMD_EXECUTE:
   1015   1.1.1.4  christos 
   1016       1.1    jruoho         AcpiDbExecute (AcpiGbl_DbArgs[1],
   1017   1.1.1.3    jruoho             &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP);
   1018       1.1    jruoho         break;
   1019       1.1    jruoho 
   1020       1.1    jruoho     case CMD_FIND:
   1021   1.1.1.4  christos 
   1022       1.1    jruoho         Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
   1023       1.1    jruoho         break;
   1024       1.1    jruoho 
   1025  1.1.1.18  christos     case CMD_FIELDS:
   1026  1.1.1.18  christos 
   1027  1.1.1.18  christos         Status = AcpiUtStrtoul64 (AcpiGbl_DbArgs[1], &Temp64);
   1028  1.1.1.18  christos 
   1029  1.1.1.18  christos         if (ACPI_FAILURE (Status) || Temp64 >= ACPI_NUM_PREDEFINED_REGIONS)
   1030  1.1.1.18  christos         {
   1031  1.1.1.18  christos             AcpiOsPrintf (
   1032  1.1.1.18  christos                 "Invalid address space ID: must be between 0 and %u inclusive\n",
   1033  1.1.1.18  christos                 ACPI_NUM_PREDEFINED_REGIONS - 1);
   1034  1.1.1.18  christos             return (AE_OK);
   1035  1.1.1.18  christos         }
   1036  1.1.1.18  christos 
   1037  1.1.1.18  christos         Status = AcpiDbDisplayFields ((UINT32) Temp64);
   1038  1.1.1.18  christos         break;
   1039  1.1.1.18  christos 
   1040       1.1    jruoho     case CMD_GO:
   1041   1.1.1.4  christos 
   1042       1.1    jruoho         AcpiGbl_CmSingleStep = FALSE;
   1043       1.1    jruoho         return (AE_OK);
   1044       1.1    jruoho 
   1045   1.1.1.2    jruoho     case CMD_HANDLERS:
   1046   1.1.1.4  christos 
   1047   1.1.1.2    jruoho         AcpiDbDisplayHandlers ();
   1048   1.1.1.2    jruoho         break;
   1049   1.1.1.2    jruoho 
   1050       1.1    jruoho     case CMD_HELP:
   1051       1.1    jruoho     case CMD_HELP2:
   1052   1.1.1.4  christos 
   1053   1.1.1.4  christos         AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
   1054       1.1    jruoho         break;
   1055       1.1    jruoho 
   1056       1.1    jruoho     case CMD_HISTORY:
   1057   1.1.1.4  christos 
   1058       1.1    jruoho         AcpiDbDisplayHistory ();
   1059       1.1    jruoho         break;
   1060       1.1    jruoho 
   1061   1.1.1.4  christos     case CMD_HISTORY_EXE: /* ! command */
   1062   1.1.1.4  christos 
   1063       1.1    jruoho         CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
   1064       1.1    jruoho         if (!CommandLine)
   1065       1.1    jruoho         {
   1066       1.1    jruoho             return (AE_CTRL_TRUE);
   1067       1.1    jruoho         }
   1068       1.1    jruoho 
   1069       1.1    jruoho         Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
   1070       1.1    jruoho         return (Status);
   1071       1.1    jruoho 
   1072   1.1.1.4  christos     case CMD_HISTORY_LAST: /* !! command */
   1073   1.1.1.4  christos 
   1074       1.1    jruoho         CommandLine = AcpiDbGetFromHistory (NULL);
   1075       1.1    jruoho         if (!CommandLine)
   1076       1.1    jruoho         {
   1077       1.1    jruoho             return (AE_CTRL_TRUE);
   1078       1.1    jruoho         }
   1079       1.1    jruoho 
   1080       1.1    jruoho         Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
   1081       1.1    jruoho         return (Status);
   1082       1.1    jruoho 
   1083       1.1    jruoho     case CMD_INFORMATION:
   1084   1.1.1.4  christos 
   1085       1.1    jruoho         AcpiDbDisplayMethodInfo (Op);
   1086       1.1    jruoho         break;
   1087       1.1    jruoho 
   1088       1.1    jruoho     case CMD_INTEGRITY:
   1089   1.1.1.4  christos 
   1090       1.1    jruoho         AcpiDbCheckIntegrity ();
   1091       1.1    jruoho         break;
   1092       1.1    jruoho 
   1093       1.1    jruoho     case CMD_INTO:
   1094   1.1.1.4  christos 
   1095       1.1    jruoho         if (Op)
   1096       1.1    jruoho         {
   1097       1.1    jruoho             AcpiGbl_CmSingleStep = TRUE;
   1098       1.1    jruoho             return (AE_OK);
   1099       1.1    jruoho         }
   1100       1.1    jruoho         break;
   1101       1.1    jruoho 
   1102       1.1    jruoho     case CMD_LEVEL:
   1103   1.1.1.4  christos 
   1104       1.1    jruoho         if (ParamCount == 0)
   1105       1.1    jruoho         {
   1106   1.1.1.8  christos             AcpiOsPrintf (
   1107  1.1.1.17  christos                 "Current debug level for file output is:    %8.8X\n",
   1108       1.1    jruoho                 AcpiGbl_DbDebugLevel);
   1109   1.1.1.8  christos             AcpiOsPrintf (
   1110  1.1.1.17  christos                 "Current debug level for console output is: %8.8X\n",
   1111       1.1    jruoho                 AcpiGbl_DbConsoleDebugLevel);
   1112       1.1    jruoho         }
   1113       1.1    jruoho         else if (ParamCount == 2)
   1114       1.1    jruoho         {
   1115       1.1    jruoho             Temp = AcpiGbl_DbConsoleDebugLevel;
   1116   1.1.1.8  christos             AcpiGbl_DbConsoleDebugLevel =
   1117   1.1.1.8  christos                 strtoul (AcpiGbl_DbArgs[1], NULL, 16);
   1118       1.1    jruoho             AcpiOsPrintf (
   1119  1.1.1.17  christos                 "Debug Level for console output was %8.8X, now %8.8X\n",
   1120       1.1    jruoho                 Temp, AcpiGbl_DbConsoleDebugLevel);
   1121       1.1    jruoho         }
   1122       1.1    jruoho         else
   1123       1.1    jruoho         {
   1124       1.1    jruoho             Temp = AcpiGbl_DbDebugLevel;
   1125   1.1.1.7  christos             AcpiGbl_DbDebugLevel = strtoul (AcpiGbl_DbArgs[1], NULL, 16);
   1126       1.1    jruoho             AcpiOsPrintf (
   1127  1.1.1.17  christos                 "Debug Level for file output was %8.8X, now %8.8X\n",
   1128       1.1    jruoho                 Temp, AcpiGbl_DbDebugLevel);
   1129       1.1    jruoho         }
   1130       1.1    jruoho         break;
   1131       1.1    jruoho 
   1132       1.1    jruoho     case CMD_LIST:
   1133   1.1.1.4  christos 
   1134  1.1.1.14  christos #ifdef ACPI_DISASSEMBLER
   1135  1.1.1.15  christos         AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
   1136  1.1.1.14  christos #else
   1137  1.1.1.14  christos         AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
   1138  1.1.1.14  christos #endif
   1139       1.1    jruoho         break;
   1140       1.1    jruoho 
   1141       1.1    jruoho     case CMD_LOCKS:
   1142   1.1.1.4  christos 
   1143       1.1    jruoho         AcpiDbDisplayLocks ();
   1144       1.1    jruoho         break;
   1145       1.1    jruoho 
   1146       1.1    jruoho     case CMD_LOCALS:
   1147   1.1.1.4  christos 
   1148       1.1    jruoho         AcpiDbDisplayLocals ();
   1149       1.1    jruoho         break;
   1150       1.1    jruoho 
   1151       1.1    jruoho     case CMD_METHODS:
   1152   1.1.1.4  christos 
   1153       1.1    jruoho         Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
   1154       1.1    jruoho         break;
   1155       1.1    jruoho 
   1156       1.1    jruoho     case CMD_NAMESPACE:
   1157   1.1.1.4  christos 
   1158       1.1    jruoho         AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
   1159       1.1    jruoho         break;
   1160       1.1    jruoho 
   1161       1.1    jruoho     case CMD_NOTIFY:
   1162   1.1.1.4  christos 
   1163   1.1.1.7  christos         Temp = strtoul (AcpiGbl_DbArgs[2], NULL, 0);
   1164       1.1    jruoho         AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
   1165       1.1    jruoho         break;
   1166       1.1    jruoho 
   1167   1.1.1.4  christos     case CMD_OBJECTS:
   1168   1.1.1.4  christos 
   1169       1.1    jruoho         AcpiUtStrupr (AcpiGbl_DbArgs[1]);
   1170       1.1    jruoho         Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
   1171       1.1    jruoho         break;
   1172       1.1    jruoho 
   1173   1.1.1.2    jruoho     case CMD_OSI:
   1174   1.1.1.4  christos 
   1175   1.1.1.2    jruoho         AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
   1176   1.1.1.2    jruoho         break;
   1177   1.1.1.2    jruoho 
   1178       1.1    jruoho     case CMD_OWNER:
   1179   1.1.1.4  christos 
   1180       1.1    jruoho         AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
   1181       1.1    jruoho         break;
   1182       1.1    jruoho 
   1183   1.1.1.4  christos     case CMD_PATHS:
   1184   1.1.1.4  christos 
   1185   1.1.1.4  christos         AcpiDbDumpNamespacePaths ();
   1186   1.1.1.4  christos         break;
   1187   1.1.1.4  christos 
   1188       1.1    jruoho     case CMD_PREFIX:
   1189   1.1.1.4  christos 
   1190       1.1    jruoho         AcpiDbSetScope (AcpiGbl_DbArgs[1]);
   1191       1.1    jruoho         break;
   1192       1.1    jruoho 
   1193       1.1    jruoho     case CMD_REFERENCES:
   1194   1.1.1.4  christos 
   1195       1.1    jruoho         AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
   1196       1.1    jruoho         break;
   1197       1.1    jruoho 
   1198       1.1    jruoho     case CMD_RESOURCES:
   1199   1.1.1.4  christos 
   1200       1.1    jruoho         AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
   1201       1.1    jruoho         break;
   1202       1.1    jruoho 
   1203       1.1    jruoho     case CMD_RESULTS:
   1204   1.1.1.4  christos 
   1205       1.1    jruoho         AcpiDbDisplayResults ();
   1206       1.1    jruoho         break;
   1207       1.1    jruoho 
   1208       1.1    jruoho     case CMD_SET:
   1209   1.1.1.4  christos 
   1210       1.1    jruoho         AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
   1211       1.1    jruoho             AcpiGbl_DbArgs[3]);
   1212       1.1    jruoho         break;
   1213       1.1    jruoho 
   1214       1.1    jruoho     case CMD_STATS:
   1215   1.1.1.4  christos 
   1216       1.1    jruoho         Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
   1217       1.1    jruoho         break;
   1218       1.1    jruoho 
   1219       1.1    jruoho     case CMD_STOP:
   1220   1.1.1.4  christos 
   1221       1.1    jruoho         return (AE_NOT_IMPLEMENTED);
   1222       1.1    jruoho 
   1223       1.1    jruoho     case CMD_TABLES:
   1224   1.1.1.4  christos 
   1225       1.1    jruoho         AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
   1226       1.1    jruoho         break;
   1227       1.1    jruoho 
   1228   1.1.1.4  christos     case CMD_TEMPLATE:
   1229   1.1.1.4  christos 
   1230   1.1.1.4  christos         AcpiDbDisplayTemplate (AcpiGbl_DbArgs[1]);
   1231   1.1.1.4  christos         break;
   1232   1.1.1.4  christos 
   1233   1.1.1.8  christos     case CMD_TRACE:
   1234   1.1.1.8  christos 
   1235   1.1.1.8  christos         AcpiDbTrace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]);
   1236   1.1.1.8  christos         break;
   1237   1.1.1.8  christos 
   1238   1.1.1.8  christos     case CMD_TREE:
   1239   1.1.1.8  christos 
   1240   1.1.1.8  christos         AcpiDbDisplayCallingTree ();
   1241   1.1.1.8  christos         break;
   1242   1.1.1.8  christos 
   1243   1.1.1.8  christos     case CMD_TYPE:
   1244   1.1.1.8  christos 
   1245   1.1.1.8  christos         AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
   1246   1.1.1.8  christos         break;
   1247   1.1.1.8  christos 
   1248   1.1.1.8  christos #ifdef ACPI_APPLICATION
   1249   1.1.1.8  christos 
   1250   1.1.1.8  christos     /* Hardware simulation commands. */
   1251   1.1.1.8  christos 
   1252   1.1.1.8  christos     case CMD_ENABLEACPI:
   1253   1.1.1.8  christos #if (!ACPI_REDUCED_HARDWARE)
   1254   1.1.1.8  christos 
   1255   1.1.1.8  christos         Status = AcpiEnable();
   1256   1.1.1.8  christos         if (ACPI_FAILURE(Status))
   1257   1.1.1.8  christos         {
   1258   1.1.1.8  christos             AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
   1259   1.1.1.8  christos             return (Status);
   1260   1.1.1.8  christos         }
   1261   1.1.1.8  christos #endif /* !ACPI_REDUCED_HARDWARE */
   1262   1.1.1.8  christos         break;
   1263   1.1.1.8  christos 
   1264   1.1.1.8  christos     case CMD_EVENT:
   1265   1.1.1.8  christos 
   1266   1.1.1.8  christos         AcpiOsPrintf ("Event command not implemented\n");
   1267   1.1.1.8  christos         break;
   1268   1.1.1.8  christos 
   1269  1.1.1.23  christos 	case CMD_INTERRUPT:
   1270  1.1.1.23  christos 
   1271  1.1.1.23  christos 		AcpiDbGenerateInterrupt (AcpiGbl_DbArgs[1]);
   1272  1.1.1.23  christos 		break;
   1273  1.1.1.23  christos 
   1274   1.1.1.8  christos     case CMD_GPE:
   1275   1.1.1.8  christos 
   1276   1.1.1.8  christos         AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
   1277   1.1.1.8  christos         break;
   1278   1.1.1.8  christos 
   1279   1.1.1.8  christos     case CMD_GPES:
   1280   1.1.1.8  christos 
   1281   1.1.1.8  christos         AcpiDbDisplayGpes ();
   1282   1.1.1.8  christos         break;
   1283   1.1.1.8  christos 
   1284   1.1.1.8  christos     case CMD_SCI:
   1285   1.1.1.8  christos 
   1286   1.1.1.8  christos         AcpiDbGenerateSci ();
   1287   1.1.1.8  christos         break;
   1288   1.1.1.8  christos 
   1289   1.1.1.8  christos     case CMD_SLEEP:
   1290   1.1.1.8  christos 
   1291   1.1.1.8  christos         Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
   1292   1.1.1.8  christos         break;
   1293   1.1.1.8  christos 
   1294   1.1.1.8  christos     /* File I/O commands. */
   1295   1.1.1.8  christos 
   1296   1.1.1.8  christos     case CMD_CLOSE:
   1297   1.1.1.8  christos 
   1298   1.1.1.8  christos         AcpiDbCloseDebugFile ();
   1299   1.1.1.8  christos         break;
   1300   1.1.1.8  christos 
   1301   1.1.1.8  christos     case CMD_LOAD:
   1302   1.1.1.8  christos         {
   1303   1.1.1.8  christos             ACPI_NEW_TABLE_DESC     *ListHead = NULL;
   1304   1.1.1.8  christos 
   1305   1.1.1.8  christos             Status = AcGetAllTablesFromFile (AcpiGbl_DbArgs[1],
   1306   1.1.1.8  christos                 ACPI_GET_ALL_TABLES, &ListHead);
   1307   1.1.1.8  christos             if (ACPI_SUCCESS (Status))
   1308   1.1.1.8  christos             {
   1309   1.1.1.8  christos                 AcpiDbLoadTables (ListHead);
   1310   1.1.1.8  christos             }
   1311   1.1.1.8  christos         }
   1312   1.1.1.8  christos         break;
   1313   1.1.1.8  christos 
   1314   1.1.1.8  christos     case CMD_OPEN:
   1315   1.1.1.8  christos 
   1316   1.1.1.8  christos         AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
   1317   1.1.1.8  christos         break;
   1318   1.1.1.8  christos 
   1319   1.1.1.8  christos     /* User space commands. */
   1320   1.1.1.8  christos 
   1321       1.1    jruoho     case CMD_TERMINATE:
   1322   1.1.1.4  christos 
   1323       1.1    jruoho         AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
   1324       1.1    jruoho         AcpiUtSubsystemShutdown ();
   1325       1.1    jruoho 
   1326       1.1    jruoho         /*
   1327       1.1    jruoho          * TBD: [Restructure] Need some way to re-initialize without
   1328       1.1    jruoho          * re-creating the semaphores!
   1329       1.1    jruoho          */
   1330       1.1    jruoho 
   1331   1.1.1.8  christos         AcpiGbl_DbTerminateLoop = TRUE;
   1332       1.1    jruoho         /*  AcpiInitialize (NULL);  */
   1333       1.1    jruoho         break;
   1334       1.1    jruoho 
   1335  1.1.1.12  christos     case CMD_BACKGROUND:
   1336  1.1.1.12  christos 
   1337  1.1.1.12  christos         AcpiDbCreateExecutionThread (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2],
   1338  1.1.1.12  christos             &AcpiGbl_DbArgTypes[2]);
   1339  1.1.1.12  christos         break;
   1340  1.1.1.12  christos 
   1341       1.1    jruoho     case CMD_THREADS:
   1342   1.1.1.4  christos 
   1343       1.1    jruoho         AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
   1344       1.1    jruoho             AcpiGbl_DbArgs[3]);
   1345       1.1    jruoho         break;
   1346       1.1    jruoho 
   1347   1.1.1.8  christos     /* Debug test commands. */
   1348       1.1    jruoho 
   1349   1.1.1.8  christos     case CMD_PREDEFINED:
   1350   1.1.1.4  christos 
   1351   1.1.1.8  christos         AcpiDbCheckPredefinedNames ();
   1352       1.1    jruoho         break;
   1353       1.1    jruoho 
   1354   1.1.1.8  christos     case CMD_TEST:
   1355   1.1.1.4  christos 
   1356   1.1.1.8  christos         AcpiDbExecuteTest (AcpiGbl_DbArgs[1]);
   1357       1.1    jruoho         break;
   1358       1.1    jruoho 
   1359       1.1    jruoho     case CMD_UNLOAD:
   1360   1.1.1.4  christos 
   1361   1.1.1.4  christos         AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1]);
   1362       1.1    jruoho         break;
   1363   1.1.1.8  christos #endif
   1364       1.1    jruoho 
   1365       1.1    jruoho     case CMD_EXIT:
   1366       1.1    jruoho     case CMD_QUIT:
   1367   1.1.1.4  christos 
   1368       1.1    jruoho         if (Op)
   1369       1.1    jruoho         {
   1370       1.1    jruoho             AcpiOsPrintf ("Method execution terminated\n");
   1371       1.1    jruoho             return (AE_CTRL_TERMINATE);
   1372       1.1    jruoho         }
   1373       1.1    jruoho 
   1374       1.1    jruoho         if (!AcpiGbl_DbOutputToFile)
   1375       1.1    jruoho         {
   1376       1.1    jruoho             AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
   1377       1.1    jruoho         }
   1378       1.1    jruoho 
   1379   1.1.1.8  christos #ifdef ACPI_APPLICATION
   1380       1.1    jruoho         AcpiDbCloseDebugFile ();
   1381   1.1.1.8  christos #endif
   1382   1.1.1.8  christos         AcpiGbl_DbTerminateLoop = TRUE;
   1383       1.1    jruoho         return (AE_CTRL_TERMINATE);
   1384       1.1    jruoho 
   1385       1.1    jruoho     case CMD_NOT_FOUND:
   1386       1.1    jruoho     default:
   1387   1.1.1.4  christos 
   1388   1.1.1.4  christos         AcpiOsPrintf ("%s: unknown command\n", AcpiGbl_DbArgs[0]);
   1389       1.1    jruoho         return (AE_CTRL_TRUE);
   1390       1.1    jruoho     }
   1391       1.1    jruoho 
   1392       1.1    jruoho     if (ACPI_SUCCESS (Status))
   1393       1.1    jruoho     {
   1394       1.1    jruoho         Status = AE_CTRL_TRUE;
   1395       1.1    jruoho     }
   1396       1.1    jruoho 
   1397       1.1    jruoho     return (Status);
   1398       1.1    jruoho }
   1399       1.1    jruoho 
   1400       1.1    jruoho 
   1401       1.1    jruoho /*******************************************************************************
   1402       1.1    jruoho  *
   1403       1.1    jruoho  * FUNCTION:    AcpiDbExecuteThread
   1404       1.1    jruoho  *
   1405       1.1    jruoho  * PARAMETERS:  Context         - Not used
   1406       1.1    jruoho  *
   1407       1.1    jruoho  * RETURN:      None
   1408       1.1    jruoho  *
   1409   1.1.1.4  christos  * DESCRIPTION: Debugger execute thread. Waits for a command line, then
   1410       1.1    jruoho  *              simply dispatches it.
   1411       1.1    jruoho  *
   1412       1.1    jruoho  ******************************************************************************/
   1413       1.1    jruoho 
   1414       1.1    jruoho void ACPI_SYSTEM_XFACE
   1415       1.1    jruoho AcpiDbExecuteThread (
   1416       1.1    jruoho     void                    *Context)
   1417       1.1    jruoho {
   1418       1.1    jruoho 
   1419  1.1.1.11  christos     (void) AcpiDbUserCommands ();
   1420   1.1.1.8  christos     AcpiGbl_DbThreadsTerminated = TRUE;
   1421       1.1    jruoho }
   1422       1.1    jruoho 
   1423       1.1    jruoho 
   1424       1.1    jruoho /*******************************************************************************
   1425       1.1    jruoho  *
   1426       1.1    jruoho  * FUNCTION:    AcpiDbUserCommands
   1427       1.1    jruoho  *
   1428  1.1.1.11  christos  * PARAMETERS:  None
   1429       1.1    jruoho  *
   1430       1.1    jruoho  * RETURN:      None
   1431       1.1    jruoho  *
   1432   1.1.1.4  christos  * DESCRIPTION: Command line execution for the AML debugger. Commands are
   1433       1.1    jruoho  *              matched and dispatched here.
   1434       1.1    jruoho  *
   1435       1.1    jruoho  ******************************************************************************/
   1436       1.1    jruoho 
   1437       1.1    jruoho ACPI_STATUS
   1438       1.1    jruoho AcpiDbUserCommands (
   1439  1.1.1.11  christos     void)
   1440       1.1    jruoho {
   1441       1.1    jruoho     ACPI_STATUS             Status = AE_OK;
   1442       1.1    jruoho 
   1443       1.1    jruoho 
   1444   1.1.1.4  christos     AcpiOsPrintf ("\n");
   1445   1.1.1.4  christos 
   1446       1.1    jruoho     /* TBD: [Restructure] Need a separate command line buffer for step mode */
   1447       1.1    jruoho 
   1448   1.1.1.8  christos     while (!AcpiGbl_DbTerminateLoop)
   1449       1.1    jruoho     {
   1450  1.1.1.11  christos         /* Wait the readiness of the command */
   1451       1.1    jruoho 
   1452  1.1.1.11  christos         Status = AcpiOsWaitCommandReady ();
   1453  1.1.1.11  christos         if (ACPI_FAILURE (Status))
   1454       1.1    jruoho         {
   1455  1.1.1.11  christos             break;
   1456       1.1    jruoho         }
   1457       1.1    jruoho 
   1458  1.1.1.11  christos         /* Just call to the command line interpreter */
   1459       1.1    jruoho 
   1460  1.1.1.11  christos         AcpiGbl_MethodExecuting = FALSE;
   1461  1.1.1.11  christos         AcpiGbl_StepToNextCall = FALSE;
   1462       1.1    jruoho 
   1463  1.1.1.11  christos         (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
   1464       1.1    jruoho 
   1465  1.1.1.11  christos         /* Notify the completion of the command */
   1466       1.1    jruoho 
   1467  1.1.1.11  christos         Status = AcpiOsNotifyCommandComplete ();
   1468  1.1.1.11  christos         if (ACPI_FAILURE (Status))
   1469  1.1.1.11  christos         {
   1470  1.1.1.11  christos             break;
   1471       1.1    jruoho         }
   1472       1.1    jruoho     }
   1473       1.1    jruoho 
   1474  1.1.1.11  christos     if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
   1475  1.1.1.11  christos     {
   1476  1.1.1.11  christos         ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));
   1477  1.1.1.11  christos     }
   1478       1.1    jruoho     return (Status);
   1479       1.1    jruoho }
   1480