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 */
643 
644     if (*String == ' ')
645     {
646         while (*String && (*String == ' '))
647         {
648             String++;
649         }
650 
651         if (!(*String))
652         {
653             return (NULL);
654         }
655     }
656 
657     switch (*String)
658     {
659     case '"':
660 
661         /* This is a quoted string, scan until closing quote */
662 
663         String++;
664         Start = String;
665         Type = ACPI_TYPE_STRING;
666 
667         /* Find end of string */
668 
669         while (*String && (*String != '"'))
670         {
671             String++;
672         }
673         break;
674 
675     case '(':
676 
677         /* This is the start of a buffer, scan until closing paren */
678 
679         String++;
680         Start = String;
681         Type = ACPI_TYPE_BUFFER;
682 
683         /* Find end of buffer */
684 
685         while (*String && (*String != ')'))
686         {
687             String++;
688         }
689         break;
690 
691     case '{':
692 
693         /* This is the start of a field unit, scan until closing brace */
694 
695         String++;
696         Start = String;
697         Type = ACPI_TYPE_FIELD_UNIT;
698 
699         /* Find end of buffer */
700 
701         while (*String && (*String != '}'))
702         {
703             String++;
704         }
705         break;
706 
707     case '[':
708 
709         /* This is the start of a package, scan until closing bracket */
710 
711         String++;
712         Depth = 1;
713         Start = String;
714         Type = ACPI_TYPE_PACKAGE;
715 
716         /* Find end of package (closing bracket) */
717 
718         while (*String)
719         {
720             /* Handle String package elements */
721 
722             if (*String == '"')
723             {
724                 /* Find end of string */
725 
726                 String++;
727                 while (*String && (*String != '"'))
728                 {
729                     String++;
730                 }
731                 if (!(*String))
732                 {
733                     break;
734                 }
735             }
736             else if (*String == '[')
737             {
738                 Depth++;         /* A nested package declaration */
739             }
740             else if (*String == ']')
741             {
742                 Depth--;
743                 if (Depth == 0) /* Found final package closing bracket */
744                 {
745                     break;
746                 }
747             }
748 
749             String++;
750         }
751         break;
752 
753     default:
754 
755         Start = String;
756 
757         /* Find end of token */
758 
759         while (*String && (*String != ' '))
760         {
761             String++;
762         }
763         break;
764     }
765 
766     if (!(*String))
767     {
768         *Next = NULL;
769     }
770     else
771     {
772         *String = 0;
773         *Next = String + 1;
774     }
775 
776     *ReturnType = Type;
777     return (Start);
778 }
779 
780 
781 /*******************************************************************************
782  *
783  * FUNCTION:    AcpiDbGetLine
784  *
785  * PARAMETERS:  InputBuffer         - Command line buffer
786  *
787  * RETURN:      Count of arguments to the command
788  *
789  * DESCRIPTION: Get the next command line from the user. Gets entire line
790  *              up to the next newline
791  *
792  ******************************************************************************/
793 
794 static UINT32
795 AcpiDbGetLine (
796     char                    *InputBuffer)
797 {
798     UINT32                  i;
799     UINT32                  Count;
800     char                    *Next;
801     char                    *This;
802 
803 
804     if (AcpiUtSafeStrcpy (AcpiGbl_DbParsedBuf, sizeof (AcpiGbl_DbParsedBuf),
805         InputBuffer))
806     {
807         AcpiOsPrintf (
808             "Buffer overflow while parsing input line (max %u characters)\n",
809             (UINT32) sizeof (AcpiGbl_DbParsedBuf));
810         return (0);
811     }
812 
813     This = AcpiGbl_DbParsedBuf;
814     for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
815     {
816         AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next,
817             &AcpiGbl_DbArgTypes[i]);
818         if (!AcpiGbl_DbArgs[i])
819         {
820             break;
821         }
822 
823         This = Next;
824     }
825 
826     /* Uppercase the actual command */
827 
828     AcpiUtStrupr (AcpiGbl_DbArgs[0]);
829 
830     Count = i;
831     if (Count)
832     {
833         Count--;  /* Number of args only */
834     }
835 
836     return (Count);
837 }
838 
839 
840 /*******************************************************************************
841  *
842  * FUNCTION:    AcpiDbMatchCommand
843  *
844  * PARAMETERS:  UserCommand             - User command line
845  *
846  * RETURN:      Index into command array, -1 if not found
847  *
848  * DESCRIPTION: Search command array for a command match
849  *
850  ******************************************************************************/
851 
852 static UINT32
853 AcpiDbMatchCommand (
854     char                    *UserCommand)
855 {
856     UINT32                  i;
857 
858 
859     if (!UserCommand || UserCommand[0] == 0)
860     {
861         return (CMD_NULL);
862     }
863 
864     for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
865     {
866         if (strstr (
867             ACPI_CAST_PTR (char, AcpiGbl_DbCommands[i].Name), UserCommand) ==
868             AcpiGbl_DbCommands[i].Name)
869         {
870             return (i);
871         }
872     }
873 
874     /* Command not recognized */
875 
876     return (CMD_NOT_FOUND);
877 }
878 
879 
880 /*******************************************************************************
881  *
882  * FUNCTION:    AcpiDbCommandDispatch
883  *
884  * PARAMETERS:  InputBuffer         - Command line buffer
885  *              WalkState           - Current walk
886  *              Op                  - Current (executing) parse op
887  *
888  * RETURN:      Status
889  *
890  * DESCRIPTION: Command dispatcher.
891  *
892  ******************************************************************************/
893 
894 ACPI_STATUS
895 AcpiDbCommandDispatch (
896     char                    *InputBuffer,
897     ACPI_WALK_STATE         *WalkState,
898     ACPI_PARSE_OBJECT       *Op)
899 {
900     UINT32                  Temp;
901     UINT64                  Temp64;
902     UINT32                  CommandIndex;
903     UINT32                  ParamCount;
904     char                    *CommandLine;
905     ACPI_STATUS             Status = AE_CTRL_TRUE;
906 
907 
908     /* If AcpiTerminate has been called, terminate this thread */
909 
910     if (AcpiGbl_DbTerminateLoop)
911     {
912         return (AE_CTRL_TERMINATE);
913     }
914 
915     /* Find command and add to the history buffer */
916 
917     ParamCount = AcpiDbGetLine (InputBuffer);
918     CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]);
919 
920     /*
921      * We don't want to add the !! command to the history buffer. It
922      * would cause an infinite loop because it would always be the
923      * previous command.
924      */
925     if (CommandIndex != CMD_HISTORY_LAST)
926     {
927         AcpiDbAddToHistory (InputBuffer);
928     }
929 
930     /* Verify that we have the minimum number of params */
931 
932     if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs)
933     {
934         AcpiOsPrintf ("%u parameters entered, [%s] requires %u parameters\n",
935             ParamCount, AcpiGbl_DbCommands[CommandIndex].Name,
936             AcpiGbl_DbCommands[CommandIndex].MinArgs);
937 
938         AcpiDbDisplayCommandInfo (
939             AcpiGbl_DbCommands[CommandIndex].Name, FALSE);
940         return (AE_CTRL_TRUE);
941     }
942 
943     /* Decode and dispatch the command */
944 
945     switch (CommandIndex)
946     {
947     case CMD_NULL:
948 
949         if (Op)
950         {
951             return (AE_OK);
952         }
953         break;
954 
955     case CMD_ALLOCATIONS:
956 
957 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
958         AcpiUtDumpAllocations ((UINT32) -1, NULL);
959 #endif
960         break;
961 
962     case CMD_ARGS:
963     case CMD_ARGUMENTS:
964 
965         AcpiDbDisplayArguments ();
966         break;
967 
968     case CMD_BREAKPOINT:
969 
970         AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
971         break;
972 
973     case CMD_BUSINFO:
974 
975         AcpiDbGetBusInfo ();
976         break;
977 
978     case CMD_CALL:
979 
980         AcpiDbSetMethodCallBreakpoint (Op);
981         Status = AE_OK;
982         break;
983 
984     case CMD_DEBUG:
985 
986         AcpiDbExecute (AcpiGbl_DbArgs[1],
987             &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_SINGLE_STEP);
988         break;
989 
990     case CMD_DISASSEMBLE:
991     case CMD_DISASM:
992 
993 #ifdef ACPI_DISASSEMBLER
994         (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
995 #else
996         AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
997 #endif
998         break;
999 
1000     case CMD_DUMP:
1001 
1002         AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1003         break;
1004 
1005     case CMD_EVALUATE:
1006     case CMD_EXECUTE:
1007 
1008         AcpiDbExecute (AcpiGbl_DbArgs[1],
1009             &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP);
1010         break;
1011 
1012     case CMD_FIND:
1013 
1014         Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
1015         break;
1016 
1017     case CMD_FIELDS:
1018 
1019         Status = AcpiUtStrtoul64 (AcpiGbl_DbArgs[1], &Temp64);
1020 
1021         if (ACPI_FAILURE (Status) || Temp64 >= ACPI_NUM_PREDEFINED_REGIONS)
1022         {
1023             AcpiOsPrintf (
1024                 "Invalid address space ID: must be between 0 and %u inclusive\n",
1025                 ACPI_NUM_PREDEFINED_REGIONS - 1);
1026             return (AE_OK);
1027         }
1028 
1029         Status = AcpiDbDisplayFields ((UINT32) Temp64);
1030         break;
1031 
1032     case CMD_GO:
1033 
1034         AcpiGbl_CmSingleStep = FALSE;
1035         return (AE_OK);
1036 
1037     case CMD_HANDLERS:
1038 
1039         AcpiDbDisplayHandlers ();
1040         break;
1041 
1042     case CMD_HELP:
1043     case CMD_HELP2:
1044 
1045         AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
1046         break;
1047 
1048     case CMD_HISTORY:
1049 
1050         AcpiDbDisplayHistory ();
1051         break;
1052 
1053     case CMD_HISTORY_EXE: /* ! command */
1054 
1055         CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
1056         if (!CommandLine)
1057         {
1058             return (AE_CTRL_TRUE);
1059         }
1060 
1061         Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
1062         return (Status);
1063 
1064     case CMD_HISTORY_LAST: /* !! command */
1065 
1066         CommandLine = AcpiDbGetFromHistory (NULL);
1067         if (!CommandLine)
1068         {
1069             return (AE_CTRL_TRUE);
1070         }
1071 
1072         Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
1073         return (Status);
1074 
1075     case CMD_INFORMATION:
1076 
1077         AcpiDbDisplayMethodInfo (Op);
1078         break;
1079 
1080     case CMD_INTEGRITY:
1081 
1082         AcpiDbCheckIntegrity ();
1083         break;
1084 
1085     case CMD_INTO:
1086 
1087         if (Op)
1088         {
1089             AcpiGbl_CmSingleStep = TRUE;
1090             return (AE_OK);
1091         }
1092         break;
1093 
1094     case CMD_LEVEL:
1095 
1096         if (ParamCount == 0)
1097         {
1098             AcpiOsPrintf (
1099                 "Current debug level for file output is:    %8.8X\n",
1100                 AcpiGbl_DbDebugLevel);
1101             AcpiOsPrintf (
1102                 "Current debug level for console output is: %8.8X\n",
1103                 AcpiGbl_DbConsoleDebugLevel);
1104         }
1105         else if (ParamCount == 2)
1106         {
1107             Temp = AcpiGbl_DbConsoleDebugLevel;
1108             AcpiGbl_DbConsoleDebugLevel =
1109                 strtoul (AcpiGbl_DbArgs[1], NULL, 16);
1110             AcpiOsPrintf (
1111                 "Debug Level for console output was %8.8X, now %8.8X\n",
1112                 Temp, AcpiGbl_DbConsoleDebugLevel);
1113         }
1114         else
1115         {
1116             Temp = AcpiGbl_DbDebugLevel;
1117             AcpiGbl_DbDebugLevel = strtoul (AcpiGbl_DbArgs[1], NULL, 16);
1118             AcpiOsPrintf (
1119                 "Debug Level for file output was %8.8X, now %8.8X\n",
1120                 Temp, AcpiGbl_DbDebugLevel);
1121         }
1122         break;
1123 
1124     case CMD_LIST:
1125 
1126 #ifdef ACPI_DISASSEMBLER
1127         AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
1128 #else
1129         AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
1130 #endif
1131         break;
1132 
1133     case CMD_LOCKS:
1134 
1135         AcpiDbDisplayLocks ();
1136         break;
1137 
1138     case CMD_LOCALS:
1139 
1140         AcpiDbDisplayLocals ();
1141         break;
1142 
1143     case CMD_METHODS:
1144 
1145         Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
1146         break;
1147 
1148     case CMD_NAMESPACE:
1149 
1150         AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1151         break;
1152 
1153     case CMD_NOTIFY:
1154 
1155         Temp = strtoul (AcpiGbl_DbArgs[2], NULL, 0);
1156         AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
1157         break;
1158 
1159     case CMD_OBJECTS:
1160 
1161         AcpiUtStrupr (AcpiGbl_DbArgs[1]);
1162         Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1163         break;
1164 
1165     case CMD_OSI:
1166 
1167         AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1168         break;
1169 
1170     case CMD_OWNER:
1171 
1172         AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1173         break;
1174 
1175     case CMD_PATHS:
1176 
1177         AcpiDbDumpNamespacePaths ();
1178         break;
1179 
1180     case CMD_PREFIX:
1181 
1182         AcpiDbSetScope (AcpiGbl_DbArgs[1]);
1183         break;
1184 
1185     case CMD_REFERENCES:
1186 
1187         AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
1188         break;
1189 
1190     case CMD_RESOURCES:
1191 
1192         AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
1193         break;
1194 
1195     case CMD_RESULTS:
1196 
1197         AcpiDbDisplayResults ();
1198         break;
1199 
1200     case CMD_SET:
1201 
1202         AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
1203             AcpiGbl_DbArgs[3]);
1204         break;
1205 
1206     case CMD_STATS:
1207 
1208         Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
1209         break;
1210 
1211     case CMD_STOP:
1212 
1213         return (AE_NOT_IMPLEMENTED);
1214 
1215     case CMD_TABLES:
1216 
1217         AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
1218         break;
1219 
1220     case CMD_TEMPLATE:
1221 
1222         AcpiDbDisplayTemplate (AcpiGbl_DbArgs[1]);
1223         break;
1224 
1225     case CMD_TRACE:
1226 
1227         AcpiDbTrace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]);
1228         break;
1229 
1230     case CMD_TREE:
1231 
1232         AcpiDbDisplayCallingTree ();
1233         break;
1234 
1235     case CMD_TYPE:
1236 
1237         AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
1238         break;
1239 
1240 #ifdef ACPI_APPLICATION
1241 
1242     /* Hardware simulation commands. */
1243 
1244     case CMD_ENABLEACPI:
1245 #if (!ACPI_REDUCED_HARDWARE)
1246 
1247         Status = AcpiEnable();
1248         if (ACPI_FAILURE(Status))
1249         {
1250             AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
1251             return (Status);
1252         }
1253 #endif /* !ACPI_REDUCED_HARDWARE */
1254         break;
1255 
1256     case CMD_EVENT:
1257 
1258         AcpiOsPrintf ("Event command not implemented\n");
1259         break;
1260 
1261     case CMD_GPE:
1262 
1263         AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1264         break;
1265 
1266     case CMD_GPES:
1267 
1268         AcpiDbDisplayGpes ();
1269         break;
1270 
1271     case CMD_SCI:
1272 
1273         AcpiDbGenerateSci ();
1274         break;
1275 
1276     case CMD_SLEEP:
1277 
1278         Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
1279         break;
1280 
1281     /* File I/O commands. */
1282 
1283     case CMD_CLOSE:
1284 
1285         AcpiDbCloseDebugFile ();
1286         break;
1287 
1288     case CMD_LOAD:
1289         {
1290             ACPI_NEW_TABLE_DESC     *ListHead = NULL;
1291 
1292             Status = AcGetAllTablesFromFile (AcpiGbl_DbArgs[1],
1293                 ACPI_GET_ALL_TABLES, &ListHead);
1294             if (ACPI_SUCCESS (Status))
1295             {
1296                 AcpiDbLoadTables (ListHead);
1297             }
1298         }
1299         break;
1300 
1301     case CMD_OPEN:
1302 
1303         AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
1304         break;
1305 
1306     /* User space commands. */
1307 
1308     case CMD_TERMINATE:
1309 
1310         AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1311         AcpiUtSubsystemShutdown ();
1312 
1313         /*
1314          * TBD: [Restructure] Need some way to re-initialize without
1315          * re-creating the semaphores!
1316          */
1317 
1318         AcpiGbl_DbTerminateLoop = TRUE;
1319         /*  AcpiInitialize (NULL);  */
1320         break;
1321 
1322     case CMD_BACKGROUND:
1323 
1324         AcpiDbCreateExecutionThread (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2],
1325             &AcpiGbl_DbArgTypes[2]);
1326         break;
1327 
1328     case CMD_THREADS:
1329 
1330         AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
1331             AcpiGbl_DbArgs[3]);
1332         break;
1333 
1334     /* Debug test commands. */
1335 
1336     case CMD_PREDEFINED:
1337 
1338         AcpiDbCheckPredefinedNames ();
1339         break;
1340 
1341     case CMD_TEST:
1342 
1343         AcpiDbExecuteTest (AcpiGbl_DbArgs[1]);
1344         break;
1345 
1346     case CMD_UNLOAD:
1347 
1348         AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1]);
1349         break;
1350 #endif
1351 
1352     case CMD_EXIT:
1353     case CMD_QUIT:
1354 
1355         if (Op)
1356         {
1357             AcpiOsPrintf ("Method execution terminated\n");
1358             return (AE_CTRL_TERMINATE);
1359         }
1360 
1361         if (!AcpiGbl_DbOutputToFile)
1362         {
1363             AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
1364         }
1365 
1366 #ifdef ACPI_APPLICATION
1367         AcpiDbCloseDebugFile ();
1368 #endif
1369         AcpiGbl_DbTerminateLoop = TRUE;
1370         return (AE_CTRL_TERMINATE);
1371 
1372     case CMD_NOT_FOUND:
1373     default:
1374 
1375         AcpiOsPrintf ("%s: unknown command\n", AcpiGbl_DbArgs[0]);
1376         return (AE_CTRL_TRUE);
1377     }
1378 
1379     if (ACPI_SUCCESS (Status))
1380     {
1381         Status = AE_CTRL_TRUE;
1382     }
1383 
1384     return (Status);
1385 }
1386 
1387 
1388 /*******************************************************************************
1389  *
1390  * FUNCTION:    AcpiDbExecuteThread
1391  *
1392  * PARAMETERS:  Context         - Not used
1393  *
1394  * RETURN:      None
1395  *
1396  * DESCRIPTION: Debugger execute thread. Waits for a command line, then
1397  *              simply dispatches it.
1398  *
1399  ******************************************************************************/
1400 
1401 void ACPI_SYSTEM_XFACE
1402 AcpiDbExecuteThread (
1403     void                    *Context)
1404 {
1405 
1406     (void) AcpiDbUserCommands ();
1407     AcpiGbl_DbThreadsTerminated = TRUE;
1408 }
1409 
1410 
1411 /*******************************************************************************
1412  *
1413  * FUNCTION:    AcpiDbUserCommands
1414  *
1415  * PARAMETERS:  None
1416  *
1417  * RETURN:      None
1418  *
1419  * DESCRIPTION: Command line execution for the AML debugger. Commands are
1420  *              matched and dispatched here.
1421  *
1422  ******************************************************************************/
1423 
1424 ACPI_STATUS
1425 AcpiDbUserCommands (
1426     void)
1427 {
1428     ACPI_STATUS             Status = AE_OK;
1429 
1430 
1431     AcpiOsPrintf ("\n");
1432 
1433     /* TBD: [Restructure] Need a separate command line buffer for step mode */
1434 
1435     while (!AcpiGbl_DbTerminateLoop)
1436     {
1437         /* Wait the readiness of the command */
1438 
1439         Status = AcpiOsWaitCommandReady ();
1440         if (ACPI_FAILURE (Status))
1441         {
1442             break;
1443         }
1444 
1445         /* Just call to the command line interpreter */
1446 
1447         AcpiGbl_MethodExecuting = FALSE;
1448         AcpiGbl_StepToNextCall = FALSE;
1449 
1450         (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
1451 
1452         /* Notify the completion of the command */
1453 
1454         Status = AcpiOsNotifyCommandComplete ();
1455         if (ACPI_FAILURE (Status))
1456         {
1457             break;
1458         }
1459     }
1460 
1461     if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
1462     {
1463         ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));
1464     }
1465     return (Status);
1466 }
1467 
1468 #endif  /* ACPI_DEBUGGER */
1469