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