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