xref: /freebsd/sys/contrib/dev/acpica/components/debugger/dbdisply.c (revision 8ef24a0d4b28fe230e20637f56869cc4148cd2ca)
1 /*******************************************************************************
2  *
3  * Module Name: dbdisply - debug display commands
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2016, 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/acevents.h>
52 #include <contrib/dev/acpica/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,  "System Notifications"},
115     {&AcpiGbl_GlobalNotify[1].Handler,  "Device Notifications"},
116     {&AcpiGbl_TableHandler,             "ACPI Table Events"},
117     {&AcpiGbl_ExceptionHandler,         "Control Method Exceptions"},
118     {&AcpiGbl_InterfaceHandler,         "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) 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):\n", 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         AcpiUtDebugDumpBuffer ((void *) ObjDesc,
372             sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX);
373         AcpiExDumpObjectDescriptor (ObjDesc, 1);
374     }
375 }
376 
377 
378 /*******************************************************************************
379  *
380  * FUNCTION:    AcpiDbDisplayMethodInfo
381  *
382  * PARAMETERS:  StartOp         - Root of the control method parse tree
383  *
384  * RETURN:      None
385  *
386  * DESCRIPTION: Display information about the current method
387  *
388  ******************************************************************************/
389 
390 void
391 AcpiDbDisplayMethodInfo (
392     ACPI_PARSE_OBJECT       *StartOp)
393 {
394     ACPI_WALK_STATE         *WalkState;
395     ACPI_OPERAND_OBJECT     *ObjDesc;
396     ACPI_NAMESPACE_NODE     *Node;
397     ACPI_PARSE_OBJECT       *RootOp;
398     ACPI_PARSE_OBJECT       *Op;
399     const ACPI_OPCODE_INFO  *OpInfo;
400     UINT32                  NumOps = 0;
401     UINT32                  NumOperands = 0;
402     UINT32                  NumOperators = 0;
403     UINT32                  NumRemainingOps = 0;
404     UINT32                  NumRemainingOperands = 0;
405     UINT32                  NumRemainingOperators = 0;
406     BOOLEAN                 CountRemaining = FALSE;
407 
408 
409     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
410     if (!WalkState)
411     {
412         AcpiOsPrintf ("There is no method currently executing\n");
413         return;
414     }
415 
416     ObjDesc = WalkState->MethodDesc;
417     Node = WalkState->MethodNode;
418 
419     AcpiOsPrintf ("Currently executing control method is [%4.4s]\n",
420         AcpiUtGetNodeName (Node));
421     AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n",
422         (UINT32) ObjDesc->Method.ParamCount,
423         (UINT32) ObjDesc->Method.SyncLevel);
424 
425     RootOp = StartOp;
426     while (RootOp->Common.Parent)
427     {
428         RootOp = RootOp->Common.Parent;
429     }
430 
431     Op = RootOp;
432 
433     while (Op)
434     {
435         if (Op == StartOp)
436         {
437             CountRemaining = TRUE;
438         }
439 
440         NumOps++;
441         if (CountRemaining)
442         {
443             NumRemainingOps++;
444         }
445 
446         /* Decode the opcode */
447 
448         OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
449         switch (OpInfo->Class)
450         {
451         case AML_CLASS_ARGUMENT:
452 
453             if (CountRemaining)
454             {
455                 NumRemainingOperands++;
456             }
457 
458             NumOperands++;
459             break;
460 
461         case AML_CLASS_UNKNOWN:
462 
463             /* Bad opcode or ASCII character */
464 
465             continue;
466 
467         default:
468 
469             if (CountRemaining)
470             {
471                 NumRemainingOperators++;
472             }
473 
474             NumOperators++;
475             break;
476         }
477 
478         Op = AcpiPsGetDepthNext (StartOp, Op);
479     }
480 
481     AcpiOsPrintf (
482         "Method contains:       %X AML Opcodes - %X Operators, %X Operands\n",
483         NumOps, NumOperators, NumOperands);
484 
485     AcpiOsPrintf (
486         "Remaining to execute:  %X AML Opcodes - %X Operators, %X Operands\n",
487         NumRemainingOps, NumRemainingOperators, NumRemainingOperands);
488 }
489 
490 
491 /*******************************************************************************
492  *
493  * FUNCTION:    AcpiDbDisplayLocals
494  *
495  * PARAMETERS:  None
496  *
497  * RETURN:      None
498  *
499  * DESCRIPTION: Display all locals for the currently running control method
500  *
501  ******************************************************************************/
502 
503 void
504 AcpiDbDisplayLocals (
505     void)
506 {
507     ACPI_WALK_STATE         *WalkState;
508 
509 
510     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
511     if (!WalkState)
512     {
513         AcpiOsPrintf ("There is no method currently executing\n");
514         return;
515     }
516 
517     AcpiDbDecodeLocals (WalkState);
518 }
519 
520 
521 /*******************************************************************************
522  *
523  * FUNCTION:    AcpiDbDisplayArguments
524  *
525  * PARAMETERS:  None
526  *
527  * RETURN:      None
528  *
529  * DESCRIPTION: Display all arguments for the currently running control method
530  *
531  ******************************************************************************/
532 
533 void
534 AcpiDbDisplayArguments (
535     void)
536 {
537     ACPI_WALK_STATE         *WalkState;
538 
539 
540     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
541     if (!WalkState)
542     {
543         AcpiOsPrintf ("There is no method currently executing\n");
544         return;
545     }
546 
547     AcpiDbDecodeArguments (WalkState);
548 }
549 
550 
551 /*******************************************************************************
552  *
553  * FUNCTION:    AcpiDbDisplayResults
554  *
555  * PARAMETERS:  None
556  *
557  * RETURN:      None
558  *
559  * DESCRIPTION: Display current contents of a method result stack
560  *
561  ******************************************************************************/
562 
563 void
564 AcpiDbDisplayResults (
565     void)
566 {
567     UINT32                  i;
568     ACPI_WALK_STATE         *WalkState;
569     ACPI_OPERAND_OBJECT     *ObjDesc;
570     UINT32                  ResultCount = 0;
571     ACPI_NAMESPACE_NODE     *Node;
572     ACPI_GENERIC_STATE      *Frame;
573     UINT32                  Index; /* Index onto current frame */
574 
575 
576     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
577     if (!WalkState)
578     {
579         AcpiOsPrintf ("There is no method currently executing\n");
580         return;
581     }
582 
583     ObjDesc = WalkState->MethodDesc;
584     Node  = WalkState->MethodNode;
585 
586     if (WalkState->Results)
587     {
588         ResultCount = WalkState->ResultCount;
589     }
590 
591     AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
592         AcpiUtGetNodeName (Node), ResultCount);
593 
594     /* From the top element of result stack */
595 
596     Frame = WalkState->Results;
597     Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
598 
599     for (i = 0; i < ResultCount; i++)
600     {
601         ObjDesc = Frame->Results.ObjDesc[Index];
602         AcpiOsPrintf ("Result%u: ", i);
603         AcpiDbDisplayInternalObject (ObjDesc, WalkState);
604 
605         if (Index == 0)
606         {
607             Frame = Frame->Results.Next;
608             Index = ACPI_RESULTS_FRAME_OBJ_NUM;
609         }
610 
611         Index--;
612     }
613 }
614 
615 
616 /*******************************************************************************
617  *
618  * FUNCTION:    AcpiDbDisplayCallingTree
619  *
620  * PARAMETERS:  None
621  *
622  * RETURN:      None
623  *
624  * DESCRIPTION: Display current calling tree of nested control methods
625  *
626  ******************************************************************************/
627 
628 void
629 AcpiDbDisplayCallingTree (
630     void)
631 {
632     ACPI_WALK_STATE         *WalkState;
633     ACPI_NAMESPACE_NODE     *Node;
634 
635 
636     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
637     if (!WalkState)
638     {
639         AcpiOsPrintf ("There is no method currently executing\n");
640         return;
641     }
642 
643     Node = WalkState->MethodNode;
644     AcpiOsPrintf ("Current Control Method Call Tree\n");
645 
646     while (WalkState)
647     {
648         Node = WalkState->MethodNode;
649         AcpiOsPrintf ("    [%4.4s]\n", AcpiUtGetNodeName (Node));
650 
651         WalkState = WalkState->Next;
652     }
653 }
654 
655 
656 /*******************************************************************************
657  *
658  * FUNCTION:    AcpiDbDisplayObjectType
659  *
660  * PARAMETERS:  ObjectArg       - User entered NS node handle
661  *
662  * RETURN:      None
663  *
664  * DESCRIPTION: Display type of an arbitrary NS node
665  *
666  ******************************************************************************/
667 
668 void
669 AcpiDbDisplayObjectType (
670     char                    *ObjectArg)
671 {
672     ACPI_SIZE               Arg;
673     ACPI_HANDLE             Handle;
674     ACPI_DEVICE_INFO        *Info;
675     ACPI_STATUS             Status;
676     UINT32                  i;
677 
678 
679     Arg = strtoul (ObjectArg, NULL, 16);
680     Handle = ACPI_TO_POINTER (Arg);
681 
682     Status = AcpiGetObjectInfo (Handle, &Info);
683     if (ACPI_FAILURE (Status))
684     {
685         AcpiOsPrintf ("Could not get object info, %s\n",
686             AcpiFormatException (Status));
687         return;
688     }
689 
690     AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n",
691         ACPI_FORMAT_UINT64 (Info->Address),
692         Info->CurrentStatus, Info->Flags);
693 
694     AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
695         Info->HighestDstates[0], Info->HighestDstates[1],
696         Info->HighestDstates[2], Info->HighestDstates[3]);
697 
698     AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
699         Info->LowestDstates[0], Info->LowestDstates[1],
700         Info->LowestDstates[2], Info->LowestDstates[3],
701         Info->LowestDstates[4]);
702 
703     if (Info->Valid & ACPI_VALID_HID)
704     {
705         AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String);
706     }
707 
708     if (Info->Valid & ACPI_VALID_UID)
709     {
710         AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String);
711     }
712 
713     if (Info->Valid & ACPI_VALID_CID)
714     {
715         for (i = 0; i < Info->CompatibleIdList.Count; i++)
716         {
717             AcpiOsPrintf ("CID %u: %s\n", i,
718                 Info->CompatibleIdList.Ids[i].String);
719         }
720     }
721 
722     ACPI_FREE (Info);
723 }
724 
725 
726 /*******************************************************************************
727  *
728  * FUNCTION:    AcpiDbDisplayResultObject
729  *
730  * PARAMETERS:  ObjDesc         - Object to be displayed
731  *              WalkState       - Current walk state
732  *
733  * RETURN:      None
734  *
735  * DESCRIPTION: Display the result of an AML opcode
736  *
737  * Note: Curently only displays the result object if we are single stepping.
738  * However, this output may be useful in other contexts and could be enabled
739  * to do so if needed.
740  *
741  ******************************************************************************/
742 
743 void
744 AcpiDbDisplayResultObject (
745     ACPI_OPERAND_OBJECT     *ObjDesc,
746     ACPI_WALK_STATE         *WalkState)
747 {
748 
749 #ifndef ACPI_APPLICATION
750     if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())
751     {
752         return;
753     }
754 #endif
755 
756     /* Only display if single stepping */
757 
758     if (!AcpiGbl_CmSingleStep)
759     {
760         return;
761     }
762 
763     AcpiOsPrintf ("ResultObj: ");
764     AcpiDbDisplayInternalObject (ObjDesc, WalkState);
765     AcpiOsPrintf ("\n");
766 }
767 
768 
769 /*******************************************************************************
770  *
771  * FUNCTION:    AcpiDbDisplayArgumentObject
772  *
773  * PARAMETERS:  ObjDesc         - Object to be displayed
774  *              WalkState       - Current walk state
775  *
776  * RETURN:      None
777  *
778  * DESCRIPTION: Display the result of an AML opcode
779  *
780  ******************************************************************************/
781 
782 void
783 AcpiDbDisplayArgumentObject (
784     ACPI_OPERAND_OBJECT     *ObjDesc,
785     ACPI_WALK_STATE         *WalkState)
786 {
787 
788 #ifndef ACPI_APPLICATION
789     if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())
790     {
791         return;
792     }
793 #endif
794 
795     if (!AcpiGbl_CmSingleStep)
796     {
797         return;
798     }
799 
800     AcpiOsPrintf ("ArgObj:    ");
801     AcpiDbDisplayInternalObject (ObjDesc, WalkState);
802 }
803 
804 
805 #if (!ACPI_REDUCED_HARDWARE)
806 /*******************************************************************************
807  *
808  * FUNCTION:    AcpiDbDisplayGpes
809  *
810  * PARAMETERS:  None
811  *
812  * RETURN:      None
813  *
814  * DESCRIPTION: Display the current GPE structures
815  *
816  ******************************************************************************/
817 
818 void
819 AcpiDbDisplayGpes (
820     void)
821 {
822     ACPI_GPE_BLOCK_INFO     *GpeBlock;
823     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo;
824     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
825     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
826     char                    *GpeType;
827     ACPI_GPE_NOTIFY_INFO    *Notify;
828     UINT32                  GpeIndex;
829     UINT32                  Block = 0;
830     UINT32                  i;
831     UINT32                  j;
832     UINT32                  Count;
833     char                    Buffer[80];
834     ACPI_BUFFER             RetBuf;
835     ACPI_STATUS             Status;
836 
837 
838     RetBuf.Length = sizeof (Buffer);
839     RetBuf.Pointer = Buffer;
840 
841     Block = 0;
842 
843     /* Walk the GPE lists */
844 
845     GpeXruptInfo = AcpiGbl_GpeXruptListHead;
846     while (GpeXruptInfo)
847     {
848         GpeBlock = GpeXruptInfo->GpeBlockListHead;
849         while (GpeBlock)
850         {
851             Status = AcpiGetName (GpeBlock->Node,
852                 ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);
853             if (ACPI_FAILURE (Status))
854             {
855                 AcpiOsPrintf ("Could not convert name to pathname\n");
856             }
857 
858             if (GpeBlock->Node == AcpiGbl_FadtGpeDevice)
859             {
860                 GpeType = "FADT-defined GPE block";
861             }
862             else
863             {
864                 GpeType = "GPE Block Device";
865             }
866 
867             AcpiOsPrintf (
868                 "\nBlock %u - Info %p  DeviceNode %p [%s] - %s\n",
869                 Block, GpeBlock, GpeBlock->Node, Buffer, GpeType);
870 
871             AcpiOsPrintf (
872                 "    Registers:    %u (%u GPEs)\n",
873                 GpeBlock->RegisterCount, GpeBlock->GpeCount);
874 
875             AcpiOsPrintf (
876                 "    GPE range:    0x%X to 0x%X on interrupt %u\n",
877                 GpeBlock->BlockBaseNumber,
878                 GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1),
879                 GpeXruptInfo->InterruptNumber);
880 
881             AcpiOsPrintf (
882                 "    RegisterInfo: %p  Status %8.8X%8.8X Enable %8.8X%8.8X\n",
883                 GpeBlock->RegisterInfo,
884                 ACPI_FORMAT_UINT64 (
885                     GpeBlock->RegisterInfo->StatusAddress.Address),
886                 ACPI_FORMAT_UINT64 (
887                     GpeBlock->RegisterInfo->EnableAddress.Address));
888 
889             AcpiOsPrintf ("    EventInfo:    %p\n", GpeBlock->EventInfo);
890 
891             /* Examine each GPE Register within the block */
892 
893             for (i = 0; i < GpeBlock->RegisterCount; i++)
894             {
895                 GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
896 
897                 AcpiOsPrintf (
898                     "    Reg %u: (GPE %.2X-%.2X)  "
899                     "RunEnable %2.2X WakeEnable %2.2X"
900                     " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
901                     i, GpeRegisterInfo->BaseGpeNumber,
902                     GpeRegisterInfo->BaseGpeNumber +
903                         (ACPI_GPE_REGISTER_WIDTH - 1),
904                     GpeRegisterInfo->EnableForRun,
905                     GpeRegisterInfo->EnableForWake,
906                     ACPI_FORMAT_UINT64 (
907                         GpeRegisterInfo->StatusAddress.Address),
908                     ACPI_FORMAT_UINT64 (
909                         GpeRegisterInfo->EnableAddress.Address));
910 
911                 /* Now look at the individual GPEs in this byte register */
912 
913                 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
914                 {
915                     GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;
916                     GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];
917 
918                     if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) ==
919                         ACPI_GPE_DISPATCH_NONE)
920                     {
921                         /* This GPE is not used (no method or handler), ignore it */
922 
923                         continue;
924                     }
925 
926                     AcpiOsPrintf (
927                         "        GPE %.2X: %p  RunRefs %2.2X Flags %2.2X (",
928                         GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo,
929                         GpeEventInfo->RuntimeCount, GpeEventInfo->Flags);
930 
931                     /* Decode the flags byte */
932 
933                     if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED)
934                     {
935                         AcpiOsPrintf ("Level, ");
936                     }
937                     else
938                     {
939                         AcpiOsPrintf ("Edge,  ");
940                     }
941 
942                     if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)
943                     {
944                         AcpiOsPrintf ("CanWake, ");
945                     }
946                     else
947                     {
948                         AcpiOsPrintf ("RunOnly, ");
949                     }
950 
951                     switch (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags))
952                     {
953                     case ACPI_GPE_DISPATCH_NONE:
954 
955                         AcpiOsPrintf ("NotUsed");
956                         break;
957 
958                     case ACPI_GPE_DISPATCH_METHOD:
959 
960                         AcpiOsPrintf ("Method");
961                         break;
962 
963                     case ACPI_GPE_DISPATCH_HANDLER:
964 
965                         AcpiOsPrintf ("Handler");
966                         break;
967 
968                     case ACPI_GPE_DISPATCH_NOTIFY:
969 
970                         Count = 0;
971                         Notify = GpeEventInfo->Dispatch.NotifyList;
972                         while (Notify)
973                         {
974                             Count++;
975                             Notify = Notify->Next;
976                         }
977 
978                         AcpiOsPrintf ("Implicit Notify on %u devices",
979                             Count);
980                         break;
981 
982                     case ACPI_GPE_DISPATCH_RAW_HANDLER:
983 
984                         AcpiOsPrintf ("RawHandler");
985                         break;
986 
987                     default:
988 
989                         AcpiOsPrintf ("UNKNOWN: %X",
990                             ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags));
991                         break;
992                     }
993 
994                     AcpiOsPrintf (")\n");
995                 }
996             }
997 
998             Block++;
999             GpeBlock = GpeBlock->Next;
1000         }
1001 
1002         GpeXruptInfo = GpeXruptInfo->Next;
1003     }
1004 }
1005 #endif /* !ACPI_REDUCED_HARDWARE */
1006 
1007 
1008 /*******************************************************************************
1009  *
1010  * FUNCTION:    AcpiDbDisplayHandlers
1011  *
1012  * PARAMETERS:  None
1013  *
1014  * RETURN:      None
1015  *
1016  * DESCRIPTION: Display the currently installed global handlers
1017  *
1018  ******************************************************************************/
1019 
1020 void
1021 AcpiDbDisplayHandlers (
1022     void)
1023 {
1024     ACPI_OPERAND_OBJECT     *ObjDesc;
1025     ACPI_OPERAND_OBJECT     *HandlerObj;
1026     ACPI_ADR_SPACE_TYPE     SpaceId;
1027     UINT32                  i;
1028 
1029 
1030     /* Operation region handlers */
1031 
1032     AcpiOsPrintf ("\nOperation Region Handlers at the namespace root:\n");
1033 
1034     ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
1035     if (ObjDesc)
1036     {
1037         for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++)
1038         {
1039             SpaceId = AcpiGbl_SpaceIdList[i];
1040 
1041             AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1042                 AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);
1043 
1044             HandlerObj = AcpiEvFindRegionHandler (
1045                 SpaceId, ObjDesc->CommonNotify.Handler);
1046             if (HandlerObj)
1047             {
1048                 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
1049                     (HandlerObj->AddressSpace.HandlerFlags &
1050                         ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?
1051                         "Default" : "User",
1052                     HandlerObj->AddressSpace.Handler);
1053 
1054                 goto FoundHandler;
1055             }
1056 
1057             /* There is no handler for this SpaceId */
1058 
1059             AcpiOsPrintf ("None\n");
1060 
1061         FoundHandler:;
1062         }
1063 
1064         /* Find all handlers for user-defined SpaceIDs */
1065 
1066         HandlerObj = ObjDesc->CommonNotify.Handler;
1067         while (HandlerObj)
1068         {
1069             if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN)
1070             {
1071                 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1072                     "User-defined ID", HandlerObj->AddressSpace.SpaceId);
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 
1080             HandlerObj = HandlerObj->AddressSpace.Next;
1081         }
1082     }
1083 
1084 #if (!ACPI_REDUCED_HARDWARE)
1085 
1086     /* Fixed event handlers */
1087 
1088     AcpiOsPrintf ("\nFixed Event Handlers:\n");
1089 
1090     for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
1091     {
1092         AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i);
1093         if (AcpiGbl_FixedEventHandlers[i].Handler)
1094         {
1095             AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
1096                 AcpiGbl_FixedEventHandlers[i].Handler);
1097         }
1098         else
1099         {
1100             AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1101         }
1102     }
1103 
1104 #endif /* !ACPI_REDUCED_HARDWARE */
1105 
1106     /* Miscellaneous global handlers */
1107 
1108     AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n");
1109 
1110     for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++)
1111     {
1112         AcpiOsPrintf (ACPI_HANDLER_NAME_STRING,
1113             AcpiGbl_HandlerList[i].Name);
1114 
1115         if (AcpiGbl_HandlerList[i].Handler)
1116         {
1117             AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
1118                 AcpiGbl_HandlerList[i].Handler);
1119         }
1120         else
1121         {
1122             AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
1123         }
1124     }
1125 
1126 
1127     /* Other handlers that are installed throughout the namespace */
1128 
1129     AcpiOsPrintf ("\nOperation Region Handlers for specific devices:\n");
1130 
1131     (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1132         ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers,
1133         NULL, NULL, NULL);
1134 }
1135 
1136 
1137 /*******************************************************************************
1138  *
1139  * FUNCTION:    AcpiDbDisplayNonRootHandlers
1140  *
1141  * PARAMETERS:  ACPI_WALK_CALLBACK
1142  *
1143  * RETURN:      Status
1144  *
1145  * DESCRIPTION: Display information about all handlers installed for a
1146  *              device object.
1147  *
1148  ******************************************************************************/
1149 
1150 static ACPI_STATUS
1151 AcpiDbDisplayNonRootHandlers (
1152     ACPI_HANDLE             ObjHandle,
1153     UINT32                  NestingLevel,
1154     void                    *Context,
1155     void                    **ReturnValue)
1156 {
1157     ACPI_NAMESPACE_NODE     *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
1158     ACPI_OPERAND_OBJECT     *ObjDesc;
1159     ACPI_OPERAND_OBJECT     *HandlerObj;
1160     char                    *Pathname;
1161 
1162 
1163     ObjDesc = AcpiNsGetAttachedObject (Node);
1164     if (!ObjDesc)
1165     {
1166         return (AE_OK);
1167     }
1168 
1169     Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
1170     if (!Pathname)
1171     {
1172         return (AE_OK);
1173     }
1174 
1175     /* Display all handlers associated with this device */
1176 
1177     HandlerObj = ObjDesc->CommonNotify.Handler;
1178     while (HandlerObj)
1179     {
1180         AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
1181             AcpiUtGetRegionName ((UINT8) HandlerObj->AddressSpace.SpaceId),
1182             HandlerObj->AddressSpace.SpaceId);
1183 
1184         AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING2,
1185             (HandlerObj->AddressSpace.HandlerFlags &
1186                 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
1187             HandlerObj->AddressSpace.Handler);
1188 
1189         AcpiOsPrintf (" Device Name: %s (%p)\n", Pathname, Node);
1190 
1191         HandlerObj = HandlerObj->AddressSpace.Next;
1192     }
1193 
1194     ACPI_FREE (Pathname);
1195     return (AE_OK);
1196 }
1197