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