mm/zsmalloc: allocate exactly size of struct zs_pool
[linux/fpc-iii.git] / drivers / acpi / acpica / exdebug.c
blob6fbfad47518c825c046f9c3eea50aafa103f48fe
1 /******************************************************************************
3 * Module Name: exdebug - Support for stores to the AML Debug Object
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2014, 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;
78 u32 timer;
80 ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc);
82 /* Output must be enabled via the debug_object global or the dbg_level */
84 if (!acpi_gbl_enable_aml_debug_object &&
85 !(acpi_dbg_level & ACPI_LV_DEBUG_OBJECT)) {
86 return_VOID;
90 * We will emit the current timer value (in microseconds) with each
91 * debug output. Only need the lower 26 bits. This allows for 67
92 * million microseconds or 67 seconds before rollover.
94 timer = ((u32)acpi_os_get_timer() / 10); /* (100 nanoseconds to microseconds) */
95 timer &= 0x03FFFFFF;
98 * Print line header as long as we are not in the middle of an
99 * object display
101 if (!((level > 0) && index == 0)) {
102 acpi_os_printf("[ACPI Debug %.8u] %*s", timer, level, " ");
105 /* Display the index for package output only */
107 if (index > 0) {
108 acpi_os_printf("(%.2u) ", index - 1);
111 if (!source_desc) {
112 acpi_os_printf("[Null Object]\n");
113 return_VOID;
116 if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
117 acpi_os_printf("%s ",
118 acpi_ut_get_object_type_name(source_desc));
120 if (!acpi_ut_valid_internal_object(source_desc)) {
121 acpi_os_printf("%p, Invalid Internal Object!\n",
122 source_desc);
123 return_VOID;
125 } else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) ==
126 ACPI_DESC_TYPE_NAMED) {
127 acpi_os_printf("%s: %p\n",
128 acpi_ut_get_type_name(((struct
129 acpi_namespace_node *)
130 source_desc)->type),
131 source_desc);
132 return_VOID;
133 } else {
134 return_VOID;
137 /* source_desc is of type ACPI_DESC_TYPE_OPERAND */
139 switch (source_desc->common.type) {
140 case ACPI_TYPE_INTEGER:
142 /* Output correct integer width */
144 if (acpi_gbl_integer_byte_width == 4) {
145 acpi_os_printf("0x%8.8X\n",
146 (u32)source_desc->integer.value);
147 } else {
148 acpi_os_printf("0x%8.8X%8.8X\n",
149 ACPI_FORMAT_UINT64(source_desc->integer.
150 value));
152 break;
154 case ACPI_TYPE_BUFFER:
156 acpi_os_printf("[0x%.2X]\n", (u32)source_desc->buffer.length);
157 acpi_ut_dump_buffer(source_desc->buffer.pointer,
158 (source_desc->buffer.length < 256) ?
159 source_desc->buffer.length : 256,
160 DB_BYTE_DISPLAY, 0);
161 break;
163 case ACPI_TYPE_STRING:
165 acpi_os_printf("[0x%.2X] \"%s\"\n",
166 source_desc->string.length,
167 source_desc->string.pointer);
168 break;
170 case ACPI_TYPE_PACKAGE:
172 acpi_os_printf("[Contains 0x%.2X Elements]\n",
173 source_desc->package.count);
175 /* Output the entire contents of the package */
177 for (i = 0; i < source_desc->package.count; i++) {
178 acpi_ex_do_debug_object(source_desc->package.
179 elements[i], level + 4, i + 1);
181 break;
183 case ACPI_TYPE_LOCAL_REFERENCE:
185 acpi_os_printf("[%s] ",
186 acpi_ut_get_reference_name(source_desc));
188 /* Decode the reference */
190 switch (source_desc->reference.class) {
191 case ACPI_REFCLASS_INDEX:
193 acpi_os_printf("0x%X\n", source_desc->reference.value);
194 break;
196 case ACPI_REFCLASS_TABLE:
198 /* Case for ddb_handle */
200 acpi_os_printf("Table Index 0x%X\n",
201 source_desc->reference.value);
202 return_VOID;
204 default:
206 break;
209 acpi_os_printf(" ");
211 /* Check for valid node first, then valid object */
213 if (source_desc->reference.node) {
214 if (ACPI_GET_DESCRIPTOR_TYPE
215 (source_desc->reference.node) !=
216 ACPI_DESC_TYPE_NAMED) {
217 acpi_os_printf
218 (" %p - Not a valid namespace node\n",
219 source_desc->reference.node);
220 } else {
221 acpi_os_printf("Node %p [%4.4s] ",
222 source_desc->reference.node,
223 (source_desc->reference.node)->
224 name.ascii);
226 switch ((source_desc->reference.node)->type) {
228 /* These types have no attached object */
230 case ACPI_TYPE_DEVICE:
231 acpi_os_printf("Device\n");
232 break;
234 case ACPI_TYPE_THERMAL:
235 acpi_os_printf("Thermal Zone\n");
236 break;
238 default:
240 acpi_ex_do_debug_object((source_desc->
241 reference.
242 node)->object,
243 level + 4, 0);
244 break;
247 } else if (source_desc->reference.object) {
248 if (ACPI_GET_DESCRIPTOR_TYPE
249 (source_desc->reference.object) ==
250 ACPI_DESC_TYPE_NAMED) {
251 acpi_ex_do_debug_object(((struct
252 acpi_namespace_node *)
253 source_desc->reference.
254 object)->object,
255 level + 4, 0);
256 } else {
257 acpi_ex_do_debug_object(source_desc->reference.
258 object, level + 4, 0);
261 break;
263 default:
265 acpi_os_printf("%p\n", source_desc);
266 break;
269 ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
270 return_VOID;
272 #endif