i386/identcpu.c: Add VIA Nano support
[dragonfly.git] / sys / contrib / dev / acpica-unix-20061109 / debugger / dbinput.c
blobcf0162f737e42d217fb936991738c85903168499
1 /*******************************************************************************
3 * Module Name: dbinput - user front-end to the AML debugger
4 * $Revision: 1.113 $
6 ******************************************************************************/
8 /******************************************************************************
10 * 1. Copyright Notice
12 * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13 * All rights reserved.
15 * 2. License
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
41 * 3. Conditions
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
118 #include "acpi.h"
119 #include "acdebug.h"
122 #ifdef ACPI_DEBUGGER
124 #define _COMPONENT ACPI_CA_DEBUGGER
125 ACPI_MODULE_NAME ("dbinput")
127 /* Local prototypes */
129 static char *
130 AcpiDbGetNextToken (
131 char *String,
132 char **Next);
134 static UINT32
135 AcpiDbGetLine (
136 char *InputBuffer);
138 static UINT32
139 AcpiDbMatchCommand (
140 char *UserCommand);
142 static void
143 AcpiDbSingleThread (
144 void);
146 static void
147 AcpiDbDisplayHelp (
148 char *HelpType);
152 * Top-level debugger commands.
154 * This list of commands must match the string table below it
156 enum AcpiExDebuggerCommands
158 CMD_NOT_FOUND = 0,
159 CMD_NULL,
160 CMD_ALLOCATIONS,
161 CMD_ARGS,
162 CMD_ARGUMENTS,
163 CMD_BREAKPOINT,
164 CMD_BUSINFO,
165 CMD_CALL,
166 CMD_CLOSE,
167 CMD_DEBUG,
168 CMD_DISASSEMBLE,
169 CMD_DUMP,
170 CMD_ENABLEACPI,
171 CMD_EVENT,
172 CMD_EXECUTE,
173 CMD_EXIT,
174 CMD_FIND,
175 CMD_GO,
176 CMD_GPE,
177 CMD_GPES,
178 CMD_HELP,
179 CMD_HELP2,
180 CMD_HISTORY,
181 CMD_HISTORY_EXE,
182 CMD_HISTORY_LAST,
183 CMD_INFORMATION,
184 CMD_INTEGRITY,
185 CMD_INTO,
186 CMD_LEVEL,
187 CMD_LIST,
188 CMD_LOAD,
189 CMD_LOCALS,
190 CMD_LOCKS,
191 CMD_METHODS,
192 CMD_NAMESPACE,
193 CMD_NOTIFY,
194 CMD_OBJECT,
195 CMD_OPEN,
196 CMD_OWNER,
197 CMD_PREFIX,
198 CMD_QUIT,
199 CMD_REFERENCES,
200 CMD_RESOURCES,
201 CMD_RESULTS,
202 CMD_SET,
203 CMD_SLEEP,
204 CMD_STATS,
205 CMD_STOP,
206 CMD_TABLES,
207 CMD_TERMINATE,
208 CMD_THREADS,
209 CMD_TRACE,
210 CMD_TREE,
211 CMD_TYPE,
212 CMD_UNLOAD
215 #define CMD_FIRST_VALID 2
217 static const COMMAND_INFO AcpiGbl_DbCommands[] =
219 {"<NOT FOUND>", 0},
220 {"<NULL>", 0},
221 {"ALLOCATIONS", 0},
222 {"ARGS", 0},
223 {"ARGUMENTS", 0},
224 {"BREAKPOINT", 1},
225 {"BUSINFO", 0},
226 {"CALL", 0},
227 {"CLOSE", 0},
228 {"DEBUG", 1},
229 {"DISASSEMBLE", 1},
230 {"DUMP", 1},
231 {"ENABLEACPI", 0},
232 {"EVENT", 1},
233 {"EXECUTE", 1},
234 {"EXIT", 0},
235 {"FIND", 1},
236 {"GO", 0},
237 {"GPE", 2},
238 {"GPES", 0},
239 {"HELP", 0},
240 {"?", 0},
241 {"HISTORY", 0},
242 {"!", 1},
243 {"!!", 0},
244 {"INFORMATION", 0},
245 {"INTEGRITY", 0},
246 {"INTO", 0},
247 {"LEVEL", 0},
248 {"LIST", 0},
249 {"LOAD", 1},
250 {"LOCALS", 0},
251 {"LOCKS", 0},
252 {"METHODS", 0},
253 {"NAMESPACE", 0},
254 {"NOTIFY", 2},
255 {"OBJECT", 1},
256 {"OPEN", 1},
257 {"OWNER", 1},
258 {"PREFIX", 0},
259 {"QUIT", 0},
260 {"REFERENCES", 1},
261 {"RESOURCES", 1},
262 {"RESULTS", 0},
263 {"SET", 3},
264 {"SLEEP", 1},
265 {"STATS", 0},
266 {"STOP", 0},
267 {"TABLES", 0},
268 {"TERMINATE", 0},
269 {"THREADS", 3},
270 {"TRACE", 1},
271 {"TREE", 0},
272 {"TYPE", 1},
273 {"UNLOAD", 1},
274 {NULL, 0}
278 /*******************************************************************************
280 * FUNCTION: AcpiDbDisplayHelp
282 * PARAMETERS: HelpType - Subcommand (optional)
284 * RETURN: None
286 * DESCRIPTION: Print a usage message.
288 ******************************************************************************/
290 static void
291 AcpiDbDisplayHelp (
292 char *HelpType)
295 AcpiUtStrupr (HelpType);
297 /* No parameter, just give the overview */
299 if (!HelpType)
301 AcpiOsPrintf ("ACPI CA Debugger Commands\n\n");
302 AcpiOsPrintf ("The following classes of commands are available. Help is available for\n");
303 AcpiOsPrintf ("each class by entering \"Help <ClassName>\"\n\n");
304 AcpiOsPrintf (" [GENERAL] General-Purpose Commands\n");
305 AcpiOsPrintf (" [NAMESPACE] Namespace Access Commands\n");
306 AcpiOsPrintf (" [METHOD] Control Method Execution Commands\n");
307 AcpiOsPrintf (" [STATISTICS] Statistical Information\n");
308 AcpiOsPrintf (" [FILE] File I/O Commands\n");
309 return;
313 * Parameter is the command class
315 * The idea here is to keep each class of commands smaller than a screenful
317 switch (HelpType[0])
319 case 'G':
320 AcpiOsPrintf ("\nGeneral-Purpose Commands\n\n");
321 AcpiOsPrintf ("Allocations Display list of current memory allocations\n");
322 AcpiOsPrintf ("Dump <Address>|<Namepath>\n");
323 AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n");
324 AcpiOsPrintf ("EnableAcpi Enable ACPI (hardware) mode\n");
325 AcpiOsPrintf ("Help This help screen\n");
326 AcpiOsPrintf ("History Display command history buffer\n");
327 AcpiOsPrintf ("Level [<DebugLevel>] [console] Get/Set debug level for file or console\n");
328 AcpiOsPrintf ("Locks Current status of internal mutexes\n");
329 AcpiOsPrintf ("Quit or Exit Exit this command\n");
330 AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n");
331 AcpiOsPrintf (" |Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n");
332 AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n");
333 AcpiOsPrintf ("Unload <TableSig> [Instance] Unload an ACPI table\n");
334 AcpiOsPrintf ("! <CommandNumber> Execute command from history buffer\n");
335 AcpiOsPrintf ("!! Execute last command again\n");
336 return;
338 case 'S':
339 AcpiOsPrintf ("\nStats Subcommands\n\n");
340 AcpiOsPrintf ("Allocations Display list of current memory allocations\n");
341 AcpiOsPrintf ("Memory Dump internal memory lists\n");
342 AcpiOsPrintf ("Misc Namespace search and mutex stats\n");
343 AcpiOsPrintf ("Objects Summary of namespace objects\n");
344 AcpiOsPrintf ("Sizes Sizes for each of the internal objects\n");
345 AcpiOsPrintf ("Stack Display CPU stack usage\n");
346 AcpiOsPrintf ("Tables Info about current ACPI table(s)\n");
347 return;
349 case 'N':
350 AcpiOsPrintf ("\nNamespace Access Commands\n\n");
351 AcpiOsPrintf ("Businfo Display system bus info\n");
352 AcpiOsPrintf ("Disassemble <Method> Disassemble a control method\n");
353 AcpiOsPrintf ("Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n");
354 AcpiOsPrintf ("Find <AcpiName> (? is wildcard) Find ACPI name(s) with wildcards\n");
355 AcpiOsPrintf ("Gpe <GpeNum> <GpeBlock> Simulate a GPE\n");
356 AcpiOsPrintf ("Gpes Display info on all GPEs\n");
357 AcpiOsPrintf ("Integrity Validate namespace integrity\n");
358 AcpiOsPrintf ("Methods Display list of loaded control methods\n");
359 AcpiOsPrintf ("Namespace [Object] [Depth] Display loaded namespace tree/subtree\n");
360 AcpiOsPrintf ("Notify <Object> <Value> Send a notification on Object\n");
361 AcpiOsPrintf ("Objects <ObjectType> Display all objects of the given type\n");
362 AcpiOsPrintf ("Owner <OwnerId> [Depth] Display loaded namespace by object owner\n");
363 AcpiOsPrintf ("Prefix [<NamePath>] Set or Get current execution prefix\n");
364 AcpiOsPrintf ("References <Addr> Find all references to object at addr\n");
365 AcpiOsPrintf ("Resources <Device> Get and display Device resources\n");
366 AcpiOsPrintf ("Set N <NamedObject> <Value> Set value for named integer\n");
367 AcpiOsPrintf ("Sleep <SleepState> Simulate sleep/wake sequence\n");
368 AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n");
369 AcpiOsPrintf ("Type <Object> Display object type\n");
370 return;
372 case 'M':
373 AcpiOsPrintf ("\nControl Method Execution Commands\n\n");
374 AcpiOsPrintf ("Arguments (or Args) Display method arguments\n");
375 AcpiOsPrintf ("Breakpoint <AmlOffset> Set an AML execution breakpoint\n");
376 AcpiOsPrintf ("Call Run to next control method invocation\n");
377 AcpiOsPrintf ("Debug <Namepath> [Arguments] Single Step a control method\n");
378 AcpiOsPrintf ("Execute <Namepath> [Arguments] Execute control method\n");
379 AcpiOsPrintf ("Go Allow method to run to completion\n");
380 AcpiOsPrintf ("Information Display info about the current method\n");
381 AcpiOsPrintf ("Into Step into (not over) a method call\n");
382 AcpiOsPrintf ("List [# of Aml Opcodes] Display method ASL statements\n");
383 AcpiOsPrintf ("Locals Display method local variables\n");
384 AcpiOsPrintf ("Results Display method result stack\n");
385 AcpiOsPrintf ("Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n");
386 AcpiOsPrintf ("Stop Terminate control method\n");
387 AcpiOsPrintf ("Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n");
388 AcpiOsPrintf ("Trace <method name> Trace method execution\n");
389 AcpiOsPrintf ("Tree Display control method calling tree\n");
390 AcpiOsPrintf ("<Enter> Single step next AML opcode (over calls)\n");
391 return;
393 case 'F':
394 AcpiOsPrintf ("\nFile I/O Commands\n\n");
395 AcpiOsPrintf ("Close Close debug output file\n");
396 AcpiOsPrintf ("Open <Output Filename> Open a file for debug output\n");
397 AcpiOsPrintf ("Load <Input Filename> Load ACPI table from a file\n");
398 return;
400 default:
401 AcpiOsPrintf ("Unrecognized Command Class: %s\n", HelpType);
402 return;
407 /*******************************************************************************
409 * FUNCTION: AcpiDbGetNextToken
411 * PARAMETERS: String - Command buffer
412 * Next - Return value, end of next token
414 * RETURN: Pointer to the start of the next token.
416 * DESCRIPTION: Command line parsing. Get the next token on the command line
418 ******************************************************************************/
420 static char *
421 AcpiDbGetNextToken (
422 char *String,
423 char **Next)
425 char *Start;
428 /* At end of buffer? */
430 if (!String || !(*String))
432 return (NULL);
435 /* Get rid of any spaces at the beginning */
437 if (*String == ' ')
439 while (*String && (*String == ' '))
441 String++;
444 if (!(*String))
446 return (NULL);
450 Start = String;
452 /* Find end of token */
454 while (*String && (*String != ' '))
456 String++;
459 if (!(*String))
461 *Next = NULL;
463 else
465 *String = 0;
466 *Next = String + 1;
469 return (Start);
473 /*******************************************************************************
475 * FUNCTION: AcpiDbGetLine
477 * PARAMETERS: InputBuffer - Command line buffer
479 * RETURN: Count of arguments to the command
481 * DESCRIPTION: Get the next command line from the user. Gets entire line
482 * up to the next newline
484 ******************************************************************************/
486 static UINT32
487 AcpiDbGetLine (
488 char *InputBuffer)
490 UINT32 i;
491 UINT32 Count;
492 char *Next;
493 char *This;
496 ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer);
498 This = AcpiGbl_DbParsedBuf;
499 for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
501 AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next);
502 if (!AcpiGbl_DbArgs[i])
504 break;
507 This = Next;
510 /* Uppercase the actual command */
512 if (AcpiGbl_DbArgs[0])
514 AcpiUtStrupr (AcpiGbl_DbArgs[0]);
517 Count = i;
518 if (Count)
520 Count--; /* Number of args only */
523 return (Count);
527 /*******************************************************************************
529 * FUNCTION: AcpiDbMatchCommand
531 * PARAMETERS: UserCommand - User command line
533 * RETURN: Index into command array, -1 if not found
535 * DESCRIPTION: Search command array for a command match
537 ******************************************************************************/
539 static UINT32
540 AcpiDbMatchCommand (
541 char *UserCommand)
543 UINT32 i;
546 if (!UserCommand || UserCommand[0] == 0)
548 return (CMD_NULL);
551 for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
553 if (ACPI_STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) ==
554 AcpiGbl_DbCommands[i].Name)
556 return (i);
560 /* Command not recognized */
562 return (CMD_NOT_FOUND);
566 /*******************************************************************************
568 * FUNCTION: AcpiDbCommandDispatch
570 * PARAMETERS: InputBuffer - Command line buffer
571 * WalkState - Current walk
572 * Op - Current (executing) parse op
574 * RETURN: Status
576 * DESCRIPTION: Command dispatcher.
578 ******************************************************************************/
580 ACPI_STATUS
581 AcpiDbCommandDispatch (
582 char *InputBuffer,
583 ACPI_WALK_STATE *WalkState,
584 ACPI_PARSE_OBJECT *Op)
586 UINT32 Temp;
587 UINT32 CommandIndex;
588 UINT32 ParamCount;
589 char *CommandLine;
590 ACPI_STATUS Status = AE_CTRL_TRUE;
593 /* If AcpiTerminate has been called, terminate this thread */
595 if (AcpiGbl_DbTerminateThreads)
597 return (AE_CTRL_TERMINATE);
600 ParamCount = AcpiDbGetLine (InputBuffer);
601 CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]);
602 Temp = 0;
604 /* Verify that we have the minimum number of params */
606 if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs)
608 AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n",
609 ParamCount, AcpiGbl_DbCommands[CommandIndex].Name,
610 AcpiGbl_DbCommands[CommandIndex].MinArgs);
612 return (AE_CTRL_TRUE);
615 /* Decode and dispatch the command */
617 switch (CommandIndex)
619 case CMD_NULL:
620 if (Op)
622 return (AE_OK);
624 break;
626 case CMD_ALLOCATIONS:
628 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
629 AcpiUtDumpAllocations ((UINT32) -1, NULL);
630 #endif
631 break;
633 case CMD_ARGS:
634 case CMD_ARGUMENTS:
635 AcpiDbDisplayArguments ();
636 break;
638 case CMD_BREAKPOINT:
639 AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
640 break;
642 case CMD_BUSINFO:
643 AcpiDbGetBusInfo ();
644 break;
646 case CMD_CALL:
647 AcpiDbSetMethodCallBreakpoint (Op);
648 Status = AE_OK;
649 break;
651 case CMD_CLOSE:
652 AcpiDbCloseDebugFile ();
653 break;
655 case CMD_DEBUG:
656 AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_SINGLE_STEP);
657 break;
659 case CMD_DISASSEMBLE:
660 (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
661 break;
663 case CMD_DUMP:
664 AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
665 break;
667 case CMD_ENABLEACPI:
668 Status = AcpiEnable();
669 if (ACPI_FAILURE(Status))
671 AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
672 return (Status);
674 break;
676 case CMD_EVENT:
677 AcpiOsPrintf ("Event command not implemented\n");
678 break;
680 case CMD_EXECUTE:
681 AcpiDbExecute (AcpiGbl_DbArgs[1],
682 &AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP);
683 break;
685 case CMD_FIND:
686 Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
687 break;
689 case CMD_GO:
690 AcpiGbl_CmSingleStep = FALSE;
691 return (AE_OK);
693 case CMD_GPE:
694 AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
695 break;
697 case CMD_GPES:
698 AcpiDbDisplayGpes ();
699 break;
701 case CMD_HELP:
702 case CMD_HELP2:
703 AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
704 break;
706 case CMD_HISTORY:
707 AcpiDbDisplayHistory ();
708 break;
710 case CMD_HISTORY_EXE:
711 CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
712 if (!CommandLine)
714 return (AE_CTRL_TRUE);
717 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
718 return (Status);
720 case CMD_HISTORY_LAST:
721 CommandLine = AcpiDbGetFromHistory (NULL);
722 if (!CommandLine)
724 return (AE_CTRL_TRUE);
727 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
728 return (Status);
730 case CMD_INFORMATION:
731 AcpiDbDisplayMethodInfo (Op);
732 break;
734 case CMD_INTEGRITY:
735 AcpiDbCheckIntegrity ();
736 break;
738 case CMD_INTO:
739 if (Op)
741 AcpiGbl_CmSingleStep = TRUE;
742 return (AE_OK);
744 break;
746 case CMD_LEVEL:
747 if (ParamCount == 0)
749 AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n",
750 AcpiGbl_DbDebugLevel);
751 AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n",
752 AcpiGbl_DbConsoleDebugLevel);
754 else if (ParamCount == 2)
756 Temp = AcpiGbl_DbConsoleDebugLevel;
757 AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1],
758 NULL, 16);
759 AcpiOsPrintf (
760 "Debug Level for console output was %8.8lX, now %8.8lX\n",
761 Temp, AcpiGbl_DbConsoleDebugLevel);
763 else
765 Temp = AcpiGbl_DbDebugLevel;
766 AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16);
767 AcpiOsPrintf (
768 "Debug Level for file output was %8.8lX, now %8.8lX\n",
769 Temp, AcpiGbl_DbDebugLevel);
771 break;
773 case CMD_LIST:
774 AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
775 break;
777 case CMD_LOAD:
778 Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL);
779 break;
781 case CMD_LOCKS:
782 AcpiDbDisplayLocks ();
783 break;
785 case CMD_LOCALS:
786 AcpiDbDisplayLocals ();
787 break;
789 case CMD_METHODS:
790 Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
791 break;
793 case CMD_NAMESPACE:
794 AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
795 break;
797 case CMD_NOTIFY:
798 Temp = ACPI_STRTOUL (AcpiGbl_DbArgs[2], NULL, 0);
799 AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
800 break;
802 case CMD_OBJECT:
803 AcpiUtStrupr (AcpiGbl_DbArgs[1]);
804 Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
805 break;
807 case CMD_OPEN:
808 AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
809 break;
811 case CMD_OWNER:
812 AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
813 break;
815 case CMD_PREFIX:
816 AcpiDbSetScope (AcpiGbl_DbArgs[1]);
817 break;
819 case CMD_REFERENCES:
820 AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
821 break;
823 case CMD_RESOURCES:
824 AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
825 break;
827 case CMD_RESULTS:
828 AcpiDbDisplayResults ();
829 break;
831 case CMD_SET:
832 AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
833 AcpiGbl_DbArgs[3]);
834 break;
836 case CMD_SLEEP:
837 Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
838 break;
840 case CMD_STATS:
841 Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
842 break;
844 case CMD_STOP:
845 return (AE_NOT_IMPLEMENTED);
847 case CMD_TABLES:
848 AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
849 break;
851 case CMD_TERMINATE:
852 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
853 AcpiUtSubsystemShutdown ();
856 * TBD: [Restructure] Need some way to re-initialize without
857 * re-creating the semaphores!
860 /* AcpiInitialize (NULL); */
861 break;
863 case CMD_THREADS:
864 AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
865 AcpiGbl_DbArgs[3]);
866 break;
868 case CMD_TRACE:
869 AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1);
870 break;
872 case CMD_TREE:
873 AcpiDbDisplayCallingTree ();
874 break;
876 case CMD_TYPE:
877 AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
878 break;
880 case CMD_UNLOAD:
881 AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
882 break;
884 case CMD_EXIT:
885 case CMD_QUIT:
886 if (Op)
888 AcpiOsPrintf ("Method execution terminated\n");
889 return (AE_CTRL_TERMINATE);
892 if (!AcpiGbl_DbOutputToFile)
894 AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
897 AcpiDbCloseDebugFile ();
898 AcpiGbl_DbTerminateThreads = TRUE;
899 return (AE_CTRL_TERMINATE);
901 case CMD_NOT_FOUND:
902 default:
903 AcpiOsPrintf ("Unknown Command\n");
904 return (AE_CTRL_TRUE);
907 if (ACPI_SUCCESS (Status))
909 Status = AE_CTRL_TRUE;
912 /* Add all commands that come here to the history buffer */
914 AcpiDbAddToHistory (InputBuffer);
915 return (Status);
919 /*******************************************************************************
921 * FUNCTION: AcpiDbExecuteThread
923 * PARAMETERS: Context - Not used
925 * RETURN: None
927 * DESCRIPTION: Debugger execute thread. Waits for a command line, then
928 * simply dispatches it.
930 ******************************************************************************/
932 void ACPI_SYSTEM_XFACE
933 AcpiDbExecuteThread (
934 void *Context)
936 ACPI_STATUS Status = AE_OK;
937 ACPI_STATUS MStatus;
940 while (Status != AE_CTRL_TERMINATE)
942 AcpiGbl_MethodExecuting = FALSE;
943 AcpiGbl_StepToNextCall = FALSE;
945 MStatus = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
946 if (ACPI_FAILURE (MStatus))
948 return;
951 Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
953 MStatus = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
954 if (ACPI_FAILURE (MStatus))
956 return;
962 /*******************************************************************************
964 * FUNCTION: AcpiDbSingleThread
966 * PARAMETERS: None
968 * RETURN: None
970 * DESCRIPTION: Debugger execute thread. Waits for a command line, then
971 * simply dispatches it.
973 ******************************************************************************/
975 static void
976 AcpiDbSingleThread (
977 void)
980 AcpiGbl_MethodExecuting = FALSE;
981 AcpiGbl_StepToNextCall = FALSE;
983 (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
987 /*******************************************************************************
989 * FUNCTION: AcpiDbUserCommands
991 * PARAMETERS: Prompt - User prompt (depends on mode)
992 * Op - Current executing parse op
994 * RETURN: None
996 * DESCRIPTION: Command line execution for the AML debugger. Commands are
997 * matched and dispatched here.
999 ******************************************************************************/
1001 ACPI_STATUS
1002 AcpiDbUserCommands (
1003 char Prompt,
1004 ACPI_PARSE_OBJECT *Op)
1006 ACPI_STATUS Status = AE_OK;
1009 /* TBD: [Restructure] Need a separate command line buffer for step mode */
1011 while (!AcpiGbl_DbTerminateThreads)
1013 /* Force output to console until a command is entered */
1015 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1017 /* Different prompt if method is executing */
1019 if (!AcpiGbl_MethodExecuting)
1021 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
1023 else
1025 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
1028 /* Get the user input line */
1030 (void) AcpiOsGetLine (AcpiGbl_DbLineBuf);
1032 /* Check for single or multithreaded debug */
1034 if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
1037 * Signal the debug thread that we have a command to execute,
1038 * and wait for the command to complete.
1040 Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_READY);
1041 if (ACPI_FAILURE (Status))
1043 return (Status);
1046 Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
1047 if (ACPI_FAILURE (Status))
1049 return (Status);
1052 else
1054 /* Just call to the command line interpreter */
1056 AcpiDbSingleThread ();
1061 * Only this thread (the original thread) should actually terminate the
1062 * subsystem, because all the semaphores are deleted during termination
1064 Status = AcpiTerminate ();
1065 return (Status);
1068 #endif /* ACPI_DEBUGGER */