Misc cleanups to take care of GCC3.x warnings. Missing 'U' and 'LL'
[dragonfly.git] / sys / contrib / dev / acpica / dbdisply.c
1 /*******************************************************************************
2  *
3  * Module Name: dbdisply - debug display commands
4  *              $Revision: 89 $
5  *
6  ******************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
13  * All rights reserved.
14  *
15  * 2. License
16  *
17  * 2.1. This is your license from Intel Corp. under its intellectual property
18  * rights.  You may have additional license terms from the party that provided
19  * you this software, covering your right to use that party's intellectual
20  * property rights.
21  *
22  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23  * copy of the source code appearing in this file ("Covered Code") an
24  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25  * base code distributed originally by Intel ("Original Intel Code") to copy,
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code.  No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision.  In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change.  Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee.  Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution.  In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government.  In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/dbdisply.c,v 1.1 2003/09/24 03:32:15 drhodus Exp $                                                               */
117
118 #include "acpi.h"
119 #include "amlcode.h"
120 #include "acdispat.h"
121 #include "acnamesp.h"
122 #include "acparser.h"
123 #include "acinterp.h"
124 #include "acdebug.h"
125
126
127 #ifdef ACPI_DEBUGGER
128
129
130 #define _COMPONENT          ACPI_CA_DEBUGGER
131         ACPI_MODULE_NAME    ("dbdisply")
132
133
134 /******************************************************************************
135  *
136  * FUNCTION:    AcpiDbGetPointer
137  *
138  * PARAMETERS:  Target          - Pointer to string to be converted
139  *
140  * RETURN:      Converted pointer
141  *
142  * DESCRIPTION: Convert an ascii pointer value to a real value
143  *
144  *****************************************************************************/
145
146 void *
147 AcpiDbGetPointer (
148     void                    *Target)
149 {
150     void                    *ObjPtr;
151
152
153 #if ACPI_MACHINE_WIDTH == 16
154 #include <stdio.h>
155
156     /* Have to handle 16-bit pointers of the form segment:offset */
157
158     if (!sscanf (Target, "%p", &ObjPtr))
159     {
160         AcpiOsPrintf ("Invalid pointer: %s\n", Target);
161         return (NULL);
162     }
163
164 #else
165
166     /* Simple flat pointer */
167
168     ObjPtr = ACPI_TO_POINTER (ACPI_STRTOUL (Target, NULL, 16));
169 #endif
170
171     return (ObjPtr);
172 }
173
174
175 /*******************************************************************************
176  *
177  * FUNCTION:    AcpiDbDumpParserDescriptor
178  *
179  * PARAMETERS:  Op              - A parser Op descriptor
180  *
181  * RETURN:      None
182  *
183  * DESCRIPTION: Display a formatted parser object
184  *
185  ******************************************************************************/
186
187 void
188 AcpiDbDumpParserDescriptor (
189     ACPI_PARSE_OBJECT       *Op)
190 {
191     const ACPI_OPCODE_INFO  *Info;
192
193
194     Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
195
196     AcpiOsPrintf ("Parser Op Descriptor:\n");
197     AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode);
198
199     ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", Info->Name));
200
201     AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg);
202     AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent);
203     AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next);
204 }
205
206
207 /*******************************************************************************
208  *
209  * FUNCTION:    AcpiDbDecodeAndDisplayObject
210  *
211  * PARAMETERS:  Target          - String with object to be displayed.  Names
212  *                                and hex pointers are supported.
213  *              OutputType      - Byte, Word, Dword, or Qword (B|W|D|Q)
214  *
215  * RETURN:      None
216  *
217  * DESCRIPTION: Display a formatted ACPI object
218  *
219  ******************************************************************************/
220
221 void
222 AcpiDbDecodeAndDisplayObject (
223     char                    *Target,
224     char                    *OutputType)
225 {
226     void                    *ObjPtr;
227     ACPI_NAMESPACE_NODE     *Node;
228     ACPI_OPERAND_OBJECT     *ObjDesc;
229     UINT32                  Display = DB_BYTE_DISPLAY;
230     char                    Buffer[80];
231     ACPI_BUFFER             RetBuf;
232     ACPI_STATUS             Status;
233     UINT32                  Size;
234
235
236     if (!Target)
237     {
238         return;
239     }
240
241     /* Decode the output type */
242
243     if (OutputType)
244     {
245         ACPI_STRUPR (OutputType);
246         if (OutputType[0] == 'W')
247         {
248             Display = DB_WORD_DISPLAY;
249         }
250         else if (OutputType[0] == 'D')
251         {
252             Display = DB_DWORD_DISPLAY;
253         }
254         else if (OutputType[0] == 'Q')
255         {
256             Display = DB_QWORD_DISPLAY;
257         }
258     }
259
260     RetBuf.Length = sizeof (Buffer);
261     RetBuf.Pointer = Buffer;
262
263     /* Differentiate between a number and a name */
264
265     if ((Target[0] >= 0x30) && (Target[0] <= 0x39))
266     {
267         ObjPtr = AcpiDbGetPointer (Target);
268         if (!AcpiOsReadable (ObjPtr, 16))
269         {
270             AcpiOsPrintf ("Address %p is invalid in this address space\n", ObjPtr);
271             return;
272         }
273
274         /* Decode the object type */
275
276         switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr))
277         {
278         case ACPI_DESC_TYPE_NAMED:
279
280             /* This is a namespace Node */
281
282             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE)))
283             {
284                 AcpiOsPrintf ("Cannot read entire Named object at address %p\n", ObjPtr);
285                 return;
286             }
287
288             Node = ObjPtr;
289             goto DumpNte;
290
291
292         case ACPI_DESC_TYPE_OPERAND:
293
294             /* This is a ACPI OPERAND OBJECT */
295
296             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT)))
297             {
298                 AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", ObjPtr);
299                 return;
300             }
301
302             AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX);
303             AcpiExDumpObjectDescriptor (ObjPtr, 1);
304             break;
305
306
307         case ACPI_DESC_TYPE_PARSER:
308
309             /* This is a Parser Op object */
310
311             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT)))
312             {
313                 AcpiOsPrintf ("Cannot read entire Parser object at address %p\n", ObjPtr);
314                 return;
315             }
316
317             AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, ACPI_UINT32_MAX);
318             AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr);
319             break;
320
321
322         default:
323
324             /* Is not a recognizeable object */
325
326             Size = 16;
327             if (AcpiOsReadable (ObjPtr, 64))
328             {
329                 Size = 64;
330             }
331
332             /* Just dump some memory */
333
334             AcpiUtDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX);
335             break;
336         }
337
338         return;
339     }
340
341     /* The parameter is a name string that must be resolved to a Named obj */
342
343     Node = AcpiDbLocalNsLookup (Target);
344     if (!Node)
345     {
346         return;
347     }
348
349
350 DumpNte:
351     /* Now dump the Named obj */
352
353     Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf);
354     if (ACPI_FAILURE (Status))
355     {
356         AcpiOsPrintf ("Could not convert name to pathname\n");
357     }
358
359     else
360     {
361         AcpiOsPrintf ("Object (%p) Pathname:  %s\n", Node, (char *) RetBuf.Pointer);
362     }
363
364     if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
365     {
366         AcpiOsPrintf ("Invalid Named object at address %p\n", Node);
367         return;
368     }
369
370     AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX);
371     AcpiExDumpNode (Node, 1);
372
373     ObjDesc = AcpiNsGetAttachedObject (Node);
374     if (ObjDesc)
375     {
376         AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc);
377         if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)))
378         {
379             AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", ObjDesc);
380             return;
381         }
382
383         AcpiUtDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX);
384         AcpiExDumpObjectDescriptor (ObjDesc, 1);
385     }
386 }
387
388
389 /*******************************************************************************
390  *
391  * FUNCTION:    AcpiDbDecodeInternalObject
392  *
393  * PARAMETERS:  ObjDesc         - Object to be displayed
394  *
395  * RETURN:      None
396  *
397  * DESCRIPTION: Short display of an internal object.  Numbers and Strings.
398  *
399  ******************************************************************************/
400
401 void
402 AcpiDbDecodeInternalObject (
403     ACPI_OPERAND_OBJECT     *ObjDesc)
404 {
405     UINT32                  i;
406
407
408     if (!ObjDesc)
409     {
410         AcpiOsPrintf (" Uninitialized");
411         return;
412     }
413
414     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
415     {
416         AcpiOsPrintf (" %p", ObjDesc);
417         return;
418     }
419
420     AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc));
421
422     switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
423     {
424     case ACPI_TYPE_INTEGER:
425
426         AcpiOsPrintf (" %8.8X%8.8X", ACPI_HIDWORD (ObjDesc->Integer.Value),
427                                      ACPI_LODWORD (ObjDesc->Integer.Value));
428         break;
429
430
431     case ACPI_TYPE_STRING:
432
433         AcpiOsPrintf ("(%d) \"%.24s",
434                 ObjDesc->String.Length, ObjDesc->String.Pointer);
435
436         if (ObjDesc->String.Length > 24)
437         {
438             AcpiOsPrintf ("...");
439         }
440         else
441         {
442             AcpiOsPrintf ("\"");
443         }
444         break;
445
446
447     case ACPI_TYPE_BUFFER:
448
449         AcpiOsPrintf ("(%d)", ObjDesc->Buffer.Length);
450         for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++)
451         {
452             AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]);
453         }
454         break;
455
456
457     default:
458
459         AcpiOsPrintf (" %p", ObjDesc);
460         break;
461     }
462 }
463
464
465 /*******************************************************************************
466  *
467  * FUNCTION:    AcpiDbDecodeNode
468  *
469  * PARAMETERS:  Node        - Object to be displayed
470  *
471  * RETURN:      None
472  *
473  * DESCRIPTION: Short display of a namespace node
474  *
475  ******************************************************************************/
476
477 void
478 AcpiDbDecodeNode (
479     ACPI_NAMESPACE_NODE     *Node)
480 {
481
482
483     AcpiOsPrintf ("<Node>            Name %4.4s",
484         Node->Name.Ascii);
485
486     if (Node->Flags & ANOBJ_METHOD_ARG)
487     {
488         AcpiOsPrintf (" [Method Arg]");
489     }
490     if (Node->Flags & ANOBJ_METHOD_LOCAL)
491     {
492         AcpiOsPrintf (" [Method Local]");
493     }
494
495     AcpiDbDecodeInternalObject (AcpiNsGetAttachedObject (Node));
496 }
497
498
499 /*******************************************************************************
500  *
501  * FUNCTION:    AcpiDbDisplayInternalObject
502  *
503  * PARAMETERS:  ObjDesc         - Object to be displayed
504  *              WalkState       - Current walk state
505  *
506  * RETURN:      None
507  *
508  * DESCRIPTION: Short display of an internal object
509  *
510  ******************************************************************************/
511
512 void
513 AcpiDbDisplayInternalObject (
514     ACPI_OPERAND_OBJECT     *ObjDesc,
515     ACPI_WALK_STATE         *WalkState)
516 {
517     UINT8                   Type;
518
519
520     AcpiOsPrintf ("%p ", ObjDesc);
521
522     if (!ObjDesc)
523     {
524         AcpiOsPrintf ("<NullObj>\n");
525         return;
526     }
527
528     /* Decode the object type */
529
530     switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
531     {
532     case ACPI_DESC_TYPE_PARSER:
533
534         AcpiOsPrintf ("<Parser>  ");
535         break;
536
537
538     case ACPI_DESC_TYPE_NAMED:
539
540         AcpiDbDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc);
541         break;
542
543
544     case ACPI_DESC_TYPE_OPERAND:
545
546         Type = ACPI_GET_OBJECT_TYPE (ObjDesc);
547         if (Type > ACPI_TYPE_LOCAL_MAX)
548         {
549             AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type);
550             return;
551         }
552
553         /* Decode the ACPI object type */
554
555         switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
556         {
557         case ACPI_TYPE_LOCAL_REFERENCE:
558
559             switch (ObjDesc->Reference.Opcode)
560             {
561             case AML_LOCAL_OP:
562
563                 AcpiOsPrintf ("[Local%d] ", ObjDesc->Reference.Offset);
564                 if (WalkState)
565                 {
566                     ObjDesc = WalkState->LocalVariables[ObjDesc->Reference.Offset].Object;
567                     AcpiOsPrintf ("%p", ObjDesc);
568                     AcpiDbDecodeInternalObject (ObjDesc);
569                 }
570                 break;
571
572
573             case AML_ARG_OP:
574
575                 AcpiOsPrintf ("[Arg%d]   ", ObjDesc->Reference.Offset);
576                 if (WalkState)
577                 {
578                     ObjDesc = WalkState->Arguments[ObjDesc->Reference.Offset].Object;
579                     AcpiOsPrintf ("%p", ObjDesc);
580                     AcpiDbDecodeInternalObject (ObjDesc);
581                 }
582                 break;
583
584
585             case AML_DEBUG_OP:
586
587                 AcpiOsPrintf ("[Debug]  ");
588                 break;
589
590
591             case AML_INDEX_OP:
592
593                 AcpiOsPrintf ("[Index]          ");
594                 if (!ObjDesc->Reference.Where)
595                 {
596                     AcpiOsPrintf ("Uninitialized WHERE ptr");
597                 }
598                 else
599                 {
600                     AcpiDbDecodeInternalObject (*(ObjDesc->Reference.Where));
601                 }
602                 break;
603
604
605             case AML_REF_OF_OP:
606
607                 AcpiOsPrintf ("[RefOf]          ");
608
609                 /* Reference can be to a Node or an Operand object */
610
611                 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object))
612                 {
613                 case ACPI_DESC_TYPE_NAMED:
614                     AcpiDbDecodeNode (ObjDesc->Reference.Object);
615                     break;
616
617                 case ACPI_DESC_TYPE_OPERAND:
618                     AcpiDbDecodeInternalObject (ObjDesc->Reference.Object);
619                     break;
620
621                 default:
622                     break;
623                 }
624                 break;
625
626
627             default:
628
629                 AcpiOsPrintf ("Unknown Reference opcode %X\n",
630                     ObjDesc->Reference.Opcode);
631                 break;
632             }
633             break;
634
635         default:
636
637             AcpiOsPrintf ("<Obj> ");
638             AcpiOsPrintf ("           ");
639             AcpiDbDecodeInternalObject (ObjDesc);
640             break;
641         }
642         break;
643
644
645     default:
646
647         AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> ");
648         break;
649     }
650
651     AcpiOsPrintf ("\n");
652 }
653
654
655 /*******************************************************************************
656  *
657  * FUNCTION:    AcpiDbDisplayMethodInfo
658  *
659  * PARAMETERS:  StartOp         - Root of the control method parse tree
660  *
661  * RETURN:      None
662  *
663  * DESCRIPTION: Display information about the current method
664  *
665  ******************************************************************************/
666
667 void
668 AcpiDbDisplayMethodInfo (
669     ACPI_PARSE_OBJECT       *StartOp)
670 {
671     ACPI_WALK_STATE         *WalkState;
672     ACPI_OPERAND_OBJECT     *ObjDesc;
673     ACPI_NAMESPACE_NODE     *Node;
674     ACPI_PARSE_OBJECT       *RootOp;
675     ACPI_PARSE_OBJECT       *Op;
676     const ACPI_OPCODE_INFO  *OpInfo;
677     UINT32                  NumOps = 0;
678     UINT32                  NumOperands = 0;
679     UINT32                  NumOperators = 0;
680     UINT32                  NumRemainingOps = 0;
681     UINT32                  NumRemainingOperands = 0;
682     UINT32                  NumRemainingOperators = 0;
683     UINT32                  NumArgs;
684     UINT32                  Concurrency;
685     BOOLEAN                 CountRemaining = FALSE;
686
687
688     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
689     if (!WalkState)
690     {
691         AcpiOsPrintf ("There is no method currently executing\n");
692         return;
693     }
694
695     ObjDesc = WalkState->MethodDesc;
696     Node    = WalkState->MethodNode;
697
698     NumArgs     = ObjDesc->Method.ParamCount;
699     Concurrency = ObjDesc->Method.Concurrency;
700
701     AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", Node->Name.Ascii);
702     AcpiOsPrintf ("%X arguments, max concurrency = %X\n", NumArgs, Concurrency);
703
704
705     RootOp = StartOp;
706     while (RootOp->Common.Parent)
707     {
708         RootOp = RootOp->Common.Parent;
709     }
710
711     Op = RootOp;
712
713     while (Op)
714     {
715         if (Op == StartOp)
716         {
717             CountRemaining = TRUE;
718         }
719
720         NumOps++;
721         if (CountRemaining)
722         {
723             NumRemainingOps++;
724         }
725
726         /* Decode the opcode */
727
728         OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
729         switch (OpInfo->Class)
730         {
731         case AML_CLASS_ARGUMENT:
732             if (CountRemaining)
733             {
734                 NumRemainingOperands++;
735             }
736
737             NumOperands++;
738             break;
739
740         case AML_CLASS_UNKNOWN:
741             /* Bad opcode or ASCII character */
742
743             continue;
744
745         default:
746             if (CountRemaining)
747             {
748                 NumRemainingOperators++;
749             }
750
751             NumOperators++;
752             break;
753         }
754
755         Op = AcpiPsGetDepthNext (StartOp, Op);
756     }
757
758     AcpiOsPrintf ("Method contains:       %X AML Opcodes - %X Operators, %X Operands\n",
759                 NumOps, NumOperators, NumOperands);
760
761     AcpiOsPrintf ("Remaining to execute:  %X AML Opcodes - %X Operators, %X Operands\n",
762                 NumRemainingOps, NumRemainingOperators, NumRemainingOperands);
763 }
764
765
766 /*******************************************************************************
767  *
768  * FUNCTION:    AcpiDbDisplayLocals
769  *
770  * PARAMETERS:  None
771  *
772  * RETURN:      None
773  *
774  * DESCRIPTION: Display all locals for the currently running control method
775  *
776  ******************************************************************************/
777
778 void
779 AcpiDbDisplayLocals (void)
780 {
781     UINT32                  i;
782     ACPI_WALK_STATE         *WalkState;
783     ACPI_OPERAND_OBJECT     *ObjDesc;
784     ACPI_NAMESPACE_NODE     *Node;
785
786
787     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
788     if (!WalkState)
789     {
790         AcpiOsPrintf ("There is no method currently executing\n");
791         return;
792     }
793
794     ObjDesc = WalkState->MethodDesc;
795     Node = WalkState->MethodNode;
796     if (!Node)
797     {
798         AcpiOsPrintf ("No method node (Executing subtree for buffer or opregion)\n");
799         return;
800     }
801
802     AcpiOsPrintf ("Local Variables for method [%4.4s]:\n", Node->Name.Ascii);
803
804     for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
805     {
806         ObjDesc = WalkState->LocalVariables[i].Object;
807         AcpiOsPrintf ("Local%d: ", i);
808         AcpiDbDisplayInternalObject (ObjDesc, WalkState);
809     }
810 }
811
812
813 /*******************************************************************************
814  *
815  * FUNCTION:    AcpiDbDisplayArguments
816  *
817  * PARAMETERS:  None
818  *
819  * RETURN:      None
820  *
821  * DESCRIPTION: Display all arguments for the currently running control method
822  *
823  ******************************************************************************/
824
825 void
826 AcpiDbDisplayArguments (void)
827 {
828     UINT32                  i;
829     ACPI_WALK_STATE         *WalkState;
830     ACPI_OPERAND_OBJECT     *ObjDesc;
831     UINT32                  NumArgs;
832     UINT32                  Concurrency;
833     ACPI_NAMESPACE_NODE     *Node;
834
835
836     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
837     if (!WalkState)
838     {
839         AcpiOsPrintf ("There is no method currently executing\n");
840         return;
841     }
842
843     ObjDesc = WalkState->MethodDesc;
844     Node    = WalkState->MethodNode;
845     if (!Node)
846     {
847         AcpiOsPrintf ("No method node (Executing subtree for buffer or opregion)\n");
848         return;
849     }
850
851     NumArgs     = ObjDesc->Method.ParamCount;
852     Concurrency = ObjDesc->Method.Concurrency;
853
854     AcpiOsPrintf ("Method [%4.4s] has %X arguments, max concurrency = %X\n",
855             Node->Name.Ascii, NumArgs, Concurrency);
856
857     for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
858     {
859         ObjDesc = WalkState->Arguments[i].Object;
860         AcpiOsPrintf ("Arg%d: ", i);
861         AcpiDbDisplayInternalObject (ObjDesc, WalkState);
862     }
863 }
864
865
866 /*******************************************************************************
867  *
868  * FUNCTION:    AcpiDbDisplayResults
869  *
870  * PARAMETERS:  None
871  *
872  * RETURN:      None
873  *
874  * DESCRIPTION: Display current contents of a method result stack
875  *
876  ******************************************************************************/
877
878 void
879 AcpiDbDisplayResults (void)
880 {
881     UINT32                  i;
882     ACPI_WALK_STATE         *WalkState;
883     ACPI_OPERAND_OBJECT     *ObjDesc;
884     UINT32                  NumResults = 0;
885     ACPI_NAMESPACE_NODE     *Node;
886
887
888     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
889     if (!WalkState)
890     {
891         AcpiOsPrintf ("There is no method currently executing\n");
892         return;
893     }
894
895     ObjDesc = WalkState->MethodDesc;
896     Node = WalkState->MethodNode;
897
898     if (WalkState->Results)
899     {
900         NumResults = WalkState->Results->Results.NumResults;
901     }
902
903     AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
904         Node->Name.Ascii, NumResults);
905
906     for (i = 0; i < NumResults; i++)
907     {
908         ObjDesc = WalkState->Results->Results.ObjDesc[i];
909         AcpiOsPrintf ("Result%d: ", i);
910         AcpiDbDisplayInternalObject (ObjDesc, WalkState);
911     }
912 }
913
914
915 /*******************************************************************************
916  *
917  * FUNCTION:    AcpiDbDisplayCallingTree
918  *
919  * PARAMETERS:  None
920  *
921  * RETURN:      None
922  *
923  * DESCRIPTION: Display current calling tree of nested control methods
924  *
925  ******************************************************************************/
926
927 void
928 AcpiDbDisplayCallingTree (void)
929 {
930     ACPI_WALK_STATE         *WalkState;
931     ACPI_NAMESPACE_NODE     *Node;
932
933
934     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
935     if (!WalkState)
936     {
937         AcpiOsPrintf ("There is no method currently executing\n");
938         return;
939     }
940
941     Node = WalkState->MethodNode;
942     AcpiOsPrintf ("Current Control Method Call Tree\n");
943
944     while (WalkState)
945     {
946         Node = WalkState->MethodNode;
947
948         AcpiOsPrintf ("    [%4.4s]\n", Node->Name.Ascii);
949
950         WalkState = WalkState->Next;
951     }
952 }
953
954
955 /*******************************************************************************
956  *
957  * FUNCTION:    AcpiDbDisplayResultObject
958  *
959  * PARAMETERS:  ObjDesc         - Object to be displayed
960  *              WalkState       - Current walk state
961  *
962  * RETURN:      None
963  *
964  * DESCRIPTION: Display the result of an AML opcode
965  *
966  * Note: Curently only displays the result object if we are single stepping.
967  * However, this output may be useful in other contexts and could be enabled
968  * to do so if needed.
969  *
970  ******************************************************************************/
971
972 void
973 AcpiDbDisplayResultObject (
974     ACPI_OPERAND_OBJECT     *ObjDesc,
975     ACPI_WALK_STATE         *WalkState)
976 {
977
978     /* Only display if single stepping */
979
980     if (!AcpiGbl_CmSingleStep)
981     {
982         return;
983     }
984
985     AcpiOsPrintf ("ResultObj: ");
986     AcpiDbDisplayInternalObject (ObjDesc, WalkState);
987     AcpiOsPrintf ("\n");
988 }
989
990
991 /*******************************************************************************
992  *
993  * FUNCTION:    AcpiDbDisplayArgumentObject
994  *
995  * PARAMETERS:  ObjDesc         - Object to be displayed
996  *              WalkState       - Current walk state
997  *
998  * RETURN:      None
999  *
1000  * DESCRIPTION: Display the result of an AML opcode
1001  *
1002  ******************************************************************************/
1003
1004 void
1005 AcpiDbDisplayArgumentObject (
1006     ACPI_OPERAND_OBJECT     *ObjDesc,
1007     ACPI_WALK_STATE         *WalkState)
1008 {
1009
1010     if (!AcpiGbl_CmSingleStep)
1011     {
1012         return;
1013     }
1014
1015     AcpiOsPrintf ("ArgObj:    ");
1016     AcpiDbDisplayInternalObject (ObjDesc, WalkState);
1017 }
1018
1019
1020 /*******************************************************************************
1021  *
1022  * FUNCTION:    AcpiDbDisplayGpes
1023  *
1024  * PARAMETERS:
1025  *
1026  * RETURN:      None
1027  *
1028  * DESCRIPTION: Display the GPE structures
1029  *
1030  ******************************************************************************/
1031
1032 void
1033 AcpiDbDisplayGpes (void)
1034 {
1035     ACPI_GPE_BLOCK_INFO     *GpeBlock;
1036     UINT32                  i = 0;
1037
1038
1039     GpeBlock = AcpiGbl_GpeBlockListHead;
1040     while (GpeBlock)
1041     {
1042         AcpiOsPrintf ("Block %d - %p\n", i, GpeBlock);
1043         AcpiOsPrintf ("    Registers:    %d\n", GpeBlock->RegisterCount);
1044         AcpiOsPrintf ("    GPE range:    %d to %d\n", GpeBlock->BlockBaseNumber,
1045                         GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8) -1);
1046         AcpiOsPrintf ("    RegisterInfo: %p\n", GpeBlock->RegisterInfo);
1047         AcpiOsPrintf ("    EventInfo:    %p\n", GpeBlock->EventInfo);
1048         i++;
1049
1050         GpeBlock = GpeBlock->Next;
1051     }
1052 }
1053
1054
1055 #endif /* ACPI_DEBUGGER */
1056