Fix numerous compiler warnings and format conversion specifiers.
[dragonfly.git] / sys / contrib / dev / acpica-unix / executer / exdump.c
1 /******************************************************************************
2  *
3  * Module Name: exdump - Interpreter debug output routines
4  *
5  *****************************************************************************/
6
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights.  You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code.  No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision.  In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change.  Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee.  Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution.  In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government.  In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************/
115
116 #define __EXDUMP_C__
117
118 #include "acpi.h"
119 #include "accommon.h"
120 #include "acinterp.h"
121 #include "amlcode.h"
122 #include "acnamesp.h"
123
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 AcpiExDumpObject (
147     ACPI_OPERAND_OBJECT     *ObjDesc,
148     ACPI_EXDUMP_INFO        *Info);
149
150 static void
151 AcpiExDumpReferenceObj (
152     ACPI_OPERAND_OBJECT     *ObjDesc);
153
154 static void
155 AcpiExDumpPackageObj (
156     ACPI_OPERAND_OBJECT     *ObjDesc,
157     UINT32                  Level,
158     UINT32                  Index);
159
160
161 /*******************************************************************************
162  *
163  * Object Descriptor info tables
164  *
165  * Note: The first table entry must be an INIT opcode and must contain
166  * the table length (number of table entries)
167  *
168  ******************************************************************************/
169
170 static ACPI_EXDUMP_INFO     AcpiExDumpInteger[2] =
171 {
172     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpInteger),        NULL},
173     {ACPI_EXD_UINT64,   ACPI_EXD_OFFSET (Integer.Value),                "Value"}
174 };
175
176 static ACPI_EXDUMP_INFO     AcpiExDumpString[4] =
177 {
178     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpString),         NULL},
179     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (String.Length),                "Length"},
180     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (String.Pointer),               "Pointer"},
181     {ACPI_EXD_STRING,   0,                                              NULL}
182 };
183
184 static ACPI_EXDUMP_INFO     AcpiExDumpBuffer[5] =
185 {
186     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpBuffer),         NULL},
187     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Buffer.Length),                "Length"},
188     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Buffer.Pointer),               "Pointer"},
189     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Buffer.Node),                  "Parent Node"},
190     {ACPI_EXD_BUFFER,   0,                                              NULL}
191 };
192
193 static ACPI_EXDUMP_INFO     AcpiExDumpPackage[5] =
194 {
195     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpPackage),        NULL},
196     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Package.Flags),                "Flags"},
197     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Package.Count),                "Elements"},
198     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Package.Elements),             "Element List"},
199     {ACPI_EXD_PACKAGE,  0,                                              NULL}
200 };
201
202 static ACPI_EXDUMP_INFO     AcpiExDumpDevice[4] =
203 {
204     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpDevice),         NULL},
205     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Device.Handler),               "Handler"},
206     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Device.SystemNotify),          "System Notify"},
207     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Device.DeviceNotify),          "Device Notify"}
208 };
209
210 static ACPI_EXDUMP_INFO     AcpiExDumpEvent[2] =
211 {
212     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpEvent),          NULL},
213     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Event.OsSemaphore),            "OsSemaphore"}
214 };
215
216 static ACPI_EXDUMP_INFO     AcpiExDumpMethod[9] =
217 {
218     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod),         NULL},
219     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.MethodFlags),           "Method Flags"},
220     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.ParamCount),            "Parameter Count"},
221     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.SyncLevel),             "Sync Level"},
222     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Method.Mutex),                 "Mutex"},
223     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.OwnerId),               "Owner Id"},
224     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.ThreadCount),           "Thread Count"},
225     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Method.AmlLength),             "Aml Length"},
226     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Method.AmlStart),              "Aml Start"}
227 };
228
229 static ACPI_EXDUMP_INFO     AcpiExDumpMutex[5] =
230 {
231     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex),          NULL},
232     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Mutex.SyncLevel),              "Sync Level"},
233     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Mutex.OwnerThread),            "Owner Thread"},
234     {ACPI_EXD_UINT16,   ACPI_EXD_OFFSET (Mutex.AcquisitionDepth),       "Acquire Depth"},
235     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Mutex.OsMutex),                "OsMutex"}
236 };
237
238 static ACPI_EXDUMP_INFO     AcpiExDumpRegion[7] =
239 {
240     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpRegion),         NULL},
241     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Region.SpaceId),               "Space Id"},
242     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Region.Flags),                 "Flags"},
243     {ACPI_EXD_ADDRESS,  ACPI_EXD_OFFSET (Region.Address),               "Address"},
244     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Region.Length),                "Length"},
245     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Region.Handler),               "Handler"},
246     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Region.Next),                  "Next"}
247 };
248
249 static ACPI_EXDUMP_INFO     AcpiExDumpPower[5] =
250 {
251     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpPower),          NULL},
252     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (PowerResource.SystemLevel),    "System Level"},
253     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (PowerResource.ResourceOrder),  "Resource Order"},
254     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (PowerResource.SystemNotify),   "System Notify"},
255     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (PowerResource.DeviceNotify),   "Device Notify"}
256 };
257
258 static ACPI_EXDUMP_INFO     AcpiExDumpProcessor[7] =
259 {
260     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpProcessor),      NULL},
261     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Processor.ProcId),             "Processor ID"},
262     {ACPI_EXD_UINT8 ,   ACPI_EXD_OFFSET (Processor.Length),             "Length"},
263     {ACPI_EXD_ADDRESS,  ACPI_EXD_OFFSET (Processor.Address),            "Address"},
264     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Processor.SystemNotify),       "System Notify"},
265     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Processor.DeviceNotify),       "Device Notify"},
266     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Processor.Handler),            "Handler"}
267 };
268
269 static ACPI_EXDUMP_INFO     AcpiExDumpThermal[4] =
270 {
271     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpThermal),        NULL},
272     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (ThermalZone.SystemNotify),     "System Notify"},
273     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (ThermalZone.DeviceNotify),     "Device Notify"},
274     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (ThermalZone.Handler),          "Handler"}
275 };
276
277 static ACPI_EXDUMP_INFO     AcpiExDumpBufferField[3] =
278 {
279     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpBufferField),    NULL},
280     {ACPI_EXD_FIELD,    0,                                              NULL},
281     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (BufferField.BufferObj),        "Buffer Object"}
282 };
283
284 static ACPI_EXDUMP_INFO     AcpiExDumpRegionField[3] =
285 {
286     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpRegionField),    NULL},
287     {ACPI_EXD_FIELD,    0,                                              NULL},
288     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Field.RegionObj),              "Region Object"}
289 };
290
291 static ACPI_EXDUMP_INFO     AcpiExDumpBankField[5] =
292 {
293     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField),      NULL},
294     {ACPI_EXD_FIELD,    0,                                              NULL},
295     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (BankField.Value),              "Value"},
296     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (BankField.RegionObj),          "Region Object"},
297     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (BankField.BankObj),            "Bank Object"}
298 };
299
300 static ACPI_EXDUMP_INFO     AcpiExDumpIndexField[5] =
301 {
302     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField),      NULL},
303     {ACPI_EXD_FIELD,    0,                                              NULL},
304     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (IndexField.Value),             "Value"},
305     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (IndexField.IndexObj),          "Index Object"},
306     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (IndexField.DataObj),           "Data Object"}
307 };
308
309 static ACPI_EXDUMP_INFO     AcpiExDumpReference[8] =
310 {
311     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpReference),       NULL},
312     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Reference.Class),              "Class"},
313     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Reference.TargetType),         "Target Type"},
314     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Reference.Value),              "Value"},
315     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Reference.Object),             "Object Desc"},
316     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Reference.Node),               "Node"},
317     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Reference.Where),              "Where"},
318     {ACPI_EXD_REFERENCE,0,                                              NULL}
319 };
320
321 static ACPI_EXDUMP_INFO     AcpiExDumpAddressHandler[6] =
322 {
323     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpAddressHandler), NULL},
324     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (AddressSpace.SpaceId),         "Space Id"},
325     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (AddressSpace.Next),            "Next"},
326     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (AddressSpace.RegionList),      "Region List"},
327     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (AddressSpace.Node),            "Node"},
328     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (AddressSpace.Context),         "Context"}
329 };
330
331 static ACPI_EXDUMP_INFO     AcpiExDumpNotify[3] =
332 {
333     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpNotify),         NULL},
334     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Notify.Node),                  "Node"},
335     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Notify.Context),               "Context"}
336 };
337
338
339 /* Miscellaneous tables */
340
341 static ACPI_EXDUMP_INFO     AcpiExDumpCommon[4] =
342 {
343     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpCommon),         NULL},
344     {ACPI_EXD_TYPE ,    0,                                              NULL},
345     {ACPI_EXD_UINT16,   ACPI_EXD_OFFSET (Common.ReferenceCount),        "Reference Count"},
346     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Common.Flags),                 "Flags"}
347 };
348
349 static ACPI_EXDUMP_INFO     AcpiExDumpFieldCommon[7] =
350 {
351     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpFieldCommon),    NULL},
352     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (CommonField.FieldFlags),       "Field Flags"},
353     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (CommonField.AccessByteWidth),  "Access Byte Width"},
354     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (CommonField.BitLength),        "Bit Length"},
355     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (CommonField.StartFieldBitOffset),"Field Bit Offset"},
356     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (CommonField.BaseByteOffset),   "Base Byte Offset"},
357     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (CommonField.Node),             "Parent Node"}
358 };
359
360 static ACPI_EXDUMP_INFO     AcpiExDumpNode[5] =
361 {
362     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpNode),           NULL},
363     {ACPI_EXD_UINT8,    ACPI_EXD_NSOFFSET (Flags),                      "Flags"},
364     {ACPI_EXD_UINT8,    ACPI_EXD_NSOFFSET (OwnerId),                    "Owner Id"},
365     {ACPI_EXD_POINTER,  ACPI_EXD_NSOFFSET (Child),                      "Child List"},
366     {ACPI_EXD_POINTER,  ACPI_EXD_NSOFFSET (Peer),                       "Next Peer"}
367 };
368
369
370 /* Dispatch table, indexed by object type */
371
372 static ACPI_EXDUMP_INFO     *AcpiExDumpInfo[] =
373 {
374     NULL,
375     AcpiExDumpInteger,
376     AcpiExDumpString,
377     AcpiExDumpBuffer,
378     AcpiExDumpPackage,
379     NULL,
380     AcpiExDumpDevice,
381     AcpiExDumpEvent,
382     AcpiExDumpMethod,
383     AcpiExDumpMutex,
384     AcpiExDumpRegion,
385     AcpiExDumpPower,
386     AcpiExDumpProcessor,
387     AcpiExDumpThermal,
388     AcpiExDumpBufferField,
389     NULL,
390     NULL,
391     AcpiExDumpRegionField,
392     AcpiExDumpBankField,
393     AcpiExDumpIndexField,
394     AcpiExDumpReference,
395     NULL,
396     NULL,
397     AcpiExDumpNotify,
398     AcpiExDumpAddressHandler,
399     NULL,
400     NULL,
401     NULL
402 };
403
404
405 /*******************************************************************************
406  *
407  * FUNCTION:    AcpiExDumpObject
408  *
409  * PARAMETERS:  ObjDesc             - Descriptor to dump
410  *              Info                - Info table corresponding to this object
411  *                                    type
412  *
413  * RETURN:      None
414  *
415  * DESCRIPTION: Walk the info table for this object
416  *
417  ******************************************************************************/
418
419 static void
420 AcpiExDumpObject (
421     ACPI_OPERAND_OBJECT     *ObjDesc,
422     ACPI_EXDUMP_INFO        *Info)
423 {
424     UINT8                   *Target;
425     char                    *Name;
426     UINT8                   Count;
427     const char              *str;
428
429
430     if (!Info)
431     {
432         AcpiOsPrintf (
433             "ExDumpObject: Display not implemented for object type %s\n",
434             AcpiUtGetObjectTypeName (ObjDesc));
435         return;
436     }
437
438     /* First table entry must contain the table length (# of table entries) */
439
440     Count = Info->Offset;
441
442     while (Count)
443     {
444         Target = ACPI_ADD_PTR (UINT8, ObjDesc, Info->Offset);
445         Name = Info->Name;
446
447         switch (Info->Opcode)
448         {
449         case ACPI_EXD_INIT:
450             break;
451
452         case ACPI_EXD_TYPE:
453
454             AcpiExOutString  ("Type", AcpiUtGetObjectTypeName (ObjDesc));
455             break;
456
457         case ACPI_EXD_UINT8:
458
459             AcpiOsPrintf ("%20s : %2.2X\n", Name, *Target);
460             break;
461
462         case ACPI_EXD_UINT16:
463
464             AcpiOsPrintf ("%20s : %4.4X\n", Name, ACPI_GET16 (Target));
465             break;
466
467         case ACPI_EXD_UINT32:
468
469             AcpiOsPrintf ("%20s : %8.8X\n", Name, ACPI_GET32 (Target));
470             break;
471
472         case ACPI_EXD_UINT64:
473
474             AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value",
475                 ACPI_FORMAT_UINT64 (ACPI_GET64 (Target)));
476             break;
477
478         case ACPI_EXD_POINTER:
479         case ACPI_EXD_ADDRESS:
480
481             AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target));
482             break;
483
484         case ACPI_EXD_STRING:
485
486             AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
487             AcpiOsPrintf ("\n");
488             break;
489
490         case ACPI_EXD_BUFFER:
491
492             ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length);
493             break;
494
495         case ACPI_EXD_PACKAGE:
496
497             /* Dump the package contents */
498
499             AcpiOsPrintf ("\nPackage Contents:\n");
500             AcpiExDumpPackageObj (ObjDesc, 0, 0);
501             break;
502
503         case ACPI_EXD_FIELD:
504
505             AcpiExDumpObject (ObjDesc, AcpiExDumpFieldCommon);
506             break;
507
508         case ACPI_EXD_REFERENCE:
509
510             str = AcpiUtGetReferenceName (ObjDesc);
511             AcpiExOutString ("Class Name", __DECONST(char *, str));
512             AcpiExDumpReferenceObj (ObjDesc);
513             break;
514
515         default:
516
517             AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
518                 Info->Opcode);
519             return;
520         }
521
522         Info++;
523         Count--;
524     }
525 }
526
527
528 /*******************************************************************************
529  *
530  * FUNCTION:    AcpiExDumpOperand
531  *
532  * PARAMETERS:  *ObjDesc        - Pointer to entry to be dumped
533  *              Depth           - Current nesting depth
534  *
535  * RETURN:      None
536  *
537  * DESCRIPTION: Dump an operand object
538  *
539  ******************************************************************************/
540
541 void
542 AcpiExDumpOperand (
543     ACPI_OPERAND_OBJECT     *ObjDesc,
544     UINT32                  Depth)
545 {
546     UINT32                  Length;
547     UINT32                  Index;
548
549
550     ACPI_FUNCTION_NAME (ExDumpOperand)
551
552
553     if (!((ACPI_LV_EXEC & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
554     {
555         return;
556     }
557
558     if (!ObjDesc)
559     {
560         /* This could be a null element of a package */
561
562         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
563         return;
564     }
565
566     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
567     {
568         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc));
569         ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC);
570         return;
571     }
572
573     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
574     {
575         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
576             "%p is not a node or operand object: [%s]\n",
577             ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
578         ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT));
579         return;
580     }
581
582     /* ObjDesc is a valid object */
583
584     if (Depth > 0)
585     {
586         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ",
587             Depth, " ", Depth, ObjDesc));
588     }
589     else
590     {
591         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc));
592     }
593
594     /* Decode object type */
595
596     switch (ObjDesc->Common.Type)
597     {
598     case ACPI_TYPE_LOCAL_REFERENCE:
599
600         AcpiOsPrintf ("Reference: [%s] ", AcpiUtGetReferenceName (ObjDesc));
601
602         switch (ObjDesc->Reference.Class)
603         {
604         case ACPI_REFCLASS_DEBUG:
605
606             AcpiOsPrintf ("\n");
607             break;
608
609
610         case ACPI_REFCLASS_INDEX:
611
612             AcpiOsPrintf ("%p\n", ObjDesc->Reference.Object);
613             break;
614
615
616         case ACPI_REFCLASS_TABLE:
617
618             AcpiOsPrintf ("Table Index %X\n", ObjDesc->Reference.Value);
619             break;
620
621
622         case ACPI_REFCLASS_REFOF:
623
624             AcpiOsPrintf ("%p [%s]\n", ObjDesc->Reference.Object,
625                 AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)
626                     ObjDesc->Reference.Object)->Common.Type));
627             break;
628
629
630         case ACPI_REFCLASS_NAME:
631
632             AcpiOsPrintf ("- [%4.4s]\n", ObjDesc->Reference.Node->Name.Ascii);
633             break;
634
635
636         case ACPI_REFCLASS_ARG:
637         case ACPI_REFCLASS_LOCAL:
638
639             AcpiOsPrintf ("%X\n", ObjDesc->Reference.Value);
640             break;
641
642
643         default:    /* Unknown reference class */
644
645             AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class);
646             break;
647         }
648         break;
649
650
651     case ACPI_TYPE_BUFFER:
652
653         AcpiOsPrintf ("Buffer length %.2X @ %p\n",
654             ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer);
655
656         /* Debug only -- dump the buffer contents */
657
658         if (ObjDesc->Buffer.Pointer)
659         {
660             Length = ObjDesc->Buffer.Length;
661             if (Length > 128)
662             {
663                 Length = 128;
664             }
665
666             AcpiOsPrintf ("Buffer Contents: (displaying length 0x%.2X)\n",
667                 Length);
668             ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length);
669         }
670         break;
671
672
673     case ACPI_TYPE_INTEGER:
674
675         AcpiOsPrintf ("Integer %8.8X%8.8X\n",
676             ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
677         break;
678
679
680     case ACPI_TYPE_PACKAGE:
681
682         AcpiOsPrintf ("Package [Len %X] ElementArray %p\n",
683             ObjDesc->Package.Count, ObjDesc->Package.Elements);
684
685         /*
686          * If elements exist, package element pointer is valid,
687          * and debug_level exceeds 1, dump package's elements.
688          */
689         if (ObjDesc->Package.Count &&
690             ObjDesc->Package.Elements &&
691             AcpiDbgLevel > 1)
692         {
693             for (Index = 0; Index < ObjDesc->Package.Count; Index++)
694             {
695                 AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1);
696             }
697         }
698         break;
699
700
701     case ACPI_TYPE_REGION:
702
703         AcpiOsPrintf ("Region %s (%X)",
704             AcpiUtGetRegionName (ObjDesc->Region.SpaceId),
705             ObjDesc->Region.SpaceId);
706
707         /*
708          * If the address and length have not been evaluated,
709          * don't print them.
710          */
711         if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID))
712         {
713             AcpiOsPrintf ("\n");
714         }
715         else
716         {
717             AcpiOsPrintf (" base %8.8X%8.8X Length %X\n",
718                 ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
719                 ObjDesc->Region.Length);
720         }
721         break;
722
723
724     case ACPI_TYPE_STRING:
725
726         AcpiOsPrintf ("String length %X @ %p ",
727             ObjDesc->String.Length,
728             ObjDesc->String.Pointer);
729
730         AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
731         AcpiOsPrintf ("\n");
732         break;
733
734
735     case ACPI_TYPE_LOCAL_BANK_FIELD:
736
737         AcpiOsPrintf ("BankField\n");
738         break;
739
740
741     case ACPI_TYPE_LOCAL_REGION_FIELD:
742
743         AcpiOsPrintf ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at "
744             "byte=%X bit=%X of below:\n",
745             ObjDesc->Field.BitLength,
746             ObjDesc->Field.AccessByteWidth,
747             ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK,
748             ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK,
749             ObjDesc->Field.BaseByteOffset,
750             ObjDesc->Field.StartFieldBitOffset);
751
752         AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1);
753         break;
754
755
756     case ACPI_TYPE_LOCAL_INDEX_FIELD:
757
758         AcpiOsPrintf ("IndexField\n");
759         break;
760
761
762     case ACPI_TYPE_BUFFER_FIELD:
763
764         AcpiOsPrintf ("BufferField: %X bits at byte %X bit %X of\n",
765             ObjDesc->BufferField.BitLength,
766             ObjDesc->BufferField.BaseByteOffset,
767             ObjDesc->BufferField.StartFieldBitOffset);
768
769         if (!ObjDesc->BufferField.BufferObj)
770         {
771             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n"));
772         }
773         else if ((ObjDesc->BufferField.BufferObj)->Common.Type !=
774                     ACPI_TYPE_BUFFER)
775         {
776             AcpiOsPrintf ("*not a Buffer*\n");
777         }
778         else
779         {
780             AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1);
781         }
782         break;
783
784
785     case ACPI_TYPE_EVENT:
786
787         AcpiOsPrintf ("Event\n");
788         break;
789
790
791     case ACPI_TYPE_METHOD:
792
793         AcpiOsPrintf ("Method(%X) @ %p:%X\n",
794             ObjDesc->Method.ParamCount,
795             ObjDesc->Method.AmlStart,
796             ObjDesc->Method.AmlLength);
797         break;
798
799
800     case ACPI_TYPE_MUTEX:
801
802         AcpiOsPrintf ("Mutex\n");
803         break;
804
805
806     case ACPI_TYPE_DEVICE:
807
808         AcpiOsPrintf ("Device\n");
809         break;
810
811
812     case ACPI_TYPE_POWER:
813
814         AcpiOsPrintf ("Power\n");
815         break;
816
817
818     case ACPI_TYPE_PROCESSOR:
819
820         AcpiOsPrintf ("Processor\n");
821         break;
822
823
824     case ACPI_TYPE_THERMAL:
825
826         AcpiOsPrintf ("Thermal\n");
827         break;
828
829
830     default:
831         /* Unknown Type */
832
833         AcpiOsPrintf ("Unknown Type %X\n", ObjDesc->Common.Type);
834         break;
835     }
836
837     return;
838 }
839
840
841 /*******************************************************************************
842  *
843  * FUNCTION:    AcpiExDumpOperands
844  *
845  * PARAMETERS:  Operands            - A list of Operand objects
846  *              OpcodeName          - AML opcode name
847  *              NumOperands         - Operand count for this opcode
848  *
849  * DESCRIPTION: Dump the operands associated with the opcode
850  *
851  ******************************************************************************/
852
853 void
854 AcpiExDumpOperands (
855     ACPI_OPERAND_OBJECT     **Operands,
856     const char              *OpcodeName,
857     UINT32                  NumOperands)
858 {
859     ACPI_FUNCTION_NAME (ExDumpOperands);
860
861
862     if (!OpcodeName)
863     {
864         OpcodeName = "UNKNOWN";
865     }
866
867     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
868         "**** Start operand dump for opcode [%s], %d operands\n",
869         OpcodeName, NumOperands));
870
871     if (NumOperands == 0)
872     {
873         NumOperands = 1;
874     }
875
876     /* Dump the individual operands */
877
878     while (NumOperands)
879     {
880         AcpiExDumpOperand (*Operands, 0);
881         Operands++;
882         NumOperands--;
883     }
884
885     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
886         "**** End operand dump for [%s]\n", OpcodeName));
887     return;
888 }
889
890
891 /*******************************************************************************
892  *
893  * FUNCTION:    AcpiExOut* functions
894  *
895  * PARAMETERS:  Title               - Descriptive text
896  *              Value               - Value to be displayed
897  *
898  * DESCRIPTION: Object dump output formatting functions.  These functions
899  *              reduce the number of format strings required and keeps them
900  *              all in one place for easy modification.
901  *
902  ******************************************************************************/
903
904 static void
905 AcpiExOutString (
906     char                    *Title,
907     char                    *Value)
908 {
909     AcpiOsPrintf ("%20s : %s\n", Title, Value);
910 }
911
912 static void
913 AcpiExOutPointer (
914     char                    *Title,
915     void                    *Value)
916 {
917     AcpiOsPrintf ("%20s : %p\n", Title, Value);
918 }
919
920
921 /*******************************************************************************
922  *
923  * FUNCTION:    AcpiExDumpNamespaceNode
924  *
925  * PARAMETERS:  Node                - Descriptor to dump
926  *              Flags               - Force display if TRUE
927  *
928  * DESCRIPTION: Dumps the members of the given.Node
929  *
930  ******************************************************************************/
931
932 void
933 AcpiExDumpNamespaceNode (
934     ACPI_NAMESPACE_NODE     *Node,
935     UINT32                  Flags)
936 {
937
938     ACPI_FUNCTION_ENTRY ();
939
940
941     if (!Flags)
942     {
943         if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
944         {
945             return;
946         }
947     }
948
949     AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node));
950     AcpiExOutString  ("Type", AcpiUtGetTypeName (Node->Type));
951     AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node));
952     AcpiExOutPointer ("Parent", AcpiNsGetParentNode (Node));
953
954     AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node),
955         AcpiExDumpNode);
956 }
957
958
959 /*******************************************************************************
960  *
961  * FUNCTION:    AcpiExDumpReferenceObj
962  *
963  * PARAMETERS:  Object              - Descriptor to dump
964  *
965  * DESCRIPTION: Dumps a reference object
966  *
967  ******************************************************************************/
968
969 static void
970 AcpiExDumpReferenceObj (
971     ACPI_OPERAND_OBJECT     *ObjDesc)
972 {
973     ACPI_BUFFER             RetBuf;
974     ACPI_STATUS             Status;
975
976
977     RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
978
979     if (ObjDesc->Reference.Class == ACPI_REFCLASS_NAME)
980     {
981         AcpiOsPrintf (" %p ", ObjDesc->Reference.Node);
982
983         Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf);
984         if (ACPI_FAILURE (Status))
985         {
986             AcpiOsPrintf (" Could not convert name to pathname\n");
987         }
988         else
989         {
990            AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer);
991            ACPI_FREE (RetBuf.Pointer);
992         }
993     }
994     else if (ObjDesc->Reference.Object)
995     {
996         if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)
997         {
998             AcpiOsPrintf (" Target: %p", ObjDesc->Reference.Object);
999             if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE)
1000             {
1001                 AcpiOsPrintf (" Table Index: %X\n", ObjDesc->Reference.Value);
1002             }
1003             else
1004             {
1005                 AcpiOsPrintf (" Target: %p [%s]\n", ObjDesc->Reference.Object,
1006                     AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)
1007                         ObjDesc->Reference.Object)->Common.Type));
1008             }
1009         }
1010         else
1011         {
1012             AcpiOsPrintf (" Target: %p\n", ObjDesc->Reference.Object);
1013         }
1014     }
1015 }
1016
1017
1018 /*******************************************************************************
1019  *
1020  * FUNCTION:    AcpiExDumpPackageObj
1021  *
1022  * PARAMETERS:  ObjDesc             - Descriptor to dump
1023  *              Level               - Indentation Level
1024  *              Index               - Package index for this object
1025  *
1026  * DESCRIPTION: Dumps the elements of the package
1027  *
1028  ******************************************************************************/
1029
1030 static void
1031 AcpiExDumpPackageObj (
1032     ACPI_OPERAND_OBJECT     *ObjDesc,
1033     UINT32                  Level,
1034     UINT32                  Index)
1035 {
1036     UINT32                  i;
1037
1038
1039     /* Indentation and index output */
1040
1041     if (Level > 0)
1042     {
1043         for (i = 0; i < Level; i++)
1044         {
1045             AcpiOsPrintf ("  ");
1046         }
1047
1048         AcpiOsPrintf ("[%.2d] ", Index);
1049     }
1050
1051     AcpiOsPrintf ("%p ", ObjDesc);
1052
1053     /* Null package elements are allowed */
1054
1055     if (!ObjDesc)
1056     {
1057         AcpiOsPrintf ("[Null Object]\n");
1058         return;
1059     }
1060
1061     /* Packages may only contain a few object types */
1062
1063     switch (ObjDesc->Common.Type)
1064     {
1065     case ACPI_TYPE_INTEGER:
1066
1067         AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
1068             ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
1069         break;
1070
1071
1072     case ACPI_TYPE_STRING:
1073
1074         AcpiOsPrintf ("[String]  Value: ");
1075         for (i = 0; i < ObjDesc->String.Length; i++)
1076         {
1077             AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]);
1078         }
1079         AcpiOsPrintf ("\n");
1080         break;
1081
1082
1083     case ACPI_TYPE_BUFFER:
1084
1085         AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length);
1086         if (ObjDesc->Buffer.Length)
1087         {
1088             AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
1089                 ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT);
1090         }
1091         else
1092         {
1093             AcpiOsPrintf ("\n");
1094         }
1095         break;
1096
1097
1098     case ACPI_TYPE_PACKAGE:
1099
1100         AcpiOsPrintf ("[Package] Contains %d Elements:\n",
1101             ObjDesc->Package.Count);
1102
1103         for (i = 0; i < ObjDesc->Package.Count; i++)
1104         {
1105             AcpiExDumpPackageObj (ObjDesc->Package.Elements[i], Level+1, i);
1106         }
1107         break;
1108
1109
1110     case ACPI_TYPE_LOCAL_REFERENCE:
1111
1112         AcpiOsPrintf ("[Object Reference] Type [%s] %2.2X",
1113             AcpiUtGetReferenceName (ObjDesc),
1114             ObjDesc->Reference.Class);
1115         AcpiExDumpReferenceObj (ObjDesc);
1116         break;
1117
1118
1119     default:
1120
1121         AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Common.Type);
1122         break;
1123     }
1124 }
1125
1126
1127 /*******************************************************************************
1128  *
1129  * FUNCTION:    AcpiExDumpObjectDescriptor
1130  *
1131  * PARAMETERS:  ObjDesc             - Descriptor to dump
1132  *              Flags               - Force display if TRUE
1133  *
1134  * DESCRIPTION: Dumps the members of the object descriptor given.
1135  *
1136  ******************************************************************************/
1137
1138 void
1139 AcpiExDumpObjectDescriptor (
1140     ACPI_OPERAND_OBJECT     *ObjDesc,
1141     UINT32                  Flags)
1142 {
1143     ACPI_FUNCTION_TRACE (ExDumpObjectDescriptor);
1144
1145
1146     if (!ObjDesc)
1147     {
1148         return_VOID;
1149     }
1150
1151     if (!Flags)
1152     {
1153         if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
1154         {
1155             return_VOID;
1156         }
1157     }
1158
1159     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
1160     {
1161         AcpiExDumpNamespaceNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags);
1162
1163         AcpiOsPrintf ("\nAttached Object (%p):\n",
1164             ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object);
1165
1166         AcpiExDumpObjectDescriptor (
1167             ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags);
1168         return_VOID;
1169     }
1170
1171     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
1172     {
1173         AcpiOsPrintf (
1174             "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n",
1175             ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
1176         return_VOID;
1177     }
1178
1179     if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX)
1180     {
1181         return_VOID;
1182     }
1183
1184     /* Common Fields */
1185
1186     AcpiExDumpObject (ObjDesc, AcpiExDumpCommon);
1187
1188     /* Object-specific fields */
1189
1190     AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]);
1191     return_VOID;
1192 }
1193
1194 #endif
1195