usb: fix a typo in a comment
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / acpi / acpica / exdebug.c
blobc7a2f1edd28276389d0a61bc5674ea6ee7e89b5d
1 /******************************************************************************
3 * Module Name: exdebug - Support for stores to the AML Debug Object
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #include <acpi/acpi.h>
45 #include "accommon.h"
46 #include "acinterp.h"
48 #define _COMPONENT ACPI_EXECUTER
49 ACPI_MODULE_NAME("exdebug")
51 #ifndef ACPI_NO_ERROR_MESSAGES
52 /*******************************************************************************
54 * FUNCTION: acpi_ex_do_debug_object
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
60 * RETURN: None
62 * DESCRIPTION: Handles stores to the AML Debug Object. For example:
63 * Store(INT1, Debug)
65 * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
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.
72 ******************************************************************************/
73 void
74 acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
75 u32 level, u32 index)
77 u32 i;
79 ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc);
81 /* Output must be enabled via the debug_object global or the dbg_level */
83 if (!acpi_gbl_enable_aml_debug_object &&
84 !(acpi_dbg_level & ACPI_LV_DEBUG_OBJECT)) {
85 return_VOID;
89 * Print line header as long as we are not in the middle of an
90 * object display
92 if (!((level > 0) && index == 0)) {
93 acpi_os_printf("[ACPI Debug] %*s", level, " ");
96 /* Display the index for package output only */
98 if (index > 0) {
99 acpi_os_printf("(%.2u) ", index - 1);
102 if (!source_desc) {
103 acpi_os_printf("[Null Object]\n");
104 return_VOID;
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));
111 if (!acpi_ut_valid_internal_object(source_desc)) {
112 acpi_os_printf("%p, Invalid Internal Object!\n",
113 source_desc);
114 return_VOID;
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;
128 /* source_desc is of type ACPI_DESC_TYPE_OPERAND */
130 switch (source_desc->common.type) {
131 case ACPI_TYPE_INTEGER:
133 /* Output correct integer width */
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));
143 break;
145 case ACPI_TYPE_BUFFER:
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;
154 case ACPI_TYPE_STRING:
156 acpi_os_printf("[0x%.2X] \"%s\"\n",
157 source_desc->string.length,
158 source_desc->string.pointer);
159 break;
161 case ACPI_TYPE_PACKAGE:
163 acpi_os_printf("[Contains 0x%.2X Elements]\n",
164 source_desc->package.count);
166 /* Output the entire contents of the package */
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);
172 break;
174 case ACPI_TYPE_LOCAL_REFERENCE:
176 acpi_os_printf("[%s] ",
177 acpi_ut_get_reference_name(source_desc));
179 /* Decode the reference */
181 switch (source_desc->reference.class) {
182 case ACPI_REFCLASS_INDEX:
184 acpi_os_printf("0x%X\n", source_desc->reference.value);
185 break;
187 case ACPI_REFCLASS_TABLE:
189 /* Case for ddb_handle */
191 acpi_os_printf("Table Index 0x%X\n",
192 source_desc->reference.value);
193 return;
195 default:
196 break;
199 acpi_os_printf(" ");
201 /* Check for valid node first, then valid object */
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);
216 switch ((source_desc->reference.node)->type) {
218 /* These types have no attached object */
220 case ACPI_TYPE_DEVICE:
221 acpi_os_printf("Device\n");
222 break;
224 case ACPI_TYPE_THERMAL:
225 acpi_os_printf("Thermal Zone\n");
226 break;
228 default:
229 acpi_ex_do_debug_object((source_desc->
230 reference.
231 node)->object,
232 level + 4, 0);
233 break;
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);
250 break;
252 default:
254 acpi_os_printf("%p\n", source_desc);
255 break;
258 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
259 return_VOID;
261 #endif