xref: /freebsd/sys/contrib/dev/acpica/components/executer/exdump.c (revision 4657548d18877f64bd02be888406aa5b02bf9b06)
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 - 2017, 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  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151 
152 #include <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/acinterp.h>
155 #include <contrib/dev/acpica/include/amlcode.h>
156 #include <contrib/dev/acpica/include/acnamesp.h>
157 
158 
159 #define _COMPONENT          ACPI_EXECUTER
160         ACPI_MODULE_NAME    ("exdump")
161 
162 /*
163  * The following routines are used for debug output only
164  */
165 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
166 
167 /* Local prototypes */
168 
169 static void
170 AcpiExOutString (
171     const char              *Title,
172     const char              *Value);
173 
174 static void
175 AcpiExOutPointer (
176     const char              *Title,
177     const void              *Value);
178 
179 static void
180 AcpiExDumpObject (
181     ACPI_OPERAND_OBJECT     *ObjDesc,
182     ACPI_EXDUMP_INFO        *Info);
183 
184 static void
185 AcpiExDumpReferenceObj (
186     ACPI_OPERAND_OBJECT     *ObjDesc);
187 
188 static void
189 AcpiExDumpPackageObj (
190     ACPI_OPERAND_OBJECT     *ObjDesc,
191     UINT32                  Level,
192     UINT32                  Index);
193 
194 
195 /*******************************************************************************
196  *
197  * Object Descriptor info tables
198  *
199  * Note: The first table entry must be an INIT opcode and must contain
200  * the table length (number of table entries)
201  *
202  ******************************************************************************/
203 
204 static ACPI_EXDUMP_INFO     AcpiExDumpInteger[2] =
205 {
206     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpInteger),        NULL},
207     {ACPI_EXD_UINT64,   ACPI_EXD_OFFSET (Integer.Value),                "Value"}
208 };
209 
210 static ACPI_EXDUMP_INFO     AcpiExDumpString[4] =
211 {
212     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpString),         NULL},
213     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (String.Length),                "Length"},
214     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (String.Pointer),               "Pointer"},
215     {ACPI_EXD_STRING,   0,                                              NULL}
216 };
217 
218 static ACPI_EXDUMP_INFO     AcpiExDumpBuffer[5] =
219 {
220     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpBuffer),         NULL},
221     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Buffer.Length),                "Length"},
222     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Buffer.Pointer),               "Pointer"},
223     {ACPI_EXD_NODE,     ACPI_EXD_OFFSET (Buffer.Node),                  "Parent Node"},
224     {ACPI_EXD_BUFFER,   0,                                              NULL}
225 };
226 
227 static ACPI_EXDUMP_INFO     AcpiExDumpPackage[6] =
228 {
229     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpPackage),        NULL},
230     {ACPI_EXD_NODE,     ACPI_EXD_OFFSET (Package.Node),                 "Parent Node"},
231     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Package.Flags),                "Flags"},
232     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Package.Count),                "Elements"},
233     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Package.Elements),             "Element List"},
234     {ACPI_EXD_PACKAGE,  0,                                              NULL}
235 };
236 
237 static ACPI_EXDUMP_INFO     AcpiExDumpDevice[4] =
238 {
239     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpDevice),         NULL},
240     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Device.NotifyList[0]),         "System Notify"},
241     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Device.NotifyList[1]),         "Device Notify"},
242     {ACPI_EXD_HDLR_LIST,ACPI_EXD_OFFSET (Device.Handler),               "Handler"}
243 };
244 
245 static ACPI_EXDUMP_INFO     AcpiExDumpEvent[2] =
246 {
247     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpEvent),          NULL},
248     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Event.OsSemaphore),            "OsSemaphore"}
249 };
250 
251 static ACPI_EXDUMP_INFO     AcpiExDumpMethod[9] =
252 {
253     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod),         NULL},
254     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.InfoFlags),             "Info Flags"},
255     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.ParamCount),            "Parameter Count"},
256     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.SyncLevel),             "Sync Level"},
257     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Method.Mutex),                 "Mutex"},
258     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.OwnerId),               "Owner Id"},
259     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Method.ThreadCount),           "Thread Count"},
260     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Method.AmlLength),             "Aml Length"},
261     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Method.AmlStart),              "Aml Start"}
262 };
263 
264 static ACPI_EXDUMP_INFO     AcpiExDumpMutex[6] =
265 {
266     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex),          NULL},
267     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Mutex.SyncLevel),              "Sync Level"},
268     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Mutex.OriginalSyncLevel),      "Original Sync Level"},
269     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Mutex.OwnerThread),            "Owner Thread"},
270     {ACPI_EXD_UINT16,   ACPI_EXD_OFFSET (Mutex.AcquisitionDepth),       "Acquire Depth"},
271     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Mutex.OsMutex),                "OsMutex"}
272 };
273 
274 static ACPI_EXDUMP_INFO     AcpiExDumpRegion[8] =
275 {
276     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpRegion),         NULL},
277     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Region.SpaceId),               "Space Id"},
278     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Region.Flags),                 "Flags"},
279     {ACPI_EXD_NODE,     ACPI_EXD_OFFSET (Region.Node),                  "Parent Node"},
280     {ACPI_EXD_ADDRESS,  ACPI_EXD_OFFSET (Region.Address),               "Address"},
281     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Region.Length),                "Length"},
282     {ACPI_EXD_HDLR_LIST,ACPI_EXD_OFFSET (Region.Handler),               "Handler"},
283     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Region.Next),                  "Next"}
284 };
285 
286 static ACPI_EXDUMP_INFO     AcpiExDumpPower[6] =
287 {
288     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpPower),          NULL},
289     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (PowerResource.SystemLevel),    "System Level"},
290     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (PowerResource.ResourceOrder),  "Resource Order"},
291     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (PowerResource.NotifyList[0]),  "System Notify"},
292     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (PowerResource.NotifyList[1]),  "Device Notify"},
293     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (PowerResource.Handler),        "Handler"}
294 };
295 
296 static ACPI_EXDUMP_INFO     AcpiExDumpProcessor[7] =
297 {
298     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpProcessor),      NULL},
299     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Processor.ProcId),             "Processor ID"},
300     {ACPI_EXD_UINT8 ,   ACPI_EXD_OFFSET (Processor.Length),             "Length"},
301     {ACPI_EXD_ADDRESS,  ACPI_EXD_OFFSET (Processor.Address),            "Address"},
302     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Processor.NotifyList[0]),      "System Notify"},
303     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Processor.NotifyList[1]),      "Device Notify"},
304     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Processor.Handler),            "Handler"}
305 };
306 
307 static ACPI_EXDUMP_INFO     AcpiExDumpThermal[4] =
308 {
309     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpThermal),        NULL},
310     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (ThermalZone.NotifyList[0]),    "System Notify"},
311     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (ThermalZone.NotifyList[1]),    "Device Notify"},
312     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (ThermalZone.Handler),          "Handler"}
313 };
314 
315 static ACPI_EXDUMP_INFO     AcpiExDumpBufferField[3] =
316 {
317     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpBufferField),    NULL},
318     {ACPI_EXD_FIELD,    0,                                              NULL},
319     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (BufferField.BufferObj),        "Buffer Object"}
320 };
321 
322 static ACPI_EXDUMP_INFO     AcpiExDumpRegionField[5] =
323 {
324     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpRegionField),    NULL},
325     {ACPI_EXD_FIELD,    0,                                              NULL},
326     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Field.AccessLength),           "AccessLength"},
327     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Field.RegionObj),              "Region Object"},
328     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Field.ResourceBuffer),         "ResourceBuffer"}
329 };
330 
331 static ACPI_EXDUMP_INFO     AcpiExDumpBankField[5] =
332 {
333     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField),      NULL},
334     {ACPI_EXD_FIELD,    0,                                              NULL},
335     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (BankField.Value),              "Value"},
336     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (BankField.RegionObj),          "Region Object"},
337     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (BankField.BankObj),            "Bank Object"}
338 };
339 
340 static ACPI_EXDUMP_INFO     AcpiExDumpIndexField[5] =
341 {
342     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField),      NULL},
343     {ACPI_EXD_FIELD,    0,                                              NULL},
344     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (IndexField.Value),             "Value"},
345     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (IndexField.IndexObj),          "Index Object"},
346     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (IndexField.DataObj),           "Data Object"}
347 };
348 
349 static ACPI_EXDUMP_INFO     AcpiExDumpReference[9] =
350 {
351     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpReference),       NULL},
352     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Reference.Class),              "Class"},
353     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Reference.TargetType),         "Target Type"},
354     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Reference.Value),              "Value"},
355     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Reference.Object),             "Object Desc"},
356     {ACPI_EXD_NODE,     ACPI_EXD_OFFSET (Reference.Node),               "Node"},
357     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Reference.Where),              "Where"},
358     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Reference.IndexPointer),       "Index Pointer"},
359     {ACPI_EXD_REFERENCE,0,                                              NULL}
360 };
361 
362 static ACPI_EXDUMP_INFO     AcpiExDumpAddressHandler[6] =
363 {
364     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpAddressHandler), NULL},
365     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (AddressSpace.SpaceId),         "Space Id"},
366     {ACPI_EXD_HDLR_LIST,ACPI_EXD_OFFSET (AddressSpace.Next),            "Next"},
367     {ACPI_EXD_RGN_LIST, ACPI_EXD_OFFSET (AddressSpace.RegionList),      "Region List"},
368     {ACPI_EXD_NODE,     ACPI_EXD_OFFSET (AddressSpace.Node),            "Node"},
369     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (AddressSpace.Context),         "Context"}
370 };
371 
372 static ACPI_EXDUMP_INFO     AcpiExDumpNotify[7] =
373 {
374     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpNotify),         NULL},
375     {ACPI_EXD_NODE,     ACPI_EXD_OFFSET (Notify.Node),                  "Node"},
376     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Notify.HandlerType),           "Handler Type"},
377     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Notify.Handler),               "Handler"},
378     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Notify.Context),               "Context"},
379     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Notify.Next[0]),               "Next System Notify"},
380     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Notify.Next[1]),               "Next Device Notify"}
381 };
382 
383 static ACPI_EXDUMP_INFO     AcpiExDumpExtra[6] =
384 {
385     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpExtra),          NULL},
386     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Extra.Method_REG),             "_REG Method"},
387     {ACPI_EXD_NODE,     ACPI_EXD_OFFSET (Extra.ScopeNode),              "Scope Node"},
388     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Extra.RegionContext),          "Region Context"},
389     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Extra.AmlStart),               "Aml Start"},
390     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (Extra.AmlLength),              "Aml Length"}
391 };
392 
393 static ACPI_EXDUMP_INFO     AcpiExDumpData[3] =
394 {
395     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpData),           NULL},
396     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Data.Handler),                 "Handler"},
397     {ACPI_EXD_POINTER,  ACPI_EXD_OFFSET (Data.Pointer),                 "Raw Data"}
398 };
399 
400 /* Miscellaneous tables */
401 
402 static ACPI_EXDUMP_INFO     AcpiExDumpCommon[5] =
403 {
404     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpCommon),         NULL},
405     {ACPI_EXD_TYPE ,    0,                                              NULL},
406     {ACPI_EXD_UINT16,   ACPI_EXD_OFFSET (Common.ReferenceCount),        "Reference Count"},
407     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (Common.Flags),                 "Flags"},
408     {ACPI_EXD_LIST,     ACPI_EXD_OFFSET (Common.NextObject),            "Object List"}
409 };
410 
411 static ACPI_EXDUMP_INFO     AcpiExDumpFieldCommon[7] =
412 {
413     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpFieldCommon),    NULL},
414     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (CommonField.FieldFlags),       "Field Flags"},
415     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (CommonField.AccessByteWidth),  "Access Byte Width"},
416     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (CommonField.BitLength),        "Bit Length"},
417     {ACPI_EXD_UINT8,    ACPI_EXD_OFFSET (CommonField.StartFieldBitOffset),"Field Bit Offset"},
418     {ACPI_EXD_UINT32,   ACPI_EXD_OFFSET (CommonField.BaseByteOffset),   "Base Byte Offset"},
419     {ACPI_EXD_NODE,     ACPI_EXD_OFFSET (CommonField.Node),             "Parent Node"}
420 };
421 
422 static ACPI_EXDUMP_INFO     AcpiExDumpNode[7] =
423 {
424     {ACPI_EXD_INIT,     ACPI_EXD_TABLE_SIZE (AcpiExDumpNode),           NULL},
425     {ACPI_EXD_UINT8,    ACPI_EXD_NSOFFSET (Flags),                      "Flags"},
426     {ACPI_EXD_UINT8,    ACPI_EXD_NSOFFSET (OwnerId),                    "Owner Id"},
427     {ACPI_EXD_LIST,     ACPI_EXD_NSOFFSET (Object),                     "Object List"},
428     {ACPI_EXD_NODE,     ACPI_EXD_NSOFFSET (Parent),                     "Parent"},
429     {ACPI_EXD_NODE,     ACPI_EXD_NSOFFSET (Child),                      "Child"},
430     {ACPI_EXD_NODE,     ACPI_EXD_NSOFFSET (Peer),                       "Peer"}
431 };
432 
433 
434 /* Dispatch table, indexed by object type */
435 
436 static ACPI_EXDUMP_INFO     *AcpiExDumpInfo[] =
437 {
438     NULL,
439     AcpiExDumpInteger,
440     AcpiExDumpString,
441     AcpiExDumpBuffer,
442     AcpiExDumpPackage,
443     NULL,
444     AcpiExDumpDevice,
445     AcpiExDumpEvent,
446     AcpiExDumpMethod,
447     AcpiExDumpMutex,
448     AcpiExDumpRegion,
449     AcpiExDumpPower,
450     AcpiExDumpProcessor,
451     AcpiExDumpThermal,
452     AcpiExDumpBufferField,
453     NULL,
454     NULL,
455     AcpiExDumpRegionField,
456     AcpiExDumpBankField,
457     AcpiExDumpIndexField,
458     AcpiExDumpReference,
459     NULL,
460     NULL,
461     AcpiExDumpNotify,
462     AcpiExDumpAddressHandler,
463     NULL,
464     NULL,
465     NULL,
466     AcpiExDumpExtra,
467     AcpiExDumpData
468 };
469 
470 
471 /*******************************************************************************
472  *
473  * FUNCTION:    AcpiExDumpObject
474  *
475  * PARAMETERS:  ObjDesc             - Descriptor to dump
476  *              Info                - Info table corresponding to this object
477  *                                    type
478  *
479  * RETURN:      None
480  *
481  * DESCRIPTION: Walk the info table for this object
482  *
483  ******************************************************************************/
484 
485 static void
486 AcpiExDumpObject (
487     ACPI_OPERAND_OBJECT     *ObjDesc,
488     ACPI_EXDUMP_INFO        *Info)
489 {
490     UINT8                   *Target;
491     const char              *Name;
492     UINT8                   Count;
493     ACPI_OPERAND_OBJECT     *Start;
494     ACPI_OPERAND_OBJECT     *Data = NULL;
495     ACPI_OPERAND_OBJECT     *Next;
496     ACPI_NAMESPACE_NODE     *Node;
497 
498 
499     if (!Info)
500     {
501         AcpiOsPrintf (
502             "ExDumpObject: Display not implemented for object type %s\n",
503             AcpiUtGetObjectTypeName (ObjDesc));
504         return;
505     }
506 
507     /* First table entry must contain the table length (# of table entries) */
508 
509     Count = Info->Offset;
510 
511     while (Count)
512     {
513         Target = ACPI_ADD_PTR (UINT8, ObjDesc, Info->Offset);
514         Name = Info->Name;
515 
516         switch (Info->Opcode)
517         {
518         case ACPI_EXD_INIT:
519 
520             break;
521 
522         case ACPI_EXD_TYPE:
523 
524             AcpiOsPrintf ("%20s : %2.2X [%s]\n", "Type",
525                 ObjDesc->Common.Type, AcpiUtGetObjectTypeName (ObjDesc));
526             break;
527 
528         case ACPI_EXD_UINT8:
529 
530             AcpiOsPrintf ("%20s : %2.2X\n", Name, *Target);
531             break;
532 
533         case ACPI_EXD_UINT16:
534 
535             AcpiOsPrintf ("%20s : %4.4X\n", Name, ACPI_GET16 (Target));
536             break;
537 
538         case ACPI_EXD_UINT32:
539 
540             AcpiOsPrintf ("%20s : %8.8X\n", Name, ACPI_GET32 (Target));
541             break;
542 
543         case ACPI_EXD_UINT64:
544 
545             AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value",
546                 ACPI_FORMAT_UINT64 (ACPI_GET64 (Target)));
547             break;
548 
549         case ACPI_EXD_POINTER:
550         case ACPI_EXD_ADDRESS:
551 
552             AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target));
553             break;
554 
555         case ACPI_EXD_STRING:
556 
557             AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
558             AcpiOsPrintf ("\n");
559             break;
560 
561         case ACPI_EXD_BUFFER:
562 
563             ACPI_DUMP_BUFFER (
564                 ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length);
565             break;
566 
567         case ACPI_EXD_PACKAGE:
568 
569             /* Dump the package contents */
570 
571             AcpiOsPrintf ("\nPackage Contents:\n");
572             AcpiExDumpPackageObj (ObjDesc, 0, 0);
573             break;
574 
575         case ACPI_EXD_FIELD:
576 
577             AcpiExDumpObject (ObjDesc, AcpiExDumpFieldCommon);
578             break;
579 
580         case ACPI_EXD_REFERENCE:
581 
582             AcpiExOutString ("Class Name", AcpiUtGetReferenceName (ObjDesc));
583             AcpiExDumpReferenceObj (ObjDesc);
584             break;
585 
586         case ACPI_EXD_LIST:
587 
588             Start = *ACPI_CAST_PTR (void *, Target);
589             Next = Start;
590 
591             AcpiOsPrintf ("%20s : %p", Name, Next);
592             if (Next)
593             {
594                 AcpiOsPrintf ("(%s %2.2X)",
595                     AcpiUtGetObjectTypeName (Next), Next->Common.Type);
596 
597                 while (Next->Common.NextObject)
598                 {
599                     if ((Next->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
600                         !Data)
601                     {
602                         Data = Next;
603                     }
604 
605                     Next = Next->Common.NextObject;
606                     AcpiOsPrintf ("->%p(%s %2.2X)", Next,
607                         AcpiUtGetObjectTypeName (Next), Next->Common.Type);
608 
609                     if ((Next == Start) || (Next == Data))
610                     {
611                         AcpiOsPrintf (
612                             "\n**** Error: Object list appears to be circular linked");
613                         break;
614                     }
615                 }
616             }
617 
618             AcpiOsPrintf ("\n");
619             break;
620 
621         case ACPI_EXD_HDLR_LIST:
622 
623             Start = *ACPI_CAST_PTR (void *, Target);
624             Next = Start;
625 
626             AcpiOsPrintf ("%20s : %p", Name, Next);
627             if (Next)
628             {
629                 AcpiOsPrintf ("(%s %2.2X)",
630                     AcpiUtGetObjectTypeName (Next),
631                     Next->AddressSpace.SpaceId);
632 
633                 while (Next->AddressSpace.Next)
634                 {
635                     if ((Next->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
636                         !Data)
637                     {
638                         Data = Next;
639                     }
640 
641                     Next = Next->AddressSpace.Next;
642                     AcpiOsPrintf ("->%p(%s %2.2X)", Next,
643                         AcpiUtGetObjectTypeName (Next),
644                         Next->AddressSpace.SpaceId);
645 
646                     if ((Next == Start) || (Next == Data))
647                     {
648                         AcpiOsPrintf (
649                             "\n**** Error: Handler list appears to be circular linked");
650                         break;
651                     }
652                 }
653             }
654 
655             AcpiOsPrintf ("\n");
656             break;
657 
658         case ACPI_EXD_RGN_LIST:
659 
660             Start = *ACPI_CAST_PTR (void *, Target);
661             Next = Start;
662 
663             AcpiOsPrintf ("%20s : %p", Name, Next);
664             if (Next)
665             {
666                 AcpiOsPrintf ("(%s %2.2X)",
667                     AcpiUtGetObjectTypeName (Next), Next->Common.Type);
668 
669                 while (Next->Region.Next)
670                 {
671                     if ((Next->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
672                         !Data)
673                     {
674                         Data = Next;
675                     }
676 
677                     Next = Next->Region.Next;
678                     AcpiOsPrintf ("->%p(%s %2.2X)", Next,
679                         AcpiUtGetObjectTypeName (Next), Next->Common.Type);
680 
681                     if ((Next == Start) || (Next == Data))
682                     {
683                         AcpiOsPrintf (
684                             "\n**** Error: Region list appears to be circular linked");
685                         break;
686                     }
687                 }
688             }
689 
690             AcpiOsPrintf ("\n");
691             break;
692 
693         case ACPI_EXD_NODE:
694 
695             Node = *ACPI_CAST_PTR (ACPI_NAMESPACE_NODE *, Target);
696 
697             AcpiOsPrintf ("%20s : %p", Name, Node);
698             if (Node)
699             {
700                 AcpiOsPrintf (" [%4.4s]", Node->Name.Ascii);
701             }
702             AcpiOsPrintf ("\n");
703             break;
704 
705         default:
706 
707             AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
708                 Info->Opcode);
709             return;
710         }
711 
712         Info++;
713         Count--;
714     }
715 }
716 
717 
718 /*******************************************************************************
719  *
720  * FUNCTION:    AcpiExDumpOperand
721  *
722  * PARAMETERS:  *ObjDesc        - Pointer to entry to be dumped
723  *              Depth           - Current nesting depth
724  *
725  * RETURN:      None
726  *
727  * DESCRIPTION: Dump an operand object
728  *
729  ******************************************************************************/
730 
731 void
732 AcpiExDumpOperand (
733     ACPI_OPERAND_OBJECT     *ObjDesc,
734     UINT32                  Depth)
735 {
736     UINT32                  Length;
737     UINT32                  Index;
738 
739 
740     ACPI_FUNCTION_NAME (ExDumpOperand)
741 
742 
743     /* Check if debug output enabled */
744 
745     if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_EXEC, _COMPONENT))
746     {
747         return;
748     }
749 
750     if (!ObjDesc)
751     {
752         /* This could be a null element of a package */
753 
754         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
755         return;
756     }
757 
758     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
759     {
760         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc));
761         ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC);
762         return;
763     }
764 
765     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
766     {
767         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
768             "%p is not a node or operand object: [%s]\n",
769             ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
770         ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT));
771         return;
772     }
773 
774     /* ObjDesc is a valid object */
775 
776     if (Depth > 0)
777     {
778         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ",
779             Depth, " ", Depth, ObjDesc));
780     }
781     else
782     {
783         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc));
784     }
785 
786     /* Decode object type */
787 
788     switch (ObjDesc->Common.Type)
789     {
790     case ACPI_TYPE_LOCAL_REFERENCE:
791 
792         AcpiOsPrintf ("Reference: [%s] ",
793             AcpiUtGetReferenceName (ObjDesc));
794 
795         switch (ObjDesc->Reference.Class)
796         {
797         case ACPI_REFCLASS_DEBUG:
798 
799             AcpiOsPrintf ("\n");
800             break;
801 
802         case ACPI_REFCLASS_INDEX:
803 
804             AcpiOsPrintf ("%p\n", ObjDesc->Reference.Object);
805             break;
806 
807         case ACPI_REFCLASS_TABLE:
808 
809             AcpiOsPrintf ("Table Index %X\n", ObjDesc->Reference.Value);
810             break;
811 
812         case ACPI_REFCLASS_REFOF:
813 
814             AcpiOsPrintf ("%p [%s]\n", ObjDesc->Reference.Object,
815                 AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)
816                     ObjDesc->Reference.Object)->Common.Type));
817             break;
818 
819         case ACPI_REFCLASS_NAME:
820 
821             AcpiOsPrintf ("- [%4.4s]\n",
822                 ObjDesc->Reference.Node->Name.Ascii);
823             break;
824 
825         case ACPI_REFCLASS_ARG:
826         case ACPI_REFCLASS_LOCAL:
827 
828             AcpiOsPrintf ("%X\n", ObjDesc->Reference.Value);
829             break;
830 
831         default:    /* Unknown reference class */
832 
833             AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class);
834             break;
835         }
836         break;
837 
838     case ACPI_TYPE_BUFFER:
839 
840         AcpiOsPrintf ("Buffer length %.2X @ %p\n",
841             ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer);
842 
843         /* Debug only -- dump the buffer contents */
844 
845         if (ObjDesc->Buffer.Pointer)
846         {
847             Length = ObjDesc->Buffer.Length;
848             if (Length > 128)
849             {
850                 Length = 128;
851             }
852 
853             AcpiOsPrintf (
854                 "Buffer Contents: (displaying length 0x%.2X)\n", Length);
855             ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length);
856         }
857         break;
858 
859     case ACPI_TYPE_INTEGER:
860 
861         AcpiOsPrintf ("Integer %8.8X%8.8X\n",
862             ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
863         break;
864 
865     case ACPI_TYPE_PACKAGE:
866 
867         AcpiOsPrintf ("Package [Len %X] ElementArray %p\n",
868             ObjDesc->Package.Count, ObjDesc->Package.Elements);
869 
870         /*
871          * If elements exist, package element pointer is valid,
872          * and debug_level exceeds 1, dump package's elements.
873          */
874         if (ObjDesc->Package.Count &&
875             ObjDesc->Package.Elements &&
876             AcpiDbgLevel > 1)
877         {
878             for (Index = 0; Index < ObjDesc->Package.Count; Index++)
879             {
880                 AcpiExDumpOperand (
881                     ObjDesc->Package.Elements[Index], Depth + 1);
882             }
883         }
884         break;
885 
886     case ACPI_TYPE_REGION:
887 
888         AcpiOsPrintf ("Region %s (%X)",
889             AcpiUtGetRegionName (ObjDesc->Region.SpaceId),
890             ObjDesc->Region.SpaceId);
891 
892         /*
893          * If the address and length have not been evaluated,
894          * don't print them.
895          */
896         if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID))
897         {
898             AcpiOsPrintf ("\n");
899         }
900         else
901         {
902             AcpiOsPrintf (" base %8.8X%8.8X Length %X\n",
903                 ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
904                 ObjDesc->Region.Length);
905         }
906         break;
907 
908     case ACPI_TYPE_STRING:
909 
910         AcpiOsPrintf ("String length %X @ %p ",
911             ObjDesc->String.Length,
912             ObjDesc->String.Pointer);
913 
914         AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
915         AcpiOsPrintf ("\n");
916         break;
917 
918     case ACPI_TYPE_LOCAL_BANK_FIELD:
919 
920         AcpiOsPrintf ("BankField\n");
921         break;
922 
923     case ACPI_TYPE_LOCAL_REGION_FIELD:
924 
925         AcpiOsPrintf ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at "
926             "byte=%X bit=%X of below:\n",
927             ObjDesc->Field.BitLength,
928             ObjDesc->Field.AccessByteWidth,
929             ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK,
930             ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK,
931             ObjDesc->Field.BaseByteOffset,
932             ObjDesc->Field.StartFieldBitOffset);
933 
934         AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth + 1);
935         break;
936 
937     case ACPI_TYPE_LOCAL_INDEX_FIELD:
938 
939         AcpiOsPrintf ("IndexField\n");
940         break;
941 
942     case ACPI_TYPE_BUFFER_FIELD:
943 
944         AcpiOsPrintf ("BufferField: %X bits at byte %X bit %X of\n",
945             ObjDesc->BufferField.BitLength,
946             ObjDesc->BufferField.BaseByteOffset,
947             ObjDesc->BufferField.StartFieldBitOffset);
948 
949         if (!ObjDesc->BufferField.BufferObj)
950         {
951             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n"));
952         }
953         else if ((ObjDesc->BufferField.BufferObj)->Common.Type !=
954             ACPI_TYPE_BUFFER)
955         {
956             AcpiOsPrintf ("*not a Buffer*\n");
957         }
958         else
959         {
960             AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth + 1);
961         }
962         break;
963 
964     case ACPI_TYPE_EVENT:
965 
966         AcpiOsPrintf ("Event\n");
967         break;
968 
969     case ACPI_TYPE_METHOD:
970 
971         AcpiOsPrintf ("Method(%X) @ %p:%X\n",
972             ObjDesc->Method.ParamCount,
973             ObjDesc->Method.AmlStart,
974             ObjDesc->Method.AmlLength);
975         break;
976 
977     case ACPI_TYPE_MUTEX:
978 
979         AcpiOsPrintf ("Mutex\n");
980         break;
981 
982     case ACPI_TYPE_DEVICE:
983 
984         AcpiOsPrintf ("Device\n");
985         break;
986 
987     case ACPI_TYPE_POWER:
988 
989         AcpiOsPrintf ("Power\n");
990         break;
991 
992     case ACPI_TYPE_PROCESSOR:
993 
994         AcpiOsPrintf ("Processor\n");
995         break;
996 
997     case ACPI_TYPE_THERMAL:
998 
999         AcpiOsPrintf ("Thermal\n");
1000         break;
1001 
1002     default:
1003 
1004         /* Unknown Type */
1005 
1006         AcpiOsPrintf ("Unknown Type %X\n", ObjDesc->Common.Type);
1007         break;
1008     }
1009 
1010     return;
1011 }
1012 
1013 
1014 /*******************************************************************************
1015  *
1016  * FUNCTION:    AcpiExDumpOperands
1017  *
1018  * PARAMETERS:  Operands            - A list of Operand objects
1019  *              OpcodeName          - AML opcode name
1020  *              NumOperands         - Operand count for this opcode
1021  *
1022  * DESCRIPTION: Dump the operands associated with the opcode
1023  *
1024  ******************************************************************************/
1025 
1026 void
1027 AcpiExDumpOperands (
1028     ACPI_OPERAND_OBJECT     **Operands,
1029     const char              *OpcodeName,
1030     UINT32                  NumOperands)
1031 {
1032     ACPI_FUNCTION_NAME (ExDumpOperands);
1033 
1034 
1035     if (!OpcodeName)
1036     {
1037         OpcodeName = "UNKNOWN";
1038     }
1039 
1040     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
1041         "**** Start operand dump for opcode [%s], %u operands\n",
1042         OpcodeName, NumOperands));
1043 
1044     if (NumOperands == 0)
1045     {
1046         NumOperands = 1;
1047     }
1048 
1049     /* Dump the individual operands */
1050 
1051     while (NumOperands)
1052     {
1053         AcpiExDumpOperand (*Operands, 0);
1054         Operands++;
1055         NumOperands--;
1056     }
1057 
1058     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
1059         "**** End operand dump for [%s]\n", OpcodeName));
1060     return;
1061 }
1062 
1063 
1064 /*******************************************************************************
1065  *
1066  * FUNCTION:    AcpiExOut* functions
1067  *
1068  * PARAMETERS:  Title               - Descriptive text
1069  *              Value               - Value to be displayed
1070  *
1071  * DESCRIPTION: Object dump output formatting functions. These functions
1072  *              reduce the number of format strings required and keeps them
1073  *              all in one place for easy modification.
1074  *
1075  ******************************************************************************/
1076 
1077 static void
1078 AcpiExOutString (
1079     const char              *Title,
1080     const char              *Value)
1081 {
1082     AcpiOsPrintf ("%20s : %s\n", Title, Value);
1083 }
1084 
1085 static void
1086 AcpiExOutPointer (
1087     const char              *Title,
1088     const void              *Value)
1089 {
1090     AcpiOsPrintf ("%20s : %p\n", Title, Value);
1091 }
1092 
1093 
1094 /*******************************************************************************
1095  *
1096  * FUNCTION:    AcpiExDumpNamespaceNode
1097  *
1098  * PARAMETERS:  Node                - Descriptor to dump
1099  *              Flags               - Force display if TRUE
1100  *
1101  * DESCRIPTION: Dumps the members of the given.Node
1102  *
1103  ******************************************************************************/
1104 
1105 void
1106 AcpiExDumpNamespaceNode (
1107     ACPI_NAMESPACE_NODE     *Node,
1108     UINT32                  Flags)
1109 {
1110 
1111     ACPI_FUNCTION_ENTRY ();
1112 
1113 
1114     if (!Flags)
1115     {
1116         /* Check if debug output enabled */
1117 
1118         if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_OBJECTS, _COMPONENT))
1119         {
1120             return;
1121         }
1122     }
1123 
1124     AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node));
1125     AcpiOsPrintf ("%20s : %2.2X [%s]\n", "Type",
1126         Node->Type, AcpiUtGetTypeName (Node->Type));
1127 
1128     AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node),
1129         AcpiExDumpNode);
1130 }
1131 
1132 
1133 /*******************************************************************************
1134  *
1135  * FUNCTION:    AcpiExDumpReferenceObj
1136  *
1137  * PARAMETERS:  Object              - Descriptor to dump
1138  *
1139  * DESCRIPTION: Dumps a reference object
1140  *
1141  ******************************************************************************/
1142 
1143 static void
1144 AcpiExDumpReferenceObj (
1145     ACPI_OPERAND_OBJECT     *ObjDesc)
1146 {
1147     ACPI_BUFFER             RetBuf;
1148     ACPI_STATUS             Status;
1149 
1150 
1151     RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1152 
1153     if (ObjDesc->Reference.Class == ACPI_REFCLASS_NAME)
1154     {
1155         AcpiOsPrintf (" %p ", ObjDesc->Reference.Node);
1156 
1157         Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node,
1158             &RetBuf, TRUE);
1159         if (ACPI_FAILURE (Status))
1160         {
1161             AcpiOsPrintf (" Could not convert name to pathname\n");
1162         }
1163         else
1164         {
1165            AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer);
1166            ACPI_FREE (RetBuf.Pointer);
1167         }
1168     }
1169     else if (ObjDesc->Reference.Object)
1170     {
1171         if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)
1172         {
1173             AcpiOsPrintf ("%22s %p", "Target :",
1174                 ObjDesc->Reference.Object);
1175             if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE)
1176             {
1177                 AcpiOsPrintf (" Table Index: %X\n",
1178                     ObjDesc->Reference.Value);
1179             }
1180             else
1181             {
1182                 AcpiOsPrintf (" [%s]\n",
1183                     AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)
1184                     ObjDesc->Reference.Object)->Common.Type));
1185             }
1186         }
1187         else
1188         {
1189             AcpiOsPrintf (" Target: %p\n", ObjDesc->Reference.Object);
1190         }
1191     }
1192 }
1193 
1194 
1195 /*******************************************************************************
1196  *
1197  * FUNCTION:    AcpiExDumpPackageObj
1198  *
1199  * PARAMETERS:  ObjDesc             - Descriptor to dump
1200  *              Level               - Indentation Level
1201  *              Index               - Package index for this object
1202  *
1203  * DESCRIPTION: Dumps the elements of the package
1204  *
1205  ******************************************************************************/
1206 
1207 static void
1208 AcpiExDumpPackageObj (
1209     ACPI_OPERAND_OBJECT     *ObjDesc,
1210     UINT32                  Level,
1211     UINT32                  Index)
1212 {
1213     UINT32                  i;
1214 
1215 
1216     /* Indentation and index output */
1217 
1218     if (Level > 0)
1219     {
1220         for (i = 0; i < Level; i++)
1221         {
1222             AcpiOsPrintf ("  ");
1223         }
1224 
1225         AcpiOsPrintf ("[%.2d] ", Index);
1226     }
1227 
1228     AcpiOsPrintf ("%p ", ObjDesc);
1229 
1230     /* Null package elements are allowed */
1231 
1232     if (!ObjDesc)
1233     {
1234         AcpiOsPrintf ("[Null Object]\n");
1235         return;
1236     }
1237 
1238     /* Packages may only contain a few object types */
1239 
1240     switch (ObjDesc->Common.Type)
1241     {
1242     case ACPI_TYPE_INTEGER:
1243 
1244         AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
1245             ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
1246         break;
1247 
1248     case ACPI_TYPE_STRING:
1249 
1250         AcpiOsPrintf ("[String]  Value: ");
1251         AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
1252         AcpiOsPrintf ("\n");
1253         break;
1254 
1255     case ACPI_TYPE_BUFFER:
1256 
1257         AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length);
1258         if (ObjDesc->Buffer.Length)
1259         {
1260             AcpiUtDebugDumpBuffer (
1261                 ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
1262                 ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT);
1263         }
1264         else
1265         {
1266             AcpiOsPrintf ("\n");
1267         }
1268         break;
1269 
1270     case ACPI_TYPE_PACKAGE:
1271 
1272         AcpiOsPrintf ("[Package] Contains %u Elements:\n",
1273             ObjDesc->Package.Count);
1274 
1275         for (i = 0; i < ObjDesc->Package.Count; i++)
1276         {
1277             AcpiExDumpPackageObj (
1278                 ObjDesc->Package.Elements[i], Level + 1, i);
1279         }
1280         break;
1281 
1282     case ACPI_TYPE_LOCAL_REFERENCE:
1283 
1284         AcpiOsPrintf ("[Object Reference] Type [%s] %2.2X",
1285             AcpiUtGetReferenceName (ObjDesc),
1286             ObjDesc->Reference.Class);
1287         AcpiExDumpReferenceObj (ObjDesc);
1288         break;
1289 
1290     default:
1291 
1292         AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Common.Type);
1293         break;
1294     }
1295 }
1296 
1297 
1298 /*******************************************************************************
1299  *
1300  * FUNCTION:    AcpiExDumpObjectDescriptor
1301  *
1302  * PARAMETERS:  ObjDesc             - Descriptor to dump
1303  *              Flags               - Force display if TRUE
1304  *
1305  * DESCRIPTION: Dumps the members of the object descriptor given.
1306  *
1307  ******************************************************************************/
1308 
1309 void
1310 AcpiExDumpObjectDescriptor (
1311     ACPI_OPERAND_OBJECT     *ObjDesc,
1312     UINT32                  Flags)
1313 {
1314     ACPI_FUNCTION_TRACE (ExDumpObjectDescriptor);
1315 
1316 
1317     if (!ObjDesc)
1318     {
1319         return_VOID;
1320     }
1321 
1322     if (!Flags)
1323     {
1324         /* Check if debug output enabled */
1325 
1326         if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_OBJECTS, _COMPONENT))
1327         {
1328             return_VOID;
1329         }
1330     }
1331 
1332     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
1333     {
1334         AcpiExDumpNamespaceNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags);
1335 
1336         AcpiOsPrintf ("\nAttached Object (%p):\n",
1337             ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object);
1338 
1339         ObjDesc = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object;
1340         goto DumpObject;
1341     }
1342 
1343     if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
1344     {
1345         AcpiOsPrintf (
1346             "%p is not an ACPI operand object: [%s]\n",
1347             ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
1348         return_VOID;
1349     }
1350 
1351     /* Validate the object type */
1352 
1353     if (ObjDesc->Common.Type > ACPI_TYPE_LOCAL_MAX)
1354     {
1355         AcpiOsPrintf ("Not a known object type: %2.2X\n",
1356             ObjDesc->Common.Type);
1357         return_VOID;
1358     }
1359 
1360 
1361 DumpObject:
1362 
1363     /* Common Fields */
1364 
1365     AcpiExDumpObject (ObjDesc, AcpiExDumpCommon);
1366 
1367     /* Object-specific fields */
1368 
1369     AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]);
1370 
1371     if (ObjDesc->Common.Type == ACPI_TYPE_REGION)
1372     {
1373         ObjDesc = ObjDesc->Common.NextObject;
1374         if (ObjDesc->Common.Type > ACPI_TYPE_LOCAL_MAX)
1375         {
1376             AcpiOsPrintf (
1377                 "Secondary object is not a known object type: %2.2X\n",
1378                 ObjDesc->Common.Type);
1379 
1380             return_VOID;
1381         }
1382 
1383         AcpiOsPrintf ("\nExtra attached Object (%p):\n", ObjDesc);
1384         AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]);
1385     }
1386 
1387     return_VOID;
1388 }
1389 
1390 #endif
1391