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