1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /******************************************************************************
4 * Module Name: exdebug - Support for stores to the AML Debug Object
6 * Copyright (C) 2000 - 2019, Intel Corp.
8 *****************************************************************************/
10 #include <acpi/acpi.h>
14 #define _COMPONENT ACPI_EXECUTER
15 ACPI_MODULE_NAME("exdebug")
17 #ifndef ACPI_NO_ERROR_MESSAGES
18 /*******************************************************************************
20 * FUNCTION: acpi_ex_do_debug_object
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
28 * DESCRIPTION: Handles stores to the AML Debug Object. For example:
31 * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
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.
38 ******************************************************************************/
40 acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
45 union acpi_operand_object *object_desc;
48 ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc);
50 /* Output must be enabled via the debug_object global or the dbg_level */
52 if (!acpi_gbl_enable_aml_debug_object &&
53 !(acpi_dbg_level & ACPI_LV_DEBUG_OBJECT)) {
57 /* Newline -- don't emit the line header */
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')) {
70 * Print line header as long as we are not in the middle of an
73 if (!((level > 0) && index == 0)) {
74 if (acpi_gbl_display_debug_timer) {
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.
80 * Convert 100 nanosecond units to microseconds
82 timer = ((u32)acpi_os_get_timer() / 10);
85 acpi_os_printf("ACPI Debug: T=0x%8.8X %*s", timer,
88 acpi_os_printf("ACPI Debug: %*s", level, " ");
92 /* Display the index for package output only */
95 acpi_os_printf("(%.2u) ", index - 1);
99 acpi_os_printf("[Null Object]\n");
103 if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
105 /* No object type prefix needed for integers and strings */
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
114 if (!acpi_ut_valid_internal_object(source_desc)) {
115 acpi_os_printf("%p, Invalid Internal Object!\n",
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 *)
131 /* source_desc is of type ACPI_DESC_TYPE_OPERAND */
133 switch (source_desc->common.type) {
134 case ACPI_TYPE_INTEGER:
136 /* Output correct integer width */
138 if (acpi_gbl_integer_byte_width == 4) {
139 acpi_os_printf("0x%8.8X\n",
140 (u32)source_desc->integer.value);
142 acpi_os_printf("0x%8.8X%8.8X\n",
143 ACPI_FORMAT_UINT64(source_desc->integer.
148 case ACPI_TYPE_BUFFER:
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,
157 case ACPI_TYPE_STRING:
159 acpi_os_printf("\"%s\"\n", source_desc->string.pointer);
162 case ACPI_TYPE_PACKAGE:
164 acpi_os_printf("(Contains 0x%.2X Elements):\n",
165 source_desc->package.count);
167 /* Output the entire contents of the package */
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);
175 case ACPI_TYPE_LOCAL_REFERENCE:
177 acpi_os_printf("[%s] ",
178 acpi_ut_get_reference_name(source_desc));
180 /* Decode the reference */
182 switch (source_desc->reference.class) {
183 case ACPI_REFCLASS_INDEX:
185 acpi_os_printf("0x%X\n", source_desc->reference.value);
188 case ACPI_REFCLASS_TABLE:
190 /* Case for ddb_handle */
192 acpi_os_printf("Table Index 0x%X\n",
193 source_desc->reference.value);
203 /* Check for valid node first, then valid object */
205 if (source_desc->reference.node) {
206 if (ACPI_GET_DESCRIPTOR_TYPE
207 (source_desc->reference.node) !=
208 ACPI_DESC_TYPE_NAMED) {
210 (" %p - Not a valid namespace node\n",
211 source_desc->reference.node);
213 acpi_os_printf("Node %p [%4.4s] ",
214 source_desc->reference.node,
215 (source_desc->reference.node)->
218 switch ((source_desc->reference.node)->type) {
220 /* These types have no attached object */
222 case ACPI_TYPE_DEVICE:
223 acpi_os_printf("Device\n");
226 case ACPI_TYPE_THERMAL:
227 acpi_os_printf("Thermal Zone\n");
232 acpi_ex_do_debug_object((source_desc->
239 } else if (source_desc->reference.object) {
240 if (ACPI_GET_DESCRIPTOR_TYPE
241 (source_desc->reference.object) ==
242 ACPI_DESC_TYPE_NAMED) {
244 /* Reference object is a namespace node */
246 acpi_ex_do_debug_object(ACPI_CAST_PTR
249 source_desc->reference.
250 object), level + 4, 0);
252 object_desc = source_desc->reference.object;
253 value = source_desc->reference.value;
255 switch (object_desc->common.type) {
256 case ACPI_TYPE_BUFFER:
258 acpi_os_printf("Buffer[%u] = 0x%2.2X\n",
260 *source_desc->reference.
264 case ACPI_TYPE_STRING:
267 ("String[%u] = \"%c\" (0x%2.2X)\n",
269 *source_desc->reference.
271 *source_desc->reference.
275 case ACPI_TYPE_PACKAGE:
277 acpi_os_printf("Package[%u] = ", value);
278 if (!(*source_desc->reference.where)) {
280 ("[Uninitialized Package Element]\n");
282 acpi_ex_do_debug_object
283 (*source_desc->reference.
284 where, level + 4, 0);
291 ("Unknown Reference object type %X\n",
292 object_desc->common.type);
301 acpi_os_printf("(Descriptor %p)\n", source_desc);
305 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));