1433d6423SLionel Sambuc /******************************************************************************
2433d6423SLionel Sambuc *
3433d6423SLionel Sambuc * Module Name: exdebug - Support for stores to the AML Debug Object
4433d6423SLionel Sambuc *
5433d6423SLionel Sambuc *****************************************************************************/
6433d6423SLionel Sambuc
7*29492bb7SDavid van Moolenbroek /*
8*29492bb7SDavid van Moolenbroek * Copyright (C) 2000 - 2014, Intel Corp.
9433d6423SLionel Sambuc * All rights reserved.
10433d6423SLionel Sambuc *
11*29492bb7SDavid van Moolenbroek * Redistribution and use in source and binary forms, with or without
12*29492bb7SDavid van Moolenbroek * modification, are permitted provided that the following conditions
13*29492bb7SDavid van Moolenbroek * are met:
14*29492bb7SDavid van Moolenbroek * 1. Redistributions of source code must retain the above copyright
15*29492bb7SDavid van Moolenbroek * notice, this list of conditions, and the following disclaimer,
16*29492bb7SDavid van Moolenbroek * without modification.
17*29492bb7SDavid van Moolenbroek * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*29492bb7SDavid van Moolenbroek * substantially similar to the "NO WARRANTY" disclaimer below
19*29492bb7SDavid van Moolenbroek * ("Disclaimer") and any redistribution must be conditioned upon
20*29492bb7SDavid van Moolenbroek * including a substantially similar Disclaimer requirement for further
21*29492bb7SDavid van Moolenbroek * binary redistribution.
22*29492bb7SDavid van Moolenbroek * 3. Neither the names of the above-listed copyright holders nor the names
23*29492bb7SDavid van Moolenbroek * of any contributors may be used to endorse or promote products derived
24*29492bb7SDavid van Moolenbroek * from this software without specific prior written permission.
25433d6423SLionel Sambuc *
26*29492bb7SDavid van Moolenbroek * Alternatively, this software may be distributed under the terms of the
27*29492bb7SDavid van Moolenbroek * GNU General Public License ("GPL") version 2 as published by the Free
28*29492bb7SDavid van Moolenbroek * Software Foundation.
29433d6423SLionel Sambuc *
30*29492bb7SDavid van Moolenbroek * NO WARRANTY
31*29492bb7SDavid van Moolenbroek * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*29492bb7SDavid van Moolenbroek * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*29492bb7SDavid van Moolenbroek * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*29492bb7SDavid van Moolenbroek * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*29492bb7SDavid van Moolenbroek * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*29492bb7SDavid van Moolenbroek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*29492bb7SDavid van Moolenbroek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*29492bb7SDavid van Moolenbroek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*29492bb7SDavid van Moolenbroek * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*29492bb7SDavid van Moolenbroek * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*29492bb7SDavid van Moolenbroek * POSSIBILITY OF SUCH DAMAGES.
42*29492bb7SDavid van Moolenbroek */
43433d6423SLionel Sambuc
44433d6423SLionel Sambuc #include "acpi.h"
45433d6423SLionel Sambuc #include "accommon.h"
46433d6423SLionel Sambuc #include "acinterp.h"
47433d6423SLionel Sambuc
48433d6423SLionel Sambuc
49433d6423SLionel Sambuc #define _COMPONENT ACPI_EXECUTER
50433d6423SLionel Sambuc ACPI_MODULE_NAME ("exdebug")
51433d6423SLionel Sambuc
52433d6423SLionel Sambuc
53433d6423SLionel Sambuc #ifndef ACPI_NO_ERROR_MESSAGES
54433d6423SLionel Sambuc /*******************************************************************************
55433d6423SLionel Sambuc *
56433d6423SLionel Sambuc * FUNCTION: AcpiExDoDebugObject
57433d6423SLionel Sambuc *
58433d6423SLionel Sambuc * PARAMETERS: SourceDesc - Object to be output to "Debug Object"
59433d6423SLionel Sambuc * Level - Indentation level (used for packages)
60433d6423SLionel Sambuc * Index - Current package element, zero if not pkg
61433d6423SLionel Sambuc *
62433d6423SLionel Sambuc * RETURN: None
63433d6423SLionel Sambuc *
64433d6423SLionel Sambuc * DESCRIPTION: Handles stores to the AML Debug Object. For example:
65433d6423SLionel Sambuc * Store(INT1, Debug)
66433d6423SLionel Sambuc *
67433d6423SLionel Sambuc * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
68433d6423SLionel Sambuc *
69433d6423SLionel Sambuc * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set, or
70433d6423SLionel Sambuc * if ACPI_LV_DEBUG_OBJECT is set in the AcpiDbgLevel. Thus, in the normal
71433d6423SLionel Sambuc * operational case, stores to the debug object are ignored but can be easily
72433d6423SLionel Sambuc * enabled if necessary.
73433d6423SLionel Sambuc *
74433d6423SLionel Sambuc ******************************************************************************/
75433d6423SLionel Sambuc
76433d6423SLionel Sambuc void
AcpiExDoDebugObject(ACPI_OPERAND_OBJECT * SourceDesc,UINT32 Level,UINT32 Index)77433d6423SLionel Sambuc AcpiExDoDebugObject (
78433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *SourceDesc,
79433d6423SLionel Sambuc UINT32 Level,
80433d6423SLionel Sambuc UINT32 Index)
81433d6423SLionel Sambuc {
82433d6423SLionel Sambuc UINT32 i;
83*29492bb7SDavid van Moolenbroek UINT32 Timer;
84433d6423SLionel Sambuc
85433d6423SLionel Sambuc
86433d6423SLionel Sambuc ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
87433d6423SLionel Sambuc
88433d6423SLionel Sambuc
89433d6423SLionel Sambuc /* Output must be enabled via the DebugObject global or the DbgLevel */
90433d6423SLionel Sambuc
91433d6423SLionel Sambuc if (!AcpiGbl_EnableAmlDebugObject &&
92433d6423SLionel Sambuc !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
93433d6423SLionel Sambuc {
94433d6423SLionel Sambuc return_VOID;
95433d6423SLionel Sambuc }
96433d6423SLionel Sambuc
97433d6423SLionel Sambuc /*
98*29492bb7SDavid van Moolenbroek * We will emit the current timer value (in microseconds) with each
99*29492bb7SDavid van Moolenbroek * debug output. Only need the lower 26 bits. This allows for 67
100*29492bb7SDavid van Moolenbroek * million microseconds or 67 seconds before rollover.
101*29492bb7SDavid van Moolenbroek */
102*29492bb7SDavid van Moolenbroek Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */
103*29492bb7SDavid van Moolenbroek Timer &= 0x03FFFFFF;
104*29492bb7SDavid van Moolenbroek
105*29492bb7SDavid van Moolenbroek /*
106433d6423SLionel Sambuc * Print line header as long as we are not in the middle of an
107433d6423SLionel Sambuc * object display
108433d6423SLionel Sambuc */
109433d6423SLionel Sambuc if (!((Level > 0) && Index == 0))
110433d6423SLionel Sambuc {
111*29492bb7SDavid van Moolenbroek AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " ");
112433d6423SLionel Sambuc }
113433d6423SLionel Sambuc
114433d6423SLionel Sambuc /* Display the index for package output only */
115433d6423SLionel Sambuc
116433d6423SLionel Sambuc if (Index > 0)
117433d6423SLionel Sambuc {
118433d6423SLionel Sambuc AcpiOsPrintf ("(%.2u) ", Index-1);
119433d6423SLionel Sambuc }
120433d6423SLionel Sambuc
121433d6423SLionel Sambuc if (!SourceDesc)
122433d6423SLionel Sambuc {
123433d6423SLionel Sambuc AcpiOsPrintf ("[Null Object]\n");
124433d6423SLionel Sambuc return_VOID;
125433d6423SLionel Sambuc }
126433d6423SLionel Sambuc
127433d6423SLionel Sambuc if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
128433d6423SLionel Sambuc {
129433d6423SLionel Sambuc AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
130433d6423SLionel Sambuc
131433d6423SLionel Sambuc if (!AcpiUtValidInternalObject (SourceDesc))
132433d6423SLionel Sambuc {
133433d6423SLionel Sambuc AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
134433d6423SLionel Sambuc return_VOID;
135433d6423SLionel Sambuc }
136433d6423SLionel Sambuc }
137433d6423SLionel Sambuc else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
138433d6423SLionel Sambuc {
139433d6423SLionel Sambuc AcpiOsPrintf ("%s: %p\n",
140433d6423SLionel Sambuc AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
141433d6423SLionel Sambuc SourceDesc);
142433d6423SLionel Sambuc return_VOID;
143433d6423SLionel Sambuc }
144433d6423SLionel Sambuc else
145433d6423SLionel Sambuc {
146433d6423SLionel Sambuc return_VOID;
147433d6423SLionel Sambuc }
148433d6423SLionel Sambuc
149433d6423SLionel Sambuc /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
150433d6423SLionel Sambuc
151433d6423SLionel Sambuc switch (SourceDesc->Common.Type)
152433d6423SLionel Sambuc {
153433d6423SLionel Sambuc case ACPI_TYPE_INTEGER:
154433d6423SLionel Sambuc
155433d6423SLionel Sambuc /* Output correct integer width */
156433d6423SLionel Sambuc
157433d6423SLionel Sambuc if (AcpiGbl_IntegerByteWidth == 4)
158433d6423SLionel Sambuc {
159433d6423SLionel Sambuc AcpiOsPrintf ("0x%8.8X\n",
160433d6423SLionel Sambuc (UINT32) SourceDesc->Integer.Value);
161433d6423SLionel Sambuc }
162433d6423SLionel Sambuc else
163433d6423SLionel Sambuc {
164433d6423SLionel Sambuc AcpiOsPrintf ("0x%8.8X%8.8X\n",
165433d6423SLionel Sambuc ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
166433d6423SLionel Sambuc }
167433d6423SLionel Sambuc break;
168433d6423SLionel Sambuc
169433d6423SLionel Sambuc case ACPI_TYPE_BUFFER:
170433d6423SLionel Sambuc
171433d6423SLionel Sambuc AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
172*29492bb7SDavid van Moolenbroek AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer,
173433d6423SLionel Sambuc (SourceDesc->Buffer.Length < 256) ?
174*29492bb7SDavid van Moolenbroek SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0);
175433d6423SLionel Sambuc break;
176433d6423SLionel Sambuc
177433d6423SLionel Sambuc case ACPI_TYPE_STRING:
178433d6423SLionel Sambuc
179433d6423SLionel Sambuc AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
180433d6423SLionel Sambuc SourceDesc->String.Length, SourceDesc->String.Pointer);
181433d6423SLionel Sambuc break;
182433d6423SLionel Sambuc
183433d6423SLionel Sambuc case ACPI_TYPE_PACKAGE:
184433d6423SLionel Sambuc
185433d6423SLionel Sambuc AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
186433d6423SLionel Sambuc SourceDesc->Package.Count);
187433d6423SLionel Sambuc
188433d6423SLionel Sambuc /* Output the entire contents of the package */
189433d6423SLionel Sambuc
190433d6423SLionel Sambuc for (i = 0; i < SourceDesc->Package.Count; i++)
191433d6423SLionel Sambuc {
192433d6423SLionel Sambuc AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
193433d6423SLionel Sambuc Level+4, i+1);
194433d6423SLionel Sambuc }
195433d6423SLionel Sambuc break;
196433d6423SLionel Sambuc
197433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_REFERENCE:
198433d6423SLionel Sambuc
199433d6423SLionel Sambuc AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
200433d6423SLionel Sambuc
201433d6423SLionel Sambuc /* Decode the reference */
202433d6423SLionel Sambuc
203433d6423SLionel Sambuc switch (SourceDesc->Reference.Class)
204433d6423SLionel Sambuc {
205433d6423SLionel Sambuc case ACPI_REFCLASS_INDEX:
206433d6423SLionel Sambuc
207433d6423SLionel Sambuc AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
208433d6423SLionel Sambuc break;
209433d6423SLionel Sambuc
210433d6423SLionel Sambuc case ACPI_REFCLASS_TABLE:
211433d6423SLionel Sambuc
212433d6423SLionel Sambuc /* Case for DdbHandle */
213433d6423SLionel Sambuc
214433d6423SLionel Sambuc AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
215*29492bb7SDavid van Moolenbroek return_VOID;
216433d6423SLionel Sambuc
217433d6423SLionel Sambuc default:
218*29492bb7SDavid van Moolenbroek
219433d6423SLionel Sambuc break;
220433d6423SLionel Sambuc }
221433d6423SLionel Sambuc
222433d6423SLionel Sambuc AcpiOsPrintf (" ");
223433d6423SLionel Sambuc
224433d6423SLionel Sambuc /* Check for valid node first, then valid object */
225433d6423SLionel Sambuc
226433d6423SLionel Sambuc if (SourceDesc->Reference.Node)
227433d6423SLionel Sambuc {
228433d6423SLionel Sambuc if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
229433d6423SLionel Sambuc ACPI_DESC_TYPE_NAMED)
230433d6423SLionel Sambuc {
231433d6423SLionel Sambuc AcpiOsPrintf (" %p - Not a valid namespace node\n",
232433d6423SLionel Sambuc SourceDesc->Reference.Node);
233433d6423SLionel Sambuc }
234433d6423SLionel Sambuc else
235433d6423SLionel Sambuc {
236433d6423SLionel Sambuc AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
237433d6423SLionel Sambuc (SourceDesc->Reference.Node)->Name.Ascii);
238433d6423SLionel Sambuc
239433d6423SLionel Sambuc switch ((SourceDesc->Reference.Node)->Type)
240433d6423SLionel Sambuc {
241433d6423SLionel Sambuc /* These types have no attached object */
242433d6423SLionel Sambuc
243433d6423SLionel Sambuc case ACPI_TYPE_DEVICE:
244433d6423SLionel Sambuc AcpiOsPrintf ("Device\n");
245433d6423SLionel Sambuc break;
246433d6423SLionel Sambuc
247433d6423SLionel Sambuc case ACPI_TYPE_THERMAL:
248433d6423SLionel Sambuc AcpiOsPrintf ("Thermal Zone\n");
249433d6423SLionel Sambuc break;
250433d6423SLionel Sambuc
251433d6423SLionel Sambuc default:
252*29492bb7SDavid van Moolenbroek
253433d6423SLionel Sambuc AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
254433d6423SLionel Sambuc Level+4, 0);
255433d6423SLionel Sambuc break;
256433d6423SLionel Sambuc }
257433d6423SLionel Sambuc }
258433d6423SLionel Sambuc }
259433d6423SLionel Sambuc else if (SourceDesc->Reference.Object)
260433d6423SLionel Sambuc {
261433d6423SLionel Sambuc if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
262433d6423SLionel Sambuc ACPI_DESC_TYPE_NAMED)
263433d6423SLionel Sambuc {
264433d6423SLionel Sambuc AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
265433d6423SLionel Sambuc SourceDesc->Reference.Object)->Object,
266433d6423SLionel Sambuc Level+4, 0);
267433d6423SLionel Sambuc }
268433d6423SLionel Sambuc else
269433d6423SLionel Sambuc {
270433d6423SLionel Sambuc AcpiExDoDebugObject (SourceDesc->Reference.Object,
271433d6423SLionel Sambuc Level+4, 0);
272433d6423SLionel Sambuc }
273433d6423SLionel Sambuc }
274433d6423SLionel Sambuc break;
275433d6423SLionel Sambuc
276433d6423SLionel Sambuc default:
277433d6423SLionel Sambuc
278433d6423SLionel Sambuc AcpiOsPrintf ("%p\n", SourceDesc);
279433d6423SLionel Sambuc break;
280433d6423SLionel Sambuc }
281433d6423SLionel Sambuc
282433d6423SLionel Sambuc ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
283433d6423SLionel Sambuc return_VOID;
284433d6423SLionel Sambuc }
285433d6423SLionel Sambuc #endif
286