1 /*******************************************************************************
3 * Module Name: dbinput - user front-end to the AML debugger
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2017, 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
267 #define CMD_FIRST_VALID 2
270 /* Second parameter is the required argument count */
272 static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] =
325 #ifdef ACPI_APPLICATION
347 * Help for all debugger commands. First argument is the number of lines
348 * of help to output for the command.
350 static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] =
352 {0, "\nGeneral-Purpose Commands:", "\n"},
353 {1, " Allocations", "Display list of current memory allocations\n"},
354 {2, " Dump <Address>|<Namepath>", "\n"},
355 {0, " [Byte|Word|Dword|Qword]", "Display ACPI objects or memory\n"},
356 {1, " Handlers", "Info about global handlers\n"},
357 {1, " Help [Command]", "This help screen or individual command\n"},
358 {1, " History", "Display command history buffer\n"},
359 {1, " Level <DebugLevel>] [console]", "Get/Set debug level for file or console\n"},
360 {1, " Locks", "Current status of internal mutexes\n"},
361 {1, " Osi [Install|Remove <name>]", "Display or modify global _OSI list\n"},
362 {1, " Quit or Exit", "Exit this command\n"},
363 {8, " Stats <SubCommand>", "Display namespace and memory statistics\n"},
364 {1, " Allocations", "Display list of current memory allocations\n"},
365 {1, " Memory", "Dump internal memory lists\n"},
366 {1, " Misc", "Namespace search and mutex stats\n"},
367 {1, " Objects", "Summary of namespace objects\n"},
368 {1, " Sizes", "Sizes for each of the internal objects\n"},
369 {1, " Stack", "Display CPU stack usage\n"},
370 {1, " Tables", "Info about current ACPI table(s)\n"},
371 {1, " Tables", "Display info about loaded ACPI tables\n"},
372 {1, " ! <CommandNumber>", "Execute command from history buffer\n"},
373 {1, " !!", "Execute last command again\n"},
375 {0, "\nNamespace Access Commands:", "\n"},
376 {1, " Businfo", "Display system bus info\n"},
377 {1, " Disassemble <Method>", "Disassemble a control method\n"},
378 {1, " Find <AcpiName> (? is wildcard)", "Find ACPI name(s) with wildcards\n"},
379 {1, " Integrity", "Validate namespace integrity\n"},
380 {1, " Methods", "Display list of loaded control methods\n"},
381 {1, " Namespace [Object] [Depth]", "Display loaded namespace tree/subtree\n"},
382 {1, " Notify <Object> <Value>", "Send a notification on Object\n"},
383 {1, " Objects [ObjectType]", "Display summary of all objects or just given type\n"},
384 {1, " Owner <OwnerId> [Depth]", "Display loaded namespace by object owner\n"},
385 {1, " Paths", "Display full pathnames of namespace objects\n"},
386 {1, " Predefined", "Check all predefined names\n"},
387 {1, " Prefix [<Namepath>]", "Set or Get current execution prefix\n"},
388 {1, " References <Addr>", "Find all references to object at addr\n"},
389 {1, " Resources [DeviceName]", "Display Device resources (no arg = all devices)\n"},
390 {1, " Set N <NamedObject> <Value>", "Set value for named integer\n"},
391 {1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"},
392 {1, " Type <Object>", "Display object type\n"},
394 {0, "\nControl Method Execution Commands:","\n"},
395 {1, " Arguments (or Args)", "Display method arguments\n"},
396 {1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\n"},
397 {1, " Call", "Run to next control method invocation\n"},
398 {1, " Debug <Namepath> [Arguments]", "Single Step a control method\n"},
399 {6, " Evaluate", "Synonym for Execute\n"},
400 {5, " Execute <Namepath> [Arguments]", "Execute control method\n"},
401 {1, " Hex Integer", "Integer method argument\n"},
402 {1, " \"Ascii String\"", "String method argument\n"},
403 {1, " (Hex Byte List)", "Buffer method argument\n"},
404 {1, " [Package Element List]", "Package method argument\n"},
405 {5, " Execute predefined", "Execute all predefined (public) methods\n"},
406 {1, " Go", "Allow method to run to completion\n"},
407 {1, " Information", "Display info about the current method\n"},
408 {1, " Into", "Step into (not over) a method call\n"},
409 {1, " List [# of Aml Opcodes]", "Display method ASL statements\n"},
410 {1, " Locals", "Display method local variables\n"},
411 {1, " Results", "Display method result stack\n"},
412 {1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"},
413 {1, " Stop", "Terminate control method\n"},
414 {5, " Trace <State> [<Namepath>] [Once]", "Trace control method execution\n"},
415 {1, " Enable", "Enable all messages\n"},
416 {1, " Disable", "Disable tracing\n"},
417 {1, " Method", "Enable method execution messages\n"},
418 {1, " Opcode", "Enable opcode execution messages\n"},
419 {1, " Tree", "Display control method calling tree\n"},
420 {1, " <Enter>", "Single step next AML opcode (over calls)\n"},
422 #ifdef ACPI_APPLICATION
423 {0, "\nHardware Simulation Commands:", "\n"},
424 {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"},
425 {1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"},
426 {1, " Gpe <GpeNum> [GpeBlockDevice]", "Simulate a GPE\n"},
427 {1, " Gpes", "Display info on all GPE devices\n"},
428 {1, " Sci", "Generate an SCI\n"},
429 {1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"},
431 {0, "\nFile I/O Commands:", "\n"},
432 {1, " Close", "Close debug output file\n"},
433 {1, " Load <Input Filename>", "Load ACPI table from a file\n"},
434 {1, " Open <Output Filename>", "Open a file for debug output\n"},
435 {1, " Unload <Namepath>", "Unload an ACPI table via namespace object\n"},
437 {0, "\nUser Space Commands:", "\n"},
438 {1, " Terminate", "Delete namespace and all internal objects\n"},
439 {1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"},
441 {0, "\nDebug Test Commands:", "\n"},
442 {3, " Test <TestName>", "Invoke a debug test\n"},
443 {1, " Objects", "Read/write/compare all namespace data objects\n"},
444 {1, " Predefined", "Execute all ACPI predefined names (_STA, etc.)\n"},
450 /*******************************************************************************
452 * FUNCTION: AcpiDbMatchCommandHelp
454 * PARAMETERS: Command - Command string to match
455 * Help - Help table entry to attempt match
457 * RETURN: TRUE if command matched, FALSE otherwise
459 * DESCRIPTION: Attempt to match a command in the help table in order to
460 * print help information for a single command.
462 ******************************************************************************/
465 AcpiDbMatchCommandHelp (
467 const ACPI_DB_COMMAND_HELP *Help)
469 char *Invocation = Help->Invocation;
473 /* Valid commands in the help table begin with a couple of spaces */
475 if (*Invocation != ' ')
480 while (*Invocation == ' ')
485 /* Match command name (full command or substring) */
487 while ((*Command) && (*Invocation) && (*Invocation != ' '))
489 if (tolower ((int) *Command) != tolower ((int) *Invocation))
498 /* Print the appropriate number of help lines */
500 LineCount = Help->LineCount;
503 AcpiOsPrintf ("%-38s : %s", Help->Invocation, Help->Description);
512 /*******************************************************************************
514 * FUNCTION: AcpiDbDisplayCommandInfo
516 * PARAMETERS: Command - Command string to match
517 * DisplayAll - Display all matching commands, or just
518 * the first one (substring match)
522 * DESCRIPTION: Display help information for a Debugger command.
524 ******************************************************************************/
527 AcpiDbDisplayCommandInfo (
531 const ACPI_DB_COMMAND_HELP *Next;
535 Next = AcpiGbl_DbCommandHelp;
536 while (Next->Invocation)
538 Matched = AcpiDbMatchCommandHelp (Command, Next);
539 if (!DisplayAll && Matched)
549 /*******************************************************************************
551 * FUNCTION: AcpiDbDisplayHelp
553 * PARAMETERS: Command - Optional command string to display help.
554 * if not specified, all debugger command
555 * help strings are displayed
559 * DESCRIPTION: Display help for a single debugger command, or all of them.
561 ******************************************************************************/
567 const ACPI_DB_COMMAND_HELP *Next = AcpiGbl_DbCommandHelp;
572 /* No argument to help, display help for all commands */
574 while (Next->Invocation)
576 AcpiOsPrintf ("%-38s%s", Next->Invocation, Next->Description);
582 /* Display help for all commands that match the subtring */
584 AcpiDbDisplayCommandInfo (Command, TRUE);
589 /*******************************************************************************
591 * FUNCTION: AcpiDbGetNextToken
593 * PARAMETERS: String - Command buffer
594 * Next - Return value, end of next token
596 * RETURN: Pointer to the start of the next token.
598 * DESCRIPTION: Command line parsing. Get the next token on the command line
600 ******************************************************************************/
606 ACPI_OBJECT_TYPE *ReturnType)
610 ACPI_OBJECT_TYPE Type = ACPI_TYPE_INTEGER;
613 /* At end of buffer? */
615 if (!String || !(*String))
620 /* Remove any spaces at the beginning */
624 while (*String && (*String == ' '))
639 /* This is a quoted string, scan until closing quote */
643 Type = ACPI_TYPE_STRING;
645 /* Find end of string */
647 while (*String && (*String != '"'))
655 /* This is the start of a buffer, scan until closing paren */
659 Type = ACPI_TYPE_BUFFER;
661 /* Find end of buffer */
663 while (*String && (*String != ')'))
671 /* This is the start of a package, scan until closing bracket */
676 Type = ACPI_TYPE_PACKAGE;
678 /* Find end of package (closing bracket) */
682 /* Handle String package elements */
686 /* Find end of string */
689 while (*String && (*String != '"'))
698 else if (*String == '[')
700 Depth++; /* A nested package declaration */
702 else if (*String == ']')
705 if (Depth == 0) /* Found final package closing bracket */
719 /* Find end of token */
721 while (*String && (*String != ' '))
743 /*******************************************************************************
745 * FUNCTION: AcpiDbGetLine
747 * PARAMETERS: InputBuffer - Command line buffer
749 * RETURN: Count of arguments to the command
751 * DESCRIPTION: Get the next command line from the user. Gets entire line
752 * up to the next newline
754 ******************************************************************************/
766 if (AcpiUtSafeStrcpy (AcpiGbl_DbParsedBuf, sizeof (AcpiGbl_DbParsedBuf),
770 "Buffer overflow while parsing input line (max %u characters)\n",
771 sizeof (AcpiGbl_DbParsedBuf));
775 This = AcpiGbl_DbParsedBuf;
776 for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
778 AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next,
779 &AcpiGbl_DbArgTypes[i]);
780 if (!AcpiGbl_DbArgs[i])
788 /* Uppercase the actual command */
790 AcpiUtStrupr (AcpiGbl_DbArgs[0]);
795 Count--; /* Number of args only */
802 /*******************************************************************************
804 * FUNCTION: AcpiDbMatchCommand
806 * PARAMETERS: UserCommand - User command line
808 * RETURN: Index into command array, -1 if not found
810 * DESCRIPTION: Search command array for a command match
812 ******************************************************************************/
821 if (!UserCommand || UserCommand[0] == 0)
826 for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
829 ACPI_CAST_PTR (char, AcpiGbl_DbCommands[i].Name), UserCommand) ==
830 AcpiGbl_DbCommands[i].Name)
836 /* Command not recognized */
838 return (CMD_NOT_FOUND);
842 /*******************************************************************************
844 * FUNCTION: AcpiDbCommandDispatch
846 * PARAMETERS: InputBuffer - Command line buffer
847 * WalkState - Current walk
848 * Op - Current (executing) parse op
852 * DESCRIPTION: Command dispatcher.
854 ******************************************************************************/
857 AcpiDbCommandDispatch (
859 ACPI_WALK_STATE *WalkState,
860 ACPI_PARSE_OBJECT *Op)
866 ACPI_STATUS Status = AE_CTRL_TRUE;
869 /* If AcpiTerminate has been called, terminate this thread */
871 if (AcpiGbl_DbTerminateLoop)
873 return (AE_CTRL_TERMINATE);
876 /* Find command and add to the history buffer */
878 ParamCount = AcpiDbGetLine (InputBuffer);
879 CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]);
883 * We don't want to add the !! command to the history buffer. It
884 * would cause an infinite loop because it would always be the
887 if (CommandIndex != CMD_HISTORY_LAST)
889 AcpiDbAddToHistory (InputBuffer);
892 /* Verify that we have the minimum number of params */
894 if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs)
896 AcpiOsPrintf ("%u parameters entered, [%s] requires %u parameters\n",
897 ParamCount, AcpiGbl_DbCommands[CommandIndex].Name,
898 AcpiGbl_DbCommands[CommandIndex].MinArgs);
900 AcpiDbDisplayCommandInfo (
901 AcpiGbl_DbCommands[CommandIndex].Name, FALSE);
902 return (AE_CTRL_TRUE);
905 /* Decode and dispatch the command */
907 switch (CommandIndex)
917 case CMD_ALLOCATIONS:
919 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
920 AcpiUtDumpAllocations ((UINT32) -1, NULL);
927 AcpiDbDisplayArguments ();
932 AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
942 AcpiDbSetMethodCallBreakpoint (Op);
948 AcpiDbExecute (AcpiGbl_DbArgs[1],
949 &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_SINGLE_STEP);
952 case CMD_DISASSEMBLE:
955 (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
960 AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
966 AcpiDbExecute (AcpiGbl_DbArgs[1],
967 &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP);
972 Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
977 AcpiGbl_CmSingleStep = FALSE;
982 AcpiDbDisplayHandlers ();
988 AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
993 AcpiDbDisplayHistory ();
996 case CMD_HISTORY_EXE: /* ! command */
998 CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
1001 return (AE_CTRL_TRUE);
1004 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
1007 case CMD_HISTORY_LAST: /* !! command */
1009 CommandLine = AcpiDbGetFromHistory (NULL);
1012 return (AE_CTRL_TRUE);
1015 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
1018 case CMD_INFORMATION:
1020 AcpiDbDisplayMethodInfo (Op);
1025 AcpiDbCheckIntegrity ();
1032 AcpiGbl_CmSingleStep = TRUE;
1039 if (ParamCount == 0)
1042 "Current debug level for file output is: %8.8lX\n",
1043 AcpiGbl_DbDebugLevel);
1045 "Current debug level for console output is: %8.8lX\n",
1046 AcpiGbl_DbConsoleDebugLevel);
1048 else if (ParamCount == 2)
1050 Temp = AcpiGbl_DbConsoleDebugLevel;
1051 AcpiGbl_DbConsoleDebugLevel =
1052 strtoul (AcpiGbl_DbArgs[1], NULL, 16);
1054 "Debug Level for console output was %8.8lX, now %8.8lX\n",
1055 Temp, AcpiGbl_DbConsoleDebugLevel);
1059 Temp = AcpiGbl_DbDebugLevel;
1060 AcpiGbl_DbDebugLevel = strtoul (AcpiGbl_DbArgs[1], NULL, 16);
1062 "Debug Level for file output was %8.8lX, now %8.8lX\n",
1063 Temp, AcpiGbl_DbDebugLevel);
1069 AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
1074 AcpiDbDisplayLocks ();
1079 AcpiDbDisplayLocals ();
1084 Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
1089 AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1094 Temp = strtoul (AcpiGbl_DbArgs[2], NULL, 0);
1095 AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
1100 AcpiUtStrupr (AcpiGbl_DbArgs[1]);
1101 Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1106 AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1111 AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1116 AcpiDbDumpNamespacePaths ();
1121 AcpiDbSetScope (AcpiGbl_DbArgs[1]);
1124 case CMD_REFERENCES:
1126 AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
1131 AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
1136 AcpiDbDisplayResults ();
1141 AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
1147 Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
1152 return (AE_NOT_IMPLEMENTED);
1156 AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
1161 AcpiDbDisplayTemplate (AcpiGbl_DbArgs[1]);
1166 AcpiDbTrace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]);
1171 AcpiDbDisplayCallingTree ();
1176 AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
1179 #ifdef ACPI_APPLICATION
1181 /* Hardware simulation commands. */
1183 case CMD_ENABLEACPI:
1184 #if (!ACPI_REDUCED_HARDWARE)
1186 Status = AcpiEnable();
1187 if (ACPI_FAILURE(Status))
1189 AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
1192 #endif /* !ACPI_REDUCED_HARDWARE */
1197 AcpiOsPrintf ("Event command not implemented\n");
1202 AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1207 AcpiDbDisplayGpes ();
1212 AcpiDbGenerateSci ();
1217 Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
1220 /* File I/O commands. */
1224 AcpiDbCloseDebugFile ();
1229 ACPI_NEW_TABLE_DESC *ListHead = NULL;
1231 Status = AcGetAllTablesFromFile (AcpiGbl_DbArgs[1],
1232 ACPI_GET_ALL_TABLES, &ListHead);
1233 if (ACPI_SUCCESS (Status))
1235 AcpiDbLoadTables (ListHead);
1242 AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
1245 /* User space commands. */
1249 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1250 AcpiUtSubsystemShutdown ();
1253 * TBD: [Restructure] Need some way to re-initialize without
1254 * re-creating the semaphores!
1257 AcpiGbl_DbTerminateLoop = TRUE;
1258 /* AcpiInitialize (NULL); */
1263 AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
1267 /* Debug test commands. */
1269 case CMD_PREDEFINED:
1271 AcpiDbCheckPredefinedNames ();
1276 AcpiDbExecuteTest (AcpiGbl_DbArgs[1]);
1281 AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1]);
1290 AcpiOsPrintf ("Method execution terminated\n");
1291 return (AE_CTRL_TERMINATE);
1294 if (!AcpiGbl_DbOutputToFile)
1296 AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
1299 #ifdef ACPI_APPLICATION
1300 AcpiDbCloseDebugFile ();
1302 AcpiGbl_DbTerminateLoop = TRUE;
1303 return (AE_CTRL_TERMINATE);
1308 AcpiOsPrintf ("%s: unknown command\n", AcpiGbl_DbArgs[0]);
1309 return (AE_CTRL_TRUE);
1312 if (ACPI_SUCCESS (Status))
1314 Status = AE_CTRL_TRUE;
1321 /*******************************************************************************
1323 * FUNCTION: AcpiDbExecuteThread
1325 * PARAMETERS: Context - Not used
1329 * DESCRIPTION: Debugger execute thread. Waits for a command line, then
1330 * simply dispatches it.
1332 ******************************************************************************/
1334 void ACPI_SYSTEM_XFACE
1335 AcpiDbExecuteThread (
1339 (void) AcpiDbUserCommands ();
1340 AcpiGbl_DbThreadsTerminated = TRUE;
1344 /*******************************************************************************
1346 * FUNCTION: AcpiDbUserCommands
1352 * DESCRIPTION: Command line execution for the AML debugger. Commands are
1353 * matched and dispatched here.
1355 ******************************************************************************/
1358 AcpiDbUserCommands (
1361 ACPI_STATUS Status = AE_OK;
1364 AcpiOsPrintf ("\n");
1366 /* TBD: [Restructure] Need a separate command line buffer for step mode */
1368 while (!AcpiGbl_DbTerminateLoop)
1370 /* Wait the readiness of the command */
1372 Status = AcpiOsWaitCommandReady ();
1373 if (ACPI_FAILURE (Status))
1378 /* Just call to the command line interpreter */
1380 AcpiGbl_MethodExecuting = FALSE;
1381 AcpiGbl_StepToNextCall = FALSE;
1383 (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
1385 /* Notify the completion of the command */
1387 Status = AcpiOsNotifyCommandComplete ();
1388 if (ACPI_FAILURE (Status))
1394 if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
1396 ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));