dbinput.c revision 84491
1/******************************************************************************* 2 * 3 * Module Name: dbinput - user front-end to the AML debugger 4 * $Revision: 72 $ 5 * 6 ******************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117 118#include "acpi.h" 119#include "acparser.h" 120#include "actables.h" 121#include "acnamesp.h" 122#include "acinterp.h" 123#include "acdebug.h" 124 125 126#ifdef ENABLE_DEBUGGER 127 128#define _COMPONENT ACPI_DEBUGGER 129 MODULE_NAME ("dbinput") 130 131 132/* 133 * Globals that are specific to the debugger 134 */ 135 136NATIVE_CHAR AcpiGbl_DbLineBuf[80]; 137NATIVE_CHAR AcpiGbl_DbParsedBuf[80]; 138NATIVE_CHAR AcpiGbl_DbScopeBuf[40]; 139NATIVE_CHAR AcpiGbl_DbDebugFilename[40]; 140NATIVE_CHAR *AcpiGbl_DbArgs[DB_MAX_ARGS]; 141NATIVE_CHAR *AcpiGbl_DbBuffer = NULL; 142NATIVE_CHAR *AcpiGbl_DbFilename = NULL; 143BOOLEAN AcpiGbl_DbOutputToFile = FALSE; 144 145UINT32 AcpiGbl_DbDebugLevel = ACPI_LV_VERBOSITY2; 146UINT32 AcpiGbl_DbConsoleDebugLevel = NORMAL_DEFAULT | ACPI_LV_TABLES; 147UINT8 AcpiGbl_DbOutputFlags = DB_CONSOLE_OUTPUT; 148 149 150BOOLEAN AcpiGbl_DbOpt_tables = FALSE; 151BOOLEAN AcpiGbl_DbOpt_disasm = FALSE; 152BOOLEAN AcpiGbl_DbOpt_stats = FALSE; 153BOOLEAN AcpiGbl_DbOpt_parse_jit = FALSE; 154BOOLEAN AcpiGbl_DbOpt_verbose = TRUE; 155BOOLEAN AcpiGbl_DbOpt_ini_methods = TRUE; 156 157/* 158 * Statistic globals 159 */ 160UINT16 AcpiGbl_ObjTypeCount[INTERNAL_TYPE_NODE_MAX+1]; 161UINT16 AcpiGbl_NodeTypeCount[INTERNAL_TYPE_NODE_MAX+1]; 162UINT16 AcpiGbl_ObjTypeCountMisc; 163UINT16 AcpiGbl_NodeTypeCountMisc; 164UINT32 AcpiGbl_NumNodes; 165UINT32 AcpiGbl_NumObjects; 166 167 168UINT32 AcpiGbl_SizeOfParseTree; 169UINT32 AcpiGbl_SizeOfMethodTrees; 170UINT32 AcpiGbl_SizeOfNodeEntries; 171UINT32 AcpiGbl_SizeOfAcpiObjects; 172 173/* 174 * Top-level debugger commands. 175 * 176 * This list of commands must match the string table below it 177 */ 178 179enum AcpiExDebuggerCommands 180{ 181 CMD_NOT_FOUND = 0, 182 CMD_NULL, 183 CMD_ALLOCATIONS, 184 CMD_ARGS, 185 CMD_ARGUMENTS, 186 CMD_BREAKPOINT, 187 CMD_CALL, 188 CMD_CLOSE, 189 CMD_DEBUG, 190 CMD_DUMP, 191 CMD_ENABLEACPI, 192 CMD_EVENT, 193 CMD_EXECUTE, 194 CMD_EXIT, 195 CMD_FIND, 196 CMD_GO, 197 CMD_HELP, 198 CMD_HELP2, 199 CMD_HISTORY, 200 CMD_HISTORY_EXE, 201 CMD_HISTORY_LAST, 202 CMD_INFORMATION, 203 CMD_INTO, 204 CMD_LEVEL, 205 CMD_LIST, 206 CMD_LOAD, 207 CMD_LOCALS, 208 CMD_LOCKS, 209 CMD_METHODS, 210 CMD_NAMESPACE, 211 CMD_NOTIFY, 212 CMD_OBJECT, 213 CMD_OPEN, 214 CMD_OWNER, 215 CMD_PREFIX, 216 CMD_QUIT, 217 CMD_REFERENCES, 218 CMD_RESOURCES, 219 CMD_RESULTS, 220 CMD_SET, 221 CMD_STATS, 222 CMD_STOP, 223 CMD_TABLES, 224 CMD_TERMINATE, 225 CMD_THREADS, 226 CMD_TREE, 227 CMD_UNLOAD 228}; 229 230#define CMD_FIRST_VALID 2 231 232 233const COMMAND_INFO AcpiGbl_DbCommands[] = 234{ 235 {"<NOT FOUND>", 0}, 236 {"<NULL>", 0}, 237 {"ALLOCATIONS", 0}, 238 {"ARGS", 0}, 239 {"ARGUMENTS", 0}, 240 {"BREAKPOINT", 1}, 241 {"CALL", 0}, 242 {"CLOSE", 0}, 243 {"DEBUG", 1}, 244 {"DUMP", 1}, 245 {"ENABLEACPI", 0}, 246 {"EVENT", 1}, 247 {"EXECUTE", 1}, 248 {"EXIT", 0}, 249 {"FIND", 1}, 250 {"GO", 0}, 251 {"HELP", 0}, 252 {"?", 0}, 253 {"HISTORY", 0}, 254 {"!", 1}, 255 {"!!", 0}, 256 {"INFORMATION", 0}, 257 {"INTO", 0}, 258 {"LEVEL", 0}, 259 {"LIST", 0}, 260 {"LOAD", 1}, 261 {"LOCALS", 0}, 262 {"LOCKS", 0}, 263 {"METHODS", 0}, 264 {"NAMESPACE", 0}, 265 {"NOTIFY", 2}, 266 {"OBJECT", 1}, 267 {"OPEN", 1}, 268 {"OWNER", 1}, 269 {"PREFIX", 0}, 270 {"QUIT", 0}, 271 {"REFERENCES", 1}, 272 {"RESOURCES", 1}, 273 {"RESULTS", 0}, 274 {"SET", 3}, 275 {"STATS", 0}, 276 {"STOP", 0}, 277 {"TABLES", 0}, 278 {"TERMINATE", 0}, 279 {"THREADS", 3}, 280 {"TREE", 0}, 281 {"UNLOAD", 1}, 282 {NULL, 0} 283}; 284 285 286/******************************************************************************* 287 * 288 * FUNCTION: AcpiDbDisplayHelp 289 * 290 * PARAMETERS: HelpType - Subcommand (optional) 291 * 292 * RETURN: None 293 * 294 * DESCRIPTION: Print a usage message. 295 * 296 ******************************************************************************/ 297 298void 299AcpiDbDisplayHelp ( 300 NATIVE_CHAR *HelpType) 301{ 302 303 304 /* No parameter, just give the overview */ 305 306 if (!HelpType) 307 { 308 AcpiOsPrintf ("ACPI CA Debugger Commands\n\n"); 309 AcpiOsPrintf ("The following classes of commands are available. Help is available for\n"); 310 AcpiOsPrintf ("each class by entering \"Help <ClassName>\"\n\n"); 311 AcpiOsPrintf (" [GENERAL] General-Purpose Commands\n"); 312 AcpiOsPrintf (" [NAMESPACE] Namespace Access Commands\n"); 313 AcpiOsPrintf (" [METHOD] Control Method Execution Commands\n"); 314 AcpiOsPrintf (" [FILE] File I/O Commands\n"); 315 return; 316 317 } 318 319 320 /* 321 * Parameter is the command class 322 * 323 * The idea here is to keep each class of commands smaller than a screenful 324 */ 325 326 switch (HelpType[0]) 327 { 328 case 'G': 329 AcpiOsPrintf ("\nGeneral-Purpose Commands\n\n"); 330 AcpiOsPrintf ("Allocations Display list of current memory allocations\n"); 331 AcpiOsPrintf ("Dump <Address>|<Namepath>\n"); 332 AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n"); 333 AcpiOsPrintf ("EnableAcpi Enable ACPI (hardware) mode\n"); 334 AcpiOsPrintf ("Help This help screen\n"); 335 AcpiOsPrintf ("History Display command history buffer\n"); 336 AcpiOsPrintf ("Level [<DebugLevel>] [console] Get/Set debug level for file or console\n"); 337 AcpiOsPrintf ("Locks Current status of internal mutexes\n"); 338 AcpiOsPrintf ("Quit or Exit Exit this command\n"); 339 AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n"); 340 AcpiOsPrintf (" |Objects|Tables] Display namespace and memory statistics\n"); 341 AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n"); 342 AcpiOsPrintf ("Unload <TableSig> [Instance] Unload an ACPI table\n"); 343 AcpiOsPrintf ("! <CommandNumber> Execute command from history buffer\n"); 344 AcpiOsPrintf ("!! Execute last command again\n"); 345 return; 346 347 case 'N': 348 AcpiOsPrintf ("\nNamespace Access Commands\n\n"); 349 AcpiOsPrintf ("Debug <Namepath> [Arguments] Single Step a control method\n"); 350 AcpiOsPrintf ("Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n"); 351 AcpiOsPrintf ("Execute <Namepath> [Arguments] Execute control method\n"); 352 AcpiOsPrintf ("Find <Name> (? is wildcard) Find ACPI name(s) with wildcards\n"); 353 AcpiOsPrintf ("Method Display list of loaded control methods\n"); 354 AcpiOsPrintf ("Namespace [<Addr>|<Path>] [Depth] Display loaded namespace tree/subtree\n"); 355 AcpiOsPrintf ("Notify <NamePath> <Value> Send a notification\n"); 356 AcpiOsPrintf ("Objects <ObjectType> Display all objects of the given type\n"); 357 AcpiOsPrintf ("Owner <OwnerId> [Depth] Display loaded namespace by object owner\n"); 358 AcpiOsPrintf ("Prefix [<NamePath>] Set or Get current execution prefix\n"); 359 AcpiOsPrintf ("References <Addr> Find all references to object at addr\n"); 360 AcpiOsPrintf ("Resources xxx Get and display resources\n"); 361 AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n"); 362 AcpiOsPrintf ("Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n"); 363 return; 364 365 case 'M': 366 AcpiOsPrintf ("\nControl Method Execution Commands\n\n"); 367 AcpiOsPrintf ("Arguments (or Args) Display method arguments\n"); 368 AcpiOsPrintf ("Breakpoint <AmlOffset> Set an AML execution breakpoint\n"); 369 AcpiOsPrintf ("Call Run to next control method invocation\n"); 370 AcpiOsPrintf ("Go Allow method to run to completion\n"); 371 AcpiOsPrintf ("Information Display info about the current method\n"); 372 AcpiOsPrintf ("Into Step into (not over) a method call\n"); 373 AcpiOsPrintf ("List [# of Aml Opcodes] Display method ASL statements\n"); 374 AcpiOsPrintf ("Locals Display method local variables\n"); 375 AcpiOsPrintf ("Results Display method result stack\n"); 376 AcpiOsPrintf ("Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n"); 377 AcpiOsPrintf ("Stop Terminate control method\n"); 378 AcpiOsPrintf ("Tree Display control method calling tree\n"); 379 AcpiOsPrintf ("<Enter> Single step next AML opcode (over calls)\n"); 380 return; 381 382 case 'F': 383 AcpiOsPrintf ("\nFile I/O Commands\n\n"); 384 AcpiOsPrintf ("Close Close debug output file\n"); 385 AcpiOsPrintf ("Open <Output Filename> Open a file for debug output\n"); 386 AcpiOsPrintf ("Load <Input Filename> Load ACPI table from a file\n"); 387 return; 388 389 default: 390 AcpiOsPrintf ("Unrecognized Command Class: %x\n", HelpType); 391 return; 392 } 393} 394 395 396/******************************************************************************* 397 * 398 * FUNCTION: AcpiDbGetNextToken 399 * 400 * PARAMETERS: String - Command buffer 401 * Next - Return value, end of next token 402 * 403 * RETURN: Pointer to the start of the next token. 404 * 405 * DESCRIPTION: Command line parsing. Get the next token on the command line 406 * 407 ******************************************************************************/ 408 409NATIVE_CHAR * 410AcpiDbGetNextToken ( 411 NATIVE_CHAR *String, 412 NATIVE_CHAR **Next) 413{ 414 NATIVE_CHAR *Start; 415 416 /* At end of buffer? */ 417 418 if (!String || !(*String)) 419 { 420 return (NULL); 421 } 422 423 424 /* Get rid of any spaces at the beginning */ 425 426 if (*String == ' ') 427 { 428 while (*String && (*String == ' ')) 429 { 430 String++; 431 } 432 433 if (!(*String)) 434 { 435 return (NULL); 436 } 437 } 438 439 Start = String; 440 441 /* Find end of token */ 442 443 while (*String && (*String != ' ')) 444 { 445 String++; 446 } 447 448 449 if (!(*String)) 450 { 451 *Next = NULL; 452 } 453 454 else 455 { 456 *String = 0; 457 *Next = String + 1; 458 } 459 460 return (Start); 461} 462 463 464/******************************************************************************* 465 * 466 * FUNCTION: AcpiDbGetLine 467 * 468 * PARAMETERS: InputBuffer - Command line buffer 469 * 470 * RETURN: None 471 * 472 * DESCRIPTION: Get the next command line from the user. Gets entire line 473 * up to the next newline 474 * 475 ******************************************************************************/ 476 477UINT32 478AcpiDbGetLine ( 479 NATIVE_CHAR *InputBuffer) 480{ 481 UINT32 i; 482 UINT32 Count; 483 NATIVE_CHAR *Next; 484 NATIVE_CHAR *This; 485 486 487 STRCPY (AcpiGbl_DbParsedBuf, InputBuffer); 488 STRUPR (AcpiGbl_DbParsedBuf); 489 490 This = AcpiGbl_DbParsedBuf; 491 for (i = 0; i < DB_MAX_ARGS; i++) 492 { 493 AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next); 494 if (!AcpiGbl_DbArgs[i]) 495 { 496 break; 497 } 498 499 This = Next; 500 } 501 502 503 /* Uppercase the actual command */ 504 505 if (AcpiGbl_DbArgs[0]) 506 { 507 STRUPR (AcpiGbl_DbArgs[0]); 508 } 509 510 Count = i; 511 if (Count) 512 { 513 Count--; /* Number of args only */ 514 } 515 516 return (Count); 517} 518 519 520/******************************************************************************* 521 * 522 * FUNCTION: AcpiDbMatchCommand 523 * 524 * PARAMETERS: UserCommand - User command line 525 * 526 * RETURN: Index into command array, -1 if not found 527 * 528 * DESCRIPTION: Search command array for a command match 529 * 530 ******************************************************************************/ 531 532UINT32 533AcpiDbMatchCommand ( 534 NATIVE_CHAR *UserCommand) 535{ 536 UINT32 i; 537 538 539 if (!UserCommand || UserCommand[0] == 0) 540 { 541 return (CMD_NULL); 542 } 543 544 for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++) 545 { 546 if (STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) == AcpiGbl_DbCommands[i].Name) 547 { 548 return (i); 549 } 550 } 551 552 /* Command not recognized */ 553 554 return (CMD_NOT_FOUND); 555} 556 557 558/******************************************************************************* 559 * 560 * FUNCTION: AcpiDbCommandDispatch 561 * 562 * PARAMETERS: InputBuffer - Command line buffer 563 * WalkState - Current walk 564 * Op - Current (executing) parse op 565 * 566 * RETURN: Status 567 * 568 * DESCRIPTION: Command dispatcher. Called from two places: 569 * 570 ******************************************************************************/ 571 572ACPI_STATUS 573AcpiDbCommandDispatch ( 574 NATIVE_CHAR *InputBuffer, 575 ACPI_WALK_STATE *WalkState, 576 ACPI_PARSE_OBJECT *Op) 577{ 578 UINT32 Temp; 579 UINT32 CommandIndex; 580 UINT32 ParamCount; 581 NATIVE_CHAR *CommandLine; 582 ACPI_STATUS Status = AE_CTRL_TRUE; 583 584 585 /* If AcpiTerminate has been called, terminate this thread */ 586 587 if (AcpiGbl_DbTerminateThreads) 588 { 589 return (AE_CTRL_TERMINATE); 590 } 591 592 ParamCount = AcpiDbGetLine (InputBuffer); 593 CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]); 594 Temp = 0; 595 596 /* Verify that we have the minimum number of params */ 597 598 if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs) 599 { 600 AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n", 601 ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, AcpiGbl_DbCommands[CommandIndex].MinArgs); 602 return (AE_CTRL_TRUE); 603 } 604 605 /* Decode and dispatch the command */ 606 607 switch (CommandIndex) 608 { 609 case CMD_NULL: 610 if (Op) 611 { 612 return (AE_OK); 613 } 614 break; 615 616 case CMD_ALLOCATIONS: 617 618#ifdef ACPI_DBG_TRACK_ALLOCATIONS 619 AcpiUtDumpAllocations ((UINT32) -1, NULL); 620#endif 621 break; 622 623 case CMD_ARGS: 624 case CMD_ARGUMENTS: 625 AcpiDbDisplayArguments (); 626 break; 627 628 case CMD_BREAKPOINT: 629 AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op); 630 break; 631 632 case CMD_CALL: 633 AcpiDbSetMethodCallBreakpoint (Op); 634 Status = AE_OK; 635 break; 636 637 case CMD_CLOSE: 638 AcpiDbCloseDebugFile (); 639 break; 640 641 case CMD_DEBUG: 642 AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_SINGLE_STEP); 643 break; 644 645 case CMD_DUMP: 646 AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 647 break; 648 649 case CMD_ENABLEACPI: 650 Status = AcpiEnable(); 651 if (ACPI_FAILURE(Status)) 652 { 653 AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status); 654 return (Status); 655 } 656 break; 657 658 case CMD_EVENT: 659 AcpiOsPrintf ("Event command not implemented\n"); 660 break; 661 662 case CMD_EXECUTE: 663 AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP); 664 break; 665 666 case CMD_FIND: 667 AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]); 668 break; 669 670 case CMD_GO: 671 AcpiGbl_CmSingleStep = FALSE; 672 return (AE_OK); 673 674 case CMD_HELP: 675 case CMD_HELP2: 676 AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]); 677 break; 678 679 case CMD_HISTORY: 680 AcpiDbDisplayHistory (); 681 break; 682 683 case CMD_HISTORY_EXE: 684 CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]); 685 if (!CommandLine) 686 { 687 return (AE_CTRL_TRUE); 688 } 689 690 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); 691 if (ACPI_SUCCESS (Status)) 692 { 693 Status = AE_CTRL_TRUE; 694 } 695 return (Status); 696 break; 697 698 case CMD_HISTORY_LAST: 699 CommandLine = AcpiDbGetFromHistory (NULL); 700 if (!CommandLine) 701 { 702 return (AE_CTRL_TRUE); 703 } 704 705 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); 706 if (ACPI_SUCCESS (Status)) 707 { 708 Status = AE_CTRL_TRUE; 709 } 710 return (Status); 711 712 case CMD_INFORMATION: 713 AcpiDbDisplayMethodInfo (Op); 714 break; 715 716 case CMD_INTO: 717 if (Op) 718 { 719 AcpiGbl_CmSingleStep = TRUE; 720 721/* TBD: Must get current walk state */ 722 /* AcpiGbl_MethodBreakpoint = 0; */ 723 return (AE_OK); 724 } 725 break; 726 727 case CMD_LEVEL: 728 if (ParamCount == 0) 729 { 730 AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", AcpiGbl_DbDebugLevel); 731 AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", AcpiGbl_DbConsoleDebugLevel); 732 } 733 else if (ParamCount == 2) 734 { 735 Temp = AcpiGbl_DbConsoleDebugLevel; 736 AcpiGbl_DbConsoleDebugLevel = STRTOUL (AcpiGbl_DbArgs[1], NULL, 16); 737 AcpiOsPrintf ("Debug Level for console output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbConsoleDebugLevel); 738 } 739 else 740 { 741 Temp = AcpiGbl_DbDebugLevel; 742 AcpiGbl_DbDebugLevel = STRTOUL (AcpiGbl_DbArgs[1], NULL, 16); 743 AcpiOsPrintf ("Debug Level for file output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbDebugLevel); 744 } 745 break; 746 747 case CMD_LIST: 748 AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op); 749 break; 750 751 case CMD_LOAD: 752 Status = AcpiDbLoadAcpiTable (AcpiGbl_DbArgs[1]); 753 if (ACPI_FAILURE (Status)) 754 { 755 return (Status); 756 } 757 break; 758 759 case CMD_LOCKS: 760 AcpiDbDisplayLocks (); 761 break; 762 763 case CMD_LOCALS: 764 AcpiDbDisplayLocals (); 765 break; 766 767 case CMD_METHODS: 768 AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]); 769 break; 770 771 case CMD_NAMESPACE: 772 AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 773 break; 774 775 case CMD_NOTIFY: 776 Temp = STRTOUL (AcpiGbl_DbArgs[2], NULL, 0); 777 AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp); 778 break; 779 780 case CMD_OBJECT: 781 AcpiDbDisplayObjects (STRUPR (AcpiGbl_DbArgs[1]), AcpiGbl_DbArgs[2]); 782 break; 783 784 case CMD_OPEN: 785 AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]); 786 break; 787 788 case CMD_OWNER: 789 AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 790 break; 791 792 case CMD_PREFIX: 793 AcpiDbSetScope (AcpiGbl_DbArgs[1]); 794 break; 795 796 case CMD_REFERENCES: 797 AcpiDbFindReferences (AcpiGbl_DbArgs[1]); 798 break; 799 800 case CMD_RESOURCES: 801 AcpiDbDisplayResources (AcpiGbl_DbArgs[1]); 802 break; 803 804 case CMD_RESULTS: 805 AcpiDbDisplayResults (); 806 break; 807 808 case CMD_SET: 809 AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); 810 break; 811 812 case CMD_STATS: 813 AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]); 814 break; 815 816 case CMD_STOP: 817 return (AE_AML_ERROR); 818 break; 819 820 case CMD_TABLES: 821 AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]); 822 break; 823 824 case CMD_TERMINATE: 825 AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); 826 AcpiUtSubsystemShutdown (); 827 828 /* TBD: [Restructure] Need some way to re-initialize without re-creating the semaphores! */ 829 830 /* AcpiInitialize (NULL); */ 831 break; 832 833 case CMD_THREADS: 834 AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); 835 break; 836 837 case CMD_TREE: 838 AcpiDbDisplayCallingTree (); 839 break; 840 841 case CMD_UNLOAD: 842 AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 843 break; 844 845 case CMD_EXIT: 846 case CMD_QUIT: 847 if (Op) 848 { 849 AcpiOsPrintf ("Method execution terminated\n"); 850 return (AE_CTRL_TERMINATE); 851 } 852 853 if (!AcpiGbl_DbOutputToFile) 854 { 855 AcpiDbgLevel = DEBUG_DEFAULT; 856 } 857 858 /* Shutdown */ 859 860 /* AcpiUtSubsystemShutdown (); */ 861 AcpiDbCloseDebugFile (); 862 863 AcpiGbl_DbTerminateThreads = TRUE; 864 865 return (AE_CTRL_TERMINATE); 866 867 case CMD_NOT_FOUND: 868 AcpiOsPrintf ("Unknown Command\n"); 869 return (AE_CTRL_TRUE); 870 } 871 872 873 /* Add all commands that come here to the history buffer */ 874 875 AcpiDbAddToHistory (InputBuffer); 876 return (Status); 877} 878 879 880/******************************************************************************* 881 * 882 * FUNCTION: AcpiDbExecuteThread 883 * 884 * PARAMETERS: Context - Not used 885 * 886 * RETURN: None 887 * 888 * DESCRIPTION: Debugger execute thread. Waits for a command line, then 889 * simply dispatches it. 890 * 891 ******************************************************************************/ 892 893void 894AcpiDbExecuteThread ( 895 void *Context) 896{ 897 ACPI_STATUS Status = AE_OK; 898 899 900 while (Status != AE_CTRL_TERMINATE) 901 { 902 AcpiGbl_MethodExecuting = FALSE; 903 AcpiGbl_StepToNextCall = FALSE; 904 905 AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); 906 Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); 907 AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); 908 } 909} 910 911 912/******************************************************************************* 913 * 914 * FUNCTION: AcpiDbSingleThread 915 * 916 * PARAMETERS: None 917 * 918 * RETURN: None 919 * 920 * DESCRIPTION: Debugger execute thread. Waits for a command line, then 921 * simply dispatches it. 922 * 923 ******************************************************************************/ 924 925void 926AcpiDbSingleThread ( 927 void) 928{ 929 ACPI_STATUS Status = AE_OK; 930 931 932 AcpiGbl_MethodExecuting = FALSE; 933 AcpiGbl_StepToNextCall = FALSE; 934 935 Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); 936} 937 938 939/******************************************************************************* 940 * 941 * FUNCTION: AcpiDbUserCommands 942 * 943 * PARAMETERS: Prompt - User prompt (depends on mode) 944 * Op - Current executing parse op 945 * 946 * RETURN: None 947 * 948 * DESCRIPTION: Command line execution for the AML debugger. Commands are 949 * matched and dispatched here. 950 * 951 ******************************************************************************/ 952 953ACPI_STATUS 954AcpiDbUserCommands ( 955 NATIVE_CHAR Prompt, 956 ACPI_PARSE_OBJECT *Op) 957{ 958 ACPI_STATUS Status = AE_OK; 959 960 961 /* TBD: [Restructure] Need a separate command line buffer for step mode */ 962 963 while (!AcpiGbl_DbTerminateThreads) 964 { 965 /* Force output to console until a command is entered */ 966 967 AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); 968 969 /* Different prompt if method is executing */ 970 971 if (!AcpiGbl_MethodExecuting) 972 { 973 AcpiOsPrintf ("%1c ", DB_COMMAND_PROMPT); 974 } 975 else 976 { 977 AcpiOsPrintf ("%1c ", DB_EXECUTE_PROMPT); 978 } 979 980 /* Get the user input line */ 981 982 AcpiOsGetLine (AcpiGbl_DbLineBuf); 983 984 985 /* Check for single or multithreaded debug */ 986 987 if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) 988 { 989 /* 990 * Signal the debug thread that we have a command to execute, 991 * and wait for the command to complete. 992 */ 993 AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); 994 AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); 995 } 996 997 else 998 { 999 /* Just call to the command line interpreter */ 1000 1001 AcpiDbSingleThread (); 1002 } 1003 } 1004 1005 1006 /* 1007 * Only this thread (the original thread) should actually terminate the subsystem, 1008 * because all the semaphores are deleted during termination 1009 */ 1010 AcpiTerminate (); 1011 return (Status); 1012} 1013 1014 1015#endif /* ENABLE_DEBUGGER */ 1016 1017