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