167754Smsmith/*******************************************************************************
267754Smsmith *
367754Smsmith * Module Name: dbdisply - debug display commands
467754Smsmith *
567754Smsmith ******************************************************************************/
667754Smsmith
7217365Sjkim/*
8245582Sjkim * Copyright (C) 2000 - 2013, Intel Corp.
970243Smsmith * All rights reserved.
1067754Smsmith *
11217365Sjkim * Redistribution and use in source and binary forms, with or without
12217365Sjkim * modification, are permitted provided that the following conditions
13217365Sjkim * are met:
14217365Sjkim * 1. Redistributions of source code must retain the above copyright
15217365Sjkim *    notice, this list of conditions, and the following disclaimer,
16217365Sjkim *    without modification.
17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18217365Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
19217365Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
20217365Sjkim *    including a substantially similar Disclaimer requirement for further
21217365Sjkim *    binary redistribution.
22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
23217365Sjkim *    of any contributors may be used to endorse or promote products derived
24217365Sjkim *    from this software without specific prior written permission.
2567754Smsmith *
26217365Sjkim * Alternatively, this software may be distributed under the terms of the
27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
28217365Sjkim * Software Foundation.
2967754Smsmith *
30217365Sjkim * NO WARRANTY
31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41217365Sjkim * POSSIBILITY OF SUCH DAMAGES.
42217365Sjkim */
4367754Smsmith
4467754Smsmith
45193341Sjkim#include <contrib/dev/acpica/include/acpi.h>
46193341Sjkim#include <contrib/dev/acpica/include/accommon.h>
47193341Sjkim#include <contrib/dev/acpica/include/amlcode.h>
48193341Sjkim#include <contrib/dev/acpica/include/acdispat.h>
49193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h>
50193341Sjkim#include <contrib/dev/acpica/include/acparser.h>
51193341Sjkim#include <contrib/dev/acpica/include/acinterp.h>
52193341Sjkim#include <contrib/dev/acpica/include/acdebug.h>
53193341Sjkim#include <contrib/dev/acpica/include/acdisasm.h>
5467754Smsmith
5567754Smsmith
56102550Siwasaki#ifdef ACPI_DEBUGGER
5767754Smsmith
58102550Siwasaki#define _COMPONENT          ACPI_CA_DEBUGGER
5991116Smsmith        ACPI_MODULE_NAME    ("dbdisply")
6067754Smsmith
61151937Sjkim/* Local prototypes */
6267754Smsmith
63151937Sjkimstatic void
64151937SjkimAcpiDbDumpParserDescriptor (
65151937Sjkim    ACPI_PARSE_OBJECT       *Op);
66151937Sjkim
67151937Sjkimstatic void *
68151937SjkimAcpiDbGetPointer (
69151937Sjkim    void                    *Target);
70151937Sjkim
71249663Sjkimstatic ACPI_STATUS
72249663SjkimAcpiDbDisplayNonRootHandlers (
73249663Sjkim    ACPI_HANDLE             ObjHandle,
74249663Sjkim    UINT32                  NestingLevel,
75249663Sjkim    void                    *Context,
76249663Sjkim    void                    **ReturnValue);
77151937Sjkim
78220663Sjkim/*
79220663Sjkim * System handler information.
80220663Sjkim * Used for Handlers command, in AcpiDbDisplayHandlers.
81220663Sjkim */
82220663Sjkim#define ACPI_PREDEFINED_PREFIX          "%25s (%.2X) : "
83220663Sjkim#define ACPI_HANDLER_NAME_STRING               "%30s : "
84220663Sjkim#define ACPI_HANDLER_PRESENT_STRING                    "%-9s (%p)\n"
85249663Sjkim#define ACPI_HANDLER_PRESENT_STRING2                   "%-9s (%p)"
86220663Sjkim#define ACPI_HANDLER_NOT_PRESENT_STRING                "%-9s\n"
87220663Sjkim
88220663Sjkim/* All predefined Address Space IDs */
89220663Sjkim
90220663Sjkimstatic ACPI_ADR_SPACE_TYPE  AcpiGbl_SpaceIdList[] =
91220663Sjkim{
92220663Sjkim    ACPI_ADR_SPACE_SYSTEM_MEMORY,
93220663Sjkim    ACPI_ADR_SPACE_SYSTEM_IO,
94220663Sjkim    ACPI_ADR_SPACE_PCI_CONFIG,
95220663Sjkim    ACPI_ADR_SPACE_EC,
96220663Sjkim    ACPI_ADR_SPACE_SMBUS,
97220663Sjkim    ACPI_ADR_SPACE_CMOS,
98220663Sjkim    ACPI_ADR_SPACE_PCI_BAR_TARGET,
99220663Sjkim    ACPI_ADR_SPACE_IPMI,
100228110Sjkim    ACPI_ADR_SPACE_GPIO,
101228110Sjkim    ACPI_ADR_SPACE_GSBUS,
102220663Sjkim    ACPI_ADR_SPACE_DATA_TABLE,
103220663Sjkim    ACPI_ADR_SPACE_FIXED_HARDWARE
104220663Sjkim};
105220663Sjkim
106220663Sjkim/* Global handler information */
107220663Sjkim
108220663Sjkimtypedef struct acpi_handler_info
109220663Sjkim{
110220663Sjkim    void                    *Handler;
111220663Sjkim    char                    *Name;
112220663Sjkim
113220663Sjkim} ACPI_HANDLER_INFO;
114220663Sjkim
115220663Sjkimstatic ACPI_HANDLER_INFO    AcpiGbl_HandlerList[] =
116220663Sjkim{
117234623Sjkim    {&AcpiGbl_GlobalNotify[0].Handler,  "System Notifications"},
118234623Sjkim    {&AcpiGbl_GlobalNotify[1].Handler,  "Device Notifications"},
119220663Sjkim    {&AcpiGbl_TableHandler,             "ACPI Table Events"},
120220663Sjkim    {&AcpiGbl_ExceptionHandler,         "Control Method Exceptions"},
121220663Sjkim    {&AcpiGbl_InterfaceHandler,         "OSI Invocations"}
122220663Sjkim};
123220663Sjkim
124220663Sjkim
125151937Sjkim/*******************************************************************************
12667754Smsmith *
12767754Smsmith * FUNCTION:    AcpiDbGetPointer
12867754Smsmith *
12967754Smsmith * PARAMETERS:  Target          - Pointer to string to be converted
13067754Smsmith *
13167754Smsmith * RETURN:      Converted pointer
13267754Smsmith *
13367754Smsmith * DESCRIPTION: Convert an ascii pointer value to a real value
13467754Smsmith *
135151937Sjkim ******************************************************************************/
13667754Smsmith
137151937Sjkimstatic void *
13867754SmsmithAcpiDbGetPointer (
13967754Smsmith    void                    *Target)
14067754Smsmith{
14167754Smsmith    void                    *ObjPtr;
142252279Sjkim    ACPI_SIZE               Address;
14367754Smsmith
14467754Smsmith
145252279Sjkim    Address = ACPI_STRTOUL (Target, NULL, 16);
146252279Sjkim    ObjPtr = ACPI_TO_POINTER (Address);
14767754Smsmith    return (ObjPtr);
14867754Smsmith}
14967754Smsmith
15067754Smsmith
15167754Smsmith/*******************************************************************************
15267754Smsmith *
15367754Smsmith * FUNCTION:    AcpiDbDumpParserDescriptor
15467754Smsmith *
15567754Smsmith * PARAMETERS:  Op              - A parser Op descriptor
15667754Smsmith *
15767754Smsmith * RETURN:      None
15867754Smsmith *
15967754Smsmith * DESCRIPTION: Display a formatted parser object
16067754Smsmith *
16167754Smsmith ******************************************************************************/
16267754Smsmith
163151937Sjkimstatic void
16467754SmsmithAcpiDbDumpParserDescriptor (
16567754Smsmith    ACPI_PARSE_OBJECT       *Op)
16667754Smsmith{
16783174Smsmith    const ACPI_OPCODE_INFO  *Info;
16867754Smsmith
16967754Smsmith
17099679Siwasaki    Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
17167754Smsmith
17267754Smsmith    AcpiOsPrintf ("Parser Op Descriptor:\n");
17399679Siwasaki    AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode);
17467754Smsmith
175151937Sjkim    ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name",
176151937Sjkim        Info->Name));
17767754Smsmith
17899679Siwasaki    AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg);
17999679Siwasaki    AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent);
18099679Siwasaki    AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next);
18167754Smsmith}
18267754Smsmith
18367754Smsmith
18467754Smsmith/*******************************************************************************
18567754Smsmith *
18667754Smsmith * FUNCTION:    AcpiDbDecodeAndDisplayObject
18767754Smsmith *
188241973Sjkim * PARAMETERS:  Target          - String with object to be displayed. Names
18967754Smsmith *                                and hex pointers are supported.
19067754Smsmith *              OutputType      - Byte, Word, Dword, or Qword (B|W|D|Q)
19167754Smsmith *
19267754Smsmith * RETURN:      None
19367754Smsmith *
19467754Smsmith * DESCRIPTION: Display a formatted ACPI object
19567754Smsmith *
19667754Smsmith ******************************************************************************/
19767754Smsmith
19867754Smsmithvoid
19967754SmsmithAcpiDbDecodeAndDisplayObject (
200114237Snjl    char                    *Target,
201114237Snjl    char                    *OutputType)
20267754Smsmith{
20367754Smsmith    void                    *ObjPtr;
20467754Smsmith    ACPI_NAMESPACE_NODE     *Node;
20587031Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
20667754Smsmith    UINT32                  Display = DB_BYTE_DISPLAY;
207114237Snjl    char                    Buffer[80];
20867754Smsmith    ACPI_BUFFER             RetBuf;
20967754Smsmith    ACPI_STATUS             Status;
21067754Smsmith    UINT32                  Size;
21167754Smsmith
21267754Smsmith
21367754Smsmith    if (!Target)
21467754Smsmith    {
21567754Smsmith        return;
21667754Smsmith    }
21767754Smsmith
21867754Smsmith    /* Decode the output type */
21967754Smsmith
22067754Smsmith    if (OutputType)
22167754Smsmith    {
222151937Sjkim        AcpiUtStrupr (OutputType);
22367754Smsmith        if (OutputType[0] == 'W')
22467754Smsmith        {
22567754Smsmith            Display = DB_WORD_DISPLAY;
22667754Smsmith        }
22767754Smsmith        else if (OutputType[0] == 'D')
22867754Smsmith        {
22967754Smsmith            Display = DB_DWORD_DISPLAY;
23067754Smsmith        }
23167754Smsmith        else if (OutputType[0] == 'Q')
23267754Smsmith        {
23367754Smsmith            Display = DB_QWORD_DISPLAY;
23467754Smsmith        }
23567754Smsmith    }
23667754Smsmith
23767754Smsmith    RetBuf.Length = sizeof (Buffer);
23867754Smsmith    RetBuf.Pointer = Buffer;
23967754Smsmith
24067754Smsmith    /* Differentiate between a number and a name */
24167754Smsmith
24267754Smsmith    if ((Target[0] >= 0x30) && (Target[0] <= 0x39))
24367754Smsmith    {
24467754Smsmith        ObjPtr = AcpiDbGetPointer (Target);
24567754Smsmith        if (!AcpiOsReadable (ObjPtr, 16))
24667754Smsmith        {
247151937Sjkim            AcpiOsPrintf ("Address %p is invalid in this address space\n",
248151937Sjkim                ObjPtr);
24967754Smsmith            return;
25067754Smsmith        }
25167754Smsmith
25267754Smsmith        /* Decode the object type */
25367754Smsmith
25491116Smsmith        switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr))
25567754Smsmith        {
25691116Smsmith        case ACPI_DESC_TYPE_NAMED:
25767754Smsmith
25891116Smsmith            /* This is a namespace Node */
25991116Smsmith
26067754Smsmith            if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE)))
26167754Smsmith            {
262151937Sjkim                AcpiOsPrintf (
263151937Sjkim                    "Cannot read entire Named object at address %p\n", ObjPtr);
26467754Smsmith                return;
26567754Smsmith            }
26667754Smsmith
26767754Smsmith            Node = ObjPtr;
268151937Sjkim            goto DumpNode;
26967754Smsmith
27099679Siwasaki        case ACPI_DESC_TYPE_OPERAND:
27191116Smsmith
27291116Smsmith            /* This is a ACPI OPERAND OBJECT */
27391116Smsmith
27467754Smsmith            if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT)))
27567754Smsmith            {
276151937Sjkim                AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n",
277151937Sjkim                    ObjPtr);
27867754Smsmith                return;
27967754Smsmith            }
28067754Smsmith
281241973Sjkim            AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display,
282151937Sjkim                ACPI_UINT32_MAX);
28377424Smsmith            AcpiExDumpObjectDescriptor (ObjPtr, 1);
28491116Smsmith            break;
28567754Smsmith
28691116Smsmith        case ACPI_DESC_TYPE_PARSER:
28791116Smsmith
28891116Smsmith            /* This is a Parser Op object */
28991116Smsmith
29067754Smsmith            if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT)))
29167754Smsmith            {
292151937Sjkim                AcpiOsPrintf (
293151937Sjkim                    "Cannot read entire Parser object at address %p\n", ObjPtr);
29467754Smsmith                return;
29567754Smsmith            }
29667754Smsmith
297241973Sjkim            AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display,
298151937Sjkim                ACPI_UINT32_MAX);
29967754Smsmith            AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr);
30091116Smsmith            break;
30167754Smsmith
30291116Smsmith        default:
30391116Smsmith
30491116Smsmith            /* Is not a recognizeable object */
30591116Smsmith
30667754Smsmith            Size = 16;
30767754Smsmith            if (AcpiOsReadable (ObjPtr, 64))
30867754Smsmith            {
30967754Smsmith                Size = 64;
31067754Smsmith            }
31167754Smsmith
31267754Smsmith            /* Just dump some memory */
31367754Smsmith
314241973Sjkim            AcpiUtDebugDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX);
31591116Smsmith            break;
31667754Smsmith        }
31767754Smsmith
31867754Smsmith        return;
31967754Smsmith    }
32067754Smsmith
32167754Smsmith    /* The parameter is a name string that must be resolved to a Named obj */
32267754Smsmith
32367754Smsmith    Node = AcpiDbLocalNsLookup (Target);
32467754Smsmith    if (!Node)
32567754Smsmith    {
32667754Smsmith        return;
32767754Smsmith    }
32867754Smsmith
32967754Smsmith
330151937SjkimDumpNode:
331151937Sjkim    /* Now dump the NS node */
33267754Smsmith
33367754Smsmith    Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf);
33467754Smsmith    if (ACPI_FAILURE (Status))
33567754Smsmith    {
33667754Smsmith        AcpiOsPrintf ("Could not convert name to pathname\n");
33767754Smsmith    }
33867754Smsmith
33969746Smsmith    else
34069746Smsmith    {
341151937Sjkim        AcpiOsPrintf ("Object (%p) Pathname:  %s\n",
342151937Sjkim            Node, (char *) RetBuf.Pointer);
34369746Smsmith    }
34469746Smsmith
34567754Smsmith    if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
34667754Smsmith    {
34767754Smsmith        AcpiOsPrintf ("Invalid Named object at address %p\n", Node);
34867754Smsmith        return;
34967754Smsmith    }
35067754Smsmith
351241973Sjkim    AcpiUtDebugDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE),
352151937Sjkim        Display, ACPI_UINT32_MAX);
353167802Sjkim    AcpiExDumpNamespaceNode (Node, 1);
35467754Smsmith
35587031Smsmith    ObjDesc = AcpiNsGetAttachedObject (Node);
35687031Smsmith    if (ObjDesc)
35767754Smsmith    {
35887031Smsmith        AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc);
35987031Smsmith        if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)))
36067754Smsmith        {
361151937Sjkim            AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n",
362151937Sjkim                ObjDesc);
36367754Smsmith            return;
36467754Smsmith        }
36567754Smsmith
366241973Sjkim        AcpiUtDebugDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT),
367151937Sjkim            Display, ACPI_UINT32_MAX);
36887031Smsmith        AcpiExDumpObjectDescriptor (ObjDesc, 1);
36967754Smsmith    }
37067754Smsmith}
37167754Smsmith
37267754Smsmith
37367754Smsmith/*******************************************************************************
37467754Smsmith *
37567754Smsmith * FUNCTION:    AcpiDbDisplayMethodInfo
37667754Smsmith *
37767754Smsmith * PARAMETERS:  StartOp         - Root of the control method parse tree
37867754Smsmith *
37967754Smsmith * RETURN:      None
38067754Smsmith *
38167754Smsmith * DESCRIPTION: Display information about the current method
38267754Smsmith *
38367754Smsmith ******************************************************************************/
38467754Smsmith
38567754Smsmithvoid
38667754SmsmithAcpiDbDisplayMethodInfo (
38767754Smsmith    ACPI_PARSE_OBJECT       *StartOp)
38867754Smsmith{
38967754Smsmith    ACPI_WALK_STATE         *WalkState;
39067754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
39167754Smsmith    ACPI_NAMESPACE_NODE     *Node;
39267754Smsmith    ACPI_PARSE_OBJECT       *RootOp;
39367754Smsmith    ACPI_PARSE_OBJECT       *Op;
39483174Smsmith    const ACPI_OPCODE_INFO  *OpInfo;
39567754Smsmith    UINT32                  NumOps = 0;
39667754Smsmith    UINT32                  NumOperands = 0;
39767754Smsmith    UINT32                  NumOperators = 0;
39867754Smsmith    UINT32                  NumRemainingOps = 0;
39967754Smsmith    UINT32                  NumRemainingOperands = 0;
40067754Smsmith    UINT32                  NumRemainingOperators = 0;
40167754Smsmith    BOOLEAN                 CountRemaining = FALSE;
40267754Smsmith
40367754Smsmith
40467754Smsmith    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
40567754Smsmith    if (!WalkState)
40667754Smsmith    {
40767754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
40867754Smsmith        return;
40967754Smsmith    }
41067754Smsmith
41167754Smsmith    ObjDesc = WalkState->MethodDesc;
41287031Smsmith    Node    = WalkState->MethodNode;
41367754Smsmith
414123315Snjl    AcpiOsPrintf ("Currently executing control method is [%4.4s]\n",
415123315Snjl            AcpiUtGetNodeName (Node));
416167802Sjkim    AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n",
417167802Sjkim            (UINT32) ObjDesc->Method.ParamCount,
418167802Sjkim            (UINT32) ObjDesc->Method.SyncLevel);
41967754Smsmith
42067754Smsmith
42167754Smsmith    RootOp = StartOp;
42299679Siwasaki    while (RootOp->Common.Parent)
42367754Smsmith    {
42499679Siwasaki        RootOp = RootOp->Common.Parent;
42567754Smsmith    }
42667754Smsmith
42767754Smsmith    Op = RootOp;
42867754Smsmith
42967754Smsmith    while (Op)
43067754Smsmith    {
43167754Smsmith        if (Op == StartOp)
43267754Smsmith        {
43367754Smsmith            CountRemaining = TRUE;
43467754Smsmith        }
43567754Smsmith
43667754Smsmith        NumOps++;
43767754Smsmith        if (CountRemaining)
43867754Smsmith        {
43967754Smsmith            NumRemainingOps++;
44067754Smsmith        }
44167754Smsmith
44267754Smsmith        /* Decode the opcode */
44367754Smsmith
44499679Siwasaki        OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
44585756Smsmith        switch (OpInfo->Class)
44667754Smsmith        {
44785756Smsmith        case AML_CLASS_ARGUMENT:
448250838Sjkim
44967754Smsmith            if (CountRemaining)
45067754Smsmith            {
45167754Smsmith                NumRemainingOperands++;
45267754Smsmith            }
45367754Smsmith
45467754Smsmith            NumOperands++;
45567754Smsmith            break;
45667754Smsmith
45785756Smsmith        case AML_CLASS_UNKNOWN:
458250838Sjkim
45985756Smsmith            /* Bad opcode or ASCII character */
46085756Smsmith
46185756Smsmith            continue;
46285756Smsmith
46367754Smsmith        default:
464250838Sjkim
46567754Smsmith            if (CountRemaining)
46667754Smsmith            {
46767754Smsmith                NumRemainingOperators++;
46867754Smsmith            }
46967754Smsmith
47067754Smsmith            NumOperators++;
47167754Smsmith            break;
47267754Smsmith        }
47367754Smsmith
47467754Smsmith        Op = AcpiPsGetDepthNext (StartOp, Op);
47567754Smsmith    }
47667754Smsmith
477151937Sjkim    AcpiOsPrintf (
478151937Sjkim        "Method contains:       %X AML Opcodes - %X Operators, %X Operands\n",
479151937Sjkim        NumOps, NumOperators, NumOperands);
48067754Smsmith
481151937Sjkim    AcpiOsPrintf (
482151937Sjkim        "Remaining to execute:  %X AML Opcodes - %X Operators, %X Operands\n",
483151937Sjkim        NumRemainingOps, NumRemainingOperators, NumRemainingOperands);
48467754Smsmith}
48567754Smsmith
48667754Smsmith
48767754Smsmith/*******************************************************************************
48867754Smsmith *
48967754Smsmith * FUNCTION:    AcpiDbDisplayLocals
49067754Smsmith *
49167754Smsmith * PARAMETERS:  None
49267754Smsmith *
49367754Smsmith * RETURN:      None
49467754Smsmith *
49567754Smsmith * DESCRIPTION: Display all locals for the currently running control method
49667754Smsmith *
49767754Smsmith ******************************************************************************/
49867754Smsmith
49967754Smsmithvoid
500151937SjkimAcpiDbDisplayLocals (
501151937Sjkim    void)
50267754Smsmith{
50367754Smsmith    ACPI_WALK_STATE         *WalkState;
50467754Smsmith
50567754Smsmith
50667754Smsmith    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
50767754Smsmith    if (!WalkState)
50867754Smsmith    {
50967754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
51067754Smsmith        return;
51167754Smsmith    }
51267754Smsmith
513117521Snjl    AcpiDmDisplayLocals (WalkState);
51467754Smsmith}
51567754Smsmith
51667754Smsmith
51767754Smsmith/*******************************************************************************
51867754Smsmith *
51967754Smsmith * FUNCTION:    AcpiDbDisplayArguments
52067754Smsmith *
52167754Smsmith * PARAMETERS:  None
52267754Smsmith *
52367754Smsmith * RETURN:      None
52467754Smsmith *
52567754Smsmith * DESCRIPTION: Display all arguments for the currently running control method
52667754Smsmith *
52767754Smsmith ******************************************************************************/
52867754Smsmith
52967754Smsmithvoid
530151937SjkimAcpiDbDisplayArguments (
531151937Sjkim    void)
53267754Smsmith{
53367754Smsmith    ACPI_WALK_STATE         *WalkState;
53467754Smsmith
53567754Smsmith
53667754Smsmith    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
53767754Smsmith    if (!WalkState)
53867754Smsmith    {
53967754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
54067754Smsmith        return;
54167754Smsmith    }
54267754Smsmith
543117521Snjl    AcpiDmDisplayArguments (WalkState);
54467754Smsmith}
54567754Smsmith
54667754Smsmith
54767754Smsmith/*******************************************************************************
54867754Smsmith *
54967754Smsmith * FUNCTION:    AcpiDbDisplayResults
55067754Smsmith *
55167754Smsmith * PARAMETERS:  None
55267754Smsmith *
55367754Smsmith * RETURN:      None
55467754Smsmith *
55567754Smsmith * DESCRIPTION: Display current contents of a method result stack
55667754Smsmith *
55767754Smsmith ******************************************************************************/
55867754Smsmith
55967754Smsmithvoid
560151937SjkimAcpiDbDisplayResults (
561151937Sjkim    void)
56267754Smsmith{
56367754Smsmith    UINT32                  i;
56467754Smsmith    ACPI_WALK_STATE         *WalkState;
56567754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
566167802Sjkim    UINT32                  ResultCount = 0;
56767754Smsmith    ACPI_NAMESPACE_NODE     *Node;
568167802Sjkim    ACPI_GENERIC_STATE      *Frame;
569167802Sjkim    UINT32                  Index; /* Index onto current frame */
57067754Smsmith
57167754Smsmith
57267754Smsmith    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
57367754Smsmith    if (!WalkState)
57467754Smsmith    {
57567754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
57667754Smsmith        return;
57767754Smsmith    }
57867754Smsmith
57967754Smsmith    ObjDesc = WalkState->MethodDesc;
580123315Snjl    Node    = WalkState->MethodNode;
58167754Smsmith
58269746Smsmith    if (WalkState->Results)
58369746Smsmith    {
584167802Sjkim        ResultCount = WalkState->ResultCount;
58569746Smsmith    }
58667754Smsmith
58787031Smsmith    AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
588167802Sjkim            AcpiUtGetNodeName (Node), ResultCount);
58969746Smsmith
590167802Sjkim    /* From the top element of result stack */
591167802Sjkim
592167802Sjkim    Frame = WalkState->Results;
593167802Sjkim    Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
594167802Sjkim
595167802Sjkim    for (i = 0; i < ResultCount; i++)
59667754Smsmith    {
597167802Sjkim        ObjDesc = Frame->Results.ObjDesc[Index];
598209746Sjkim        AcpiOsPrintf ("Result%u: ", i);
599117521Snjl        AcpiDmDisplayInternalObject (ObjDesc, WalkState);
600167802Sjkim        if (Index == 0)
601167802Sjkim        {
602167802Sjkim            Frame = Frame->Results.Next;
603167802Sjkim            Index = ACPI_RESULTS_FRAME_OBJ_NUM;
604167802Sjkim        }
605167802Sjkim        Index--;
60667754Smsmith    }
60767754Smsmith}
60867754Smsmith
60967754Smsmith
61067754Smsmith/*******************************************************************************
61167754Smsmith *
61267754Smsmith * FUNCTION:    AcpiDbDisplayCallingTree
61367754Smsmith *
61467754Smsmith * PARAMETERS:  None
61567754Smsmith *
61667754Smsmith * RETURN:      None
61767754Smsmith *
61867754Smsmith * DESCRIPTION: Display current calling tree of nested control methods
61967754Smsmith *
62067754Smsmith ******************************************************************************/
62167754Smsmith
62267754Smsmithvoid
623151937SjkimAcpiDbDisplayCallingTree (
624151937Sjkim    void)
62567754Smsmith{
62667754Smsmith    ACPI_WALK_STATE         *WalkState;
62767754Smsmith    ACPI_NAMESPACE_NODE     *Node;
62867754Smsmith
62967754Smsmith
63067754Smsmith    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
63167754Smsmith    if (!WalkState)
63267754Smsmith    {
63367754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
63467754Smsmith        return;
63567754Smsmith    }
63667754Smsmith
63769450Smsmith    Node = WalkState->MethodNode;
63867754Smsmith    AcpiOsPrintf ("Current Control Method Call Tree\n");
63967754Smsmith
64099679Siwasaki    while (WalkState)
64167754Smsmith    {
64269450Smsmith        Node = WalkState->MethodNode;
64367754Smsmith
644123315Snjl        AcpiOsPrintf ("    [%4.4s]\n", AcpiUtGetNodeName (Node));
64567754Smsmith
64667754Smsmith        WalkState = WalkState->Next;
64767754Smsmith    }
64867754Smsmith}
64967754Smsmith
65067754Smsmith
65167754Smsmith/*******************************************************************************
65267754Smsmith *
653117521Snjl * FUNCTION:    AcpiDbDisplayObjectType
654117521Snjl *
655241973Sjkim * PARAMETERS:  Name            - User entered NS node handle or name
656117521Snjl *
657117521Snjl * RETURN:      None
658117521Snjl *
659123315Snjl * DESCRIPTION: Display type of an arbitrary NS node
660117521Snjl *
661117521Snjl ******************************************************************************/
662117521Snjl
663117521Snjlvoid
664117521SnjlAcpiDbDisplayObjectType (
665241973Sjkim    char                    *Name)
666117521Snjl{
667241973Sjkim    ACPI_NAMESPACE_NODE     *Node;
668117521Snjl    ACPI_DEVICE_INFO        *Info;
669117521Snjl    ACPI_STATUS             Status;
670193267Sjkim    UINT32                  i;
671117521Snjl
672117521Snjl
673241973Sjkim    Node = AcpiDbConvertToNode (Name);
674241973Sjkim    if (!Node)
675241973Sjkim    {
676241973Sjkim        return;
677241973Sjkim    }
678117521Snjl
679241973Sjkim    Status = AcpiGetObjectInfo (ACPI_CAST_PTR (ACPI_HANDLE, Node), &Info);
680197104Sjkim    if (ACPI_FAILURE (Status))
681117521Snjl    {
682197104Sjkim        AcpiOsPrintf ("Could not get object info, %s\n",
683197104Sjkim            AcpiFormatException (Status));
684197104Sjkim        return;
685197104Sjkim    }
686117521Snjl
687241973Sjkim    if (Info->Valid & ACPI_VALID_ADR)
688241973Sjkim    {
689241973Sjkim        AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n",
690241973Sjkim            ACPI_FORMAT_UINT64 (Info->Address),
691241973Sjkim            Info->CurrentStatus, Info->Flags);
692241973Sjkim    }
693241973Sjkim    if (Info->Valid & ACPI_VALID_SXDS)
694241973Sjkim    {
695241973Sjkim        AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
696241973Sjkim            Info->HighestDstates[0], Info->HighestDstates[1],
697241973Sjkim            Info->HighestDstates[2], Info->HighestDstates[3]);
698241973Sjkim    }
699241973Sjkim    if (Info->Valid & ACPI_VALID_SXWS)
700241973Sjkim    {
701241973Sjkim        AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
702241973Sjkim            Info->LowestDstates[0], Info->LowestDstates[1],
703241973Sjkim            Info->LowestDstates[2], Info->LowestDstates[3],
704241973Sjkim            Info->LowestDstates[4]);
705241973Sjkim    }
706117521Snjl
707197104Sjkim    if (Info->Valid & ACPI_VALID_HID)
708197104Sjkim    {
709197104Sjkim        AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String);
710117521Snjl    }
711197104Sjkim    if (Info->Valid & ACPI_VALID_UID)
712117521Snjl    {
713197104Sjkim        AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String);
714117521Snjl    }
715241973Sjkim    if (Info->Valid & ACPI_VALID_SUB)
716241973Sjkim    {
717241973Sjkim        AcpiOsPrintf ("SUB: %s\n", Info->SubsystemId.String);
718241973Sjkim    }
719197104Sjkim    if (Info->Valid & ACPI_VALID_CID)
720197104Sjkim    {
721197104Sjkim        for (i = 0; i < Info->CompatibleIdList.Count; i++)
722197104Sjkim        {
723209746Sjkim            AcpiOsPrintf ("CID %u: %s\n", i,
724197104Sjkim                Info->CompatibleIdList.Ids[i].String);
725197104Sjkim        }
726197104Sjkim    }
727197104Sjkim
728197104Sjkim    ACPI_FREE (Info);
729117521Snjl}
730117521Snjl
731117521Snjl
732117521Snjl/*******************************************************************************
733117521Snjl *
73467754Smsmith * FUNCTION:    AcpiDbDisplayResultObject
73567754Smsmith *
73667754Smsmith * PARAMETERS:  ObjDesc         - Object to be displayed
73767754Smsmith *              WalkState       - Current walk state
73867754Smsmith *
73967754Smsmith * RETURN:      None
74067754Smsmith *
74167754Smsmith * DESCRIPTION: Display the result of an AML opcode
74267754Smsmith *
74391116Smsmith * Note: Curently only displays the result object if we are single stepping.
74491116Smsmith * However, this output may be useful in other contexts and could be enabled
74591116Smsmith * to do so if needed.
74691116Smsmith *
74767754Smsmith ******************************************************************************/
74867754Smsmith
74967754Smsmithvoid
75067754SmsmithAcpiDbDisplayResultObject (
75167754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc,
75267754Smsmith    ACPI_WALK_STATE         *WalkState)
75367754Smsmith{
75467754Smsmith
75591116Smsmith    /* Only display if single stepping */
75691116Smsmith
75767754Smsmith    if (!AcpiGbl_CmSingleStep)
75867754Smsmith    {
75967754Smsmith        return;
76067754Smsmith    }
76167754Smsmith
76267754Smsmith    AcpiOsPrintf ("ResultObj: ");
763117521Snjl    AcpiDmDisplayInternalObject (ObjDesc, WalkState);
76467754Smsmith    AcpiOsPrintf ("\n");
76567754Smsmith}
76667754Smsmith
76767754Smsmith
76867754Smsmith/*******************************************************************************
76967754Smsmith *
77067754Smsmith * FUNCTION:    AcpiDbDisplayArgumentObject
77167754Smsmith *
77267754Smsmith * PARAMETERS:  ObjDesc         - Object to be displayed
77367754Smsmith *              WalkState       - Current walk state
77467754Smsmith *
77567754Smsmith * RETURN:      None
77667754Smsmith *
77767754Smsmith * DESCRIPTION: Display the result of an AML opcode
77867754Smsmith *
77967754Smsmith ******************************************************************************/
78067754Smsmith
78167754Smsmithvoid
78267754SmsmithAcpiDbDisplayArgumentObject (
78367754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc,
78467754Smsmith    ACPI_WALK_STATE         *WalkState)
78567754Smsmith{
78667754Smsmith
78767754Smsmith    if (!AcpiGbl_CmSingleStep)
78867754Smsmith    {
78967754Smsmith        return;
79067754Smsmith    }
79167754Smsmith
79267754Smsmith    AcpiOsPrintf ("ArgObj:    ");
793117521Snjl    AcpiDmDisplayInternalObject (ObjDesc, WalkState);
79467754Smsmith}
79567754Smsmith
796114237Snjl
797231844Sjkim#if (!ACPI_REDUCED_HARDWARE)
798114237Snjl/*******************************************************************************
799114237Snjl *
800114237Snjl * FUNCTION:    AcpiDbDisplayGpes
801114237Snjl *
802123315Snjl * PARAMETERS:  None
803114237Snjl *
804114237Snjl * RETURN:      None
805114237Snjl *
806123315Snjl * DESCRIPTION: Display the current GPE structures
807114237Snjl *
808114237Snjl ******************************************************************************/
809114237Snjl
810114237Snjlvoid
811151937SjkimAcpiDbDisplayGpes (
812151937Sjkim    void)
813114237Snjl{
814114237Snjl    ACPI_GPE_BLOCK_INFO     *GpeBlock;
815117521Snjl    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo;
816129684Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
817129684Snjl    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
818207344Sjkim    char                    *GpeType;
819237412Sjkim    ACPI_GPE_NOTIFY_INFO    *Notify;
820129684Snjl    UINT32                  GpeIndex;
821129684Snjl    UINT32                  Block = 0;
822129684Snjl    UINT32                  i;
823129684Snjl    UINT32                  j;
824237412Sjkim    UINT32                  Count;
825129684Snjl    char                    Buffer[80];
826129684Snjl    ACPI_BUFFER             RetBuf;
827129684Snjl    ACPI_STATUS             Status;
828114237Snjl
829114237Snjl
830129684Snjl    RetBuf.Length = sizeof (Buffer);
831129684Snjl    RetBuf.Pointer = Buffer;
832129684Snjl
833129684Snjl    Block = 0;
834129684Snjl
835129684Snjl    /* Walk the GPE lists */
836129684Snjl
837117521Snjl    GpeXruptInfo = AcpiGbl_GpeXruptListHead;
838117521Snjl    while (GpeXruptInfo)
839114237Snjl    {
840117521Snjl        GpeBlock = GpeXruptInfo->GpeBlockListHead;
841117521Snjl        while (GpeBlock)
842117521Snjl        {
843129684Snjl            Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf);
844129684Snjl            if (ACPI_FAILURE (Status))
845129684Snjl            {
846129684Snjl                AcpiOsPrintf ("Could not convert name to pathname\n");
847129684Snjl            }
848129684Snjl
849207344Sjkim            if (GpeBlock->Node == AcpiGbl_FadtGpeDevice)
850207344Sjkim            {
851207344Sjkim                GpeType = "FADT-defined GPE block";
852207344Sjkim            }
853207344Sjkim            else
854207344Sjkim            {
855207344Sjkim                GpeType = "GPE Block Device";
856207344Sjkim            }
857151937Sjkim
858209746Sjkim            AcpiOsPrintf ("\nBlock %u - Info %p  DeviceNode %p [%s] - %s\n",
859207344Sjkim                Block, GpeBlock, GpeBlock->Node, Buffer, GpeType);
860207344Sjkim
861151937Sjkim            AcpiOsPrintf ("    Registers:    %u (%u GPEs)\n",
862206117Sjkim                GpeBlock->RegisterCount, GpeBlock->GpeCount);
863151937Sjkim
864206117Sjkim            AcpiOsPrintf ("    GPE range:    0x%X to 0x%X on interrupt %u\n",
865151937Sjkim                GpeBlock->BlockBaseNumber,
866206117Sjkim                GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1),
867206117Sjkim                GpeXruptInfo->InterruptNumber);
868151937Sjkim
869151937Sjkim            AcpiOsPrintf (
870151937Sjkim                "    RegisterInfo: %p  Status %8.8X%8.8X Enable %8.8X%8.8X\n",
871151937Sjkim                GpeBlock->RegisterInfo,
872167802Sjkim                ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address),
873167802Sjkim                ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address));
874151937Sjkim
875117521Snjl            AcpiOsPrintf ("    EventInfo:    %p\n", GpeBlock->EventInfo);
876114237Snjl
877129684Snjl            /* Examine each GPE Register within the block */
878129684Snjl
879129684Snjl            for (i = 0; i < GpeBlock->RegisterCount; i++)
880129684Snjl            {
881129684Snjl                GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
882129684Snjl
883129684Snjl                AcpiOsPrintf (
884206117Sjkim                    "    Reg %u: (GPE %.2X-%.2X)  RunEnable %2.2X WakeEnable %2.2X"
885206117Sjkim                    " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
886206117Sjkim                    i, GpeRegisterInfo->BaseGpeNumber,
887206117Sjkim                    GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1),
888151937Sjkim                    GpeRegisterInfo->EnableForRun,
889206117Sjkim                    GpeRegisterInfo->EnableForWake,
890167802Sjkim                    ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address),
891167802Sjkim                    ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address));
892129684Snjl
893129684Snjl                /* Now look at the individual GPEs in this byte register */
894129684Snjl
895129684Snjl                for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
896129684Snjl                {
897129684Snjl                    GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;
898129684Snjl                    GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];
899129684Snjl
900216471Sjkim                    if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
901216471Sjkim                        ACPI_GPE_DISPATCH_NONE)
902129684Snjl                    {
903206117Sjkim                        /* This GPE is not used (no method or handler), ignore it */
904129684Snjl
905129684Snjl                        continue;
906129684Snjl                    }
907129684Snjl
908129684Snjl                    AcpiOsPrintf (
909209746Sjkim                        "        GPE %.2X: %p  RunRefs %2.2X Flags %2.2X (",
910206117Sjkim                        GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo,
911216471Sjkim                        GpeEventInfo->RuntimeCount, GpeEventInfo->Flags);
912129684Snjl
913206117Sjkim                    /* Decode the flags byte */
914206117Sjkim
915129684Snjl                    if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED)
916129684Snjl                    {
917129684Snjl                        AcpiOsPrintf ("Level, ");
918129684Snjl                    }
919129684Snjl                    else
920129684Snjl                    {
921129684Snjl                        AcpiOsPrintf ("Edge,  ");
922129684Snjl                    }
923129684Snjl
924206117Sjkim                    if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)
925129684Snjl                    {
926206117Sjkim                        AcpiOsPrintf ("CanWake, ");
927129684Snjl                    }
928129684Snjl                    else
929129684Snjl                    {
930206117Sjkim                        AcpiOsPrintf ("RunOnly, ");
931129684Snjl                    }
932129684Snjl
933129684Snjl                    switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
934129684Snjl                    {
935216471Sjkim                    case ACPI_GPE_DISPATCH_NONE:
936250838Sjkim
937129684Snjl                        AcpiOsPrintf ("NotUsed");
938129684Snjl                        break;
939250838Sjkim
940216471Sjkim                    case ACPI_GPE_DISPATCH_METHOD:
941250838Sjkim
942216471Sjkim                        AcpiOsPrintf ("Method");
943216471Sjkim                        break;
944129684Snjl                    case ACPI_GPE_DISPATCH_HANDLER:
945250838Sjkim
946129684Snjl                        AcpiOsPrintf ("Handler");
947129684Snjl                        break;
948250838Sjkim
949216471Sjkim                    case ACPI_GPE_DISPATCH_NOTIFY:
950250838Sjkim
951237412Sjkim                        Count = 0;
952237412Sjkim                        Notify = GpeEventInfo->Dispatch.NotifyList;
953237412Sjkim                        while (Notify)
954237412Sjkim                        {
955237412Sjkim                            Count++;
956237412Sjkim                            Notify = Notify->Next;
957237412Sjkim                        }
958237412Sjkim                        AcpiOsPrintf ("Implicit Notify on %u devices", Count);
959129684Snjl                        break;
960250838Sjkim
961129684Snjl                    default:
962250838Sjkim
963129684Snjl                        AcpiOsPrintf ("UNKNOWN: %X",
964129684Snjl                            GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK);
965129684Snjl                        break;
966129684Snjl                    }
967129684Snjl
968206117Sjkim                    AcpiOsPrintf (")\n");
969129684Snjl                }
970129684Snjl            }
971129684Snjl            Block++;
972117521Snjl            GpeBlock = GpeBlock->Next;
973117521Snjl        }
974117521Snjl        GpeXruptInfo = GpeXruptInfo->Next;
975114237Snjl    }
976114237Snjl}
977231844Sjkim#endif /* !ACPI_REDUCED_HARDWARE */
978114237Snjl
979220663Sjkim
980218590Sjkim/*******************************************************************************
981218590Sjkim *
982218590Sjkim * FUNCTION:    AcpiDbDisplayHandlers
983218590Sjkim *
984218590Sjkim * PARAMETERS:  None
985218590Sjkim *
986218590Sjkim * RETURN:      None
987218590Sjkim *
988218590Sjkim * DESCRIPTION: Display the currently installed global handlers
989218590Sjkim *
990218590Sjkim ******************************************************************************/
991218590Sjkim
992218590Sjkimvoid
993218590SjkimAcpiDbDisplayHandlers (
994218590Sjkim    void)
995218590Sjkim{
996218590Sjkim    ACPI_OPERAND_OBJECT     *ObjDesc;
997218590Sjkim    ACPI_OPERAND_OBJECT     *HandlerObj;
998218590Sjkim    ACPI_ADR_SPACE_TYPE     SpaceId;
999218590Sjkim    UINT32                  i;
1000218590Sjkim
1001218590Sjkim
1002218590Sjkim    /* Operation region handlers */
1003218590Sjkim
1004249663Sjkim    AcpiOsPrintf ("\nOperation Region Handlers at the namespace root:\n");
1005218590Sjkim
1006218590Sjkim    ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
1007218590Sjkim    if (ObjDesc)
1008218590Sjkim    {
1009220663Sjkim        for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++)
1010218590Sjkim        {
1011220663Sjkim            SpaceId = AcpiGbl_SpaceIdList[i];
1012218590Sjkim            HandlerObj = ObjDesc->Device.Handler;
1013218590Sjkim
1014218590Sjkim            AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1015218590Sjkim                AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);
1016218590Sjkim
1017218590Sjkim            while (HandlerObj)
1018218590Sjkim            {
1019228110Sjkim                if (AcpiGbl_SpaceIdList[i] == HandlerObj->AddressSpace.SpaceId)
1020218590Sjkim                {
1021218590Sjkim                    AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
1022218590Sjkim                        (HandlerObj->AddressSpace.HandlerFlags &
1023218590Sjkim                            ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
1024218590Sjkim                        HandlerObj->AddressSpace.Handler);
1025218590Sjkim                    goto FoundHandler;
1026218590Sjkim                }
1027218590Sjkim
1028218590Sjkim                HandlerObj = HandlerObj->AddressSpace.Next;
1029218590Sjkim            }
1030218590Sjkim
1031218590Sjkim            /* There is no handler for this SpaceId */
1032218590Sjkim
1033218590Sjkim            AcpiOsPrintf ("None\n");
1034218590Sjkim
1035218590Sjkim        FoundHandler:;
1036218590Sjkim        }
1037228110Sjkim
1038228110Sjkim        /* Find all handlers for user-defined SpaceIDs */
1039228110Sjkim
1040228110Sjkim        HandlerObj = ObjDesc->Device.Handler;
1041228110Sjkim        while (HandlerObj)
1042228110Sjkim        {
1043228110Sjkim            if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN)
1044228110Sjkim            {
1045228110Sjkim                AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1046228110Sjkim                    "User-defined ID", HandlerObj->AddressSpace.SpaceId);
1047228110Sjkim                AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
1048228110Sjkim                    (HandlerObj->AddressSpace.HandlerFlags &
1049228110Sjkim                        ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
1050228110Sjkim                    HandlerObj->AddressSpace.Handler);
1051228110Sjkim            }
1052228110Sjkim
1053228110Sjkim            HandlerObj = HandlerObj->AddressSpace.Next;
1054228110Sjkim        }
1055218590Sjkim    }
1056218590Sjkim
1057231844Sjkim#if (!ACPI_REDUCED_HARDWARE)
1058231844Sjkim
1059218590Sjkim    /* Fixed event handlers */
1060218590Sjkim
1061218590Sjkim    AcpiOsPrintf ("\nFixed Event Handlers:\n");
1062218590Sjkim
1063218590Sjkim    for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
1064218590Sjkim    {
1065218590Sjkim        AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i);
1066218590Sjkim        if (AcpiGbl_FixedEventHandlers[i].Handler)
1067218590Sjkim        {
1068218590Sjkim            AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
1069218590Sjkim                AcpiGbl_FixedEventHandlers[i].Handler);
1070218590Sjkim        }
1071218590Sjkim        else
1072218590Sjkim        {
1073218590Sjkim            AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1074218590Sjkim        }
1075218590Sjkim    }
1076218590Sjkim
1077231844Sjkim#endif /* !ACPI_REDUCED_HARDWARE */
1078231844Sjkim
1079218590Sjkim    /* Miscellaneous global handlers */
1080218590Sjkim
1081218590Sjkim    AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n");
1082218590Sjkim
1083220663Sjkim    for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++)
1084218590Sjkim    {
1085220663Sjkim        AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, AcpiGbl_HandlerList[i].Name);
1086220663Sjkim        if (AcpiGbl_HandlerList[i].Handler)
1087218590Sjkim        {
1088218590Sjkim            AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
1089220663Sjkim                AcpiGbl_HandlerList[i].Handler);
1090218590Sjkim        }
1091218590Sjkim        else
1092218590Sjkim        {
1093218590Sjkim            AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1094218590Sjkim        }
1095218590Sjkim    }
1096249663Sjkim
1097249663Sjkim
1098249663Sjkim    /* Other handlers that are installed throughout the namespace */
1099249663Sjkim
1100249663Sjkim    AcpiOsPrintf ("\nOperation Region Handlers for specific devices:\n");
1101249663Sjkim
1102249663Sjkim    (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1103249663Sjkim                ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers,
1104249663Sjkim                NULL, NULL, NULL);
1105218590Sjkim}
1106218590Sjkim
1107249663Sjkim
1108249663Sjkim/*******************************************************************************
1109249663Sjkim *
1110249663Sjkim * FUNCTION:    AcpiDbDisplayNonRootHandlers
1111249663Sjkim *
1112249663Sjkim * PARAMETERS:  ACPI_WALK_CALLBACK
1113249663Sjkim *
1114249663Sjkim * RETURN:      Status
1115249663Sjkim *
1116249663Sjkim * DESCRIPTION: Display information about all handlers installed for a
1117249663Sjkim *              device object.
1118249663Sjkim *
1119249663Sjkim ******************************************************************************/
1120249663Sjkim
1121249663Sjkimstatic ACPI_STATUS
1122249663SjkimAcpiDbDisplayNonRootHandlers (
1123249663Sjkim    ACPI_HANDLE             ObjHandle,
1124249663Sjkim    UINT32                  NestingLevel,
1125249663Sjkim    void                    *Context,
1126249663Sjkim    void                    **ReturnValue)
1127249663Sjkim{
1128249663Sjkim    ACPI_NAMESPACE_NODE     *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
1129249663Sjkim    ACPI_OPERAND_OBJECT     *ObjDesc;
1130249663Sjkim    ACPI_OPERAND_OBJECT     *HandlerObj;
1131249663Sjkim    char                    *Pathname;
1132249663Sjkim
1133249663Sjkim
1134249663Sjkim    ObjDesc = AcpiNsGetAttachedObject (Node);
1135249663Sjkim    if (!ObjDesc)
1136249663Sjkim    {
1137249663Sjkim        return (AE_OK);
1138249663Sjkim    }
1139249663Sjkim
1140249663Sjkim    Pathname = AcpiNsGetExternalPathname (Node);
1141249663Sjkim    if (!Pathname)
1142249663Sjkim    {
1143249663Sjkim        return (AE_OK);
1144249663Sjkim    }
1145249663Sjkim
1146249663Sjkim    /* Display all handlers associated with this device */
1147249663Sjkim
1148249663Sjkim    HandlerObj = ObjDesc->Device.Handler;
1149249663Sjkim    while (HandlerObj)
1150249663Sjkim    {
1151249663Sjkim        AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1152249663Sjkim            AcpiUtGetRegionName ((UINT8) HandlerObj->AddressSpace.SpaceId),
1153249663Sjkim            HandlerObj->AddressSpace.SpaceId);
1154249663Sjkim
1155249663Sjkim        AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING2,
1156249663Sjkim            (HandlerObj->AddressSpace.HandlerFlags &
1157249663Sjkim                ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
1158249663Sjkim            HandlerObj->AddressSpace.Handler);
1159249663Sjkim
1160249663Sjkim        AcpiOsPrintf (" Device Name: %s (%p)\n", Pathname, Node);
1161249663Sjkim
1162249663Sjkim        HandlerObj = HandlerObj->AddressSpace.Next;
1163249663Sjkim    }
1164249663Sjkim
1165249663Sjkim    ACPI_FREE (Pathname);
1166249663Sjkim    return (AE_OK);
1167249663Sjkim}
1168249663Sjkim
1169102550Siwasaki#endif /* ACPI_DEBUGGER */
1170