ACPICA: Debug Object: Cleanup output
[deliverable/linux.git] / drivers / acpi / acpica / exdebug.c
CommitLineData
4cdf1a56
LM
1/******************************************************************************
2 *
3 * Module Name: exdebug - Support for stores to the AML Debug Object
4 *
5 *****************************************************************************/
6
7/*
82a80941 8 * Copyright (C) 2000 - 2015, Intel Corp.
4cdf1a56
LM
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acinterp.h"
47
48#define _COMPONENT ACPI_EXECUTER
49ACPI_MODULE_NAME("exdebug")
50
51#ifndef ACPI_NO_ERROR_MESSAGES
52/*******************************************************************************
53 *
54 * FUNCTION: acpi_ex_do_debug_object
55 *
56 * PARAMETERS: source_desc - Object to be output to "Debug Object"
ba494bee
BM
57 * level - Indentation level (used for packages)
58 * index - Current package element, zero if not pkg
4cdf1a56
LM
59 *
60 * RETURN: None
61 *
62 * DESCRIPTION: Handles stores to the AML Debug Object. For example:
63 * Store(INT1, Debug)
64 *
65 * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
66 *
67 * This function is only enabled if acpi_gbl_enable_aml_debug_object is set, or
68 * if ACPI_LV_DEBUG_OBJECT is set in the acpi_dbg_level. Thus, in the normal
69 * operational case, stores to the debug object are ignored but can be easily
70 * enabled if necessary.
71 *
72 ******************************************************************************/
73void
74acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
75 u32 level, u32 index)
76{
77 u32 i;
1aae3b97 78 u32 timer;
fde175e3
BM
79 union acpi_operand_object *object_desc;
80 u32 value;
4cdf1a56
LM
81
82 ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc);
83
84 /* Output must be enabled via the debug_object global or the dbg_level */
85
86 if (!acpi_gbl_enable_aml_debug_object &&
87 !(acpi_dbg_level & ACPI_LV_DEBUG_OBJECT)) {
88 return_VOID;
89 }
90
5e568304
BM
91 /* Null string or newline -- don't emit the line header */
92
93 if ((ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) &&
94 (source_desc->common.type == ACPI_TYPE_STRING)) {
95 if ((source_desc->string.length == 0) ||
96 ((source_desc->string.length == 1) &&
97 (*source_desc->string.pointer == '\n'))) {
98 acpi_os_printf("\n");
99 return_VOID;
100 }
101 }
1aae3b97 102
4cdf1a56
LM
103 /*
104 * Print line header as long as we are not in the middle of an
105 * object display
106 */
107 if (!((level > 0) && index == 0)) {
5e568304
BM
108 if (acpi_gbl_display_debug_timer) {
109 /*
110 * We will emit the current timer value (in microseconds) with each
111 * debug output. Only need the lower 26 bits. This allows for 67
112 * million microseconds or 67 seconds before rollover.
113 *
114 * Convert 100 nanosecond units to microseconds
115 */
116 timer = ((u32)acpi_os_get_timer() / 10);
117 timer &= 0x03FFFFFF;
118
119 acpi_os_printf("[ACPI Debug T=0x%8.8X] %*s", timer,
120 level, " ");
121 } else {
122 acpi_os_printf("[ACPI Debug] %*s", level, " ");
123 }
4cdf1a56
LM
124 }
125
126 /* Display the index for package output only */
127
128 if (index > 0) {
129 acpi_os_printf("(%.2u) ", index - 1);
130 }
131
132 if (!source_desc) {
133 acpi_os_printf("[Null Object]\n");
134 return_VOID;
135 }
136
137 if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
5e568304
BM
138
139 /* No object type prefix needed for integers and strings */
140
141 if ((source_desc->common.type != ACPI_TYPE_INTEGER) &&
142 (source_desc->common.type != ACPI_TYPE_STRING)) {
143 acpi_os_printf("%s ",
144 acpi_ut_get_object_type_name
145 (source_desc));
146 }
4cdf1a56
LM
147
148 if (!acpi_ut_valid_internal_object(source_desc)) {
149 acpi_os_printf("%p, Invalid Internal Object!\n",
150 source_desc);
151 return_VOID;
152 }
153 } else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) ==
154 ACPI_DESC_TYPE_NAMED) {
5e568304 155 acpi_os_printf("%s (Node %p)\n",
4cdf1a56
LM
156 acpi_ut_get_type_name(((struct
157 acpi_namespace_node *)
158 source_desc)->type),
159 source_desc);
160 return_VOID;
161 } else {
162 return_VOID;
163 }
164
165 /* source_desc is of type ACPI_DESC_TYPE_OPERAND */
166
167 switch (source_desc->common.type) {
168 case ACPI_TYPE_INTEGER:
169
170 /* Output correct integer width */
171
172 if (acpi_gbl_integer_byte_width == 4) {
173 acpi_os_printf("0x%8.8X\n",
174 (u32)source_desc->integer.value);
175 } else {
176 acpi_os_printf("0x%8.8X%8.8X\n",
177 ACPI_FORMAT_UINT64(source_desc->integer.
178 value));
179 }
180 break;
181
182 case ACPI_TYPE_BUFFER:
183
184 acpi_os_printf("[0x%.2X]\n", (u32)source_desc->buffer.length);
97171c6b
BM
185 acpi_ut_dump_buffer(source_desc->buffer.pointer,
186 (source_desc->buffer.length < 256) ?
187 source_desc->buffer.length : 256,
188 DB_BYTE_DISPLAY, 0);
4cdf1a56
LM
189 break;
190
191 case ACPI_TYPE_STRING:
192
5e568304 193 acpi_os_printf("\"%s\"\n", source_desc->string.pointer);
4cdf1a56
LM
194 break;
195
196 case ACPI_TYPE_PACKAGE:
197
5e568304 198 acpi_os_printf("(Contains 0x%.2X Elements):\n",
4cdf1a56
LM
199 source_desc->package.count);
200
201 /* Output the entire contents of the package */
202
203 for (i = 0; i < source_desc->package.count; i++) {
204 acpi_ex_do_debug_object(source_desc->package.
205 elements[i], level + 4, i + 1);
206 }
207 break;
208
209 case ACPI_TYPE_LOCAL_REFERENCE:
210
211 acpi_os_printf("[%s] ",
212 acpi_ut_get_reference_name(source_desc));
213
214 /* Decode the reference */
215
216 switch (source_desc->reference.class) {
217 case ACPI_REFCLASS_INDEX:
218
219 acpi_os_printf("0x%X\n", source_desc->reference.value);
220 break;
221
222 case ACPI_REFCLASS_TABLE:
223
224 /* Case for ddb_handle */
225
226 acpi_os_printf("Table Index 0x%X\n",
227 source_desc->reference.value);
68aafc35 228 return_VOID;
4cdf1a56
LM
229
230 default:
1d1ea1b7 231
4cdf1a56
LM
232 break;
233 }
234
235 acpi_os_printf(" ");
236
237 /* Check for valid node first, then valid object */
238
239 if (source_desc->reference.node) {
240 if (ACPI_GET_DESCRIPTOR_TYPE
241 (source_desc->reference.node) !=
242 ACPI_DESC_TYPE_NAMED) {
243 acpi_os_printf
244 (" %p - Not a valid namespace node\n",
245 source_desc->reference.node);
246 } else {
247 acpi_os_printf("Node %p [%4.4s] ",
248 source_desc->reference.node,
249 (source_desc->reference.node)->
250 name.ascii);
251
252 switch ((source_desc->reference.node)->type) {
253
254 /* These types have no attached object */
255
256 case ACPI_TYPE_DEVICE:
257 acpi_os_printf("Device\n");
258 break;
259
260 case ACPI_TYPE_THERMAL:
261 acpi_os_printf("Thermal Zone\n");
262 break;
263
264 default:
1d1ea1b7 265
4cdf1a56
LM
266 acpi_ex_do_debug_object((source_desc->
267 reference.
268 node)->object,
269 level + 4, 0);
270 break;
271 }
272 }
273 } else if (source_desc->reference.object) {
274 if (ACPI_GET_DESCRIPTOR_TYPE
275 (source_desc->reference.object) ==
276 ACPI_DESC_TYPE_NAMED) {
5e568304
BM
277
278 /* Reference object is a namespace node */
279
280 acpi_ex_do_debug_object(ACPI_CAST_PTR
281 (union
282 acpi_operand_object,
4cdf1a56 283 source_desc->reference.
5e568304 284 object), level + 4, 0);
4cdf1a56 285 } else {
fde175e3
BM
286 object_desc = source_desc->reference.object;
287 value = source_desc->reference.value;
288
289 switch (object_desc->common.type) {
290 case ACPI_TYPE_BUFFER:
291
292 acpi_os_printf("Buffer[%u] = 0x%2.2X\n",
293 value,
294 *source_desc->reference.
295 index_pointer);
296 break;
297
298 case ACPI_TYPE_STRING:
299
300 acpi_os_printf
301 ("String[%u] = \"%c\" (0x%2.2X)\n",
302 value,
303 *source_desc->reference.
304 index_pointer,
305 *source_desc->reference.
306 index_pointer);
307 break;
308
309 case ACPI_TYPE_PACKAGE:
310
311 acpi_os_printf("Package[%u] = ", value);
312 acpi_ex_do_debug_object(*source_desc->
313 reference.where,
314 level + 4, 0);
315 break;
316
317 default:
318
319 acpi_os_printf
320 ("Unknown Reference object type %X\n",
321 object_desc->common.type);
322 break;
323 }
4cdf1a56
LM
324 }
325 }
326 break;
327
328 default:
329
5e568304 330 acpi_os_printf("(Descriptor %p)\n", source_desc);
4cdf1a56
LM
331 break;
332 }
333
334 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
335 return_VOID;
336}
337#endif
This page took 0.301584 seconds and 5 git commands to generate.