exdump.c revision 193249
1/******************************************************************************
2 *
3 * Module Name: exdump - Interpreter debug output routines
4 *              $Revision: 1.202 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2007, 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
135static void
136AcpiExOutString (
137    char                    *Title,
138    char                    *Value);
139
140static void
141AcpiExOutPointer (
142    char                    *Title,
143    void                    *Value);
144
145static void
146AcpiExDumpObject (
147    ACPI_OPERAND_OBJECT     *ObjDesc,
148    ACPI_EXDUMP_INFO        *Info);
149
150static void
151AcpiExDumpReferenceObj (
152    ACPI_OPERAND_OBJECT     *ObjDesc);
153
154static void
155AcpiExDumpPackageObj (
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
170static 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
176static 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
184static 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
193static 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
202static 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
210static 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
216static ACPI_EXDUMP_INFO     AcpiExDumpMethod[8] =
217{
218    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod),         NULL},
219    {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.ParamCount),            "ParamCount"},
220    {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.SyncLevel),             "Sync Level"},
221    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Method.Mutex),                 "Mutex"},
222    {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.OwnerId),               "Owner Id"},
223    {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.ThreadCount),           "Thread Count"},
224    {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Method.AmlLength),             "Aml Length"},
225    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Method.AmlStart),              "Aml Start"}
226};
227
228static ACPI_EXDUMP_INFO     AcpiExDumpMutex[5] =
229{
230    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex),          NULL},
231    {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Mutex.SyncLevel),              "Sync Level"},
232    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Mutex.OwnerThread),            "Owner Thread"},
233    {ACPI_EXD_UINT16,   ACPI_EXD_OFFSET (Mutex.AcquisitionDepth),       "Acquire Depth"},
234    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Mutex.OsMutex),                "OsMutex"}
235};
236
237static ACPI_EXDUMP_INFO     AcpiExDumpRegion[7] =
238{
239    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpRegion),         NULL},
240    {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Region.SpaceId),               "Space Id"},
241    {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Region.Flags),                 "Flags"},
242    {ACPI_EXD_ADDRESS,  ACPI_EXD_OFFSET (Region.Address),               "Address"},
243    {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Region.Length),                "Length"},
244    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Region.Handler),               "Handler"},
245    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Region.Next),                  "Next"}
246};
247
248static ACPI_EXDUMP_INFO     AcpiExDumpPower[5] =
249{
250    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpPower),          NULL},
251    {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (PowerResource.SystemLevel),    "System Level"},
252    {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (PowerResource.ResourceOrder),  "Resource Order"},
253    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (PowerResource.SystemNotify),   "System Notify"},
254    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (PowerResource.DeviceNotify),   "Device Notify"}
255};
256
257static ACPI_EXDUMP_INFO     AcpiExDumpProcessor[7] =
258{
259    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpProcessor),      NULL},
260    {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Processor.ProcId),             "Processor ID"},
261    {ACPI_EXD_UINT8 ,   ACPI_EXD_OFFSET (Processor.Length),             "Length"},
262    {ACPI_EXD_ADDRESS,  ACPI_EXD_OFFSET (Processor.Address),            "Address"},
263    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Processor.SystemNotify),       "System Notify"},
264    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Processor.DeviceNotify),       "Device Notify"},
265    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Processor.Handler),            "Handler"}
266};
267
268static ACPI_EXDUMP_INFO     AcpiExDumpThermal[4] =
269{
270    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpThermal),        NULL},
271    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (ThermalZone.SystemNotify),     "System Notify"},
272    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (ThermalZone.DeviceNotify),     "Device Notify"},
273    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (ThermalZone.Handler),          "Handler"}
274};
275
276static ACPI_EXDUMP_INFO     AcpiExDumpBufferField[3] =
277{
278    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpBufferField),    NULL},
279    {ACPI_EXD_FIELD,    0,                                              NULL},
280    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (BufferField.BufferObj),        "Buffer Object"}
281};
282
283static ACPI_EXDUMP_INFO     AcpiExDumpRegionField[3] =
284{
285    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpRegionField),    NULL},
286    {ACPI_EXD_FIELD,    0,                                              NULL},
287    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Field.RegionObj),              "Region Object"}
288};
289
290static ACPI_EXDUMP_INFO     AcpiExDumpBankField[5] =
291{
292    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField),      NULL},
293    {ACPI_EXD_FIELD,    0,                                              NULL},
294    {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (BankField.Value),              "Value"},
295    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (BankField.RegionObj),          "Region Object"},
296    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (BankField.BankObj),            "Bank Object"}
297};
298
299static ACPI_EXDUMP_INFO     AcpiExDumpIndexField[5] =
300{
301    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField),      NULL},
302    {ACPI_EXD_FIELD,    0,                                              NULL},
303    {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (IndexField.Value),             "Value"},
304    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (IndexField.IndexObj),          "Index Object"},
305    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (IndexField.DataObj),           "Data Object"}
306};
307
308
309static ACPI_EXDUMP_INFO     AcpiExDumpReference[7] =
310{
311    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpReference),       NULL},
312    {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Reference.TargetType),         "Target Type"},
313    {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Reference.Offset),             "Offset"},
314    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Reference.Object),             "Object Desc"},
315    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Reference.Node),               "Node"},
316    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Reference.Where),              "Where"},
317    {ACPI_EXD_REFERENCE,0,                                              NULL}
318};
319
320static ACPI_EXDUMP_INFO     AcpiExDumpAddressHandler[6] =
321{
322    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpAddressHandler), NULL},
323    {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (AddressSpace.SpaceId),         "Space Id"},
324    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (AddressSpace.Next),            "Next"},
325    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (AddressSpace.RegionList),      "Region List"},
326    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (AddressSpace.Node),            "Node"},
327    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (AddressSpace.Context),         "Context"}
328};
329
330static ACPI_EXDUMP_INFO     AcpiExDumpNotify[3] =
331{
332    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpNotify),         NULL},
333    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Notify.Node),                  "Node"},
334    {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Notify.Context),               "Context"}
335};
336
337
338/* Miscellaneous tables */
339
340static ACPI_EXDUMP_INFO     AcpiExDumpCommon[4] =
341{
342    {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpCommon),         NULL},
343    {ACPI_EXD_TYPE ,    0,                                              NULL},
344    {ACPI_EXD_UINT16,   ACPI_EXD_OFFSET (Common.ReferenceCount),        "Reference Count"},
345    {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Common.Flags),                 "Flags"}
346};
347
348
349static 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
360static 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
372static 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
419static void
420AcpiExDumpObject (
421    ACPI_OPERAND_OBJECT     *ObjDesc,
422    ACPI_EXDUMP_INFO        *Info)
423{
424    UINT8                   *Target;
425    char                    *Name;
426    UINT8                   Count;
427
428
429    if (!Info)
430    {
431        AcpiOsPrintf (
432            "ExDumpObject: Display not implemented for object type %s\n",
433            AcpiUtGetObjectTypeName (ObjDesc));
434        return;
435    }
436
437    /* First table entry must contain the table length (# of table entries) */
438
439    Count = Info->Offset;
440
441    while (Count)
442    {
443        Target = ACPI_ADD_PTR (UINT8, ObjDesc, Info->Offset);
444        Name = Info->Name;
445
446        switch (Info->Opcode)
447        {
448        case ACPI_EXD_INIT:
449            break;
450
451        case ACPI_EXD_TYPE:
452            AcpiExOutString  ("Type", AcpiUtGetObjectTypeName (ObjDesc));
453            break;
454
455        case ACPI_EXD_UINT8:
456
457            AcpiOsPrintf ("%20s : %2.2X\n", Name, *Target);
458            break;
459
460        case ACPI_EXD_UINT16:
461
462            AcpiOsPrintf ("%20s : %4.4X\n", Name, ACPI_GET16 (Target));
463            break;
464
465        case ACPI_EXD_UINT32:
466
467            AcpiOsPrintf ("%20s : %8.8X\n", Name, ACPI_GET32 (Target));
468            break;
469
470        case ACPI_EXD_UINT64:
471
472            AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value",
473                    ACPI_FORMAT_UINT64 (ACPI_GET64 (Target)));
474            break;
475
476        case ACPI_EXD_POINTER:
477        case ACPI_EXD_ADDRESS:
478
479            AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target));
480            break;
481
482        case ACPI_EXD_STRING:
483
484            AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
485            AcpiOsPrintf ("\n");
486            break;
487
488        case ACPI_EXD_BUFFER:
489
490            ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length);
491            break;
492
493        case ACPI_EXD_PACKAGE:
494
495            /* Dump the package contents */
496
497            AcpiOsPrintf ("\nPackage Contents:\n");
498            AcpiExDumpPackageObj (ObjDesc, 0, 0);
499            break;
500
501        case ACPI_EXD_FIELD:
502
503            AcpiExDumpObject (ObjDesc, AcpiExDumpFieldCommon);
504            break;
505
506        case ACPI_EXD_REFERENCE:
507
508            AcpiExOutString ("Opcode",
509                (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name);
510            AcpiExDumpReferenceObj (ObjDesc);
511            break;
512
513        default:
514            AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", Info->Opcode);
515            return;
516        }
517
518        Info++;
519        Count--;
520    }
521}
522
523
524/*******************************************************************************
525 *
526 * FUNCTION:    AcpiExDumpOperand
527 *
528 * PARAMETERS:  *ObjDesc        - Pointer to entry to be dumped
529 *              Depth           - Current nesting depth
530 *
531 * RETURN:      None
532 *
533 * DESCRIPTION: Dump an operand object
534 *
535 ******************************************************************************/
536
537void
538AcpiExDumpOperand (
539    ACPI_OPERAND_OBJECT     *ObjDesc,
540    UINT32                  Depth)
541{
542    UINT32                  Length;
543    UINT32                  Index;
544
545
546    ACPI_FUNCTION_NAME (ExDumpOperand)
547
548
549    if (!((ACPI_LV_EXEC & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
550    {
551        return;
552    }
553
554    if (!ObjDesc)
555    {
556        /* This could be a null element of a package */
557
558        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
559        return;
560    }
561
562    if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
563    {
564        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc));
565        ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC);
566        return;
567    }
568
569    if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
570    {
571        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
572            "%p is not a node or operand object: [%s]\n",
573            ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
574        ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT));
575        return;
576    }
577
578    /* ObjDesc is a valid object */
579
580    if (Depth > 0)
581    {
582        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ",
583            Depth, " ", Depth, ObjDesc));
584    }
585    else
586    {
587        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc));
588    }
589
590    /* Decode object type */
591
592    switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
593    {
594    case ACPI_TYPE_LOCAL_REFERENCE:
595
596        switch (ObjDesc->Reference.Opcode)
597        {
598        case AML_DEBUG_OP:
599
600            AcpiOsPrintf ("Reference: Debug\n");
601            break;
602
603
604        case AML_INDEX_OP:
605
606            AcpiOsPrintf ("Reference: Index %p\n",
607                ObjDesc->Reference.Object);
608            break;
609
610
611        case AML_REF_OF_OP:
612
613            AcpiOsPrintf ("Reference: (RefOf) %p\n",
614                ObjDesc->Reference.Object);
615            break;
616
617
618        case AML_ARG_OP:
619
620            AcpiOsPrintf ("Reference: Arg%d",
621                ObjDesc->Reference.Offset);
622
623            if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
624            {
625                /* Value is an Integer */
626
627                AcpiOsPrintf (" value is [%8.8X%8.8x]",
628                    ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
629            }
630
631            AcpiOsPrintf ("\n");
632            break;
633
634
635        case AML_LOCAL_OP:
636
637            AcpiOsPrintf ("Reference: Local%d",
638                ObjDesc->Reference.Offset);
639
640            if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
641            {
642
643                /* Value is an Integer */
644
645                AcpiOsPrintf (" value is [%8.8X%8.8x]",
646                    ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
647            }
648
649            AcpiOsPrintf ("\n");
650            break;
651
652
653        case AML_INT_NAMEPATH_OP:
654
655            AcpiOsPrintf ("Reference.Node->Name %X\n",
656                ObjDesc->Reference.Node->Name.Integer);
657            break;
658
659
660        default:
661
662            /* Unknown opcode */
663
664            AcpiOsPrintf ("Unknown Reference opcode=%X\n",
665                ObjDesc->Reference.Opcode);
666            break;
667
668        }
669        break;
670
671
672    case ACPI_TYPE_BUFFER:
673
674        AcpiOsPrintf ("Buffer len %X @ %p\n",
675            ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer);
676
677        Length = ObjDesc->Buffer.Length;
678        if (Length > 64)
679        {
680            Length = 64;
681        }
682
683        /* Debug only -- dump the buffer contents */
684
685        if (ObjDesc->Buffer.Pointer)
686        {
687            AcpiOsPrintf ("Buffer Contents: ");
688
689            for (Index = 0; Index < Length; Index++)
690            {
691                AcpiOsPrintf (" %02x", ObjDesc->Buffer.Pointer[Index]);
692            }
693            AcpiOsPrintf ("\n");
694        }
695        break;
696
697
698    case ACPI_TYPE_INTEGER:
699
700        AcpiOsPrintf ("Integer %8.8X%8.8X\n",
701            ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
702        break;
703
704
705    case ACPI_TYPE_PACKAGE:
706
707        AcpiOsPrintf ("Package [Len %X] ElementArray %p\n",
708            ObjDesc->Package.Count, ObjDesc->Package.Elements);
709
710        /*
711         * If elements exist, package element pointer is valid,
712         * and debug_level exceeds 1, dump package's elements.
713         */
714        if (ObjDesc->Package.Count &&
715            ObjDesc->Package.Elements &&
716            AcpiDbgLevel > 1)
717        {
718            for (Index = 0; Index < ObjDesc->Package.Count; Index++)
719            {
720                AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1);
721            }
722        }
723        break;
724
725
726    case ACPI_TYPE_REGION:
727
728        AcpiOsPrintf ("Region %s (%X)",
729            AcpiUtGetRegionName (ObjDesc->Region.SpaceId),
730            ObjDesc->Region.SpaceId);
731
732        /*
733         * If the address and length have not been evaluated,
734         * don't print them.
735         */
736        if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID))
737        {
738            AcpiOsPrintf ("\n");
739        }
740        else
741        {
742            AcpiOsPrintf (" base %8.8X%8.8X Length %X\n",
743                ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
744                ObjDesc->Region.Length);
745        }
746        break;
747
748
749    case ACPI_TYPE_STRING:
750
751        AcpiOsPrintf ("String length %X @ %p ",
752            ObjDesc->String.Length,
753            ObjDesc->String.Pointer);
754
755        AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
756        AcpiOsPrintf ("\n");
757        break;
758
759
760    case ACPI_TYPE_LOCAL_BANK_FIELD:
761
762        AcpiOsPrintf ("BankField\n");
763        break;
764
765
766    case ACPI_TYPE_LOCAL_REGION_FIELD:
767
768        AcpiOsPrintf (
769            "RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
770            ObjDesc->Field.BitLength,
771            ObjDesc->Field.AccessByteWidth,
772            ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK,
773            ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK,
774            ObjDesc->Field.BaseByteOffset,
775            ObjDesc->Field.StartFieldBitOffset);
776
777        AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1);
778        break;
779
780
781    case ACPI_TYPE_LOCAL_INDEX_FIELD:
782
783        AcpiOsPrintf ("IndexField\n");
784        break;
785
786
787    case ACPI_TYPE_BUFFER_FIELD:
788
789        AcpiOsPrintf (
790            "BufferField: %X bits at byte %X bit %X of\n",
791            ObjDesc->BufferField.BitLength,
792            ObjDesc->BufferField.BaseByteOffset,
793            ObjDesc->BufferField.StartFieldBitOffset);
794
795        if (!ObjDesc->BufferField.BufferObj)
796        {
797            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n"));
798        }
799        else if (ACPI_GET_OBJECT_TYPE (ObjDesc->BufferField.BufferObj) !=
800                    ACPI_TYPE_BUFFER)
801        {
802            AcpiOsPrintf ("*not a Buffer*\n");
803        }
804        else
805        {
806            AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1);
807        }
808        break;
809
810
811    case ACPI_TYPE_EVENT:
812
813        AcpiOsPrintf ("Event\n");
814        break;
815
816
817    case ACPI_TYPE_METHOD:
818
819        AcpiOsPrintf ("Method(%X) @ %p:%X\n",
820            ObjDesc->Method.ParamCount,
821            ObjDesc->Method.AmlStart,
822            ObjDesc->Method.AmlLength);
823        break;
824
825
826    case ACPI_TYPE_MUTEX:
827
828        AcpiOsPrintf ("Mutex\n");
829        break;
830
831
832    case ACPI_TYPE_DEVICE:
833
834        AcpiOsPrintf ("Device\n");
835        break;
836
837
838    case ACPI_TYPE_POWER:
839
840        AcpiOsPrintf ("Power\n");
841        break;
842
843
844    case ACPI_TYPE_PROCESSOR:
845
846        AcpiOsPrintf ("Processor\n");
847        break;
848
849
850    case ACPI_TYPE_THERMAL:
851
852        AcpiOsPrintf ("Thermal\n");
853        break;
854
855
856    default:
857        /* Unknown Type */
858
859        AcpiOsPrintf ("Unknown Type %X\n", ACPI_GET_OBJECT_TYPE (ObjDesc));
860        break;
861    }
862
863    return;
864}
865
866
867/*******************************************************************************
868 *
869 * FUNCTION:    AcpiExDumpOperands
870 *
871 * PARAMETERS:  Operands            - Operand list
872 *              InterpreterMode     - Load or Exec
873 *              Ident               - Identification
874 *              NumLevels           - # of stack entries to dump above line
875 *              Note                - Output notation
876 *              ModuleName          - Caller's module name
877 *              LineNumber          - Caller's invocation line number
878 *
879 * DESCRIPTION: Dump the object stack
880 *
881 ******************************************************************************/
882
883void
884AcpiExDumpOperands (
885    ACPI_OPERAND_OBJECT     **Operands,
886    ACPI_INTERPRETER_MODE   InterpreterMode,
887    char                    *Ident,
888    UINT32                  NumLevels,
889    char                    *Note,
890    char                    *ModuleName,
891    UINT32                  LineNumber)
892{
893    ACPI_NATIVE_UINT        i;
894
895
896    ACPI_FUNCTION_NAME (ExDumpOperands);
897
898
899    if (!Ident)
900    {
901        Ident = "?";
902    }
903
904    if (!Note)
905    {
906        Note = "?";
907    }
908
909    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
910        "************* Operand Stack Contents (Opcode [%s], %d Operands)\n",
911        Ident, NumLevels));
912
913    if (NumLevels == 0)
914    {
915        NumLevels = 1;
916    }
917
918    /* Dump the operand stack starting at the top */
919
920    for (i = 0; NumLevels > 0; i--, NumLevels--)
921    {
922        AcpiExDumpOperand (Operands[i], 0);
923    }
924
925    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
926        "************* Operand Stack dump from %s(%d), %s\n",
927        ModuleName, LineNumber, Note));
928    return;
929}
930
931
932/*******************************************************************************
933 *
934 * FUNCTION:    AcpiExOut* functions
935 *
936 * PARAMETERS:  Title               - Descriptive text
937 *              Value               - Value to be displayed
938 *
939 * DESCRIPTION: Object dump output formatting functions.  These functions
940 *              reduce the number of format strings required and keeps them
941 *              all in one place for easy modification.
942 *
943 ******************************************************************************/
944
945static void
946AcpiExOutString (
947    char                    *Title,
948    char                    *Value)
949{
950    AcpiOsPrintf ("%20s : %s\n", Title, Value);
951}
952
953static void
954AcpiExOutPointer (
955    char                    *Title,
956    void                    *Value)
957{
958    AcpiOsPrintf ("%20s : %p\n", Title, Value);
959}
960
961
962/*******************************************************************************
963 *
964 * FUNCTION:    AcpiExDumpNamespaceNode
965 *
966 * PARAMETERS:  Node                - Descriptor to dump
967 *              Flags               - Force display if TRUE
968 *
969 * DESCRIPTION: Dumps the members of the given.Node
970 *
971 ******************************************************************************/
972
973void
974AcpiExDumpNamespaceNode (
975    ACPI_NAMESPACE_NODE     *Node,
976    UINT32                  Flags)
977{
978
979    ACPI_FUNCTION_ENTRY ();
980
981
982    if (!Flags)
983    {
984        if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
985        {
986            return;
987        }
988    }
989
990    AcpiOsPrintf ("%20s : %4.4s\n",       "Name", AcpiUtGetNodeName (Node));
991    AcpiExOutString  ("Type",             AcpiUtGetTypeName (Node->Type));
992    AcpiExOutPointer ("Attached Object",  AcpiNsGetAttachedObject (Node));
993    AcpiExOutPointer ("Parent",           AcpiNsGetParentNode (Node));
994
995    AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node),
996        AcpiExDumpNode);
997}
998
999
1000/*******************************************************************************
1001 *
1002 * FUNCTION:    AcpiExDumpReferenceObj
1003 *
1004 * PARAMETERS:  Object              - Descriptor to dump
1005 *
1006 * DESCRIPTION: Dumps a reference object
1007 *
1008 ******************************************************************************/
1009
1010static void
1011AcpiExDumpReferenceObj (
1012    ACPI_OPERAND_OBJECT     *ObjDesc)
1013{
1014    ACPI_BUFFER             RetBuf;
1015    ACPI_STATUS             Status;
1016
1017
1018    RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1019
1020    if (ObjDesc->Reference.Opcode == AML_INT_NAMEPATH_OP)
1021    {
1022        AcpiOsPrintf ("Named Object %p ", ObjDesc->Reference.Node);
1023
1024        Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf);
1025        if (ACPI_FAILURE (Status))
1026        {
1027            AcpiOsPrintf ("Could not convert name to pathname\n");
1028        }
1029        else
1030        {
1031           AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer);
1032           ACPI_FREE (RetBuf.Pointer);
1033        }
1034    }
1035    else if (ObjDesc->Reference.Object)
1036    {
1037        AcpiOsPrintf ("\nReferenced Object: %p\n", ObjDesc->Reference.Object);
1038    }
1039}
1040
1041
1042/*******************************************************************************
1043 *
1044 * FUNCTION:    AcpiExDumpPackageObj
1045 *
1046 * PARAMETERS:  ObjDesc             - Descriptor to dump
1047 *              Level               - Indentation Level
1048 *              Index               - Package index for this object
1049 *
1050 * DESCRIPTION: Dumps the elements of the package
1051 *
1052 ******************************************************************************/
1053
1054static void
1055AcpiExDumpPackageObj (
1056    ACPI_OPERAND_OBJECT     *ObjDesc,
1057    UINT32                  Level,
1058    UINT32                  Index)
1059{
1060    UINT32                  i;
1061
1062
1063    /* Indentation and index output */
1064
1065    if (Level > 0)
1066    {
1067        for (i = 0; i < Level; i++)
1068        {
1069            AcpiOsPrintf ("  ");
1070        }
1071
1072        AcpiOsPrintf ("[%.2d] ", Index);
1073    }
1074
1075    AcpiOsPrintf ("%p ", ObjDesc);
1076
1077    /* Null package elements are allowed */
1078
1079    if (!ObjDesc)
1080    {
1081        AcpiOsPrintf ("[Null Object]\n");
1082        return;
1083    }
1084
1085    /* Packages may only contain a few object types */
1086
1087    switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
1088    {
1089    case ACPI_TYPE_INTEGER:
1090
1091        AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
1092                    ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
1093        break;
1094
1095
1096    case ACPI_TYPE_STRING:
1097
1098        AcpiOsPrintf ("[String]  Value: ");
1099        for (i = 0; i < ObjDesc->String.Length; i++)
1100        {
1101            AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]);
1102        }
1103        AcpiOsPrintf ("\n");
1104        break;
1105
1106
1107    case ACPI_TYPE_BUFFER:
1108
1109        AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length);
1110        if (ObjDesc->Buffer.Length)
1111        {
1112            AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
1113                    ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT);
1114        }
1115        else
1116        {
1117            AcpiOsPrintf ("\n");
1118        }
1119        break;
1120
1121
1122    case ACPI_TYPE_PACKAGE:
1123
1124        AcpiOsPrintf ("[Package] Contains %d Elements:\n",
1125                ObjDesc->Package.Count);
1126
1127        for (i = 0; i < ObjDesc->Package.Count; i++)
1128        {
1129            AcpiExDumpPackageObj (ObjDesc->Package.Elements[i], Level+1, i);
1130        }
1131        break;
1132
1133
1134    case ACPI_TYPE_LOCAL_REFERENCE:
1135
1136        AcpiOsPrintf ("[Object Reference] ");
1137        AcpiExDumpReferenceObj (ObjDesc);
1138        break;
1139
1140
1141    default:
1142
1143        AcpiOsPrintf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (ObjDesc));
1144        break;
1145    }
1146}
1147
1148
1149/*******************************************************************************
1150 *
1151 * FUNCTION:    AcpiExDumpObjectDescriptor
1152 *
1153 * PARAMETERS:  ObjDesc             - Descriptor to dump
1154 *              Flags               - Force display if TRUE
1155 *
1156 * DESCRIPTION: Dumps the members of the object descriptor given.
1157 *
1158 ******************************************************************************/
1159
1160void
1161AcpiExDumpObjectDescriptor (
1162    ACPI_OPERAND_OBJECT     *ObjDesc,
1163    UINT32                  Flags)
1164{
1165    ACPI_FUNCTION_TRACE (ExDumpObjectDescriptor);
1166
1167
1168    if (!ObjDesc)
1169    {
1170        return_VOID;
1171    }
1172
1173    if (!Flags)
1174    {
1175        if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
1176        {
1177            return_VOID;
1178        }
1179    }
1180
1181    if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
1182    {
1183        AcpiExDumpNamespaceNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags);
1184
1185        AcpiOsPrintf ("\nAttached Object (%p):\n",
1186            ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object);
1187
1188        AcpiExDumpObjectDescriptor (
1189            ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags);
1190        return_VOID;
1191    }
1192
1193    if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
1194    {
1195        AcpiOsPrintf (
1196            "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n",
1197            ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
1198        return_VOID;
1199    }
1200
1201    if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX)
1202    {
1203        return_VOID;
1204    }
1205
1206    /* Common Fields */
1207
1208    AcpiExDumpObject (ObjDesc, AcpiExDumpCommon);
1209
1210    /* Object-specific fields */
1211
1212    AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]);
1213    return_VOID;
1214}
1215
1216#endif
1217
1218