167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: dbinput - user front-end to the AML debugger 467754Smsmith * 567754Smsmith ******************************************************************************/ 667754Smsmith 7217365Sjkim/* 8217365Sjkim * Copyright (C) 2000 - 2011, Intel Corp. 970243Smsmith * All rights reserved. 1067754Smsmith * 11217365Sjkim * Redistribution and use in source and binary forms, with or without 12217365Sjkim * modification, are permitted provided that the following conditions 13217365Sjkim * are met: 14217365Sjkim * 1. Redistributions of source code must retain the above copyright 15217365Sjkim * notice, this list of conditions, and the following disclaimer, 16217365Sjkim * without modification. 17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20217365Sjkim * including a substantially similar Disclaimer requirement for further 21217365Sjkim * binary redistribution. 22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23217365Sjkim * of any contributors may be used to endorse or promote products derived 24217365Sjkim * from this software without specific prior written permission. 2567754Smsmith * 26217365Sjkim * Alternatively, this software may be distributed under the terms of the 27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28217365Sjkim * Software Foundation. 2967754Smsmith * 30217365Sjkim * NO WARRANTY 31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 42217365Sjkim */ 4367754Smsmith 4467754Smsmith 45193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 46193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 47193341Sjkim#include <contrib/dev/acpica/include/acdebug.h> 4867754Smsmith 4967754Smsmith 50102550Siwasaki#ifdef ACPI_DEBUGGER 5167754Smsmith 52102550Siwasaki#define _COMPONENT ACPI_CA_DEBUGGER 5391116Smsmith ACPI_MODULE_NAME ("dbinput") 5467754Smsmith 55151937Sjkim/* Local prototypes */ 5667754Smsmith 57151937Sjkimstatic UINT32 58151937SjkimAcpiDbGetLine ( 59151937Sjkim char *InputBuffer); 60151937Sjkim 61151937Sjkimstatic UINT32 62151937SjkimAcpiDbMatchCommand ( 63151937Sjkim char *UserCommand); 64151937Sjkim 65151937Sjkimstatic void 66151937SjkimAcpiDbSingleThread ( 67151937Sjkim void); 68151937Sjkim 69151937Sjkimstatic void 70151937SjkimAcpiDbDisplayHelp ( 71218590Sjkim void); 72151937Sjkim 73151937Sjkim 7467754Smsmith/* 7567754Smsmith * Top-level debugger commands. 7667754Smsmith * 7767754Smsmith * This list of commands must match the string table below it 7867754Smsmith */ 7977424Smsmithenum AcpiExDebuggerCommands 8067754Smsmith{ 8167754Smsmith CMD_NOT_FOUND = 0, 8267754Smsmith CMD_NULL, 8367754Smsmith CMD_ALLOCATIONS, 8467754Smsmith CMD_ARGS, 8567754Smsmith CMD_ARGUMENTS, 86193267Sjkim CMD_BATCH, 8767754Smsmith CMD_BREAKPOINT, 88151937Sjkim CMD_BUSINFO, 8967754Smsmith CMD_CALL, 9067754Smsmith CMD_CLOSE, 9167754Smsmith CMD_DEBUG, 92138287Smarks CMD_DISASSEMBLE, 9367754Smsmith CMD_DUMP, 9467754Smsmith CMD_ENABLEACPI, 9567754Smsmith CMD_EVENT, 9667754Smsmith CMD_EXECUTE, 9767754Smsmith CMD_EXIT, 9867754Smsmith CMD_FIND, 9967754Smsmith CMD_GO, 100114237Snjl CMD_GPE, 101114237Snjl CMD_GPES, 102218590Sjkim CMD_HANDLERS, 10367754Smsmith CMD_HELP, 10467754Smsmith CMD_HELP2, 10567754Smsmith CMD_HISTORY, 10667754Smsmith CMD_HISTORY_EXE, 10767754Smsmith CMD_HISTORY_LAST, 10867754Smsmith CMD_INFORMATION, 10999679Siwasaki CMD_INTEGRITY, 11067754Smsmith CMD_INTO, 11167754Smsmith CMD_LEVEL, 11267754Smsmith CMD_LIST, 11367754Smsmith CMD_LOAD, 11467754Smsmith CMD_LOCALS, 11577424Smsmith CMD_LOCKS, 11667754Smsmith CMD_METHODS, 11767754Smsmith CMD_NAMESPACE, 11867754Smsmith CMD_NOTIFY, 11967754Smsmith CMD_OBJECT, 12067754Smsmith CMD_OPEN, 121210976Sjkim CMD_OSI, 12267754Smsmith CMD_OWNER, 123193267Sjkim CMD_PREDEFINED, 12467754Smsmith CMD_PREFIX, 12567754Smsmith CMD_QUIT, 12667754Smsmith CMD_REFERENCES, 12773561Smsmith CMD_RESOURCES, 12867754Smsmith CMD_RESULTS, 12967754Smsmith CMD_SET, 130129684Snjl CMD_SLEEP, 13167754Smsmith CMD_STATS, 13267754Smsmith CMD_STOP, 13367754Smsmith CMD_TABLES, 13467754Smsmith CMD_TERMINATE, 13567754Smsmith CMD_THREADS, 136151937Sjkim CMD_TRACE, 13767754Smsmith CMD_TREE, 138117521Snjl CMD_TYPE, 13967754Smsmith CMD_UNLOAD 14067754Smsmith}; 14167754Smsmith 14267754Smsmith#define CMD_FIRST_VALID 2 14367754Smsmith 144193267Sjkim 145193267Sjkim/* Second parameter is the required argument count */ 146193267Sjkim 14799679Siwasakistatic const COMMAND_INFO AcpiGbl_DbCommands[] = 14867754Smsmith{ 14967754Smsmith {"<NOT FOUND>", 0}, 15067754Smsmith {"<NULL>", 0}, 15167754Smsmith {"ALLOCATIONS", 0}, 15267754Smsmith {"ARGS", 0}, 15367754Smsmith {"ARGUMENTS", 0}, 154193267Sjkim {"BATCH", 0}, 15567754Smsmith {"BREAKPOINT", 1}, 156151937Sjkim {"BUSINFO", 0}, 15767754Smsmith {"CALL", 0}, 15867754Smsmith {"CLOSE", 0}, 15967754Smsmith {"DEBUG", 1}, 160138287Smarks {"DISASSEMBLE", 1}, 16167754Smsmith {"DUMP", 1}, 16267754Smsmith {"ENABLEACPI", 0}, 16367754Smsmith {"EVENT", 1}, 16467754Smsmith {"EXECUTE", 1}, 16567754Smsmith {"EXIT", 0}, 16667754Smsmith {"FIND", 1}, 16767754Smsmith {"GO", 0}, 168114237Snjl {"GPE", 2}, 169114237Snjl {"GPES", 0}, 170218590Sjkim {"HANDLERS", 0}, 17167754Smsmith {"HELP", 0}, 17267754Smsmith {"?", 0}, 17367754Smsmith {"HISTORY", 0}, 17467754Smsmith {"!", 1}, 17567754Smsmith {"!!", 0}, 17667754Smsmith {"INFORMATION", 0}, 17799679Siwasaki {"INTEGRITY", 0}, 17867754Smsmith {"INTO", 0}, 17967754Smsmith {"LEVEL", 0}, 18067754Smsmith {"LIST", 0}, 18167754Smsmith {"LOAD", 1}, 18267754Smsmith {"LOCALS", 0}, 18377424Smsmith {"LOCKS", 0}, 18467754Smsmith {"METHODS", 0}, 18567754Smsmith {"NAMESPACE", 0}, 18667754Smsmith {"NOTIFY", 2}, 18767754Smsmith {"OBJECT", 1}, 18867754Smsmith {"OPEN", 1}, 189210976Sjkim {"OSI", 0}, 19067754Smsmith {"OWNER", 1}, 191193267Sjkim {"PREDEFINED", 0}, 19267754Smsmith {"PREFIX", 0}, 19367754Smsmith {"QUIT", 0}, 19467754Smsmith {"REFERENCES", 1}, 19573561Smsmith {"RESOURCES", 1}, 19667754Smsmith {"RESULTS", 0}, 19767754Smsmith {"SET", 3}, 198129684Snjl {"SLEEP", 1}, 19967754Smsmith {"STATS", 0}, 20067754Smsmith {"STOP", 0}, 20167754Smsmith {"TABLES", 0}, 20267754Smsmith {"TERMINATE", 0}, 20367754Smsmith {"THREADS", 3}, 204151937Sjkim {"TRACE", 1}, 20567754Smsmith {"TREE", 0}, 206117521Snjl {"TYPE", 1}, 20782367Smsmith {"UNLOAD", 1}, 20867754Smsmith {NULL, 0} 20967754Smsmith}; 21067754Smsmith 21167754Smsmith 21267754Smsmith/******************************************************************************* 21367754Smsmith * 21467754Smsmith * FUNCTION: AcpiDbDisplayHelp 21567754Smsmith * 216218590Sjkim * PARAMETERS: None 21767754Smsmith * 21867754Smsmith * RETURN: None 21967754Smsmith * 22067754Smsmith * DESCRIPTION: Print a usage message. 22167754Smsmith * 22267754Smsmith ******************************************************************************/ 22367754Smsmith 224151937Sjkimstatic void 22567754SmsmithAcpiDbDisplayHelp ( 226218590Sjkim void) 22767754Smsmith{ 22867754Smsmith 229218590Sjkim AcpiOsPrintf ("\nGeneral-Purpose Commands:\n"); 230218590Sjkim AcpiOsPrintf (" Allocations Display list of current memory allocations\n"); 231218590Sjkim AcpiOsPrintf (" Dump <Address>|<Namepath>\n"); 232218590Sjkim AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n"); 233218590Sjkim AcpiOsPrintf (" EnableAcpi Enable ACPI (hardware) mode\n"); 234218590Sjkim AcpiOsPrintf (" Handlers Info about global handlers\n"); 235218590Sjkim AcpiOsPrintf (" Help This help screen\n"); 236218590Sjkim AcpiOsPrintf (" History Display command history buffer\n"); 237218590Sjkim AcpiOsPrintf (" Level [<DebugLevel>] [console] Get/Set debug level for file or console\n"); 238218590Sjkim AcpiOsPrintf (" Locks Current status of internal mutexes\n"); 239218590Sjkim AcpiOsPrintf (" Osi [Install|Remove <name>] Display or modify global _OSI list\n"); 240218590Sjkim AcpiOsPrintf (" Quit or Exit Exit this command\n"); 241218590Sjkim AcpiOsPrintf (" Stats [Allocations|Memory|Misc|\n"); 242218590Sjkim AcpiOsPrintf (" Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n"); 243218590Sjkim AcpiOsPrintf (" Allocations Display list of current memory allocations\n"); 244218590Sjkim AcpiOsPrintf (" Memory Dump internal memory lists\n"); 245218590Sjkim AcpiOsPrintf (" Misc Namespace search and mutex stats\n"); 246218590Sjkim AcpiOsPrintf (" Objects Summary of namespace objects\n"); 247218590Sjkim AcpiOsPrintf (" Sizes Sizes for each of the internal objects\n"); 248218590Sjkim AcpiOsPrintf (" Stack Display CPU stack usage\n"); 249218590Sjkim AcpiOsPrintf (" Tables Info about current ACPI table(s)\n"); 250218590Sjkim AcpiOsPrintf (" Tables Display info about loaded ACPI tables\n"); 251218590Sjkim AcpiOsPrintf (" Unload <TableSig> [Instance] Unload an ACPI table\n"); 252218590Sjkim AcpiOsPrintf (" ! <CommandNumber> Execute command from history buffer\n"); 253218590Sjkim AcpiOsPrintf (" !! Execute last command again\n"); 25467754Smsmith 255218590Sjkim AcpiOsPrintf ("\nNamespace Access Commands:\n"); 256218590Sjkim AcpiOsPrintf (" Businfo Display system bus info\n"); 257218590Sjkim AcpiOsPrintf (" Disassemble <Method> Disassemble a control method\n"); 258218590Sjkim AcpiOsPrintf (" Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n"); 259218590Sjkim AcpiOsPrintf (" Find <AcpiName> (? is wildcard) Find ACPI name(s) with wildcards\n"); 260218590Sjkim AcpiOsPrintf (" Gpe <GpeNum> <GpeBlock> Simulate a GPE\n"); 261218590Sjkim AcpiOsPrintf (" Gpes Display info on all GPEs\n"); 262218590Sjkim AcpiOsPrintf (" Integrity Validate namespace integrity\n"); 263218590Sjkim AcpiOsPrintf (" Methods Display list of loaded control methods\n"); 264218590Sjkim AcpiOsPrintf (" Namespace [Object] [Depth] Display loaded namespace tree/subtree\n"); 265218590Sjkim AcpiOsPrintf (" Notify <Object> <Value> Send a notification on Object\n"); 266218590Sjkim AcpiOsPrintf (" Objects <ObjectType> Display all objects of the given type\n"); 267218590Sjkim AcpiOsPrintf (" Owner <OwnerId> [Depth] Display loaded namespace by object owner\n"); 268218590Sjkim AcpiOsPrintf (" Predefined Check all predefined names\n"); 269218590Sjkim AcpiOsPrintf (" Prefix [<NamePath>] Set or Get current execution prefix\n"); 270218590Sjkim AcpiOsPrintf (" References <Addr> Find all references to object at addr\n"); 271218590Sjkim AcpiOsPrintf (" Resources <Device> Get and display Device resources\n"); 272218590Sjkim AcpiOsPrintf (" Set N <NamedObject> <Value> Set value for named integer\n"); 273218590Sjkim AcpiOsPrintf (" Sleep <SleepState> Simulate sleep/wake sequence\n"); 274218590Sjkim AcpiOsPrintf (" Terminate Delete namespace and all internal objects\n"); 275218590Sjkim AcpiOsPrintf (" Type <Object> Display object type\n"); 27667754Smsmith 277218590Sjkim AcpiOsPrintf ("\nControl Method Execution Commands:\n"); 278218590Sjkim AcpiOsPrintf (" Arguments (or Args) Display method arguments\n"); 279218590Sjkim AcpiOsPrintf (" Breakpoint <AmlOffset> Set an AML execution breakpoint\n"); 280218590Sjkim AcpiOsPrintf (" Call Run to next control method invocation\n"); 281218590Sjkim AcpiOsPrintf (" Debug <Namepath> [Arguments] Single Step a control method\n"); 282218590Sjkim AcpiOsPrintf (" Execute <Namepath> [Arguments] Execute control method\n"); 283222544Sjkim AcpiOsPrintf (" Hex Integer Integer method argument\n"); 284222544Sjkim AcpiOsPrintf (" \"Ascii String\" String method argument\n"); 285222544Sjkim AcpiOsPrintf (" (Byte List) Buffer method argument\n"); 286222544Sjkim AcpiOsPrintf (" [Package Element List] Package method argument\n"); 287218590Sjkim AcpiOsPrintf (" Go Allow method to run to completion\n"); 288218590Sjkim AcpiOsPrintf (" Information Display info about the current method\n"); 289218590Sjkim AcpiOsPrintf (" Into Step into (not over) a method call\n"); 290218590Sjkim AcpiOsPrintf (" List [# of Aml Opcodes] Display method ASL statements\n"); 291218590Sjkim AcpiOsPrintf (" Locals Display method local variables\n"); 292218590Sjkim AcpiOsPrintf (" Results Display method result stack\n"); 293218590Sjkim AcpiOsPrintf (" Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n"); 294218590Sjkim AcpiOsPrintf (" Stop Terminate control method\n"); 295218590Sjkim AcpiOsPrintf (" Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n"); 296218590Sjkim AcpiOsPrintf (" Trace <method name> Trace method execution\n"); 297218590Sjkim AcpiOsPrintf (" Tree Display control method calling tree\n"); 298218590Sjkim AcpiOsPrintf (" <Enter> Single step next AML opcode (over calls)\n"); 29967754Smsmith 300218590Sjkim AcpiOsPrintf ("\nFile I/O Commands:\n"); 301218590Sjkim AcpiOsPrintf (" Close Close debug output file\n"); 302218590Sjkim AcpiOsPrintf (" Load <Input Filename> Load ACPI table from a file\n"); 303218590Sjkim AcpiOsPrintf (" Open <Output Filename> Open a file for debug output\n"); 30467754Smsmith} 30567754Smsmith 30667754Smsmith 30767754Smsmith/******************************************************************************* 30867754Smsmith * 30967754Smsmith * FUNCTION: AcpiDbGetNextToken 31067754Smsmith * 31167754Smsmith * PARAMETERS: String - Command buffer 31267754Smsmith * Next - Return value, end of next token 31367754Smsmith * 31467754Smsmith * RETURN: Pointer to the start of the next token. 31567754Smsmith * 31667754Smsmith * DESCRIPTION: Command line parsing. Get the next token on the command line 31767754Smsmith * 31867754Smsmith ******************************************************************************/ 31967754Smsmith 320222544Sjkimchar * 32167754SmsmithAcpiDbGetNextToken ( 322114237Snjl char *String, 323222544Sjkim char **Next, 324222544Sjkim ACPI_OBJECT_TYPE *ReturnType) 32567754Smsmith{ 326114237Snjl char *Start; 327222544Sjkim UINT32 Depth; 328222544Sjkim ACPI_OBJECT_TYPE Type = ACPI_TYPE_INTEGER; 32967754Smsmith 33091116Smsmith 33167754Smsmith /* At end of buffer? */ 33267754Smsmith 33367754Smsmith if (!String || !(*String)) 33467754Smsmith { 33567754Smsmith return (NULL); 33667754Smsmith } 33767754Smsmith 338222544Sjkim /* Remove any spaces at the beginning */ 33967754Smsmith 34067754Smsmith if (*String == ' ') 34167754Smsmith { 34267754Smsmith while (*String && (*String == ' ')) 34367754Smsmith { 34467754Smsmith String++; 34567754Smsmith } 34667754Smsmith 34767754Smsmith if (!(*String)) 34867754Smsmith { 34967754Smsmith return (NULL); 35067754Smsmith } 35167754Smsmith } 35267754Smsmith 353222544Sjkim switch (*String) 354210976Sjkim { 355222544Sjkim case '"': 356222544Sjkim 357210976Sjkim /* This is a quoted string, scan until closing quote */ 35867754Smsmith 359210976Sjkim String++; 360210976Sjkim Start = String; 361222544Sjkim Type = ACPI_TYPE_STRING; 36267754Smsmith 363222544Sjkim /* Find end of string */ 364210976Sjkim 365210976Sjkim while (*String && (*String != '"')) 366210976Sjkim { 367210976Sjkim String++; 368210976Sjkim } 369222544Sjkim break; 370222544Sjkim 371222544Sjkim case '(': 372222544Sjkim 373222544Sjkim /* This is the start of a buffer, scan until closing paren */ 374222544Sjkim 375222544Sjkim String++; 376210976Sjkim Start = String; 377222544Sjkim Type = ACPI_TYPE_BUFFER; 378210976Sjkim 379222544Sjkim /* Find end of buffer */ 380222544Sjkim 381222544Sjkim while (*String && (*String != ')')) 382222544Sjkim { 383222544Sjkim String++; 384222544Sjkim } 385222544Sjkim break; 386222544Sjkim 387222544Sjkim case '[': 388222544Sjkim 389222544Sjkim /* This is the start of a package, scan until closing bracket */ 390222544Sjkim 391222544Sjkim String++; 392222544Sjkim Depth = 1; 393222544Sjkim Start = String; 394222544Sjkim Type = ACPI_TYPE_PACKAGE; 395222544Sjkim 396222544Sjkim /* Find end of package (closing bracket) */ 397222544Sjkim 398222544Sjkim while (*String) 399222544Sjkim { 400222544Sjkim /* Handle String package elements */ 401222544Sjkim 402222544Sjkim if (*String == '"') 403222544Sjkim { 404222544Sjkim /* Find end of string */ 405222544Sjkim 406222544Sjkim String++; 407222544Sjkim while (*String && (*String != '"')) 408222544Sjkim { 409222544Sjkim String++; 410222544Sjkim } 411222544Sjkim if (!(*String)) 412222544Sjkim { 413222544Sjkim break; 414222544Sjkim } 415222544Sjkim } 416222544Sjkim else if (*String == '[') 417222544Sjkim { 418222544Sjkim Depth++; /* A nested package declaration */ 419222544Sjkim } 420222544Sjkim else if (*String == ']') 421222544Sjkim { 422222544Sjkim Depth--; 423222544Sjkim if (Depth == 0) /* Found final package closing bracket */ 424222544Sjkim { 425222544Sjkim break; 426222544Sjkim } 427222544Sjkim } 428222544Sjkim 429222544Sjkim String++; 430222544Sjkim } 431222544Sjkim break; 432222544Sjkim 433222544Sjkim default: 434222544Sjkim 435222544Sjkim Start = String; 436222544Sjkim 437210976Sjkim /* Find end of token */ 438210976Sjkim 439210976Sjkim while (*String && (*String != ' ')) 440210976Sjkim { 441210976Sjkim String++; 442210976Sjkim } 443222544Sjkim break; 44467754Smsmith } 44567754Smsmith 44667754Smsmith if (!(*String)) 44767754Smsmith { 44867754Smsmith *Next = NULL; 44967754Smsmith } 45067754Smsmith else 45167754Smsmith { 45267754Smsmith *String = 0; 45367754Smsmith *Next = String + 1; 45467754Smsmith } 45567754Smsmith 456222544Sjkim *ReturnType = Type; 45767754Smsmith return (Start); 45867754Smsmith} 45967754Smsmith 46067754Smsmith 46167754Smsmith/******************************************************************************* 46267754Smsmith * 46367754Smsmith * FUNCTION: AcpiDbGetLine 46467754Smsmith * 46567754Smsmith * PARAMETERS: InputBuffer - Command line buffer 46667754Smsmith * 467151937Sjkim * RETURN: Count of arguments to the command 46867754Smsmith * 46967754Smsmith * DESCRIPTION: Get the next command line from the user. Gets entire line 47067754Smsmith * up to the next newline 47167754Smsmith * 47267754Smsmith ******************************************************************************/ 47367754Smsmith 474151937Sjkimstatic UINT32 47567754SmsmithAcpiDbGetLine ( 476114237Snjl char *InputBuffer) 47767754Smsmith{ 47867754Smsmith UINT32 i; 47967754Smsmith UINT32 Count; 480114237Snjl char *Next; 481114237Snjl char *This; 48267754Smsmith 48367754Smsmith 48491116Smsmith ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer); 48567754Smsmith 48683174Smsmith This = AcpiGbl_DbParsedBuf; 48791116Smsmith for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++) 48867754Smsmith { 489222544Sjkim AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next, 490222544Sjkim &AcpiGbl_DbArgTypes[i]); 49183174Smsmith if (!AcpiGbl_DbArgs[i]) 49267754Smsmith { 49367754Smsmith break; 49467754Smsmith } 49567754Smsmith 49667754Smsmith This = Next; 49767754Smsmith } 49867754Smsmith 49967754Smsmith /* Uppercase the actual command */ 50067754Smsmith 50183174Smsmith if (AcpiGbl_DbArgs[0]) 50267754Smsmith { 503151937Sjkim AcpiUtStrupr (AcpiGbl_DbArgs[0]); 50467754Smsmith } 50567754Smsmith 50667754Smsmith Count = i; 50767754Smsmith if (Count) 50867754Smsmith { 50967754Smsmith Count--; /* Number of args only */ 51067754Smsmith } 51167754Smsmith 51267754Smsmith return (Count); 51367754Smsmith} 51467754Smsmith 51567754Smsmith 51667754Smsmith/******************************************************************************* 51767754Smsmith * 51867754Smsmith * FUNCTION: AcpiDbMatchCommand 51967754Smsmith * 52067754Smsmith * PARAMETERS: UserCommand - User command line 52167754Smsmith * 52267754Smsmith * RETURN: Index into command array, -1 if not found 52367754Smsmith * 52467754Smsmith * DESCRIPTION: Search command array for a command match 52567754Smsmith * 52667754Smsmith ******************************************************************************/ 52767754Smsmith 528151937Sjkimstatic UINT32 52967754SmsmithAcpiDbMatchCommand ( 530114237Snjl char *UserCommand) 53167754Smsmith{ 53267754Smsmith UINT32 i; 53367754Smsmith 53467754Smsmith 53567754Smsmith if (!UserCommand || UserCommand[0] == 0) 53667754Smsmith { 53767754Smsmith return (CMD_NULL); 53867754Smsmith } 53967754Smsmith 54083174Smsmith for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++) 54167754Smsmith { 54291116Smsmith if (ACPI_STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) == 54391116Smsmith AcpiGbl_DbCommands[i].Name) 54467754Smsmith { 54567754Smsmith return (i); 54667754Smsmith } 54767754Smsmith } 54867754Smsmith 54967754Smsmith /* Command not recognized */ 55067754Smsmith 55167754Smsmith return (CMD_NOT_FOUND); 55267754Smsmith} 55367754Smsmith 55467754Smsmith 55567754Smsmith/******************************************************************************* 55667754Smsmith * 55767754Smsmith * FUNCTION: AcpiDbCommandDispatch 55867754Smsmith * 55967754Smsmith * PARAMETERS: InputBuffer - Command line buffer 56067754Smsmith * WalkState - Current walk 56167754Smsmith * Op - Current (executing) parse op 56267754Smsmith * 56367754Smsmith * RETURN: Status 56467754Smsmith * 565151937Sjkim * DESCRIPTION: Command dispatcher. 56667754Smsmith * 56767754Smsmith ******************************************************************************/ 56867754Smsmith 56967754SmsmithACPI_STATUS 57067754SmsmithAcpiDbCommandDispatch ( 571114237Snjl char *InputBuffer, 57267754Smsmith ACPI_WALK_STATE *WalkState, 57367754Smsmith ACPI_PARSE_OBJECT *Op) 57467754Smsmith{ 57567754Smsmith UINT32 Temp; 57667754Smsmith UINT32 CommandIndex; 57767754Smsmith UINT32 ParamCount; 578114237Snjl char *CommandLine; 57967754Smsmith ACPI_STATUS Status = AE_CTRL_TRUE; 58067754Smsmith 58167754Smsmith 58267754Smsmith /* If AcpiTerminate has been called, terminate this thread */ 58367754Smsmith 58467754Smsmith if (AcpiGbl_DbTerminateThreads) 58567754Smsmith { 58667754Smsmith return (AE_CTRL_TERMINATE); 58767754Smsmith } 58867754Smsmith 58967754Smsmith ParamCount = AcpiDbGetLine (InputBuffer); 59083174Smsmith CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]); 59167754Smsmith Temp = 0; 59267754Smsmith 59367754Smsmith /* Verify that we have the minimum number of params */ 59467754Smsmith 59583174Smsmith if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs) 59667754Smsmith { 597209746Sjkim AcpiOsPrintf ("%u parameters entered, [%s] requires %u parameters\n", 598151937Sjkim ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, 599151937Sjkim AcpiGbl_DbCommands[CommandIndex].MinArgs); 600151937Sjkim 60167754Smsmith return (AE_CTRL_TRUE); 60267754Smsmith } 60367754Smsmith 60467754Smsmith /* Decode and dispatch the command */ 60567754Smsmith 60667754Smsmith switch (CommandIndex) 60767754Smsmith { 60867754Smsmith case CMD_NULL: 60967754Smsmith if (Op) 61067754Smsmith { 61167754Smsmith return (AE_OK); 61267754Smsmith } 61367754Smsmith break; 61467754Smsmith 61567754Smsmith case CMD_ALLOCATIONS: 61683174Smsmith 61780062Smsmith#ifdef ACPI_DBG_TRACK_ALLOCATIONS 61884491Smsmith AcpiUtDumpAllocations ((UINT32) -1, NULL); 61980062Smsmith#endif 62067754Smsmith break; 62167754Smsmith 62267754Smsmith case CMD_ARGS: 62367754Smsmith case CMD_ARGUMENTS: 62467754Smsmith AcpiDbDisplayArguments (); 62567754Smsmith break; 62667754Smsmith 627193267Sjkim case CMD_BATCH: 628198237Sjkim AcpiDbBatchExecute (AcpiGbl_DbArgs[1]); 629193267Sjkim break; 630193267Sjkim 63167754Smsmith case CMD_BREAKPOINT: 63283174Smsmith AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op); 63367754Smsmith break; 63467754Smsmith 635151937Sjkim case CMD_BUSINFO: 636151937Sjkim AcpiDbGetBusInfo (); 637151937Sjkim break; 638151937Sjkim 63967754Smsmith case CMD_CALL: 64067754Smsmith AcpiDbSetMethodCallBreakpoint (Op); 64167754Smsmith Status = AE_OK; 64267754Smsmith break; 64367754Smsmith 64467754Smsmith case CMD_CLOSE: 64567754Smsmith AcpiDbCloseDebugFile (); 64667754Smsmith break; 64767754Smsmith 64867754Smsmith case CMD_DEBUG: 649222544Sjkim AcpiDbExecute (AcpiGbl_DbArgs[1], 650222544Sjkim &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_SINGLE_STEP); 65167754Smsmith break; 65267754Smsmith 653138287Smarks case CMD_DISASSEMBLE: 654151937Sjkim (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]); 655138287Smarks break; 656138287Smarks 65767754Smsmith case CMD_DUMP: 65883174Smsmith AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 65967754Smsmith break; 66067754Smsmith 66167754Smsmith case CMD_ENABLEACPI: 66267754Smsmith Status = AcpiEnable(); 66367754Smsmith if (ACPI_FAILURE(Status)) 66467754Smsmith { 66569746Smsmith AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status); 66667754Smsmith return (Status); 66767754Smsmith } 66867754Smsmith break; 66967754Smsmith 67067754Smsmith case CMD_EVENT: 67167754Smsmith AcpiOsPrintf ("Event command not implemented\n"); 67267754Smsmith break; 67367754Smsmith 67467754Smsmith case CMD_EXECUTE: 675151937Sjkim AcpiDbExecute (AcpiGbl_DbArgs[1], 676222544Sjkim &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP); 67767754Smsmith break; 67867754Smsmith 67967754Smsmith case CMD_FIND: 680129684Snjl Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]); 68167754Smsmith break; 68267754Smsmith 68367754Smsmith case CMD_GO: 68467754Smsmith AcpiGbl_CmSingleStep = FALSE; 68567754Smsmith return (AE_OK); 68667754Smsmith 687114237Snjl case CMD_GPE: 688114237Snjl AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 689114237Snjl break; 690114237Snjl 691114237Snjl case CMD_GPES: 692114237Snjl AcpiDbDisplayGpes (); 693114237Snjl break; 694114237Snjl 695218590Sjkim case CMD_HANDLERS: 696218590Sjkim AcpiDbDisplayHandlers (); 697218590Sjkim break; 698218590Sjkim 69967754Smsmith case CMD_HELP: 70067754Smsmith case CMD_HELP2: 701218590Sjkim AcpiDbDisplayHelp (); 70267754Smsmith break; 70367754Smsmith 70467754Smsmith case CMD_HISTORY: 70567754Smsmith AcpiDbDisplayHistory (); 70667754Smsmith break; 70767754Smsmith 70867754Smsmith case CMD_HISTORY_EXE: 70983174Smsmith CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]); 71067754Smsmith if (!CommandLine) 71167754Smsmith { 71267754Smsmith return (AE_CTRL_TRUE); 71367754Smsmith } 71467754Smsmith 71567754Smsmith Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); 71667754Smsmith return (Status); 71767754Smsmith 71867754Smsmith case CMD_HISTORY_LAST: 71967754Smsmith CommandLine = AcpiDbGetFromHistory (NULL); 72067754Smsmith if (!CommandLine) 72167754Smsmith { 72267754Smsmith return (AE_CTRL_TRUE); 72367754Smsmith } 72467754Smsmith 72567754Smsmith Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); 72667754Smsmith return (Status); 72767754Smsmith 72867754Smsmith case CMD_INFORMATION: 72967754Smsmith AcpiDbDisplayMethodInfo (Op); 73067754Smsmith break; 73167754Smsmith 73299679Siwasaki case CMD_INTEGRITY: 73399679Siwasaki AcpiDbCheckIntegrity (); 73499679Siwasaki break; 73599679Siwasaki 73667754Smsmith case CMD_INTO: 73767754Smsmith if (Op) 73867754Smsmith { 73967754Smsmith AcpiGbl_CmSingleStep = TRUE; 74067754Smsmith return (AE_OK); 74167754Smsmith } 74267754Smsmith break; 74367754Smsmith 74467754Smsmith case CMD_LEVEL: 74567754Smsmith if (ParamCount == 0) 74667754Smsmith { 747151937Sjkim AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", 748151937Sjkim AcpiGbl_DbDebugLevel); 749151937Sjkim AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", 750151937Sjkim AcpiGbl_DbConsoleDebugLevel); 75167754Smsmith } 75267754Smsmith else if (ParamCount == 2) 75367754Smsmith { 75467754Smsmith Temp = AcpiGbl_DbConsoleDebugLevel; 755151937Sjkim AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], 756151937Sjkim NULL, 16); 757151937Sjkim AcpiOsPrintf ( 758151937Sjkim "Debug Level for console output was %8.8lX, now %8.8lX\n", 759151937Sjkim Temp, AcpiGbl_DbConsoleDebugLevel); 76067754Smsmith } 76167754Smsmith else 76267754Smsmith { 76367754Smsmith Temp = AcpiGbl_DbDebugLevel; 76491116Smsmith AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16); 765151937Sjkim AcpiOsPrintf ( 766151937Sjkim "Debug Level for file output was %8.8lX, now %8.8lX\n", 767151937Sjkim Temp, AcpiGbl_DbDebugLevel); 76867754Smsmith } 76967754Smsmith break; 77067754Smsmith 77167754Smsmith case CMD_LIST: 77283174Smsmith AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op); 77367754Smsmith break; 77467754Smsmith 77567754Smsmith case CMD_LOAD: 776114237Snjl Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL); 77767754Smsmith break; 77867754Smsmith 77977424Smsmith case CMD_LOCKS: 78077424Smsmith AcpiDbDisplayLocks (); 78177424Smsmith break; 78277424Smsmith 78367754Smsmith case CMD_LOCALS: 78467754Smsmith AcpiDbDisplayLocals (); 78567754Smsmith break; 78667754Smsmith 78767754Smsmith case CMD_METHODS: 788129684Snjl Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]); 78967754Smsmith break; 79067754Smsmith 79167754Smsmith case CMD_NAMESPACE: 79283174Smsmith AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 79367754Smsmith break; 79467754Smsmith 79567754Smsmith case CMD_NOTIFY: 79691116Smsmith Temp = ACPI_STRTOUL (AcpiGbl_DbArgs[2], NULL, 0); 79783174Smsmith AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp); 79867754Smsmith break; 79967754Smsmith 80067754Smsmith case CMD_OBJECT: 801151937Sjkim AcpiUtStrupr (AcpiGbl_DbArgs[1]); 802129684Snjl Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 80367754Smsmith break; 80467754Smsmith 80567754Smsmith case CMD_OPEN: 80683174Smsmith AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]); 80767754Smsmith break; 80867754Smsmith 809210976Sjkim case CMD_OSI: 810210976Sjkim AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 811210976Sjkim break; 812210976Sjkim 81367754Smsmith case CMD_OWNER: 81483174Smsmith AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 81567754Smsmith break; 81667754Smsmith 817193267Sjkim case CMD_PREDEFINED: 818193267Sjkim AcpiDbCheckPredefinedNames (); 819193267Sjkim break; 820193267Sjkim 82167754Smsmith case CMD_PREFIX: 82283174Smsmith AcpiDbSetScope (AcpiGbl_DbArgs[1]); 82367754Smsmith break; 82467754Smsmith 82567754Smsmith case CMD_REFERENCES: 82683174Smsmith AcpiDbFindReferences (AcpiGbl_DbArgs[1]); 82767754Smsmith break; 82867754Smsmith 82973561Smsmith case CMD_RESOURCES: 83083174Smsmith AcpiDbDisplayResources (AcpiGbl_DbArgs[1]); 83173561Smsmith break; 83273561Smsmith 83367754Smsmith case CMD_RESULTS: 83467754Smsmith AcpiDbDisplayResults (); 83567754Smsmith break; 83667754Smsmith 83767754Smsmith case CMD_SET: 838151937Sjkim AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], 839151937Sjkim AcpiGbl_DbArgs[3]); 84067754Smsmith break; 84167754Smsmith 842129684Snjl case CMD_SLEEP: 843129684Snjl Status = AcpiDbSleep (AcpiGbl_DbArgs[1]); 844129684Snjl break; 845129684Snjl 84667754Smsmith case CMD_STATS: 847129684Snjl Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]); 84867754Smsmith break; 84967754Smsmith 85067754Smsmith case CMD_STOP: 85199679Siwasaki return (AE_NOT_IMPLEMENTED); 85267754Smsmith 85367754Smsmith case CMD_TABLES: 85483174Smsmith AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]); 85567754Smsmith break; 85667754Smsmith 85767754Smsmith case CMD_TERMINATE: 85891116Smsmith AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 85977424Smsmith AcpiUtSubsystemShutdown (); 86067754Smsmith 861151937Sjkim /* 862151937Sjkim * TBD: [Restructure] Need some way to re-initialize without 863151937Sjkim * re-creating the semaphores! 864151937Sjkim */ 86567754Smsmith 86667754Smsmith /* AcpiInitialize (NULL); */ 86767754Smsmith break; 86867754Smsmith 86967754Smsmith case CMD_THREADS: 870151937Sjkim AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], 871151937Sjkim AcpiGbl_DbArgs[3]); 87267754Smsmith break; 87367754Smsmith 874151937Sjkim case CMD_TRACE: 875193267Sjkim (void) AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1); 876151937Sjkim break; 877151937Sjkim 87867754Smsmith case CMD_TREE: 87967754Smsmith AcpiDbDisplayCallingTree (); 88067754Smsmith break; 88167754Smsmith 882117521Snjl case CMD_TYPE: 883117521Snjl AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]); 884117521Snjl break; 885117521Snjl 88667754Smsmith case CMD_UNLOAD: 88783174Smsmith AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 88867754Smsmith break; 88967754Smsmith 89067754Smsmith case CMD_EXIT: 89167754Smsmith case CMD_QUIT: 89267754Smsmith if (Op) 89367754Smsmith { 89477424Smsmith AcpiOsPrintf ("Method execution terminated\n"); 89577424Smsmith return (AE_CTRL_TERMINATE); 89667754Smsmith } 89767754Smsmith 89883174Smsmith if (!AcpiGbl_DbOutputToFile) 89967754Smsmith { 900114237Snjl AcpiDbgLevel = ACPI_DEBUG_DEFAULT; 90167754Smsmith } 90267754Smsmith 90367754Smsmith AcpiDbCloseDebugFile (); 90467754Smsmith AcpiGbl_DbTerminateThreads = TRUE; 90567754Smsmith return (AE_CTRL_TERMINATE); 90667754Smsmith 90767754Smsmith case CMD_NOT_FOUND: 90899679Siwasaki default: 90967754Smsmith AcpiOsPrintf ("Unknown Command\n"); 91067754Smsmith return (AE_CTRL_TRUE); 91167754Smsmith } 91267754Smsmith 913151937Sjkim if (ACPI_SUCCESS (Status)) 914151937Sjkim { 915151937Sjkim Status = AE_CTRL_TRUE; 916151937Sjkim } 91767754Smsmith 91867754Smsmith /* Add all commands that come here to the history buffer */ 91967754Smsmith 92067754Smsmith AcpiDbAddToHistory (InputBuffer); 92167754Smsmith return (Status); 92267754Smsmith} 92367754Smsmith 92467754Smsmith 92567754Smsmith/******************************************************************************* 92667754Smsmith * 92767754Smsmith * FUNCTION: AcpiDbExecuteThread 92867754Smsmith * 92967754Smsmith * PARAMETERS: Context - Not used 93067754Smsmith * 93167754Smsmith * RETURN: None 93267754Smsmith * 93367754Smsmith * DESCRIPTION: Debugger execute thread. Waits for a command line, then 93467754Smsmith * simply dispatches it. 93567754Smsmith * 93667754Smsmith ******************************************************************************/ 93767754Smsmith 93892388Smsmithvoid ACPI_SYSTEM_XFACE 93967754SmsmithAcpiDbExecuteThread ( 94067754Smsmith void *Context) 94167754Smsmith{ 94267754Smsmith ACPI_STATUS Status = AE_OK; 94391116Smsmith ACPI_STATUS MStatus; 94467754Smsmith 94567754Smsmith 94667754Smsmith while (Status != AE_CTRL_TERMINATE) 94767754Smsmith { 94867754Smsmith AcpiGbl_MethodExecuting = FALSE; 94967754Smsmith AcpiGbl_StepToNextCall = FALSE; 95067754Smsmith 95191116Smsmith MStatus = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); 95291116Smsmith if (ACPI_FAILURE (MStatus)) 95391116Smsmith { 95491116Smsmith return; 95591116Smsmith } 95691116Smsmith 95783174Smsmith Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); 95891116Smsmith 95991116Smsmith MStatus = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); 96091116Smsmith if (ACPI_FAILURE (MStatus)) 96191116Smsmith { 96291116Smsmith return; 96391116Smsmith } 96467754Smsmith } 96567754Smsmith} 96667754Smsmith 96767754Smsmith 96867754Smsmith/******************************************************************************* 96967754Smsmith * 97067754Smsmith * FUNCTION: AcpiDbSingleThread 97167754Smsmith * 97267754Smsmith * PARAMETERS: None 97367754Smsmith * 97467754Smsmith * RETURN: None 97567754Smsmith * 97667754Smsmith * DESCRIPTION: Debugger execute thread. Waits for a command line, then 97767754Smsmith * simply dispatches it. 97867754Smsmith * 97967754Smsmith ******************************************************************************/ 98067754Smsmith 981151937Sjkimstatic void 98267754SmsmithAcpiDbSingleThread ( 98367754Smsmith void) 98467754Smsmith{ 98567754Smsmith 98667754Smsmith AcpiGbl_MethodExecuting = FALSE; 98767754Smsmith AcpiGbl_StepToNextCall = FALSE; 98867754Smsmith 98999679Siwasaki (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); 99067754Smsmith} 99167754Smsmith 99267754Smsmith 99367754Smsmith/******************************************************************************* 99467754Smsmith * 99567754Smsmith * FUNCTION: AcpiDbUserCommands 99667754Smsmith * 99767754Smsmith * PARAMETERS: Prompt - User prompt (depends on mode) 99867754Smsmith * Op - Current executing parse op 99967754Smsmith * 100067754Smsmith * RETURN: None 100167754Smsmith * 100267754Smsmith * DESCRIPTION: Command line execution for the AML debugger. Commands are 100367754Smsmith * matched and dispatched here. 100467754Smsmith * 100567754Smsmith ******************************************************************************/ 100667754Smsmith 100767754SmsmithACPI_STATUS 100867754SmsmithAcpiDbUserCommands ( 1009114237Snjl char Prompt, 101067754Smsmith ACPI_PARSE_OBJECT *Op) 101167754Smsmith{ 101267754Smsmith ACPI_STATUS Status = AE_OK; 101367754Smsmith 101467754Smsmith 101567754Smsmith /* TBD: [Restructure] Need a separate command line buffer for step mode */ 101667754Smsmith 101767754Smsmith while (!AcpiGbl_DbTerminateThreads) 101867754Smsmith { 101967754Smsmith /* Force output to console until a command is entered */ 102067754Smsmith 102191116Smsmith AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 102267754Smsmith 102367754Smsmith /* Different prompt if method is executing */ 102467754Smsmith 102567754Smsmith if (!AcpiGbl_MethodExecuting) 102667754Smsmith { 102791116Smsmith AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT); 102867754Smsmith } 102967754Smsmith else 103067754Smsmith { 103191116Smsmith AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT); 103267754Smsmith } 103367754Smsmith 103467754Smsmith /* Get the user input line */ 103567754Smsmith 1036222544Sjkim Status = AcpiOsGetLine (AcpiGbl_DbLineBuf, 1037222544Sjkim ACPI_DB_LINE_BUFFER_SIZE, NULL); 1038222544Sjkim if (ACPI_FAILURE (Status)) 1039222544Sjkim { 1040222544Sjkim ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line")); 1041222544Sjkim return (Status); 1042222544Sjkim } 104367754Smsmith 104467754Smsmith /* Check for single or multithreaded debug */ 104567754Smsmith 104667754Smsmith if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) 104767754Smsmith { 104867754Smsmith /* 104967754Smsmith * Signal the debug thread that we have a command to execute, 105067754Smsmith * and wait for the command to complete. 105167754Smsmith */ 105291116Smsmith Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); 105391116Smsmith if (ACPI_FAILURE (Status)) 105491116Smsmith { 105591116Smsmith return (Status); 105691116Smsmith } 105791116Smsmith 105891116Smsmith Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); 105991116Smsmith if (ACPI_FAILURE (Status)) 106091116Smsmith { 106191116Smsmith return (Status); 106291116Smsmith } 106367754Smsmith } 106467754Smsmith else 106567754Smsmith { 106667754Smsmith /* Just call to the command line interpreter */ 106767754Smsmith 106867754Smsmith AcpiDbSingleThread (); 106967754Smsmith } 107067754Smsmith } 107167754Smsmith 107267754Smsmith /* 1073151937Sjkim * Only this thread (the original thread) should actually terminate the 1074151937Sjkim * subsystem, because all the semaphores are deleted during termination 107567754Smsmith */ 107699679Siwasaki Status = AcpiTerminate (); 107767754Smsmith return (Status); 107867754Smsmith} 107967754Smsmith 1080102550Siwasaki#endif /* ACPI_DEBUGGER */ 108167754Smsmith 1082