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