blob: 983510640059a5bf24feb6e9d85620e918223ee3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: utdebug - Debug print routines
4 *
5 *****************************************************************************/
6
7/*
Bob Moorea8357b02010-01-22 19:07:36 +08008 * Copyright (C) 2000 - 2010, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47#define _COMPONENT ACPI_UTILITIES
Len Brown4be44fc2005-08-05 00:44:28 -040048ACPI_MODULE_NAME("utdebug")
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#ifdef ACPI_DEBUG_OUTPUT
Len Brownab8aa062006-07-07 20:11:07 -040050static acpi_thread_id acpi_gbl_prev_thread_id;
Len Brown4be44fc2005-08-05 00:44:28 -040051static char *acpi_gbl_fn_entry_str = "----Entry";
52static char *acpi_gbl_fn_exit_str = "----Exit-";
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Robert Moore0c9938c2005-07-29 15:15:00 -070054/* Local prototypes */
55
Len Brown4be44fc2005-08-05 00:44:28 -040056static const char *acpi_ut_trim_function_name(const char *function_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Robert Moore44f6c012005-04-18 22:49:35 -040058/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 *
60 * FUNCTION: acpi_ut_init_stack_ptr_trace
61 *
62 * PARAMETERS: None
63 *
64 * RETURN: None
65 *
Robert Moore44f6c012005-04-18 22:49:35 -040066 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 *
Robert Moore44f6c012005-04-18 22:49:35 -040068 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Len Brown4be44fc2005-08-05 00:44:28 -040070void acpi_ut_init_stack_ptr_trace(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
Bob Moore1d18c052008-04-10 19:06:40 +040072 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
Bob Moore1d18c052008-04-10 19:06:40 +040074 acpi_gbl_entry_stack_pointer = &current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075}
76
Robert Moore44f6c012005-04-18 22:49:35 -040077/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 *
79 * FUNCTION: acpi_ut_track_stack_ptr
80 *
81 * PARAMETERS: None
82 *
83 * RETURN: None
84 *
Robert Moore44f6c012005-04-18 22:49:35 -040085 * DESCRIPTION: Save the current CPU stack pointer
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 *
Robert Moore44f6c012005-04-18 22:49:35 -040087 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Len Brown4be44fc2005-08-05 00:44:28 -040089void acpi_ut_track_stack_ptr(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090{
Len Brown4be44fc2005-08-05 00:44:28 -040091 acpi_size current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Bob Moore1d18c052008-04-10 19:06:40 +040093 if (&current_sp < acpi_gbl_lowest_stack_pointer) {
94 acpi_gbl_lowest_stack_pointer = &current_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 }
96
97 if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
98 acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
99 }
100}
101
Robert Moore44f6c012005-04-18 22:49:35 -0400102/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 *
Robert Moore0c9938c2005-07-29 15:15:00 -0700104 * FUNCTION: acpi_ut_trim_function_name
105 *
106 * PARAMETERS: function_name - Ascii string containing a procedure name
107 *
108 * RETURN: Updated pointer to the function name
109 *
110 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
Harvey Harrison96b2dd12008-03-05 18:24:51 -0800111 * This allows compiler macros such as __func__ to be used
Robert Moore0c9938c2005-07-29 15:15:00 -0700112 * with no change to the debug output.
113 *
114 ******************************************************************************/
115
Len Brown4be44fc2005-08-05 00:44:28 -0400116static const char *acpi_ut_trim_function_name(const char *function_name)
Robert Moore0c9938c2005-07-29 15:15:00 -0700117{
118
119 /* All Function names are longer than 4 chars, check is safe */
120
Bob Moorea18ecf42005-08-15 03:42:00 -0800121 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400122
Robert Moore0c9938c2005-07-29 15:15:00 -0700123 /* This is the case where the original source has not been modified */
124
125 return (function_name + 4);
126 }
127
Bob Moorea18ecf42005-08-15 03:42:00 -0800128 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400129
Robert Moore0c9938c2005-07-29 15:15:00 -0700130 /* This is the case where the source has been 'linuxized' */
131
132 return (function_name + 5);
133 }
134
135 return (function_name);
136}
137
Robert Moore0c9938c2005-07-29 15:15:00 -0700138/*******************************************************************************
139 *
Bob Moore50df4d82008-12-31 03:01:23 +0800140 * FUNCTION: acpi_debug_print
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 *
Robert Moore44f6c012005-04-18 22:49:35 -0400142 * PARAMETERS: requested_debug_level - Requested debug print level
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 * line_number - Caller's line number (for error output)
Robert Mooref9f46012005-07-08 00:00:00 -0400144 * function_name - Caller's procedure name
145 * module_name - Caller's module name
146 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 * Format - Printf format field
148 * ... - Optional printf arguments
149 *
150 * RETURN: None
151 *
152 * DESCRIPTION: Print error message with prefix consisting of the module name,
153 * line number, and component ID.
154 *
Robert Moore44f6c012005-04-18 22:49:35 -0400155 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
Len Brown4be44fc2005-08-05 00:44:28 -0400157void ACPI_INTERNAL_VAR_XFACE
Bob Moore50df4d82008-12-31 03:01:23 +0800158acpi_debug_print(u32 requested_debug_level,
159 u32 line_number,
160 const char *function_name,
161 const char *module_name,
162 u32 component_id, const char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163{
Bob Moore83135242006-10-03 00:00:00 -0400164 acpi_thread_id thread_id;
Len Brown4be44fc2005-08-05 00:44:28 -0400165 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166
167 /*
168 * Stay silent if the debug level or component ID is disabled
169 */
170 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400171 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 return;
173 }
174
175 /*
176 * Thread tracking and context switch notification
177 */
Len Brown4be44fc2005-08-05 00:44:28 -0400178 thread_id = acpi_os_get_thread_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 if (thread_id != acpi_gbl_prev_thread_id) {
180 if (ACPI_LV_THREADS & acpi_dbg_level) {
Len Brown4be44fc2005-08-05 00:44:28 -0400181 acpi_os_printf
Bob Moore10b65752009-04-22 11:39:10 +0800182 ("\n**** Context Switch from TID %p to TID %p ****\n\n",
183 ACPI_CAST_PTR(void, acpi_gbl_prev_thread_id),
184 ACPI_CAST_PTR(void, thread_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 }
186
187 acpi_gbl_prev_thread_id = thread_id;
188 }
189
190 /*
191 * Display the module name, current line number, thread ID (if requested),
192 * current procedure nesting level, and the current procedure name
193 */
Len Brown4be44fc2005-08-05 00:44:28 -0400194 acpi_os_printf("%8s-%04ld ", module_name, line_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
196 if (ACPI_LV_THREADS & acpi_dbg_level) {
Bob Moore10b65752009-04-22 11:39:10 +0800197 acpi_os_printf("[%p] ", ACPI_CAST_PTR(void, thread_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 }
199
Len Brown4be44fc2005-08-05 00:44:28 -0400200 acpi_os_printf("[%02ld] %-22.22s: ",
201 acpi_gbl_nesting_level,
202 acpi_ut_trim_function_name(function_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
Len Brown4be44fc2005-08-05 00:44:28 -0400204 va_start(args, format);
205 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400206 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207}
Robert Moore44f6c012005-04-18 22:49:35 -0400208
Bob Moore50df4d82008-12-31 03:01:23 +0800209ACPI_EXPORT_SYMBOL(acpi_debug_print)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
Robert Moore44f6c012005-04-18 22:49:35 -0400211/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 *
Bob Moore50df4d82008-12-31 03:01:23 +0800213 * FUNCTION: acpi_debug_print_raw
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 *
215 * PARAMETERS: requested_debug_level - Requested debug print level
216 * line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400217 * function_name - Caller's procedure name
218 * module_name - Caller's module name
219 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 * Format - Printf format field
221 * ... - Optional printf arguments
222 *
223 * RETURN: None
224 *
225 * DESCRIPTION: Print message with no headers. Has same interface as
226 * debug_print so that the same macros can be used.
227 *
Robert Moore44f6c012005-04-18 22:49:35 -0400228 ******************************************************************************/
Len Brown4be44fc2005-08-05 00:44:28 -0400229void ACPI_INTERNAL_VAR_XFACE
Bob Moore50df4d82008-12-31 03:01:23 +0800230acpi_debug_print_raw(u32 requested_debug_level,
231 u32 line_number,
232 const char *function_name,
233 const char *module_name,
234 u32 component_id, const char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235{
Len Brown4be44fc2005-08-05 00:44:28 -0400236 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400239 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 return;
241 }
242
Len Brown4be44fc2005-08-05 00:44:28 -0400243 va_start(args, format);
244 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400245 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
Bob Moore50df4d82008-12-31 03:01:23 +0800248ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Robert Moore44f6c012005-04-18 22:49:35 -0400250/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 *
252 * FUNCTION: acpi_ut_trace
253 *
254 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400255 * function_name - Caller's procedure name
256 * module_name - Caller's module name
257 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 *
259 * RETURN: None
260 *
261 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
262 * set in debug_level
263 *
Robert Moore44f6c012005-04-18 22:49:35 -0400264 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265void
Len Brown4be44fc2005-08-05 00:44:28 -0400266acpi_ut_trace(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800267 const char *function_name,
268 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269{
270
271 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400272 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
Bob Moore50df4d82008-12-31 03:01:23 +0800274 acpi_debug_print(ACPI_LV_FUNCTIONS,
275 line_number, function_name, module_name, component_id,
276 "%s\n", acpi_gbl_fn_entry_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Bob Moore83135242006-10-03 00:00:00 -0400279ACPI_EXPORT_SYMBOL(acpi_ut_trace)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
Robert Moore44f6c012005-04-18 22:49:35 -0400281/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 *
283 * FUNCTION: acpi_ut_trace_ptr
284 *
285 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400286 * function_name - Caller's procedure name
287 * module_name - Caller's module name
288 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 * Pointer - Pointer to display
290 *
291 * RETURN: None
292 *
293 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
294 * set in debug_level
295 *
Robert Moore44f6c012005-04-18 22:49:35 -0400296 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297void
Len Brown4be44fc2005-08-05 00:44:28 -0400298acpi_ut_trace_ptr(u32 line_number,
299 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800300 const char *module_name, u32 component_id, void *pointer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301{
302 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400303 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
Bob Moore50df4d82008-12-31 03:01:23 +0800305 acpi_debug_print(ACPI_LV_FUNCTIONS,
306 line_number, function_name, module_name, component_id,
307 "%s %p\n", acpi_gbl_fn_entry_str, pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308}
309
Robert Moore44f6c012005-04-18 22:49:35 -0400310/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 *
312 * FUNCTION: acpi_ut_trace_str
313 *
314 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400315 * function_name - Caller's procedure name
316 * module_name - Caller's module name
317 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 * String - Additional string to display
319 *
320 * RETURN: None
321 *
322 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
323 * set in debug_level
324 *
Robert Moore44f6c012005-04-18 22:49:35 -0400325 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326
327void
Len Brown4be44fc2005-08-05 00:44:28 -0400328acpi_ut_trace_str(u32 line_number,
329 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800330 const char *module_name, u32 component_id, char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331{
332
333 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400334 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
Bob Moore50df4d82008-12-31 03:01:23 +0800336 acpi_debug_print(ACPI_LV_FUNCTIONS,
337 line_number, function_name, module_name, component_id,
338 "%s %s\n", acpi_gbl_fn_entry_str, string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339}
340
Robert Moore44f6c012005-04-18 22:49:35 -0400341/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 *
343 * FUNCTION: acpi_ut_trace_u32
344 *
345 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400346 * function_name - Caller's procedure name
347 * module_name - Caller's module name
348 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 * Integer - Integer to display
350 *
351 * RETURN: None
352 *
353 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
354 * set in debug_level
355 *
Robert Moore44f6c012005-04-18 22:49:35 -0400356 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
358void
Len Brown4be44fc2005-08-05 00:44:28 -0400359acpi_ut_trace_u32(u32 line_number,
360 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800361 const char *module_name, u32 component_id, u32 integer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362{
363
364 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400365 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366
Bob Moore50df4d82008-12-31 03:01:23 +0800367 acpi_debug_print(ACPI_LV_FUNCTIONS,
368 line_number, function_name, module_name, component_id,
369 "%s %08X\n", acpi_gbl_fn_entry_str, integer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370}
371
Robert Moore44f6c012005-04-18 22:49:35 -0400372/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 *
374 * FUNCTION: acpi_ut_exit
375 *
376 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400377 * function_name - Caller's procedure name
378 * module_name - Caller's module name
379 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 *
381 * RETURN: None
382 *
383 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
384 * set in debug_level
385 *
Robert Moore44f6c012005-04-18 22:49:35 -0400386 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
388void
Len Brown4be44fc2005-08-05 00:44:28 -0400389acpi_ut_exit(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800390 const char *function_name,
391 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392{
393
Bob Moore50df4d82008-12-31 03:01:23 +0800394 acpi_debug_print(ACPI_LV_FUNCTIONS,
395 line_number, function_name, module_name, component_id,
396 "%s\n", acpi_gbl_fn_exit_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397
398 acpi_gbl_nesting_level--;
399}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
Bob Moore83135242006-10-03 00:00:00 -0400401ACPI_EXPORT_SYMBOL(acpi_ut_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
Robert Moore44f6c012005-04-18 22:49:35 -0400403/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 *
405 * FUNCTION: acpi_ut_status_exit
406 *
407 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400408 * function_name - Caller's procedure name
409 * module_name - Caller's module name
410 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 * Status - Exit status code
412 *
413 * RETURN: None
414 *
415 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
416 * set in debug_level. Prints exit status also.
417 *
Robert Moore44f6c012005-04-18 22:49:35 -0400418 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419void
Len Brown4be44fc2005-08-05 00:44:28 -0400420acpi_ut_status_exit(u32 line_number,
421 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800422 const char *module_name,
423 u32 component_id, acpi_status status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424{
425
Len Brown4be44fc2005-08-05 00:44:28 -0400426 if (ACPI_SUCCESS(status)) {
Bob Moore50df4d82008-12-31 03:01:23 +0800427 acpi_debug_print(ACPI_LV_FUNCTIONS,
428 line_number, function_name, module_name,
429 component_id, "%s %s\n", acpi_gbl_fn_exit_str,
430 acpi_format_exception(status));
Len Brown4be44fc2005-08-05 00:44:28 -0400431 } else {
Bob Moore50df4d82008-12-31 03:01:23 +0800432 acpi_debug_print(ACPI_LV_FUNCTIONS,
433 line_number, function_name, module_name,
434 component_id, "%s ****Exception****: %s\n",
435 acpi_gbl_fn_exit_str,
436 acpi_format_exception(status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 }
438
439 acpi_gbl_nesting_level--;
440}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
Bob Moore83135242006-10-03 00:00:00 -0400442ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
Robert Moore44f6c012005-04-18 22:49:35 -0400444/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 *
446 * FUNCTION: acpi_ut_value_exit
447 *
448 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400449 * function_name - Caller's procedure name
450 * module_name - Caller's module name
451 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 * Value - Value to be printed with exit msg
453 *
454 * RETURN: None
455 *
456 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
457 * set in debug_level. Prints exit value also.
458 *
Robert Moore44f6c012005-04-18 22:49:35 -0400459 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460void
Len Brown4be44fc2005-08-05 00:44:28 -0400461acpi_ut_value_exit(u32 line_number,
462 const char *function_name,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800463 const char *module_name, u32 component_id, u64 value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464{
465
Bob Moore50df4d82008-12-31 03:01:23 +0800466 acpi_debug_print(ACPI_LV_FUNCTIONS,
467 line_number, function_name, module_name, component_id,
468 "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str,
469 ACPI_FORMAT_UINT64(value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
471 acpi_gbl_nesting_level--;
472}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473
Bob Moore83135242006-10-03 00:00:00 -0400474ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
Robert Moore44f6c012005-04-18 22:49:35 -0400476/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 *
478 * FUNCTION: acpi_ut_ptr_exit
479 *
480 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400481 * function_name - Caller's procedure name
482 * module_name - Caller's module name
483 * component_id - Caller's component ID
Robert Moore44f6c012005-04-18 22:49:35 -0400484 * Ptr - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 *
486 * RETURN: None
487 *
488 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
489 * set in debug_level. Prints exit value also.
490 *
Robert Moore44f6c012005-04-18 22:49:35 -0400491 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492void
Len Brown4be44fc2005-08-05 00:44:28 -0400493acpi_ut_ptr_exit(u32 line_number,
494 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800495 const char *module_name, u32 component_id, u8 *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496{
497
Bob Moore50df4d82008-12-31 03:01:23 +0800498 acpi_debug_print(ACPI_LV_FUNCTIONS,
499 line_number, function_name, module_name, component_id,
500 "%s %p\n", acpi_gbl_fn_exit_str, ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501
502 acpi_gbl_nesting_level--;
503}
504
505#endif
506
Robert Moore44f6c012005-04-18 22:49:35 -0400507/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 *
509 * FUNCTION: acpi_ut_dump_buffer
510 *
511 * PARAMETERS: Buffer - Buffer to dump
512 * Count - Amount to dump, in bytes
513 * Display - BYTE, WORD, DWORD, or QWORD display
514 * component_iD - Caller's component ID
515 *
516 * RETURN: None
517 *
518 * DESCRIPTION: Generic dump buffer in both hex and ascii.
519 *
Robert Moore44f6c012005-04-18 22:49:35 -0400520 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521
Bob Moore793c2382006-03-31 00:00:00 -0500522void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523{
Bob Moore67a119f2008-06-10 13:42:13 +0800524 u32 i = 0;
525 u32 j;
Len Brown4be44fc2005-08-05 00:44:28 -0400526 u32 temp32;
527 u8 buf_char;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528
Bob Moore5eb69182008-04-10 19:06:39 +0400529 if (!buffer) {
530 acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
531 return;
532 }
533
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 if ((count < 4) || (count & 0x01)) {
535 display = DB_BYTE_DISPLAY;
536 }
537
Robert Moore44f6c012005-04-18 22:49:35 -0400538 /* Nasty little dump buffer routine! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 while (i < count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400541
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 /* Print current offset */
543
Bob Moore67a119f2008-06-10 13:42:13 +0800544 acpi_os_printf("%6.4X: ", i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545
546 /* Print 16 hex chars */
547
548 for (j = 0; j < 16;) {
549 if (i + j >= count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400550
Robert Moore44f6c012005-04-18 22:49:35 -0400551 /* Dump fill spaces */
552
Len Brown4be44fc2005-08-05 00:44:28 -0400553 acpi_os_printf("%*s", ((display * 2) + 1), " ");
Bob Moore67a119f2008-06-10 13:42:13 +0800554 j += display;
Robert Moore44f6c012005-04-18 22:49:35 -0400555 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 }
557
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 switch (display) {
Bob Moore793c2382006-03-31 00:00:00 -0500559 case DB_BYTE_DISPLAY:
Len Brown4be44fc2005-08-05 00:44:28 -0400560 default: /* Default is BYTE display */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561
Bob Moore67a119f2008-06-10 13:42:13 +0800562 acpi_os_printf("%02X ",
563 buffer[(acpi_size) i + j]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 break;
565
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 case DB_WORD_DISPLAY:
567
Bob Moore67a119f2008-06-10 13:42:13 +0800568 ACPI_MOVE_16_TO_32(&temp32,
569 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400570 acpi_os_printf("%04X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 break;
572
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 case DB_DWORD_DISPLAY:
574
Bob Moore67a119f2008-06-10 13:42:13 +0800575 ACPI_MOVE_32_TO_32(&temp32,
576 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400577 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 break;
579
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 case DB_QWORD_DISPLAY:
581
Bob Moore67a119f2008-06-10 13:42:13 +0800582 ACPI_MOVE_32_TO_32(&temp32,
583 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400584 acpi_os_printf("%08X", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585
Bob Moore67a119f2008-06-10 13:42:13 +0800586 ACPI_MOVE_32_TO_32(&temp32,
587 &buffer[(acpi_size) i + j +
588 4]);
Len Brown4be44fc2005-08-05 00:44:28 -0400589 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 break;
591 }
Robert Moore44f6c012005-04-18 22:49:35 -0400592
Bob Moore67a119f2008-06-10 13:42:13 +0800593 j += display;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 }
595
596 /*
Robert Moore0c9938c2005-07-29 15:15:00 -0700597 * Print the ASCII equivalent characters but watch out for the bad
598 * unprintable ones (printable chars are 0x20 through 0x7E)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 */
Len Brown4be44fc2005-08-05 00:44:28 -0400600 acpi_os_printf(" ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 for (j = 0; j < 16; j++) {
602 if (i + j >= count) {
Len Brown4be44fc2005-08-05 00:44:28 -0400603 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 return;
605 }
606
Bob Moore67a119f2008-06-10 13:42:13 +0800607 buf_char = buffer[(acpi_size) i + j];
Len Brown4be44fc2005-08-05 00:44:28 -0400608 if (ACPI_IS_PRINT(buf_char)) {
609 acpi_os_printf("%c", buf_char);
610 } else {
611 acpi_os_printf(".");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 }
613 }
614
615 /* Done with that line. */
616
Len Brown4be44fc2005-08-05 00:44:28 -0400617 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 i += 16;
619 }
620
621 return;
622}
Bob Moore793c2382006-03-31 00:00:00 -0500623
624/*******************************************************************************
625 *
626 * FUNCTION: acpi_ut_dump_buffer
627 *
628 * PARAMETERS: Buffer - Buffer to dump
629 * Count - Amount to dump, in bytes
630 * Display - BYTE, WORD, DWORD, or QWORD display
631 * component_iD - Caller's component ID
632 *
633 * RETURN: None
634 *
635 * DESCRIPTION: Generic dump buffer in both hex and ascii.
636 *
637 ******************************************************************************/
638
639void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
640{
641
642 /* Only dump the buffer if tracing is enabled */
643
644 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
645 (component_id & acpi_dbg_layer))) {
646 return;
647 }
648
649 acpi_ut_dump_buffer2(buffer, count, display);
650}