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