1 /*******************************************************************************
3 * Module Name: dbinput - user front-end to the AML debugger
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
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
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
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;
37 * The above copyright and patent license is granted only if the following
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.
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
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
72 * 3.4. Intel retains all right, title, and interest in and to the Original
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.
80 * 4. Disclaimer and Export Compliance
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
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
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.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
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.
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.
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.
150 *****************************************************************************/
152 #include <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/acdebug.h>
156 #ifdef ACPI_APPLICATION
157 #include <contrib/dev/acpica/include/acapps.h>
160 #define _COMPONENT ACPI_CA_DEBUGGER
161 ACPI_MODULE_NAME ("dbinput")
164 /* Local prototypes */
175 AcpiDbDisplayCommandInfo (
184 AcpiDbMatchCommandHelp (
186 const ACPI_DB_COMMAND_HELP *Help);
190 * Top-level debugger commands.
192 * This list of commands must match the string table below it
194 enum AcpiExDebuggerCommands
247 #ifdef ACPI_APPLICATION
268 #define CMD_FIRST_VALID 2
271 /* Second parameter is the required argument count */
273 static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] =
326 #ifdef ACPI_APPLICATION
349 * Help for all debugger commands. First argument is the number of lines
350 * of help to output for the command.
352 * Note: Some commands are not supported by the kernel-level version of
355 static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] =
357 {0, "\nNamespace Access:", "\n"},
358 {1, " Businfo", "Display system bus info\n"},
359 {1, " Disassemble <Method>", "Disassemble a control method\n"},
360 {1, " Find <AcpiName> (? is wildcard)", "Find ACPI name(s) with wildcards\n"},
361 {1, " Integrity", "Validate namespace integrity\n"},
362 {1, " Methods", "Display list of loaded control methods\n"},
363 {1, " Namespace [Object] [Depth]", "Display loaded namespace tree/subtree\n"},
364 {1, " Notify <Object> <Value>", "Send a notification on Object\n"},
365 {1, " Objects [ObjectType]", "Display summary of all objects or just given type\n"},
366 {1, " Owner <OwnerId> [Depth]", "Display loaded namespace by object owner\n"},
367 {1, " Paths", "Display full pathnames of namespace objects\n"},
368 {1, " Predefined", "Check all predefined names\n"},
369 {1, " Prefix [<Namepath>]", "Set or Get current execution prefix\n"},
370 {1, " References <Addr>", "Find all references to object at addr\n"},
371 {1, " Resources [DeviceName]", "Display Device resources (no arg = all devices)\n"},
372 {1, " Set N <NamedObject> <Value>", "Set value for named integer\n"},
373 {1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"},
374 {1, " Type <Object>", "Display object type\n"},
376 {0, "\nControl Method Execution:", "\n"},
377 {1, " Evaluate <Namepath> [Arguments]", "Evaluate object or control method\n"},
378 {1, " Execute <Namepath> [Arguments]", "Synonym for Evaluate\n"},
379 #ifdef ACPI_APPLICATION
380 {1, " Background <Namepath> [Arguments]", "Evaluate object/method in a separate thread\n"},
381 {1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"},
383 {1, " Debug <Namepath> [Arguments]", "Single-Step a control method\n"},
384 {7, " [Arguments] formats:", "Control method argument formats\n"},
385 {1, " Hex Integer", "Integer\n"},
386 {1, " \"Ascii String\"", "String\n"},
387 {1, " (Hex Byte List)", "Buffer\n"},
388 {1, " (01 42 7A BF)", "Buffer example (4 bytes)\n"},
389 {1, " [Package Element List]", "Package\n"},
390 {1, " [0x01 0x1234 \"string\"]", "Package example (3 elements)\n"},
392 {0, "\nMiscellaneous:", "\n"},
393 {1, " Allocations", "Display list of current memory allocations\n"},
394 {2, " Dump <Address>|<Namepath>", "\n"},
395 {0, " [Byte|Word|Dword|Qword]", "Display ACPI objects or memory\n"},
396 {1, " Handlers", "Info about global handlers\n"},
397 {1, " Help [Command]", "This help screen or individual command\n"},
398 {1, " History", "Display command history buffer\n"},
399 {1, " Level <DebugLevel>] [console]", "Get/Set debug level for file or console\n"},
400 {1, " Locks", "Current status of internal mutexes\n"},
401 {1, " Osi [Install|Remove <name>]", "Display or modify global _OSI list\n"},
402 {1, " Quit or Exit", "Exit this command\n"},
403 {8, " Stats <SubCommand>", "Display namespace and memory statistics\n"},
404 {1, " Allocations", "Display list of current memory allocations\n"},
405 {1, " Memory", "Dump internal memory lists\n"},
406 {1, " Misc", "Namespace search and mutex stats\n"},
407 {1, " Objects", "Summary of namespace objects\n"},
408 {1, " Sizes", "Sizes for each of the internal objects\n"},
409 {1, " Stack", "Display CPU stack usage\n"},
410 {1, " Tables", "Info about current ACPI table(s)\n"},
411 {1, " Tables", "Display info about loaded ACPI tables\n"},
412 #ifdef ACPI_APPLICATION
413 {1, " Terminate", "Delete namespace and all internal objects\n"},
415 {1, " ! <CommandNumber>", "Execute command from history buffer\n"},
416 {1, " !!", "Execute last command again\n"},
418 {0, "\nMethod and Namespace Debugging:", "\n"},
419 {5, " Trace <State> [<Namepath>] [Once]", "Trace control method execution\n"},
420 {1, " Enable", "Enable all messages\n"},
421 {1, " Disable", "Disable tracing\n"},
422 {1, " Method", "Enable method execution messages\n"},
423 {1, " Opcode", "Enable opcode execution messages\n"},
424 {3, " Test <TestName>", "Invoke a debug test\n"},
425 {1, " Objects", "Read/write/compare all namespace data objects\n"},
426 {1, " Predefined", "Validate all ACPI predefined names (_STA, etc.)\n"},
427 {1, " Execute predefined", "Execute all predefined (public) methods\n"},
429 {0, "\nControl Method Single-Step Execution:","\n"},
430 {1, " Arguments (or Args)", "Display method arguments\n"},
431 {1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\n"},
432 {1, " Call", "Run to next control method invocation\n"},
433 {1, " Go", "Allow method to run to completion\n"},
434 {1, " Information", "Display info about the current method\n"},
435 {1, " Into", "Step into (not over) a method call\n"},
436 {1, " List [# of Aml Opcodes]", "Display method ASL statements\n"},
437 {1, " Locals", "Display method local variables\n"},
438 {1, " Results", "Display method result stack\n"},
439 {1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"},
440 {1, " Stop", "Terminate control method\n"},
441 {1, " Tree", "Display control method calling tree\n"},
442 {1, " <Enter>", "Single step next AML opcode (over calls)\n"},
444 #ifdef ACPI_APPLICATION
445 {0, "\nFile Operations:", "\n"},
446 {1, " Close", "Close debug output file\n"},
447 {1, " Load <Input Filename>", "Load ACPI table from a file\n"},
448 {1, " Open <Output Filename>", "Open a file for debug output\n"},
449 {1, " Unload <Namepath>", "Unload an ACPI table via namespace object\n"},
451 {0, "\nHardware Simulation:", "\n"},
452 {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"},
453 {1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"},
454 {1, " Gpe <GpeNum> [GpeBlockDevice]", "Simulate a GPE\n"},
455 {1, " Gpes", "Display info on all GPE devices\n"},
456 {1, " Sci", "Generate an SCI\n"},
457 {1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"},
463 /*******************************************************************************
465 * FUNCTION: AcpiDbMatchCommandHelp
467 * PARAMETERS: Command - Command string to match
468 * Help - Help table entry to attempt match
470 * RETURN: TRUE if command matched, FALSE otherwise
472 * DESCRIPTION: Attempt to match a command in the help table in order to
473 * print help information for a single command.
475 ******************************************************************************/
478 AcpiDbMatchCommandHelp (
480 const ACPI_DB_COMMAND_HELP *Help)
482 char *Invocation = Help->Invocation;
486 /* Valid commands in the help table begin with a couple of spaces */
488 if (*Invocation != ' ')
493 while (*Invocation == ' ')
498 /* Match command name (full command or substring) */
500 while ((*Command) && (*Invocation) && (*Invocation != ' '))
502 if (tolower ((int) *Command) != tolower ((int) *Invocation))
511 /* Print the appropriate number of help lines */
513 LineCount = Help->LineCount;
516 AcpiOsPrintf ("%-38s : %s", Help->Invocation, Help->Description);
525 /*******************************************************************************
527 * FUNCTION: AcpiDbDisplayCommandInfo
529 * PARAMETERS: Command - Command string to match
530 * DisplayAll - Display all matching commands, or just
531 * the first one (substring match)
535 * DESCRIPTION: Display help information for a Debugger command.
537 ******************************************************************************/
540 AcpiDbDisplayCommandInfo (
544 const ACPI_DB_COMMAND_HELP *Next;
548 Next = AcpiGbl_DbCommandHelp;
549 while (Next->Invocation)
551 Matched = AcpiDbMatchCommandHelp (Command, Next);
552 if (!DisplayAll && Matched)
562 /*******************************************************************************
564 * FUNCTION: AcpiDbDisplayHelp
566 * PARAMETERS: Command - Optional command string to display help.
567 * if not specified, all debugger command
568 * help strings are displayed
572 * DESCRIPTION: Display help for a single debugger command, or all of them.
574 ******************************************************************************/
580 const ACPI_DB_COMMAND_HELP *Next = AcpiGbl_DbCommandHelp;
585 /* No argument to help, display help for all commands */
587 AcpiOsPrintf ("\nSummary of AML Debugger Commands\n\n");
589 while (Next->Invocation)
591 AcpiOsPrintf ("%-38s%s", Next->Invocation, Next->Description);
599 /* Display help for all commands that match the subtring */
601 AcpiDbDisplayCommandInfo (Command, TRUE);
606 /*******************************************************************************
608 * FUNCTION: AcpiDbGetNextToken
610 * PARAMETERS: String - Command buffer
611 * Next - Return value, end of next token
613 * RETURN: Pointer to the start of the next token.
615 * DESCRIPTION: Command line parsing. Get the next token on the command line
617 ******************************************************************************/
623 ACPI_OBJECT_TYPE *ReturnType)
627 ACPI_OBJECT_TYPE Type = ACPI_TYPE_INTEGER;
630 /* At end of buffer? */
632 if (!String || !(*String))
637 /* Remove any spaces at the beginning */
641 while (*String && (*String == ' '))
656 /* This is a quoted string, scan until closing quote */
660 Type = ACPI_TYPE_STRING;
662 /* Find end of string */
664 while (*String && (*String != '"'))
672 /* This is the start of a buffer, scan until closing paren */
676 Type = ACPI_TYPE_BUFFER;
678 /* Find end of buffer */
680 while (*String && (*String != ')'))
688 /* This is the start of a package, scan until closing bracket */
693 Type = ACPI_TYPE_PACKAGE;
695 /* Find end of package (closing bracket) */
699 /* Handle String package elements */
703 /* Find end of string */
706 while (*String && (*String != '"'))
715 else if (*String == '[')
717 Depth++; /* A nested package declaration */
719 else if (*String == ']')
722 if (Depth == 0) /* Found final package closing bracket */
736 /* Find end of token */
738 while (*String && (*String != ' '))
760 /*******************************************************************************
762 * FUNCTION: AcpiDbGetLine
764 * PARAMETERS: InputBuffer - Command line buffer
766 * RETURN: Count of arguments to the command
768 * DESCRIPTION: Get the next command line from the user. Gets entire line
769 * up to the next newline
771 ******************************************************************************/
783 if (AcpiUtSafeStrcpy (AcpiGbl_DbParsedBuf, sizeof (AcpiGbl_DbParsedBuf),
787 "Buffer overflow while parsing input line (max %u characters)\n",
788 sizeof (AcpiGbl_DbParsedBuf));
792 This = AcpiGbl_DbParsedBuf;
793 for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
795 AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next,
796 &AcpiGbl_DbArgTypes[i]);
797 if (!AcpiGbl_DbArgs[i])
805 /* Uppercase the actual command */
807 AcpiUtStrupr (AcpiGbl_DbArgs[0]);
812 Count--; /* Number of args only */
819 /*******************************************************************************
821 * FUNCTION: AcpiDbMatchCommand
823 * PARAMETERS: UserCommand - User command line
825 * RETURN: Index into command array, -1 if not found
827 * DESCRIPTION: Search command array for a command match
829 ******************************************************************************/
838 if (!UserCommand || UserCommand[0] == 0)
843 for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
846 ACPI_CAST_PTR (char, AcpiGbl_DbCommands[i].Name), UserCommand) ==
847 AcpiGbl_DbCommands[i].Name)
853 /* Command not recognized */
855 return (CMD_NOT_FOUND);
859 /*******************************************************************************
861 * FUNCTION: AcpiDbCommandDispatch
863 * PARAMETERS: InputBuffer - Command line buffer
864 * WalkState - Current walk
865 * Op - Current (executing) parse op
869 * DESCRIPTION: Command dispatcher.
871 ******************************************************************************/
874 AcpiDbCommandDispatch (
876 ACPI_WALK_STATE *WalkState,
877 ACPI_PARSE_OBJECT *Op)
883 ACPI_STATUS Status = AE_CTRL_TRUE;
886 /* If AcpiTerminate has been called, terminate this thread */
888 if (AcpiGbl_DbTerminateLoop)
890 return (AE_CTRL_TERMINATE);
893 /* Find command and add to the history buffer */
895 ParamCount = AcpiDbGetLine (InputBuffer);
896 CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]);
900 * We don't want to add the !! command to the history buffer. It
901 * would cause an infinite loop because it would always be the
904 if (CommandIndex != CMD_HISTORY_LAST)
906 AcpiDbAddToHistory (InputBuffer);
909 /* Verify that we have the minimum number of params */
911 if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs)
913 AcpiOsPrintf ("%u parameters entered, [%s] requires %u parameters\n",
914 ParamCount, AcpiGbl_DbCommands[CommandIndex].Name,
915 AcpiGbl_DbCommands[CommandIndex].MinArgs);
917 AcpiDbDisplayCommandInfo (
918 AcpiGbl_DbCommands[CommandIndex].Name, FALSE);
919 return (AE_CTRL_TRUE);
922 /* Decode and dispatch the command */
924 switch (CommandIndex)
934 case CMD_ALLOCATIONS:
936 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
937 AcpiUtDumpAllocations ((UINT32) -1, NULL);
944 AcpiDbDisplayArguments ();
949 AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
959 AcpiDbSetMethodCallBreakpoint (Op);
965 AcpiDbExecute (AcpiGbl_DbArgs[1],
966 &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_SINGLE_STEP);
969 case CMD_DISASSEMBLE:
972 #ifdef ACPI_DISASSEMBLER
973 (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
975 AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
981 AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
987 AcpiDbExecute (AcpiGbl_DbArgs[1],
988 &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP);
993 Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
998 AcpiGbl_CmSingleStep = FALSE;
1003 AcpiDbDisplayHandlers ();
1009 AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
1014 AcpiDbDisplayHistory ();
1017 case CMD_HISTORY_EXE: /* ! command */
1019 CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
1022 return (AE_CTRL_TRUE);
1025 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
1028 case CMD_HISTORY_LAST: /* !! command */
1030 CommandLine = AcpiDbGetFromHistory (NULL);
1033 return (AE_CTRL_TRUE);
1036 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
1039 case CMD_INFORMATION:
1041 AcpiDbDisplayMethodInfo (Op);
1046 AcpiDbCheckIntegrity ();
1053 AcpiGbl_CmSingleStep = TRUE;
1060 if (ParamCount == 0)
1063 "Current debug level for file output is: %8.8lX\n",
1064 AcpiGbl_DbDebugLevel);
1066 "Current debug level for console output is: %8.8lX\n",
1067 AcpiGbl_DbConsoleDebugLevel);
1069 else if (ParamCount == 2)
1071 Temp = AcpiGbl_DbConsoleDebugLevel;
1072 AcpiGbl_DbConsoleDebugLevel =
1073 strtoul (AcpiGbl_DbArgs[1], NULL, 16);
1075 "Debug Level for console output was %8.8lX, now %8.8lX\n",
1076 Temp, AcpiGbl_DbConsoleDebugLevel);
1080 Temp = AcpiGbl_DbDebugLevel;
1081 AcpiGbl_DbDebugLevel = strtoul (AcpiGbl_DbArgs[1], NULL, 16);
1083 "Debug Level for file output was %8.8lX, now %8.8lX\n",
1084 Temp, AcpiGbl_DbDebugLevel);
1090 #ifdef ACPI_DISASSEMBLER
1091 AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
1093 AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
1099 AcpiDbDisplayLocks ();
1104 AcpiDbDisplayLocals ();
1109 Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
1114 AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1119 Temp = strtoul (AcpiGbl_DbArgs[2], NULL, 0);
1120 AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
1125 AcpiUtStrupr (AcpiGbl_DbArgs[1]);
1126 Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1131 AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1136 AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1141 AcpiDbDumpNamespacePaths ();
1146 AcpiDbSetScope (AcpiGbl_DbArgs[1]);
1149 case CMD_REFERENCES:
1151 AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
1156 AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
1161 AcpiDbDisplayResults ();
1166 AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
1172 Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
1177 return (AE_NOT_IMPLEMENTED);
1181 AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
1186 AcpiDbDisplayTemplate (AcpiGbl_DbArgs[1]);
1191 AcpiDbTrace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]);
1196 AcpiDbDisplayCallingTree ();
1201 AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
1204 #ifdef ACPI_APPLICATION
1206 /* Hardware simulation commands. */
1208 case CMD_ENABLEACPI:
1209 #if (!ACPI_REDUCED_HARDWARE)
1211 Status = AcpiEnable();
1212 if (ACPI_FAILURE(Status))
1214 AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
1217 #endif /* !ACPI_REDUCED_HARDWARE */
1222 AcpiOsPrintf ("Event command not implemented\n");
1227 AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1232 AcpiDbDisplayGpes ();
1237 AcpiDbGenerateSci ();
1242 Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
1245 /* File I/O commands. */
1249 AcpiDbCloseDebugFile ();
1254 ACPI_NEW_TABLE_DESC *ListHead = NULL;
1256 Status = AcGetAllTablesFromFile (AcpiGbl_DbArgs[1],
1257 ACPI_GET_ALL_TABLES, &ListHead);
1258 if (ACPI_SUCCESS (Status))
1260 AcpiDbLoadTables (ListHead);
1267 AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
1270 /* User space commands. */
1274 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1275 AcpiUtSubsystemShutdown ();
1278 * TBD: [Restructure] Need some way to re-initialize without
1279 * re-creating the semaphores!
1282 AcpiGbl_DbTerminateLoop = TRUE;
1283 /* AcpiInitialize (NULL); */
1286 case CMD_BACKGROUND:
1288 AcpiDbCreateExecutionThread (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2],
1289 &AcpiGbl_DbArgTypes[2]);
1294 AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
1298 /* Debug test commands. */
1300 case CMD_PREDEFINED:
1302 AcpiDbCheckPredefinedNames ();
1307 AcpiDbExecuteTest (AcpiGbl_DbArgs[1]);
1312 AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1]);
1321 AcpiOsPrintf ("Method execution terminated\n");
1322 return (AE_CTRL_TERMINATE);
1325 if (!AcpiGbl_DbOutputToFile)
1327 AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
1330 #ifdef ACPI_APPLICATION
1331 AcpiDbCloseDebugFile ();
1333 AcpiGbl_DbTerminateLoop = TRUE;
1334 return (AE_CTRL_TERMINATE);
1339 AcpiOsPrintf ("%s: unknown command\n", AcpiGbl_DbArgs[0]);
1340 return (AE_CTRL_TRUE);
1343 if (ACPI_SUCCESS (Status))
1345 Status = AE_CTRL_TRUE;
1352 /*******************************************************************************
1354 * FUNCTION: AcpiDbExecuteThread
1356 * PARAMETERS: Context - Not used
1360 * DESCRIPTION: Debugger execute thread. Waits for a command line, then
1361 * simply dispatches it.
1363 ******************************************************************************/
1365 void ACPI_SYSTEM_XFACE
1366 AcpiDbExecuteThread (
1370 (void) AcpiDbUserCommands ();
1371 AcpiGbl_DbThreadsTerminated = TRUE;
1375 /*******************************************************************************
1377 * FUNCTION: AcpiDbUserCommands
1383 * DESCRIPTION: Command line execution for the AML debugger. Commands are
1384 * matched and dispatched here.
1386 ******************************************************************************/
1389 AcpiDbUserCommands (
1392 ACPI_STATUS Status = AE_OK;
1395 AcpiOsPrintf ("\n");
1397 /* TBD: [Restructure] Need a separate command line buffer for step mode */
1399 while (!AcpiGbl_DbTerminateLoop)
1401 /* Wait the readiness of the command */
1403 Status = AcpiOsWaitCommandReady ();
1404 if (ACPI_FAILURE (Status))
1409 /* Just call to the command line interpreter */
1411 AcpiGbl_MethodExecuting = FALSE;
1412 AcpiGbl_StepToNextCall = FALSE;
1414 (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
1416 /* Notify the completion of the command */
1418 Status = AcpiOsNotifyCommandComplete ();
1419 if (ACPI_FAILURE (Status))
1425 if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
1427 ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));