]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/dev/acpica/exdump.c
This commit was generated by cvs2svn to compensate for changes in r156952,
[FreeBSD/FreeBSD.git] / sys / contrib / dev / acpica / exdump.c
1 /******************************************************************************
2  *
3  * Module Name: exdump - Interpreter debug output routines
4  *              $Revision: 1.188 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2005, 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
117 #define __EXDUMP_C__
118
119 #include <contrib/dev/acpica/acpi.h>
120 #include <contrib/dev/acpica/acinterp.h>
121 #include <contrib/dev/acpica/amlcode.h>
122 #include <contrib/dev/acpica/acnamesp.h>
123 #include <contrib/dev/acpica/acparser.h>
124
125 #define _COMPONENT          ACPI_EXECUTER
126         ACPI_MODULE_NAME    ("exdump")
127
128 /*
129  * The following routines are used for debug output only
130  */
131 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
132
133 /* Local prototypes */
134
135 static void
136 AcpiExOutString (
137     char                    *Title,
138     char                    *Value);
139
140 static void
141 AcpiExOutPointer (
142     char                    *Title,
143     void                    *Value);
144
145 static void
146 AcpiExOutInteger (
147     char                    *Title,
148     UINT32                  Value);
149
150 static void
151 AcpiExOutAddress (
152     char                    *Title,
153     ACPI_PHYSICAL_ADDRESS   Value);
154
155 static void
156 AcpiExDumpReference (
157     ACPI_OPERAND_OBJECT     *ObjDesc);
158
159 static void
160 AcpiExDumpPackage (
161     ACPI_OPERAND_OBJECT     *ObjDesc,
162     UINT32                  Level,
163     UINT32                  Index);
164
165
166 /*******************************************************************************
167  *
168  * FUNCTION:    AcpiExDumpOperand
169  *
170  * PARAMETERS:  *ObjDesc        - Pointer to entry to be dumped
171  *              Depth           - Current nesting depth
172  *
173  * RETURN:      None
174  *
175  * DESCRIPTION: Dump an operand object
176  *
177  ******************************************************************************/
178
179 void
180 AcpiExDumpOperand (
181     ACPI_OPERAND_OBJECT     *ObjDesc,
182     UINT32                  Depth)
183 {
184     UINT32                  Length;
185     UINT32                  Index;
186
187
188     ACPI_FUNCTION_NAME ("ExDumpOperand")
189
190
191     if (!((ACPI_LV_EXEC & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
192     {
193         return;
194     }
195
196     if (!ObjDesc)
197     {
198         /* This could be a null element of a package */
199
200         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
201         return;
202     }
203
204     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
205     {
206         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc));
207         ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC);
208         return;
209     }
210
211     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
212     {
213         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
214             "%p is not a node or operand object: [%s]\n",
215             ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
216         ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT));
217         return;
218     }
219
220     /* ObjDesc is a valid object */
221
222     if (Depth > 0)
223     {
224         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ",
225             Depth, " ", Depth, ObjDesc));
226     }
227     else
228     {
229         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc));
230     }
231
232     /* Decode object type */
233
234     switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
235     {
236     case ACPI_TYPE_LOCAL_REFERENCE:
237
238         switch (ObjDesc->Reference.Opcode)
239         {
240         case AML_DEBUG_OP:
241
242             AcpiOsPrintf ("Reference: Debug\n");
243             break;
244
245
246         case AML_NAME_OP:
247
248             ACPI_DUMP_PATHNAME (ObjDesc->Reference.Object,
249                 "Reference: Name: ", ACPI_LV_INFO, _COMPONENT);
250             ACPI_DUMP_ENTRY (ObjDesc->Reference.Object, ACPI_LV_INFO);
251             break;
252
253
254         case AML_INDEX_OP:
255
256             AcpiOsPrintf ("Reference: Index %p\n",
257                 ObjDesc->Reference.Object);
258             break;
259
260
261         case AML_REF_OF_OP:
262
263             AcpiOsPrintf ("Reference: (RefOf) %p\n",
264                 ObjDesc->Reference.Object);
265             break;
266
267
268         case AML_ARG_OP:
269
270             AcpiOsPrintf ("Reference: Arg%d",
271                 ObjDesc->Reference.Offset);
272
273             if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
274             {
275                 /* Value is an Integer */
276
277                 AcpiOsPrintf (" value is [%8.8X%8.8x]",
278                     ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
279             }
280
281             AcpiOsPrintf ("\n");
282             break;
283
284
285         case AML_LOCAL_OP:
286
287             AcpiOsPrintf ("Reference: Local%d",
288                 ObjDesc->Reference.Offset);
289
290             if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
291             {
292
293                 /* Value is an Integer */
294
295                 AcpiOsPrintf (" value is [%8.8X%8.8x]",
296                     ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
297             }
298
299             AcpiOsPrintf ("\n");
300             break;
301
302
303         case AML_INT_NAMEPATH_OP:
304
305             AcpiOsPrintf ("Reference.Node->Name %X\n",
306                 ObjDesc->Reference.Node->Name.Integer);
307             break;
308
309
310         default:
311
312             /* Unknown opcode */
313
314             AcpiOsPrintf ("Unknown Reference opcode=%X\n",
315                 ObjDesc->Reference.Opcode);
316             break;
317
318         }
319         break;
320
321
322     case ACPI_TYPE_BUFFER:
323
324         AcpiOsPrintf ("Buffer len %X @ %p\n",
325             ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer);
326
327         Length = ObjDesc->Buffer.Length;
328         if (Length > 64)
329         {
330             Length = 64;
331         }
332
333         /* Debug only -- dump the buffer contents */
334
335         if (ObjDesc->Buffer.Pointer)
336         {
337             AcpiOsPrintf ("Buffer Contents: ");
338
339             for (Index = 0; Index < Length; Index++)
340             {
341                 AcpiOsPrintf (" %02x", ObjDesc->Buffer.Pointer[Index]);
342             }
343             AcpiOsPrintf ("\n");
344         }
345         break;
346
347
348     case ACPI_TYPE_INTEGER:
349
350         AcpiOsPrintf ("Integer %8.8X%8.8X\n",
351             ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
352         break;
353
354
355     case ACPI_TYPE_PACKAGE:
356
357         AcpiOsPrintf ("Package [Len %X] ElementArray %p\n",
358             ObjDesc->Package.Count, ObjDesc->Package.Elements);
359
360         /*
361          * If elements exist, package element pointer is valid,
362          * and debug_level exceeds 1, dump package's elements.
363          */
364         if (ObjDesc->Package.Count &&
365             ObjDesc->Package.Elements &&
366             AcpiDbgLevel > 1)
367         {
368             for (Index = 0; Index < ObjDesc->Package.Count; Index++)
369             {
370                 AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1);
371             }
372         }
373         break;
374
375
376     case ACPI_TYPE_REGION:
377
378         AcpiOsPrintf ("Region %s (%X)",
379             AcpiUtGetRegionName (ObjDesc->Region.SpaceId),
380             ObjDesc->Region.SpaceId);
381
382         /*
383          * If the address and length have not been evaluated,
384          * don't print them.
385          */
386         if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID))
387         {
388             AcpiOsPrintf ("\n");
389         }
390         else
391         {
392             AcpiOsPrintf (" base %8.8X%8.8X Length %X\n",
393                 ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
394                 ObjDesc->Region.Length);
395         }
396         break;
397
398
399     case ACPI_TYPE_STRING:
400
401         AcpiOsPrintf ("String length %X @ %p ",
402             ObjDesc->String.Length,
403             ObjDesc->String.Pointer);
404
405         AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
406         AcpiOsPrintf ("\n");
407         break;
408
409
410     case ACPI_TYPE_LOCAL_BANK_FIELD:
411
412         AcpiOsPrintf ("BankField\n");
413         break;
414
415
416     case ACPI_TYPE_LOCAL_REGION_FIELD:
417
418         AcpiOsPrintf (
419             "RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
420             ObjDesc->Field.BitLength,
421             ObjDesc->Field.AccessByteWidth,
422             ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK,
423             ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK,
424             ObjDesc->Field.BaseByteOffset,
425             ObjDesc->Field.StartFieldBitOffset);
426
427         AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1);
428         break;
429
430
431     case ACPI_TYPE_LOCAL_INDEX_FIELD:
432
433         AcpiOsPrintf ("IndexField\n");
434         break;
435
436
437     case ACPI_TYPE_BUFFER_FIELD:
438
439         AcpiOsPrintf (
440             "BufferField: %X bits at byte %X bit %X of\n",
441             ObjDesc->BufferField.BitLength,
442             ObjDesc->BufferField.BaseByteOffset,
443             ObjDesc->BufferField.StartFieldBitOffset);
444
445         if (!ObjDesc->BufferField.BufferObj)
446         {
447             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n"));
448         }
449         else if (ACPI_GET_OBJECT_TYPE (ObjDesc->BufferField.BufferObj) !=
450                     ACPI_TYPE_BUFFER)
451         {
452             AcpiOsPrintf ("*not a Buffer*\n");
453         }
454         else
455         {
456             AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1);
457         }
458         break;
459
460
461     case ACPI_TYPE_EVENT:
462
463         AcpiOsPrintf ("Event\n");
464         break;
465
466
467     case ACPI_TYPE_METHOD:
468
469         AcpiOsPrintf ("Method(%X) @ %p:%X\n",
470             ObjDesc->Method.ParamCount,
471             ObjDesc->Method.AmlStart,
472             ObjDesc->Method.AmlLength);
473         break;
474
475
476     case ACPI_TYPE_MUTEX:
477
478         AcpiOsPrintf ("Mutex\n");
479         break;
480
481
482     case ACPI_TYPE_DEVICE:
483
484         AcpiOsPrintf ("Device\n");
485         break;
486
487
488     case ACPI_TYPE_POWER:
489
490         AcpiOsPrintf ("Power\n");
491         break;
492
493
494     case ACPI_TYPE_PROCESSOR:
495
496         AcpiOsPrintf ("Processor\n");
497         break;
498
499
500     case ACPI_TYPE_THERMAL:
501
502         AcpiOsPrintf ("Thermal\n");
503         break;
504
505
506     default:
507         /* Unknown Type */
508
509         AcpiOsPrintf ("Unknown Type %X\n", ACPI_GET_OBJECT_TYPE (ObjDesc));
510         break;
511     }
512
513     return;
514 }
515
516
517 /*******************************************************************************
518  *
519  * FUNCTION:    AcpiExDumpOperands
520  *
521  * PARAMETERS:  Operands            - Operand list
522  *              InterpreterMode     - Load or Exec
523  *              Ident               - Identification
524  *              NumLevels           - # of stack entries to dump above line
525  *              Note                - Output notation
526  *              ModuleName          - Caller's module name
527  *              LineNumber          - Caller's invocation line number
528  *
529  * DESCRIPTION: Dump the object stack
530  *
531  ******************************************************************************/
532
533 void
534 AcpiExDumpOperands (
535     ACPI_OPERAND_OBJECT     **Operands,
536     ACPI_INTERPRETER_MODE   InterpreterMode,
537     char                    *Ident,
538     UINT32                  NumLevels,
539     char                    *Note,
540     char                    *ModuleName,
541     UINT32                  LineNumber)
542 {
543     ACPI_NATIVE_UINT        i;
544
545
546     ACPI_FUNCTION_NAME ("ExDumpOperands");
547
548
549     if (!Ident)
550     {
551         Ident = "?";
552     }
553
554     if (!Note)
555     {
556         Note = "?";
557     }
558
559     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
560         "************* Operand Stack Contents (Opcode [%s], %d Operands)\n",
561         Ident, NumLevels));
562
563     if (NumLevels == 0)
564     {
565         NumLevels = 1;
566     }
567
568     /* Dump the operand stack starting at the top */
569
570     for (i = 0; NumLevels > 0; i--, NumLevels--)
571     {
572         AcpiExDumpOperand (Operands[i], 0);
573     }
574
575     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
576         "************* Operand Stack dump from %s(%d), %s\n",
577         ModuleName, LineNumber, Note));
578     return;
579 }
580
581
582 /*******************************************************************************
583  *
584  * FUNCTION:    AcpiExOut* functions
585  *
586  * PARAMETERS:  Title               - Descriptive text
587  *              Value               - Value to be displayed
588  *
589  * DESCRIPTION: Object dump output formatting functions.  These functions
590  *              reduce the number of format strings required and keeps them
591  *              all in one place for easy modification.
592  *
593  ******************************************************************************/
594
595 static void
596 AcpiExOutString (
597     char                    *Title,
598     char                    *Value)
599 {
600     AcpiOsPrintf ("%20s : %s\n", Title, Value);
601 }
602
603 static void
604 AcpiExOutPointer (
605     char                    *Title,
606     void                    *Value)
607 {
608     AcpiOsPrintf ("%20s : %p\n", Title, Value);
609 }
610
611 static void
612 AcpiExOutInteger (
613     char                    *Title,
614     UINT32                  Value)
615 {
616     AcpiOsPrintf ("%20s : %.2X\n", Title, Value);
617 }
618
619 static void
620 AcpiExOutAddress (
621     char                    *Title,
622     ACPI_PHYSICAL_ADDRESS   Value)
623 {
624
625 #if ACPI_MACHINE_WIDTH == 16
626     AcpiOsPrintf ("%20s : %p\n", Title, Value);
627 #else
628     AcpiOsPrintf ("%20s : %8.8X%8.8X\n", Title, ACPI_FORMAT_UINT64 (Value));
629 #endif
630 }
631
632
633 /*******************************************************************************
634  *
635  * FUNCTION:    AcpiExDumpNode
636  *
637  * PARAMETERS:  *Node               - Descriptor to dump
638  *              Flags               - Force display if TRUE
639  *
640  * DESCRIPTION: Dumps the members of the given.Node
641  *
642  ******************************************************************************/
643
644 void
645 AcpiExDumpNode (
646     ACPI_NAMESPACE_NODE     *Node,
647     UINT32                  Flags)
648 {
649
650     ACPI_FUNCTION_ENTRY ();
651
652
653     if (!Flags)
654     {
655         if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
656         {
657             return;
658         }
659     }
660
661     AcpiOsPrintf ("%20s : %4.4s\n",       "Name", AcpiUtGetNodeName (Node));
662     AcpiExOutString  ("Type",             AcpiUtGetTypeName (Node->Type));
663     AcpiExOutInteger ("Flags",            Node->Flags);
664     AcpiExOutInteger ("Owner Id",         Node->OwnerId);
665     AcpiExOutInteger ("Reference Count",  Node->ReferenceCount);
666     AcpiExOutPointer ("Attached Object",  AcpiNsGetAttachedObject (Node));
667     AcpiExOutPointer ("ChildList",        Node->Child);
668     AcpiExOutPointer ("NextPeer",         Node->Peer);
669     AcpiExOutPointer ("Parent",           AcpiNsGetParentNode (Node));
670 }
671
672
673 /*******************************************************************************
674  *
675  * FUNCTION:    AcpiExDumpReference
676  *
677  * PARAMETERS:  Object              - Descriptor to dump
678  *
679  * DESCRIPTION: Dumps a reference object
680  *
681  ******************************************************************************/
682
683 static void
684 AcpiExDumpReference (
685     ACPI_OPERAND_OBJECT     *ObjDesc)
686 {
687     ACPI_BUFFER             RetBuf;
688     ACPI_STATUS             Status;
689
690
691     if (ObjDesc->Reference.Opcode == AML_INT_NAMEPATH_OP)
692     {
693         AcpiOsPrintf ("Named Object %p ", ObjDesc->Reference.Node);
694         RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
695         Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf);
696         if (ACPI_FAILURE (Status))
697         {
698             AcpiOsPrintf ("Could not convert name to pathname\n");
699         }
700         else
701         {
702            AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer);
703            ACPI_MEM_FREE (RetBuf.Pointer);
704         }
705     }
706     else if (ObjDesc->Reference.Object)
707     {
708         AcpiOsPrintf ("\nReferenced Object: %p\n", ObjDesc->Reference.Object);
709     }
710 }
711
712
713 /*******************************************************************************
714  *
715  * FUNCTION:    AcpiExDumpPackage
716  *
717  * PARAMETERS:  Object              - Descriptor to dump
718  *              Level               - Indentation Level
719  *              Index               - Package index for this object
720  *
721  * DESCRIPTION: Dumps the elements of the package
722  *
723  ******************************************************************************/
724
725 static void
726 AcpiExDumpPackage (
727     ACPI_OPERAND_OBJECT     *ObjDesc,
728     UINT32                  Level,
729     UINT32                  Index)
730 {
731     UINT32                  i;
732
733
734     /* Indentation and index output */
735
736     if (Level > 0)
737     {
738         for (i = 0; i < Level; i++)
739         {
740             AcpiOsPrintf ("  ");
741         }
742
743         AcpiOsPrintf ("[%.2d] ", Index);
744     }
745
746     AcpiOsPrintf ("%p ", ObjDesc);
747
748     /* Null package elements are allowed */
749
750     if (!ObjDesc)
751     {
752         AcpiOsPrintf ("[Null Object]\n");
753         return;
754     }
755
756     /* Packages may only contain a few object types */
757
758     switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
759     {
760     case ACPI_TYPE_INTEGER:
761
762         AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
763                     ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
764         break;
765
766
767     case ACPI_TYPE_STRING:
768
769         AcpiOsPrintf ("[String]  Value: ");
770         for (i = 0; i < ObjDesc->String.Length; i++)
771         {
772             AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]);
773         }
774         AcpiOsPrintf ("\n");
775         break;
776
777
778     case ACPI_TYPE_BUFFER:
779
780         AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length);
781         if (ObjDesc->Buffer.Length)
782         {
783             AcpiUtDumpBuffer ((UINT8 *) ObjDesc->Buffer.Pointer,
784                     ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT);
785         }
786         else
787         {
788             AcpiOsPrintf ("\n");
789         }
790         break;
791
792
793     case ACPI_TYPE_PACKAGE:
794
795         AcpiOsPrintf ("[Package] Contains %d Elements:\n",
796                 ObjDesc->Package.Count);
797
798         for (i = 0; i < ObjDesc->Package.Count; i++)
799         {
800             AcpiExDumpPackage (ObjDesc->Package.Elements[i], Level+1, i);
801         }
802         break;
803
804
805     case ACPI_TYPE_LOCAL_REFERENCE:
806
807         AcpiOsPrintf ("[Object Reference] ");
808         AcpiExDumpReference (ObjDesc);
809         break;
810
811
812     default:
813
814         AcpiOsPrintf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (ObjDesc));
815         break;
816     }
817 }
818
819
820 /*******************************************************************************
821  *
822  * FUNCTION:    AcpiExDumpObjectDescriptor
823  *
824  * PARAMETERS:  Object              - Descriptor to dump
825  *              Flags               - Force display if TRUE
826  *
827  * DESCRIPTION: Dumps the members of the object descriptor given.
828  *
829  ******************************************************************************/
830
831 void
832 AcpiExDumpObjectDescriptor (
833     ACPI_OPERAND_OBJECT     *ObjDesc,
834     UINT32                  Flags)
835 {
836     ACPI_FUNCTION_TRACE ("ExDumpObjectDescriptor");
837
838
839     if (!ObjDesc)
840     {
841         return_VOID;
842     }
843
844     if (!Flags)
845     {
846         if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
847         {
848             return_VOID;
849         }
850     }
851
852     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
853     {
854         AcpiExDumpNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags);
855         AcpiOsPrintf ("\nAttached Object (%p):\n",
856             ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object);
857         AcpiExDumpObjectDescriptor (
858             ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags);
859         return_VOID;
860     }
861
862     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
863     {
864         AcpiOsPrintf (
865             "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n",
866             ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
867         return_VOID;
868     }
869
870     /* Common Fields */
871
872     AcpiExOutString  ("Type",               AcpiUtGetObjectTypeName (ObjDesc));
873     AcpiExOutInteger ("Reference Count",    ObjDesc->Common.ReferenceCount);
874     AcpiExOutInteger ("Flags",              ObjDesc->Common.Flags);
875
876     /* Object-specific Fields */
877
878     switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
879     {
880     case ACPI_TYPE_INTEGER:
881
882         AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value",
883                 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
884         break;
885
886
887     case ACPI_TYPE_STRING:
888
889         AcpiExOutInteger ("Length",         ObjDesc->String.Length);
890
891         AcpiOsPrintf ("%20s : %p  ", "Pointer", ObjDesc->String.Pointer);
892         AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
893         AcpiOsPrintf ("\n");
894         break;
895
896
897     case ACPI_TYPE_BUFFER:
898
899         AcpiExOutInteger ("Length",         ObjDesc->Buffer.Length);
900         AcpiExOutPointer ("Pointer",        ObjDesc->Buffer.Pointer);
901         ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length);
902         break;
903
904
905     case ACPI_TYPE_PACKAGE:
906
907         AcpiExOutInteger ("Flags",          ObjDesc->Package.Flags);
908         AcpiExOutInteger ("Elements",       ObjDesc->Package.Count);
909         AcpiExOutPointer ("Element List",   ObjDesc->Package.Elements);
910
911         /* Dump the package contents */
912
913         AcpiOsPrintf ("\nPackage Contents:\n");
914         AcpiExDumpPackage (ObjDesc, 0, 0);
915         break;
916
917
918     case ACPI_TYPE_DEVICE:
919
920         AcpiExOutPointer ("Handler",        ObjDesc->Device.Handler);
921         AcpiExOutPointer ("SystemNotify",   ObjDesc->Device.SystemNotify);
922         AcpiExOutPointer ("DeviceNotify",   ObjDesc->Device.DeviceNotify);
923         break;
924
925
926     case ACPI_TYPE_EVENT:
927
928         AcpiExOutPointer ("Semaphore",      ObjDesc->Event.Semaphore);
929         break;
930
931
932     case ACPI_TYPE_METHOD:
933
934         AcpiExOutInteger ("ParamCount",     ObjDesc->Method.ParamCount);
935         AcpiExOutInteger ("Concurrency",    ObjDesc->Method.Concurrency);
936         AcpiExOutPointer ("Semaphore",      ObjDesc->Method.Semaphore);
937         AcpiExOutInteger ("OwnerId",        ObjDesc->Method.OwnerId);
938         AcpiExOutInteger ("AmlLength",      ObjDesc->Method.AmlLength);
939         AcpiExOutPointer ("AmlStart",       ObjDesc->Method.AmlStart);
940         break;
941
942
943     case ACPI_TYPE_MUTEX:
944
945         AcpiExOutInteger ("SyncLevel",      ObjDesc->Mutex.SyncLevel);
946         AcpiExOutPointer ("OwnerThread",    ObjDesc->Mutex.OwnerThread);
947         AcpiExOutInteger ("AcquireDepth",   ObjDesc->Mutex.AcquisitionDepth);
948         AcpiExOutPointer ("Semaphore",      ObjDesc->Mutex.Semaphore);
949         break;
950
951
952     case ACPI_TYPE_REGION:
953
954         AcpiExOutInteger ("SpaceId",        ObjDesc->Region.SpaceId);
955         AcpiExOutInteger ("Flags",          ObjDesc->Region.Flags);
956         AcpiExOutAddress ("Address",        ObjDesc->Region.Address);
957         AcpiExOutInteger ("Length",         ObjDesc->Region.Length);
958         AcpiExOutPointer ("Handler",        ObjDesc->Region.Handler);
959         AcpiExOutPointer ("Next",           ObjDesc->Region.Next);
960         break;
961
962
963     case ACPI_TYPE_POWER:
964
965         AcpiExOutInteger ("SystemLevel",    ObjDesc->PowerResource.SystemLevel);
966         AcpiExOutInteger ("ResourceOrder",  ObjDesc->PowerResource.ResourceOrder);
967         AcpiExOutPointer ("SystemNotify",   ObjDesc->PowerResource.SystemNotify);
968         AcpiExOutPointer ("DeviceNotify",   ObjDesc->PowerResource.DeviceNotify);
969         break;
970
971
972     case ACPI_TYPE_PROCESSOR:
973
974         AcpiExOutInteger ("Processor ID",   ObjDesc->Processor.ProcId);
975         AcpiExOutInteger ("Length",         ObjDesc->Processor.Length);
976         AcpiExOutAddress ("Address",        (ACPI_PHYSICAL_ADDRESS) ObjDesc->Processor.Address);
977         AcpiExOutPointer ("SystemNotify",   ObjDesc->Processor.SystemNotify);
978         AcpiExOutPointer ("DeviceNotify",   ObjDesc->Processor.DeviceNotify);
979         AcpiExOutPointer ("Handler",        ObjDesc->Processor.Handler);
980         break;
981
982
983     case ACPI_TYPE_THERMAL:
984
985         AcpiExOutPointer ("SystemNotify",   ObjDesc->ThermalZone.SystemNotify);
986         AcpiExOutPointer ("DeviceNotify",   ObjDesc->ThermalZone.DeviceNotify);
987         AcpiExOutPointer ("Handler",        ObjDesc->ThermalZone.Handler);
988         break;
989
990
991     case ACPI_TYPE_BUFFER_FIELD:
992     case ACPI_TYPE_LOCAL_REGION_FIELD:
993     case ACPI_TYPE_LOCAL_BANK_FIELD:
994     case ACPI_TYPE_LOCAL_INDEX_FIELD:
995
996         AcpiExOutInteger ("FieldFlags",     ObjDesc->CommonField.FieldFlags);
997         AcpiExOutInteger ("AccessByteWidth",ObjDesc->CommonField.AccessByteWidth);
998         AcpiExOutInteger ("BitLength",      ObjDesc->CommonField.BitLength);
999         AcpiExOutInteger ("FldBitOffset",   ObjDesc->CommonField.StartFieldBitOffset);
1000         AcpiExOutInteger ("BaseByteOffset", ObjDesc->CommonField.BaseByteOffset);
1001         AcpiExOutPointer ("ParentNode",     ObjDesc->CommonField.Node);
1002
1003         switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
1004         {
1005         case ACPI_TYPE_BUFFER_FIELD:
1006             AcpiExOutPointer ("BufferObj",  ObjDesc->BufferField.BufferObj);
1007             break;
1008
1009         case ACPI_TYPE_LOCAL_REGION_FIELD:
1010             AcpiExOutPointer ("RegionObj",  ObjDesc->Field.RegionObj);
1011             break;
1012
1013         case ACPI_TYPE_LOCAL_BANK_FIELD:
1014             AcpiExOutInteger ("Value",      ObjDesc->BankField.Value);
1015             AcpiExOutPointer ("RegionObj",  ObjDesc->BankField.RegionObj);
1016             AcpiExOutPointer ("BankObj",    ObjDesc->BankField.BankObj);
1017             break;
1018
1019         case ACPI_TYPE_LOCAL_INDEX_FIELD:
1020             AcpiExOutInteger ("Value",      ObjDesc->IndexField.Value);
1021             AcpiExOutPointer ("Index",      ObjDesc->IndexField.IndexObj);
1022             AcpiExOutPointer ("Data",       ObjDesc->IndexField.DataObj);
1023             break;
1024
1025         default:
1026             /* All object types covered above */
1027             break;
1028         }
1029         break;
1030
1031
1032     case ACPI_TYPE_LOCAL_REFERENCE:
1033
1034         AcpiExOutInteger ("TargetType",     ObjDesc->Reference.TargetType);
1035         AcpiExOutString  ("Opcode",         (AcpiPsGetOpcodeInfo (
1036                                              ObjDesc->Reference.Opcode))->Name);
1037         AcpiExOutInteger ("Offset",         ObjDesc->Reference.Offset);
1038         AcpiExOutPointer ("ObjDesc",        ObjDesc->Reference.Object);
1039         AcpiExOutPointer ("Node",           ObjDesc->Reference.Node);
1040         AcpiExOutPointer ("Where",          ObjDesc->Reference.Where);
1041
1042         AcpiExDumpReference (ObjDesc);
1043         break;
1044
1045
1046     case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:
1047
1048         AcpiExOutInteger ("SpaceId",        ObjDesc->AddressSpace.SpaceId);
1049         AcpiExOutPointer ("Next",           ObjDesc->AddressSpace.Next);
1050         AcpiExOutPointer ("RegionList",     ObjDesc->AddressSpace.RegionList);
1051         AcpiExOutPointer ("Node",           ObjDesc->AddressSpace.Node);
1052         AcpiExOutPointer ("Context",        ObjDesc->AddressSpace.Context);
1053         break;
1054
1055
1056     case ACPI_TYPE_LOCAL_NOTIFY:
1057
1058         AcpiExOutPointer ("Node",           ObjDesc->Notify.Node);
1059         AcpiExOutPointer ("Context",        ObjDesc->Notify.Context);
1060         break;
1061
1062
1063     case ACPI_TYPE_LOCAL_ALIAS:
1064     case ACPI_TYPE_LOCAL_METHOD_ALIAS:
1065     case ACPI_TYPE_LOCAL_EXTRA:
1066     case ACPI_TYPE_LOCAL_DATA:
1067     default:
1068
1069         AcpiOsPrintf (
1070             "ExDumpObjectDescriptor: Display not implemented for object type %s\n",
1071             AcpiUtGetObjectTypeName (ObjDesc));
1072         break;
1073     }
1074
1075     return_VOID;
1076 }
1077
1078 #endif
1079