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