13446Smrj /*******************************************************************************
23446Smrj *
33446Smrj * Module Name: dbinput - user front-end to the AML debugger
43446Smrj *
53446Smrj ******************************************************************************/
63446Smrj
73446Smrj /******************************************************************************
83446Smrj *
93446Smrj * 1. Copyright Notice
103446Smrj *
119980SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj * All rights reserved.
133446Smrj *
143446Smrj * 2. License
153446Smrj *
163446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj * rights. You may have additional license terms from the party that provided
183446Smrj * you this software, covering your right to use that party's intellectual
193446Smrj * property rights.
203446Smrj *
213446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj * copy of the source code appearing in this file ("Covered Code") an
233446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj * make derivatives, distribute, use and display any portion of the Covered
263446Smrj * Code in any form, with the right to sublicense such rights; and
273446Smrj *
283446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj * license (with the right to sublicense), under only those claims of Intel
303446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj * solely to the minimum extent necessary to exercise the above copyright
333446Smrj * license, and in no event shall the patent license extend to any additions
343446Smrj * to or modifications of the Original Intel Code. No other license or right
353446Smrj * is granted directly or by implication, estoppel or otherwise;
363446Smrj *
373446Smrj * The above copyright and patent license is granted only if the following
383446Smrj * conditions are met:
393446Smrj *
403446Smrj * 3. Conditions
413446Smrj *
423446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj * Redistribution of source code of any substantial portion of the Covered
443446Smrj * Code or modification with rights to further distribute source must include
453446Smrj * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj * and the following Disclaimer and Export Compliance provision. In addition,
473446Smrj * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj * contain a file documenting the changes Licensee made to create that Covered
493446Smrj * Code and the date of any change. Licensee must include in that file the
503446Smrj * documentation of any changes made by any predecessor Licensee. Licensee
513446Smrj * must include a prominent statement that the modification is derived,
523446Smrj * directly or indirectly, from Original Intel Code.
533446Smrj *
543446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj * Redistribution of source code of any substantial portion of the Covered
563446Smrj * Code or modification without rights to further distribute source must
573446Smrj * include the following Disclaimer and Export Compliance provision in the
583446Smrj * documentation and/or other materials provided with distribution. In
593446Smrj * addition, Licensee may not authorize further sublicense of source of any
603446Smrj * portion of the Covered Code, and must include terms to the effect that the
613446Smrj * license from Licensee to its licensee is limited to the intellectual
623446Smrj * property embodied in the software Licensee provides to its licensee, and
633446Smrj * not to intellectual property embodied in modifications its licensee may
643446Smrj * make.
653446Smrj *
663446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj * substantial portion of the Covered Code or modification must reproduce the
683446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj * provision in the documentation and/or other materials provided with the
703446Smrj * distribution.
713446Smrj *
723446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj * Intel Code.
743446Smrj *
753446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj * other dealings in products derived from or relating to the Covered Code
783446Smrj * without prior written authorization from Intel.
793446Smrj *
803446Smrj * 4. Disclaimer and Export Compliance
813446Smrj *
823446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
853446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
863446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj * PARTICULAR PURPOSE.
893446Smrj *
903446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
963446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj * LIMITED REMEDY.
983446Smrj *
993446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj * software or system incorporating such software without first obtaining any
1013446Smrj * required license or other approval from the U. S. Department of Commerce or
1023446Smrj * any other agency or department of the United States Government. In the
1033446Smrj * event Licensee exports any such software from the United States or
1043446Smrj * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj * ensure that the distribution and export/re-export of the software is in
1063446Smrj * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj * software, or service, directly or indirectly, to any country for which the
1103446Smrj * United States government or any agency thereof requires an export license,
1113446Smrj * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj * such license, approval or letter.
1133446Smrj *
1143446Smrj *****************************************************************************/
1153446Smrj
1163446Smrj
1173446Smrj #include "acpi.h"
1189980SDana.Myers@Sun.COM #include "accommon.h"
1193446Smrj #include "acdebug.h"
1203446Smrj
1213446Smrj
1223446Smrj #ifdef ACPI_DEBUGGER
1233446Smrj
1243446Smrj #define _COMPONENT ACPI_CA_DEBUGGER
1253446Smrj ACPI_MODULE_NAME ("dbinput")
1263446Smrj
1273446Smrj /* Local prototypes */
1283446Smrj
1293446Smrj static char *
1303446Smrj AcpiDbGetNextToken (
1313446Smrj char *String,
1323446Smrj char **Next);
1333446Smrj
1343446Smrj static UINT32
1353446Smrj AcpiDbGetLine (
1363446Smrj char *InputBuffer);
1373446Smrj
1383446Smrj static UINT32
1393446Smrj AcpiDbMatchCommand (
1403446Smrj char *UserCommand);
1413446Smrj
1423446Smrj static void
1433446Smrj AcpiDbSingleThread (
1443446Smrj void);
1453446Smrj
1463446Smrj static void
1473446Smrj AcpiDbDisplayHelp (
1483446Smrj char *HelpType);
1493446Smrj
1503446Smrj
1513446Smrj /*
1523446Smrj * Top-level debugger commands.
1533446Smrj *
1543446Smrj * This list of commands must match the string table below it
1553446Smrj */
1563446Smrj enum AcpiExDebuggerCommands
1573446Smrj {
1583446Smrj CMD_NOT_FOUND = 0,
1593446Smrj CMD_NULL,
1603446Smrj CMD_ALLOCATIONS,
1613446Smrj CMD_ARGS,
1623446Smrj CMD_ARGUMENTS,
1639980SDana.Myers@Sun.COM CMD_BATCH,
1643446Smrj CMD_BREAKPOINT,
1653446Smrj CMD_BUSINFO,
1663446Smrj CMD_CALL,
1673446Smrj CMD_CLOSE,
1683446Smrj CMD_DEBUG,
1693446Smrj CMD_DISASSEMBLE,
1703446Smrj CMD_DUMP,
1713446Smrj CMD_ENABLEACPI,
1723446Smrj CMD_EVENT,
1733446Smrj CMD_EXECUTE,
1743446Smrj CMD_EXIT,
1753446Smrj CMD_FIND,
1763446Smrj CMD_GO,
1773446Smrj CMD_GPE,
1783446Smrj CMD_GPES,
1793446Smrj CMD_HELP,
1803446Smrj CMD_HELP2,
1813446Smrj CMD_HISTORY,
1823446Smrj CMD_HISTORY_EXE,
1833446Smrj CMD_HISTORY_LAST,
1843446Smrj CMD_INFORMATION,
1853446Smrj CMD_INTEGRITY,
1863446Smrj CMD_INTO,
1873446Smrj CMD_LEVEL,
1883446Smrj CMD_LIST,
1893446Smrj CMD_LOAD,
1903446Smrj CMD_LOCALS,
1913446Smrj CMD_LOCKS,
1923446Smrj CMD_METHODS,
1933446Smrj CMD_NAMESPACE,
1943446Smrj CMD_NOTIFY,
1953446Smrj CMD_OBJECT,
1963446Smrj CMD_OPEN,
1973446Smrj CMD_OWNER,
1989980SDana.Myers@Sun.COM CMD_PREDEFINED,
1993446Smrj CMD_PREFIX,
2003446Smrj CMD_QUIT,
2013446Smrj CMD_REFERENCES,
2023446Smrj CMD_RESOURCES,
2033446Smrj CMD_RESULTS,
2043446Smrj CMD_SET,
2053446Smrj CMD_SLEEP,
2063446Smrj CMD_STATS,
2073446Smrj CMD_STOP,
2083446Smrj CMD_TABLES,
2093446Smrj CMD_TERMINATE,
2103446Smrj CMD_THREADS,
2113446Smrj CMD_TRACE,
2123446Smrj CMD_TREE,
2133446Smrj CMD_TYPE,
2143446Smrj CMD_UNLOAD
2153446Smrj };
2163446Smrj
2173446Smrj #define CMD_FIRST_VALID 2
2183446Smrj
2199980SDana.Myers@Sun.COM
2209980SDana.Myers@Sun.COM /* Second parameter is the required argument count */
2219980SDana.Myers@Sun.COM
2223446Smrj static const COMMAND_INFO AcpiGbl_DbCommands[] =
2233446Smrj {
2243446Smrj {"<NOT FOUND>", 0},
2253446Smrj {"<NULL>", 0},
2263446Smrj {"ALLOCATIONS", 0},
2273446Smrj {"ARGS", 0},
2283446Smrj {"ARGUMENTS", 0},
2299980SDana.Myers@Sun.COM {"BATCH", 0},
2303446Smrj {"BREAKPOINT", 1},
2313446Smrj {"BUSINFO", 0},
2323446Smrj {"CALL", 0},
2333446Smrj {"CLOSE", 0},
2343446Smrj {"DEBUG", 1},
2353446Smrj {"DISASSEMBLE", 1},
2363446Smrj {"DUMP", 1},
2373446Smrj {"ENABLEACPI", 0},
2383446Smrj {"EVENT", 1},
2393446Smrj {"EXECUTE", 1},
2403446Smrj {"EXIT", 0},
2413446Smrj {"FIND", 1},
2423446Smrj {"GO", 0},
2433446Smrj {"GPE", 2},
2443446Smrj {"GPES", 0},
2453446Smrj {"HELP", 0},
2463446Smrj {"?", 0},
2473446Smrj {"HISTORY", 0},
2483446Smrj {"!", 1},
2493446Smrj {"!!", 0},
2503446Smrj {"INFORMATION", 0},
2513446Smrj {"INTEGRITY", 0},
2523446Smrj {"INTO", 0},
2533446Smrj {"LEVEL", 0},
2543446Smrj {"LIST", 0},
2553446Smrj {"LOAD", 1},
2563446Smrj {"LOCALS", 0},
2573446Smrj {"LOCKS", 0},
2583446Smrj {"METHODS", 0},
2593446Smrj {"NAMESPACE", 0},
2603446Smrj {"NOTIFY", 2},
2613446Smrj {"OBJECT", 1},
2623446Smrj {"OPEN", 1},
2633446Smrj {"OWNER", 1},
2649980SDana.Myers@Sun.COM {"PREDEFINED", 0},
2653446Smrj {"PREFIX", 0},
2663446Smrj {"QUIT", 0},
2673446Smrj {"REFERENCES", 1},
2683446Smrj {"RESOURCES", 1},
2693446Smrj {"RESULTS", 0},
2703446Smrj {"SET", 3},
2713446Smrj {"SLEEP", 1},
2723446Smrj {"STATS", 0},
2733446Smrj {"STOP", 0},
2743446Smrj {"TABLES", 0},
2753446Smrj {"TERMINATE", 0},
2763446Smrj {"THREADS", 3},
2773446Smrj {"TRACE", 1},
2783446Smrj {"TREE", 0},
2793446Smrj {"TYPE", 1},
2803446Smrj {"UNLOAD", 1},
2813446Smrj {NULL, 0}
2823446Smrj };
2833446Smrj
2843446Smrj
2853446Smrj /*******************************************************************************
2863446Smrj *
2873446Smrj * FUNCTION: AcpiDbDisplayHelp
2883446Smrj *
2893446Smrj * PARAMETERS: HelpType - Subcommand (optional)
2903446Smrj *
2913446Smrj * RETURN: None
2923446Smrj *
2933446Smrj * DESCRIPTION: Print a usage message.
2943446Smrj *
2953446Smrj ******************************************************************************/
2963446Smrj
2973446Smrj static void
AcpiDbDisplayHelp(char * HelpType)2983446Smrj AcpiDbDisplayHelp (
2993446Smrj char *HelpType)
3003446Smrj {
3013446Smrj
3023446Smrj AcpiUtStrupr (HelpType);
3033446Smrj
3043446Smrj /* No parameter, just give the overview */
3053446Smrj
3063446Smrj if (!HelpType)
3073446Smrj {
3083446Smrj AcpiOsPrintf ("ACPI CA Debugger Commands\n\n");
3093446Smrj AcpiOsPrintf ("The following classes of commands are available. Help is available for\n");
3103446Smrj AcpiOsPrintf ("each class by entering \"Help <ClassName>\"\n\n");
3113446Smrj AcpiOsPrintf (" [GENERAL] General-Purpose Commands\n");
3123446Smrj AcpiOsPrintf (" [NAMESPACE] Namespace Access Commands\n");
3133446Smrj AcpiOsPrintf (" [METHOD] Control Method Execution Commands\n");
3143446Smrj AcpiOsPrintf (" [STATISTICS] Statistical Information\n");
3153446Smrj AcpiOsPrintf (" [FILE] File I/O Commands\n");
3163446Smrj return;
3173446Smrj }
3183446Smrj
3193446Smrj /*
3203446Smrj * Parameter is the command class
3213446Smrj *
3223446Smrj * The idea here is to keep each class of commands smaller than a screenful
3233446Smrj */
3243446Smrj switch (HelpType[0])
3253446Smrj {
3263446Smrj case 'G':
3273446Smrj AcpiOsPrintf ("\nGeneral-Purpose Commands\n\n");
3283446Smrj AcpiOsPrintf ("Allocations Display list of current memory allocations\n");
3293446Smrj AcpiOsPrintf ("Dump <Address>|<Namepath>\n");
3303446Smrj AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n");
3313446Smrj AcpiOsPrintf ("EnableAcpi Enable ACPI (hardware) mode\n");
3323446Smrj AcpiOsPrintf ("Help This help screen\n");
3333446Smrj AcpiOsPrintf ("History Display command history buffer\n");
3343446Smrj AcpiOsPrintf ("Level [<DebugLevel>] [console] Get/Set debug level for file or console\n");
3353446Smrj AcpiOsPrintf ("Locks Current status of internal mutexes\n");
3363446Smrj AcpiOsPrintf ("Quit or Exit Exit this command\n");
3373446Smrj AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n");
3383446Smrj AcpiOsPrintf (" |Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n");
3393446Smrj AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n");
3403446Smrj AcpiOsPrintf ("Unload <TableSig> [Instance] Unload an ACPI table\n");
3413446Smrj AcpiOsPrintf ("! <CommandNumber> Execute command from history buffer\n");
3423446Smrj AcpiOsPrintf ("!! Execute last command again\n");
3433446Smrj return;
3443446Smrj
3453446Smrj case 'S':
3463446Smrj AcpiOsPrintf ("\nStats Subcommands\n\n");
3473446Smrj AcpiOsPrintf ("Allocations Display list of current memory allocations\n");
3483446Smrj AcpiOsPrintf ("Memory Dump internal memory lists\n");
3493446Smrj AcpiOsPrintf ("Misc Namespace search and mutex stats\n");
3503446Smrj AcpiOsPrintf ("Objects Summary of namespace objects\n");
3513446Smrj AcpiOsPrintf ("Sizes Sizes for each of the internal objects\n");
3523446Smrj AcpiOsPrintf ("Stack Display CPU stack usage\n");
3533446Smrj AcpiOsPrintf ("Tables Info about current ACPI table(s)\n");
3543446Smrj return;
3553446Smrj
3563446Smrj case 'N':
3573446Smrj AcpiOsPrintf ("\nNamespace Access Commands\n\n");
3583446Smrj AcpiOsPrintf ("Businfo Display system bus info\n");
3593446Smrj AcpiOsPrintf ("Disassemble <Method> Disassemble a control method\n");
3603446Smrj AcpiOsPrintf ("Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n");
3613446Smrj AcpiOsPrintf ("Find <AcpiName> (? is wildcard) Find ACPI name(s) with wildcards\n");
3623446Smrj AcpiOsPrintf ("Gpe <GpeNum> <GpeBlock> Simulate a GPE\n");
3633446Smrj AcpiOsPrintf ("Gpes Display info on all GPEs\n");
3643446Smrj AcpiOsPrintf ("Integrity Validate namespace integrity\n");
3653446Smrj AcpiOsPrintf ("Methods Display list of loaded control methods\n");
3663446Smrj AcpiOsPrintf ("Namespace [Object] [Depth] Display loaded namespace tree/subtree\n");
3673446Smrj AcpiOsPrintf ("Notify <Object> <Value> Send a notification on Object\n");
3683446Smrj AcpiOsPrintf ("Objects <ObjectType> Display all objects of the given type\n");
3693446Smrj AcpiOsPrintf ("Owner <OwnerId> [Depth] Display loaded namespace by object owner\n");
3709980SDana.Myers@Sun.COM AcpiOsPrintf ("Predefined Check all predefined names\n");
3713446Smrj AcpiOsPrintf ("Prefix [<NamePath>] Set or Get current execution prefix\n");
3723446Smrj AcpiOsPrintf ("References <Addr> Find all references to object at addr\n");
3733446Smrj AcpiOsPrintf ("Resources <Device> Get and display Device resources\n");
3743446Smrj AcpiOsPrintf ("Set N <NamedObject> <Value> Set value for named integer\n");
3753446Smrj AcpiOsPrintf ("Sleep <SleepState> Simulate sleep/wake sequence\n");
3763446Smrj AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n");
3773446Smrj AcpiOsPrintf ("Type <Object> Display object type\n");
3783446Smrj return;
3793446Smrj
3803446Smrj case 'M':
3813446Smrj AcpiOsPrintf ("\nControl Method Execution Commands\n\n");
3823446Smrj AcpiOsPrintf ("Arguments (or Args) Display method arguments\n");
3833446Smrj AcpiOsPrintf ("Breakpoint <AmlOffset> Set an AML execution breakpoint\n");
3843446Smrj AcpiOsPrintf ("Call Run to next control method invocation\n");
3853446Smrj AcpiOsPrintf ("Debug <Namepath> [Arguments] Single Step a control method\n");
3863446Smrj AcpiOsPrintf ("Execute <Namepath> [Arguments] Execute control method\n");
3873446Smrj AcpiOsPrintf ("Go Allow method to run to completion\n");
3883446Smrj AcpiOsPrintf ("Information Display info about the current method\n");
3893446Smrj AcpiOsPrintf ("Into Step into (not over) a method call\n");
3903446Smrj AcpiOsPrintf ("List [# of Aml Opcodes] Display method ASL statements\n");
3913446Smrj AcpiOsPrintf ("Locals Display method local variables\n");
3923446Smrj AcpiOsPrintf ("Results Display method result stack\n");
3933446Smrj AcpiOsPrintf ("Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n");
3943446Smrj AcpiOsPrintf ("Stop Terminate control method\n");
3953446Smrj AcpiOsPrintf ("Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n");
3963446Smrj AcpiOsPrintf ("Trace <method name> Trace method execution\n");
3973446Smrj AcpiOsPrintf ("Tree Display control method calling tree\n");
3983446Smrj AcpiOsPrintf ("<Enter> Single step next AML opcode (over calls)\n");
3993446Smrj return;
4003446Smrj
4013446Smrj case 'F':
4023446Smrj AcpiOsPrintf ("\nFile I/O Commands\n\n");
4033446Smrj AcpiOsPrintf ("Close Close debug output file\n");
4043446Smrj AcpiOsPrintf ("Open <Output Filename> Open a file for debug output\n");
4053446Smrj AcpiOsPrintf ("Load <Input Filename> Load ACPI table from a file\n");
4063446Smrj return;
4073446Smrj
4083446Smrj default:
4093446Smrj AcpiOsPrintf ("Unrecognized Command Class: %s\n", HelpType);
4103446Smrj return;
4113446Smrj }
4123446Smrj }
4133446Smrj
4143446Smrj
4153446Smrj /*******************************************************************************
4163446Smrj *
4173446Smrj * FUNCTION: AcpiDbGetNextToken
4183446Smrj *
4193446Smrj * PARAMETERS: String - Command buffer
4203446Smrj * Next - Return value, end of next token
4213446Smrj *
4223446Smrj * RETURN: Pointer to the start of the next token.
4233446Smrj *
4243446Smrj * DESCRIPTION: Command line parsing. Get the next token on the command line
4253446Smrj *
4263446Smrj ******************************************************************************/
4273446Smrj
4283446Smrj static char *
AcpiDbGetNextToken(char * String,char ** Next)4293446Smrj AcpiDbGetNextToken (
4303446Smrj char *String,
4313446Smrj char **Next)
4323446Smrj {
4333446Smrj char *Start;
4343446Smrj
4353446Smrj
4363446Smrj /* At end of buffer? */
4373446Smrj
4383446Smrj if (!String || !(*String))
4393446Smrj {
4403446Smrj return (NULL);
4413446Smrj }
4423446Smrj
4433446Smrj /* Get rid of any spaces at the beginning */
4443446Smrj
4453446Smrj if (*String == ' ')
4463446Smrj {
4473446Smrj while (*String && (*String == ' '))
4483446Smrj {
4493446Smrj String++;
4503446Smrj }
4513446Smrj
4523446Smrj if (!(*String))
4533446Smrj {
4543446Smrj return (NULL);
4553446Smrj }
4563446Smrj }
4573446Smrj
4583446Smrj Start = String;
4593446Smrj
4603446Smrj /* Find end of token */
4613446Smrj
4623446Smrj while (*String && (*String != ' '))
4633446Smrj {
4643446Smrj String++;
4653446Smrj }
4663446Smrj
4673446Smrj if (!(*String))
4683446Smrj {
4693446Smrj *Next = NULL;
4703446Smrj }
4713446Smrj else
4723446Smrj {
4733446Smrj *String = 0;
4743446Smrj *Next = String + 1;
4753446Smrj }
4763446Smrj
4773446Smrj return (Start);
4783446Smrj }
4793446Smrj
4803446Smrj
4813446Smrj /*******************************************************************************
4823446Smrj *
4833446Smrj * FUNCTION: AcpiDbGetLine
4843446Smrj *
4853446Smrj * PARAMETERS: InputBuffer - Command line buffer
4863446Smrj *
4873446Smrj * RETURN: Count of arguments to the command
4883446Smrj *
4893446Smrj * DESCRIPTION: Get the next command line from the user. Gets entire line
4903446Smrj * up to the next newline
4913446Smrj *
4923446Smrj ******************************************************************************/
4933446Smrj
4943446Smrj static UINT32
AcpiDbGetLine(char * InputBuffer)4953446Smrj AcpiDbGetLine (
4963446Smrj char *InputBuffer)
4973446Smrj {
4983446Smrj UINT32 i;
4993446Smrj UINT32 Count;
5003446Smrj char *Next;
5013446Smrj char *This;
5023446Smrj
5033446Smrj
5043446Smrj ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer);
5053446Smrj
5063446Smrj This = AcpiGbl_DbParsedBuf;
5073446Smrj for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
5083446Smrj {
5093446Smrj AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next);
5103446Smrj if (!AcpiGbl_DbArgs[i])
5113446Smrj {
5123446Smrj break;
5133446Smrj }
5143446Smrj
5153446Smrj This = Next;
5163446Smrj }
5173446Smrj
5183446Smrj /* Uppercase the actual command */
5193446Smrj
5203446Smrj if (AcpiGbl_DbArgs[0])
5213446Smrj {
5223446Smrj AcpiUtStrupr (AcpiGbl_DbArgs[0]);
5233446Smrj }
5243446Smrj
5253446Smrj Count = i;
5263446Smrj if (Count)
5273446Smrj {
5283446Smrj Count--; /* Number of args only */
5293446Smrj }
5303446Smrj
5313446Smrj return (Count);
5323446Smrj }
5333446Smrj
5343446Smrj
5353446Smrj /*******************************************************************************
5363446Smrj *
5373446Smrj * FUNCTION: AcpiDbMatchCommand
5383446Smrj *
5393446Smrj * PARAMETERS: UserCommand - User command line
5403446Smrj *
5413446Smrj * RETURN: Index into command array, -1 if not found
5423446Smrj *
5433446Smrj * DESCRIPTION: Search command array for a command match
5443446Smrj *
5453446Smrj ******************************************************************************/
5463446Smrj
5473446Smrj static UINT32
AcpiDbMatchCommand(char * UserCommand)5483446Smrj AcpiDbMatchCommand (
5493446Smrj char *UserCommand)
5503446Smrj {
5513446Smrj UINT32 i;
5523446Smrj
5533446Smrj
5543446Smrj if (!UserCommand || UserCommand[0] == 0)
5553446Smrj {
5563446Smrj return (CMD_NULL);
5573446Smrj }
5583446Smrj
5593446Smrj for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
5603446Smrj {
5613446Smrj if (ACPI_STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) ==
5623446Smrj AcpiGbl_DbCommands[i].Name)
5633446Smrj {
5643446Smrj return (i);
5653446Smrj }
5663446Smrj }
5673446Smrj
5683446Smrj /* Command not recognized */
5693446Smrj
5703446Smrj return (CMD_NOT_FOUND);
5713446Smrj }
5723446Smrj
5733446Smrj
5743446Smrj /*******************************************************************************
5753446Smrj *
5763446Smrj * FUNCTION: AcpiDbCommandDispatch
5773446Smrj *
5783446Smrj * PARAMETERS: InputBuffer - Command line buffer
5793446Smrj * WalkState - Current walk
5803446Smrj * Op - Current (executing) parse op
5813446Smrj *
5823446Smrj * RETURN: Status
5833446Smrj *
5843446Smrj * DESCRIPTION: Command dispatcher.
5853446Smrj *
5863446Smrj ******************************************************************************/
5873446Smrj
5883446Smrj ACPI_STATUS
AcpiDbCommandDispatch(char * InputBuffer,ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Op)5893446Smrj AcpiDbCommandDispatch (
5903446Smrj char *InputBuffer,
5913446Smrj ACPI_WALK_STATE *WalkState,
5923446Smrj ACPI_PARSE_OBJECT *Op)
5933446Smrj {
5943446Smrj UINT32 Temp;
5953446Smrj UINT32 CommandIndex;
5963446Smrj UINT32 ParamCount;
5973446Smrj char *CommandLine;
5983446Smrj ACPI_STATUS Status = AE_CTRL_TRUE;
5993446Smrj
6003446Smrj
6013446Smrj /* If AcpiTerminate has been called, terminate this thread */
6023446Smrj
6033446Smrj if (AcpiGbl_DbTerminateThreads)
6043446Smrj {
6053446Smrj return (AE_CTRL_TERMINATE);
6063446Smrj }
6073446Smrj
6083446Smrj ParamCount = AcpiDbGetLine (InputBuffer);
6093446Smrj CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]);
6103446Smrj Temp = 0;
6113446Smrj
6123446Smrj /* Verify that we have the minimum number of params */
6133446Smrj
6143446Smrj if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs)
6153446Smrj {
6163446Smrj AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n",
6173446Smrj ParamCount, AcpiGbl_DbCommands[CommandIndex].Name,
6183446Smrj AcpiGbl_DbCommands[CommandIndex].MinArgs);
6193446Smrj
6203446Smrj return (AE_CTRL_TRUE);
6213446Smrj }
6223446Smrj
6233446Smrj /* Decode and dispatch the command */
6243446Smrj
6253446Smrj switch (CommandIndex)
6263446Smrj {
6273446Smrj case CMD_NULL:
6283446Smrj if (Op)
6293446Smrj {
6303446Smrj return (AE_OK);
6313446Smrj }
6323446Smrj break;
6333446Smrj
6343446Smrj case CMD_ALLOCATIONS:
6353446Smrj
6363446Smrj #ifdef ACPI_DBG_TRACK_ALLOCATIONS
6373446Smrj AcpiUtDumpAllocations ((UINT32) -1, NULL);
6383446Smrj #endif
6393446Smrj break;
6403446Smrj
6413446Smrj case CMD_ARGS:
6423446Smrj case CMD_ARGUMENTS:
6433446Smrj AcpiDbDisplayArguments ();
6443446Smrj break;
6453446Smrj
6469980SDana.Myers@Sun.COM case CMD_BATCH:
647*11225SDana.Myers@Sun.COM AcpiDbBatchExecute (AcpiGbl_DbArgs[1]);
6489980SDana.Myers@Sun.COM break;
6499980SDana.Myers@Sun.COM
6503446Smrj case CMD_BREAKPOINT:
6513446Smrj AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
6523446Smrj break;
6533446Smrj
6543446Smrj case CMD_BUSINFO:
6553446Smrj AcpiDbGetBusInfo ();
6563446Smrj break;
6573446Smrj
6583446Smrj case CMD_CALL:
6593446Smrj AcpiDbSetMethodCallBreakpoint (Op);
6603446Smrj Status = AE_OK;
6613446Smrj break;
6623446Smrj
6633446Smrj case CMD_CLOSE:
6643446Smrj AcpiDbCloseDebugFile ();
6653446Smrj break;
6663446Smrj
6673446Smrj case CMD_DEBUG:
6683446Smrj AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_SINGLE_STEP);
6693446Smrj break;
6703446Smrj
6713446Smrj case CMD_DISASSEMBLE:
6723446Smrj (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
6733446Smrj break;
6743446Smrj
6753446Smrj case CMD_DUMP:
6763446Smrj AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
6773446Smrj break;
6783446Smrj
6793446Smrj case CMD_ENABLEACPI:
6803446Smrj Status = AcpiEnable();
6813446Smrj if (ACPI_FAILURE(Status))
6823446Smrj {
6833446Smrj AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
6843446Smrj return (Status);
6853446Smrj }
6863446Smrj break;
6873446Smrj
6883446Smrj case CMD_EVENT:
6893446Smrj AcpiOsPrintf ("Event command not implemented\n");
6903446Smrj break;
6913446Smrj
6923446Smrj case CMD_EXECUTE:
6933446Smrj AcpiDbExecute (AcpiGbl_DbArgs[1],
6943446Smrj &AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP);
6953446Smrj break;
6963446Smrj
6973446Smrj case CMD_FIND:
6983446Smrj Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
6993446Smrj break;
7003446Smrj
7013446Smrj case CMD_GO:
7023446Smrj AcpiGbl_CmSingleStep = FALSE;
7033446Smrj return (AE_OK);
7043446Smrj
7053446Smrj case CMD_GPE:
7063446Smrj AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
7073446Smrj break;
7083446Smrj
7093446Smrj case CMD_GPES:
7103446Smrj AcpiDbDisplayGpes ();
7113446Smrj break;
7123446Smrj
7133446Smrj case CMD_HELP:
7143446Smrj case CMD_HELP2:
7153446Smrj AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
7163446Smrj break;
7173446Smrj
7183446Smrj case CMD_HISTORY:
7193446Smrj AcpiDbDisplayHistory ();
7203446Smrj break;
7213446Smrj
7223446Smrj case CMD_HISTORY_EXE:
7233446Smrj CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
7243446Smrj if (!CommandLine)
7253446Smrj {
7263446Smrj return (AE_CTRL_TRUE);
7273446Smrj }
7283446Smrj
7293446Smrj Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
7303446Smrj return (Status);
7313446Smrj
7323446Smrj case CMD_HISTORY_LAST:
7333446Smrj CommandLine = AcpiDbGetFromHistory (NULL);
7343446Smrj if (!CommandLine)
7353446Smrj {
7363446Smrj return (AE_CTRL_TRUE);
7373446Smrj }
7383446Smrj
7393446Smrj Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
7403446Smrj return (Status);
7413446Smrj
7423446Smrj case CMD_INFORMATION:
7433446Smrj AcpiDbDisplayMethodInfo (Op);
7443446Smrj break;
7453446Smrj
7463446Smrj case CMD_INTEGRITY:
7473446Smrj AcpiDbCheckIntegrity ();
7483446Smrj break;
7493446Smrj
7503446Smrj case CMD_INTO:
7513446Smrj if (Op)
7523446Smrj {
7533446Smrj AcpiGbl_CmSingleStep = TRUE;
7543446Smrj return (AE_OK);
7553446Smrj }
7563446Smrj break;
7573446Smrj
7583446Smrj case CMD_LEVEL:
7593446Smrj if (ParamCount == 0)
7603446Smrj {
7613446Smrj AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n",
7623446Smrj AcpiGbl_DbDebugLevel);
7633446Smrj AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n",
7643446Smrj AcpiGbl_DbConsoleDebugLevel);
7653446Smrj }
7663446Smrj else if (ParamCount == 2)
7673446Smrj {
7683446Smrj Temp = AcpiGbl_DbConsoleDebugLevel;
7693446Smrj AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1],
7703446Smrj NULL, 16);
7713446Smrj AcpiOsPrintf (
7723446Smrj "Debug Level for console output was %8.8lX, now %8.8lX\n",
7733446Smrj Temp, AcpiGbl_DbConsoleDebugLevel);
7743446Smrj }
7753446Smrj else
7763446Smrj {
7773446Smrj Temp = AcpiGbl_DbDebugLevel;
7783446Smrj AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16);
7793446Smrj AcpiOsPrintf (
7803446Smrj "Debug Level for file output was %8.8lX, now %8.8lX\n",
7813446Smrj Temp, AcpiGbl_DbDebugLevel);
7823446Smrj }
7833446Smrj break;
7843446Smrj
7853446Smrj case CMD_LIST:
7863446Smrj AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
7873446Smrj break;
7883446Smrj
7893446Smrj case CMD_LOAD:
7903446Smrj Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL);
7913446Smrj break;
7923446Smrj
7933446Smrj case CMD_LOCKS:
7943446Smrj AcpiDbDisplayLocks ();
7953446Smrj break;
7963446Smrj
7973446Smrj case CMD_LOCALS:
7983446Smrj AcpiDbDisplayLocals ();
7993446Smrj break;
8003446Smrj
8013446Smrj case CMD_METHODS:
8023446Smrj Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
8033446Smrj break;
8043446Smrj
8053446Smrj case CMD_NAMESPACE:
8063446Smrj AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
8073446Smrj break;
8083446Smrj
8093446Smrj case CMD_NOTIFY:
8103446Smrj Temp = ACPI_STRTOUL (AcpiGbl_DbArgs[2], NULL, 0);
8113446Smrj AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
8123446Smrj break;
8133446Smrj
8143446Smrj case CMD_OBJECT:
8153446Smrj AcpiUtStrupr (AcpiGbl_DbArgs[1]);
8163446Smrj Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
8173446Smrj break;
8183446Smrj
8193446Smrj case CMD_OPEN:
8203446Smrj AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
8213446Smrj break;
8223446Smrj
8233446Smrj case CMD_OWNER:
8243446Smrj AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
8253446Smrj break;
8263446Smrj
8279980SDana.Myers@Sun.COM case CMD_PREDEFINED:
8289980SDana.Myers@Sun.COM AcpiDbCheckPredefinedNames ();
8299980SDana.Myers@Sun.COM break;
8309980SDana.Myers@Sun.COM
8313446Smrj case CMD_PREFIX:
8323446Smrj AcpiDbSetScope (AcpiGbl_DbArgs[1]);
8333446Smrj break;
8343446Smrj
8353446Smrj case CMD_REFERENCES:
8363446Smrj AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
8373446Smrj break;
8383446Smrj
8393446Smrj case CMD_RESOURCES:
8403446Smrj AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
8413446Smrj break;
8423446Smrj
8433446Smrj case CMD_RESULTS:
8443446Smrj AcpiDbDisplayResults ();
8453446Smrj break;
8463446Smrj
8473446Smrj case CMD_SET:
8483446Smrj AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
8493446Smrj AcpiGbl_DbArgs[3]);
8503446Smrj break;
8513446Smrj
8523446Smrj case CMD_SLEEP:
8533446Smrj Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
8543446Smrj break;
8553446Smrj
8563446Smrj case CMD_STATS:
8573446Smrj Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
8583446Smrj break;
8593446Smrj
8603446Smrj case CMD_STOP:
8613446Smrj return (AE_NOT_IMPLEMENTED);
8623446Smrj
8633446Smrj case CMD_TABLES:
8643446Smrj AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
8653446Smrj break;
8663446Smrj
8673446Smrj case CMD_TERMINATE:
8683446Smrj AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
8693446Smrj AcpiUtSubsystemShutdown ();
8703446Smrj
8713446Smrj /*
8723446Smrj * TBD: [Restructure] Need some way to re-initialize without
8733446Smrj * re-creating the semaphores!
8743446Smrj */
8753446Smrj
8763446Smrj /* AcpiInitialize (NULL); */
8773446Smrj break;
8783446Smrj
8793446Smrj case CMD_THREADS:
8803446Smrj AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
8813446Smrj AcpiGbl_DbArgs[3]);
8823446Smrj break;
8833446Smrj
8843446Smrj case CMD_TRACE:
8857851SDana.Myers@Sun.COM (void) AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1);
8863446Smrj break;
8873446Smrj
8883446Smrj case CMD_TREE:
8893446Smrj AcpiDbDisplayCallingTree ();
8903446Smrj break;
8913446Smrj
8923446Smrj case CMD_TYPE:
8933446Smrj AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
8943446Smrj break;
8953446Smrj
8963446Smrj case CMD_UNLOAD:
8973446Smrj AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
8983446Smrj break;
8993446Smrj
9003446Smrj case CMD_EXIT:
9013446Smrj case CMD_QUIT:
9023446Smrj if (Op)
9033446Smrj {
9043446Smrj AcpiOsPrintf ("Method execution terminated\n");
9053446Smrj return (AE_CTRL_TERMINATE);
9063446Smrj }
9073446Smrj
9083446Smrj if (!AcpiGbl_DbOutputToFile)
9093446Smrj {
9103446Smrj AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
9113446Smrj }
9123446Smrj
9133446Smrj AcpiDbCloseDebugFile ();
9143446Smrj AcpiGbl_DbTerminateThreads = TRUE;
9153446Smrj return (AE_CTRL_TERMINATE);
9163446Smrj
9173446Smrj case CMD_NOT_FOUND:
9183446Smrj default:
9193446Smrj AcpiOsPrintf ("Unknown Command\n");
9203446Smrj return (AE_CTRL_TRUE);
9213446Smrj }
9223446Smrj
9233446Smrj if (ACPI_SUCCESS (Status))
9243446Smrj {
9253446Smrj Status = AE_CTRL_TRUE;
9263446Smrj }
9273446Smrj
9283446Smrj /* Add all commands that come here to the history buffer */
9293446Smrj
9303446Smrj AcpiDbAddToHistory (InputBuffer);
9313446Smrj return (Status);
9323446Smrj }
9333446Smrj
9343446Smrj
9353446Smrj /*******************************************************************************
9363446Smrj *
9373446Smrj * FUNCTION: AcpiDbExecuteThread
9383446Smrj *
9393446Smrj * PARAMETERS: Context - Not used
9403446Smrj *
9413446Smrj * RETURN: None
9423446Smrj *
9433446Smrj * DESCRIPTION: Debugger execute thread. Waits for a command line, then
9443446Smrj * simply dispatches it.
9453446Smrj *
9463446Smrj ******************************************************************************/
9473446Smrj
9483446Smrj void ACPI_SYSTEM_XFACE
AcpiDbExecuteThread(void * Context)9493446Smrj AcpiDbExecuteThread (
9503446Smrj void *Context)
9513446Smrj {
9523446Smrj ACPI_STATUS Status = AE_OK;
9533446Smrj ACPI_STATUS MStatus;
9543446Smrj
9553446Smrj
9563446Smrj while (Status != AE_CTRL_TERMINATE)
9573446Smrj {
9583446Smrj AcpiGbl_MethodExecuting = FALSE;
9593446Smrj AcpiGbl_StepToNextCall = FALSE;
9603446Smrj
9613446Smrj MStatus = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
9623446Smrj if (ACPI_FAILURE (MStatus))
9633446Smrj {
9643446Smrj return;
9653446Smrj }
9663446Smrj
9673446Smrj Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
9683446Smrj
9693446Smrj MStatus = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
9703446Smrj if (ACPI_FAILURE (MStatus))
9713446Smrj {
9723446Smrj return;
9733446Smrj }
9743446Smrj }
9753446Smrj }
9763446Smrj
9773446Smrj
9783446Smrj /*******************************************************************************
9793446Smrj *
9803446Smrj * FUNCTION: AcpiDbSingleThread
9813446Smrj *
9823446Smrj * PARAMETERS: None
9833446Smrj *
9843446Smrj * RETURN: None
9853446Smrj *
9863446Smrj * DESCRIPTION: Debugger execute thread. Waits for a command line, then
9873446Smrj * simply dispatches it.
9883446Smrj *
9893446Smrj ******************************************************************************/
9903446Smrj
9913446Smrj static void
AcpiDbSingleThread(void)9923446Smrj AcpiDbSingleThread (
9933446Smrj void)
9943446Smrj {
9953446Smrj
9963446Smrj AcpiGbl_MethodExecuting = FALSE;
9973446Smrj AcpiGbl_StepToNextCall = FALSE;
9983446Smrj
9993446Smrj (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
10003446Smrj }
10013446Smrj
10023446Smrj
10033446Smrj /*******************************************************************************
10043446Smrj *
10053446Smrj * FUNCTION: AcpiDbUserCommands
10063446Smrj *
10073446Smrj * PARAMETERS: Prompt - User prompt (depends on mode)
10083446Smrj * Op - Current executing parse op
10093446Smrj *
10103446Smrj * RETURN: None
10113446Smrj *
10123446Smrj * DESCRIPTION: Command line execution for the AML debugger. Commands are
10133446Smrj * matched and dispatched here.
10143446Smrj *
10153446Smrj ******************************************************************************/
10163446Smrj
10173446Smrj ACPI_STATUS
AcpiDbUserCommands(char Prompt,ACPI_PARSE_OBJECT * Op)10183446Smrj AcpiDbUserCommands (
10193446Smrj char Prompt,
10203446Smrj ACPI_PARSE_OBJECT *Op)
10213446Smrj {
10223446Smrj ACPI_STATUS Status = AE_OK;
10233446Smrj
10243446Smrj
10253446Smrj /* TBD: [Restructure] Need a separate command line buffer for step mode */
10263446Smrj
10273446Smrj while (!AcpiGbl_DbTerminateThreads)
10283446Smrj {
10293446Smrj /* Force output to console until a command is entered */
10303446Smrj
10313446Smrj AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
10323446Smrj
10333446Smrj /* Different prompt if method is executing */
10343446Smrj
10353446Smrj if (!AcpiGbl_MethodExecuting)
10363446Smrj {
10373446Smrj AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
10383446Smrj }
10393446Smrj else
10403446Smrj {
10413446Smrj AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
10423446Smrj }
10433446Smrj
10443446Smrj /* Get the user input line */
10453446Smrj
10463446Smrj (void) AcpiOsGetLine (AcpiGbl_DbLineBuf);
10473446Smrj
10483446Smrj /* Check for single or multithreaded debug */
10493446Smrj
10503446Smrj if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
10513446Smrj {
10523446Smrj /*
10533446Smrj * Signal the debug thread that we have a command to execute,
10543446Smrj * and wait for the command to complete.
10553446Smrj */
10563446Smrj Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_READY);
10573446Smrj if (ACPI_FAILURE (Status))
10583446Smrj {
10593446Smrj return (Status);
10603446Smrj }
10613446Smrj
10623446Smrj Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
10633446Smrj if (ACPI_FAILURE (Status))
10643446Smrj {
10653446Smrj return (Status);
10663446Smrj }
10673446Smrj }
10683446Smrj else
10693446Smrj {
10703446Smrj /* Just call to the command line interpreter */
10713446Smrj
10723446Smrj AcpiDbSingleThread ();
10733446Smrj }
10743446Smrj }
10753446Smrj
10763446Smrj /*
10773446Smrj * Only this thread (the original thread) should actually terminate the
10783446Smrj * subsystem, because all the semaphores are deleted during termination
10793446Smrj */
10803446Smrj Status = AcpiTerminate ();
10813446Smrj return (Status);
10823446Smrj }
10833446Smrj
10843446Smrj #endif /* ACPI_DEBUGGER */
10853446Smrj
1086