dbinput.c revision 69746
1/******************************************************************************* 2 * 3 * Module Name: dbinput - user front-end to the AML debugger 4 * $Revision: 52 $ 5 * 6 ******************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights 13 * 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 DEBUGGER 129 MODULE_NAME ("dbinput") 130 131 132/* 133 * Globals that are specific to the debugger 134 */ 135 136NATIVE_CHAR LineBuf[80]; 137NATIVE_CHAR ParsedBuf[80]; 138NATIVE_CHAR ScopeBuf[40]; 139NATIVE_CHAR DebugFilename[40]; 140NATIVE_CHAR *Args[DB_MAX_ARGS]; 141NATIVE_CHAR *Buffer; 142NATIVE_CHAR *Filename = NULL; 143BOOLEAN OutputToFile = FALSE; 144 145 146UINT32 AcpiGbl_DbDebugLevel = 0x0FFFFFFF; 147UINT32 AcpiGbl_DbConsoleDebugLevel = NORMAL_DEFAULT | TRACE_TABLES; 148UINT8 AcpiGbl_DbOutputFlags = DB_CONSOLE_OUTPUT; 149 150 151BOOLEAN opt_tables = FALSE; 152BOOLEAN opt_disasm = FALSE; 153BOOLEAN opt_stats = FALSE; 154BOOLEAN opt_parse_jit = FALSE; 155BOOLEAN opt_verbose = TRUE; 156 157 158/* 159 * Top-level debugger commands. 160 * 161 * This list of commands must match the string table below it 162 */ 163 164enum AcpiAmlDebuggerCommands 165{ 166 CMD_NOT_FOUND = 0, 167 CMD_NULL, 168 CMD_ALLOCATIONS, 169 CMD_ARGS, 170 CMD_ARGUMENTS, 171 CMD_BREAKPOINT, 172 CMD_CALL, 173 CMD_CLOSE, 174 CMD_DEBUG, 175 CMD_DUMP, 176 CMD_ENABLEACPI, 177 CMD_EVENT, 178 CMD_EXECUTE, 179 CMD_EXIT, 180 CMD_FIND, 181 CMD_GO, 182 CMD_HELP, 183 CMD_HELP2, 184 CMD_HISTORY, 185 CMD_HISTORY_EXE, 186 CMD_HISTORY_LAST, 187 CMD_INFORMATION, 188 CMD_INTO, 189 CMD_LEVEL, 190 CMD_LIST, 191 CMD_LOAD, 192 CMD_LOCALS, 193 CMD_METHODS, 194 CMD_NAMESPACE, 195 CMD_NOTIFY, 196 CMD_OBJECT, 197 CMD_OPEN, 198 CMD_OWNER, 199 CMD_PREFIX, 200 CMD_QUIT, 201 CMD_REFERENCES, 202 CMD_RESULTS, 203 CMD_SET, 204 CMD_STATS, 205 CMD_STOP, 206 CMD_TABLES, 207 CMD_TERMINATE, 208 CMD_THREADS, 209 CMD_TREE, 210 CMD_UNLOAD 211}; 212 213#define CMD_FIRST_VALID 2 214 215 216COMMAND_INFO Commands[] = 217{ 218 {"<NOT FOUND>", 0}, 219 {"<NULL>", 0}, 220 {"ALLOCATIONS", 0}, 221 {"ARGS", 0}, 222 {"ARGUMENTS", 0}, 223 {"BREAKPOINT", 1}, 224 {"CALL", 0}, 225 {"CLOSE", 0}, 226 {"DEBUG", 1}, 227 {"DUMP", 1}, 228 {"ENABLEACPI", 0}, 229 {"EVENT", 1}, 230 {"EXECUTE", 1}, 231 {"EXIT", 0}, 232 {"FIND", 1}, 233 {"GO", 0}, 234 {"HELP", 0}, 235 {"?", 0}, 236 {"HISTORY", 0}, 237 {"!", 1}, 238 {"!!", 0}, 239 {"INFORMATION", 0}, 240 {"INTO", 0}, 241 {"LEVEL", 0}, 242 {"LIST", 0}, 243 {"LOAD", 1}, 244 {"LOCALS", 0}, 245 {"METHODS", 0}, 246 {"NAMESPACE", 0}, 247 {"NOTIFY", 2}, 248 {"OBJECT", 1}, 249 {"OPEN", 1}, 250 {"OWNER", 1}, 251 {"PREFIX", 0}, 252 {"QUIT", 0}, 253 {"REFERENCES", 1}, 254 {"RESULTS", 0}, 255 {"SET", 3}, 256 {"STATS", 0}, 257 {"STOP", 0}, 258 {"TABLES", 0}, 259 {"TERMINATE", 0}, 260 {"THREADS", 3}, 261 {"TREE", 0}, 262 {"UNLOAD", 0}, 263 {NULL, 0} 264}; 265 266 267/******************************************************************************* 268 * 269 * FUNCTION: AcpiDbDisplayHelp 270 * 271 * PARAMETERS: HelpType - Subcommand (optional) 272 * 273 * RETURN: None 274 * 275 * DESCRIPTION: Print a usage message. 276 * 277 ******************************************************************************/ 278 279void 280AcpiDbDisplayHelp ( 281 NATIVE_CHAR *HelpType) 282{ 283 284 285 /* No parameter, just give the overview */ 286 287 if (!HelpType) 288 { 289 AcpiOsPrintf ("ACPI CA Debugger Commands\n\n"); 290 AcpiOsPrintf ("The following classes of commands are available. Help is available for\n"); 291 AcpiOsPrintf ("each class by entering \"Help <ClassName>\"\n\n"); 292 AcpiOsPrintf (" [GENERAL] General-Purpose Commands\n"); 293 AcpiOsPrintf (" [NAMESPACE] Namespace Access Commands\n"); 294 AcpiOsPrintf (" [METHOD] Control Method Execution Commands\n"); 295 AcpiOsPrintf (" [FILE] File I/O Commands\n"); 296 return; 297 298 } 299 300 301 /* 302 * Parameter is the command class 303 * 304 * The idea here is to keep each class of commands smaller than a screenful 305 */ 306 307 switch (HelpType[0]) 308 { 309 case 'G': 310 AcpiOsPrintf ("\nGeneral-Purpose Commands\n\n"); 311 AcpiOsPrintf ("Allocations Display list of current memory allocations\n"); 312 AcpiOsPrintf ("Dump <Address>|<Namepath>\n"); 313 AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n"); 314 AcpiOsPrintf ("EnableAcpi Enable ACPI (hardware) mode\n"); 315 AcpiOsPrintf ("Help This help screen\n"); 316 AcpiOsPrintf ("History Display command history buffer\n"); 317 AcpiOsPrintf ("Level [<DebugLevel>] [console] Get/Set debug level for file or console\n"); 318 AcpiOsPrintf ("Quit or Exit Exit this command\n"); 319 AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n"); 320 AcpiOsPrintf (" |Objects|Tables] Display namespace and memory statistics\n"); 321 AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n"); 322 AcpiOsPrintf ("Unload Unload an ACPI table\n"); 323 AcpiOsPrintf ("! <CommandNumber> Execute command from history buffer\n"); 324 AcpiOsPrintf ("!! Execute last command again\n"); 325 return; 326 327 case 'N': 328 AcpiOsPrintf ("\nNamespace Access Commands\n\n"); 329 AcpiOsPrintf ("Debug <Namepath> [Arguments] Single Step a control method\n"); 330 AcpiOsPrintf ("Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n"); 331 AcpiOsPrintf ("Execute <Namepath> [Arguments] Execute control method\n"); 332 AcpiOsPrintf ("Find <Name> (? is wildcard) Find ACPI name(s) with wildcards\n"); 333 AcpiOsPrintf ("Method Display list of loaded control methods\n"); 334 AcpiOsPrintf ("Namespace [<Addr>|<Path>] [Depth] Display loaded namespace tree/subtree\n"); 335 AcpiOsPrintf ("Notify <NamePath> <Value> Send a notification\n"); 336 AcpiOsPrintf ("Objects <ObjectType> Display all objects of the given type\n"); 337 AcpiOsPrintf ("Owner <OwnerId> [Depth] Display loaded namespace by object owner\n"); 338 AcpiOsPrintf ("Prefix [<NamePath>] Set or Get current execution prefix\n"); 339 AcpiOsPrintf ("References <Addr> Find all references to object at addr\n"); 340 AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n"); 341 AcpiOsPrintf ("Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n"); 342 return; 343 344 case 'M': 345 AcpiOsPrintf ("\nControl Method Execution Commands\n\n"); 346 AcpiOsPrintf ("Arguments (or Args) Display method arguments\n"); 347 AcpiOsPrintf ("Breakpoint <AmlOffset> Set an AML execution breakpoint\n"); 348 AcpiOsPrintf ("Call Run to next control method invocation\n"); 349 AcpiOsPrintf ("Go Allow method to run to completion\n"); 350 AcpiOsPrintf ("Information Display info about the current method\n"); 351 AcpiOsPrintf ("Into Step into (not over) a method call\n"); 352 AcpiOsPrintf ("List [# of AcpiAml Opcodes] Display method ASL statements\n"); 353 AcpiOsPrintf ("Locals Display method local variables\n"); 354 AcpiOsPrintf ("Results Display method result stack\n"); 355 AcpiOsPrintf ("Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n"); 356 AcpiOsPrintf ("Stop Terminate control method\n"); 357 AcpiOsPrintf ("Tree Display control method calling tree\n"); 358 AcpiOsPrintf ("<Enter> Single step next AML opcode (over calls)\n"); 359 return; 360 361 case 'F': 362 AcpiOsPrintf ("\nFile I/O Commands\n\n"); 363 AcpiOsPrintf ("Close Close debug output file\n"); 364 AcpiOsPrintf ("Open <Output Filename> Open a file for debug output\n"); 365 AcpiOsPrintf ("Load <Input Filename> Load ACPI table from a file\n"); 366 return; 367 368 default: 369 AcpiOsPrintf ("Unrecognized Command Class: %x\n", HelpType); 370 return; 371 } 372} 373 374 375/******************************************************************************* 376 * 377 * FUNCTION: AcpiDbGetNextToken 378 * 379 * PARAMETERS: String - Command buffer 380 * Next - Return value, end of next token 381 * 382 * RETURN: Pointer to the start of the next token. 383 * 384 * DESCRIPTION: Command line parsing. Get the next token on the command line 385 * 386 ******************************************************************************/ 387 388NATIVE_CHAR * 389AcpiDbGetNextToken ( 390 NATIVE_CHAR *String, 391 NATIVE_CHAR **Next) 392{ 393 NATIVE_CHAR *Start; 394 395 /* At end of buffer? */ 396 397 if (!String || !(*String)) 398 { 399 return (NULL); 400 } 401 402 403 /* Get rid of any spaces at the beginning */ 404 405 if (*String == ' ') 406 { 407 while (*String && (*String == ' ')) 408 { 409 String++; 410 } 411 412 if (!(*String)) 413 { 414 return (NULL); 415 } 416 } 417 418 Start = String; 419 420 /* Find end of token */ 421 422 while (*String && (*String != ' ')) 423 { 424 String++; 425 } 426 427 428 if (!(*String)) 429 { 430 *Next = NULL; 431 } 432 433 else 434 { 435 *String = 0; 436 *Next = String + 1; 437 } 438 439 return (Start); 440} 441 442 443/******************************************************************************* 444 * 445 * FUNCTION: AcpiDbGetLine 446 * 447 * PARAMETERS: InputBuffer - Command line buffer 448 * 449 * RETURN: None 450 * 451 * DESCRIPTION: Get the next command line from the user. Gets entire line 452 * up to the next newline 453 * 454 ******************************************************************************/ 455 456UINT32 457AcpiDbGetLine ( 458 NATIVE_CHAR *InputBuffer) 459{ 460 UINT32 i; 461 UINT32 Count; 462 NATIVE_CHAR *Next; 463 NATIVE_CHAR *This; 464 465 466 STRCPY (ParsedBuf, InputBuffer); 467 STRUPR (ParsedBuf); 468 469 This = ParsedBuf; 470 for (i = 0; i < DB_MAX_ARGS; i++) 471 { 472 Args[i] = AcpiDbGetNextToken (This, &Next); 473 if (!Args[i]) 474 { 475 break; 476 } 477 478 This = Next; 479 } 480 481 482 /* Uppercase the actual command */ 483 484 if (Args[0]) 485 { 486 STRUPR (Args[0]); 487 } 488 489 Count = i; 490 if (Count) 491 { 492 Count--; /* Number of args only */ 493 } 494 495 return (Count); 496} 497 498 499/******************************************************************************* 500 * 501 * FUNCTION: AcpiDbMatchCommand 502 * 503 * PARAMETERS: UserCommand - User command line 504 * 505 * RETURN: Index into command array, -1 if not found 506 * 507 * DESCRIPTION: Search command array for a command match 508 * 509 ******************************************************************************/ 510 511UINT32 512AcpiDbMatchCommand ( 513 NATIVE_CHAR *UserCommand) 514{ 515 UINT32 i; 516 517 518 if (!UserCommand || UserCommand[0] == 0) 519 { 520 return (CMD_NULL); 521 } 522 523 for (i = CMD_FIRST_VALID; Commands[i].Name; i++) 524 { 525 if (STRSTR (Commands[i].Name, UserCommand) == Commands[i].Name) 526 { 527 return (i); 528 } 529 } 530 531 /* Command not recognized */ 532 533 return (CMD_NOT_FOUND); 534} 535 536 537/******************************************************************************* 538 * 539 * FUNCTION: AcpiDbCommandDispatch 540 * 541 * PARAMETERS: InputBuffer - Command line buffer 542 * WalkState - Current walk 543 * Op - Current (executing) parse op 544 * 545 * RETURN: Status 546 * 547 * DESCRIPTION: Command dispatcher. Called from two places: 548 * 549 ******************************************************************************/ 550 551ACPI_STATUS 552AcpiDbCommandDispatch ( 553 NATIVE_CHAR *InputBuffer, 554 ACPI_WALK_STATE *WalkState, 555 ACPI_PARSE_OBJECT *Op) 556{ 557 UINT32 Temp; 558 UINT32 CommandIndex; 559 UINT32 ParamCount; 560 NATIVE_CHAR *CommandLine; 561 ACPI_STATUS Status = AE_CTRL_TRUE; 562 563 564 /* If AcpiTerminate has been called, terminate this thread */ 565 566 if (AcpiGbl_DbTerminateThreads) 567 { 568 return (AE_CTRL_TERMINATE); 569 } 570 571 ParamCount = AcpiDbGetLine (InputBuffer); 572 CommandIndex = AcpiDbMatchCommand (Args[0]); 573 Temp = 0; 574 575 /* Verify that we have the minimum number of params */ 576 577 if (ParamCount < Commands[CommandIndex].MinArgs) 578 { 579 AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n", 580 ParamCount, Commands[CommandIndex].Name, Commands[CommandIndex].MinArgs); 581 return (AE_CTRL_TRUE); 582 } 583 584 /* Decode and dispatch the command */ 585 586 switch (CommandIndex) 587 { 588 case CMD_NULL: 589 if (Op) 590 { 591 return (AE_OK); 592 } 593 break; 594 595 case CMD_ALLOCATIONS: 596 AcpiCmDumpCurrentAllocations ((UINT32) -1, NULL); 597 break; 598 599 case CMD_ARGS: 600 case CMD_ARGUMENTS: 601 AcpiDbDisplayArguments (); 602 break; 603 604 case CMD_BREAKPOINT: 605 AcpiDbSetMethodBreakpoint (Args[1], WalkState, Op); 606 break; 607 608 case CMD_CALL: 609 AcpiDbSetMethodCallBreakpoint (Op); 610 Status = AE_OK; 611 break; 612 613 case CMD_CLOSE: 614 AcpiDbCloseDebugFile (); 615 break; 616 617 case CMD_DEBUG: 618 AcpiDbExecute (Args[1], &Args[2], EX_SINGLE_STEP); 619 break; 620 621 case CMD_DUMP: 622 AcpiDbDecodeAndDisplayObject (Args[1], Args[2]); 623 break; 624 625 case CMD_ENABLEACPI: 626 Status = AcpiEnable(); 627 if (ACPI_FAILURE(Status)) 628 { 629 AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status); 630 return (Status); 631 } 632 break; 633 634 case CMD_EVENT: 635 AcpiOsPrintf ("Event command not implemented\n"); 636 break; 637 638 case CMD_EXECUTE: 639 AcpiDbExecute (Args[1], &Args[2], EX_NO_SINGLE_STEP); 640 break; 641 642 case CMD_FIND: 643 AcpiDbFindNameInNamespace (Args[1]); 644 break; 645 646 case CMD_GO: 647 AcpiGbl_CmSingleStep = FALSE; 648 return (AE_OK); 649 650 case CMD_HELP: 651 case CMD_HELP2: 652 AcpiDbDisplayHelp (Args[1]); 653 break; 654 655 case CMD_HISTORY: 656 AcpiDbDisplayHistory (); 657 break; 658 659 case CMD_HISTORY_EXE: 660 CommandLine = AcpiDbGetFromHistory (Args[1]); 661 if (!CommandLine) 662 { 663 return (AE_CTRL_TRUE); 664 } 665 666 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); 667 if (ACPI_SUCCESS (Status)) 668 Status = AE_CTRL_TRUE; 669 return (Status); 670 break; 671 672 case CMD_HISTORY_LAST: 673 CommandLine = AcpiDbGetFromHistory (NULL); 674 if (!CommandLine) 675 { 676 return (AE_CTRL_TRUE); 677 } 678 679 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); 680 if (ACPI_SUCCESS (Status)) 681 Status = AE_CTRL_TRUE; 682 return (Status); 683 684 case CMD_INFORMATION: 685 AcpiDbDisplayMethodInfo (Op); 686 break; 687 688 case CMD_INTO: 689 if (Op) 690 { 691 AcpiGbl_CmSingleStep = TRUE; 692 693/* TBD: Must get current walk state */ 694 /* AcpiGbl_MethodBreakpoint = 0; */ 695 return (AE_OK); 696 } 697 break; 698 699 case CMD_LEVEL: 700 if (ParamCount == 0) 701 { 702 AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", AcpiGbl_DbDebugLevel); 703 AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", AcpiGbl_DbConsoleDebugLevel); 704 } 705 else if (ParamCount == 2) 706 { 707 Temp = AcpiGbl_DbConsoleDebugLevel; 708 AcpiGbl_DbConsoleDebugLevel = STRTOUL (Args[1], NULL, 16); 709 AcpiOsPrintf ("Debug Level for console output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbConsoleDebugLevel); 710 } 711 else 712 { 713 Temp = AcpiGbl_DbDebugLevel; 714 AcpiGbl_DbDebugLevel = STRTOUL (Args[1], NULL, 16); 715 AcpiOsPrintf ("Debug Level for file output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbDebugLevel); 716 } 717 break; 718 719 case CMD_LIST: 720 AcpiDbDisassembleAml (Args[1], Op); 721 break; 722 723 case CMD_LOAD: 724 Status = AcpiDbLoadAcpiTable (Args[1]); 725 if (ACPI_FAILURE (Status)) 726 { 727 return (Status); 728 } 729 break; 730 731 case CMD_LOCALS: 732 AcpiDbDisplayLocals (); 733 break; 734 735 case CMD_METHODS: 736 AcpiDbDisplayObjects ("METHOD", Args[1]); 737 break; 738 739 case CMD_NAMESPACE: 740 AcpiDbDumpNamespace (Args[1], Args[2]); 741 break; 742 743 case CMD_NOTIFY: 744 Temp = STRTOUL (Args[2], NULL, 0); 745 AcpiDbSendNotify (Args[1], Temp); 746 break; 747 748 case CMD_OBJECT: 749 AcpiDbDisplayObjects (Args[1], Args[2]); 750 break; 751 752 case CMD_OPEN: 753 AcpiDbOpenDebugFile (Args[1]); 754 break; 755 756 case CMD_OWNER: 757 AcpiDbDumpNamespaceByOwner (Args[1], Args[2]); 758 break; 759 760 case CMD_PREFIX: 761 AcpiDbSetScope (Args[1]); 762 break; 763 764 case CMD_REFERENCES: 765 AcpiDbFindReferences (Args[1]); 766 break; 767 768 case CMD_RESULTS: 769 AcpiDbDisplayResults (); 770 break; 771 772 case CMD_SET: 773 AcpiDbSetMethodData (Args[1], Args[2], Args[3]); 774 break; 775 776 case CMD_STATS: 777 AcpiDbDisplayStatistics (Args[1]); 778 break; 779 780 case CMD_STOP: 781 return (AE_AML_ERROR); 782 break; 783 784 case CMD_TABLES: 785 AcpiDbDisplayTableInfo (Args[1]); 786 break; 787 788 case CMD_TERMINATE: 789 AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); 790 AcpiCmSubsystemShutdown (); 791 792 /* TBD: [Restructure] Need some way to re-initialize without re-creating the semaphores! */ 793 794 /* AcpiInitialize (NULL); */ 795 break; 796 797 case CMD_THREADS: 798 AcpiDbCreateExecutionThreads (Args[1], Args[2], Args[3]); 799 break; 800 801 case CMD_TREE: 802 AcpiDbDisplayCallingTree (); 803 break; 804 805 case CMD_UNLOAD: 806 AcpiDbUnloadAcpiTable (Args[1], Args[2]); 807 break; 808 809 case CMD_EXIT: 810 case CMD_QUIT: 811 if (Op) 812 { 813 return (AE_AML_ERROR); 814 } 815 816 if (!OutputToFile) 817 { 818 AcpiDbgLevel = DEBUG_DEFAULT; 819 } 820 821 /* Shutdown */ 822 823 /* AcpiCmSubsystemShutdown (); */ 824 AcpiDbCloseDebugFile (); 825 826 AcpiGbl_DbTerminateThreads = TRUE; 827 828 return (AE_CTRL_TERMINATE); 829 830 case CMD_NOT_FOUND: 831 AcpiOsPrintf ("Unknown Command\n"); 832 return (AE_CTRL_TRUE); 833 } 834 835 836 /* Add all commands that come here to the history buffer */ 837 838 AcpiDbAddToHistory (InputBuffer); 839 return (Status); 840} 841 842 843/******************************************************************************* 844 * 845 * FUNCTION: AcpiDbExecuteThread 846 * 847 * PARAMETERS: Context - Not used 848 * 849 * RETURN: None 850 * 851 * DESCRIPTION: Debugger execute thread. Waits for a command line, then 852 * simply dispatches it. 853 * 854 ******************************************************************************/ 855 856void 857AcpiDbExecuteThread ( 858 void *Context) 859{ 860 ACPI_STATUS Status = AE_OK; 861 862 863 while (Status != AE_CTRL_TERMINATE) 864 { 865 AcpiGbl_MethodExecuting = FALSE; 866 AcpiGbl_StepToNextCall = FALSE; 867 868 AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); 869 Status = AcpiDbCommandDispatch (LineBuf, NULL, NULL); 870 AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); 871 } 872} 873 874 875/******************************************************************************* 876 * 877 * FUNCTION: AcpiDbSingleThread 878 * 879 * PARAMETERS: None 880 * 881 * RETURN: None 882 * 883 * DESCRIPTION: Debugger execute thread. Waits for a command line, then 884 * simply dispatches it. 885 * 886 ******************************************************************************/ 887 888void 889AcpiDbSingleThread ( 890 void) 891{ 892 ACPI_STATUS Status = AE_OK; 893 894 895 AcpiGbl_MethodExecuting = FALSE; 896 AcpiGbl_StepToNextCall = FALSE; 897 898 Status = AcpiDbCommandDispatch (LineBuf, NULL, NULL); 899} 900 901 902/******************************************************************************* 903 * 904 * FUNCTION: AcpiDbUserCommands 905 * 906 * PARAMETERS: Prompt - User prompt (depends on mode) 907 * Op - Current executing parse op 908 * 909 * RETURN: None 910 * 911 * DESCRIPTION: Command line execution for the AML debugger. Commands are 912 * matched and dispatched here. 913 * 914 ******************************************************************************/ 915 916ACPI_STATUS 917AcpiDbUserCommands ( 918 NATIVE_CHAR Prompt, 919 ACPI_PARSE_OBJECT *Op) 920{ 921 ACPI_STATUS Status = AE_OK; 922 923 924 /* TBD: [Restructure] Need a separate command line buffer for step mode */ 925 926 while (!AcpiGbl_DbTerminateThreads) 927 { 928 /* Force output to console until a command is entered */ 929 930 AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); 931 932 /* Different prompt if method is executing */ 933 934 if (!AcpiGbl_MethodExecuting) 935 { 936 AcpiOsPrintf ("%1c ", DB_COMMAND_PROMPT); 937 } 938 else 939 { 940 AcpiOsPrintf ("%1c ", DB_EXECUTE_PROMPT); 941 } 942 943 /* Get the user input line */ 944 945 AcpiOsGetLine (LineBuf); 946 947 948 /* Check for single or multithreaded debug */ 949 950 if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) 951 { 952 /* 953 * Signal the debug thread that we have a command to execute, 954 * and wait for the command to complete. 955 */ 956 957 AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); 958 AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); 959 } 960 961 else 962 { 963 /* Just call to the command line interpreter */ 964 965 AcpiDbSingleThread (); 966 } 967 } 968 969 970 /* 971 * Only this thread (the original thread) should actually terminate the subsystem, 972 * because all the semaphores are deleted during termination 973 */ 974 AcpiTerminate (); 975 976 return (Status); 977} 978 979 980#endif /* ENABLE_DEBUGGER */ 981 982