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