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