1a9643ea8Slogwang /******************************************************************************
2a9643ea8Slogwang  *
3a9643ea8Slogwang  * Module Name: exdebug - Support for stores to the AML Debug Object
4a9643ea8Slogwang  *
5a9643ea8Slogwang  *****************************************************************************/
6a9643ea8Slogwang 
7*22ce4affSfengbojiang /******************************************************************************
8*22ce4affSfengbojiang  *
9*22ce4affSfengbojiang  * 1. Copyright Notice
10*22ce4affSfengbojiang  *
11*22ce4affSfengbojiang  * Some or all of this work - Copyright (c) 1999 - 2020, Intel Corp.
12a9643ea8Slogwang  * All rights reserved.
13a9643ea8Slogwang  *
14*22ce4affSfengbojiang  * 2. License
15*22ce4affSfengbojiang  *
16*22ce4affSfengbojiang  * 2.1. This is your license from Intel Corp. under its intellectual property
17*22ce4affSfengbojiang  * rights. You may have additional license terms from the party that provided
18*22ce4affSfengbojiang  * you this software, covering your right to use that party's intellectual
19*22ce4affSfengbojiang  * property rights.
20*22ce4affSfengbojiang  *
21*22ce4affSfengbojiang  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22*22ce4affSfengbojiang  * copy of the source code appearing in this file ("Covered Code") an
23*22ce4affSfengbojiang  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24*22ce4affSfengbojiang  * base code distributed originally by Intel ("Original Intel Code") to copy,
25*22ce4affSfengbojiang  * make derivatives, distribute, use and display any portion of the Covered
26*22ce4affSfengbojiang  * Code in any form, with the right to sublicense such rights; and
27*22ce4affSfengbojiang  *
28*22ce4affSfengbojiang  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29*22ce4affSfengbojiang  * license (with the right to sublicense), under only those claims of Intel
30*22ce4affSfengbojiang  * patents that are infringed by the Original Intel Code, to make, use, sell,
31*22ce4affSfengbojiang  * offer to sell, and import the Covered Code and derivative works thereof
32*22ce4affSfengbojiang  * solely to the minimum extent necessary to exercise the above copyright
33*22ce4affSfengbojiang  * license, and in no event shall the patent license extend to any additions
34*22ce4affSfengbojiang  * to or modifications of the Original Intel Code. No other license or right
35*22ce4affSfengbojiang  * is granted directly or by implication, estoppel or otherwise;
36*22ce4affSfengbojiang  *
37*22ce4affSfengbojiang  * The above copyright and patent license is granted only if the following
38*22ce4affSfengbojiang  * conditions are met:
39*22ce4affSfengbojiang  *
40*22ce4affSfengbojiang  * 3. Conditions
41*22ce4affSfengbojiang  *
42*22ce4affSfengbojiang  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43*22ce4affSfengbojiang  * Redistribution of source code of any substantial portion of the Covered
44*22ce4affSfengbojiang  * Code or modification with rights to further distribute source must include
45*22ce4affSfengbojiang  * the above Copyright Notice, the above License, this list of Conditions,
46*22ce4affSfengbojiang  * and the following Disclaimer and Export Compliance provision. In addition,
47*22ce4affSfengbojiang  * Licensee must cause all Covered Code to which Licensee contributes to
48*22ce4affSfengbojiang  * contain a file documenting the changes Licensee made to create that Covered
49*22ce4affSfengbojiang  * Code and the date of any change. Licensee must include in that file the
50*22ce4affSfengbojiang  * documentation of any changes made by any predecessor Licensee. Licensee
51*22ce4affSfengbojiang  * must include a prominent statement that the modification is derived,
52*22ce4affSfengbojiang  * directly or indirectly, from Original Intel Code.
53*22ce4affSfengbojiang  *
54*22ce4affSfengbojiang  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55*22ce4affSfengbojiang  * Redistribution of source code of any substantial portion of the Covered
56*22ce4affSfengbojiang  * Code or modification without rights to further distribute source must
57*22ce4affSfengbojiang  * include the following Disclaimer and Export Compliance provision in the
58*22ce4affSfengbojiang  * documentation and/or other materials provided with distribution. In
59*22ce4affSfengbojiang  * addition, Licensee may not authorize further sublicense of source of any
60*22ce4affSfengbojiang  * portion of the Covered Code, and must include terms to the effect that the
61*22ce4affSfengbojiang  * license from Licensee to its licensee is limited to the intellectual
62*22ce4affSfengbojiang  * property embodied in the software Licensee provides to its licensee, and
63*22ce4affSfengbojiang  * not to intellectual property embodied in modifications its licensee may
64*22ce4affSfengbojiang  * make.
65*22ce4affSfengbojiang  *
66*22ce4affSfengbojiang  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67*22ce4affSfengbojiang  * substantial portion of the Covered Code or modification must reproduce the
68*22ce4affSfengbojiang  * above Copyright Notice, and the following Disclaimer and Export Compliance
69*22ce4affSfengbojiang  * provision in the documentation and/or other materials provided with the
70*22ce4affSfengbojiang  * distribution.
71*22ce4affSfengbojiang  *
72*22ce4affSfengbojiang  * 3.4. Intel retains all right, title, and interest in and to the Original
73*22ce4affSfengbojiang  * Intel Code.
74*22ce4affSfengbojiang  *
75*22ce4affSfengbojiang  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76*22ce4affSfengbojiang  * Intel shall be used in advertising or otherwise to promote the sale, use or
77*22ce4affSfengbojiang  * other dealings in products derived from or relating to the Covered Code
78*22ce4affSfengbojiang  * without prior written authorization from Intel.
79*22ce4affSfengbojiang  *
80*22ce4affSfengbojiang  * 4. Disclaimer and Export Compliance
81*22ce4affSfengbojiang  *
82*22ce4affSfengbojiang  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83*22ce4affSfengbojiang  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84*22ce4affSfengbojiang  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85*22ce4affSfengbojiang  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86*22ce4affSfengbojiang  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87*22ce4affSfengbojiang  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88*22ce4affSfengbojiang  * PARTICULAR PURPOSE.
89*22ce4affSfengbojiang  *
90*22ce4affSfengbojiang  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91*22ce4affSfengbojiang  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92*22ce4affSfengbojiang  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93*22ce4affSfengbojiang  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94*22ce4affSfengbojiang  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95*22ce4affSfengbojiang  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96*22ce4affSfengbojiang  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97*22ce4affSfengbojiang  * LIMITED REMEDY.
98*22ce4affSfengbojiang  *
99*22ce4affSfengbojiang  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100*22ce4affSfengbojiang  * software or system incorporating such software without first obtaining any
101*22ce4affSfengbojiang  * required license or other approval from the U. S. Department of Commerce or
102*22ce4affSfengbojiang  * any other agency or department of the United States Government. In the
103*22ce4affSfengbojiang  * event Licensee exports any such software from the United States or
104*22ce4affSfengbojiang  * re-exports any such software from a foreign destination, Licensee shall
105*22ce4affSfengbojiang  * ensure that the distribution and export/re-export of the software is in
106*22ce4affSfengbojiang  * compliance with all laws, regulations, orders, or other restrictions of the
107*22ce4affSfengbojiang  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108*22ce4affSfengbojiang  * any of its subsidiaries will export/re-export any technical data, process,
109*22ce4affSfengbojiang  * software, or service, directly or indirectly, to any country for which the
110*22ce4affSfengbojiang  * United States government or any agency thereof requires an export license,
111*22ce4affSfengbojiang  * other governmental approval, or letter of assurance, without first obtaining
112*22ce4affSfengbojiang  * such license, approval or letter.
113*22ce4affSfengbojiang  *
114*22ce4affSfengbojiang  *****************************************************************************
115*22ce4affSfengbojiang  *
116*22ce4affSfengbojiang  * Alternatively, you may choose to be licensed under the terms of the
117*22ce4affSfengbojiang  * following license:
118*22ce4affSfengbojiang  *
119a9643ea8Slogwang  * Redistribution and use in source and binary forms, with or without
120a9643ea8Slogwang  * modification, are permitted provided that the following conditions
121a9643ea8Slogwang  * are met:
122a9643ea8Slogwang  * 1. Redistributions of source code must retain the above copyright
123a9643ea8Slogwang  *    notice, this list of conditions, and the following disclaimer,
124a9643ea8Slogwang  *    without modification.
125a9643ea8Slogwang  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126a9643ea8Slogwang  *    substantially similar to the "NO WARRANTY" disclaimer below
127a9643ea8Slogwang  *    ("Disclaimer") and any redistribution must be conditioned upon
128a9643ea8Slogwang  *    including a substantially similar Disclaimer requirement for further
129a9643ea8Slogwang  *    binary redistribution.
130a9643ea8Slogwang  * 3. Neither the names of the above-listed copyright holders nor the names
131a9643ea8Slogwang  *    of any contributors may be used to endorse or promote products derived
132a9643ea8Slogwang  *    from this software without specific prior written permission.
133a9643ea8Slogwang  *
134*22ce4affSfengbojiang  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135*22ce4affSfengbojiang  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136*22ce4affSfengbojiang  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137*22ce4affSfengbojiang  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138*22ce4affSfengbojiang  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139*22ce4affSfengbojiang  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140*22ce4affSfengbojiang  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141*22ce4affSfengbojiang  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142*22ce4affSfengbojiang  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143*22ce4affSfengbojiang  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144*22ce4affSfengbojiang  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145*22ce4affSfengbojiang  *
146*22ce4affSfengbojiang  * Alternatively, you may choose to be licensed under the terms of the
147a9643ea8Slogwang  * GNU General Public License ("GPL") version 2 as published by the Free
148a9643ea8Slogwang  * Software Foundation.
149a9643ea8Slogwang  *
150*22ce4affSfengbojiang  *****************************************************************************/
151a9643ea8Slogwang 
152a9643ea8Slogwang #include <contrib/dev/acpica/include/acpi.h>
153a9643ea8Slogwang #include <contrib/dev/acpica/include/accommon.h>
154a9643ea8Slogwang #include <contrib/dev/acpica/include/acinterp.h>
155a9643ea8Slogwang 
156a9643ea8Slogwang 
157a9643ea8Slogwang #define _COMPONENT          ACPI_EXECUTER
158a9643ea8Slogwang         ACPI_MODULE_NAME    ("exdebug")
159a9643ea8Slogwang 
160a9643ea8Slogwang 
161a9643ea8Slogwang #ifndef ACPI_NO_ERROR_MESSAGES
162a9643ea8Slogwang /*******************************************************************************
163a9643ea8Slogwang  *
164a9643ea8Slogwang  * FUNCTION:    AcpiExDoDebugObject
165a9643ea8Slogwang  *
166a9643ea8Slogwang  * PARAMETERS:  SourceDesc          - Object to be output to "Debug Object"
167a9643ea8Slogwang  *              Level               - Indentation level (used for packages)
168a9643ea8Slogwang  *              Index               - Current package element, zero if not pkg
169a9643ea8Slogwang  *
170a9643ea8Slogwang  * RETURN:      None
171a9643ea8Slogwang  *
172a9643ea8Slogwang  * DESCRIPTION: Handles stores to the AML Debug Object. For example:
173a9643ea8Slogwang  *              Store(INT1, Debug)
174a9643ea8Slogwang  *
175a9643ea8Slogwang  * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
176a9643ea8Slogwang  *
177a9643ea8Slogwang  * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set, or
178a9643ea8Slogwang  * if ACPI_LV_DEBUG_OBJECT is set in the AcpiDbgLevel. Thus, in the normal
179a9643ea8Slogwang  * operational case, stores to the debug object are ignored but can be easily
180a9643ea8Slogwang  * enabled if necessary.
181a9643ea8Slogwang  *
182a9643ea8Slogwang  ******************************************************************************/
183a9643ea8Slogwang 
184a9643ea8Slogwang void
AcpiExDoDebugObject(ACPI_OPERAND_OBJECT * SourceDesc,UINT32 Level,UINT32 Index)185a9643ea8Slogwang AcpiExDoDebugObject (
186a9643ea8Slogwang     ACPI_OPERAND_OBJECT     *SourceDesc,
187a9643ea8Slogwang     UINT32                  Level,
188a9643ea8Slogwang     UINT32                  Index)
189a9643ea8Slogwang {
190a9643ea8Slogwang     UINT32                  i;
191a9643ea8Slogwang     UINT32                  Timer;
192a9643ea8Slogwang     ACPI_OPERAND_OBJECT     *ObjectDesc;
193a9643ea8Slogwang     UINT32                  Value;
194a9643ea8Slogwang 
195a9643ea8Slogwang 
196a9643ea8Slogwang     ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
197a9643ea8Slogwang 
198a9643ea8Slogwang 
199a9643ea8Slogwang     /* Output must be enabled via the DebugObject global or the DbgLevel */
200a9643ea8Slogwang 
201a9643ea8Slogwang     if (!AcpiGbl_EnableAmlDebugObject &&
202a9643ea8Slogwang         !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
203a9643ea8Slogwang     {
204a9643ea8Slogwang         return_VOID;
205a9643ea8Slogwang     }
206a9643ea8Slogwang 
207*22ce4affSfengbojiang     /* Newline -- don't emit the line header */
208a9643ea8Slogwang 
209a9643ea8Slogwang     if (SourceDesc &&
210a9643ea8Slogwang         (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) &&
211a9643ea8Slogwang         (SourceDesc->Common.Type == ACPI_TYPE_STRING))
212a9643ea8Slogwang     {
213*22ce4affSfengbojiang         if ((SourceDesc->String.Length == 1) &&
214*22ce4affSfengbojiang             (*SourceDesc->String.Pointer == '\n'))
215a9643ea8Slogwang         {
216a9643ea8Slogwang             AcpiOsPrintf ("\n");
217a9643ea8Slogwang             return_VOID;
218a9643ea8Slogwang         }
219a9643ea8Slogwang     }
220a9643ea8Slogwang 
221a9643ea8Slogwang     /*
222a9643ea8Slogwang      * Print line header as long as we are not in the middle of an
223a9643ea8Slogwang      * object display
224a9643ea8Slogwang      */
225a9643ea8Slogwang     if (!((Level > 0) && Index == 0))
226a9643ea8Slogwang     {
227a9643ea8Slogwang         if (AcpiGbl_DisplayDebugTimer)
228a9643ea8Slogwang         {
229a9643ea8Slogwang             /*
230a9643ea8Slogwang              * We will emit the current timer value (in microseconds) with each
231a9643ea8Slogwang              * debug output. Only need the lower 26 bits. This allows for 67
232a9643ea8Slogwang              * million microseconds or 67 seconds before rollover.
233a9643ea8Slogwang              *
234a9643ea8Slogwang              * Convert 100 nanosecond units to microseconds
235a9643ea8Slogwang              */
236a9643ea8Slogwang             Timer = ((UINT32) AcpiOsGetTimer () / 10);
237a9643ea8Slogwang             Timer &= 0x03FFFFFF;
238a9643ea8Slogwang 
239*22ce4affSfengbojiang             AcpiOsPrintf ("ACPI Debug: T=0x%8.8X %*s", Timer, Level, " ");
240a9643ea8Slogwang         }
241a9643ea8Slogwang         else
242a9643ea8Slogwang         {
243*22ce4affSfengbojiang             AcpiOsPrintf ("ACPI Debug: %*s", Level, " ");
244a9643ea8Slogwang         }
245a9643ea8Slogwang     }
246a9643ea8Slogwang 
247a9643ea8Slogwang     /* Display the index for package output only */
248a9643ea8Slogwang 
249a9643ea8Slogwang     if (Index > 0)
250a9643ea8Slogwang     {
251a9643ea8Slogwang        AcpiOsPrintf ("(%.2u) ", Index - 1);
252a9643ea8Slogwang     }
253a9643ea8Slogwang 
254a9643ea8Slogwang     if (!SourceDesc)
255a9643ea8Slogwang     {
256a9643ea8Slogwang         AcpiOsPrintf ("[Null Object]\n");
257a9643ea8Slogwang         return_VOID;
258a9643ea8Slogwang     }
259a9643ea8Slogwang 
260a9643ea8Slogwang     if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
261a9643ea8Slogwang     {
262a9643ea8Slogwang         /* No object type prefix needed for integers and strings */
263a9643ea8Slogwang 
264a9643ea8Slogwang         if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
265a9643ea8Slogwang             (SourceDesc->Common.Type != ACPI_TYPE_STRING))
266a9643ea8Slogwang         {
267a9643ea8Slogwang             AcpiOsPrintf ("%s  ", AcpiUtGetObjectTypeName (SourceDesc));
268a9643ea8Slogwang         }
269a9643ea8Slogwang 
270a9643ea8Slogwang         if (!AcpiUtValidInternalObject (SourceDesc))
271a9643ea8Slogwang         {
272a9643ea8Slogwang            AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
273a9643ea8Slogwang            return_VOID;
274a9643ea8Slogwang         }
275a9643ea8Slogwang     }
276a9643ea8Slogwang     else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
277a9643ea8Slogwang     {
278a9643ea8Slogwang         AcpiOsPrintf ("%s  (Node %p)\n",
279a9643ea8Slogwang             AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
280a9643ea8Slogwang                 SourceDesc);
281a9643ea8Slogwang         return_VOID;
282a9643ea8Slogwang     }
283a9643ea8Slogwang     else
284a9643ea8Slogwang     {
285a9643ea8Slogwang         return_VOID;
286a9643ea8Slogwang     }
287a9643ea8Slogwang 
288a9643ea8Slogwang     /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
289a9643ea8Slogwang 
290a9643ea8Slogwang     switch (SourceDesc->Common.Type)
291a9643ea8Slogwang     {
292a9643ea8Slogwang     case ACPI_TYPE_INTEGER:
293a9643ea8Slogwang 
294a9643ea8Slogwang         /* Output correct integer width */
295a9643ea8Slogwang 
296a9643ea8Slogwang         if (AcpiGbl_IntegerByteWidth == 4)
297a9643ea8Slogwang         {
298a9643ea8Slogwang             AcpiOsPrintf ("0x%8.8X\n",
299a9643ea8Slogwang                 (UINT32) SourceDesc->Integer.Value);
300a9643ea8Slogwang         }
301a9643ea8Slogwang         else
302a9643ea8Slogwang         {
303a9643ea8Slogwang             AcpiOsPrintf ("0x%8.8X%8.8X\n",
304a9643ea8Slogwang                 ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
305a9643ea8Slogwang         }
306a9643ea8Slogwang         break;
307a9643ea8Slogwang 
308a9643ea8Slogwang     case ACPI_TYPE_BUFFER:
309a9643ea8Slogwang 
310a9643ea8Slogwang         AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
311a9643ea8Slogwang         AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer,
312a9643ea8Slogwang             (SourceDesc->Buffer.Length < 256) ?
313a9643ea8Slogwang                 SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0);
314a9643ea8Slogwang         break;
315a9643ea8Slogwang 
316a9643ea8Slogwang     case ACPI_TYPE_STRING:
317a9643ea8Slogwang 
318a9643ea8Slogwang         AcpiOsPrintf ("\"%s\"\n", SourceDesc->String.Pointer);
319a9643ea8Slogwang         break;
320a9643ea8Slogwang 
321a9643ea8Slogwang     case ACPI_TYPE_PACKAGE:
322a9643ea8Slogwang 
323a9643ea8Slogwang         AcpiOsPrintf ("(Contains 0x%.2X Elements):\n",
324a9643ea8Slogwang             SourceDesc->Package.Count);
325a9643ea8Slogwang 
326a9643ea8Slogwang         /* Output the entire contents of the package */
327a9643ea8Slogwang 
328a9643ea8Slogwang         for (i = 0; i < SourceDesc->Package.Count; i++)
329a9643ea8Slogwang         {
330a9643ea8Slogwang             AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
331a9643ea8Slogwang                 Level + 4, i + 1);
332a9643ea8Slogwang         }
333a9643ea8Slogwang         break;
334a9643ea8Slogwang 
335a9643ea8Slogwang     case ACPI_TYPE_LOCAL_REFERENCE:
336a9643ea8Slogwang 
337a9643ea8Slogwang         AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
338a9643ea8Slogwang 
339a9643ea8Slogwang         /* Decode the reference */
340a9643ea8Slogwang 
341a9643ea8Slogwang         switch (SourceDesc->Reference.Class)
342a9643ea8Slogwang         {
343a9643ea8Slogwang         case ACPI_REFCLASS_INDEX:
344a9643ea8Slogwang 
345a9643ea8Slogwang             AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
346a9643ea8Slogwang             break;
347a9643ea8Slogwang 
348a9643ea8Slogwang         case ACPI_REFCLASS_TABLE:
349a9643ea8Slogwang 
350a9643ea8Slogwang             /* Case for DdbHandle */
351a9643ea8Slogwang 
352a9643ea8Slogwang             AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
353a9643ea8Slogwang             return_VOID;
354a9643ea8Slogwang 
355a9643ea8Slogwang         default:
356a9643ea8Slogwang 
357a9643ea8Slogwang             break;
358a9643ea8Slogwang         }
359a9643ea8Slogwang 
360a9643ea8Slogwang         AcpiOsPrintf ("  ");
361a9643ea8Slogwang 
362a9643ea8Slogwang         /* Check for valid node first, then valid object */
363a9643ea8Slogwang 
364a9643ea8Slogwang         if (SourceDesc->Reference.Node)
365a9643ea8Slogwang         {
366a9643ea8Slogwang             if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
367a9643ea8Slogwang                 ACPI_DESC_TYPE_NAMED)
368a9643ea8Slogwang             {
369a9643ea8Slogwang                 AcpiOsPrintf (" %p - Not a valid namespace node\n",
370a9643ea8Slogwang                     SourceDesc->Reference.Node);
371a9643ea8Slogwang             }
372a9643ea8Slogwang             else
373a9643ea8Slogwang             {
374a9643ea8Slogwang                 AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
375a9643ea8Slogwang                     (SourceDesc->Reference.Node)->Name.Ascii);
376a9643ea8Slogwang 
377a9643ea8Slogwang                 switch ((SourceDesc->Reference.Node)->Type)
378a9643ea8Slogwang                 {
379a9643ea8Slogwang                 /* These types have no attached object */
380a9643ea8Slogwang 
381a9643ea8Slogwang                 case ACPI_TYPE_DEVICE:
382a9643ea8Slogwang                     AcpiOsPrintf ("Device\n");
383a9643ea8Slogwang                     break;
384a9643ea8Slogwang 
385a9643ea8Slogwang                 case ACPI_TYPE_THERMAL:
386a9643ea8Slogwang                     AcpiOsPrintf ("Thermal Zone\n");
387a9643ea8Slogwang                     break;
388a9643ea8Slogwang 
389a9643ea8Slogwang                 default:
390a9643ea8Slogwang 
391a9643ea8Slogwang                     AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
392a9643ea8Slogwang                         Level + 4, 0);
393a9643ea8Slogwang                     break;
394a9643ea8Slogwang                 }
395a9643ea8Slogwang             }
396a9643ea8Slogwang         }
397a9643ea8Slogwang         else if (SourceDesc->Reference.Object)
398a9643ea8Slogwang         {
399a9643ea8Slogwang             if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
400a9643ea8Slogwang                 ACPI_DESC_TYPE_NAMED)
401a9643ea8Slogwang             {
402a9643ea8Slogwang                 /* Reference object is a namespace node */
403a9643ea8Slogwang 
404a9643ea8Slogwang                 AcpiExDoDebugObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT,
405a9643ea8Slogwang                     SourceDesc->Reference.Object),
406a9643ea8Slogwang                     Level + 4, 0);
407a9643ea8Slogwang             }
408a9643ea8Slogwang             else
409a9643ea8Slogwang             {
410a9643ea8Slogwang                 ObjectDesc = SourceDesc->Reference.Object;
411a9643ea8Slogwang                 Value = SourceDesc->Reference.Value;
412a9643ea8Slogwang 
413a9643ea8Slogwang                 switch (ObjectDesc->Common.Type)
414a9643ea8Slogwang                 {
415a9643ea8Slogwang                 case ACPI_TYPE_BUFFER:
416a9643ea8Slogwang 
417a9643ea8Slogwang                     AcpiOsPrintf ("Buffer[%u] = 0x%2.2X\n",
418a9643ea8Slogwang                         Value, *SourceDesc->Reference.IndexPointer);
419a9643ea8Slogwang                     break;
420a9643ea8Slogwang 
421a9643ea8Slogwang                 case ACPI_TYPE_STRING:
422a9643ea8Slogwang 
423a9643ea8Slogwang                     AcpiOsPrintf ("String[%u] = \"%c\" (0x%2.2X)\n",
424a9643ea8Slogwang                         Value, *SourceDesc->Reference.IndexPointer,
425a9643ea8Slogwang                         *SourceDesc->Reference.IndexPointer);
426a9643ea8Slogwang                     break;
427a9643ea8Slogwang 
428a9643ea8Slogwang                 case ACPI_TYPE_PACKAGE:
429a9643ea8Slogwang 
430a9643ea8Slogwang                     AcpiOsPrintf ("Package[%u] = ", Value);
431a9643ea8Slogwang                     if (!(*SourceDesc->Reference.Where))
432a9643ea8Slogwang                     {
433a9643ea8Slogwang                         AcpiOsPrintf ("[Uninitialized Package Element]\n");
434a9643ea8Slogwang                     }
435a9643ea8Slogwang                     else
436a9643ea8Slogwang                     {
437a9643ea8Slogwang                         AcpiExDoDebugObject (*SourceDesc->Reference.Where,
438a9643ea8Slogwang                             Level+4, 0);
439a9643ea8Slogwang                     }
440a9643ea8Slogwang                     break;
441a9643ea8Slogwang 
442a9643ea8Slogwang                 default:
443a9643ea8Slogwang 
444a9643ea8Slogwang                     AcpiOsPrintf ("Unknown Reference object type %X\n",
445a9643ea8Slogwang                         ObjectDesc->Common.Type);
446a9643ea8Slogwang                     break;
447a9643ea8Slogwang                 }
448a9643ea8Slogwang             }
449a9643ea8Slogwang         }
450a9643ea8Slogwang         break;
451a9643ea8Slogwang 
452a9643ea8Slogwang     default:
453a9643ea8Slogwang 
454a9643ea8Slogwang         AcpiOsPrintf ("(Descriptor %p)\n", SourceDesc);
455a9643ea8Slogwang         break;
456a9643ea8Slogwang     }
457a9643ea8Slogwang 
458a9643ea8Slogwang     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
459a9643ea8Slogwang     return_VOID;
460a9643ea8Slogwang }
461a9643ea8Slogwang #endif
462