1 /******************************************************************************* 2 * 3 * Module Name: dbdisply - debug display commands 4 * 5 ******************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2015, 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 #include "acpi.h" 45 #include "accommon.h" 46 #include "amlcode.h" 47 #include "acdispat.h" 48 #include "acnamesp.h" 49 #include "acparser.h" 50 #include "acinterp.h" 51 #include "acdebug.h" 52 53 54 #ifdef ACPI_DEBUGGER 55 56 #define _COMPONENT ACPI_CA_DEBUGGER 57 ACPI_MODULE_NAME ("dbdisply") 58 59 /* Local prototypes */ 60 61 static void 62 AcpiDbDumpParserDescriptor ( 63 ACPI_PARSE_OBJECT *Op); 64 65 static void * 66 AcpiDbGetPointer ( 67 void *Target); 68 69 static ACPI_STATUS 70 AcpiDbDisplayNonRootHandlers ( 71 ACPI_HANDLE ObjHandle, 72 UINT32 NestingLevel, 73 void *Context, 74 void **ReturnValue); 75 76 /* 77 * System handler information. 78 * Used for Handlers command, in AcpiDbDisplayHandlers. 79 */ 80 #define ACPI_PREDEFINED_PREFIX "%25s (%.2X) : " 81 #define ACPI_HANDLER_NAME_STRING "%30s : " 82 #define ACPI_HANDLER_PRESENT_STRING "%-9s (%p)\n" 83 #define ACPI_HANDLER_PRESENT_STRING2 "%-9s (%p)" 84 #define ACPI_HANDLER_NOT_PRESENT_STRING "%-9s\n" 85 86 /* All predefined Address Space IDs */ 87 88 static ACPI_ADR_SPACE_TYPE AcpiGbl_SpaceIdList[] = 89 { 90 ACPI_ADR_SPACE_SYSTEM_MEMORY, 91 ACPI_ADR_SPACE_SYSTEM_IO, 92 ACPI_ADR_SPACE_PCI_CONFIG, 93 ACPI_ADR_SPACE_EC, 94 ACPI_ADR_SPACE_SMBUS, 95 ACPI_ADR_SPACE_CMOS, 96 ACPI_ADR_SPACE_PCI_BAR_TARGET, 97 ACPI_ADR_SPACE_IPMI, 98 ACPI_ADR_SPACE_GPIO, 99 ACPI_ADR_SPACE_GSBUS, 100 ACPI_ADR_SPACE_DATA_TABLE, 101 ACPI_ADR_SPACE_FIXED_HARDWARE 102 }; 103 104 /* Global handler information */ 105 106 typedef struct acpi_handler_info 107 { 108 void *Handler; 109 char *Name; 110 111 } ACPI_HANDLER_INFO; 112 113 static ACPI_HANDLER_INFO AcpiGbl_HandlerList[] = 114 { 115 {&AcpiGbl_GlobalNotify[0].Handler, "System Notifications"}, 116 {&AcpiGbl_GlobalNotify[1].Handler, "Device Notifications"}, 117 {&AcpiGbl_TableHandler, "ACPI Table Events"}, 118 {&AcpiGbl_ExceptionHandler, "Control Method Exceptions"}, 119 {&AcpiGbl_InterfaceHandler, "OSI Invocations"} 120 }; 121 122 123 /******************************************************************************* 124 * 125 * FUNCTION: AcpiDbGetPointer 126 * 127 * PARAMETERS: Target - Pointer to string to be converted 128 * 129 * RETURN: Converted pointer 130 * 131 * DESCRIPTION: Convert an ascii pointer value to a real value 132 * 133 ******************************************************************************/ 134 135 static void * 136 AcpiDbGetPointer ( 137 void *Target) 138 { 139 void *ObjPtr; 140 ACPI_SIZE Address; 141 142 143 Address = strtoul (Target, NULL, 16); 144 ObjPtr = ACPI_TO_POINTER (Address); 145 return (ObjPtr); 146 } 147 148 149 /******************************************************************************* 150 * 151 * FUNCTION: AcpiDbDumpParserDescriptor 152 * 153 * PARAMETERS: Op - A parser Op descriptor 154 * 155 * RETURN: None 156 * 157 * DESCRIPTION: Display a formatted parser object 158 * 159 ******************************************************************************/ 160 161 static void 162 AcpiDbDumpParserDescriptor ( 163 ACPI_PARSE_OBJECT *Op) 164 { 165 const ACPI_OPCODE_INFO *Info; 166 167 168 Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 169 170 AcpiOsPrintf ("Parser Op Descriptor:\n"); 171 AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode); 172 173 ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", 174 Info->Name)); 175 176 AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg); 177 AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent); 178 AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next); 179 } 180 181 182 /******************************************************************************* 183 * 184 * FUNCTION: AcpiDbDecodeAndDisplayObject 185 * 186 * PARAMETERS: Target - String with object to be displayed. Names 187 * and hex pointers are supported. 188 * OutputType - Byte, Word, Dword, or Qword (B|W|D|Q) 189 * 190 * RETURN: None 191 * 192 * DESCRIPTION: Display a formatted ACPI object 193 * 194 ******************************************************************************/ 195 196 void 197 AcpiDbDecodeAndDisplayObject ( 198 char *Target, 199 char *OutputType) 200 { 201 void *ObjPtr; 202 ACPI_NAMESPACE_NODE *Node; 203 ACPI_OPERAND_OBJECT *ObjDesc; 204 UINT32 Display = DB_BYTE_DISPLAY; 205 char Buffer[80]; 206 ACPI_BUFFER RetBuf; 207 ACPI_STATUS Status; 208 UINT32 Size; 209 210 211 if (!Target) 212 { 213 return; 214 } 215 216 /* Decode the output type */ 217 218 if (OutputType) 219 { 220 AcpiUtStrupr (OutputType); 221 if (OutputType[0] == 'W') 222 { 223 Display = DB_WORD_DISPLAY; 224 } 225 else if (OutputType[0] == 'D') 226 { 227 Display = DB_DWORD_DISPLAY; 228 } 229 else if (OutputType[0] == 'Q') 230 { 231 Display = DB_QWORD_DISPLAY; 232 } 233 } 234 235 RetBuf.Length = sizeof (Buffer); 236 RetBuf.Pointer = Buffer; 237 238 /* Differentiate between a number and a name */ 239 240 if ((Target[0] >= 0x30) && (Target[0] <= 0x39)) 241 { 242 ObjPtr = AcpiDbGetPointer (Target); 243 if (!AcpiOsReadable (ObjPtr, 16)) 244 { 245 AcpiOsPrintf ( 246 "Address %p is invalid in this address space\n", 247 ObjPtr); 248 return; 249 } 250 251 /* Decode the object type */ 252 253 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr)) 254 { 255 case ACPI_DESC_TYPE_NAMED: 256 257 /* This is a namespace Node */ 258 259 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) 260 { 261 AcpiOsPrintf ( 262 "Cannot read entire Named object at address %p\n", 263 ObjPtr); 264 return; 265 } 266 267 Node = ObjPtr; 268 goto DumpNode; 269 270 case ACPI_DESC_TYPE_OPERAND: 271 272 /* This is a ACPI OPERAND OBJECT */ 273 274 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) 275 { 276 AcpiOsPrintf ( 277 "Cannot read entire ACPI object at address %p\n", 278 ObjPtr); 279 return; 280 } 281 282 AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), 283 Display, ACPI_UINT32_MAX); 284 AcpiExDumpObjectDescriptor (ObjPtr, 1); 285 break; 286 287 case ACPI_DESC_TYPE_PARSER: 288 289 /* This is a Parser Op object */ 290 291 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) 292 { 293 AcpiOsPrintf ( 294 "Cannot read entire Parser object at address %p\n", 295 ObjPtr); 296 return; 297 } 298 299 AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), 300 Display, ACPI_UINT32_MAX); 301 AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); 302 break; 303 304 default: 305 306 /* Is not a recognizeable object */ 307 308 AcpiOsPrintf ( 309 "Not a known ACPI internal object, descriptor type %2.2X\n", 310 ACPI_GET_DESCRIPTOR_TYPE (ObjPtr)); 311 312 Size = 16; 313 if (AcpiOsReadable (ObjPtr, 64)) 314 { 315 Size = 64; 316 } 317 318 /* Just dump some memory */ 319 320 AcpiUtDebugDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX); 321 break; 322 } 323 324 return; 325 } 326 327 /* The parameter is a name string that must be resolved to a Named obj */ 328 329 Node = AcpiDbLocalNsLookup (Target); 330 if (!Node) 331 { 332 return; 333 } 334 335 336 DumpNode: 337 /* Now dump the NS node */ 338 339 Status = AcpiGetName (Node, ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf); 340 if (ACPI_FAILURE (Status)) 341 { 342 AcpiOsPrintf ("Could not convert name to pathname\n"); 343 } 344 345 else 346 { 347 AcpiOsPrintf ("Object (%p) Pathname: %s\n", 348 Node, (char *) RetBuf.Pointer); 349 } 350 351 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) 352 { 353 AcpiOsPrintf ("Invalid Named object at address %p\n", Node); 354 return; 355 } 356 357 AcpiUtDebugDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), 358 Display, ACPI_UINT32_MAX); 359 AcpiExDumpNamespaceNode (Node, 1); 360 361 ObjDesc = AcpiNsGetAttachedObject (Node); 362 if (ObjDesc) 363 { 364 AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc); 365 if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT))) 366 { 367 AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", 368 ObjDesc); 369 return; 370 } 371 372 AcpiUtDebugDumpBuffer ((void *) ObjDesc, 373 sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); 374 AcpiExDumpObjectDescriptor (ObjDesc, 1); 375 } 376 } 377 378 379 /******************************************************************************* 380 * 381 * FUNCTION: AcpiDbDisplayMethodInfo 382 * 383 * PARAMETERS: StartOp - Root of the control method parse tree 384 * 385 * RETURN: None 386 * 387 * DESCRIPTION: Display information about the current method 388 * 389 ******************************************************************************/ 390 391 void 392 AcpiDbDisplayMethodInfo ( 393 ACPI_PARSE_OBJECT *StartOp) 394 { 395 ACPI_WALK_STATE *WalkState; 396 ACPI_OPERAND_OBJECT *ObjDesc; 397 ACPI_NAMESPACE_NODE *Node; 398 ACPI_PARSE_OBJECT *RootOp; 399 ACPI_PARSE_OBJECT *Op; 400 const ACPI_OPCODE_INFO *OpInfo; 401 UINT32 NumOps = 0; 402 UINT32 NumOperands = 0; 403 UINT32 NumOperators = 0; 404 UINT32 NumRemainingOps = 0; 405 UINT32 NumRemainingOperands = 0; 406 UINT32 NumRemainingOperators = 0; 407 BOOLEAN CountRemaining = FALSE; 408 409 410 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 411 if (!WalkState) 412 { 413 AcpiOsPrintf ("There is no method currently executing\n"); 414 return; 415 } 416 417 ObjDesc = WalkState->MethodDesc; 418 Node = WalkState->MethodNode; 419 420 AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", 421 AcpiUtGetNodeName (Node)); 422 AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n", 423 (UINT32) ObjDesc->Method.ParamCount, 424 (UINT32) ObjDesc->Method.SyncLevel); 425 426 427 RootOp = StartOp; 428 while (RootOp->Common.Parent) 429 { 430 RootOp = RootOp->Common.Parent; 431 } 432 433 Op = RootOp; 434 435 while (Op) 436 { 437 if (Op == StartOp) 438 { 439 CountRemaining = TRUE; 440 } 441 442 NumOps++; 443 if (CountRemaining) 444 { 445 NumRemainingOps++; 446 } 447 448 /* Decode the opcode */ 449 450 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 451 switch (OpInfo->Class) 452 { 453 case AML_CLASS_ARGUMENT: 454 455 if (CountRemaining) 456 { 457 NumRemainingOperands++; 458 } 459 460 NumOperands++; 461 break; 462 463 case AML_CLASS_UNKNOWN: 464 465 /* Bad opcode or ASCII character */ 466 467 continue; 468 469 default: 470 471 if (CountRemaining) 472 { 473 NumRemainingOperators++; 474 } 475 476 NumOperators++; 477 break; 478 } 479 480 Op = AcpiPsGetDepthNext (StartOp, Op); 481 } 482 483 AcpiOsPrintf ( 484 "Method contains: %X AML Opcodes - %X Operators, %X Operands\n", 485 NumOps, NumOperators, NumOperands); 486 487 AcpiOsPrintf ( 488 "Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n", 489 NumRemainingOps, NumRemainingOperators, NumRemainingOperands); 490 } 491 492 493 /******************************************************************************* 494 * 495 * FUNCTION: AcpiDbDisplayLocals 496 * 497 * PARAMETERS: None 498 * 499 * RETURN: None 500 * 501 * DESCRIPTION: Display all locals for the currently running control method 502 * 503 ******************************************************************************/ 504 505 void 506 AcpiDbDisplayLocals ( 507 void) 508 { 509 ACPI_WALK_STATE *WalkState; 510 511 512 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 513 if (!WalkState) 514 { 515 AcpiOsPrintf ("There is no method currently executing\n"); 516 return; 517 } 518 519 AcpiDbDecodeLocals (WalkState); 520 } 521 522 523 /******************************************************************************* 524 * 525 * FUNCTION: AcpiDbDisplayArguments 526 * 527 * PARAMETERS: None 528 * 529 * RETURN: None 530 * 531 * DESCRIPTION: Display all arguments for the currently running control method 532 * 533 ******************************************************************************/ 534 535 void 536 AcpiDbDisplayArguments ( 537 void) 538 { 539 ACPI_WALK_STATE *WalkState; 540 541 542 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 543 if (!WalkState) 544 { 545 AcpiOsPrintf ("There is no method currently executing\n"); 546 return; 547 } 548 549 AcpiDbDecodeArguments (WalkState); 550 } 551 552 553 /******************************************************************************* 554 * 555 * FUNCTION: AcpiDbDisplayResults 556 * 557 * PARAMETERS: None 558 * 559 * RETURN: None 560 * 561 * DESCRIPTION: Display current contents of a method result stack 562 * 563 ******************************************************************************/ 564 565 void 566 AcpiDbDisplayResults ( 567 void) 568 { 569 UINT32 i; 570 ACPI_WALK_STATE *WalkState; 571 ACPI_OPERAND_OBJECT *ObjDesc; 572 UINT32 ResultCount = 0; 573 ACPI_NAMESPACE_NODE *Node; 574 ACPI_GENERIC_STATE *Frame; 575 UINT32 Index; /* Index onto current frame */ 576 577 578 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 579 if (!WalkState) 580 { 581 AcpiOsPrintf ("There is no method currently executing\n"); 582 return; 583 } 584 585 ObjDesc = WalkState->MethodDesc; 586 Node = WalkState->MethodNode; 587 588 if (WalkState->Results) 589 { 590 ResultCount = WalkState->ResultCount; 591 } 592 593 AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n", 594 AcpiUtGetNodeName (Node), ResultCount); 595 596 /* From the top element of result stack */ 597 598 Frame = WalkState->Results; 599 Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM; 600 601 for (i = 0; i < ResultCount; i++) 602 { 603 ObjDesc = Frame->Results.ObjDesc[Index]; 604 AcpiOsPrintf ("Result%u: ", i); 605 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 606 607 if (Index == 0) 608 { 609 Frame = Frame->Results.Next; 610 Index = ACPI_RESULTS_FRAME_OBJ_NUM; 611 } 612 613 Index--; 614 } 615 } 616 617 618 /******************************************************************************* 619 * 620 * FUNCTION: AcpiDbDisplayCallingTree 621 * 622 * PARAMETERS: None 623 * 624 * RETURN: None 625 * 626 * DESCRIPTION: Display current calling tree of nested control methods 627 * 628 ******************************************************************************/ 629 630 void 631 AcpiDbDisplayCallingTree ( 632 void) 633 { 634 ACPI_WALK_STATE *WalkState; 635 ACPI_NAMESPACE_NODE *Node; 636 637 638 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 639 if (!WalkState) 640 { 641 AcpiOsPrintf ("There is no method currently executing\n"); 642 return; 643 } 644 645 Node = WalkState->MethodNode; 646 AcpiOsPrintf ("Current Control Method Call Tree\n"); 647 648 while (WalkState) 649 { 650 Node = WalkState->MethodNode; 651 AcpiOsPrintf (" [%4.4s]\n", AcpiUtGetNodeName (Node)); 652 653 WalkState = WalkState->Next; 654 } 655 } 656 657 658 /******************************************************************************* 659 * 660 * FUNCTION: AcpiDbDisplayObjectType 661 * 662 * PARAMETERS: Name - User entered NS node handle or name 663 * 664 * RETURN: None 665 * 666 * DESCRIPTION: Display type of an arbitrary NS node 667 * 668 ******************************************************************************/ 669 670 void 671 AcpiDbDisplayObjectType ( 672 char *Name) 673 { 674 ACPI_NAMESPACE_NODE *Node; 675 ACPI_DEVICE_INFO *Info; 676 ACPI_STATUS Status; 677 UINT32 i; 678 679 680 Node = AcpiDbConvertToNode (Name); 681 if (!Node) 682 { 683 return; 684 } 685 686 Status = AcpiGetObjectInfo (ACPI_CAST_PTR (ACPI_HANDLE, Node), &Info); 687 if (ACPI_FAILURE (Status)) 688 { 689 AcpiOsPrintf ("Could not get object info, %s\n", 690 AcpiFormatException (Status)); 691 return; 692 } 693 694 if (Info->Valid & ACPI_VALID_ADR) 695 { 696 AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", 697 ACPI_FORMAT_UINT64 (Info->Address), 698 Info->CurrentStatus, Info->Flags); 699 } 700 if (Info->Valid & ACPI_VALID_SXDS) 701 { 702 AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", 703 Info->HighestDstates[0], Info->HighestDstates[1], 704 Info->HighestDstates[2], Info->HighestDstates[3]); 705 } 706 if (Info->Valid & ACPI_VALID_SXWS) 707 { 708 AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", 709 Info->LowestDstates[0], Info->LowestDstates[1], 710 Info->LowestDstates[2], Info->LowestDstates[3], 711 Info->LowestDstates[4]); 712 } 713 714 if (Info->Valid & ACPI_VALID_HID) 715 { 716 AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String); 717 } 718 719 if (Info->Valid & ACPI_VALID_UID) 720 { 721 AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String); 722 } 723 724 if (Info->Valid & ACPI_VALID_SUB) 725 { 726 AcpiOsPrintf ("SUB: %s\n", Info->SubsystemId.String); 727 } 728 729 if (Info->Valid & ACPI_VALID_CID) 730 { 731 for (i = 0; i < Info->CompatibleIdList.Count; i++) 732 { 733 AcpiOsPrintf ("CID %u: %s\n", i, 734 Info->CompatibleIdList.Ids[i].String); 735 } 736 } 737 738 ACPI_FREE (Info); 739 } 740 741 742 /******************************************************************************* 743 * 744 * FUNCTION: AcpiDbDisplayResultObject 745 * 746 * PARAMETERS: ObjDesc - Object to be displayed 747 * WalkState - Current walk state 748 * 749 * RETURN: None 750 * 751 * DESCRIPTION: Display the result of an AML opcode 752 * 753 * Note: Curently only displays the result object if we are single stepping. 754 * However, this output may be useful in other contexts and could be enabled 755 * to do so if needed. 756 * 757 ******************************************************************************/ 758 759 void 760 AcpiDbDisplayResultObject ( 761 ACPI_OPERAND_OBJECT *ObjDesc, 762 ACPI_WALK_STATE *WalkState) 763 { 764 765 /* Only display if single stepping */ 766 767 if (!AcpiGbl_CmSingleStep) 768 { 769 return; 770 } 771 772 AcpiOsPrintf ("ResultObj: "); 773 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 774 AcpiOsPrintf ("\n"); 775 } 776 777 778 /******************************************************************************* 779 * 780 * FUNCTION: AcpiDbDisplayArgumentObject 781 * 782 * PARAMETERS: ObjDesc - Object to be displayed 783 * WalkState - Current walk state 784 * 785 * RETURN: None 786 * 787 * DESCRIPTION: Display the result of an AML opcode 788 * 789 ******************************************************************************/ 790 791 void 792 AcpiDbDisplayArgumentObject ( 793 ACPI_OPERAND_OBJECT *ObjDesc, 794 ACPI_WALK_STATE *WalkState) 795 { 796 797 if (!AcpiGbl_CmSingleStep) 798 { 799 return; 800 } 801 802 AcpiOsPrintf ("ArgObj: "); 803 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 804 } 805 806 807 #if (!ACPI_REDUCED_HARDWARE) 808 /******************************************************************************* 809 * 810 * FUNCTION: AcpiDbDisplayGpes 811 * 812 * PARAMETERS: None 813 * 814 * RETURN: None 815 * 816 * DESCRIPTION: Display the current GPE structures 817 * 818 ******************************************************************************/ 819 820 void 821 AcpiDbDisplayGpes ( 822 void) 823 { 824 ACPI_GPE_BLOCK_INFO *GpeBlock; 825 ACPI_GPE_XRUPT_INFO *GpeXruptInfo; 826 ACPI_GPE_EVENT_INFO *GpeEventInfo; 827 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 828 char *GpeType; 829 ACPI_GPE_NOTIFY_INFO *Notify; 830 UINT32 GpeIndex; 831 UINT32 Block = 0; 832 UINT32 i; 833 UINT32 j; 834 UINT32 Count; 835 char Buffer[80]; 836 ACPI_BUFFER RetBuf; 837 ACPI_STATUS Status; 838 839 840 RetBuf.Length = sizeof (Buffer); 841 RetBuf.Pointer = Buffer; 842 843 Block = 0; 844 845 /* Walk the GPE lists */ 846 847 GpeXruptInfo = AcpiGbl_GpeXruptListHead; 848 while (GpeXruptInfo) 849 { 850 GpeBlock = GpeXruptInfo->GpeBlockListHead; 851 while (GpeBlock) 852 { 853 Status = AcpiGetName (GpeBlock->Node, 854 ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf); 855 if (ACPI_FAILURE (Status)) 856 { 857 AcpiOsPrintf ("Could not convert name to pathname\n"); 858 } 859 860 if (GpeBlock->Node == AcpiGbl_FadtGpeDevice) 861 { 862 GpeType = "FADT-defined GPE block"; 863 } 864 else 865 { 866 GpeType = "GPE Block Device"; 867 } 868 869 AcpiOsPrintf ( 870 "\nBlock %u - Info %p DeviceNode %p [%s] - %s\n", 871 Block, GpeBlock, GpeBlock->Node, Buffer, GpeType); 872 873 AcpiOsPrintf ( 874 " Registers: %u (%u GPEs)\n", 875 GpeBlock->RegisterCount, GpeBlock->GpeCount); 876 877 AcpiOsPrintf ( 878 " GPE range: 0x%X to 0x%X on interrupt %u\n", 879 GpeBlock->BlockBaseNumber, 880 GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1), 881 GpeXruptInfo->InterruptNumber); 882 883 AcpiOsPrintf ( 884 " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", 885 GpeBlock->RegisterInfo, 886 ACPI_FORMAT_UINT64 ( 887 GpeBlock->RegisterInfo->StatusAddress.Address), 888 ACPI_FORMAT_UINT64 ( 889 GpeBlock->RegisterInfo->EnableAddress.Address)); 890 891 AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); 892 893 /* Examine each GPE Register within the block */ 894 895 for (i = 0; i < GpeBlock->RegisterCount; i++) 896 { 897 GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; 898 899 AcpiOsPrintf ( 900 " Reg %u: (GPE %.2X-%.2X) " 901 "RunEnable %2.2X WakeEnable %2.2X" 902 " Status %8.8X%8.8X Enable %8.8X%8.8X\n", 903 i, GpeRegisterInfo->BaseGpeNumber, 904 GpeRegisterInfo->BaseGpeNumber + 905 (ACPI_GPE_REGISTER_WIDTH - 1), 906 GpeRegisterInfo->EnableForRun, 907 GpeRegisterInfo->EnableForWake, 908 ACPI_FORMAT_UINT64 ( 909 GpeRegisterInfo->StatusAddress.Address), 910 ACPI_FORMAT_UINT64 ( 911 GpeRegisterInfo->EnableAddress.Address)); 912 913 /* Now look at the individual GPEs in this byte register */ 914 915 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) 916 { 917 GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j; 918 GpeEventInfo = &GpeBlock->EventInfo[GpeIndex]; 919 920 if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) == 921 ACPI_GPE_DISPATCH_NONE) 922 { 923 /* This GPE is not used (no method or handler), ignore it */ 924 925 continue; 926 } 927 928 AcpiOsPrintf ( 929 " GPE %.2X: %p RunRefs %2.2X Flags %2.2X (", 930 GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo, 931 GpeEventInfo->RuntimeCount, GpeEventInfo->Flags); 932 933 /* Decode the flags byte */ 934 935 if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED) 936 { 937 AcpiOsPrintf ("Level, "); 938 } 939 else 940 { 941 AcpiOsPrintf ("Edge, "); 942 } 943 944 if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE) 945 { 946 AcpiOsPrintf ("CanWake, "); 947 } 948 else 949 { 950 AcpiOsPrintf ("RunOnly, "); 951 } 952 953 switch (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags)) 954 { 955 case ACPI_GPE_DISPATCH_NONE: 956 957 AcpiOsPrintf ("NotUsed"); 958 break; 959 960 case ACPI_GPE_DISPATCH_METHOD: 961 962 AcpiOsPrintf ("Method"); 963 break; 964 965 case ACPI_GPE_DISPATCH_HANDLER: 966 967 AcpiOsPrintf ("Handler"); 968 break; 969 970 case ACPI_GPE_DISPATCH_NOTIFY: 971 972 Count = 0; 973 Notify = GpeEventInfo->Dispatch.NotifyList; 974 while (Notify) 975 { 976 Count++; 977 Notify = Notify->Next; 978 } 979 980 AcpiOsPrintf ("Implicit Notify on %u devices", 981 Count); 982 break; 983 984 case ACPI_GPE_DISPATCH_RAW_HANDLER: 985 986 AcpiOsPrintf ("RawHandler"); 987 break; 988 989 default: 990 991 AcpiOsPrintf ("UNKNOWN: %X", 992 ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags)); 993 break; 994 } 995 996 AcpiOsPrintf (")\n"); 997 } 998 } 999 1000 Block++; 1001 GpeBlock = GpeBlock->Next; 1002 } 1003 1004 GpeXruptInfo = GpeXruptInfo->Next; 1005 } 1006 } 1007 #endif /* !ACPI_REDUCED_HARDWARE */ 1008 1009 1010 /******************************************************************************* 1011 * 1012 * FUNCTION: AcpiDbDisplayHandlers 1013 * 1014 * PARAMETERS: None 1015 * 1016 * RETURN: None 1017 * 1018 * DESCRIPTION: Display the currently installed global handlers 1019 * 1020 ******************************************************************************/ 1021 1022 void 1023 AcpiDbDisplayHandlers ( 1024 void) 1025 { 1026 ACPI_OPERAND_OBJECT *ObjDesc; 1027 ACPI_OPERAND_OBJECT *HandlerObj; 1028 ACPI_ADR_SPACE_TYPE SpaceId; 1029 UINT32 i; 1030 1031 1032 /* Operation region handlers */ 1033 1034 AcpiOsPrintf ("\nOperation Region Handlers at the namespace root:\n"); 1035 1036 ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode); 1037 if (ObjDesc) 1038 { 1039 for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++) 1040 { 1041 SpaceId = AcpiGbl_SpaceIdList[i]; 1042 HandlerObj = ObjDesc->Device.Handler; 1043 1044 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, 1045 AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId); 1046 1047 while (HandlerObj) 1048 { 1049 if (AcpiGbl_SpaceIdList[i] == 1050 HandlerObj->AddressSpace.SpaceId) 1051 { 1052 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, 1053 (HandlerObj->AddressSpace.HandlerFlags & 1054 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? 1055 "Default" : "User", 1056 HandlerObj->AddressSpace.Handler); 1057 1058 goto FoundHandler; 1059 } 1060 1061 HandlerObj = HandlerObj->AddressSpace.Next; 1062 } 1063 1064 /* There is no handler for this SpaceId */ 1065 1066 AcpiOsPrintf ("None\n"); 1067 1068 FoundHandler:; 1069 } 1070 1071 /* Find all handlers for user-defined SpaceIDs */ 1072 1073 HandlerObj = ObjDesc->Device.Handler; 1074 while (HandlerObj) 1075 { 1076 if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN) 1077 { 1078 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, 1079 "User-defined ID", HandlerObj->AddressSpace.SpaceId); 1080 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, 1081 (HandlerObj->AddressSpace.HandlerFlags & 1082 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? 1083 "Default" : "User", 1084 HandlerObj->AddressSpace.Handler); 1085 } 1086 1087 HandlerObj = HandlerObj->AddressSpace.Next; 1088 } 1089 } 1090 1091 #if (!ACPI_REDUCED_HARDWARE) 1092 1093 /* Fixed event handlers */ 1094 1095 AcpiOsPrintf ("\nFixed Event Handlers:\n"); 1096 1097 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) 1098 { 1099 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i); 1100 if (AcpiGbl_FixedEventHandlers[i].Handler) 1101 { 1102 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User", 1103 AcpiGbl_FixedEventHandlers[i].Handler); 1104 } 1105 else 1106 { 1107 AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None"); 1108 } 1109 } 1110 1111 #endif /* !ACPI_REDUCED_HARDWARE */ 1112 1113 /* Miscellaneous global handlers */ 1114 1115 AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n"); 1116 1117 for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++) 1118 { 1119 AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, 1120 AcpiGbl_HandlerList[i].Name); 1121 1122 if (AcpiGbl_HandlerList[i].Handler) 1123 { 1124 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User", 1125 AcpiGbl_HandlerList[i].Handler); 1126 } 1127 else 1128 { 1129 AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None"); 1130 } 1131 } 1132 1133 1134 /* Other handlers that are installed throughout the namespace */ 1135 1136 AcpiOsPrintf ("\nOperation Region Handlers for specific devices:\n"); 1137 1138 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 1139 ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers, 1140 NULL, NULL, NULL); 1141 } 1142 1143 1144 /******************************************************************************* 1145 * 1146 * FUNCTION: AcpiDbDisplayNonRootHandlers 1147 * 1148 * PARAMETERS: ACPI_WALK_CALLBACK 1149 * 1150 * RETURN: Status 1151 * 1152 * DESCRIPTION: Display information about all handlers installed for a 1153 * device object. 1154 * 1155 ******************************************************************************/ 1156 1157 static ACPI_STATUS 1158 AcpiDbDisplayNonRootHandlers ( 1159 ACPI_HANDLE ObjHandle, 1160 UINT32 NestingLevel, 1161 void *Context, 1162 void **ReturnValue) 1163 { 1164 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); 1165 ACPI_OPERAND_OBJECT *ObjDesc; 1166 ACPI_OPERAND_OBJECT *HandlerObj; 1167 char *Pathname; 1168 1169 1170 ObjDesc = AcpiNsGetAttachedObject (Node); 1171 if (!ObjDesc) 1172 { 1173 return (AE_OK); 1174 } 1175 1176 Pathname = AcpiNsGetExternalPathname (Node); 1177 if (!Pathname) 1178 { 1179 return (AE_OK); 1180 } 1181 1182 /* Display all handlers associated with this device */ 1183 1184 HandlerObj = ObjDesc->Device.Handler; 1185 while (HandlerObj) 1186 { 1187 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, 1188 AcpiUtGetRegionName ((UINT8) HandlerObj->AddressSpace.SpaceId), 1189 HandlerObj->AddressSpace.SpaceId); 1190 1191 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING2, 1192 (HandlerObj->AddressSpace.HandlerFlags & 1193 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User", 1194 HandlerObj->AddressSpace.Handler); 1195 1196 AcpiOsPrintf (" Device Name: %s (%p)\n", Pathname, Node); 1197 1198 HandlerObj = HandlerObj->AddressSpace.Next; 1199 } 1200 1201 ACPI_FREE (Pathname); 1202 return (AE_OK); 1203 } 1204 1205 #endif /* ACPI_DEBUGGER */ 1206