xref: /onnv-gate/usr/src/uts/intel/io/acpica/debugger/dbinput.c (revision 3446:5903aece022d)
1*3446Smrj /*******************************************************************************
2*3446Smrj  *
3*3446Smrj  * Module Name: dbinput - user front-end to the AML debugger
4*3446Smrj  *              $Revision: 1.113 $
5*3446Smrj  *
6*3446Smrj  ******************************************************************************/
7*3446Smrj 
8*3446Smrj /******************************************************************************
9*3446Smrj  *
10*3446Smrj  * 1. Copyright Notice
11*3446Smrj  *
12*3446Smrj  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13*3446Smrj  * All rights reserved.
14*3446Smrj  *
15*3446Smrj  * 2. License
16*3446Smrj  *
17*3446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
18*3446Smrj  * rights.  You may have additional license terms from the party that provided
19*3446Smrj  * you this software, covering your right to use that party's intellectual
20*3446Smrj  * property rights.
21*3446Smrj  *
22*3446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23*3446Smrj  * copy of the source code appearing in this file ("Covered Code") an
24*3446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25*3446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
26*3446Smrj  * make derivatives, distribute, use and display any portion of the Covered
27*3446Smrj  * Code in any form, with the right to sublicense such rights; and
28*3446Smrj  *
29*3446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30*3446Smrj  * license (with the right to sublicense), under only those claims of Intel
31*3446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
32*3446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
33*3446Smrj  * solely to the minimum extent necessary to exercise the above copyright
34*3446Smrj  * license, and in no event shall the patent license extend to any additions
35*3446Smrj  * to or modifications of the Original Intel Code.  No other license or right
36*3446Smrj  * is granted directly or by implication, estoppel or otherwise;
37*3446Smrj  *
38*3446Smrj  * The above copyright and patent license is granted only if the following
39*3446Smrj  * conditions are met:
40*3446Smrj  *
41*3446Smrj  * 3. Conditions
42*3446Smrj  *
43*3446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44*3446Smrj  * Redistribution of source code of any substantial portion of the Covered
45*3446Smrj  * Code or modification with rights to further distribute source must include
46*3446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
47*3446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
48*3446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
49*3446Smrj  * contain a file documenting the changes Licensee made to create that Covered
50*3446Smrj  * Code and the date of any change.  Licensee must include in that file the
51*3446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
52*3446Smrj  * must include a prominent statement that the modification is derived,
53*3446Smrj  * directly or indirectly, from Original Intel Code.
54*3446Smrj  *
55*3446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56*3446Smrj  * Redistribution of source code of any substantial portion of the Covered
57*3446Smrj  * Code or modification without rights to further distribute source must
58*3446Smrj  * include the following Disclaimer and Export Compliance provision in the
59*3446Smrj  * documentation and/or other materials provided with distribution.  In
60*3446Smrj  * addition, Licensee may not authorize further sublicense of source of any
61*3446Smrj  * portion of the Covered Code, and must include terms to the effect that the
62*3446Smrj  * license from Licensee to its licensee is limited to the intellectual
63*3446Smrj  * property embodied in the software Licensee provides to its licensee, and
64*3446Smrj  * not to intellectual property embodied in modifications its licensee may
65*3446Smrj  * make.
66*3446Smrj  *
67*3446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68*3446Smrj  * substantial portion of the Covered Code or modification must reproduce the
69*3446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
70*3446Smrj  * provision in the documentation and/or other materials provided with the
71*3446Smrj  * distribution.
72*3446Smrj  *
73*3446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
74*3446Smrj  * Intel Code.
75*3446Smrj  *
76*3446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77*3446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
78*3446Smrj  * other dealings in products derived from or relating to the Covered Code
79*3446Smrj  * without prior written authorization from Intel.
80*3446Smrj  *
81*3446Smrj  * 4. Disclaimer and Export Compliance
82*3446Smrj  *
83*3446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84*3446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85*3446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86*3446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87*3446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88*3446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89*3446Smrj  * PARTICULAR PURPOSE.
90*3446Smrj  *
91*3446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92*3446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93*3446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94*3446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95*3446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96*3446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97*3446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98*3446Smrj  * LIMITED REMEDY.
99*3446Smrj  *
100*3446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101*3446Smrj  * software or system incorporating such software without first obtaining any
102*3446Smrj  * required license or other approval from the U. S. Department of Commerce or
103*3446Smrj  * any other agency or department of the United States Government.  In the
104*3446Smrj  * event Licensee exports any such software from the United States or
105*3446Smrj  * re-exports any such software from a foreign destination, Licensee shall
106*3446Smrj  * ensure that the distribution and export/re-export of the software is in
107*3446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
108*3446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109*3446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
110*3446Smrj  * software, or service, directly or indirectly, to any country for which the
111*3446Smrj  * United States government or any agency thereof requires an export license,
112*3446Smrj  * other governmental approval, or letter of assurance, without first obtaining
113*3446Smrj  * such license, approval or letter.
114*3446Smrj  *
115*3446Smrj  *****************************************************************************/
116*3446Smrj 
117*3446Smrj 
118*3446Smrj #include "acpi.h"
119*3446Smrj #include "acdebug.h"
120*3446Smrj 
121*3446Smrj 
122*3446Smrj #ifdef ACPI_DEBUGGER
123*3446Smrj 
124*3446Smrj #define _COMPONENT          ACPI_CA_DEBUGGER
125*3446Smrj         ACPI_MODULE_NAME    ("dbinput")
126*3446Smrj 
127*3446Smrj /* Local prototypes */
128*3446Smrj 
129*3446Smrj static char *
130*3446Smrj AcpiDbGetNextToken (
131*3446Smrj     char                    *String,
132*3446Smrj     char                    **Next);
133*3446Smrj 
134*3446Smrj static UINT32
135*3446Smrj AcpiDbGetLine (
136*3446Smrj     char                    *InputBuffer);
137*3446Smrj 
138*3446Smrj static UINT32
139*3446Smrj AcpiDbMatchCommand (
140*3446Smrj     char                    *UserCommand);
141*3446Smrj 
142*3446Smrj static void
143*3446Smrj AcpiDbSingleThread (
144*3446Smrj     void);
145*3446Smrj 
146*3446Smrj static void
147*3446Smrj AcpiDbDisplayHelp (
148*3446Smrj     char                    *HelpType);
149*3446Smrj 
150*3446Smrj 
151*3446Smrj /*
152*3446Smrj  * Top-level debugger commands.
153*3446Smrj  *
154*3446Smrj  * This list of commands must match the string table below it
155*3446Smrj  */
156*3446Smrj enum AcpiExDebuggerCommands
157*3446Smrj {
158*3446Smrj     CMD_NOT_FOUND = 0,
159*3446Smrj     CMD_NULL,
160*3446Smrj     CMD_ALLOCATIONS,
161*3446Smrj     CMD_ARGS,
162*3446Smrj     CMD_ARGUMENTS,
163*3446Smrj     CMD_BREAKPOINT,
164*3446Smrj     CMD_BUSINFO,
165*3446Smrj     CMD_CALL,
166*3446Smrj     CMD_CLOSE,
167*3446Smrj     CMD_DEBUG,
168*3446Smrj     CMD_DISASSEMBLE,
169*3446Smrj     CMD_DUMP,
170*3446Smrj     CMD_ENABLEACPI,
171*3446Smrj     CMD_EVENT,
172*3446Smrj     CMD_EXECUTE,
173*3446Smrj     CMD_EXIT,
174*3446Smrj     CMD_FIND,
175*3446Smrj     CMD_GO,
176*3446Smrj     CMD_GPE,
177*3446Smrj     CMD_GPES,
178*3446Smrj     CMD_HELP,
179*3446Smrj     CMD_HELP2,
180*3446Smrj     CMD_HISTORY,
181*3446Smrj     CMD_HISTORY_EXE,
182*3446Smrj     CMD_HISTORY_LAST,
183*3446Smrj     CMD_INFORMATION,
184*3446Smrj     CMD_INTEGRITY,
185*3446Smrj     CMD_INTO,
186*3446Smrj     CMD_LEVEL,
187*3446Smrj     CMD_LIST,
188*3446Smrj     CMD_LOAD,
189*3446Smrj     CMD_LOCALS,
190*3446Smrj     CMD_LOCKS,
191*3446Smrj     CMD_METHODS,
192*3446Smrj     CMD_NAMESPACE,
193*3446Smrj     CMD_NOTIFY,
194*3446Smrj     CMD_OBJECT,
195*3446Smrj     CMD_OPEN,
196*3446Smrj     CMD_OWNER,
197*3446Smrj     CMD_PREFIX,
198*3446Smrj     CMD_QUIT,
199*3446Smrj     CMD_REFERENCES,
200*3446Smrj     CMD_RESOURCES,
201*3446Smrj     CMD_RESULTS,
202*3446Smrj     CMD_SET,
203*3446Smrj     CMD_SLEEP,
204*3446Smrj     CMD_STATS,
205*3446Smrj     CMD_STOP,
206*3446Smrj     CMD_TABLES,
207*3446Smrj     CMD_TERMINATE,
208*3446Smrj     CMD_THREADS,
209*3446Smrj     CMD_TRACE,
210*3446Smrj     CMD_TREE,
211*3446Smrj     CMD_TYPE,
212*3446Smrj     CMD_UNLOAD
213*3446Smrj };
214*3446Smrj 
215*3446Smrj #define CMD_FIRST_VALID     2
216*3446Smrj 
217*3446Smrj static const COMMAND_INFO       AcpiGbl_DbCommands[] =
218*3446Smrj {
219*3446Smrj     {"<NOT FOUND>",  0},
220*3446Smrj     {"<NULL>",       0},
221*3446Smrj     {"ALLOCATIONS",  0},
222*3446Smrj     {"ARGS",         0},
223*3446Smrj     {"ARGUMENTS",    0},
224*3446Smrj     {"BREAKPOINT",   1},
225*3446Smrj     {"BUSINFO",      0},
226*3446Smrj     {"CALL",         0},
227*3446Smrj     {"CLOSE",        0},
228*3446Smrj     {"DEBUG",        1},
229*3446Smrj     {"DISASSEMBLE",  1},
230*3446Smrj     {"DUMP",         1},
231*3446Smrj     {"ENABLEACPI",   0},
232*3446Smrj     {"EVENT",        1},
233*3446Smrj     {"EXECUTE",      1},
234*3446Smrj     {"EXIT",         0},
235*3446Smrj     {"FIND",         1},
236*3446Smrj     {"GO",           0},
237*3446Smrj     {"GPE",          2},
238*3446Smrj     {"GPES",         0},
239*3446Smrj     {"HELP",         0},
240*3446Smrj     {"?",            0},
241*3446Smrj     {"HISTORY",      0},
242*3446Smrj     {"!",            1},
243*3446Smrj     {"!!",           0},
244*3446Smrj     {"INFORMATION",  0},
245*3446Smrj     {"INTEGRITY",    0},
246*3446Smrj     {"INTO",         0},
247*3446Smrj     {"LEVEL",        0},
248*3446Smrj     {"LIST",         0},
249*3446Smrj     {"LOAD",         1},
250*3446Smrj     {"LOCALS",       0},
251*3446Smrj     {"LOCKS",        0},
252*3446Smrj     {"METHODS",      0},
253*3446Smrj     {"NAMESPACE",    0},
254*3446Smrj     {"NOTIFY",       2},
255*3446Smrj     {"OBJECT",       1},
256*3446Smrj     {"OPEN",         1},
257*3446Smrj     {"OWNER",        1},
258*3446Smrj     {"PREFIX",       0},
259*3446Smrj     {"QUIT",         0},
260*3446Smrj     {"REFERENCES",   1},
261*3446Smrj     {"RESOURCES",    1},
262*3446Smrj     {"RESULTS",      0},
263*3446Smrj     {"SET",          3},
264*3446Smrj     {"SLEEP",        1},
265*3446Smrj     {"STATS",        0},
266*3446Smrj     {"STOP",         0},
267*3446Smrj     {"TABLES",       0},
268*3446Smrj     {"TERMINATE",    0},
269*3446Smrj     {"THREADS",      3},
270*3446Smrj     {"TRACE",        1},
271*3446Smrj     {"TREE",         0},
272*3446Smrj     {"TYPE",         1},
273*3446Smrj     {"UNLOAD",       1},
274*3446Smrj     {NULL,           0}
275*3446Smrj };
276*3446Smrj 
277*3446Smrj 
278*3446Smrj /*******************************************************************************
279*3446Smrj  *
280*3446Smrj  * FUNCTION:    AcpiDbDisplayHelp
281*3446Smrj  *
282*3446Smrj  * PARAMETERS:  HelpType        - Subcommand (optional)
283*3446Smrj  *
284*3446Smrj  * RETURN:      None
285*3446Smrj  *
286*3446Smrj  * DESCRIPTION: Print a usage message.
287*3446Smrj  *
288*3446Smrj  ******************************************************************************/
289*3446Smrj 
290*3446Smrj static void
291*3446Smrj AcpiDbDisplayHelp (
292*3446Smrj     char                    *HelpType)
293*3446Smrj {
294*3446Smrj 
295*3446Smrj     AcpiUtStrupr (HelpType);
296*3446Smrj 
297*3446Smrj     /* No parameter, just give the overview */
298*3446Smrj 
299*3446Smrj     if (!HelpType)
300*3446Smrj     {
301*3446Smrj         AcpiOsPrintf ("ACPI CA Debugger Commands\n\n");
302*3446Smrj         AcpiOsPrintf ("The following classes of commands are available.  Help is available for\n");
303*3446Smrj         AcpiOsPrintf ("each class by entering \"Help <ClassName>\"\n\n");
304*3446Smrj         AcpiOsPrintf ("    [GENERAL]       General-Purpose Commands\n");
305*3446Smrj         AcpiOsPrintf ("    [NAMESPACE]     Namespace Access Commands\n");
306*3446Smrj         AcpiOsPrintf ("    [METHOD]        Control Method Execution Commands\n");
307*3446Smrj         AcpiOsPrintf ("    [STATISTICS]    Statistical Information\n");
308*3446Smrj         AcpiOsPrintf ("    [FILE]          File I/O Commands\n");
309*3446Smrj         return;
310*3446Smrj     }
311*3446Smrj 
312*3446Smrj     /*
313*3446Smrj      * Parameter is the command class
314*3446Smrj      *
315*3446Smrj      * The idea here is to keep each class of commands smaller than a screenful
316*3446Smrj      */
317*3446Smrj     switch (HelpType[0])
318*3446Smrj     {
319*3446Smrj     case 'G':
320*3446Smrj         AcpiOsPrintf ("\nGeneral-Purpose Commands\n\n");
321*3446Smrj         AcpiOsPrintf ("Allocations                         Display list of current memory allocations\n");
322*3446Smrj         AcpiOsPrintf ("Dump <Address>|<Namepath>\n");
323*3446Smrj         AcpiOsPrintf ("     [Byte|Word|Dword|Qword]        Display ACPI objects or memory\n");
324*3446Smrj         AcpiOsPrintf ("EnableAcpi                          Enable ACPI (hardware) mode\n");
325*3446Smrj         AcpiOsPrintf ("Help                                This help screen\n");
326*3446Smrj         AcpiOsPrintf ("History                             Display command history buffer\n");
327*3446Smrj         AcpiOsPrintf ("Level [<DebugLevel>] [console]      Get/Set debug level for file or console\n");
328*3446Smrj         AcpiOsPrintf ("Locks                               Current status of internal mutexes\n");
329*3446Smrj         AcpiOsPrintf ("Quit or Exit                        Exit this command\n");
330*3446Smrj         AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n");
331*3446Smrj         AcpiOsPrintf ("      |Objects|Sizes|Stack|Tables]  Display namespace and memory statistics\n");
332*3446Smrj         AcpiOsPrintf ("Tables                              Display info about loaded ACPI tables\n");
333*3446Smrj         AcpiOsPrintf ("Unload <TableSig> [Instance]        Unload an ACPI table\n");
334*3446Smrj         AcpiOsPrintf ("! <CommandNumber>                   Execute command from history buffer\n");
335*3446Smrj         AcpiOsPrintf ("!!                                  Execute last command again\n");
336*3446Smrj         return;
337*3446Smrj 
338*3446Smrj     case 'S':
339*3446Smrj         AcpiOsPrintf ("\nStats Subcommands\n\n");
340*3446Smrj         AcpiOsPrintf ("Allocations                         Display list of current memory allocations\n");
341*3446Smrj         AcpiOsPrintf ("Memory                              Dump internal memory lists\n");
342*3446Smrj         AcpiOsPrintf ("Misc                                Namespace search and mutex stats\n");
343*3446Smrj         AcpiOsPrintf ("Objects                             Summary of namespace objects\n");
344*3446Smrj         AcpiOsPrintf ("Sizes                               Sizes for each of the internal objects\n");
345*3446Smrj         AcpiOsPrintf ("Stack                               Display CPU stack usage\n");
346*3446Smrj         AcpiOsPrintf ("Tables                              Info about current ACPI table(s)\n");
347*3446Smrj         return;
348*3446Smrj 
349*3446Smrj     case 'N':
350*3446Smrj         AcpiOsPrintf ("\nNamespace Access Commands\n\n");
351*3446Smrj         AcpiOsPrintf ("Businfo                             Display system bus info\n");
352*3446Smrj         AcpiOsPrintf ("Disassemble <Method>                Disassemble a control method\n");
353*3446Smrj         AcpiOsPrintf ("Event <F|G> <Value>                 Generate AcpiEvent (Fixed/GPE)\n");
354*3446Smrj         AcpiOsPrintf ("Find <AcpiName>  (? is wildcard)    Find ACPI name(s) with wildcards\n");
355*3446Smrj         AcpiOsPrintf ("Gpe <GpeNum> <GpeBlock>             Simulate a GPE\n");
356*3446Smrj         AcpiOsPrintf ("Gpes                                Display info on all GPEs\n");
357*3446Smrj         AcpiOsPrintf ("Integrity                           Validate namespace integrity\n");
358*3446Smrj         AcpiOsPrintf ("Methods                             Display list of loaded control methods\n");
359*3446Smrj         AcpiOsPrintf ("Namespace [Object] [Depth]          Display loaded namespace tree/subtree\n");
360*3446Smrj         AcpiOsPrintf ("Notify <Object> <Value>             Send a notification on Object\n");
361*3446Smrj         AcpiOsPrintf ("Objects <ObjectType>                Display all objects of the given type\n");
362*3446Smrj         AcpiOsPrintf ("Owner <OwnerId> [Depth]             Display loaded namespace by object owner\n");
363*3446Smrj         AcpiOsPrintf ("Prefix [<NamePath>]                 Set or Get current execution prefix\n");
364*3446Smrj         AcpiOsPrintf ("References <Addr>                   Find all references to object at addr\n");
365*3446Smrj         AcpiOsPrintf ("Resources <Device>                  Get and display Device resources\n");
366*3446Smrj         AcpiOsPrintf ("Set N <NamedObject> <Value>         Set value for named integer\n");
367*3446Smrj         AcpiOsPrintf ("Sleep <SleepState>                  Simulate sleep/wake sequence\n");
368*3446Smrj         AcpiOsPrintf ("Terminate                           Delete namespace and all internal objects\n");
369*3446Smrj         AcpiOsPrintf ("Type <Object>                       Display object type\n");
370*3446Smrj         return;
371*3446Smrj 
372*3446Smrj     case 'M':
373*3446Smrj         AcpiOsPrintf ("\nControl Method Execution Commands\n\n");
374*3446Smrj         AcpiOsPrintf ("Arguments (or Args)                 Display method arguments\n");
375*3446Smrj         AcpiOsPrintf ("Breakpoint <AmlOffset>              Set an AML execution breakpoint\n");
376*3446Smrj         AcpiOsPrintf ("Call                                Run to next control method invocation\n");
377*3446Smrj         AcpiOsPrintf ("Debug <Namepath> [Arguments]        Single Step a control method\n");
378*3446Smrj         AcpiOsPrintf ("Execute <Namepath> [Arguments]      Execute control method\n");
379*3446Smrj         AcpiOsPrintf ("Go                                  Allow method to run to completion\n");
380*3446Smrj         AcpiOsPrintf ("Information                         Display info about the current method\n");
381*3446Smrj         AcpiOsPrintf ("Into                                Step into (not over) a method call\n");
382*3446Smrj         AcpiOsPrintf ("List [# of Aml Opcodes]             Display method ASL statements\n");
383*3446Smrj         AcpiOsPrintf ("Locals                              Display method local variables\n");
384*3446Smrj         AcpiOsPrintf ("Results                             Display method result stack\n");
385*3446Smrj         AcpiOsPrintf ("Set <A|L> <#> <Value>               Set method data (Arguments/Locals)\n");
386*3446Smrj         AcpiOsPrintf ("Stop                                Terminate control method\n");
387*3446Smrj         AcpiOsPrintf ("Thread <Threads><Loops><NamePath>   Spawn threads to execute method(s)\n");
388*3446Smrj         AcpiOsPrintf ("Trace <method name>                 Trace method execution\n");
389*3446Smrj         AcpiOsPrintf ("Tree                                Display control method calling tree\n");
390*3446Smrj         AcpiOsPrintf ("<Enter>                             Single step next AML opcode (over calls)\n");
391*3446Smrj         return;
392*3446Smrj 
393*3446Smrj     case 'F':
394*3446Smrj         AcpiOsPrintf ("\nFile I/O Commands\n\n");
395*3446Smrj         AcpiOsPrintf ("Close                               Close debug output file\n");
396*3446Smrj         AcpiOsPrintf ("Open <Output Filename>              Open a file for debug output\n");
397*3446Smrj         AcpiOsPrintf ("Load <Input Filename>               Load ACPI table from a file\n");
398*3446Smrj         return;
399*3446Smrj 
400*3446Smrj     default:
401*3446Smrj         AcpiOsPrintf ("Unrecognized Command Class: %s\n", HelpType);
402*3446Smrj         return;
403*3446Smrj     }
404*3446Smrj }
405*3446Smrj 
406*3446Smrj 
407*3446Smrj /*******************************************************************************
408*3446Smrj  *
409*3446Smrj  * FUNCTION:    AcpiDbGetNextToken
410*3446Smrj  *
411*3446Smrj  * PARAMETERS:  String          - Command buffer
412*3446Smrj  *              Next            - Return value, end of next token
413*3446Smrj  *
414*3446Smrj  * RETURN:      Pointer to the start of the next token.
415*3446Smrj  *
416*3446Smrj  * DESCRIPTION: Command line parsing.  Get the next token on the command line
417*3446Smrj  *
418*3446Smrj  ******************************************************************************/
419*3446Smrj 
420*3446Smrj static char *
421*3446Smrj AcpiDbGetNextToken (
422*3446Smrj     char                    *String,
423*3446Smrj     char                    **Next)
424*3446Smrj {
425*3446Smrj     char                    *Start;
426*3446Smrj 
427*3446Smrj 
428*3446Smrj     /* At end of buffer? */
429*3446Smrj 
430*3446Smrj     if (!String || !(*String))
431*3446Smrj     {
432*3446Smrj         return (NULL);
433*3446Smrj     }
434*3446Smrj 
435*3446Smrj     /* Get rid of any spaces at the beginning */
436*3446Smrj 
437*3446Smrj     if (*String == ' ')
438*3446Smrj     {
439*3446Smrj         while (*String && (*String == ' '))
440*3446Smrj         {
441*3446Smrj             String++;
442*3446Smrj         }
443*3446Smrj 
444*3446Smrj         if (!(*String))
445*3446Smrj         {
446*3446Smrj             return (NULL);
447*3446Smrj         }
448*3446Smrj     }
449*3446Smrj 
450*3446Smrj     Start = String;
451*3446Smrj 
452*3446Smrj     /* Find end of token */
453*3446Smrj 
454*3446Smrj     while (*String && (*String != ' '))
455*3446Smrj     {
456*3446Smrj         String++;
457*3446Smrj     }
458*3446Smrj 
459*3446Smrj     if (!(*String))
460*3446Smrj     {
461*3446Smrj         *Next = NULL;
462*3446Smrj     }
463*3446Smrj     else
464*3446Smrj     {
465*3446Smrj         *String = 0;
466*3446Smrj         *Next = String + 1;
467*3446Smrj     }
468*3446Smrj 
469*3446Smrj     return (Start);
470*3446Smrj }
471*3446Smrj 
472*3446Smrj 
473*3446Smrj /*******************************************************************************
474*3446Smrj  *
475*3446Smrj  * FUNCTION:    AcpiDbGetLine
476*3446Smrj  *
477*3446Smrj  * PARAMETERS:  InputBuffer         - Command line buffer
478*3446Smrj  *
479*3446Smrj  * RETURN:      Count of arguments to the command
480*3446Smrj  *
481*3446Smrj  * DESCRIPTION: Get the next command line from the user.  Gets entire line
482*3446Smrj  *              up to the next newline
483*3446Smrj  *
484*3446Smrj  ******************************************************************************/
485*3446Smrj 
486*3446Smrj static UINT32
487*3446Smrj AcpiDbGetLine (
488*3446Smrj     char                    *InputBuffer)
489*3446Smrj {
490*3446Smrj     UINT32                  i;
491*3446Smrj     UINT32                  Count;
492*3446Smrj     char                    *Next;
493*3446Smrj     char                    *This;
494*3446Smrj 
495*3446Smrj 
496*3446Smrj     ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer);
497*3446Smrj 
498*3446Smrj     This = AcpiGbl_DbParsedBuf;
499*3446Smrj     for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
500*3446Smrj     {
501*3446Smrj         AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next);
502*3446Smrj         if (!AcpiGbl_DbArgs[i])
503*3446Smrj         {
504*3446Smrj             break;
505*3446Smrj         }
506*3446Smrj 
507*3446Smrj         This = Next;
508*3446Smrj     }
509*3446Smrj 
510*3446Smrj     /* Uppercase the actual command */
511*3446Smrj 
512*3446Smrj     if (AcpiGbl_DbArgs[0])
513*3446Smrj     {
514*3446Smrj         AcpiUtStrupr (AcpiGbl_DbArgs[0]);
515*3446Smrj     }
516*3446Smrj 
517*3446Smrj     Count = i;
518*3446Smrj     if (Count)
519*3446Smrj     {
520*3446Smrj         Count--;  /* Number of args only */
521*3446Smrj     }
522*3446Smrj 
523*3446Smrj     return (Count);
524*3446Smrj }
525*3446Smrj 
526*3446Smrj 
527*3446Smrj /*******************************************************************************
528*3446Smrj  *
529*3446Smrj  * FUNCTION:    AcpiDbMatchCommand
530*3446Smrj  *
531*3446Smrj  * PARAMETERS:  UserCommand             - User command line
532*3446Smrj  *
533*3446Smrj  * RETURN:      Index into command array, -1 if not found
534*3446Smrj  *
535*3446Smrj  * DESCRIPTION: Search command array for a command match
536*3446Smrj  *
537*3446Smrj  ******************************************************************************/
538*3446Smrj 
539*3446Smrj static UINT32
540*3446Smrj AcpiDbMatchCommand (
541*3446Smrj     char                    *UserCommand)
542*3446Smrj {
543*3446Smrj     UINT32                  i;
544*3446Smrj 
545*3446Smrj 
546*3446Smrj     if (!UserCommand || UserCommand[0] == 0)
547*3446Smrj     {
548*3446Smrj         return (CMD_NULL);
549*3446Smrj     }
550*3446Smrj 
551*3446Smrj     for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
552*3446Smrj     {
553*3446Smrj         if (ACPI_STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) ==
554*3446Smrj                          AcpiGbl_DbCommands[i].Name)
555*3446Smrj         {
556*3446Smrj             return (i);
557*3446Smrj         }
558*3446Smrj     }
559*3446Smrj 
560*3446Smrj     /* Command not recognized */
561*3446Smrj 
562*3446Smrj     return (CMD_NOT_FOUND);
563*3446Smrj }
564*3446Smrj 
565*3446Smrj 
566*3446Smrj /*******************************************************************************
567*3446Smrj  *
568*3446Smrj  * FUNCTION:    AcpiDbCommandDispatch
569*3446Smrj  *
570*3446Smrj  * PARAMETERS:  InputBuffer         - Command line buffer
571*3446Smrj  *              WalkState           - Current walk
572*3446Smrj  *              Op                  - Current (executing) parse op
573*3446Smrj  *
574*3446Smrj  * RETURN:      Status
575*3446Smrj  *
576*3446Smrj  * DESCRIPTION: Command dispatcher.
577*3446Smrj  *
578*3446Smrj  ******************************************************************************/
579*3446Smrj 
580*3446Smrj ACPI_STATUS
581*3446Smrj AcpiDbCommandDispatch (
582*3446Smrj     char                    *InputBuffer,
583*3446Smrj     ACPI_WALK_STATE         *WalkState,
584*3446Smrj     ACPI_PARSE_OBJECT       *Op)
585*3446Smrj {
586*3446Smrj     UINT32                  Temp;
587*3446Smrj     UINT32                  CommandIndex;
588*3446Smrj     UINT32                  ParamCount;
589*3446Smrj     char                    *CommandLine;
590*3446Smrj     ACPI_STATUS             Status = AE_CTRL_TRUE;
591*3446Smrj 
592*3446Smrj 
593*3446Smrj     /* If AcpiTerminate has been called, terminate this thread */
594*3446Smrj 
595*3446Smrj     if (AcpiGbl_DbTerminateThreads)
596*3446Smrj     {
597*3446Smrj         return (AE_CTRL_TERMINATE);
598*3446Smrj     }
599*3446Smrj 
600*3446Smrj     ParamCount = AcpiDbGetLine (InputBuffer);
601*3446Smrj     CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]);
602*3446Smrj     Temp = 0;
603*3446Smrj 
604*3446Smrj     /* Verify that we have the minimum number of params */
605*3446Smrj 
606*3446Smrj     if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs)
607*3446Smrj     {
608*3446Smrj         AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n",
609*3446Smrj             ParamCount, AcpiGbl_DbCommands[CommandIndex].Name,
610*3446Smrj             AcpiGbl_DbCommands[CommandIndex].MinArgs);
611*3446Smrj 
612*3446Smrj         return (AE_CTRL_TRUE);
613*3446Smrj     }
614*3446Smrj 
615*3446Smrj     /* Decode and dispatch the command */
616*3446Smrj 
617*3446Smrj     switch (CommandIndex)
618*3446Smrj     {
619*3446Smrj     case CMD_NULL:
620*3446Smrj         if (Op)
621*3446Smrj         {
622*3446Smrj             return (AE_OK);
623*3446Smrj         }
624*3446Smrj         break;
625*3446Smrj 
626*3446Smrj     case CMD_ALLOCATIONS:
627*3446Smrj 
628*3446Smrj #ifdef ACPI_DBG_TRACK_ALLOCATIONS
629*3446Smrj         AcpiUtDumpAllocations ((UINT32) -1, NULL);
630*3446Smrj #endif
631*3446Smrj         break;
632*3446Smrj 
633*3446Smrj     case CMD_ARGS:
634*3446Smrj     case CMD_ARGUMENTS:
635*3446Smrj         AcpiDbDisplayArguments ();
636*3446Smrj         break;
637*3446Smrj 
638*3446Smrj     case CMD_BREAKPOINT:
639*3446Smrj         AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
640*3446Smrj         break;
641*3446Smrj 
642*3446Smrj     case CMD_BUSINFO:
643*3446Smrj         AcpiDbGetBusInfo ();
644*3446Smrj         break;
645*3446Smrj 
646*3446Smrj     case CMD_CALL:
647*3446Smrj         AcpiDbSetMethodCallBreakpoint (Op);
648*3446Smrj         Status = AE_OK;
649*3446Smrj         break;
650*3446Smrj 
651*3446Smrj     case CMD_CLOSE:
652*3446Smrj         AcpiDbCloseDebugFile ();
653*3446Smrj         break;
654*3446Smrj 
655*3446Smrj     case CMD_DEBUG:
656*3446Smrj         AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_SINGLE_STEP);
657*3446Smrj         break;
658*3446Smrj 
659*3446Smrj     case CMD_DISASSEMBLE:
660*3446Smrj         (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
661*3446Smrj         break;
662*3446Smrj 
663*3446Smrj     case CMD_DUMP:
664*3446Smrj         AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
665*3446Smrj         break;
666*3446Smrj 
667*3446Smrj     case CMD_ENABLEACPI:
668*3446Smrj         Status = AcpiEnable();
669*3446Smrj         if (ACPI_FAILURE(Status))
670*3446Smrj         {
671*3446Smrj             AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
672*3446Smrj             return (Status);
673*3446Smrj         }
674*3446Smrj         break;
675*3446Smrj 
676*3446Smrj     case CMD_EVENT:
677*3446Smrj         AcpiOsPrintf ("Event command not implemented\n");
678*3446Smrj         break;
679*3446Smrj 
680*3446Smrj     case CMD_EXECUTE:
681*3446Smrj         AcpiDbExecute (AcpiGbl_DbArgs[1],
682*3446Smrj             &AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP);
683*3446Smrj         break;
684*3446Smrj 
685*3446Smrj     case CMD_FIND:
686*3446Smrj         Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
687*3446Smrj         break;
688*3446Smrj 
689*3446Smrj     case CMD_GO:
690*3446Smrj         AcpiGbl_CmSingleStep = FALSE;
691*3446Smrj         return (AE_OK);
692*3446Smrj 
693*3446Smrj     case CMD_GPE:
694*3446Smrj         AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
695*3446Smrj         break;
696*3446Smrj 
697*3446Smrj     case CMD_GPES:
698*3446Smrj         AcpiDbDisplayGpes ();
699*3446Smrj         break;
700*3446Smrj 
701*3446Smrj     case CMD_HELP:
702*3446Smrj     case CMD_HELP2:
703*3446Smrj         AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
704*3446Smrj         break;
705*3446Smrj 
706*3446Smrj     case CMD_HISTORY:
707*3446Smrj         AcpiDbDisplayHistory ();
708*3446Smrj         break;
709*3446Smrj 
710*3446Smrj     case CMD_HISTORY_EXE:
711*3446Smrj         CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
712*3446Smrj         if (!CommandLine)
713*3446Smrj         {
714*3446Smrj             return (AE_CTRL_TRUE);
715*3446Smrj         }
716*3446Smrj 
717*3446Smrj         Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
718*3446Smrj         return (Status);
719*3446Smrj 
720*3446Smrj     case CMD_HISTORY_LAST:
721*3446Smrj         CommandLine = AcpiDbGetFromHistory (NULL);
722*3446Smrj         if (!CommandLine)
723*3446Smrj         {
724*3446Smrj             return (AE_CTRL_TRUE);
725*3446Smrj         }
726*3446Smrj 
727*3446Smrj         Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
728*3446Smrj         return (Status);
729*3446Smrj 
730*3446Smrj     case CMD_INFORMATION:
731*3446Smrj         AcpiDbDisplayMethodInfo (Op);
732*3446Smrj         break;
733*3446Smrj 
734*3446Smrj     case CMD_INTEGRITY:
735*3446Smrj         AcpiDbCheckIntegrity ();
736*3446Smrj         break;
737*3446Smrj 
738*3446Smrj     case CMD_INTO:
739*3446Smrj         if (Op)
740*3446Smrj         {
741*3446Smrj             AcpiGbl_CmSingleStep = TRUE;
742*3446Smrj             return (AE_OK);
743*3446Smrj         }
744*3446Smrj         break;
745*3446Smrj 
746*3446Smrj     case CMD_LEVEL:
747*3446Smrj         if (ParamCount == 0)
748*3446Smrj         {
749*3446Smrj             AcpiOsPrintf ("Current debug level for file output is:    %8.8lX\n",
750*3446Smrj                 AcpiGbl_DbDebugLevel);
751*3446Smrj             AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n",
752*3446Smrj                 AcpiGbl_DbConsoleDebugLevel);
753*3446Smrj         }
754*3446Smrj         else if (ParamCount == 2)
755*3446Smrj         {
756*3446Smrj             Temp = AcpiGbl_DbConsoleDebugLevel;
757*3446Smrj             AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1],
758*3446Smrj                                             NULL, 16);
759*3446Smrj             AcpiOsPrintf (
760*3446Smrj                 "Debug Level for console output was %8.8lX, now %8.8lX\n",
761*3446Smrj                 Temp, AcpiGbl_DbConsoleDebugLevel);
762*3446Smrj         }
763*3446Smrj         else
764*3446Smrj         {
765*3446Smrj             Temp = AcpiGbl_DbDebugLevel;
766*3446Smrj             AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16);
767*3446Smrj             AcpiOsPrintf (
768*3446Smrj                 "Debug Level for file output was %8.8lX, now %8.8lX\n",
769*3446Smrj                 Temp, AcpiGbl_DbDebugLevel);
770*3446Smrj         }
771*3446Smrj         break;
772*3446Smrj 
773*3446Smrj     case CMD_LIST:
774*3446Smrj         AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
775*3446Smrj         break;
776*3446Smrj 
777*3446Smrj     case CMD_LOAD:
778*3446Smrj         Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL);
779*3446Smrj         break;
780*3446Smrj 
781*3446Smrj     case CMD_LOCKS:
782*3446Smrj         AcpiDbDisplayLocks ();
783*3446Smrj         break;
784*3446Smrj 
785*3446Smrj     case CMD_LOCALS:
786*3446Smrj         AcpiDbDisplayLocals ();
787*3446Smrj         break;
788*3446Smrj 
789*3446Smrj     case CMD_METHODS:
790*3446Smrj         Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
791*3446Smrj         break;
792*3446Smrj 
793*3446Smrj     case CMD_NAMESPACE:
794*3446Smrj         AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
795*3446Smrj         break;
796*3446Smrj 
797*3446Smrj     case CMD_NOTIFY:
798*3446Smrj         Temp = ACPI_STRTOUL (AcpiGbl_DbArgs[2], NULL, 0);
799*3446Smrj         AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
800*3446Smrj         break;
801*3446Smrj 
802*3446Smrj     case CMD_OBJECT:
803*3446Smrj         AcpiUtStrupr (AcpiGbl_DbArgs[1]);
804*3446Smrj         Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
805*3446Smrj         break;
806*3446Smrj 
807*3446Smrj     case CMD_OPEN:
808*3446Smrj         AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
809*3446Smrj         break;
810*3446Smrj 
811*3446Smrj     case CMD_OWNER:
812*3446Smrj         AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
813*3446Smrj         break;
814*3446Smrj 
815*3446Smrj     case CMD_PREFIX:
816*3446Smrj         AcpiDbSetScope (AcpiGbl_DbArgs[1]);
817*3446Smrj         break;
818*3446Smrj 
819*3446Smrj     case CMD_REFERENCES:
820*3446Smrj         AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
821*3446Smrj         break;
822*3446Smrj 
823*3446Smrj     case CMD_RESOURCES:
824*3446Smrj         AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
825*3446Smrj         break;
826*3446Smrj 
827*3446Smrj     case CMD_RESULTS:
828*3446Smrj         AcpiDbDisplayResults ();
829*3446Smrj         break;
830*3446Smrj 
831*3446Smrj     case CMD_SET:
832*3446Smrj         AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
833*3446Smrj             AcpiGbl_DbArgs[3]);
834*3446Smrj         break;
835*3446Smrj 
836*3446Smrj     case CMD_SLEEP:
837*3446Smrj         Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
838*3446Smrj         break;
839*3446Smrj 
840*3446Smrj     case CMD_STATS:
841*3446Smrj         Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
842*3446Smrj         break;
843*3446Smrj 
844*3446Smrj     case CMD_STOP:
845*3446Smrj         return (AE_NOT_IMPLEMENTED);
846*3446Smrj 
847*3446Smrj     case CMD_TABLES:
848*3446Smrj         AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
849*3446Smrj         break;
850*3446Smrj 
851*3446Smrj     case CMD_TERMINATE:
852*3446Smrj         AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
853*3446Smrj         AcpiUtSubsystemShutdown ();
854*3446Smrj 
855*3446Smrj         /*
856*3446Smrj          * TBD: [Restructure] Need some way to re-initialize without
857*3446Smrj          * re-creating the semaphores!
858*3446Smrj          */
859*3446Smrj 
860*3446Smrj         /*  AcpiInitialize (NULL);  */
861*3446Smrj         break;
862*3446Smrj 
863*3446Smrj     case CMD_THREADS:
864*3446Smrj         AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
865*3446Smrj             AcpiGbl_DbArgs[3]);
866*3446Smrj         break;
867*3446Smrj 
868*3446Smrj     case CMD_TRACE:
869*3446Smrj         AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1);
870*3446Smrj         break;
871*3446Smrj 
872*3446Smrj     case CMD_TREE:
873*3446Smrj         AcpiDbDisplayCallingTree ();
874*3446Smrj         break;
875*3446Smrj 
876*3446Smrj     case CMD_TYPE:
877*3446Smrj         AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
878*3446Smrj         break;
879*3446Smrj 
880*3446Smrj     case CMD_UNLOAD:
881*3446Smrj         AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
882*3446Smrj         break;
883*3446Smrj 
884*3446Smrj     case CMD_EXIT:
885*3446Smrj     case CMD_QUIT:
886*3446Smrj         if (Op)
887*3446Smrj         {
888*3446Smrj             AcpiOsPrintf ("Method execution terminated\n");
889*3446Smrj             return (AE_CTRL_TERMINATE);
890*3446Smrj         }
891*3446Smrj 
892*3446Smrj         if (!AcpiGbl_DbOutputToFile)
893*3446Smrj         {
894*3446Smrj             AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
895*3446Smrj         }
896*3446Smrj 
897*3446Smrj         AcpiDbCloseDebugFile ();
898*3446Smrj         AcpiGbl_DbTerminateThreads = TRUE;
899*3446Smrj         return (AE_CTRL_TERMINATE);
900*3446Smrj 
901*3446Smrj     case CMD_NOT_FOUND:
902*3446Smrj     default:
903*3446Smrj         AcpiOsPrintf ("Unknown Command\n");
904*3446Smrj         return (AE_CTRL_TRUE);
905*3446Smrj     }
906*3446Smrj 
907*3446Smrj     if (ACPI_SUCCESS (Status))
908*3446Smrj     {
909*3446Smrj         Status = AE_CTRL_TRUE;
910*3446Smrj     }
911*3446Smrj 
912*3446Smrj     /* Add all commands that come here to the history buffer */
913*3446Smrj 
914*3446Smrj     AcpiDbAddToHistory (InputBuffer);
915*3446Smrj     return (Status);
916*3446Smrj }
917*3446Smrj 
918*3446Smrj 
919*3446Smrj /*******************************************************************************
920*3446Smrj  *
921*3446Smrj  * FUNCTION:    AcpiDbExecuteThread
922*3446Smrj  *
923*3446Smrj  * PARAMETERS:  Context         - Not used
924*3446Smrj  *
925*3446Smrj  * RETURN:      None
926*3446Smrj  *
927*3446Smrj  * DESCRIPTION: Debugger execute thread.  Waits for a command line, then
928*3446Smrj  *              simply dispatches it.
929*3446Smrj  *
930*3446Smrj  ******************************************************************************/
931*3446Smrj 
932*3446Smrj void ACPI_SYSTEM_XFACE
933*3446Smrj AcpiDbExecuteThread (
934*3446Smrj     void                    *Context)
935*3446Smrj {
936*3446Smrj     ACPI_STATUS             Status = AE_OK;
937*3446Smrj     ACPI_STATUS             MStatus;
938*3446Smrj 
939*3446Smrj 
940*3446Smrj     while (Status != AE_CTRL_TERMINATE)
941*3446Smrj     {
942*3446Smrj         AcpiGbl_MethodExecuting = FALSE;
943*3446Smrj         AcpiGbl_StepToNextCall = FALSE;
944*3446Smrj 
945*3446Smrj         MStatus = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
946*3446Smrj         if (ACPI_FAILURE (MStatus))
947*3446Smrj         {
948*3446Smrj             return;
949*3446Smrj         }
950*3446Smrj 
951*3446Smrj         Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
952*3446Smrj 
953*3446Smrj         MStatus = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
954*3446Smrj         if (ACPI_FAILURE (MStatus))
955*3446Smrj         {
956*3446Smrj             return;
957*3446Smrj         }
958*3446Smrj     }
959*3446Smrj }
960*3446Smrj 
961*3446Smrj 
962*3446Smrj /*******************************************************************************
963*3446Smrj  *
964*3446Smrj  * FUNCTION:    AcpiDbSingleThread
965*3446Smrj  *
966*3446Smrj  * PARAMETERS:  None
967*3446Smrj  *
968*3446Smrj  * RETURN:      None
969*3446Smrj  *
970*3446Smrj  * DESCRIPTION: Debugger execute thread.  Waits for a command line, then
971*3446Smrj  *              simply dispatches it.
972*3446Smrj  *
973*3446Smrj  ******************************************************************************/
974*3446Smrj 
975*3446Smrj static void
976*3446Smrj AcpiDbSingleThread (
977*3446Smrj     void)
978*3446Smrj {
979*3446Smrj 
980*3446Smrj     AcpiGbl_MethodExecuting = FALSE;
981*3446Smrj     AcpiGbl_StepToNextCall = FALSE;
982*3446Smrj 
983*3446Smrj     (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
984*3446Smrj }
985*3446Smrj 
986*3446Smrj 
987*3446Smrj /*******************************************************************************
988*3446Smrj  *
989*3446Smrj  * FUNCTION:    AcpiDbUserCommands
990*3446Smrj  *
991*3446Smrj  * PARAMETERS:  Prompt              - User prompt (depends on mode)
992*3446Smrj  *              Op                  - Current executing parse op
993*3446Smrj  *
994*3446Smrj  * RETURN:      None
995*3446Smrj  *
996*3446Smrj  * DESCRIPTION: Command line execution for the AML debugger.  Commands are
997*3446Smrj  *              matched and dispatched here.
998*3446Smrj  *
999*3446Smrj  ******************************************************************************/
1000*3446Smrj 
1001*3446Smrj ACPI_STATUS
1002*3446Smrj AcpiDbUserCommands (
1003*3446Smrj     char                    Prompt,
1004*3446Smrj     ACPI_PARSE_OBJECT       *Op)
1005*3446Smrj {
1006*3446Smrj     ACPI_STATUS             Status = AE_OK;
1007*3446Smrj 
1008*3446Smrj 
1009*3446Smrj     /* TBD: [Restructure] Need a separate command line buffer for step mode */
1010*3446Smrj 
1011*3446Smrj     while (!AcpiGbl_DbTerminateThreads)
1012*3446Smrj     {
1013*3446Smrj         /* Force output to console until a command is entered */
1014*3446Smrj 
1015*3446Smrj         AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1016*3446Smrj 
1017*3446Smrj         /* Different prompt if method is executing */
1018*3446Smrj 
1019*3446Smrj         if (!AcpiGbl_MethodExecuting)
1020*3446Smrj         {
1021*3446Smrj             AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
1022*3446Smrj         }
1023*3446Smrj         else
1024*3446Smrj         {
1025*3446Smrj             AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
1026*3446Smrj         }
1027*3446Smrj 
1028*3446Smrj         /* Get the user input line */
1029*3446Smrj 
1030*3446Smrj         (void) AcpiOsGetLine (AcpiGbl_DbLineBuf);
1031*3446Smrj 
1032*3446Smrj         /* Check for single or multithreaded debug */
1033*3446Smrj 
1034*3446Smrj         if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
1035*3446Smrj         {
1036*3446Smrj             /*
1037*3446Smrj              * Signal the debug thread that we have a command to execute,
1038*3446Smrj              * and wait for the command to complete.
1039*3446Smrj              */
1040*3446Smrj             Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_READY);
1041*3446Smrj             if (ACPI_FAILURE (Status))
1042*3446Smrj             {
1043*3446Smrj                 return (Status);
1044*3446Smrj             }
1045*3446Smrj 
1046*3446Smrj             Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
1047*3446Smrj             if (ACPI_FAILURE (Status))
1048*3446Smrj             {
1049*3446Smrj                 return (Status);
1050*3446Smrj             }
1051*3446Smrj         }
1052*3446Smrj         else
1053*3446Smrj         {
1054*3446Smrj             /* Just call to the command line interpreter */
1055*3446Smrj 
1056*3446Smrj             AcpiDbSingleThread ();
1057*3446Smrj         }
1058*3446Smrj     }
1059*3446Smrj 
1060*3446Smrj     /*
1061*3446Smrj      * Only this thread (the original thread) should actually terminate the
1062*3446Smrj      * subsystem, because all the semaphores are deleted during termination
1063*3446Smrj      */
1064*3446Smrj     Status = AcpiTerminate ();
1065*3446Smrj     return (Status);
1066*3446Smrj }
1067*3446Smrj 
1068*3446Smrj #endif  /* ACPI_DEBUGGER */
1069*3446Smrj 
1070