exdebug.c revision 1.5 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: exdebug - Support for stores to the AML Debug Object
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.3 jruoho /*
8 1.5 christos * Copyright (C) 2000 - 2014, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.3 jruoho * Redistribution and use in source and binary forms, with or without
12 1.3 jruoho * modification, are permitted provided that the following conditions
13 1.3 jruoho * are met:
14 1.3 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.3 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.3 jruoho * without modification.
17 1.3 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.3 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.3 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.3 jruoho * including a substantially similar Disclaimer requirement for further
21 1.3 jruoho * binary redistribution.
22 1.3 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.3 jruoho * of any contributors may be used to endorse or promote products derived
24 1.3 jruoho * from this software without specific prior written permission.
25 1.3 jruoho *
26 1.3 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.3 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.3 jruoho * Software Foundation.
29 1.3 jruoho *
30 1.3 jruoho * NO WARRANTY
31 1.3 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.3 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.3 jruoho * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.3 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.3 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.3 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.3 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.3 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.3 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.3 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.3 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.3 jruoho */
43 1.1 jruoho
44 1.1 jruoho #define __EXDEBUG_C__
45 1.1 jruoho
46 1.1 jruoho #include "acpi.h"
47 1.1 jruoho #include "accommon.h"
48 1.1 jruoho #include "acinterp.h"
49 1.1 jruoho
50 1.1 jruoho
51 1.1 jruoho #define _COMPONENT ACPI_EXECUTER
52 1.1 jruoho ACPI_MODULE_NAME ("exdebug")
53 1.1 jruoho
54 1.1 jruoho
55 1.1 jruoho #ifndef ACPI_NO_ERROR_MESSAGES
56 1.1 jruoho /*******************************************************************************
57 1.1 jruoho *
58 1.1 jruoho * FUNCTION: AcpiExDoDebugObject
59 1.1 jruoho *
60 1.1 jruoho * PARAMETERS: SourceDesc - Object to be output to "Debug Object"
61 1.1 jruoho * Level - Indentation level (used for packages)
62 1.1 jruoho * Index - Current package element, zero if not pkg
63 1.1 jruoho *
64 1.1 jruoho * RETURN: None
65 1.1 jruoho *
66 1.1 jruoho * DESCRIPTION: Handles stores to the AML Debug Object. For example:
67 1.1 jruoho * Store(INT1, Debug)
68 1.1 jruoho *
69 1.1 jruoho * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
70 1.1 jruoho *
71 1.2 jruoho * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set.
72 1.2 jruoho * Thus, in the normal operational case, stores to the debug object are
73 1.2 jruoho * ignored but can be easily enabled if necessary.
74 1.1 jruoho *
75 1.1 jruoho ******************************************************************************/
76 1.1 jruoho
77 1.1 jruoho void
78 1.1 jruoho AcpiExDoDebugObject (
79 1.1 jruoho ACPI_OPERAND_OBJECT *SourceDesc,
80 1.1 jruoho UINT32 Level,
81 1.1 jruoho UINT32 Index)
82 1.1 jruoho {
83 1.1 jruoho UINT32 i;
84 1.5 christos UINT32 Timer;
85 1.1 jruoho
86 1.1 jruoho
87 1.1 jruoho ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
88 1.1 jruoho
89 1.1 jruoho
90 1.2 jruoho /* Output must be enabled via the DebugObject global */
91 1.1 jruoho
92 1.2 jruoho if (!AcpiGbl_EnableAmlDebugObject)
93 1.1 jruoho {
94 1.1 jruoho return_VOID;
95 1.1 jruoho }
96 1.1 jruoho
97 1.1 jruoho /*
98 1.5 christos * We will emit the current timer value (in microseconds) with each
99 1.5 christos * debug output. Only need the lower 26 bits. This allows for 67
100 1.5 christos * million microseconds or 67 seconds before rollover.
101 1.5 christos */
102 1.5 christos Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */
103 1.5 christos Timer &= 0x03FFFFFF;
104 1.5 christos
105 1.5 christos /*
106 1.1 jruoho * Print line header as long as we are not in the middle of an
107 1.1 jruoho * object display
108 1.1 jruoho */
109 1.1 jruoho if (!((Level > 0) && Index == 0))
110 1.1 jruoho {
111 1.5 christos AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " ");
112 1.1 jruoho }
113 1.1 jruoho
114 1.1 jruoho /* Display the index for package output only */
115 1.1 jruoho
116 1.1 jruoho if (Index > 0)
117 1.1 jruoho {
118 1.1 jruoho AcpiOsPrintf ("(%.2u) ", Index-1);
119 1.1 jruoho }
120 1.1 jruoho
121 1.1 jruoho if (!SourceDesc)
122 1.1 jruoho {
123 1.1 jruoho AcpiOsPrintf ("[Null Object]\n");
124 1.1 jruoho return_VOID;
125 1.1 jruoho }
126 1.1 jruoho
127 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
128 1.1 jruoho {
129 1.1 jruoho AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
130 1.1 jruoho
131 1.1 jruoho if (!AcpiUtValidInternalObject (SourceDesc))
132 1.1 jruoho {
133 1.1 jruoho AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
134 1.1 jruoho return_VOID;
135 1.1 jruoho }
136 1.1 jruoho }
137 1.1 jruoho else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
138 1.1 jruoho {
139 1.1 jruoho AcpiOsPrintf ("%s: %p\n",
140 1.1 jruoho AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
141 1.1 jruoho SourceDesc);
142 1.1 jruoho return_VOID;
143 1.1 jruoho }
144 1.1 jruoho else
145 1.1 jruoho {
146 1.1 jruoho return_VOID;
147 1.1 jruoho }
148 1.1 jruoho
149 1.1 jruoho /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
150 1.1 jruoho
151 1.1 jruoho switch (SourceDesc->Common.Type)
152 1.1 jruoho {
153 1.1 jruoho case ACPI_TYPE_INTEGER:
154 1.1 jruoho
155 1.1 jruoho /* Output correct integer width */
156 1.1 jruoho
157 1.1 jruoho if (AcpiGbl_IntegerByteWidth == 4)
158 1.1 jruoho {
159 1.1 jruoho AcpiOsPrintf ("0x%8.8X\n",
160 1.1 jruoho (UINT32) SourceDesc->Integer.Value);
161 1.1 jruoho }
162 1.1 jruoho else
163 1.1 jruoho {
164 1.1 jruoho AcpiOsPrintf ("0x%8.8X%8.8X\n",
165 1.1 jruoho ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
166 1.1 jruoho }
167 1.1 jruoho break;
168 1.1 jruoho
169 1.1 jruoho case ACPI_TYPE_BUFFER:
170 1.1 jruoho
171 1.1 jruoho AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
172 1.4 christos AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer,
173 1.1 jruoho (SourceDesc->Buffer.Length < 256) ?
174 1.4 christos SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0);
175 1.1 jruoho break;
176 1.1 jruoho
177 1.1 jruoho case ACPI_TYPE_STRING:
178 1.1 jruoho
179 1.1 jruoho AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
180 1.1 jruoho SourceDesc->String.Length, SourceDesc->String.Pointer);
181 1.1 jruoho break;
182 1.1 jruoho
183 1.1 jruoho case ACPI_TYPE_PACKAGE:
184 1.1 jruoho
185 1.1 jruoho AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
186 1.1 jruoho SourceDesc->Package.Count);
187 1.1 jruoho
188 1.1 jruoho /* Output the entire contents of the package */
189 1.1 jruoho
190 1.1 jruoho for (i = 0; i < SourceDesc->Package.Count; i++)
191 1.1 jruoho {
192 1.1 jruoho AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
193 1.1 jruoho Level+4, i+1);
194 1.1 jruoho }
195 1.1 jruoho break;
196 1.1 jruoho
197 1.1 jruoho case ACPI_TYPE_LOCAL_REFERENCE:
198 1.1 jruoho
199 1.1 jruoho AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
200 1.1 jruoho
201 1.1 jruoho /* Decode the reference */
202 1.1 jruoho
203 1.1 jruoho switch (SourceDesc->Reference.Class)
204 1.1 jruoho {
205 1.1 jruoho case ACPI_REFCLASS_INDEX:
206 1.1 jruoho
207 1.1 jruoho AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
208 1.1 jruoho break;
209 1.1 jruoho
210 1.1 jruoho case ACPI_REFCLASS_TABLE:
211 1.1 jruoho
212 1.1 jruoho /* Case for DdbHandle */
213 1.1 jruoho
214 1.1 jruoho AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
215 1.4 christos return_VOID;
216 1.1 jruoho
217 1.1 jruoho default:
218 1.4 christos
219 1.1 jruoho break;
220 1.1 jruoho }
221 1.1 jruoho
222 1.1 jruoho AcpiOsPrintf (" ");
223 1.1 jruoho
224 1.1 jruoho /* Check for valid node first, then valid object */
225 1.1 jruoho
226 1.1 jruoho if (SourceDesc->Reference.Node)
227 1.1 jruoho {
228 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
229 1.1 jruoho ACPI_DESC_TYPE_NAMED)
230 1.1 jruoho {
231 1.1 jruoho AcpiOsPrintf (" %p - Not a valid namespace node\n",
232 1.1 jruoho SourceDesc->Reference.Node);
233 1.1 jruoho }
234 1.1 jruoho else
235 1.1 jruoho {
236 1.1 jruoho AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
237 1.1 jruoho (SourceDesc->Reference.Node)->Name.Ascii);
238 1.1 jruoho
239 1.1 jruoho switch ((SourceDesc->Reference.Node)->Type)
240 1.1 jruoho {
241 1.1 jruoho /* These types have no attached object */
242 1.1 jruoho
243 1.1 jruoho case ACPI_TYPE_DEVICE:
244 1.1 jruoho AcpiOsPrintf ("Device\n");
245 1.1 jruoho break;
246 1.1 jruoho
247 1.1 jruoho case ACPI_TYPE_THERMAL:
248 1.1 jruoho AcpiOsPrintf ("Thermal Zone\n");
249 1.1 jruoho break;
250 1.1 jruoho
251 1.1 jruoho default:
252 1.4 christos
253 1.1 jruoho AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
254 1.1 jruoho Level+4, 0);
255 1.1 jruoho break;
256 1.1 jruoho }
257 1.1 jruoho }
258 1.1 jruoho }
259 1.1 jruoho else if (SourceDesc->Reference.Object)
260 1.1 jruoho {
261 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
262 1.1 jruoho ACPI_DESC_TYPE_NAMED)
263 1.1 jruoho {
264 1.1 jruoho AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
265 1.1 jruoho SourceDesc->Reference.Object)->Object,
266 1.1 jruoho Level+4, 0);
267 1.1 jruoho }
268 1.1 jruoho else
269 1.1 jruoho {
270 1.1 jruoho AcpiExDoDebugObject (SourceDesc->Reference.Object,
271 1.1 jruoho Level+4, 0);
272 1.1 jruoho }
273 1.1 jruoho }
274 1.1 jruoho break;
275 1.1 jruoho
276 1.1 jruoho default:
277 1.1 jruoho
278 1.1 jruoho AcpiOsPrintf ("%p\n", SourceDesc);
279 1.1 jruoho break;
280 1.1 jruoho }
281 1.1 jruoho
282 1.1 jruoho ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
283 1.1 jruoho return_VOID;
284 1.1 jruoho }
285 1.1 jruoho #endif
286