xref: /dflybsd-src/sys/contrib/dev/acpica/source/components/debugger/dbdisply.c (revision 2762423991074ed996c5c4488491cb3ef18c25ea)
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 "acpi.h"
45 #include "accommon.h"
46 #include "amlcode.h"
47 #include "acdispat.h"
48 #include "acnamesp.h"
49 #include "acparser.h"
50 #include "acinterp.h"
51 #include "acevents.h"
52 #include "acdebug.h"
53 
54 
55 #ifdef ACPI_DEBUGGER
56 
57 #define _COMPONENT          ACPI_CA_DEBUGGER
58         ACPI_MODULE_NAME    ("dbdisply")
59 
60 /* Local prototypes */
61 
62 static void
63 AcpiDbDumpParserDescriptor (
64     ACPI_PARSE_OBJECT       *Op);
65 
66 static void *
67 AcpiDbGetPointer (
68     void                    *Target);
69 
70 static ACPI_STATUS
71 AcpiDbDisplayNonRootHandlers (
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 
89 static 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 
107 typedef struct acpi_handler_info
108 {
109     void                    *Handler;
110     char                    *Name;
111 
112 } ACPI_HANDLER_INFO;
113 
114 static 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 
136 static void *
137 AcpiDbGetPointer (
138     void                    *Target)
139 {
140     void                    *ObjPtr;
141     ACPI_SIZE               Address;
142 
143 
144     Address = 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 
162 static void
163 AcpiDbDumpParserDescriptor (
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 
197 void
198 AcpiDbDecodeAndDisplayObject (
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 (
247                 "Address %p is invalid in this address space\n",
248                 ObjPtr);
249             return;
250         }
251 
252         /* Decode the object type */
253 
254         switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr))
255         {
256         case ACPI_DESC_TYPE_NAMED:
257 
258             /* This is a namespace Node */
259 
260             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE)))
261             {
262                 AcpiOsPrintf (
263                     "Cannot read entire Named object at address %p\n",
264                     ObjPtr);
265                 return;
266             }
267 
268             Node = ObjPtr;
269             goto DumpNode;
270 
271         case ACPI_DESC_TYPE_OPERAND:
272 
273             /* This is a ACPI OPERAND OBJECT */
274 
275             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT)))
276             {
277                 AcpiOsPrintf (
278                     "Cannot read entire ACPI object at address %p\n",
279                     ObjPtr);
280                 return;
281             }
282 
283             AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT),
284                 Display, ACPI_UINT32_MAX);
285             AcpiExDumpObjectDescriptor (ObjPtr, 1);
286             break;
287 
288         case ACPI_DESC_TYPE_PARSER:
289 
290             /* This is a Parser Op object */
291 
292             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT)))
293             {
294                 AcpiOsPrintf (
295                     "Cannot read entire Parser object at address %p\n",
296                     ObjPtr);
297                 return;
298             }
299 
300             AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT),
301                 Display, ACPI_UINT32_MAX);
302             AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr);
303             break;
304 
305         default:
306 
307             /* Is not a recognizeable object */
308 
309             AcpiOsPrintf (
310                 "Not a known ACPI internal object, descriptor type %2.2X\n",
311                 ACPI_GET_DESCRIPTOR_TYPE (ObjPtr));
312 
313             Size = 16;
314             if (AcpiOsReadable (ObjPtr, 64))
315             {
316                 Size = 64;
317             }
318 
319             /* Just dump some memory */
320 
321             AcpiUtDebugDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX);
322             break;
323         }
324 
325         return;
326     }
327 
328     /* The parameter is a name string that must be resolved to a Named obj */
329 
330     Node = AcpiDbLocalNsLookup (Target);
331     if (!Node)
332     {
333         return;
334     }
335 
336 
337 DumpNode:
338     /* Now dump the NS node */
339 
340     Status = AcpiGetName (Node, ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);
341     if (ACPI_FAILURE (Status))
342     {
343         AcpiOsPrintf ("Could not convert name to pathname\n");
344     }
345 
346     else
347     {
348         AcpiOsPrintf ("Object (%p) Pathname:  %s\n",
349             Node, (char *) RetBuf.Pointer);
350     }
351 
352     if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
353     {
354         AcpiOsPrintf ("Invalid Named object at address %p\n", Node);
355         return;
356     }
357 
358     AcpiUtDebugDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE),
359         Display, ACPI_UINT32_MAX);
360     AcpiExDumpNamespaceNode (Node, 1);
361 
362     ObjDesc = AcpiNsGetAttachedObject (Node);
363     if (ObjDesc)
364     {
365         AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc);
366         if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)))
367         {
368             AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n",
369                 ObjDesc);
370             return;
371         }
372 
373         AcpiUtDebugDumpBuffer ((void *) ObjDesc,
374             sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX);
375         AcpiExDumpObjectDescriptor (ObjDesc, 1);
376     }
377 }
378 
379 
380 /*******************************************************************************
381  *
382  * FUNCTION:    AcpiDbDisplayMethodInfo
383  *
384  * PARAMETERS:  StartOp         - Root of the control method parse tree
385  *
386  * RETURN:      None
387  *
388  * DESCRIPTION: Display information about the current method
389  *
390  ******************************************************************************/
391 
392 void
393 AcpiDbDisplayMethodInfo (
394     ACPI_PARSE_OBJECT       *StartOp)
395 {
396     ACPI_WALK_STATE         *WalkState;
397     ACPI_OPERAND_OBJECT     *ObjDesc;
398     ACPI_NAMESPACE_NODE     *Node;
399     ACPI_PARSE_OBJECT       *RootOp;
400     ACPI_PARSE_OBJECT       *Op;
401     const ACPI_OPCODE_INFO  *OpInfo;
402     UINT32                  NumOps = 0;
403     UINT32                  NumOperands = 0;
404     UINT32                  NumOperators = 0;
405     UINT32                  NumRemainingOps = 0;
406     UINT32                  NumRemainingOperands = 0;
407     UINT32                  NumRemainingOperators = 0;
408     BOOLEAN                 CountRemaining = FALSE;
409 
410 
411     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
412     if (!WalkState)
413     {
414         AcpiOsPrintf ("There is no method currently executing\n");
415         return;
416     }
417 
418     ObjDesc = WalkState->MethodDesc;
419     Node = WalkState->MethodNode;
420 
421     AcpiOsPrintf ("Currently executing control method is [%4.4s]\n",
422         AcpiUtGetNodeName (Node));
423     AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n",
424         (UINT32) ObjDesc->Method.ParamCount,
425         (UINT32) ObjDesc->Method.SyncLevel);
426 
427     RootOp = StartOp;
428     while (RootOp->Common.Parent)
429     {
430         RootOp = RootOp->Common.Parent;
431     }
432 
433     Op = RootOp;
434 
435     while (Op)
436     {
437         if (Op == StartOp)
438         {
439             CountRemaining = TRUE;
440         }
441 
442         NumOps++;
443         if (CountRemaining)
444         {
445             NumRemainingOps++;
446         }
447 
448         /* Decode the opcode */
449 
450         OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
451         switch (OpInfo->Class)
452         {
453         case AML_CLASS_ARGUMENT:
454 
455             if (CountRemaining)
456             {
457                 NumRemainingOperands++;
458             }
459 
460             NumOperands++;
461             break;
462 
463         case AML_CLASS_UNKNOWN:
464 
465             /* Bad opcode or ASCII character */
466 
467             continue;
468 
469         default:
470 
471             if (CountRemaining)
472             {
473                 NumRemainingOperators++;
474             }
475 
476             NumOperators++;
477             break;
478         }
479 
480         Op = AcpiPsGetDepthNext (StartOp, Op);
481     }
482 
483     AcpiOsPrintf (
484         "Method contains:       %X AML Opcodes - %X Operators, %X Operands\n",
485         NumOps, NumOperators, NumOperands);
486 
487     AcpiOsPrintf (
488         "Remaining to execute:  %X AML Opcodes - %X Operators, %X Operands\n",
489         NumRemainingOps, NumRemainingOperators, NumRemainingOperands);
490 }
491 
492 
493 /*******************************************************************************
494  *
495  * FUNCTION:    AcpiDbDisplayLocals
496  *
497  * PARAMETERS:  None
498  *
499  * RETURN:      None
500  *
501  * DESCRIPTION: Display all locals for the currently running control method
502  *
503  ******************************************************************************/
504 
505 void
506 AcpiDbDisplayLocals (
507     void)
508 {
509     ACPI_WALK_STATE         *WalkState;
510 
511 
512     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
513     if (!WalkState)
514     {
515         AcpiOsPrintf ("There is no method currently executing\n");
516         return;
517     }
518 
519     AcpiDbDecodeLocals (WalkState);
520 }
521 
522 
523 /*******************************************************************************
524  *
525  * FUNCTION:    AcpiDbDisplayArguments
526  *
527  * PARAMETERS:  None
528  *
529  * RETURN:      None
530  *
531  * DESCRIPTION: Display all arguments for the currently running control method
532  *
533  ******************************************************************************/
534 
535 void
536 AcpiDbDisplayArguments (
537     void)
538 {
539     ACPI_WALK_STATE         *WalkState;
540 
541 
542     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
543     if (!WalkState)
544     {
545         AcpiOsPrintf ("There is no method currently executing\n");
546         return;
547     }
548 
549     AcpiDbDecodeArguments (WalkState);
550 }
551 
552 
553 /*******************************************************************************
554  *
555  * FUNCTION:    AcpiDbDisplayResults
556  *
557  * PARAMETERS:  None
558  *
559  * RETURN:      None
560  *
561  * DESCRIPTION: Display current contents of a method result stack
562  *
563  ******************************************************************************/
564 
565 void
566 AcpiDbDisplayResults (
567     void)
568 {
569     UINT32                  i;
570     ACPI_WALK_STATE         *WalkState;
571     ACPI_OPERAND_OBJECT     *ObjDesc;
572     UINT32                  ResultCount = 0;
573     ACPI_NAMESPACE_NODE     *Node;
574     ACPI_GENERIC_STATE      *Frame;
575     UINT32                  Index; /* Index onto current frame */
576 
577 
578     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
579     if (!WalkState)
580     {
581         AcpiOsPrintf ("There is no method currently executing\n");
582         return;
583     }
584 
585     ObjDesc = WalkState->MethodDesc;
586     Node  = WalkState->MethodNode;
587 
588     if (WalkState->Results)
589     {
590         ResultCount = WalkState->ResultCount;
591     }
592 
593     AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
594         AcpiUtGetNodeName (Node), ResultCount);
595 
596     /* From the top element of result stack */
597 
598     Frame = WalkState->Results;
599     Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
600 
601     for (i = 0; i < ResultCount; i++)
602     {
603         ObjDesc = Frame->Results.ObjDesc[Index];
604         AcpiOsPrintf ("Result%u: ", i);
605         AcpiDbDisplayInternalObject (ObjDesc, WalkState);
606 
607         if (Index == 0)
608         {
609             Frame = Frame->Results.Next;
610             Index = ACPI_RESULTS_FRAME_OBJ_NUM;
611         }
612 
613         Index--;
614     }
615 }
616 
617 
618 /*******************************************************************************
619  *
620  * FUNCTION:    AcpiDbDisplayCallingTree
621  *
622  * PARAMETERS:  None
623  *
624  * RETURN:      None
625  *
626  * DESCRIPTION: Display current calling tree of nested control methods
627  *
628  ******************************************************************************/
629 
630 void
631 AcpiDbDisplayCallingTree (
632     void)
633 {
634     ACPI_WALK_STATE         *WalkState;
635     ACPI_NAMESPACE_NODE     *Node;
636 
637 
638     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
639     if (!WalkState)
640     {
641         AcpiOsPrintf ("There is no method currently executing\n");
642         return;
643     }
644 
645     Node = WalkState->MethodNode;
646     AcpiOsPrintf ("Current Control Method Call Tree\n");
647 
648     while (WalkState)
649     {
650         Node = WalkState->MethodNode;
651         AcpiOsPrintf ("    [%4.4s]\n", AcpiUtGetNodeName (Node));
652 
653         WalkState = WalkState->Next;
654     }
655 }
656 
657 
658 /*******************************************************************************
659  *
660  * FUNCTION:    AcpiDbDisplayObjectType
661  *
662  * PARAMETERS:  ObjectArg       - User entered NS node handle
663  *
664  * RETURN:      None
665  *
666  * DESCRIPTION: Display type of an arbitrary NS node
667  *
668  ******************************************************************************/
669 
670 void
671 AcpiDbDisplayObjectType (
672     char                    *ObjectArg)
673 {
674     ACPI_HANDLE             Handle;
675     ACPI_DEVICE_INFO        *Info;
676     ACPI_STATUS             Status;
677     UINT32                  i;
678 
679 
680     Handle = ACPI_TO_POINTER (strtoul (ObjectArg, NULL, 16));
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 
1198 #endif /* ACPI_DEBUGGER */
1199