Linux Audio

Check our new training course

Loading...
v3.1
 
  1/******************************************************************************
  2 *
  3 * Module Name: exdebug - Support for stores to the AML Debug Object
  4 *
 
 
  5 *****************************************************************************/
  6
  7/*
  8 * Copyright (C) 2000 - 2011, Intel Corp.
  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"
 57 *              Level               - Indentation level (used for packages)
 58 *              Index               - Current package element, zero if not pkg
 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;
 
 
 
 78
 79	ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc);
 80
 81	/* Output must be enabled via the debug_object global or the dbg_level */
 82
 83	if (!acpi_gbl_enable_aml_debug_object &&
 84	    !(acpi_dbg_level & ACPI_LV_DEBUG_OBJECT)) {
 85		return_VOID;
 86	}
 87
 
 
 
 
 
 
 
 
 
 
 
 
 88	/*
 89	 * Print line header as long as we are not in the middle of an
 90	 * object display
 91	 */
 92	if (!((level > 0) && index == 0)) {
 93		acpi_os_printf("[ACPI Debug] %*s", level, " ");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 94	}
 95
 96	/* Display the index for package output only */
 97
 98	if (index > 0) {
 99		acpi_os_printf("(%.2u) ", index - 1);
100	}
101
102	if (!source_desc) {
103		acpi_os_printf("[Null Object]\n");
104		return_VOID;
105	}
106
107	if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
108		acpi_os_printf("%s ",
109			       acpi_ut_get_object_type_name(source_desc));
 
 
 
 
 
 
 
110
111		if (!acpi_ut_valid_internal_object(source_desc)) {
112			acpi_os_printf("%p, Invalid Internal Object!\n",
113				       source_desc);
114			return_VOID;
115		}
116	} else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) ==
117		   ACPI_DESC_TYPE_NAMED) {
118		acpi_os_printf("%s: %p\n",
119			       acpi_ut_get_type_name(((struct
120						       acpi_namespace_node *)
121						      source_desc)->type),
122			       source_desc);
123		return_VOID;
124	} else {
125		return_VOID;
126	}
127
128	/* source_desc is of type ACPI_DESC_TYPE_OPERAND */
129
130	switch (source_desc->common.type) {
131	case ACPI_TYPE_INTEGER:
132
133		/* Output correct integer width */
134
135		if (acpi_gbl_integer_byte_width == 4) {
136			acpi_os_printf("0x%8.8X\n",
137				       (u32)source_desc->integer.value);
138		} else {
139			acpi_os_printf("0x%8.8X%8.8X\n",
140				       ACPI_FORMAT_UINT64(source_desc->integer.
141							  value));
142		}
143		break;
144
145	case ACPI_TYPE_BUFFER:
146
147		acpi_os_printf("[0x%.2X]\n", (u32)source_desc->buffer.length);
148		acpi_ut_dump_buffer2(source_desc->buffer.pointer,
149				     (source_desc->buffer.length < 256) ?
150				     source_desc->buffer.length : 256,
151				     DB_BYTE_DISPLAY);
152		break;
153
154	case ACPI_TYPE_STRING:
155
156		acpi_os_printf("[0x%.2X] \"%s\"\n",
157			       source_desc->string.length,
158			       source_desc->string.pointer);
159		break;
160
161	case ACPI_TYPE_PACKAGE:
162
163		acpi_os_printf("[Contains 0x%.2X Elements]\n",
164			       source_desc->package.count);
165
166		/* Output the entire contents of the package */
167
168		for (i = 0; i < source_desc->package.count; i++) {
169			acpi_ex_do_debug_object(source_desc->package.
170						elements[i], level + 4, i + 1);
171		}
172		break;
173
174	case ACPI_TYPE_LOCAL_REFERENCE:
175
176		acpi_os_printf("[%s] ",
177			       acpi_ut_get_reference_name(source_desc));
178
179		/* Decode the reference */
180
181		switch (source_desc->reference.class) {
182		case ACPI_REFCLASS_INDEX:
183
184			acpi_os_printf("0x%X\n", source_desc->reference.value);
185			break;
186
187		case ACPI_REFCLASS_TABLE:
188
189			/* Case for ddb_handle */
190
191			acpi_os_printf("Table Index 0x%X\n",
192				       source_desc->reference.value);
193			return;
194
195		default:
 
196			break;
197		}
198
199		acpi_os_printf(" ");
200
201		/* Check for valid node first, then valid object */
202
203		if (source_desc->reference.node) {
204			if (ACPI_GET_DESCRIPTOR_TYPE
205			    (source_desc->reference.node) !=
206			    ACPI_DESC_TYPE_NAMED) {
207				acpi_os_printf
208				    (" %p - Not a valid namespace node\n",
209				     source_desc->reference.node);
210			} else {
211				acpi_os_printf("Node %p [%4.4s] ",
212					       source_desc->reference.node,
213					       (source_desc->reference.node)->
214					       name.ascii);
215
216				switch ((source_desc->reference.node)->type) {
217
218					/* These types have no attached object */
219
220				case ACPI_TYPE_DEVICE:
221					acpi_os_printf("Device\n");
222					break;
223
224				case ACPI_TYPE_THERMAL:
225					acpi_os_printf("Thermal Zone\n");
226					break;
227
228				default:
 
229					acpi_ex_do_debug_object((source_desc->
230								 reference.
231								 node)->object,
232								level + 4, 0);
233					break;
234				}
235			}
236		} else if (source_desc->reference.object) {
237			if (ACPI_GET_DESCRIPTOR_TYPE
238			    (source_desc->reference.object) ==
239			    ACPI_DESC_TYPE_NAMED) {
240				acpi_ex_do_debug_object(((struct
241							  acpi_namespace_node *)
 
 
 
 
242							 source_desc->reference.
243							 object)->object,
244							level + 4, 0);
245			} else {
246				acpi_ex_do_debug_object(source_desc->reference.
247							object, level + 4, 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248			}
249		}
250		break;
251
252	default:
253
254		acpi_os_printf("%p\n", source_desc);
255		break;
256	}
257
258	ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
259	return_VOID;
260}
261#endif
v5.9
  1// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2/******************************************************************************
  3 *
  4 * Module Name: exdebug - Support for stores to the AML Debug Object
  5 *
  6 * Copyright (C) 2000 - 2020, Intel Corp.
  7 *
  8 *****************************************************************************/
  9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 10#include <acpi/acpi.h>
 11#include "accommon.h"
 12#include "acinterp.h"
 13
 14#define _COMPONENT          ACPI_EXECUTER
 15ACPI_MODULE_NAME("exdebug")
 16
 17#ifndef ACPI_NO_ERROR_MESSAGES
 18/*******************************************************************************
 19 *
 20 * FUNCTION:    acpi_ex_do_debug_object
 21 *
 22 * PARAMETERS:  source_desc         - Object to be output to "Debug Object"
 23 *              level               - Indentation level (used for packages)
 24 *              index               - Current package element, zero if not pkg
 25 *
 26 * RETURN:      None
 27 *
 28 * DESCRIPTION: Handles stores to the AML Debug Object. For example:
 29 *              Store(INT1, Debug)
 30 *
 31 * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
 32 *
 33 * This function is only enabled if acpi_gbl_enable_aml_debug_object is set, or
 34 * if ACPI_LV_DEBUG_OBJECT is set in the acpi_dbg_level. Thus, in the normal
 35 * operational case, stores to the debug object are ignored but can be easily
 36 * enabled if necessary.
 37 *
 38 ******************************************************************************/
 39void
 40acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
 41			u32 level, u32 index)
 42{
 43	u32 i;
 44	u32 timer;
 45	union acpi_operand_object *object_desc;
 46	u32 value;
 47
 48	ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc);
 49
 50	/* Output must be enabled via the debug_object global or the dbg_level */
 51
 52	if (!acpi_gbl_enable_aml_debug_object &&
 53	    !(acpi_dbg_level & ACPI_LV_DEBUG_OBJECT)) {
 54		return_VOID;
 55	}
 56
 57	/* Newline -- don't emit the line header */
 58
 59	if (source_desc &&
 60	    (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) &&
 61	    (source_desc->common.type == ACPI_TYPE_STRING)) {
 62		if ((source_desc->string.length == 1) &&
 63		    (*source_desc->string.pointer == '\n')) {
 64			acpi_os_printf("\n");
 65			return_VOID;
 66		}
 67	}
 68
 69	/*
 70	 * Print line header as long as we are not in the middle of an
 71	 * object display
 72	 */
 73	if (!((level > 0) && index == 0)) {
 74		if (acpi_gbl_display_debug_timer) {
 75			/*
 76			 * We will emit the current timer value (in microseconds) with each
 77			 * debug output. Only need the lower 26 bits. This allows for 67
 78			 * million microseconds or 67 seconds before rollover.
 79			 *
 80			 * Convert 100 nanosecond units to microseconds
 81			 */
 82			timer = ((u32)acpi_os_get_timer() / 10);
 83			timer &= 0x03FFFFFF;
 84
 85			acpi_os_printf("ACPI Debug: T=0x%8.8X %*s", timer,
 86				       level, " ");
 87		} else {
 88			acpi_os_printf("ACPI Debug: %*s", level, " ");
 89		}
 90	}
 91
 92	/* Display the index for package output only */
 93
 94	if (index > 0) {
 95		acpi_os_printf("(%.2u) ", index - 1);
 96	}
 97
 98	if (!source_desc) {
 99		acpi_os_printf("[Null Object]\n");
100		return_VOID;
101	}
102
103	if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
104
105		/* No object type prefix needed for integers and strings */
106
107		if ((source_desc->common.type != ACPI_TYPE_INTEGER) &&
108		    (source_desc->common.type != ACPI_TYPE_STRING)) {
109			acpi_os_printf("%s ",
110				       acpi_ut_get_object_type_name
111				       (source_desc));
112		}
113
114		if (!acpi_ut_valid_internal_object(source_desc)) {
115			acpi_os_printf("%p, Invalid Internal Object!\n",
116				       source_desc);
117			return_VOID;
118		}
119	} else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) ==
120		   ACPI_DESC_TYPE_NAMED) {
121		acpi_os_printf("%s (Node %p)\n",
122			       acpi_ut_get_type_name(((struct
123						       acpi_namespace_node *)
124						      source_desc)->type),
125			       source_desc);
126		return_VOID;
127	} else {
128		return_VOID;
129	}
130
131	/* source_desc is of type ACPI_DESC_TYPE_OPERAND */
132
133	switch (source_desc->common.type) {
134	case ACPI_TYPE_INTEGER:
135
136		/* Output correct integer width */
137
138		if (acpi_gbl_integer_byte_width == 4) {
139			acpi_os_printf("0x%8.8X\n",
140				       (u32)source_desc->integer.value);
141		} else {
142			acpi_os_printf("0x%8.8X%8.8X\n",
143				       ACPI_FORMAT_UINT64(source_desc->integer.
144							  value));
145		}
146		break;
147
148	case ACPI_TYPE_BUFFER:
149
150		acpi_os_printf("[0x%.2X]\n", (u32)source_desc->buffer.length);
151		acpi_ut_dump_buffer(source_desc->buffer.pointer,
152				    (source_desc->buffer.length < 256) ?
153				    source_desc->buffer.length : 256,
154				    DB_BYTE_DISPLAY, 0);
155		break;
156
157	case ACPI_TYPE_STRING:
158
159		acpi_os_printf("\"%s\"\n", source_desc->string.pointer);
 
 
160		break;
161
162	case ACPI_TYPE_PACKAGE:
163
164		acpi_os_printf("(Contains 0x%.2X Elements):\n",
165			       source_desc->package.count);
166
167		/* Output the entire contents of the package */
168
169		for (i = 0; i < source_desc->package.count; i++) {
170			acpi_ex_do_debug_object(source_desc->package.
171						elements[i], level + 4, i + 1);
172		}
173		break;
174
175	case ACPI_TYPE_LOCAL_REFERENCE:
176
177		acpi_os_printf("[%s] ",
178			       acpi_ut_get_reference_name(source_desc));
179
180		/* Decode the reference */
181
182		switch (source_desc->reference.class) {
183		case ACPI_REFCLASS_INDEX:
184
185			acpi_os_printf("0x%X\n", source_desc->reference.value);
186			break;
187
188		case ACPI_REFCLASS_TABLE:
189
190			/* Case for ddb_handle */
191
192			acpi_os_printf("Table Index 0x%X\n",
193				       source_desc->reference.value);
194			return_VOID;
195
196		default:
197
198			break;
199		}
200
201		acpi_os_printf(" ");
202
203		/* Check for valid node first, then valid object */
204
205		if (source_desc->reference.node) {
206			if (ACPI_GET_DESCRIPTOR_TYPE
207			    (source_desc->reference.node) !=
208			    ACPI_DESC_TYPE_NAMED) {
209				acpi_os_printf
210				    (" %p - Not a valid namespace node\n",
211				     source_desc->reference.node);
212			} else {
213				acpi_os_printf("Node %p [%4.4s] ",
214					       source_desc->reference.node,
215					       (source_desc->reference.node)->
216					       name.ascii);
217
218				switch ((source_desc->reference.node)->type) {
219
220					/* These types have no attached object */
221
222				case ACPI_TYPE_DEVICE:
223					acpi_os_printf("Device\n");
224					break;
225
226				case ACPI_TYPE_THERMAL:
227					acpi_os_printf("Thermal Zone\n");
228					break;
229
230				default:
231
232					acpi_ex_do_debug_object((source_desc->
233								 reference.
234								 node)->object,
235								level + 4, 0);
236					break;
237				}
238			}
239		} else if (source_desc->reference.object) {
240			if (ACPI_GET_DESCRIPTOR_TYPE
241			    (source_desc->reference.object) ==
242			    ACPI_DESC_TYPE_NAMED) {
243
244				/* Reference object is a namespace node */
245
246				acpi_ex_do_debug_object(ACPI_CAST_PTR
247							(union
248							 acpi_operand_object,
249							 source_desc->reference.
250							 object), level + 4, 0);
 
251			} else {
252				object_desc = source_desc->reference.object;
253				value = source_desc->reference.value;
254
255				switch (object_desc->common.type) {
256				case ACPI_TYPE_BUFFER:
257
258					acpi_os_printf("Buffer[%u] = 0x%2.2X\n",
259						       value,
260						       *source_desc->reference.
261						       index_pointer);
262					break;
263
264				case ACPI_TYPE_STRING:
265
266					acpi_os_printf
267					    ("String[%u] = \"%c\" (0x%2.2X)\n",
268					     value,
269					     *source_desc->reference.
270					     index_pointer,
271					     *source_desc->reference.
272					     index_pointer);
273					break;
274
275				case ACPI_TYPE_PACKAGE:
276
277					acpi_os_printf("Package[%u] = ", value);
278					if (!(*source_desc->reference.where)) {
279						acpi_os_printf
280						    ("[Uninitialized Package Element]\n");
281					} else {
282						acpi_ex_do_debug_object
283						    (*source_desc->reference.
284						     where, level + 4, 0);
285					}
286					break;
287
288				default:
289
290					acpi_os_printf
291					    ("Unknown Reference object type %X\n",
292					     object_desc->common.type);
293					break;
294				}
295			}
296		}
297		break;
298
299	default:
300
301		acpi_os_printf("(Descriptor %p)\n", source_desc);
302		break;
303	}
304
305	ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
306	return_VOID;
307}
308#endif