1 /******************************************************************************* 2 * 3 * Module Name: dbdisply - debug display commands 4 * 5 ******************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 ***************************************************************************** 115 * 116 * Alternatively, you may choose to be licensed under the terms of the 117 * following license: 118 * 119 * Redistribution and use in source and binary forms, with or without 120 * modification, are permitted provided that the following conditions 121 * are met: 122 * 1. Redistributions of source code must retain the above copyright 123 * notice, this list of conditions, and the following disclaimer, 124 * without modification. 125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 * substantially similar to the "NO WARRANTY" disclaimer below 127 * ("Disclaimer") and any redistribution must be conditioned upon 128 * including a substantially similar Disclaimer requirement for further 129 * binary redistribution. 130 * 3. Neither the names of the above-listed copyright holders nor the names 131 * of any contributors may be used to endorse or promote products derived 132 * from this software without specific prior written permission. 133 * 134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 * 146 * Alternatively, you may choose to be licensed under the terms of the 147 * GNU General Public License ("GPL") version 2 as published by the Free 148 * Software Foundation. 149 * 150 *****************************************************************************/ 151 152 #include "acpi.h" 153 #include "accommon.h" 154 #include "amlcode.h" 155 #include "acdispat.h" 156 #include "acnamesp.h" 157 #include "acparser.h" 158 #include "acinterp.h" 159 #include "acevents.h" 160 #include "acdebug.h" 161 162 163 #ifdef ACPI_DEBUGGER 164 165 #define _COMPONENT ACPI_CA_DEBUGGER 166 ACPI_MODULE_NAME ("dbdisply") 167 168 /* Local prototypes */ 169 170 static void 171 AcpiDbDumpParserDescriptor ( 172 ACPI_PARSE_OBJECT *Op); 173 174 static void * 175 AcpiDbGetPointer ( 176 void *Target); 177 178 static ACPI_STATUS 179 AcpiDbDisplayNonRootHandlers ( 180 ACPI_HANDLE ObjHandle, 181 UINT32 NestingLevel, 182 void *Context, 183 void **ReturnValue); 184 185 /* 186 * System handler information. 187 * Used for Handlers command, in AcpiDbDisplayHandlers. 188 */ 189 #define ACPI_PREDEFINED_PREFIX "%25s (%.2X) : " 190 #define ACPI_HANDLER_NAME_STRING "%30s : " 191 #define ACPI_HANDLER_PRESENT_STRING "%-9s (%p)\n" 192 #define ACPI_HANDLER_PRESENT_STRING2 "%-9s (%p)" 193 #define ACPI_HANDLER_NOT_PRESENT_STRING "%-9s\n" 194 195 /* All predefined Address Space IDs */ 196 197 static ACPI_ADR_SPACE_TYPE AcpiGbl_SpaceIdList[] = 198 { 199 ACPI_ADR_SPACE_SYSTEM_MEMORY, 200 ACPI_ADR_SPACE_SYSTEM_IO, 201 ACPI_ADR_SPACE_PCI_CONFIG, 202 ACPI_ADR_SPACE_EC, 203 ACPI_ADR_SPACE_SMBUS, 204 ACPI_ADR_SPACE_CMOS, 205 ACPI_ADR_SPACE_PCI_BAR_TARGET, 206 ACPI_ADR_SPACE_IPMI, 207 ACPI_ADR_SPACE_GPIO, 208 ACPI_ADR_SPACE_GSBUS, 209 ACPI_ADR_SPACE_DATA_TABLE, 210 ACPI_ADR_SPACE_FIXED_HARDWARE 211 }; 212 213 /* Global handler information */ 214 215 typedef struct acpi_handler_info 216 { 217 void *Handler; 218 char *Name; 219 220 } ACPI_HANDLER_INFO; 221 222 static ACPI_HANDLER_INFO AcpiGbl_HandlerList[] = 223 { 224 {&AcpiGbl_GlobalNotify[0].Handler, "System Notifications"}, 225 {&AcpiGbl_GlobalNotify[1].Handler, "Device Notifications"}, 226 {&AcpiGbl_TableHandler, "ACPI Table Events"}, 227 {&AcpiGbl_ExceptionHandler, "Control Method Exceptions"}, 228 {&AcpiGbl_InterfaceHandler, "OSI Invocations"} 229 }; 230 231 232 /******************************************************************************* 233 * 234 * FUNCTION: AcpiDbGetPointer 235 * 236 * PARAMETERS: Target - Pointer to string to be converted 237 * 238 * RETURN: Converted pointer 239 * 240 * DESCRIPTION: Convert an ascii pointer value to a real value 241 * 242 ******************************************************************************/ 243 244 static void * 245 AcpiDbGetPointer ( 246 void *Target) 247 { 248 void *ObjPtr; 249 ACPI_SIZE Address; 250 251 252 Address = strtoul (Target, NULL, 16); 253 ObjPtr = ACPI_TO_POINTER (Address); 254 return (ObjPtr); 255 } 256 257 258 /******************************************************************************* 259 * 260 * FUNCTION: AcpiDbDumpParserDescriptor 261 * 262 * PARAMETERS: Op - A parser Op descriptor 263 * 264 * RETURN: None 265 * 266 * DESCRIPTION: Display a formatted parser object 267 * 268 ******************************************************************************/ 269 270 static void 271 AcpiDbDumpParserDescriptor ( 272 ACPI_PARSE_OBJECT *Op) 273 { 274 const ACPI_OPCODE_INFO *Info; 275 276 277 Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 278 279 AcpiOsPrintf ("Parser Op Descriptor:\n"); 280 AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode); 281 282 ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", 283 Info->Name)); 284 285 AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg); 286 AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent); 287 AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next); 288 } 289 290 291 /******************************************************************************* 292 * 293 * FUNCTION: AcpiDbDecodeAndDisplayObject 294 * 295 * PARAMETERS: Target - String with object to be displayed. Names 296 * and hex pointers are supported. 297 * OutputType - Byte, Word, Dword, or Qword (B|W|D|Q) 298 * 299 * RETURN: None 300 * 301 * DESCRIPTION: Display a formatted ACPI object 302 * 303 ******************************************************************************/ 304 305 void 306 AcpiDbDecodeAndDisplayObject ( 307 char *Target, 308 char *OutputType) 309 { 310 void *ObjPtr; 311 ACPI_NAMESPACE_NODE *Node; 312 ACPI_OPERAND_OBJECT *ObjDesc; 313 UINT32 Display = DB_BYTE_DISPLAY; 314 char Buffer[80]; 315 ACPI_BUFFER RetBuf; 316 ACPI_STATUS Status; 317 UINT32 Size; 318 319 320 if (!Target) 321 { 322 return; 323 } 324 325 /* Decode the output type */ 326 327 if (OutputType) 328 { 329 AcpiUtStrupr (OutputType); 330 if (OutputType[0] == 'W') 331 { 332 Display = DB_WORD_DISPLAY; 333 } 334 else if (OutputType[0] == 'D') 335 { 336 Display = DB_DWORD_DISPLAY; 337 } 338 else if (OutputType[0] == 'Q') 339 { 340 Display = DB_QWORD_DISPLAY; 341 } 342 } 343 344 RetBuf.Length = sizeof (Buffer); 345 RetBuf.Pointer = Buffer; 346 347 /* Differentiate between a number and a name */ 348 349 if ((Target[0] >= 0x30) && (Target[0] <= 0x39)) 350 { 351 ObjPtr = AcpiDbGetPointer (Target); 352 if (!AcpiOsReadable (ObjPtr, 16)) 353 { 354 AcpiOsPrintf ( 355 "Address %p is invalid in this address space\n", 356 ObjPtr); 357 return; 358 } 359 360 /* Decode the object type */ 361 362 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr)) 363 { 364 case ACPI_DESC_TYPE_NAMED: 365 366 /* This is a namespace Node */ 367 368 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) 369 { 370 AcpiOsPrintf ( 371 "Cannot read entire Named object at address %p\n", 372 ObjPtr); 373 return; 374 } 375 376 Node = ObjPtr; 377 goto DumpNode; 378 379 case ACPI_DESC_TYPE_OPERAND: 380 381 /* This is a ACPI OPERAND OBJECT */ 382 383 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) 384 { 385 AcpiOsPrintf ( 386 "Cannot read entire ACPI object at address %p\n", 387 ObjPtr); 388 return; 389 } 390 391 AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), 392 Display, ACPI_UINT32_MAX); 393 AcpiExDumpObjectDescriptor (ObjPtr, 1); 394 break; 395 396 case ACPI_DESC_TYPE_PARSER: 397 398 /* This is a Parser Op object */ 399 400 if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) 401 { 402 AcpiOsPrintf ( 403 "Cannot read entire Parser object at address %p\n", 404 ObjPtr); 405 return; 406 } 407 408 AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), 409 Display, ACPI_UINT32_MAX); 410 AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); 411 break; 412 413 default: 414 415 /* Is not a recognizeable object */ 416 417 AcpiOsPrintf ( 418 "Not a known ACPI internal object, descriptor type %2.2X\n", 419 ACPI_GET_DESCRIPTOR_TYPE (ObjPtr)); 420 421 Size = 16; 422 if (AcpiOsReadable (ObjPtr, 64)) 423 { 424 Size = 64; 425 } 426 427 /* Just dump some memory */ 428 429 AcpiUtDebugDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX); 430 break; 431 } 432 433 return; 434 } 435 436 /* The parameter is a name string that must be resolved to a Named obj */ 437 438 Node = AcpiDbLocalNsLookup (Target); 439 if (!Node) 440 { 441 return; 442 } 443 444 445 DumpNode: 446 /* Now dump the NS node */ 447 448 Status = AcpiGetName (Node, ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf); 449 if (ACPI_FAILURE (Status)) 450 { 451 AcpiOsPrintf ("Could not convert name to pathname\n"); 452 } 453 454 else 455 { 456 AcpiOsPrintf ("Object (%p) Pathname: %s\n", 457 Node, (char *) RetBuf.Pointer); 458 } 459 460 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) 461 { 462 AcpiOsPrintf ("Invalid Named object at address %p\n", Node); 463 return; 464 } 465 466 AcpiUtDebugDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), 467 Display, ACPI_UINT32_MAX); 468 AcpiExDumpNamespaceNode (Node, 1); 469 470 ObjDesc = AcpiNsGetAttachedObject (Node); 471 if (ObjDesc) 472 { 473 AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc); 474 if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT))) 475 { 476 AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", 477 ObjDesc); 478 return; 479 } 480 481 AcpiUtDebugDumpBuffer ((void *) ObjDesc, 482 sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); 483 AcpiExDumpObjectDescriptor (ObjDesc, 1); 484 } 485 } 486 487 488 /******************************************************************************* 489 * 490 * FUNCTION: AcpiDbDisplayMethodInfo 491 * 492 * PARAMETERS: StartOp - Root of the control method parse tree 493 * 494 * RETURN: None 495 * 496 * DESCRIPTION: Display information about the current method 497 * 498 ******************************************************************************/ 499 500 void 501 AcpiDbDisplayMethodInfo ( 502 ACPI_PARSE_OBJECT *StartOp) 503 { 504 ACPI_WALK_STATE *WalkState; 505 ACPI_OPERAND_OBJECT *ObjDesc; 506 ACPI_NAMESPACE_NODE *Node; 507 ACPI_PARSE_OBJECT *RootOp; 508 ACPI_PARSE_OBJECT *Op; 509 const ACPI_OPCODE_INFO *OpInfo; 510 UINT32 NumOps = 0; 511 UINT32 NumOperands = 0; 512 UINT32 NumOperators = 0; 513 UINT32 NumRemainingOps = 0; 514 UINT32 NumRemainingOperands = 0; 515 UINT32 NumRemainingOperators = 0; 516 BOOLEAN CountRemaining = FALSE; 517 518 519 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 520 if (!WalkState) 521 { 522 AcpiOsPrintf ("There is no method currently executing\n"); 523 return; 524 } 525 526 ObjDesc = WalkState->MethodDesc; 527 Node = WalkState->MethodNode; 528 529 AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", 530 AcpiUtGetNodeName (Node)); 531 AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n", 532 (UINT32) ObjDesc->Method.ParamCount, 533 (UINT32) ObjDesc->Method.SyncLevel); 534 535 RootOp = StartOp; 536 while (RootOp->Common.Parent) 537 { 538 RootOp = RootOp->Common.Parent; 539 } 540 541 Op = RootOp; 542 543 while (Op) 544 { 545 if (Op == StartOp) 546 { 547 CountRemaining = TRUE; 548 } 549 550 NumOps++; 551 if (CountRemaining) 552 { 553 NumRemainingOps++; 554 } 555 556 /* Decode the opcode */ 557 558 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 559 switch (OpInfo->Class) 560 { 561 case AML_CLASS_ARGUMENT: 562 563 if (CountRemaining) 564 { 565 NumRemainingOperands++; 566 } 567 568 NumOperands++; 569 break; 570 571 case AML_CLASS_UNKNOWN: 572 573 /* Bad opcode or ASCII character */ 574 575 continue; 576 577 default: 578 579 if (CountRemaining) 580 { 581 NumRemainingOperators++; 582 } 583 584 NumOperators++; 585 break; 586 } 587 588 Op = AcpiPsGetDepthNext (StartOp, Op); 589 } 590 591 AcpiOsPrintf ( 592 "Method contains: %X AML Opcodes - %X Operators, %X Operands\n", 593 NumOps, NumOperators, NumOperands); 594 595 AcpiOsPrintf ( 596 "Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n", 597 NumRemainingOps, NumRemainingOperators, NumRemainingOperands); 598 } 599 600 601 /******************************************************************************* 602 * 603 * FUNCTION: AcpiDbDisplayLocals 604 * 605 * PARAMETERS: None 606 * 607 * RETURN: None 608 * 609 * DESCRIPTION: Display all locals for the currently running control method 610 * 611 ******************************************************************************/ 612 613 void 614 AcpiDbDisplayLocals ( 615 void) 616 { 617 ACPI_WALK_STATE *WalkState; 618 619 620 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 621 if (!WalkState) 622 { 623 AcpiOsPrintf ("There is no method currently executing\n"); 624 return; 625 } 626 627 AcpiDbDecodeLocals (WalkState); 628 } 629 630 631 /******************************************************************************* 632 * 633 * FUNCTION: AcpiDbDisplayArguments 634 * 635 * PARAMETERS: None 636 * 637 * RETURN: None 638 * 639 * DESCRIPTION: Display all arguments for the currently running control method 640 * 641 ******************************************************************************/ 642 643 void 644 AcpiDbDisplayArguments ( 645 void) 646 { 647 ACPI_WALK_STATE *WalkState; 648 649 650 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 651 if (!WalkState) 652 { 653 AcpiOsPrintf ("There is no method currently executing\n"); 654 return; 655 } 656 657 AcpiDbDecodeArguments (WalkState); 658 } 659 660 661 /******************************************************************************* 662 * 663 * FUNCTION: AcpiDbDisplayResults 664 * 665 * PARAMETERS: None 666 * 667 * RETURN: None 668 * 669 * DESCRIPTION: Display current contents of a method result stack 670 * 671 ******************************************************************************/ 672 673 void 674 AcpiDbDisplayResults ( 675 void) 676 { 677 UINT32 i; 678 ACPI_WALK_STATE *WalkState; 679 ACPI_OPERAND_OBJECT *ObjDesc; 680 UINT32 ResultCount = 0; 681 ACPI_NAMESPACE_NODE *Node; 682 ACPI_GENERIC_STATE *Frame; 683 UINT32 Index; /* Index onto current frame */ 684 685 686 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 687 if (!WalkState) 688 { 689 AcpiOsPrintf ("There is no method currently executing\n"); 690 return; 691 } 692 693 ObjDesc = WalkState->MethodDesc; 694 Node = WalkState->MethodNode; 695 696 if (WalkState->Results) 697 { 698 ResultCount = WalkState->ResultCount; 699 } 700 701 AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n", 702 AcpiUtGetNodeName (Node), ResultCount); 703 704 /* From the top element of result stack */ 705 706 Frame = WalkState->Results; 707 Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM; 708 709 for (i = 0; i < ResultCount; i++) 710 { 711 ObjDesc = Frame->Results.ObjDesc[Index]; 712 AcpiOsPrintf ("Result%u: ", i); 713 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 714 715 if (Index == 0) 716 { 717 Frame = Frame->Results.Next; 718 Index = ACPI_RESULTS_FRAME_OBJ_NUM; 719 } 720 721 Index--; 722 } 723 } 724 725 726 /******************************************************************************* 727 * 728 * FUNCTION: AcpiDbDisplayCallingTree 729 * 730 * PARAMETERS: None 731 * 732 * RETURN: None 733 * 734 * DESCRIPTION: Display current calling tree of nested control methods 735 * 736 ******************************************************************************/ 737 738 void 739 AcpiDbDisplayCallingTree ( 740 void) 741 { 742 ACPI_WALK_STATE *WalkState; 743 ACPI_NAMESPACE_NODE *Node; 744 745 746 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 747 if (!WalkState) 748 { 749 AcpiOsPrintf ("There is no method currently executing\n"); 750 return; 751 } 752 753 Node = WalkState->MethodNode; 754 AcpiOsPrintf ("Current Control Method Call Tree\n"); 755 756 while (WalkState) 757 { 758 Node = WalkState->MethodNode; 759 AcpiOsPrintf (" [%4.4s]\n", AcpiUtGetNodeName (Node)); 760 761 WalkState = WalkState->Next; 762 } 763 } 764 765 766 /******************************************************************************* 767 * 768 * FUNCTION: AcpiDbDisplayObjectType 769 * 770 * PARAMETERS: ObjectArg - User entered NS node handle 771 * 772 * RETURN: None 773 * 774 * DESCRIPTION: Display type of an arbitrary NS node 775 * 776 ******************************************************************************/ 777 778 void 779 AcpiDbDisplayObjectType ( 780 char *ObjectArg) 781 { 782 ACPI_SIZE Arg; 783 ACPI_HANDLE Handle; 784 ACPI_DEVICE_INFO *Info; 785 ACPI_STATUS Status; 786 UINT32 i; 787 788 789 Arg = strtoul (ObjectArg, NULL, 16); 790 Handle = ACPI_TO_POINTER (Arg); 791 792 Status = AcpiGetObjectInfo (Handle, &Info); 793 if (ACPI_FAILURE (Status)) 794 { 795 AcpiOsPrintf ("Could not get object info, %s\n", 796 AcpiFormatException (Status)); 797 return; 798 } 799 800 AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", 801 ACPI_FORMAT_UINT64 (Info->Address), 802 Info->CurrentStatus, Info->Flags); 803 804 AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", 805 Info->HighestDstates[0], Info->HighestDstates[1], 806 Info->HighestDstates[2], Info->HighestDstates[3]); 807 808 AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", 809 Info->LowestDstates[0], Info->LowestDstates[1], 810 Info->LowestDstates[2], Info->LowestDstates[3], 811 Info->LowestDstates[4]); 812 813 if (Info->Valid & ACPI_VALID_HID) 814 { 815 AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String); 816 } 817 818 if (Info->Valid & ACPI_VALID_UID) 819 { 820 AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String); 821 } 822 823 if (Info->Valid & ACPI_VALID_CID) 824 { 825 for (i = 0; i < Info->CompatibleIdList.Count; i++) 826 { 827 AcpiOsPrintf ("CID %u: %s\n", i, 828 Info->CompatibleIdList.Ids[i].String); 829 } 830 } 831 832 ACPI_FREE (Info); 833 } 834 835 836 /******************************************************************************* 837 * 838 * FUNCTION: AcpiDbDisplayResultObject 839 * 840 * PARAMETERS: ObjDesc - Object to be displayed 841 * WalkState - Current walk state 842 * 843 * RETURN: None 844 * 845 * DESCRIPTION: Display the result of an AML opcode 846 * 847 * Note: Curently only displays the result object if we are single stepping. 848 * However, this output may be useful in other contexts and could be enabled 849 * to do so if needed. 850 * 851 ******************************************************************************/ 852 853 void 854 AcpiDbDisplayResultObject ( 855 ACPI_OPERAND_OBJECT *ObjDesc, 856 ACPI_WALK_STATE *WalkState) 857 { 858 859 #ifndef ACPI_APPLICATION 860 if (AcpiGbl_DbThreadId != AcpiOsGetThreadId()) 861 { 862 return; 863 } 864 #endif 865 866 /* Only display if single stepping */ 867 868 if (!AcpiGbl_CmSingleStep) 869 { 870 return; 871 } 872 873 AcpiOsPrintf ("ResultObj: "); 874 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 875 AcpiOsPrintf ("\n"); 876 } 877 878 879 /******************************************************************************* 880 * 881 * FUNCTION: AcpiDbDisplayArgumentObject 882 * 883 * PARAMETERS: ObjDesc - Object to be displayed 884 * WalkState - Current walk state 885 * 886 * RETURN: None 887 * 888 * DESCRIPTION: Display the result of an AML opcode 889 * 890 ******************************************************************************/ 891 892 void 893 AcpiDbDisplayArgumentObject ( 894 ACPI_OPERAND_OBJECT *ObjDesc, 895 ACPI_WALK_STATE *WalkState) 896 { 897 898 #ifndef ACPI_APPLICATION 899 if (AcpiGbl_DbThreadId != AcpiOsGetThreadId()) 900 { 901 return; 902 } 903 #endif 904 905 if (!AcpiGbl_CmSingleStep) 906 { 907 return; 908 } 909 910 AcpiOsPrintf ("ArgObj: "); 911 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 912 } 913 914 915 #if (!ACPI_REDUCED_HARDWARE) 916 /******************************************************************************* 917 * 918 * FUNCTION: AcpiDbDisplayGpes 919 * 920 * PARAMETERS: None 921 * 922 * RETURN: None 923 * 924 * DESCRIPTION: Display the current GPE structures 925 * 926 ******************************************************************************/ 927 928 void 929 AcpiDbDisplayGpes ( 930 void) 931 { 932 ACPI_GPE_BLOCK_INFO *GpeBlock; 933 ACPI_GPE_XRUPT_INFO *GpeXruptInfo; 934 ACPI_GPE_EVENT_INFO *GpeEventInfo; 935 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 936 char *GpeType; 937 ACPI_GPE_NOTIFY_INFO *Notify; 938 UINT32 GpeIndex; 939 UINT32 Block = 0; 940 UINT32 i; 941 UINT32 j; 942 UINT32 Count; 943 char Buffer[80]; 944 ACPI_BUFFER RetBuf; 945 ACPI_STATUS Status; 946 947 948 RetBuf.Length = sizeof (Buffer); 949 RetBuf.Pointer = Buffer; 950 951 Block = 0; 952 953 /* Walk the GPE lists */ 954 955 GpeXruptInfo = AcpiGbl_GpeXruptListHead; 956 while (GpeXruptInfo) 957 { 958 GpeBlock = GpeXruptInfo->GpeBlockListHead; 959 while (GpeBlock) 960 { 961 Status = AcpiGetName (GpeBlock->Node, 962 ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf); 963 if (ACPI_FAILURE (Status)) 964 { 965 AcpiOsPrintf ("Could not convert name to pathname\n"); 966 } 967 968 if (GpeBlock->Node == AcpiGbl_FadtGpeDevice) 969 { 970 GpeType = "FADT-defined GPE block"; 971 } 972 else 973 { 974 GpeType = "GPE Block Device"; 975 } 976 977 AcpiOsPrintf ( 978 "\nBlock %u - Info %p DeviceNode %p [%s] - %s\n", 979 Block, GpeBlock, GpeBlock->Node, Buffer, GpeType); 980 981 AcpiOsPrintf ( 982 " Registers: %u (%u GPEs)\n", 983 GpeBlock->RegisterCount, GpeBlock->GpeCount); 984 985 AcpiOsPrintf ( 986 " GPE range: 0x%X to 0x%X on interrupt %u\n", 987 GpeBlock->BlockBaseNumber, 988 GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1), 989 GpeXruptInfo->InterruptNumber); 990 991 AcpiOsPrintf ( 992 " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", 993 GpeBlock->RegisterInfo, 994 ACPI_FORMAT_UINT64 ( 995 GpeBlock->RegisterInfo->StatusAddress.Address), 996 ACPI_FORMAT_UINT64 ( 997 GpeBlock->RegisterInfo->EnableAddress.Address)); 998 999 AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); 1000 1001 /* Examine each GPE Register within the block */ 1002 1003 for (i = 0; i < GpeBlock->RegisterCount; i++) 1004 { 1005 GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; 1006 1007 AcpiOsPrintf ( 1008 " Reg %u: (GPE %.2X-%.2X) " 1009 "RunEnable %2.2X WakeEnable %2.2X" 1010 " Status %8.8X%8.8X Enable %8.8X%8.8X\n", 1011 i, GpeRegisterInfo->BaseGpeNumber, 1012 GpeRegisterInfo->BaseGpeNumber + 1013 (ACPI_GPE_REGISTER_WIDTH - 1), 1014 GpeRegisterInfo->EnableForRun, 1015 GpeRegisterInfo->EnableForWake, 1016 ACPI_FORMAT_UINT64 ( 1017 GpeRegisterInfo->StatusAddress.Address), 1018 ACPI_FORMAT_UINT64 ( 1019 GpeRegisterInfo->EnableAddress.Address)); 1020 1021 /* Now look at the individual GPEs in this byte register */ 1022 1023 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) 1024 { 1025 GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j; 1026 GpeEventInfo = &GpeBlock->EventInfo[GpeIndex]; 1027 1028 if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) == 1029 ACPI_GPE_DISPATCH_NONE) 1030 { 1031 /* This GPE is not used (no method or handler), ignore it */ 1032 1033 continue; 1034 } 1035 1036 AcpiOsPrintf ( 1037 " GPE %.2X: %p RunRefs %2.2X Flags %2.2X (", 1038 GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo, 1039 GpeEventInfo->RuntimeCount, GpeEventInfo->Flags); 1040 1041 /* Decode the flags byte */ 1042 1043 if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED) 1044 { 1045 AcpiOsPrintf ("Level, "); 1046 } 1047 else 1048 { 1049 AcpiOsPrintf ("Edge, "); 1050 } 1051 1052 if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE) 1053 { 1054 AcpiOsPrintf ("CanWake, "); 1055 } 1056 else 1057 { 1058 AcpiOsPrintf ("RunOnly, "); 1059 } 1060 1061 switch (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags)) 1062 { 1063 case ACPI_GPE_DISPATCH_NONE: 1064 1065 AcpiOsPrintf ("NotUsed"); 1066 break; 1067 1068 case ACPI_GPE_DISPATCH_METHOD: 1069 1070 AcpiOsPrintf ("Method"); 1071 break; 1072 1073 case ACPI_GPE_DISPATCH_HANDLER: 1074 1075 AcpiOsPrintf ("Handler"); 1076 break; 1077 1078 case ACPI_GPE_DISPATCH_NOTIFY: 1079 1080 Count = 0; 1081 Notify = GpeEventInfo->Dispatch.NotifyList; 1082 while (Notify) 1083 { 1084 Count++; 1085 Notify = Notify->Next; 1086 } 1087 1088 AcpiOsPrintf ("Implicit Notify on %u devices", 1089 Count); 1090 break; 1091 1092 case ACPI_GPE_DISPATCH_RAW_HANDLER: 1093 1094 AcpiOsPrintf ("RawHandler"); 1095 break; 1096 1097 default: 1098 1099 AcpiOsPrintf ("UNKNOWN: %X", 1100 ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags)); 1101 break; 1102 } 1103 1104 AcpiOsPrintf (")\n"); 1105 } 1106 } 1107 1108 Block++; 1109 GpeBlock = GpeBlock->Next; 1110 } 1111 1112 GpeXruptInfo = GpeXruptInfo->Next; 1113 } 1114 } 1115 #endif /* !ACPI_REDUCED_HARDWARE */ 1116 1117 1118 /******************************************************************************* 1119 * 1120 * FUNCTION: AcpiDbDisplayHandlers 1121 * 1122 * PARAMETERS: None 1123 * 1124 * RETURN: None 1125 * 1126 * DESCRIPTION: Display the currently installed global handlers 1127 * 1128 ******************************************************************************/ 1129 1130 void 1131 AcpiDbDisplayHandlers ( 1132 void) 1133 { 1134 ACPI_OPERAND_OBJECT *ObjDesc; 1135 ACPI_OPERAND_OBJECT *HandlerObj; 1136 ACPI_ADR_SPACE_TYPE SpaceId; 1137 UINT32 i; 1138 1139 1140 /* Operation region handlers */ 1141 1142 AcpiOsPrintf ("\nOperation Region Handlers at the namespace root:\n"); 1143 1144 ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode); 1145 if (ObjDesc) 1146 { 1147 for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++) 1148 { 1149 SpaceId = AcpiGbl_SpaceIdList[i]; 1150 1151 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, 1152 AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId); 1153 1154 HandlerObj = AcpiEvFindRegionHandler ( 1155 SpaceId, ObjDesc->CommonNotify.Handler); 1156 if (HandlerObj) 1157 { 1158 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, 1159 (HandlerObj->AddressSpace.HandlerFlags & 1160 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? 1161 "Default" : "User", 1162 HandlerObj->AddressSpace.Handler); 1163 1164 goto FoundHandler; 1165 } 1166 1167 /* There is no handler for this SpaceId */ 1168 1169 AcpiOsPrintf ("None\n"); 1170 1171 FoundHandler:; 1172 } 1173 1174 /* Find all handlers for user-defined SpaceIDs */ 1175 1176 HandlerObj = ObjDesc->CommonNotify.Handler; 1177 while (HandlerObj) 1178 { 1179 if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN) 1180 { 1181 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, 1182 "User-defined ID", HandlerObj->AddressSpace.SpaceId); 1183 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, 1184 (HandlerObj->AddressSpace.HandlerFlags & 1185 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? 1186 "Default" : "User", 1187 HandlerObj->AddressSpace.Handler); 1188 } 1189 1190 HandlerObj = HandlerObj->AddressSpace.Next; 1191 } 1192 } 1193 1194 #if (!ACPI_REDUCED_HARDWARE) 1195 1196 /* Fixed event handlers */ 1197 1198 AcpiOsPrintf ("\nFixed Event Handlers:\n"); 1199 1200 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) 1201 { 1202 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i); 1203 if (AcpiGbl_FixedEventHandlers[i].Handler) 1204 { 1205 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User", 1206 AcpiGbl_FixedEventHandlers[i].Handler); 1207 } 1208 else 1209 { 1210 AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None"); 1211 } 1212 } 1213 1214 #endif /* !ACPI_REDUCED_HARDWARE */ 1215 1216 /* Miscellaneous global handlers */ 1217 1218 AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n"); 1219 1220 for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++) 1221 { 1222 AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, 1223 AcpiGbl_HandlerList[i].Name); 1224 1225 if (AcpiGbl_HandlerList[i].Handler) 1226 { 1227 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User", 1228 AcpiGbl_HandlerList[i].Handler); 1229 } 1230 else 1231 { 1232 AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None"); 1233 } 1234 } 1235 1236 1237 /* Other handlers that are installed throughout the namespace */ 1238 1239 AcpiOsPrintf ("\nOperation Region Handlers for specific devices:\n"); 1240 1241 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 1242 ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers, 1243 NULL, NULL, NULL); 1244 } 1245 1246 1247 /******************************************************************************* 1248 * 1249 * FUNCTION: AcpiDbDisplayNonRootHandlers 1250 * 1251 * PARAMETERS: ACPI_WALK_CALLBACK 1252 * 1253 * RETURN: Status 1254 * 1255 * DESCRIPTION: Display information about all handlers installed for a 1256 * device object. 1257 * 1258 ******************************************************************************/ 1259 1260 static ACPI_STATUS 1261 AcpiDbDisplayNonRootHandlers ( 1262 ACPI_HANDLE ObjHandle, 1263 UINT32 NestingLevel, 1264 void *Context, 1265 void **ReturnValue) 1266 { 1267 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); 1268 ACPI_OPERAND_OBJECT *ObjDesc; 1269 ACPI_OPERAND_OBJECT *HandlerObj; 1270 char *Pathname; 1271 1272 1273 ObjDesc = AcpiNsGetAttachedObject (Node); 1274 if (!ObjDesc) 1275 { 1276 return (AE_OK); 1277 } 1278 1279 Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); 1280 if (!Pathname) 1281 { 1282 return (AE_OK); 1283 } 1284 1285 /* Display all handlers associated with this device */ 1286 1287 HandlerObj = ObjDesc->CommonNotify.Handler; 1288 while (HandlerObj) 1289 { 1290 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, 1291 AcpiUtGetRegionName ((UINT8) HandlerObj->AddressSpace.SpaceId), 1292 HandlerObj->AddressSpace.SpaceId); 1293 1294 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING2, 1295 (HandlerObj->AddressSpace.HandlerFlags & 1296 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User", 1297 HandlerObj->AddressSpace.Handler); 1298 1299 AcpiOsPrintf (" Device Name: %s (%p)\n", Pathname, Node); 1300 1301 HandlerObj = HandlerObj->AddressSpace.Next; 1302 } 1303 1304 ACPI_FREE (Pathname); 1305 return (AE_OK); 1306 } 1307 1308 #endif /* ACPI_DEBUGGER */ 1309