Home | History | Annotate | Line # | Download | only in debugger
dbdisply.c revision 1.13
      1 /*******************************************************************************
      2  *
      3  * Module Name: dbdisply - debug display commands
      4  *
      5  ******************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2017, 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 recognizeable 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     ObjDesc = WalkState->MethodDesc;
    609     Node  = WalkState->MethodNode;
    610 
    611     if (WalkState->Results)
    612     {
    613         ResultCount = WalkState->ResultCount;
    614     }
    615 
    616     AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
    617         AcpiUtGetNodeName (Node), ResultCount);
    618 
    619     /* From the top element of result stack */
    620 
    621     Frame = WalkState->Results;
    622     Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
    623 
    624     for (i = 0; i < ResultCount; i++)
    625     {
    626         ObjDesc = Frame->Results.ObjDesc[Index];
    627         AcpiOsPrintf ("Result%u: ", i);
    628         AcpiDbDisplayInternalObject (ObjDesc, WalkState);
    629 
    630         if (Index == 0)
    631         {
    632             Frame = Frame->Results.Next;
    633             Index = ACPI_RESULTS_FRAME_OBJ_NUM;
    634         }
    635 
    636         Index--;
    637     }
    638 }
    639 
    640 
    641 /*******************************************************************************
    642  *
    643  * FUNCTION:    AcpiDbDisplayCallingTree
    644  *
    645  * PARAMETERS:  None
    646  *
    647  * RETURN:      None
    648  *
    649  * DESCRIPTION: Display current calling tree of nested control methods
    650  *
    651  ******************************************************************************/
    652 
    653 void
    654 AcpiDbDisplayCallingTree (
    655     void)
    656 {
    657     ACPI_WALK_STATE         *WalkState;
    658     ACPI_NAMESPACE_NODE     *Node;
    659 
    660 
    661     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
    662     if (!WalkState)
    663     {
    664         AcpiOsPrintf ("There is no method currently executing\n");
    665         return;
    666     }
    667 
    668     Node = WalkState->MethodNode;
    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 
    693 void
    694 AcpiDbDisplayObjectType (
    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, STA: %8.8X, Flags: %X\n",
    716         ACPI_FORMAT_UINT64 (Info->Address),
    717         Info->CurrentStatus, Info->Flags);
    718 
    719     AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
    720         Info->HighestDstates[0], Info->HighestDstates[1],
    721         Info->HighestDstates[2], Info->HighestDstates[3]);
    722 
    723     AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
    724         Info->LowestDstates[0], Info->LowestDstates[1],
    725         Info->LowestDstates[2], Info->LowestDstates[3],
    726         Info->LowestDstates[4]);
    727 
    728     if (Info->Valid & ACPI_VALID_HID)
    729     {
    730         AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String);
    731     }
    732 
    733     if (Info->Valid & ACPI_VALID_UID)
    734     {
    735         AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String);
    736     }
    737 
    738     if (Info->Valid & ACPI_VALID_CID)
    739     {
    740         for (i = 0; i < Info->CompatibleIdList.Count; i++)
    741         {
    742             AcpiOsPrintf ("CID %u: %s\n", i,
    743                 Info->CompatibleIdList.Ids[i].String);
    744         }
    745     }
    746 
    747     ACPI_FREE (Info);
    748 }
    749 
    750 
    751 /*******************************************************************************
    752  *
    753  * FUNCTION:    AcpiDbDisplayResultObject
    754  *
    755  * PARAMETERS:  ObjDesc         - Object to be displayed
    756  *              WalkState       - Current walk state
    757  *
    758  * RETURN:      None
    759  *
    760  * DESCRIPTION: Display the result of an AML opcode
    761  *
    762  * Note: Curently only displays the result object if we are single stepping.
    763  * However, this output may be useful in other contexts and could be enabled
    764  * to do so if needed.
    765  *
    766  ******************************************************************************/
    767 
    768 void
    769 AcpiDbDisplayResultObject (
    770     ACPI_OPERAND_OBJECT     *ObjDesc,
    771     ACPI_WALK_STATE         *WalkState)
    772 {
    773 
    774 #ifndef ACPI_APPLICATION
    775     if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())
    776     {
    777         return;
    778     }
    779 #endif
    780 
    781     /* Only display if single stepping */
    782 
    783     if (!AcpiGbl_CmSingleStep)
    784     {
    785         return;
    786     }
    787 
    788     AcpiOsPrintf ("ResultObj: ");
    789     AcpiDbDisplayInternalObject (ObjDesc, WalkState);
    790     AcpiOsPrintf ("\n");
    791 }
    792 
    793 
    794 /*******************************************************************************
    795  *
    796  * FUNCTION:    AcpiDbDisplayArgumentObject
    797  *
    798  * PARAMETERS:  ObjDesc         - Object to be displayed
    799  *              WalkState       - Current walk state
    800  *
    801  * RETURN:      None
    802  *
    803  * DESCRIPTION: Display the result of an AML opcode
    804  *
    805  ******************************************************************************/
    806 
    807 void
    808 AcpiDbDisplayArgumentObject (
    809     ACPI_OPERAND_OBJECT     *ObjDesc,
    810     ACPI_WALK_STATE         *WalkState)
    811 {
    812 
    813 #ifndef ACPI_APPLICATION
    814     if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())
    815     {
    816         return;
    817     }
    818 #endif
    819 
    820     if (!AcpiGbl_CmSingleStep)
    821     {
    822         return;
    823     }
    824 
    825     AcpiOsPrintf ("ArgObj:    ");
    826     AcpiDbDisplayInternalObject (ObjDesc, WalkState);
    827 }
    828 
    829 
    830 #if (!ACPI_REDUCED_HARDWARE)
    831 /*******************************************************************************
    832  *
    833  * FUNCTION:    AcpiDbDisplayGpes
    834  *
    835  * PARAMETERS:  None
    836  *
    837  * RETURN:      None
    838  *
    839  * DESCRIPTION: Display the current GPE structures
    840  *
    841  ******************************************************************************/
    842 
    843 void
    844 AcpiDbDisplayGpes (
    845     void)
    846 {
    847     ACPI_GPE_BLOCK_INFO     *GpeBlock;
    848     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo;
    849     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
    850     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    851     const char              *GpeType;
    852     ACPI_GPE_NOTIFY_INFO    *Notify;
    853     UINT32                  GpeIndex;
    854     UINT32                  Block = 0;
    855     UINT32                  i;
    856     UINT32                  j;
    857     UINT32                  Count;
    858     char                    Buffer[80];
    859     ACPI_BUFFER             RetBuf;
    860     ACPI_STATUS             Status;
    861 
    862 
    863     RetBuf.Length = sizeof (Buffer);
    864     RetBuf.Pointer = Buffer;
    865 
    866     Block = 0;
    867 
    868     /* Walk the GPE lists */
    869 
    870     GpeXruptInfo = AcpiGbl_GpeXruptListHead;
    871     while (GpeXruptInfo)
    872     {
    873         GpeBlock = GpeXruptInfo->GpeBlockListHead;
    874         while (GpeBlock)
    875         {
    876             Status = AcpiGetName (GpeBlock->Node,
    877                 ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);
    878             if (ACPI_FAILURE (Status))
    879             {
    880                 AcpiOsPrintf ("Could not convert name to pathname\n");
    881             }
    882 
    883             if (GpeBlock->Node == AcpiGbl_FadtGpeDevice)
    884             {
    885                 GpeType = "FADT-defined GPE block";
    886             }
    887             else
    888             {
    889                 GpeType = "GPE Block Device";
    890             }
    891 
    892             AcpiOsPrintf (
    893                 "\nBlock %u - Info %p  DeviceNode %p [%s] - %s\n",
    894                 Block, GpeBlock, GpeBlock->Node, Buffer, GpeType);
    895 
    896             AcpiOsPrintf (
    897                 "    Registers:    %u (%u GPEs)\n",
    898                 GpeBlock->RegisterCount, GpeBlock->GpeCount);
    899 
    900             AcpiOsPrintf (
    901                 "    GPE range:    0x%X to 0x%X on interrupt %u\n",
    902                 GpeBlock->BlockBaseNumber,
    903                 GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1),
    904                 GpeXruptInfo->InterruptNumber);
    905 
    906             AcpiOsPrintf (
    907                 "    RegisterInfo: %p  Status %8.8X%8.8X Enable %8.8X%8.8X\n",
    908                 GpeBlock->RegisterInfo,
    909                 ACPI_FORMAT_UINT64 (
    910                     GpeBlock->RegisterInfo->StatusAddress.Address),
    911                 ACPI_FORMAT_UINT64 (
    912                     GpeBlock->RegisterInfo->EnableAddress.Address));
    913 
    914             AcpiOsPrintf ("    EventInfo:    %p\n", GpeBlock->EventInfo);
    915 
    916             /* Examine each GPE Register within the block */
    917 
    918             for (i = 0; i < GpeBlock->RegisterCount; i++)
    919             {
    920                 GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
    921 
    922                 AcpiOsPrintf (
    923                     "    Reg %u: (GPE %.2X-%.2X)  "
    924                     "RunEnable %2.2X WakeEnable %2.2X"
    925                     " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
    926                     i, GpeRegisterInfo->BaseGpeNumber,
    927                     GpeRegisterInfo->BaseGpeNumber +
    928                         (ACPI_GPE_REGISTER_WIDTH - 1),
    929                     GpeRegisterInfo->EnableForRun,
    930                     GpeRegisterInfo->EnableForWake,
    931                     ACPI_FORMAT_UINT64 (
    932                         GpeRegisterInfo->StatusAddress.Address),
    933                     ACPI_FORMAT_UINT64 (
    934                         GpeRegisterInfo->EnableAddress.Address));
    935 
    936                 /* Now look at the individual GPEs in this byte register */
    937 
    938                 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
    939                 {
    940                     GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;
    941                     GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];
    942 
    943                     if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) ==
    944                         ACPI_GPE_DISPATCH_NONE)
    945                     {
    946                         /* This GPE is not used (no method or handler), ignore it */
    947 
    948                         continue;
    949                     }
    950 
    951                     AcpiOsPrintf (
    952                         "        GPE %.2X: %p  RunRefs %2.2X Flags %2.2X (",
    953                         GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo,
    954                         GpeEventInfo->RuntimeCount, GpeEventInfo->Flags);
    955 
    956                     /* Decode the flags byte */
    957 
    958                     if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED)
    959                     {
    960                         AcpiOsPrintf ("Level, ");
    961                     }
    962                     else
    963                     {
    964                         AcpiOsPrintf ("Edge,  ");
    965                     }
    966 
    967                     if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)
    968                     {
    969                         AcpiOsPrintf ("CanWake, ");
    970                     }
    971                     else
    972                     {
    973                         AcpiOsPrintf ("RunOnly, ");
    974                     }
    975 
    976                     switch (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags))
    977                     {
    978                     case ACPI_GPE_DISPATCH_NONE:
    979 
    980                         AcpiOsPrintf ("NotUsed");
    981                         break;
    982 
    983                     case ACPI_GPE_DISPATCH_METHOD:
    984 
    985                         AcpiOsPrintf ("Method");
    986                         break;
    987 
    988                     case ACPI_GPE_DISPATCH_HANDLER:
    989 
    990                         AcpiOsPrintf ("Handler");
    991                         break;
    992 
    993                     case ACPI_GPE_DISPATCH_NOTIFY:
    994 
    995                         Count = 0;
    996                         Notify = GpeEventInfo->Dispatch.NotifyList;
    997                         while (Notify)
    998                         {
    999                             Count++;
   1000                             Notify = Notify->Next;
   1001                         }
   1002 
   1003                         AcpiOsPrintf ("Implicit Notify on %u devices",
   1004                             Count);
   1005                         break;
   1006 
   1007                     case ACPI_GPE_DISPATCH_RAW_HANDLER:
   1008 
   1009                         AcpiOsPrintf ("RawHandler");
   1010                         break;
   1011 
   1012                     default:
   1013 
   1014                         AcpiOsPrintf ("UNKNOWN: %X",
   1015                             ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags));
   1016                         break;
   1017                     }
   1018 
   1019                     AcpiOsPrintf (")\n");
   1020                 }
   1021             }
   1022 
   1023             Block++;
   1024             GpeBlock = GpeBlock->Next;
   1025         }
   1026 
   1027         GpeXruptInfo = GpeXruptInfo->Next;
   1028     }
   1029 }
   1030 #endif /* !ACPI_REDUCED_HARDWARE */
   1031 
   1032 
   1033 /*******************************************************************************
   1034  *
   1035  * FUNCTION:    AcpiDbDisplayHandlers
   1036  *
   1037  * PARAMETERS:  None
   1038  *
   1039  * RETURN:      None
   1040  *
   1041  * DESCRIPTION: Display the currently installed global handlers
   1042  *
   1043  ******************************************************************************/
   1044 
   1045 void
   1046 AcpiDbDisplayHandlers (
   1047     void)
   1048 {
   1049     ACPI_OPERAND_OBJECT     *ObjDesc;
   1050     ACPI_OPERAND_OBJECT     *HandlerObj;
   1051     ACPI_ADR_SPACE_TYPE     SpaceId;
   1052     UINT32                  i;
   1053 
   1054 
   1055     /* Operation region handlers */
   1056 
   1057     AcpiOsPrintf ("\nOperation Region Handlers at the namespace root:\n");
   1058 
   1059     ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
   1060     if (ObjDesc)
   1061     {
   1062         for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++)
   1063         {
   1064             SpaceId = AcpiGbl_SpaceIdList[i];
   1065 
   1066             AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
   1067                 AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);
   1068 
   1069             HandlerObj = AcpiEvFindRegionHandler (
   1070                 SpaceId, ObjDesc->CommonNotify.Handler);
   1071             if (HandlerObj)
   1072             {
   1073                 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
   1074                     (HandlerObj->AddressSpace.HandlerFlags &
   1075                         ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?
   1076                         "Default" : "User",
   1077                     HandlerObj->AddressSpace.Handler);
   1078 
   1079                 goto FoundHandler;
   1080             }
   1081 
   1082             /* There is no handler for this SpaceId */
   1083 
   1084             AcpiOsPrintf ("None\n");
   1085 
   1086         FoundHandler:;
   1087         }
   1088 
   1089         /* Find all handlers for user-defined SpaceIDs */
   1090 
   1091         HandlerObj = ObjDesc->CommonNotify.Handler;
   1092         while (HandlerObj)
   1093         {
   1094             if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN)
   1095             {
   1096                 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
   1097                     "User-defined ID", HandlerObj->AddressSpace.SpaceId);
   1098                 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
   1099                     (HandlerObj->AddressSpace.HandlerFlags &
   1100                         ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?
   1101                         "Default" : "User",
   1102                     HandlerObj->AddressSpace.Handler);
   1103             }
   1104 
   1105             HandlerObj = HandlerObj->AddressSpace.Next;
   1106         }
   1107     }
   1108 
   1109 #if (!ACPI_REDUCED_HARDWARE)
   1110 
   1111     /* Fixed event handlers */
   1112 
   1113     AcpiOsPrintf ("\nFixed Event Handlers:\n");
   1114 
   1115     for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
   1116     {
   1117         AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i);
   1118         if (AcpiGbl_FixedEventHandlers[i].Handler)
   1119         {
   1120             AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
   1121                 AcpiGbl_FixedEventHandlers[i].Handler);
   1122         }
   1123         else
   1124         {
   1125             AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
   1126         }
   1127     }
   1128 
   1129 #endif /* !ACPI_REDUCED_HARDWARE */
   1130 
   1131     /* Miscellaneous global handlers */
   1132 
   1133     AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n");
   1134 
   1135     for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++)
   1136     {
   1137         AcpiOsPrintf (ACPI_HANDLER_NAME_STRING,
   1138             AcpiGbl_HandlerList[i].Name);
   1139 
   1140         if (AcpiGbl_HandlerList[i].Handler)
   1141         {
   1142             AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
   1143                 AcpiGbl_HandlerList[i].Handler);
   1144         }
   1145         else
   1146         {
   1147             AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
   1148         }
   1149     }
   1150 
   1151 
   1152     /* Other handlers that are installed throughout the namespace */
   1153 
   1154     AcpiOsPrintf ("\nOperation Region Handlers for specific devices:\n");
   1155 
   1156     (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
   1157         ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers,
   1158         NULL, NULL, NULL);
   1159 }
   1160 
   1161 
   1162 /*******************************************************************************
   1163  *
   1164  * FUNCTION:    AcpiDbDisplayNonRootHandlers
   1165  *
   1166  * PARAMETERS:  ACPI_WALK_CALLBACK
   1167  *
   1168  * RETURN:      Status
   1169  *
   1170  * DESCRIPTION: Display information about all handlers installed for a
   1171  *              device object.
   1172  *
   1173  ******************************************************************************/
   1174 
   1175 static ACPI_STATUS
   1176 AcpiDbDisplayNonRootHandlers (
   1177     ACPI_HANDLE             ObjHandle,
   1178     UINT32                  NestingLevel,
   1179     void                    *Context,
   1180     void                    **ReturnValue)
   1181 {
   1182     ACPI_NAMESPACE_NODE     *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
   1183     ACPI_OPERAND_OBJECT     *ObjDesc;
   1184     ACPI_OPERAND_OBJECT     *HandlerObj;
   1185     char                    *Pathname;
   1186 
   1187 
   1188     ObjDesc = AcpiNsGetAttachedObject (Node);
   1189     if (!ObjDesc)
   1190     {
   1191         return (AE_OK);
   1192     }
   1193 
   1194     Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
   1195     if (!Pathname)
   1196     {
   1197         return (AE_OK);
   1198     }
   1199 
   1200     /* Display all handlers associated with this device */
   1201 
   1202     HandlerObj = ObjDesc->CommonNotify.Handler;
   1203     while (HandlerObj)
   1204     {
   1205         AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
   1206             AcpiUtGetRegionName ((UINT8) HandlerObj->AddressSpace.SpaceId),
   1207             HandlerObj->AddressSpace.SpaceId);
   1208 
   1209         AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING2,
   1210             (HandlerObj->AddressSpace.HandlerFlags &
   1211                 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
   1212             HandlerObj->AddressSpace.Handler);
   1213 
   1214         AcpiOsPrintf (" Device Name: %s (%p)\n", Pathname, Node);
   1215 
   1216         HandlerObj = HandlerObj->AddressSpace.Next;
   1217     }
   1218 
   1219     ACPI_FREE (Pathname);
   1220     return (AE_OK);
   1221 }
   1222