1 /******************************************************************************* 2 * 3 * Module Name: dbobject - ACPI object decode and display 4 * 5 ******************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2020, 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 "acnamesp.h" 155 #include "acdebug.h" 156 157 158 #ifdef ACPI_DEBUGGER 159 160 #define _COMPONENT ACPI_CA_DEBUGGER 161 ACPI_MODULE_NAME ("dbobject") 162 163 164 /* Local prototypes */ 165 166 static void 167 AcpiDbDecodeNode ( 168 ACPI_NAMESPACE_NODE *Node); 169 170 171 /******************************************************************************* 172 * 173 * FUNCTION: AcpiDbDumpMethodInfo 174 * 175 * PARAMETERS: Status - Method execution status 176 * WalkState - Current state of the parse tree walk 177 * 178 * RETURN: None 179 * 180 * DESCRIPTION: Called when a method has been aborted because of an error. 181 * Dumps the method execution stack, and the method locals/args, 182 * and disassembles the AML opcode that failed. 183 * 184 ******************************************************************************/ 185 186 void 187 AcpiDbDumpMethodInfo ( 188 ACPI_STATUS Status, 189 ACPI_WALK_STATE *WalkState) 190 { 191 ACPI_THREAD_STATE *Thread; 192 ACPI_NAMESPACE_NODE *Node; 193 194 195 Node = WalkState->MethodNode; 196 197 /* There are no locals or arguments for the module-level code case */ 198 199 if (Node == AcpiGbl_RootNode) 200 { 201 return; 202 } 203 204 /* Ignore control codes, they are not errors */ 205 206 if ((Status & AE_CODE_MASK) == AE_CODE_CONTROL) 207 { 208 return; 209 } 210 211 /* We may be executing a deferred opcode */ 212 213 if (WalkState->DeferredNode) 214 { 215 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n"); 216 return; 217 } 218 219 /* 220 * If there is no Thread, we are not actually executing a method. 221 * This can happen when the iASL compiler calls the interpreter 222 * to perform constant folding. 223 */ 224 Thread = WalkState->Thread; 225 if (!Thread) 226 { 227 return; 228 } 229 230 /* Display the method locals and arguments */ 231 232 AcpiOsPrintf ("\n"); 233 AcpiDbDecodeLocals (WalkState); 234 AcpiOsPrintf ("\n"); 235 AcpiDbDecodeArguments (WalkState); 236 AcpiOsPrintf ("\n"); 237 } 238 239 240 /******************************************************************************* 241 * 242 * FUNCTION: AcpiDbDecodeInternalObject 243 * 244 * PARAMETERS: ObjDesc - Object to be displayed 245 * 246 * RETURN: None 247 * 248 * DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers. 249 * 250 ******************************************************************************/ 251 252 void 253 AcpiDbDecodeInternalObject ( 254 ACPI_OPERAND_OBJECT *ObjDesc) 255 { 256 UINT32 i; 257 258 259 if (!ObjDesc) 260 { 261 AcpiOsPrintf (" Uninitialized"); 262 return; 263 } 264 265 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) 266 { 267 AcpiOsPrintf (" %p [%s]", ObjDesc, 268 AcpiUtGetDescriptorName (ObjDesc)); 269 return; 270 } 271 272 AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc)); 273 274 switch (ObjDesc->Common.Type) 275 { 276 case ACPI_TYPE_INTEGER: 277 278 AcpiOsPrintf (" %8.8X%8.8X", 279 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); 280 break; 281 282 case ACPI_TYPE_STRING: 283 284 AcpiOsPrintf ("(%u) \"%.60s", 285 ObjDesc->String.Length, ObjDesc->String.Pointer); 286 287 if (ObjDesc->String.Length > 60) 288 { 289 AcpiOsPrintf ("..."); 290 } 291 else 292 { 293 AcpiOsPrintf ("\""); 294 } 295 break; 296 297 case ACPI_TYPE_BUFFER: 298 299 AcpiOsPrintf ("(%u)", ObjDesc->Buffer.Length); 300 for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++) 301 { 302 AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]); 303 } 304 break; 305 306 default: 307 308 AcpiOsPrintf (" %p", ObjDesc); 309 break; 310 } 311 } 312 313 314 /******************************************************************************* 315 * 316 * FUNCTION: AcpiDbDecodeNode 317 * 318 * PARAMETERS: Node - Object to be displayed 319 * 320 * RETURN: None 321 * 322 * DESCRIPTION: Short display of a namespace node 323 * 324 ******************************************************************************/ 325 326 static void 327 AcpiDbDecodeNode ( 328 ACPI_NAMESPACE_NODE *Node) 329 { 330 331 AcpiOsPrintf ("<Node> Name %4.4s", 332 AcpiUtGetNodeName (Node)); 333 334 if (Node->Flags & ANOBJ_METHOD_ARG) 335 { 336 AcpiOsPrintf (" [Method Arg]"); 337 } 338 if (Node->Flags & ANOBJ_METHOD_LOCAL) 339 { 340 AcpiOsPrintf (" [Method Local]"); 341 } 342 343 switch (Node->Type) 344 { 345 /* These types have no attached object */ 346 347 case ACPI_TYPE_DEVICE: 348 349 AcpiOsPrintf (" Device"); 350 break; 351 352 case ACPI_TYPE_THERMAL: 353 354 AcpiOsPrintf (" Thermal Zone"); 355 break; 356 357 default: 358 359 AcpiDbDecodeInternalObject (AcpiNsGetAttachedObject (Node)); 360 break; 361 } 362 } 363 364 365 /******************************************************************************* 366 * 367 * FUNCTION: AcpiDbDisplayInternalObject 368 * 369 * PARAMETERS: ObjDesc - Object to be displayed 370 * WalkState - Current walk state 371 * 372 * RETURN: None 373 * 374 * DESCRIPTION: Short display of an internal object 375 * 376 ******************************************************************************/ 377 378 void 379 AcpiDbDisplayInternalObject ( 380 ACPI_OPERAND_OBJECT *ObjDesc, 381 ACPI_WALK_STATE *WalkState) 382 { 383 UINT8 Type; 384 385 386 AcpiOsPrintf ("%p ", ObjDesc); 387 388 if (!ObjDesc) 389 { 390 AcpiOsPrintf ("<Null Object>\n"); 391 return; 392 } 393 394 /* Decode the object type */ 395 396 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) 397 { 398 case ACPI_DESC_TYPE_PARSER: 399 400 AcpiOsPrintf ("<Parser> "); 401 break; 402 403 case ACPI_DESC_TYPE_NAMED: 404 405 AcpiDbDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc); 406 break; 407 408 case ACPI_DESC_TYPE_OPERAND: 409 410 Type = ObjDesc->Common.Type; 411 if (Type > ACPI_TYPE_LOCAL_MAX) 412 { 413 AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type); 414 return; 415 } 416 417 /* Decode the ACPI object type */ 418 419 switch (ObjDesc->Common.Type) 420 { 421 case ACPI_TYPE_LOCAL_REFERENCE: 422 423 AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (ObjDesc)); 424 425 /* Decode the reference */ 426 427 switch (ObjDesc->Reference.Class) 428 { 429 case ACPI_REFCLASS_LOCAL: 430 431 AcpiOsPrintf ("%X ", ObjDesc->Reference.Value); 432 if (WalkState) 433 { 434 ObjDesc = WalkState->LocalVariables 435 [ObjDesc->Reference.Value].Object; 436 AcpiOsPrintf ("%p", ObjDesc); 437 AcpiDbDecodeInternalObject (ObjDesc); 438 } 439 break; 440 441 case ACPI_REFCLASS_ARG: 442 443 AcpiOsPrintf ("%X ", ObjDesc->Reference.Value); 444 if (WalkState) 445 { 446 ObjDesc = WalkState->Arguments 447 [ObjDesc->Reference.Value].Object; 448 AcpiOsPrintf ("%p", ObjDesc); 449 AcpiDbDecodeInternalObject (ObjDesc); 450 } 451 break; 452 453 case ACPI_REFCLASS_INDEX: 454 455 switch (ObjDesc->Reference.TargetType) 456 { 457 case ACPI_TYPE_BUFFER_FIELD: 458 459 AcpiOsPrintf ("%p", ObjDesc->Reference.Object); 460 AcpiDbDecodeInternalObject (ObjDesc->Reference.Object); 461 break; 462 463 case ACPI_TYPE_PACKAGE: 464 465 AcpiOsPrintf ("%p", ObjDesc->Reference.Where); 466 if (!ObjDesc->Reference.Where) 467 { 468 AcpiOsPrintf (" Uninitialized WHERE pointer"); 469 } 470 else 471 { 472 AcpiDbDecodeInternalObject ( 473 *(ObjDesc->Reference.Where)); 474 } 475 break; 476 477 default: 478 479 AcpiOsPrintf ("Unknown index target type"); 480 break; 481 } 482 break; 483 484 case ACPI_REFCLASS_REFOF: 485 486 if (!ObjDesc->Reference.Object) 487 { 488 AcpiOsPrintf ( 489 "Uninitialized reference subobject pointer"); 490 break; 491 } 492 493 /* Reference can be to a Node or an Operand object */ 494 495 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object)) 496 { 497 case ACPI_DESC_TYPE_NAMED: 498 499 AcpiDbDecodeNode (ObjDesc->Reference.Object); 500 break; 501 502 case ACPI_DESC_TYPE_OPERAND: 503 504 AcpiDbDecodeInternalObject (ObjDesc->Reference.Object); 505 break; 506 507 default: 508 break; 509 } 510 break; 511 512 case ACPI_REFCLASS_NAME: 513 514 AcpiDbDecodeNode (ObjDesc->Reference.Node); 515 break; 516 517 case ACPI_REFCLASS_DEBUG: 518 case ACPI_REFCLASS_TABLE: 519 520 AcpiOsPrintf ("\n"); 521 break; 522 523 default: /* Unknown reference class */ 524 525 AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class); 526 break; 527 } 528 break; 529 530 default: 531 532 AcpiOsPrintf ("<Obj> "); 533 AcpiDbDecodeInternalObject (ObjDesc); 534 break; 535 } 536 break; 537 538 default: 539 540 AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> [%s]", 541 AcpiUtGetDescriptorName (ObjDesc)); 542 break; 543 } 544 545 AcpiOsPrintf ("\n"); 546 } 547 548 549 /******************************************************************************* 550 * 551 * FUNCTION: AcpiDbDecodeLocals 552 * 553 * PARAMETERS: WalkState - State for current method 554 * 555 * RETURN: None 556 * 557 * DESCRIPTION: Display all locals for the currently running control method 558 * 559 ******************************************************************************/ 560 561 void 562 AcpiDbDecodeLocals ( 563 ACPI_WALK_STATE *WalkState) 564 { 565 UINT32 i; 566 ACPI_OPERAND_OBJECT *ObjDesc; 567 ACPI_NAMESPACE_NODE *Node; 568 BOOLEAN DisplayLocals = FALSE; 569 570 571 Node = WalkState->MethodNode; 572 573 /* There are no locals for the module-level code case */ 574 575 if (Node == AcpiGbl_RootNode) 576 { 577 return; 578 } 579 580 if (!Node) 581 { 582 AcpiOsPrintf ( 583 "No method node (Executing subtree for buffer or opregion)\n"); 584 return; 585 } 586 587 if (Node->Type != ACPI_TYPE_METHOD) 588 { 589 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n"); 590 return; 591 } 592 593 /* Are any locals actually set? */ 594 595 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) 596 { 597 ObjDesc = WalkState->LocalVariables[i].Object; 598 if (ObjDesc) 599 { 600 DisplayLocals = TRUE; 601 break; 602 } 603 } 604 605 /* If any are set, only display the ones that are set */ 606 607 if (DisplayLocals) 608 { 609 AcpiOsPrintf ("\nInitialized Local Variables for Method [%4.4s]:\n", 610 AcpiUtGetNodeName (Node)); 611 612 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) 613 { 614 ObjDesc = WalkState->LocalVariables[i].Object; 615 if (ObjDesc) 616 { 617 AcpiOsPrintf (" Local%X: ", i); 618 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 619 } 620 } 621 } 622 else 623 { 624 AcpiOsPrintf ( 625 "No Local Variables are initialized for Method [%4.4s]\n", 626 AcpiUtGetNodeName (Node)); 627 } 628 } 629 630 631 /******************************************************************************* 632 * 633 * FUNCTION: AcpiDbDecodeArguments 634 * 635 * PARAMETERS: WalkState - State for current method 636 * 637 * RETURN: None 638 * 639 * DESCRIPTION: Display all arguments for the currently running control method 640 * 641 ******************************************************************************/ 642 643 void 644 AcpiDbDecodeArguments ( 645 ACPI_WALK_STATE *WalkState) 646 { 647 UINT32 i; 648 ACPI_OPERAND_OBJECT *ObjDesc; 649 ACPI_NAMESPACE_NODE *Node; 650 BOOLEAN DisplayArgs = FALSE; 651 652 653 Node = WalkState->MethodNode; 654 655 /* There are no arguments for the module-level code case */ 656 657 if (Node == AcpiGbl_RootNode) 658 { 659 return; 660 } 661 662 if (!Node) 663 { 664 AcpiOsPrintf ( 665 "No method node (Executing subtree for buffer or opregion)\n"); 666 return; 667 } 668 669 if (Node->Type != ACPI_TYPE_METHOD) 670 { 671 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n"); 672 return; 673 } 674 675 /* Are any arguments actually set? */ 676 677 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) 678 { 679 ObjDesc = WalkState->Arguments[i].Object; 680 if (ObjDesc) 681 { 682 DisplayArgs = TRUE; 683 break; 684 } 685 } 686 687 /* If any are set, only display the ones that are set */ 688 689 if (DisplayArgs) 690 { 691 AcpiOsPrintf ( 692 "Initialized Arguments for Method [%4.4s]: " 693 "(%X arguments defined for method invocation)\n", 694 AcpiUtGetNodeName (Node), Node->Object->Method.ParamCount); 695 696 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) 697 { 698 ObjDesc = WalkState->Arguments[i].Object; 699 if (ObjDesc) 700 { 701 AcpiOsPrintf (" Arg%u: ", i); 702 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 703 } 704 } 705 } 706 else 707 { 708 AcpiOsPrintf ( 709 "No Arguments are initialized for method [%4.4s]\n", 710 AcpiUtGetNodeName (Node)); 711 } 712 } 713 714 #endif 715