blob: 815442bbd0518e6d2ee154971966eff3a760c6d5 [file] [log] [blame]
Lin Ming4cdf1a52010-03-03 16:28:28 +08001/******************************************************************************
2 *
3 * Module Name: exdebug - Support for stores to the AML Debug Object
4 *
5 *****************************************************************************/
6
7/*
David E. Box82a80942015-02-05 15:20:45 +08008 * Copyright (C) 2000 - 2015, Intel Corp.
Lin Ming4cdf1a52010-03-03 16:28:28 +08009 * 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"
Bob Mooreba494be2012-07-12 09:40:10 +080057 * level - Indentation level (used for packages)
58 * index - Current package element, zero if not pkg
Lin Ming4cdf1a52010-03-03 16:28:28 +080059 *
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;
Bob Moore1aae3b92014-07-30 12:21:19 +080078 u32 timer;
Bob Moorefde175e2015-07-01 14:44:44 +080079 union acpi_operand_object *object_desc;
80 u32 value;
Lin Ming4cdf1a52010-03-03 16:28:28 +080081
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
91 /*
Bob Moore1aae3b92014-07-30 12:21:19 +080092 * We will emit the current timer value (in microseconds) with each
93 * debug output. Only need the lower 26 bits. This allows for 67
94 * million microseconds or 67 seconds before rollover.
95 */
96 timer = ((u32)acpi_os_get_timer() / 10); /* (100 nanoseconds to microseconds) */
97 timer &= 0x03FFFFFF;
98
99 /*
Lin Ming4cdf1a52010-03-03 16:28:28 +0800100 * Print line header as long as we are not in the middle of an
101 * object display
102 */
103 if (!((level > 0) && index == 0)) {
Bob Moore1aae3b92014-07-30 12:21:19 +0800104 acpi_os_printf("[ACPI Debug %.8u] %*s", timer, level, " ");
Lin Ming4cdf1a52010-03-03 16:28:28 +0800105 }
106
107 /* Display the index for package output only */
108
109 if (index > 0) {
110 acpi_os_printf("(%.2u) ", index - 1);
111 }
112
113 if (!source_desc) {
114 acpi_os_printf("[Null Object]\n");
115 return_VOID;
116 }
117
118 if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
119 acpi_os_printf("%s ",
120 acpi_ut_get_object_type_name(source_desc));
121
122 if (!acpi_ut_valid_internal_object(source_desc)) {
123 acpi_os_printf("%p, Invalid Internal Object!\n",
124 source_desc);
125 return_VOID;
126 }
127 } else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) ==
128 ACPI_DESC_TYPE_NAMED) {
129 acpi_os_printf("%s: %p\n",
130 acpi_ut_get_type_name(((struct
131 acpi_namespace_node *)
132 source_desc)->type),
133 source_desc);
134 return_VOID;
135 } else {
136 return_VOID;
137 }
138
139 /* source_desc is of type ACPI_DESC_TYPE_OPERAND */
140
141 switch (source_desc->common.type) {
142 case ACPI_TYPE_INTEGER:
143
144 /* Output correct integer width */
145
146 if (acpi_gbl_integer_byte_width == 4) {
147 acpi_os_printf("0x%8.8X\n",
148 (u32)source_desc->integer.value);
149 } else {
150 acpi_os_printf("0x%8.8X%8.8X\n",
151 ACPI_FORMAT_UINT64(source_desc->integer.
152 value));
153 }
154 break;
155
156 case ACPI_TYPE_BUFFER:
157
158 acpi_os_printf("[0x%.2X]\n", (u32)source_desc->buffer.length);
Bob Moore97171c62012-10-31 02:28:11 +0000159 acpi_ut_dump_buffer(source_desc->buffer.pointer,
160 (source_desc->buffer.length < 256) ?
161 source_desc->buffer.length : 256,
162 DB_BYTE_DISPLAY, 0);
Lin Ming4cdf1a52010-03-03 16:28:28 +0800163 break;
164
165 case ACPI_TYPE_STRING:
166
167 acpi_os_printf("[0x%.2X] \"%s\"\n",
168 source_desc->string.length,
169 source_desc->string.pointer);
170 break;
171
172 case ACPI_TYPE_PACKAGE:
173
174 acpi_os_printf("[Contains 0x%.2X Elements]\n",
175 source_desc->package.count);
176
177 /* Output the entire contents of the package */
178
179 for (i = 0; i < source_desc->package.count; i++) {
180 acpi_ex_do_debug_object(source_desc->package.
181 elements[i], level + 4, i + 1);
182 }
183 break;
184
185 case ACPI_TYPE_LOCAL_REFERENCE:
186
187 acpi_os_printf("[%s] ",
188 acpi_ut_get_reference_name(source_desc));
189
190 /* Decode the reference */
191
192 switch (source_desc->reference.class) {
193 case ACPI_REFCLASS_INDEX:
194
195 acpi_os_printf("0x%X\n", source_desc->reference.value);
196 break;
197
198 case ACPI_REFCLASS_TABLE:
199
200 /* Case for ddb_handle */
201
202 acpi_os_printf("Table Index 0x%X\n",
203 source_desc->reference.value);
Bob Moore68aafc32012-10-31 02:26:01 +0000204 return_VOID;
Lin Ming4cdf1a52010-03-03 16:28:28 +0800205
206 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000207
Lin Ming4cdf1a52010-03-03 16:28:28 +0800208 break;
209 }
210
211 acpi_os_printf(" ");
212
213 /* Check for valid node first, then valid object */
214
215 if (source_desc->reference.node) {
216 if (ACPI_GET_DESCRIPTOR_TYPE
217 (source_desc->reference.node) !=
218 ACPI_DESC_TYPE_NAMED) {
219 acpi_os_printf
220 (" %p - Not a valid namespace node\n",
221 source_desc->reference.node);
222 } else {
223 acpi_os_printf("Node %p [%4.4s] ",
224 source_desc->reference.node,
225 (source_desc->reference.node)->
226 name.ascii);
227
228 switch ((source_desc->reference.node)->type) {
229
230 /* These types have no attached object */
231
232 case ACPI_TYPE_DEVICE:
233 acpi_os_printf("Device\n");
234 break;
235
236 case ACPI_TYPE_THERMAL:
237 acpi_os_printf("Thermal Zone\n");
238 break;
239
240 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000241
Lin Ming4cdf1a52010-03-03 16:28:28 +0800242 acpi_ex_do_debug_object((source_desc->
243 reference.
244 node)->object,
245 level + 4, 0);
246 break;
247 }
248 }
249 } else if (source_desc->reference.object) {
250 if (ACPI_GET_DESCRIPTOR_TYPE
251 (source_desc->reference.object) ==
252 ACPI_DESC_TYPE_NAMED) {
253 acpi_ex_do_debug_object(((struct
254 acpi_namespace_node *)
255 source_desc->reference.
256 object)->object,
257 level + 4, 0);
258 } else {
Bob Moorefde175e2015-07-01 14:44:44 +0800259 object_desc = source_desc->reference.object;
260 value = source_desc->reference.value;
261
262 switch (object_desc->common.type) {
263 case ACPI_TYPE_BUFFER:
264
265 acpi_os_printf("Buffer[%u] = 0x%2.2X\n",
266 value,
267 *source_desc->reference.
268 index_pointer);
269 break;
270
271 case ACPI_TYPE_STRING:
272
273 acpi_os_printf
274 ("String[%u] = \"%c\" (0x%2.2X)\n",
275 value,
276 *source_desc->reference.
277 index_pointer,
278 *source_desc->reference.
279 index_pointer);
280 break;
281
282 case ACPI_TYPE_PACKAGE:
283
284 acpi_os_printf("Package[%u] = ", value);
285 acpi_ex_do_debug_object(*source_desc->
286 reference.where,
287 level + 4, 0);
288 break;
289
290 default:
291
292 acpi_os_printf
293 ("Unknown Reference object type %X\n",
294 object_desc->common.type);
295 break;
296 }
Lin Ming4cdf1a52010-03-03 16:28:28 +0800297 }
298 }
299 break;
300
301 default:
302
303 acpi_os_printf("%p\n", source_desc);
304 break;
305 }
306
307 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
308 return_VOID;
309}
310#endif