1 /*******************************************************************************
3 * Module Name: dbinput - user front-end to the AML debugger
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2020, 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
249 #ifdef ACPI_APPLICATION
270 #define CMD_FIRST_VALID 2
273 /* Second parameter is the required argument count */
275 static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] =
330 #ifdef ACPI_APPLICATION
353 * Help for all debugger commands. First argument is the number of lines
354 * of help to output for the command.
356 * Note: Some commands are not supported by the kernel-level version of
359 static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] =
361 {0, "\nNamespace Access:", "\n"},
362 {1, " Businfo", "Display system bus info\n"},
363 {1, " Disassemble <Method>", "Disassemble a control method\n"},
364 {1, " Find <AcpiName> (? is wildcard)", "Find ACPI name(s) with wildcards\n"},
365 {1, " Integrity", "Validate namespace integrity\n"},
366 {1, " Methods", "Display list of loaded control methods\n"},
367 {1, " Fields <AddressSpaceId>", "Display list of loaded field units by space ID\n"},
368 {1, " Namespace [Object] [Depth]", "Display loaded namespace tree/subtree\n"},
369 {1, " Notify <Object> <Value>", "Send a notification on Object\n"},
370 {1, " Objects [ObjectType]", "Display summary of all objects or just given type\n"},
371 {1, " Owner <OwnerId> [Depth]", "Display loaded namespace by object owner\n"},
372 {1, " Paths", "Display full pathnames of namespace objects\n"},
373 {1, " Predefined", "Check all predefined names\n"},
374 {1, " Prefix [<Namepath>]", "Set or Get current execution prefix\n"},
375 {1, " References <Addr>", "Find all references to object at addr\n"},
376 {1, " Resources [DeviceName]", "Display Device resources (no arg = all devices)\n"},
377 {1, " Set N <NamedObject> <Value>", "Set value for named integer\n"},
378 {1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"},
379 {1, " Type <Object>", "Display object type\n"},
381 {0, "\nControl Method Execution:", "\n"},
382 {1, " All <NameSeg>", "Evaluate all objects named NameSeg\n"},
383 {1, " Evaluate <Namepath> [Arguments]", "Evaluate object or control method\n"},
384 {1, " Execute <Namepath> [Arguments]", "Synonym for Evaluate\n"},
385 #ifdef ACPI_APPLICATION
386 {1, " Background <Namepath> [Arguments]", "Evaluate object/method in a separate thread\n"},
387 {1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"},
389 {1, " Debug <Namepath> [Arguments]", "Single-Step a control method\n"},
390 {7, " [Arguments] formats:", "Control method argument formats\n"},
391 {1, " Hex Integer", "Integer\n"},
392 {1, " \"Ascii String\"", "String\n"},
393 {1, " (Hex Byte List)", "Buffer\n"},
394 {1, " (01 42 7A BF)", "Buffer example (4 bytes)\n"},
395 {1, " [Package Element List]", "Package\n"},
396 {1, " [0x01 0x1234 \"string\"]", "Package example (3 elements)\n"},
398 {0, "\nMiscellaneous:", "\n"},
399 {1, " Allocations", "Display list of current memory allocations\n"},
400 {2, " Dump <Address>|<Namepath>", "\n"},
401 {0, " [Byte|Word|Dword|Qword]", "Display ACPI objects or memory\n"},
402 {1, " Handlers", "Info about global handlers\n"},
403 {1, " Help [Command]", "This help screen or individual command\n"},
404 {1, " History", "Display command history buffer\n"},
405 {1, " Level <DebugLevel>] [console]", "Get/Set debug level for file or console\n"},
406 {1, " Locks", "Current status of internal mutexes\n"},
407 {1, " Osi [Install|Remove <name>]", "Display or modify global _OSI list\n"},
408 {1, " Quit or Exit", "Exit this command\n"},
409 {8, " Stats <SubCommand>", "Display namespace and memory statistics\n"},
410 {1, " Allocations", "Display list of current memory allocations\n"},
411 {1, " Memory", "Dump internal memory lists\n"},
412 {1, " Misc", "Namespace search and mutex stats\n"},
413 {1, " Objects", "Summary of namespace objects\n"},
414 {1, " Sizes", "Sizes for each of the internal objects\n"},
415 {1, " Stack", "Display CPU stack usage\n"},
416 {1, " Tables", "Info about current ACPI table(s)\n"},
417 {1, " Tables", "Display info about loaded ACPI tables\n"},
418 #ifdef ACPI_APPLICATION
419 {1, " Terminate", "Delete namespace and all internal objects\n"},
421 {1, " ! <CommandNumber>", "Execute command from history buffer\n"},
422 {1, " !!", "Execute last command again\n"},
424 {0, "\nMethod and Namespace Debugging:", "\n"},
425 {5, " Trace <State> [<Namepath>] [Once]", "Trace control method execution\n"},
426 {1, " Enable", "Enable all messages\n"},
427 {1, " Disable", "Disable tracing\n"},
428 {1, " Method", "Enable method execution messages\n"},
429 {1, " Opcode", "Enable opcode execution messages\n"},
430 {3, " Test <TestName>", "Invoke a debug test\n"},
431 {1, " Objects", "Read/write/compare all namespace data objects\n"},
432 {1, " Predefined", "Validate all ACPI predefined names (_STA, etc.)\n"},
433 {1, " Execute predefined", "Execute all predefined (public) methods\n"},
435 {0, "\nControl Method Single-Step Execution:","\n"},
436 {1, " Arguments (or Args)", "Display method arguments\n"},
437 {1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\n"},
438 {1, " Call", "Run to next control method invocation\n"},
439 {1, " Go", "Allow method to run to completion\n"},
440 {1, " Information", "Display info about the current method\n"},
441 {1, " Into", "Step into (not over) a method call\n"},
442 {1, " List [# of Aml Opcodes]", "Display method ASL statements\n"},
443 {1, " Locals", "Display method local variables\n"},
444 {1, " Results", "Display method result stack\n"},
445 {1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"},
446 {1, " Stop", "Terminate control method\n"},
447 {1, " Tree", "Display control method calling tree\n"},
448 {1, " <Enter>", "Single step next AML opcode (over calls)\n"},
450 #ifdef ACPI_APPLICATION
451 {0, "\nFile Operations:", "\n"},
452 {1, " Close", "Close debug output file\n"},
453 {1, " Load <Input Filename>", "Load ACPI table from a file\n"},
454 {1, " Open <Output Filename>", "Open a file for debug output\n"},
455 {1, " Unload <Namepath>", "Unload an ACPI table via namespace object\n"},
457 {0, "\nHardware Simulation:", "\n"},
458 {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"},
459 {1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"},
460 {1, " Gpe <GpeNum> [GpeBlockDevice]", "Simulate a GPE\n"},
461 {1, " Gpes", "Display info on all GPE devices\n"},
462 {1, " Sci", "Generate an SCI\n"},
463 {1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"},
469 /*******************************************************************************
471 * FUNCTION: AcpiDbMatchCommandHelp
473 * PARAMETERS: Command - Command string to match
474 * Help - Help table entry to attempt match
476 * RETURN: TRUE if command matched, FALSE otherwise
478 * DESCRIPTION: Attempt to match a command in the help table in order to
479 * print help information for a single command.
481 ******************************************************************************/
484 AcpiDbMatchCommandHelp (
486 const ACPI_DB_COMMAND_HELP *Help)
488 char *Invocation = Help->Invocation;
492 /* Valid commands in the help table begin with a couple of spaces */
494 if (*Invocation != ' ')
499 while (*Invocation == ' ')
504 /* Match command name (full command or substring) */
506 while ((*Command) && (*Invocation) && (*Invocation != ' '))
508 if (tolower ((int) *Command) != tolower ((int) *Invocation))
517 /* Print the appropriate number of help lines */
519 LineCount = Help->LineCount;
522 AcpiOsPrintf ("%-38s : %s", Help->Invocation, Help->Description);
531 /*******************************************************************************
533 * FUNCTION: AcpiDbDisplayCommandInfo
535 * PARAMETERS: Command - Command string to match
536 * DisplayAll - Display all matching commands, or just
537 * the first one (substring match)
541 * DESCRIPTION: Display help information for a Debugger command.
543 ******************************************************************************/
546 AcpiDbDisplayCommandInfo (
550 const ACPI_DB_COMMAND_HELP *Next;
554 Next = AcpiGbl_DbCommandHelp;
555 while (Next->Invocation)
557 Matched = AcpiDbMatchCommandHelp (Command, Next);
558 if (!DisplayAll && Matched)
568 /*******************************************************************************
570 * FUNCTION: AcpiDbDisplayHelp
572 * PARAMETERS: Command - Optional command string to display help.
573 * if not specified, all debugger command
574 * help strings are displayed
578 * DESCRIPTION: Display help for a single debugger command, or all of them.
580 ******************************************************************************/
586 const ACPI_DB_COMMAND_HELP *Next = AcpiGbl_DbCommandHelp;
591 /* No argument to help, display help for all commands */
593 AcpiOsPrintf ("\nSummary of AML Debugger Commands\n\n");
595 while (Next->Invocation)
597 AcpiOsPrintf ("%-38s%s", Next->Invocation, Next->Description);
605 /* Display help for all commands that match the substring */
607 AcpiDbDisplayCommandInfo (Command, TRUE);
612 /*******************************************************************************
614 * FUNCTION: AcpiDbGetNextToken
616 * PARAMETERS: String - Command buffer
617 * Next - Return value, end of next token
619 * RETURN: Pointer to the start of the next token.
621 * DESCRIPTION: Command line parsing. Get the next token on the command line
623 ******************************************************************************/
629 ACPI_OBJECT_TYPE *ReturnType)
633 ACPI_OBJECT_TYPE Type = ACPI_TYPE_INTEGER;
636 /* At end of buffer? */
638 if (!String || !(*String))
643 /* Remove any spaces at the beginning, ignore blank lines */
645 while (*String && isspace (*String))
659 /* This is a quoted string, scan until closing quote */
663 Type = ACPI_TYPE_STRING;
665 /* Find end of string */
667 while (*String && (*String != '"'))
675 /* This is the start of a buffer, scan until closing paren */
679 Type = ACPI_TYPE_BUFFER;
681 /* Find end of buffer */
683 while (*String && (*String != ')'))
691 /* This is the start of a field unit, scan until closing brace */
695 Type = ACPI_TYPE_FIELD_UNIT;
697 /* Find end of buffer */
699 while (*String && (*String != '}'))
707 /* This is the start of a package, scan until closing bracket */
712 Type = ACPI_TYPE_PACKAGE;
714 /* Find end of package (closing bracket) */
718 /* Handle String package elements */
722 /* Find end of string */
725 while (*String && (*String != '"'))
734 else if (*String == '[')
736 Depth++; /* A nested package declaration */
738 else if (*String == ']')
741 if (Depth == 0) /* Found final package closing bracket */
755 /* Find end of token */
757 while (*String && !isspace (*String))
779 /*******************************************************************************
781 * FUNCTION: AcpiDbGetLine
783 * PARAMETERS: InputBuffer - Command line buffer
785 * RETURN: Count of arguments to the command
787 * DESCRIPTION: Get the next command line from the user. Gets entire line
788 * up to the next newline
790 ******************************************************************************/
802 if (AcpiUtSafeStrcpy (AcpiGbl_DbParsedBuf, sizeof (AcpiGbl_DbParsedBuf),
806 "Buffer overflow while parsing input line (max %u characters)\n",
807 (UINT32) sizeof (AcpiGbl_DbParsedBuf));
811 This = AcpiGbl_DbParsedBuf;
812 for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
814 AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next,
815 &AcpiGbl_DbArgTypes[i]);
816 if (!AcpiGbl_DbArgs[i])
824 /* Uppercase the actual command */
826 AcpiUtStrupr (AcpiGbl_DbArgs[0]);
831 Count--; /* Number of args only */
838 /*******************************************************************************
840 * FUNCTION: AcpiDbMatchCommand
842 * PARAMETERS: UserCommand - User command line
844 * RETURN: Index into command array, -1 if not found
846 * DESCRIPTION: Search command array for a command match
848 ******************************************************************************/
857 if (!UserCommand || UserCommand[0] == 0)
862 for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
865 ACPI_CAST_PTR (char, AcpiGbl_DbCommands[i].Name), UserCommand) ==
866 AcpiGbl_DbCommands[i].Name)
872 /* Command not recognized */
874 return (CMD_NOT_FOUND);
878 /*******************************************************************************
880 * FUNCTION: AcpiDbCommandDispatch
882 * PARAMETERS: InputBuffer - Command line buffer
883 * WalkState - Current walk
884 * Op - Current (executing) parse op
888 * DESCRIPTION: Command dispatcher.
890 ******************************************************************************/
893 AcpiDbCommandDispatch (
895 ACPI_WALK_STATE *WalkState,
896 ACPI_PARSE_OBJECT *Op)
903 ACPI_STATUS Status = AE_CTRL_TRUE;
906 /* If AcpiTerminate has been called, terminate this thread */
908 if (AcpiGbl_DbTerminateLoop)
910 return (AE_CTRL_TERMINATE);
913 /* Find command and add to the history buffer */
915 ParamCount = AcpiDbGetLine (InputBuffer);
916 CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]);
919 * We don't want to add the !! command to the history buffer. It
920 * would cause an infinite loop because it would always be the
923 if (CommandIndex != CMD_HISTORY_LAST)
925 AcpiDbAddToHistory (InputBuffer);
928 /* Verify that we have the minimum number of params */
930 if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs)
932 AcpiOsPrintf ("%u parameters entered, [%s] requires %u parameters\n",
933 ParamCount, AcpiGbl_DbCommands[CommandIndex].Name,
934 AcpiGbl_DbCommands[CommandIndex].MinArgs);
936 AcpiDbDisplayCommandInfo (
937 AcpiGbl_DbCommands[CommandIndex].Name, FALSE);
938 return (AE_CTRL_TRUE);
941 /* Decode and dispatch the command */
943 switch (CommandIndex)
955 AcpiOsPrintf ("Executing all objects with NameSeg: %s\n", AcpiGbl_DbArgs[1]);
956 AcpiDbExecute (AcpiGbl_DbArgs[1],
957 &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP | EX_ALL);
960 case CMD_ALLOCATIONS:
962 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
963 AcpiUtDumpAllocations ((UINT32) -1, NULL);
970 AcpiDbDisplayArguments ();
975 AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
985 AcpiDbSetMethodCallBreakpoint (Op);
991 AcpiDbExecute (AcpiGbl_DbArgs[1],
992 &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_SINGLE_STEP);
995 case CMD_DISASSEMBLE:
998 #ifdef ACPI_DISASSEMBLER
999 (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
1001 AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
1007 AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1013 AcpiDbExecute (AcpiGbl_DbArgs[1],
1014 &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP);
1019 Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
1024 Status = AcpiUtStrtoul64 (AcpiGbl_DbArgs[1], &Temp64);
1026 if (ACPI_FAILURE (Status) || Temp64 >= ACPI_NUM_PREDEFINED_REGIONS)
1029 "Invalid address space ID: must be between 0 and %u inclusive\n",
1030 ACPI_NUM_PREDEFINED_REGIONS - 1);
1034 Status = AcpiDbDisplayFields ((UINT32) Temp64);
1039 AcpiGbl_CmSingleStep = FALSE;
1044 AcpiDbDisplayHandlers ();
1050 AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
1055 AcpiDbDisplayHistory ();
1058 case CMD_HISTORY_EXE: /* ! command */
1060 CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
1063 return (AE_CTRL_TRUE);
1066 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
1069 case CMD_HISTORY_LAST: /* !! command */
1071 CommandLine = AcpiDbGetFromHistory (NULL);
1074 return (AE_CTRL_TRUE);
1077 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
1080 case CMD_INFORMATION:
1082 AcpiDbDisplayMethodInfo (Op);
1087 AcpiDbCheckIntegrity ();
1094 AcpiGbl_CmSingleStep = TRUE;
1101 if (ParamCount == 0)
1104 "Current debug level for file output is: %8.8X\n",
1105 AcpiGbl_DbDebugLevel);
1107 "Current debug level for console output is: %8.8X\n",
1108 AcpiGbl_DbConsoleDebugLevel);
1110 else if (ParamCount == 2)
1112 Temp = AcpiGbl_DbConsoleDebugLevel;
1113 AcpiGbl_DbConsoleDebugLevel =
1114 strtoul (AcpiGbl_DbArgs[1], NULL, 16);
1116 "Debug Level for console output was %8.8X, now %8.8X\n",
1117 Temp, AcpiGbl_DbConsoleDebugLevel);
1121 Temp = AcpiGbl_DbDebugLevel;
1122 AcpiGbl_DbDebugLevel = strtoul (AcpiGbl_DbArgs[1], NULL, 16);
1124 "Debug Level for file output was %8.8X, now %8.8X\n",
1125 Temp, AcpiGbl_DbDebugLevel);
1131 #ifdef ACPI_DISASSEMBLER
1132 AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
1134 AcpiOsPrintf ("The AML Disassembler is not configured/present\n");
1140 AcpiDbDisplayLocks ();
1145 AcpiDbDisplayLocals ();
1150 Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
1155 AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1160 Temp = strtoul (AcpiGbl_DbArgs[2], NULL, 0);
1161 AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
1166 AcpiUtStrupr (AcpiGbl_DbArgs[1]);
1167 Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1172 AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1177 AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1182 AcpiDbDumpNamespacePaths ();
1187 AcpiDbSetScope (AcpiGbl_DbArgs[1]);
1190 case CMD_REFERENCES:
1192 AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
1197 AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
1202 AcpiDbDisplayResults ();
1207 AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
1213 Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
1218 return (AE_NOT_IMPLEMENTED);
1222 AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
1227 AcpiDbDisplayTemplate (AcpiGbl_DbArgs[1]);
1232 AcpiDbTrace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]);
1237 AcpiDbDisplayCallingTree ();
1242 AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
1245 #ifdef ACPI_APPLICATION
1247 /* Hardware simulation commands. */
1249 case CMD_ENABLEACPI:
1250 #if (!ACPI_REDUCED_HARDWARE)
1252 Status = AcpiEnable();
1253 if (ACPI_FAILURE(Status))
1255 AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
1258 #endif /* !ACPI_REDUCED_HARDWARE */
1263 AcpiOsPrintf ("Event command not implemented\n");
1268 AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
1273 AcpiDbDisplayGpes ();
1278 AcpiDbGenerateSci ();
1283 Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
1286 /* File I/O commands. */
1290 AcpiDbCloseDebugFile ();
1295 ACPI_NEW_TABLE_DESC *ListHead = NULL;
1297 Status = AcGetAllTablesFromFile (AcpiGbl_DbArgs[1],
1298 ACPI_GET_ALL_TABLES, &ListHead);
1299 if (ACPI_SUCCESS (Status))
1301 AcpiDbLoadTables (ListHead);
1308 AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
1311 /* User space commands. */
1315 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1316 AcpiUtSubsystemShutdown ();
1319 * TBD: [Restructure] Need some way to re-initialize without
1320 * re-creating the semaphores!
1323 AcpiGbl_DbTerminateLoop = TRUE;
1324 /* AcpiInitialize (NULL); */
1327 case CMD_BACKGROUND:
1329 AcpiDbCreateExecutionThread (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2],
1330 &AcpiGbl_DbArgTypes[2]);
1335 AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2],
1339 /* Debug test commands. */
1341 case CMD_PREDEFINED:
1343 AcpiDbCheckPredefinedNames ();
1348 AcpiDbExecuteTest (AcpiGbl_DbArgs[1]);
1353 AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1]);
1362 AcpiOsPrintf ("Method execution terminated\n");
1363 return (AE_CTRL_TERMINATE);
1366 if (!AcpiGbl_DbOutputToFile)
1368 AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
1371 #ifdef ACPI_APPLICATION
1372 AcpiDbCloseDebugFile ();
1374 AcpiGbl_DbTerminateLoop = TRUE;
1375 return (AE_CTRL_TERMINATE);
1380 AcpiOsPrintf ("%s: unknown command\n", AcpiGbl_DbArgs[0]);
1381 return (AE_CTRL_TRUE);
1384 if (ACPI_SUCCESS (Status))
1386 Status = AE_CTRL_TRUE;
1393 /*******************************************************************************
1395 * FUNCTION: AcpiDbExecuteThread
1397 * PARAMETERS: Context - Not used
1401 * DESCRIPTION: Debugger execute thread. Waits for a command line, then
1402 * simply dispatches it.
1404 ******************************************************************************/
1406 void ACPI_SYSTEM_XFACE
1407 AcpiDbExecuteThread (
1411 (void) AcpiDbUserCommands ();
1412 AcpiGbl_DbThreadsTerminated = TRUE;
1416 /*******************************************************************************
1418 * FUNCTION: AcpiDbUserCommands
1424 * DESCRIPTION: Command line execution for the AML debugger. Commands are
1425 * matched and dispatched here.
1427 ******************************************************************************/
1430 AcpiDbUserCommands (
1433 ACPI_STATUS Status = AE_OK;
1436 AcpiOsPrintf ("\n");
1438 /* TBD: [Restructure] Need a separate command line buffer for step mode */
1440 while (!AcpiGbl_DbTerminateLoop)
1442 /* Wait the readiness of the command */
1444 Status = AcpiOsWaitCommandReady ();
1445 if (ACPI_FAILURE (Status))
1450 /* Just call to the command line interpreter */
1452 AcpiGbl_MethodExecuting = FALSE;
1453 AcpiGbl_StepToNextCall = FALSE;
1455 (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
1457 /* Notify the completion of the command */
1459 Status = AcpiOsNotifyCommandComplete ();
1460 if (ACPI_FAILURE (Status))
1466 if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
1468 ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));