dbinput.c revision 246849
1/******************************************************************************* 2 * 3 * Module Name: dbinput - user front-end to the AML debugger 4 * 5 ******************************************************************************/ 6 7/* 8 * Copyright (C) 2000 - 2013, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 45#include <contrib/dev/acpica/include/acpi.h> 46#include <contrib/dev/acpica/include/accommon.h> 47#include <contrib/dev/acpica/include/acdebug.h> 48 49 50#ifdef ACPI_DEBUGGER 51 52#define _COMPONENT ACPI_CA_DEBUGGER 53 ACPI_MODULE_NAME ("dbinput") 54 55/* Local prototypes */ 56 57static UINT32 58AcpiDbGetLine ( 59 char *InputBuffer); 60 61static UINT32 62AcpiDbMatchCommand ( 63 char *UserCommand); 64 65static void 66AcpiDbSingleThread ( 67 void); 68 69static void 70AcpiDbDisplayCommandInfo ( 71 char *Command, 72 BOOLEAN DisplayAll); 73 74static void 75AcpiDbDisplayHelp ( 76 char *Command); 77 78static BOOLEAN 79AcpiDbMatchCommandHelp ( 80 char *Command, 81 const ACPI_DB_COMMAND_HELP *Help); 82 83 84/* 85 * Top-level debugger commands. 86 * 87 * This list of commands must match the string table below it 88 */ 89enum AcpiExDebuggerCommands 90{ 91 CMD_NOT_FOUND = 0, 92 CMD_NULL, 93 CMD_ALLOCATIONS, 94 CMD_ARGS, 95 CMD_ARGUMENTS, 96 CMD_BATCH, 97 CMD_BREAKPOINT, 98 CMD_BUSINFO, 99 CMD_CALL, 100 CMD_CLOSE, 101 CMD_DEBUG, 102 CMD_DISASSEMBLE, 103 CMD_DISASM, 104 CMD_DUMP, 105 CMD_ENABLEACPI, 106 CMD_EVALUATE, 107 CMD_EVENT, 108 CMD_EXECUTE, 109 CMD_EXIT, 110 CMD_FIND, 111 CMD_GO, 112 CMD_GPE, 113 CMD_GPES, 114 CMD_HANDLERS, 115 CMD_HELP, 116 CMD_HELP2, 117 CMD_HISTORY, 118 CMD_HISTORY_EXE, 119 CMD_HISTORY_LAST, 120 CMD_INFORMATION, 121 CMD_INTEGRITY, 122 CMD_INTO, 123 CMD_LEVEL, 124 CMD_LIST, 125 CMD_LOAD, 126 CMD_LOCALS, 127 CMD_LOCKS, 128 CMD_METHODS, 129 CMD_NAMESPACE, 130 CMD_NOTIFY, 131 CMD_OBJECT, 132 CMD_OPEN, 133 CMD_OSI, 134 CMD_OWNER, 135 CMD_PREDEFINED, 136 CMD_PREFIX, 137 CMD_QUIT, 138 CMD_REFERENCES, 139 CMD_RESOURCES, 140 CMD_RESULTS, 141 CMD_SET, 142 CMD_SLEEP, 143 CMD_STATS, 144 CMD_STOP, 145 CMD_TABLES, 146 CMD_TEMPLATE, 147 CMD_TERMINATE, 148 CMD_THREADS, 149 CMD_TRACE, 150 CMD_TREE, 151 CMD_TYPE, 152 CMD_UNLOAD 153}; 154 155#define CMD_FIRST_VALID 2 156 157 158/* Second parameter is the required argument count */ 159 160static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = 161{ 162 {"<NOT FOUND>", 0}, 163 {"<NULL>", 0}, 164 {"ALLOCATIONS", 0}, 165 {"ARGS", 0}, 166 {"ARGUMENTS", 0}, 167 {"BATCH", 0}, 168 {"BREAKPOINT", 1}, 169 {"BUSINFO", 0}, 170 {"CALL", 0}, 171 {"CLOSE", 0}, 172 {"DEBUG", 1}, 173 {"DISASSEMBLE", 1}, 174 {"DISASM", 1}, 175 {"DUMP", 1}, 176 {"ENABLEACPI", 0}, 177 {"EVALUATE", 1}, 178 {"EVENT", 1}, 179 {"EXECUTE", 1}, 180 {"EXIT", 0}, 181 {"FIND", 1}, 182 {"GO", 0}, 183 {"GPE", 2}, 184 {"GPES", 0}, 185 {"HANDLERS", 0}, 186 {"HELP", 0}, 187 {"?", 0}, 188 {"HISTORY", 0}, 189 {"!", 1}, 190 {"!!", 0}, 191 {"INFORMATION", 0}, 192 {"INTEGRITY", 0}, 193 {"INTO", 0}, 194 {"LEVEL", 0}, 195 {"LIST", 0}, 196 {"LOAD", 1}, 197 {"LOCALS", 0}, 198 {"LOCKS", 0}, 199 {"METHODS", 0}, 200 {"NAMESPACE", 0}, 201 {"NOTIFY", 2}, 202 {"OBJECT", 1}, 203 {"OPEN", 1}, 204 {"OSI", 0}, 205 {"OWNER", 1}, 206 {"PREDEFINED", 0}, 207 {"PREFIX", 0}, 208 {"QUIT", 0}, 209 {"REFERENCES", 1}, 210 {"RESOURCES", 0}, 211 {"RESULTS", 0}, 212 {"SET", 3}, 213 {"SLEEP", 0}, 214 {"STATS", 1}, 215 {"STOP", 0}, 216 {"TABLES", 0}, 217 {"TEMPLATE", 1}, 218 {"TERMINATE", 0}, 219 {"THREADS", 3}, 220 {"TRACE", 1}, 221 {"TREE", 0}, 222 {"TYPE", 1}, 223 {"UNLOAD", 1}, 224 {NULL, 0} 225}; 226 227/* 228 * Help for all debugger commands. First argument is the number of lines 229 * of help to output for the command. 230 */ 231static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = 232{ 233 {0, "\nGeneral-Purpose Commands:", "\n"}, 234 {1, " Allocations", "Display list of current memory allocations\n"}, 235 {2, " Dump <Address>|<Namepath>", "\n"}, 236 {0, " [Byte|Word|Dword|Qword]", "Display ACPI objects or memory\n"}, 237 {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"}, 238 {1, " Handlers", "Info about global handlers\n"}, 239 {1, " Help [Command]", "This help screen or individual command\n"}, 240 {1, " History", "Display command history buffer\n"}, 241 {1, " Level <DebugLevel>] [console]", "Get/Set debug level for file or console\n"}, 242 {1, " Locks", "Current status of internal mutexes\n"}, 243 {1, " Osi [Install|Remove <name>]", "Display or modify global _OSI list\n"}, 244 {1, " Quit or Exit", "Exit this command\n"}, 245 {9, " Stats [Allocations|Memory|Misc|", "\n"}, 246 {1, " Objects|Sizes|Stack|Tables]", "Display namespace and memory statistics\n"}, 247 {1, " Allocations", "Display list of current memory allocations\n"}, 248 {1, " Memory", "Dump internal memory lists\n"}, 249 {1, " Misc", "Namespace search and mutex stats\n"}, 250 {1, " Objects", "Summary of namespace objects\n"}, 251 {1, " Sizes", "Sizes for each of the internal objects\n"}, 252 {1, " Stack", "Display CPU stack usage\n"}, 253 {1, " Tables", "Info about current ACPI table(s)\n"}, 254 {1, " Tables", "Display info about loaded ACPI tables\n"}, 255 {1, " Unload <Namepath>", "Unload an ACPI table via namespace object\n"}, 256 {1, " ! <CommandNumber>", "Execute command from history buffer\n"}, 257 {1, " !!", "Execute last command again\n"}, 258 259 {0, "\nNamespace Access Commands:", "\n"}, 260 {1, " Businfo", "Display system bus info\n"}, 261 {1, " Disassemble <Method>", "Disassemble a control method\n"}, 262 {1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"}, 263 {1, " Find <AcpiName> (? is wildcard)", "Find ACPI name(s) with wildcards\n"}, 264 {1, " Gpe <GpeNum> <GpeBlock>", "Simulate a GPE\n"}, 265 {1, " Gpes", "Display info on all GPEs\n"}, 266 {1, " Integrity", "Validate namespace integrity\n"}, 267 {1, " Methods", "Display list of loaded control methods\n"}, 268 {1, " Namespace [Object] [Depth]", "Display loaded namespace tree/subtree\n"}, 269 {1, " Notify <Object> <Value>", "Send a notification on Object\n"}, 270 {1, " Objects <ObjectType>", "Display all objects of the given type\n"}, 271 {1, " Owner <OwnerId> [Depth]", "Display loaded namespace by object owner\n"}, 272 {1, " Predefined", "Check all predefined names\n"}, 273 {1, " Prefix [<NamePath>]", "Set or Get current execution prefix\n"}, 274 {1, " References <Addr>", "Find all references to object at addr\n"}, 275 {1, " Resources [DeviceName]", "Display Device resources (no arg = all devices)\n"}, 276 {1, " Set N <NamedObject> <Value>", "Set value for named integer\n"}, 277 {1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"}, 278 {1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"}, 279 {1, " Terminate", "Delete namespace and all internal objects\n"}, 280 {1, " Type <Object>", "Display object type\n"}, 281 282 {0, "\nControl Method Execution Commands:","\n"}, 283 {1, " Arguments (or Args)", "Display method arguments\n"}, 284 {1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\n"}, 285 {1, " Call", "Run to next control method invocation\n"}, 286 {1, " Debug <Namepath> [Arguments]", "Single Step a control method\n"}, 287 {6, " Evaluate", "Synonym for Execute\n"}, 288 {5, " Execute <Namepath> [Arguments]", "Execute control method\n"}, 289 {1, " Hex Integer", "Integer method argument\n"}, 290 {1, " \"Ascii String\"", "String method argument\n"}, 291 {1, " (Byte List)", "Buffer method argument\n"}, 292 {1, " [Package Element List]", "Package method argument\n"}, 293 {1, " Go", "Allow method to run to completion\n"}, 294 {1, " Information", "Display info about the current method\n"}, 295 {1, " Into", "Step into (not over) a method call\n"}, 296 {1, " List [# of Aml Opcodes]", "Display method ASL statements\n"}, 297 {1, " Locals", "Display method local variables\n"}, 298 {1, " Results", "Display method result stack\n"}, 299 {1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"}, 300 {1, " Stop", "Terminate control method\n"}, 301 {1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"}, 302 {1, " Trace <method name>", "Trace method execution\n"}, 303 {1, " Tree", "Display control method calling tree\n"}, 304 {1, " <Enter>", "Single step next AML opcode (over calls)\n"}, 305 306 {0, "\nFile I/O Commands:", "\n"}, 307 {1, " Close", "Close debug output file\n"}, 308 {1, " Load <Input Filename>", "Load ACPI table from a file\n"}, 309 {1, " Open <Output Filename>", "Open a file for debug output\n"}, 310 {0, NULL, NULL} 311}; 312 313 314/******************************************************************************* 315 * 316 * FUNCTION: AcpiDbMatchCommandHelp 317 * 318 * PARAMETERS: Command - Command string to match 319 * Help - Help table entry to attempt match 320 * 321 * RETURN: TRUE if command matched, FALSE otherwise 322 * 323 * DESCRIPTION: Attempt to match a command in the help table in order to 324 * print help information for a single command. 325 * 326 ******************************************************************************/ 327 328static BOOLEAN 329AcpiDbMatchCommandHelp ( 330 char *Command, 331 const ACPI_DB_COMMAND_HELP *Help) 332{ 333 char *Invocation = Help->Invocation; 334 UINT32 LineCount; 335 336 337 /* Valid commands in the help table begin with a couple of spaces */ 338 339 if (*Invocation != ' ') 340 { 341 return (FALSE); 342 } 343 344 while (*Invocation == ' ') 345 { 346 Invocation++; 347 } 348 349 /* Match command name (full command or substring) */ 350 351 while ((*Command) && (*Invocation) && (*Invocation != ' ')) 352 { 353 if (ACPI_TOLOWER (*Command) != ACPI_TOLOWER (*Invocation)) 354 { 355 return (FALSE); 356 } 357 358 Invocation++; 359 Command++; 360 } 361 362 /* Print the appropriate number of help lines */ 363 364 LineCount = Help->LineCount; 365 while (LineCount) 366 { 367 AcpiOsPrintf ("%-38s : %s", Help->Invocation, Help->Description); 368 Help++; 369 LineCount--; 370 } 371 372 return (TRUE); 373} 374 375 376/******************************************************************************* 377 * 378 * FUNCTION: AcpiDbDisplayCommandInfo 379 * 380 * PARAMETERS: Command - Command string to match 381 * DisplayAll - Display all matching commands, or just 382 * the first one (substring match) 383 * 384 * RETURN: None 385 * 386 * DESCRIPTION: Display help information for a Debugger command. 387 * 388 ******************************************************************************/ 389 390static void 391AcpiDbDisplayCommandInfo ( 392 char *Command, 393 BOOLEAN DisplayAll) 394{ 395 const ACPI_DB_COMMAND_HELP *Next; 396 BOOLEAN Matched; 397 398 399 Next = AcpiGbl_DbCommandHelp; 400 while (Next->Invocation) 401 { 402 Matched = AcpiDbMatchCommandHelp (Command, Next); 403 if (!DisplayAll && Matched) 404 { 405 return; 406 } 407 408 Next++; 409 } 410} 411 412 413/******************************************************************************* 414 * 415 * FUNCTION: AcpiDbDisplayHelp 416 * 417 * PARAMETERS: Command - Optional command string to display help. 418 * if not specified, all debugger command 419 * help strings are displayed 420 * 421 * RETURN: None 422 * 423 * DESCRIPTION: Display help for a single debugger command, or all of them. 424 * 425 ******************************************************************************/ 426 427static void 428AcpiDbDisplayHelp ( 429 char *Command) 430{ 431 const ACPI_DB_COMMAND_HELP *Next = AcpiGbl_DbCommandHelp; 432 433 434 if (!Command) 435 { 436 /* No argument to help, display help for all commands */ 437 438 while (Next->Invocation) 439 { 440 AcpiOsPrintf ("%-38s%s", Next->Invocation, Next->Description); 441 Next++; 442 } 443 } 444 else 445 { 446 /* Display help for all commands that match the subtring */ 447 448 AcpiDbDisplayCommandInfo (Command, TRUE); 449 } 450} 451 452 453/******************************************************************************* 454 * 455 * FUNCTION: AcpiDbGetNextToken 456 * 457 * PARAMETERS: String - Command buffer 458 * Next - Return value, end of next token 459 * 460 * RETURN: Pointer to the start of the next token. 461 * 462 * DESCRIPTION: Command line parsing. Get the next token on the command line 463 * 464 ******************************************************************************/ 465 466char * 467AcpiDbGetNextToken ( 468 char *String, 469 char **Next, 470 ACPI_OBJECT_TYPE *ReturnType) 471{ 472 char *Start; 473 UINT32 Depth; 474 ACPI_OBJECT_TYPE Type = ACPI_TYPE_INTEGER; 475 476 477 /* At end of buffer? */ 478 479 if (!String || !(*String)) 480 { 481 return (NULL); 482 } 483 484 /* Remove any spaces at the beginning */ 485 486 if (*String == ' ') 487 { 488 while (*String && (*String == ' ')) 489 { 490 String++; 491 } 492 493 if (!(*String)) 494 { 495 return (NULL); 496 } 497 } 498 499 switch (*String) 500 { 501 case '"': 502 503 /* This is a quoted string, scan until closing quote */ 504 505 String++; 506 Start = String; 507 Type = ACPI_TYPE_STRING; 508 509 /* Find end of string */ 510 511 while (*String && (*String != '"')) 512 { 513 String++; 514 } 515 break; 516 517 case '(': 518 519 /* This is the start of a buffer, scan until closing paren */ 520 521 String++; 522 Start = String; 523 Type = ACPI_TYPE_BUFFER; 524 525 /* Find end of buffer */ 526 527 while (*String && (*String != ')')) 528 { 529 String++; 530 } 531 break; 532 533 case '[': 534 535 /* This is the start of a package, scan until closing bracket */ 536 537 String++; 538 Depth = 1; 539 Start = String; 540 Type = ACPI_TYPE_PACKAGE; 541 542 /* Find end of package (closing bracket) */ 543 544 while (*String) 545 { 546 /* Handle String package elements */ 547 548 if (*String == '"') 549 { 550 /* Find end of string */ 551 552 String++; 553 while (*String && (*String != '"')) 554 { 555 String++; 556 } 557 if (!(*String)) 558 { 559 break; 560 } 561 } 562 else if (*String == '[') 563 { 564 Depth++; /* A nested package declaration */ 565 } 566 else if (*String == ']') 567 { 568 Depth--; 569 if (Depth == 0) /* Found final package closing bracket */ 570 { 571 break; 572 } 573 } 574 575 String++; 576 } 577 break; 578 579 default: 580 581 Start = String; 582 583 /* Find end of token */ 584 585 while (*String && (*String != ' ')) 586 { 587 String++; 588 } 589 break; 590 } 591 592 if (!(*String)) 593 { 594 *Next = NULL; 595 } 596 else 597 { 598 *String = 0; 599 *Next = String + 1; 600 } 601 602 *ReturnType = Type; 603 return (Start); 604} 605 606 607/******************************************************************************* 608 * 609 * FUNCTION: AcpiDbGetLine 610 * 611 * PARAMETERS: InputBuffer - Command line buffer 612 * 613 * RETURN: Count of arguments to the command 614 * 615 * DESCRIPTION: Get the next command line from the user. Gets entire line 616 * up to the next newline 617 * 618 ******************************************************************************/ 619 620static UINT32 621AcpiDbGetLine ( 622 char *InputBuffer) 623{ 624 UINT32 i; 625 UINT32 Count; 626 char *Next; 627 char *This; 628 629 630 ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer); 631 632 This = AcpiGbl_DbParsedBuf; 633 for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++) 634 { 635 AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next, 636 &AcpiGbl_DbArgTypes[i]); 637 if (!AcpiGbl_DbArgs[i]) 638 { 639 break; 640 } 641 642 This = Next; 643 } 644 645 /* Uppercase the actual command */ 646 647 if (AcpiGbl_DbArgs[0]) 648 { 649 AcpiUtStrupr (AcpiGbl_DbArgs[0]); 650 } 651 652 Count = i; 653 if (Count) 654 { 655 Count--; /* Number of args only */ 656 } 657 658 return (Count); 659} 660 661 662/******************************************************************************* 663 * 664 * FUNCTION: AcpiDbMatchCommand 665 * 666 * PARAMETERS: UserCommand - User command line 667 * 668 * RETURN: Index into command array, -1 if not found 669 * 670 * DESCRIPTION: Search command array for a command match 671 * 672 ******************************************************************************/ 673 674static UINT32 675AcpiDbMatchCommand ( 676 char *UserCommand) 677{ 678 UINT32 i; 679 680 681 if (!UserCommand || UserCommand[0] == 0) 682 { 683 return (CMD_NULL); 684 } 685 686 for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++) 687 { 688 if (ACPI_STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) == 689 AcpiGbl_DbCommands[i].Name) 690 { 691 return (i); 692 } 693 } 694 695 /* Command not recognized */ 696 697 return (CMD_NOT_FOUND); 698} 699 700 701/******************************************************************************* 702 * 703 * FUNCTION: AcpiDbCommandDispatch 704 * 705 * PARAMETERS: InputBuffer - Command line buffer 706 * WalkState - Current walk 707 * Op - Current (executing) parse op 708 * 709 * RETURN: Status 710 * 711 * DESCRIPTION: Command dispatcher. 712 * 713 ******************************************************************************/ 714 715ACPI_STATUS 716AcpiDbCommandDispatch ( 717 char *InputBuffer, 718 ACPI_WALK_STATE *WalkState, 719 ACPI_PARSE_OBJECT *Op) 720{ 721 UINT32 Temp; 722 UINT32 CommandIndex; 723 UINT32 ParamCount; 724 char *CommandLine; 725 ACPI_STATUS Status = AE_CTRL_TRUE; 726 727 728 /* If AcpiTerminate has been called, terminate this thread */ 729 730 if (AcpiGbl_DbTerminateThreads) 731 { 732 return (AE_CTRL_TERMINATE); 733 } 734 735 ParamCount = AcpiDbGetLine (InputBuffer); 736 CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]); 737 Temp = 0; 738 739 /* Verify that we have the minimum number of params */ 740 741 if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs) 742 { 743 AcpiOsPrintf ("%u parameters entered, [%s] requires %u parameters\n", 744 ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, 745 AcpiGbl_DbCommands[CommandIndex].MinArgs); 746 747 AcpiDbDisplayCommandInfo (AcpiGbl_DbCommands[CommandIndex].Name, FALSE); 748 return (AE_CTRL_TRUE); 749 } 750 751 /* Decode and dispatch the command */ 752 753 switch (CommandIndex) 754 { 755 case CMD_NULL: 756 if (Op) 757 { 758 return (AE_OK); 759 } 760 break; 761 762 case CMD_ALLOCATIONS: 763 764#ifdef ACPI_DBG_TRACK_ALLOCATIONS 765 AcpiUtDumpAllocations ((UINT32) -1, NULL); 766#endif 767 break; 768 769 case CMD_ARGS: 770 case CMD_ARGUMENTS: 771 AcpiDbDisplayArguments (); 772 break; 773 774 case CMD_BATCH: 775 AcpiDbBatchExecute (AcpiGbl_DbArgs[1]); 776 break; 777 778 case CMD_BREAKPOINT: 779 AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op); 780 break; 781 782 case CMD_BUSINFO: 783 AcpiDbGetBusInfo (); 784 break; 785 786 case CMD_CALL: 787 AcpiDbSetMethodCallBreakpoint (Op); 788 Status = AE_OK; 789 break; 790 791 case CMD_CLOSE: 792 AcpiDbCloseDebugFile (); 793 break; 794 795 case CMD_DEBUG: 796 AcpiDbExecute (AcpiGbl_DbArgs[1], 797 &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_SINGLE_STEP); 798 break; 799 800 case CMD_DISASSEMBLE: 801 case CMD_DISASM: 802 (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]); 803 break; 804 805 case CMD_DUMP: 806 AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 807 break; 808 809 case CMD_ENABLEACPI: 810#if (!ACPI_REDUCED_HARDWARE) 811 812 Status = AcpiEnable(); 813 if (ACPI_FAILURE(Status)) 814 { 815 AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status); 816 return (Status); 817 } 818#endif /* !ACPI_REDUCED_HARDWARE */ 819 break; 820 821 case CMD_EVENT: 822 AcpiOsPrintf ("Event command not implemented\n"); 823 break; 824 825 case CMD_EVALUATE: 826 case CMD_EXECUTE: 827 AcpiDbExecute (AcpiGbl_DbArgs[1], 828 &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP); 829 break; 830 831 case CMD_FIND: 832 Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]); 833 break; 834 835 case CMD_GO: 836 AcpiGbl_CmSingleStep = FALSE; 837 return (AE_OK); 838 839 case CMD_GPE: 840 AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 841 break; 842 843 case CMD_GPES: 844 AcpiDbDisplayGpes (); 845 break; 846 847 case CMD_HANDLERS: 848 AcpiDbDisplayHandlers (); 849 break; 850 851 case CMD_HELP: 852 case CMD_HELP2: 853 AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]); 854 break; 855 856 case CMD_HISTORY: 857 AcpiDbDisplayHistory (); 858 break; 859 860 case CMD_HISTORY_EXE: 861 CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]); 862 if (!CommandLine) 863 { 864 return (AE_CTRL_TRUE); 865 } 866 867 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); 868 return (Status); 869 870 case CMD_HISTORY_LAST: 871 CommandLine = AcpiDbGetFromHistory (NULL); 872 if (!CommandLine) 873 { 874 return (AE_CTRL_TRUE); 875 } 876 877 Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); 878 return (Status); 879 880 case CMD_INFORMATION: 881 AcpiDbDisplayMethodInfo (Op); 882 break; 883 884 case CMD_INTEGRITY: 885 AcpiDbCheckIntegrity (); 886 break; 887 888 case CMD_INTO: 889 if (Op) 890 { 891 AcpiGbl_CmSingleStep = TRUE; 892 return (AE_OK); 893 } 894 break; 895 896 case CMD_LEVEL: 897 if (ParamCount == 0) 898 { 899 AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", 900 AcpiGbl_DbDebugLevel); 901 AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", 902 AcpiGbl_DbConsoleDebugLevel); 903 } 904 else if (ParamCount == 2) 905 { 906 Temp = AcpiGbl_DbConsoleDebugLevel; 907 AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], 908 NULL, 16); 909 AcpiOsPrintf ( 910 "Debug Level for console output was %8.8lX, now %8.8lX\n", 911 Temp, AcpiGbl_DbConsoleDebugLevel); 912 } 913 else 914 { 915 Temp = AcpiGbl_DbDebugLevel; 916 AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16); 917 AcpiOsPrintf ( 918 "Debug Level for file output was %8.8lX, now %8.8lX\n", 919 Temp, AcpiGbl_DbDebugLevel); 920 } 921 break; 922 923 case CMD_LIST: 924 AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op); 925 break; 926 927 case CMD_LOAD: 928 Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL); 929 break; 930 931 case CMD_LOCKS: 932 AcpiDbDisplayLocks (); 933 break; 934 935 case CMD_LOCALS: 936 AcpiDbDisplayLocals (); 937 break; 938 939 case CMD_METHODS: 940 Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]); 941 break; 942 943 case CMD_NAMESPACE: 944 AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 945 break; 946 947 case CMD_NOTIFY: 948 Temp = ACPI_STRTOUL (AcpiGbl_DbArgs[2], NULL, 0); 949 AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp); 950 break; 951 952 case CMD_OBJECT: 953 AcpiUtStrupr (AcpiGbl_DbArgs[1]); 954 Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 955 break; 956 957 case CMD_OPEN: 958 AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]); 959 break; 960 961 case CMD_OSI: 962 AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 963 break; 964 965 case CMD_OWNER: 966 AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); 967 break; 968 969 case CMD_PREDEFINED: 970 AcpiDbCheckPredefinedNames (); 971 break; 972 973 case CMD_PREFIX: 974 AcpiDbSetScope (AcpiGbl_DbArgs[1]); 975 break; 976 977 case CMD_REFERENCES: 978 AcpiDbFindReferences (AcpiGbl_DbArgs[1]); 979 break; 980 981 case CMD_RESOURCES: 982 AcpiDbDisplayResources (AcpiGbl_DbArgs[1]); 983 break; 984 985 case CMD_RESULTS: 986 AcpiDbDisplayResults (); 987 break; 988 989 case CMD_SET: 990 AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], 991 AcpiGbl_DbArgs[3]); 992 break; 993 994 case CMD_SLEEP: 995 Status = AcpiDbSleep (AcpiGbl_DbArgs[1]); 996 break; 997 998 case CMD_STATS: 999 Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]); 1000 break; 1001 1002 case CMD_STOP: 1003 return (AE_NOT_IMPLEMENTED); 1004 1005 case CMD_TABLES: 1006 AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]); 1007 break; 1008 1009 case CMD_TEMPLATE: 1010 AcpiDbDisplayTemplate (AcpiGbl_DbArgs[1]); 1011 break; 1012 1013 case CMD_TERMINATE: 1014 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 1015 AcpiUtSubsystemShutdown (); 1016 1017 /* 1018 * TBD: [Restructure] Need some way to re-initialize without 1019 * re-creating the semaphores! 1020 */ 1021 1022 /* AcpiInitialize (NULL); */ 1023 break; 1024 1025 case CMD_THREADS: 1026 AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], 1027 AcpiGbl_DbArgs[3]); 1028 break; 1029 1030 case CMD_TRACE: 1031 (void) AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1); 1032 break; 1033 1034 case CMD_TREE: 1035 AcpiDbDisplayCallingTree (); 1036 break; 1037 1038 case CMD_TYPE: 1039 AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]); 1040 break; 1041 1042 case CMD_UNLOAD: 1043 AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1]); 1044 break; 1045 1046 case CMD_EXIT: 1047 case CMD_QUIT: 1048 if (Op) 1049 { 1050 AcpiOsPrintf ("Method execution terminated\n"); 1051 return (AE_CTRL_TERMINATE); 1052 } 1053 1054 if (!AcpiGbl_DbOutputToFile) 1055 { 1056 AcpiDbgLevel = ACPI_DEBUG_DEFAULT; 1057 } 1058 1059 AcpiDbCloseDebugFile (); 1060 AcpiGbl_DbTerminateThreads = TRUE; 1061 return (AE_CTRL_TERMINATE); 1062 1063 case CMD_NOT_FOUND: 1064 default: 1065 AcpiOsPrintf ("Unknown Command\n"); 1066 return (AE_CTRL_TRUE); 1067 } 1068 1069 if (ACPI_SUCCESS (Status)) 1070 { 1071 Status = AE_CTRL_TRUE; 1072 } 1073 1074 /* Add all commands that come here to the history buffer */ 1075 1076 AcpiDbAddToHistory (InputBuffer); 1077 return (Status); 1078} 1079 1080 1081/******************************************************************************* 1082 * 1083 * FUNCTION: AcpiDbExecuteThread 1084 * 1085 * PARAMETERS: Context - Not used 1086 * 1087 * RETURN: None 1088 * 1089 * DESCRIPTION: Debugger execute thread. Waits for a command line, then 1090 * simply dispatches it. 1091 * 1092 ******************************************************************************/ 1093 1094void ACPI_SYSTEM_XFACE 1095AcpiDbExecuteThread ( 1096 void *Context) 1097{ 1098 ACPI_STATUS Status = AE_OK; 1099 ACPI_STATUS MStatus; 1100 1101 1102 while (Status != AE_CTRL_TERMINATE) 1103 { 1104 AcpiGbl_MethodExecuting = FALSE; 1105 AcpiGbl_StepToNextCall = FALSE; 1106 1107 MStatus = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); 1108 if (ACPI_FAILURE (MStatus)) 1109 { 1110 return; 1111 } 1112 1113 Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); 1114 1115 MStatus = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); 1116 if (ACPI_FAILURE (MStatus)) 1117 { 1118 return; 1119 } 1120 } 1121} 1122 1123 1124/******************************************************************************* 1125 * 1126 * FUNCTION: AcpiDbSingleThread 1127 * 1128 * PARAMETERS: None 1129 * 1130 * RETURN: None 1131 * 1132 * DESCRIPTION: Debugger execute thread. Waits for a command line, then 1133 * simply dispatches it. 1134 * 1135 ******************************************************************************/ 1136 1137static void 1138AcpiDbSingleThread ( 1139 void) 1140{ 1141 1142 AcpiGbl_MethodExecuting = FALSE; 1143 AcpiGbl_StepToNextCall = FALSE; 1144 1145 (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); 1146} 1147 1148 1149/******************************************************************************* 1150 * 1151 * FUNCTION: AcpiDbUserCommands 1152 * 1153 * PARAMETERS: Prompt - User prompt (depends on mode) 1154 * Op - Current executing parse op 1155 * 1156 * RETURN: None 1157 * 1158 * DESCRIPTION: Command line execution for the AML debugger. Commands are 1159 * matched and dispatched here. 1160 * 1161 ******************************************************************************/ 1162 1163ACPI_STATUS 1164AcpiDbUserCommands ( 1165 char Prompt, 1166 ACPI_PARSE_OBJECT *Op) 1167{ 1168 ACPI_STATUS Status = AE_OK; 1169 1170 1171 AcpiOsPrintf ("\n"); 1172 1173 /* TBD: [Restructure] Need a separate command line buffer for step mode */ 1174 1175 while (!AcpiGbl_DbTerminateThreads) 1176 { 1177 /* Force output to console until a command is entered */ 1178 1179 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 1180 1181 /* Different prompt if method is executing */ 1182 1183 if (!AcpiGbl_MethodExecuting) 1184 { 1185 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT); 1186 } 1187 else 1188 { 1189 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT); 1190 } 1191 1192 /* Get the user input line */ 1193 1194 Status = AcpiOsGetLine (AcpiGbl_DbLineBuf, 1195 ACPI_DB_LINE_BUFFER_SIZE, NULL); 1196 if (ACPI_FAILURE (Status)) 1197 { 1198 ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line")); 1199 return (Status); 1200 } 1201 1202 /* Check for single or multithreaded debug */ 1203 1204 if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) 1205 { 1206 /* 1207 * Signal the debug thread that we have a command to execute, 1208 * and wait for the command to complete. 1209 */ 1210 Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); 1211 if (ACPI_FAILURE (Status)) 1212 { 1213 return (Status); 1214 } 1215 1216 Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); 1217 if (ACPI_FAILURE (Status)) 1218 { 1219 return (Status); 1220 } 1221 } 1222 else 1223 { 1224 /* Just call to the command line interpreter */ 1225 1226 AcpiDbSingleThread (); 1227 } 1228 } 1229 1230 /* 1231 * Only this thread (the original thread) should actually terminate the 1232 * subsystem, because all the semaphores are deleted during termination 1233 */ 1234 Status = AcpiTerminate (); 1235 return (Status); 1236} 1237 1238#endif /* ACPI_DEBUGGER */ 1239