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