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 - 2021, 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_ALL,
199     CMD_ALLOCATIONS,
200     CMD_ARGS,
201     CMD_ARGUMENTS,
202     CMD_BREAKPOINT,
203     CMD_BUSINFO,
204     CMD_CALL,
205     CMD_DEBUG,
206     CMD_DISASSEMBLE,
207     CMD_DISASM,
208     CMD_DUMP,
209     CMD_EVALUATE,
210     CMD_EXECUTE,
211     CMD_EXIT,
212     CMD_FIELDS,
213     CMD_FIND,
214     CMD_GO,
215     CMD_HANDLERS,
216     CMD_HELP,
217     CMD_HELP2,
218     CMD_HISTORY,
219     CMD_HISTORY_EXE,
220     CMD_HISTORY_LAST,
221     CMD_INFORMATION,
222     CMD_INTEGRITY,
223     CMD_INTO,
224     CMD_LEVEL,
225     CMD_LIST,
226     CMD_LOCALS,
227     CMD_LOCKS,
228     CMD_METHODS,
229     CMD_NAMESPACE,
230     CMD_NOTIFY,
231     CMD_OBJECTS,
232     CMD_OSI,
233     CMD_OWNER,
234     CMD_PATHS,
235     CMD_PREDEFINED,
236     CMD_PREFIX,
237     CMD_QUIT,
238     CMD_REFERENCES,
239     CMD_RESOURCES,
240     CMD_RESULTS,
241     CMD_SET,
242     CMD_STATS,
243     CMD_STOP,
244     CMD_TABLES,
245     CMD_TEMPLATE,
246     CMD_TRACE,
247     CMD_TREE,
248     CMD_TYPE,
249 #ifdef ACPI_APPLICATION
250     CMD_ENABLEACPI,
251     CMD_EVENT,
252     CMD_GPE,
253     CMD_GPES,
254     CMD_SCI,
255     CMD_SLEEP,
256 
257     CMD_CLOSE,
258     CMD_LOAD,
259     CMD_OPEN,
260     CMD_UNLOAD,
261 
262     CMD_TERMINATE,
263     CMD_BACKGROUND,
264     CMD_THREADS,
265 
266     CMD_TEST,
267 #endif
268 };
269 
270 #define CMD_FIRST_VALID     2
271 
272 
273 /* Second parameter is the required argument count */
274 
275 static const ACPI_DB_COMMAND_INFO   AcpiGbl_DbCommands[] =
276 {
277     {"<NOT FOUND>",  0},
278     {"<NULL>",       0},
279     {"ALL",          1},
280     {"ALLOCATIONS",  0},
281     {"ARGS",         0},
282     {"ARGUMENTS",    0},
283     {"BREAKPOINT",   1},
284     {"BUSINFO",      0},
285     {"CALL",         0},
286     {"DEBUG",        1},
287     {"DISASSEMBLE",  1},
288     {"DISASM",       1},
289     {"DUMP",         1},
290     {"EVALUATE",     1},
291     {"EXECUTE",      1},
292     {"EXIT",         0},
293     {"FIELDS",       1},
294     {"FIND",         1},
295     {"GO",           0},
296     {"HANDLERS",     0},
297     {"HELP",         0},
298     {"?",            0},
299     {"HISTORY",      0},
300     {"!",            1},
301     {"!!",           0},
302     {"INFORMATION",  0},
303     {"INTEGRITY",    0},
304     {"INTO",         0},
305     {"LEVEL",        0},
306     {"LIST",         0},
307     {"LOCALS",       0},
308     {"LOCKS",        0},
309     {"METHODS",      0},
310     {"NAMESPACE",    0},
311     {"NOTIFY",       2},
312     {"OBJECTS",      0},
313     {"OSI",          0},
314     {"OWNER",        1},
315     {"PATHS",        0},
316     {"PREDEFINED",   0},
317     {"PREFIX",       0},
318     {"QUIT",         0},
319     {"REFERENCES",   1},
320     {"RESOURCES",    0},
321     {"RESULTS",      0},
322     {"SET",          3},
323     {"STATS",        1},
324     {"STOP",         0},
325     {"TABLES",       0},
326     {"TEMPLATE",     1},
327     {"TRACE",        1},
328     {"TREE",         0},
329     {"TYPE",         1},
330 #ifdef ACPI_APPLICATION
331     {"ENABLEACPI",   0},
332     {"EVENT",        1},
333     {"GPE",          1},
334     {"GPES",         0},
335     {"SCI",          0},
336     {"SLEEP",        0},
337 
338     {"CLOSE",        0},
339     {"LOAD",         1},
340     {"OPEN",         1},
341     {"UNLOAD",       1},
342 
343     {"TERMINATE",    0},
344     {"BACKGROUND",   1},
345     {"THREADS",      3},
346 
347     {"TEST",         1},
348 #endif
349     {NULL,           0}
350 };
351 
352 /*
353  * Help for all debugger commands. First argument is the number of lines
354  * of help to output for the command.
355  *
356  * Note: Some commands are not supported by the kernel-level version of
357  * the debugger.
358  */
359 static const ACPI_DB_COMMAND_HELP   AcpiGbl_DbCommandHelp[] =
360 {
361     {0, "\nNamespace Access:",                  "\n"},
362     {1, "  Businfo",                            "Display system bus info\n"},
363     {1, "  Disassemble <Method>",               "Disassemble a control method\n"},
364     {1, "  Find <AcpiName> (? is wildcard)",    "Find ACPI name(s) with wildcards\n"},
365     {1, "  Integrity",                          "Validate namespace integrity\n"},
366     {1, "  Methods",                            "Display list of loaded control methods\n"},
367     {1, "  Fields <AddressSpaceId>",            "Display list of loaded field units by space ID\n"},
368     {1, "  Namespace [Object] [Depth]",         "Display loaded namespace tree/subtree\n"},
369     {1, "  Notify <Object> <Value>",            "Send a notification on Object\n"},
370     {1, "  Objects [ObjectType]",               "Display summary of all objects or just given type\n"},
371     {1, "  Owner <OwnerId> [Depth]",            "Display loaded namespace by object owner\n"},
372     {1, "  Paths",                              "Display full pathnames of namespace objects\n"},
373     {1, "  Predefined",                         "Check all predefined names\n"},
374     {1, "  Prefix [<Namepath>]",                "Set or Get current execution prefix\n"},
375     {1, "  References <Addr>",                  "Find all references to object at addr\n"},
376     {1, "  Resources [DeviceName]",             "Display Device resources (no arg = all devices)\n"},
377     {1, "  Set N <NamedObject> <Value>",        "Set value for named integer\n"},
378     {1, "  Template <Object>",                  "Format/dump a Buffer/ResourceTemplate\n"},
379     {1, "  Type <Object>",                      "Display object type\n"},
380 
381     {0, "\nControl Method Execution:",          "\n"},
382     {1, "  All <NameSeg>",                      "Evaluate all objects named NameSeg\n"},
383     {1, "  Evaluate <Namepath> [Arguments]",    "Evaluate object or control method\n"},
384     {1, "  Execute <Namepath> [Arguments]",     "Synonym for Evaluate\n"},
385 #ifdef ACPI_APPLICATION
386     {1, "  Background <Namepath> [Arguments]",  "Evaluate object/method in a separate thread\n"},
387     {1, "  Thread <Threads><Loops><NamePath>",  "Spawn threads to execute method(s)\n"},
388 #endif
389     {1, "  Debug <Namepath> [Arguments]",       "Single-Step a control method\n"},
390     {7, "  [Arguments] formats:",               "Control method argument formats\n"},
391     {1, "     Hex Integer",                     "Integer\n"},
392     {1, "     \"Ascii String\"",                "String\n"},
393     {1, "     (Hex Byte List)",                 "Buffer\n"},
394     {1, "         (01 42 7A BF)",               "Buffer example (4 bytes)\n"},
395     {1, "     [Package Element List]",          "Package\n"},
396     {1, "         [0x01 0x1234 \"string\"]",    "Package example (3 elements)\n"},
397 
398     {0, "\nMiscellaneous:",                     "\n"},
399     {1, "  Allocations",                        "Display list of current memory allocations\n"},
400     {2, "  Dump <Address>|<Namepath>",          "\n"},
401     {0, "       [Byte|Word|Dword|Qword]",       "Display ACPI objects or memory\n"},
402     {1, "  Handlers",                           "Info about global handlers\n"},
403     {1, "  Help [Command]",                     "This help screen or individual command\n"},
404     {1, "  History",                            "Display command history buffer\n"},
405     {1, "  Level <DebugLevel>] [console]",      "Get/Set debug level for file or console\n"},
406     {1, "  Locks",                              "Current status of internal mutexes\n"},
407     {1, "  Osi [Install|Remove <name>]",        "Display or modify global _OSI list\n"},
408     {1, "  Quit or Exit",                       "Exit this command\n"},
409     {8, "  Stats <SubCommand>",                 "Display namespace and memory statistics\n"},
410     {1, "     Allocations",                     "Display list of current memory allocations\n"},
411     {1, "     Memory",                          "Dump internal memory lists\n"},
412     {1, "     Misc",                            "Namespace search and mutex stats\n"},
413     {1, "     Objects",                         "Summary of namespace objects\n"},
414     {1, "     Sizes",                           "Sizes for each of the internal objects\n"},
415     {1, "     Stack",                           "Display CPU stack usage\n"},
416     {1, "     Tables",                          "Info about current ACPI table(s)\n"},
417     {1, "  Tables",                             "Display info about loaded ACPI tables\n"},
418 #ifdef ACPI_APPLICATION
419     {1, "  Terminate",                          "Delete namespace and all internal objects\n"},
420 #endif
421     {1, "  ! <CommandNumber>",                  "Execute command from history buffer\n"},
422     {1, "  !!",                                 "Execute last command again\n"},
423 
424     {0, "\nMethod and Namespace Debugging:",    "\n"},
425     {5, "  Trace <State> [<Namepath>] [Once]",  "Trace control method execution\n"},
426     {1, "     Enable",                          "Enable all messages\n"},
427     {1, "     Disable",                         "Disable tracing\n"},
428     {1, "     Method",                          "Enable method execution messages\n"},
429     {1, "     Opcode",                          "Enable opcode execution messages\n"},
430     {3, "  Test <TestName>",                    "Invoke a debug test\n"},
431     {1, "     Objects",                         "Read/write/compare all namespace data objects\n"},
432     {1, "     Predefined",                      "Validate all ACPI predefined names (_STA, etc.)\n"},
433     {1, "  Execute predefined",                 "Execute all predefined (public) methods\n"},
434 
435     {0, "\nControl Method Single-Step Execution:","\n"},
436     {1, "  Arguments (or Args)",                "Display method arguments\n"},
437     {1, "  Breakpoint <AmlOffset>",             "Set an AML execution breakpoint\n"},
438     {1, "  Call",                               "Run to next control method invocation\n"},
439     {1, "  Go",                                 "Allow method to run to completion\n"},
440     {1, "  Information",                        "Display info about the current method\n"},
441     {1, "  Into",                               "Step into (not over) a method call\n"},
442     {1, "  List [# of Aml Opcodes]",            "Display method ASL statements\n"},
443     {1, "  Locals",                             "Display method local variables\n"},
444     {1, "  Results",                            "Display method result stack\n"},
445     {1, "  Set <A|L> <#> <Value>",              "Set method data (Arguments/Locals)\n"},
446     {1, "  Stop",                               "Terminate control method\n"},
447     {1, "  Tree",                               "Display control method calling tree\n"},
448     {1, "  <Enter>",                            "Single step next AML opcode (over calls)\n"},
449 
450 #ifdef ACPI_APPLICATION
451     {0, "\nFile Operations:",                   "\n"},
452     {1, "  Close",                              "Close debug output file\n"},
453     {1, "  Load <Input Filename>",              "Load ACPI table from a file\n"},
454     {1, "  Open <Output Filename>",             "Open a file for debug output\n"},
455     {1, "  Unload <Namepath>",                  "Unload an ACPI table via namespace object\n"},
456 
457     {0, "\nHardware Simulation:",               "\n"},
458     {1, "  EnableAcpi",                         "Enable ACPI (hardware) mode\n"},
459     {1, "  Event <F|G> <Value>",                "Generate AcpiEvent (Fixed/GPE)\n"},
460     {1, "  Gpe <GpeNum> [GpeBlockDevice]",      "Simulate a GPE\n"},
461     {1, "  Gpes",                               "Display info on all GPE devices\n"},
462     {1, "  Sci",                                "Generate an SCI\n"},
463     {1, "  Sleep [SleepState]",                 "Simulate sleep/wake sequence(s) (0-5)\n"},
464 #endif
465     {0, NULL, NULL}
466 };
467 
468 
469 /*******************************************************************************
470  *
471  * FUNCTION:    AcpiDbMatchCommandHelp
472  *
473  * PARAMETERS:  Command             - Command string to match
474  *              Help                - Help table entry to attempt match
475  *
476  * RETURN:      TRUE if command matched, FALSE otherwise
477  *
478  * DESCRIPTION: Attempt to match a command in the help table in order to
479  *              print help information for a single command.
480  *
481  ******************************************************************************/
482 
483 static BOOLEAN
484 AcpiDbMatchCommandHelp (
485     const char                  *Command,
486     const ACPI_DB_COMMAND_HELP  *Help)
487 {
488     char                    *Invocation = Help->Invocation;
489     UINT32                  LineCount;
490 
491 
492     /* Valid commands in the help table begin with a couple of spaces */
493 
494     if (*Invocation != ' ')
495     {
496         return (FALSE);
497     }
498 
499     while (*Invocation == ' ')
500     {
501         Invocation++;
502     }
503 
504     /* Match command name (full command or substring) */
505 
506     while ((*Command) && (*Invocation) && (*Invocation != ' '))
507     {
508         if (tolower ((int) *Command) != tolower ((int) *Invocation))
509         {
510             return (FALSE);
511         }
512 
513         Invocation++;
514         Command++;
515     }
516 
517     /* Print the appropriate number of help lines */
518 
519     LineCount = Help->LineCount;
520     while (LineCount)
521     {
522         AcpiOsPrintf ("%-38s : %s", Help->Invocation, Help->Description);
523         Help++;
524         LineCount--;
525     }
526 
527     return (TRUE);
528 }
529 
530 
531 /*******************************************************************************
532  *
533  * FUNCTION:    AcpiDbDisplayCommandInfo
534  *
535  * PARAMETERS:  Command             - Command string to match
536  *              DisplayAll          - Display all matching commands, or just
537  *                                    the first one (substring match)
538  *
539  * RETURN:      None
540  *
541  * DESCRIPTION: Display help information for a Debugger command.
542  *
543  ******************************************************************************/
544 
545 static void
546 AcpiDbDisplayCommandInfo (
547     const char              *Command,
548     BOOLEAN                 DisplayAll)
549 {
550     const ACPI_DB_COMMAND_HELP  *Next;
551     BOOLEAN                     Matched;
552 
553 
554     Next = AcpiGbl_DbCommandHelp;
555     while (Next->Invocation)
556     {
557         Matched = AcpiDbMatchCommandHelp (Command, Next);
558         if (!DisplayAll && Matched)
559         {
560             return;
561         }
562 
563         Next++;
564     }
565 }
566 
567 
568 /*******************************************************************************
569  *
570  * FUNCTION:    AcpiDbDisplayHelp
571  *
572  * PARAMETERS:  Command             - Optional command string to display help.
573  *                                    if not specified, all debugger command
574  *                                    help strings are displayed
575  *
576  * RETURN:      None
577  *
578  * DESCRIPTION: Display help for a single debugger command, or all of them.
579  *
580  ******************************************************************************/
581 
582 static void
583 AcpiDbDisplayHelp (
584     char                    *Command)
585 {
586     const ACPI_DB_COMMAND_HELP  *Next = AcpiGbl_DbCommandHelp;
587 
588 
589     if (!Command)
590     {
591         /* No argument to help, display help for all commands */
592 
593         AcpiOsPrintf ("\nSummary of AML Debugger Commands\n\n");
594 
595         while (Next->Invocation)
596         {
597             AcpiOsPrintf ("%-38s%s", Next->Invocation, Next->Description);
598             Next++;
599         }
600         AcpiOsPrintf ("\n");
601 
602     }
603     else
604     {
605         /* Display help for all commands that match the substring */
606 
607         AcpiDbDisplayCommandInfo (Command, TRUE);
608     }
609 }
610 
611 
612 /*******************************************************************************
613  *
614  * FUNCTION:    AcpiDbGetNextToken
615  *
616  * PARAMETERS:  String          - Command buffer
617  *              Next            - Return value, end of next token
618  *
619  * RETURN:      Pointer to the start of the next token.
620  *
621  * DESCRIPTION: Command line parsing. Get the next token on the command line
622  *
623  ******************************************************************************/
624 
625 char *
626 AcpiDbGetNextToken (
627     char                    *String,
628     char                    **Next,
629     ACPI_OBJECT_TYPE        *ReturnType)
630 {
631     char                    *Start;
632     UINT32                  Depth;
633     ACPI_OBJECT_TYPE        Type = ACPI_TYPE_INTEGER;
634 
635 
636     /* At end of buffer? */
637 
638     if (!String || !(*String))
639     {
640         return (NULL);
641     }
642 
643     /* Remove any spaces at the beginning, ignore blank lines */
644 
645     while (*String && isspace ((int) *String))
646     {
647         String++;
648     }
649 
650     if (!(*String))
651     {
652         return (NULL);
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 && !isspace ((int) *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_ALL:
954 
955         AcpiOsPrintf ("Executing all objects with NameSeg: %s\n", AcpiGbl_DbArgs[1]);
956         AcpiDbExecute (AcpiGbl_DbArgs[1],
957             &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP | EX_ALL);
958         break;
959 
960     case CMD_ALLOCATIONS:
961 
962 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
963         AcpiUtDumpAllocations ((UINT32) -1, NULL);
964 #endif
965         break;
966 
967     case CMD_ARGS:
968     case CMD_ARGUMENTS:
969 
970         AcpiDbDisplayArguments ();
971         break;
972 
973     case CMD_BREAKPOINT:
974 
975         AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
976         break;
977 
978     case CMD_BUSINFO:
979 
980         AcpiDbGetBusInfo ();
981         break;
982 
983     case CMD_CALL:
984 
985         AcpiDbSetMethodCallBreakpoint (Op);
986         Status = AE_OK;
987         break;
988 
989     case CMD_DEBUG:
990 
991         AcpiDbExecute (AcpiGbl_DbArgs[1],
992             &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_SINGLE_STEP);
993         break;
994 
995     case CMD_DISASSEMBLE:
996     case CMD_DISASM:
997 
998 #ifdef ACPI_DISASSEMBLER
999         (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
1000 #else
1001         AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
1002 #endif
1003         break;
1004 
1005     case CMD_DUMP:
1006 
1007         AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1008         break;
1009 
1010     case CMD_EVALUATE:
1011     case CMD_EXECUTE:
1012 
1013         AcpiDbExecute (AcpiGbl_DbArgs[1],
1014             &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP);
1015         break;
1016 
1017     case CMD_FIND:
1018 
1019         Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
1020         break;
1021 
1022     case CMD_FIELDS:
1023 
1024         Status = AcpiUtStrtoul64 (AcpiGbl_DbArgs[1], &Temp64);
1025 
1026         if (ACPI_FAILURE (Status) || Temp64 >= ACPI_NUM_PREDEFINED_REGIONS)
1027         {
1028             AcpiOsPrintf (
1029                 "Invalid address space ID: must be between 0 and %u inclusive\n",
1030                 ACPI_NUM_PREDEFINED_REGIONS - 1);
1031             return (AE_OK);
1032         }
1033 
1034         Status = AcpiDbDisplayFields ((UINT32) Temp64);
1035         break;
1036 
1037     case CMD_GO:
1038 
1039         AcpiGbl_CmSingleStep = FALSE;
1040         return (AE_OK);
1041 
1042     case CMD_HANDLERS:
1043 
1044         AcpiDbDisplayHandlers ();
1045         break;
1046 
1047     case CMD_HELP:
1048     case CMD_HELP2:
1049 
1050         AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
1051         break;
1052 
1053     case CMD_HISTORY:
1054 
1055         AcpiDbDisplayHistory ();
1056         break;
1057 
1058     case CMD_HISTORY_EXE: /* ! command */
1059 
1060         CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
1061         if (!CommandLine)
1062         {
1063             return (AE_CTRL_TRUE);
1064         }
1065 
1066         Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
1067         return (Status);
1068 
1069     case CMD_HISTORY_LAST: /* !! command */
1070 
1071         CommandLine = AcpiDbGetFromHistory (NULL);
1072         if (!CommandLine)
1073         {
1074             return (AE_CTRL_TRUE);
1075         }
1076 
1077         Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
1078         return (Status);
1079 
1080     case CMD_INFORMATION:
1081 
1082         AcpiDbDisplayMethodInfo (Op);
1083         break;
1084 
1085     case CMD_INTEGRITY:
1086 
1087         AcpiDbCheckIntegrity ();
1088         break;
1089 
1090     case CMD_INTO:
1091 
1092         if (Op)
1093         {
1094             AcpiGbl_CmSingleStep = TRUE;
1095             return (AE_OK);
1096         }
1097         break;
1098 
1099     case CMD_LEVEL:
1100 
1101         if (ParamCount == 0)
1102         {
1103             AcpiOsPrintf (
1104                 "Current debug level for file output is:    %8.8X\n",
1105                 AcpiGbl_DbDebugLevel);
1106             AcpiOsPrintf (
1107                 "Current debug level for console output is: %8.8X\n",
1108                 AcpiGbl_DbConsoleDebugLevel);
1109         }
1110         else if (ParamCount == 2)
1111         {
1112             Temp = AcpiGbl_DbConsoleDebugLevel;
1113             AcpiGbl_DbConsoleDebugLevel =
1114                 strtoul (AcpiGbl_DbArgs[1], NULL, 16);
1115             AcpiOsPrintf (
1116                 "Debug Level for console output was %8.8X, now %8.8X\n",
1117                 Temp, AcpiGbl_DbConsoleDebugLevel);
1118         }
1119         else
1120         {
1121             Temp = AcpiGbl_DbDebugLevel;
1122             AcpiGbl_DbDebugLevel = strtoul (AcpiGbl_DbArgs[1], NULL, 16);
1123             AcpiOsPrintf (
1124                 "Debug Level for file output was %8.8X, now %8.8X\n",
1125                 Temp, AcpiGbl_DbDebugLevel);
1126         }
1127         break;
1128 
1129     case CMD_LIST:
1130 
1131 #ifdef ACPI_DISASSEMBLER
1132         AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
1133 #else
1134         AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
1135 #endif
1136         break;
1137 
1138     case CMD_LOCKS:
1139 
1140         AcpiDbDisplayLocks ();
1141         break;
1142 
1143     case CMD_LOCALS:
1144 
1145         AcpiDbDisplayLocals ();
1146         break;
1147 
1148     case CMD_METHODS:
1149 
1150         Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
1151         break;
1152 
1153     case CMD_NAMESPACE:
1154 
1155         AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1156         break;
1157 
1158     case CMD_NOTIFY:
1159 
1160         Temp = strtoul (AcpiGbl_DbArgs[2], NULL, 0);
1161         AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
1162         break;
1163 
1164     case CMD_OBJECTS:
1165 
1166         AcpiUtStrupr (AcpiGbl_DbArgs[1]);
1167         Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1168         break;
1169 
1170     case CMD_OSI:
1171 
1172         AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1173         break;
1174 
1175     case CMD_OWNER:
1176 
1177         AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1178         break;
1179 
1180     case CMD_PATHS:
1181 
1182         AcpiDbDumpNamespacePaths ();
1183         break;
1184 
1185     case CMD_PREFIX:
1186 
1187         AcpiDbSetScope (AcpiGbl_DbArgs[1]);
1188         break;
1189 
1190     case CMD_REFERENCES:
1191 
1192         AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
1193         break;
1194 
1195     case CMD_RESOURCES:
1196 
1197         AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
1198         break;
1199 
1200     case CMD_RESULTS:
1201 
1202         AcpiDbDisplayResults ();
1203         break;
1204 
1205     case CMD_SET:
1206 
1207         AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
1208             AcpiGbl_DbArgs[3]);
1209         break;
1210 
1211     case CMD_STATS:
1212 
1213         Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
1214         break;
1215 
1216     case CMD_STOP:
1217 
1218         return (AE_NOT_IMPLEMENTED);
1219 
1220     case CMD_TABLES:
1221 
1222         AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
1223         break;
1224 
1225     case CMD_TEMPLATE:
1226 
1227         AcpiDbDisplayTemplate (AcpiGbl_DbArgs[1]);
1228         break;
1229 
1230     case CMD_TRACE:
1231 
1232         AcpiDbTrace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]);
1233         break;
1234 
1235     case CMD_TREE:
1236 
1237         AcpiDbDisplayCallingTree ();
1238         break;
1239 
1240     case CMD_TYPE:
1241 
1242         AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
1243         break;
1244 
1245 #ifdef ACPI_APPLICATION
1246 
1247     /* Hardware simulation commands. */
1248 
1249     case CMD_ENABLEACPI:
1250 #if (!ACPI_REDUCED_HARDWARE)
1251 
1252         Status = AcpiEnable();
1253         if (ACPI_FAILURE(Status))
1254         {
1255             AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
1256             return (Status);
1257         }
1258 #endif /* !ACPI_REDUCED_HARDWARE */
1259         break;
1260 
1261     case CMD_EVENT:
1262 
1263         AcpiOsPrintf ("Event command not implemented\n");
1264         break;
1265 
1266     case CMD_GPE:
1267 
1268         AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1269         break;
1270 
1271     case CMD_GPES:
1272 
1273         AcpiDbDisplayGpes ();
1274         break;
1275 
1276     case CMD_SCI:
1277 
1278         AcpiDbGenerateSci ();
1279         break;
1280 
1281     case CMD_SLEEP:
1282 
1283         Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
1284         break;
1285 
1286     /* File I/O commands. */
1287 
1288     case CMD_CLOSE:
1289 
1290         AcpiDbCloseDebugFile ();
1291         break;
1292 
1293     case CMD_LOAD:
1294         {
1295             ACPI_NEW_TABLE_DESC     *ListHead = NULL;
1296 
1297             Status = AcGetAllTablesFromFile (AcpiGbl_DbArgs[1],
1298                 ACPI_GET_ALL_TABLES, &ListHead);
1299             if (ACPI_SUCCESS (Status))
1300             {
1301                 AcpiDbLoadTables (ListHead);
1302             }
1303         }
1304         break;
1305 
1306     case CMD_OPEN:
1307 
1308         AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
1309         break;
1310 
1311     /* User space commands. */
1312 
1313     case CMD_TERMINATE:
1314 
1315         AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1316         AcpiUtSubsystemShutdown ();
1317 
1318         /*
1319          * TBD: [Restructure] Need some way to re-initialize without
1320          * re-creating the semaphores!
1321          */
1322 
1323         AcpiGbl_DbTerminateLoop = TRUE;
1324         /*  AcpiInitialize (NULL);  */
1325         break;
1326 
1327     case CMD_BACKGROUND:
1328 
1329         AcpiDbCreateExecutionThread (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2],
1330             &AcpiGbl_DbArgTypes[2]);
1331         break;
1332 
1333     case CMD_THREADS:
1334 
1335         AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
1336             AcpiGbl_DbArgs[3]);
1337         break;
1338 
1339     /* Debug test commands. */
1340 
1341     case CMD_PREDEFINED:
1342 
1343         AcpiDbCheckPredefinedNames ();
1344         break;
1345 
1346     case CMD_TEST:
1347 
1348         AcpiDbExecuteTest (AcpiGbl_DbArgs[1]);
1349         break;
1350 
1351     case CMD_UNLOAD:
1352 
1353         AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1]);
1354         break;
1355 #endif
1356 
1357     case CMD_EXIT:
1358     case CMD_QUIT:
1359 
1360         if (Op)
1361         {
1362             AcpiOsPrintf ("Method execution terminated\n");
1363             return (AE_CTRL_TERMINATE);
1364         }
1365 
1366         if (!AcpiGbl_DbOutputToFile)
1367         {
1368             AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
1369         }
1370 
1371 #ifdef ACPI_APPLICATION
1372         AcpiDbCloseDebugFile ();
1373 #endif
1374         AcpiGbl_DbTerminateLoop = TRUE;
1375         return (AE_CTRL_TERMINATE);
1376 
1377     case CMD_NOT_FOUND:
1378     default:
1379 
1380         AcpiOsPrintf ("%s: unknown command\n", AcpiGbl_DbArgs[0]);
1381         return (AE_CTRL_TRUE);
1382     }
1383 
1384     if (ACPI_SUCCESS (Status))
1385     {
1386         Status = AE_CTRL_TRUE;
1387     }
1388 
1389     return (Status);
1390 }
1391 
1392 
1393 /*******************************************************************************
1394  *
1395  * FUNCTION:    AcpiDbExecuteThread
1396  *
1397  * PARAMETERS:  Context         - Not used
1398  *
1399  * RETURN:      None
1400  *
1401  * DESCRIPTION: Debugger execute thread. Waits for a command line, then
1402  *              simply dispatches it.
1403  *
1404  ******************************************************************************/
1405 
1406 void ACPI_SYSTEM_XFACE
1407 AcpiDbExecuteThread (
1408     void                    *Context)
1409 {
1410 
1411     (void) AcpiDbUserCommands ();
1412     AcpiGbl_DbThreadsTerminated = TRUE;
1413 }
1414 
1415 
1416 /*******************************************************************************
1417  *
1418  * FUNCTION:    AcpiDbUserCommands
1419  *
1420  * PARAMETERS:  None
1421  *
1422  * RETURN:      None
1423  *
1424  * DESCRIPTION: Command line execution for the AML debugger. Commands are
1425  *              matched and dispatched here.
1426  *
1427  ******************************************************************************/
1428 
1429 ACPI_STATUS
1430 AcpiDbUserCommands (
1431     void)
1432 {
1433     ACPI_STATUS             Status = AE_OK;
1434 
1435 
1436     AcpiOsPrintf ("\n");
1437 
1438     /* TBD: [Restructure] Need a separate command line buffer for step mode */
1439 
1440     while (!AcpiGbl_DbTerminateLoop)
1441     {
1442         /* Wait the readiness of the command */
1443 
1444         Status = AcpiOsWaitCommandReady ();
1445         if (ACPI_FAILURE (Status))
1446         {
1447             break;
1448         }
1449 
1450         /* Just call to the command line interpreter */
1451 
1452         AcpiGbl_MethodExecuting = FALSE;
1453         AcpiGbl_StepToNextCall = FALSE;
1454 
1455         (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
1456 
1457         /* Notify the completion of the command */
1458 
1459         Status = AcpiOsNotifyCommandComplete ();
1460         if (ACPI_FAILURE (Status))
1461         {
1462             break;
1463         }
1464     }
1465 
1466     if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
1467     {
1468         ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));
1469     }
1470     return (Status);
1471 }
1472