blob: f21c486929a54a96fcf8bbcf5a6d34049b00bbf5 [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
Lin Ming28eb3fc2010-09-15 13:55:13 +0800182 ("\n**** Context Switch from TID %u to TID %u ****\n\n",
183 (u32)acpi_gbl_prev_thread_id, (u32)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 }
185
186 acpi_gbl_prev_thread_id = thread_id;
187 }
188
189 /*
190 * Display the module name, current line number, thread ID (if requested),
191 * current procedure nesting level, and the current procedure name
192 */
Len Brown4be44fc2005-08-05 00:44:28 -0400193 acpi_os_printf("%8s-%04ld ", module_name, line_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
195 if (ACPI_LV_THREADS & acpi_dbg_level) {
Lin Ming28eb3fc2010-09-15 13:55:13 +0800196 acpi_os_printf("[%u] ", (u32)thread_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 }
198
Len Brown4be44fc2005-08-05 00:44:28 -0400199 acpi_os_printf("[%02ld] %-22.22s: ",
200 acpi_gbl_nesting_level,
201 acpi_ut_trim_function_name(function_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Len Brown4be44fc2005-08-05 00:44:28 -0400203 va_start(args, format);
204 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400205 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206}
Robert Moore44f6c012005-04-18 22:49:35 -0400207
Bob Moore50df4d82008-12-31 03:01:23 +0800208ACPI_EXPORT_SYMBOL(acpi_debug_print)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
Robert Moore44f6c012005-04-18 22:49:35 -0400210/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 *
Bob Moore50df4d82008-12-31 03:01:23 +0800212 * FUNCTION: acpi_debug_print_raw
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 *
214 * PARAMETERS: requested_debug_level - Requested debug print level
215 * line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400216 * function_name - Caller's procedure name
217 * module_name - Caller's module name
218 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 * Format - Printf format field
220 * ... - Optional printf arguments
221 *
222 * RETURN: None
223 *
224 * DESCRIPTION: Print message with no headers. Has same interface as
225 * debug_print so that the same macros can be used.
226 *
Robert Moore44f6c012005-04-18 22:49:35 -0400227 ******************************************************************************/
Len Brown4be44fc2005-08-05 00:44:28 -0400228void ACPI_INTERNAL_VAR_XFACE
Bob Moore50df4d82008-12-31 03:01:23 +0800229acpi_debug_print_raw(u32 requested_debug_level,
230 u32 line_number,
231 const char *function_name,
232 const char *module_name,
233 u32 component_id, const char *format, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234{
Len Brown4be44fc2005-08-05 00:44:28 -0400235 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
237 if (!(requested_debug_level & acpi_dbg_level) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400238 !(component_id & acpi_dbg_layer)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 return;
240 }
241
Len Brown4be44fc2005-08-05 00:44:28 -0400242 va_start(args, format);
243 acpi_os_vprintf(format, args);
Bob Moore507f0462008-04-10 19:06:42 +0400244 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Bob Moore50df4d82008-12-31 03:01:23 +0800247ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
Robert Moore44f6c012005-04-18 22:49:35 -0400249/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 *
251 * FUNCTION: acpi_ut_trace
252 *
253 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400254 * function_name - Caller's procedure name
255 * module_name - Caller's module name
256 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 *
258 * RETURN: None
259 *
260 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
261 * set in debug_level
262 *
Robert Moore44f6c012005-04-18 22:49:35 -0400263 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264void
Len Brown4be44fc2005-08-05 00:44:28 -0400265acpi_ut_trace(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800266 const char *function_name,
267 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268{
269
270 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400271 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Bob Moore50df4d82008-12-31 03:01:23 +0800273 acpi_debug_print(ACPI_LV_FUNCTIONS,
274 line_number, function_name, module_name, component_id,
275 "%s\n", acpi_gbl_fn_entry_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Bob Moore83135242006-10-03 00:00:00 -0400278ACPI_EXPORT_SYMBOL(acpi_ut_trace)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Robert Moore44f6c012005-04-18 22:49:35 -0400280/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 *
282 * FUNCTION: acpi_ut_trace_ptr
283 *
284 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400285 * function_name - Caller's procedure name
286 * module_name - Caller's module name
287 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 * Pointer - Pointer to display
289 *
290 * RETURN: None
291 *
292 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
293 * set in debug_level
294 *
Robert Moore44f6c012005-04-18 22:49:35 -0400295 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296void
Len Brown4be44fc2005-08-05 00:44:28 -0400297acpi_ut_trace_ptr(u32 line_number,
298 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800299 const char *module_name, u32 component_id, void *pointer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300{
301 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400302 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
Bob Moore50df4d82008-12-31 03:01:23 +0800304 acpi_debug_print(ACPI_LV_FUNCTIONS,
305 line_number, function_name, module_name, component_id,
306 "%s %p\n", acpi_gbl_fn_entry_str, pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307}
308
Robert Moore44f6c012005-04-18 22:49:35 -0400309/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 *
311 * FUNCTION: acpi_ut_trace_str
312 *
313 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400314 * function_name - Caller's procedure name
315 * module_name - Caller's module name
316 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 * String - Additional string to display
318 *
319 * RETURN: None
320 *
321 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
322 * set in debug_level
323 *
Robert Moore44f6c012005-04-18 22:49:35 -0400324 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
326void
Len Brown4be44fc2005-08-05 00:44:28 -0400327acpi_ut_trace_str(u32 line_number,
328 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800329 const char *module_name, u32 component_id, char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330{
331
332 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400333 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334
Bob Moore50df4d82008-12-31 03:01:23 +0800335 acpi_debug_print(ACPI_LV_FUNCTIONS,
336 line_number, function_name, module_name, component_id,
337 "%s %s\n", acpi_gbl_fn_entry_str, string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338}
339
Robert Moore44f6c012005-04-18 22:49:35 -0400340/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 *
342 * FUNCTION: acpi_ut_trace_u32
343 *
344 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400345 * function_name - Caller's procedure name
346 * module_name - Caller's module name
347 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 * Integer - Integer to display
349 *
350 * RETURN: None
351 *
352 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
353 * set in debug_level
354 *
Robert Moore44f6c012005-04-18 22:49:35 -0400355 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
357void
Len Brown4be44fc2005-08-05 00:44:28 -0400358acpi_ut_trace_u32(u32 line_number,
359 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800360 const char *module_name, u32 component_id, u32 integer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361{
362
363 acpi_gbl_nesting_level++;
Len Brown4be44fc2005-08-05 00:44:28 -0400364 acpi_ut_track_stack_ptr();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
Bob Moore50df4d82008-12-31 03:01:23 +0800366 acpi_debug_print(ACPI_LV_FUNCTIONS,
367 line_number, function_name, module_name, component_id,
368 "%s %08X\n", acpi_gbl_fn_entry_str, integer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369}
370
Robert Moore44f6c012005-04-18 22:49:35 -0400371/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 *
373 * FUNCTION: acpi_ut_exit
374 *
375 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400376 * function_name - Caller's procedure name
377 * module_name - Caller's module name
378 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 *
380 * RETURN: None
381 *
382 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
383 * set in debug_level
384 *
Robert Moore44f6c012005-04-18 22:49:35 -0400385 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386
387void
Len Brown4be44fc2005-08-05 00:44:28 -0400388acpi_ut_exit(u32 line_number,
Bob Moore4b8ed632008-06-10 13:55:53 +0800389 const char *function_name,
390 const char *module_name, u32 component_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391{
392
Bob Moore50df4d82008-12-31 03:01:23 +0800393 acpi_debug_print(ACPI_LV_FUNCTIONS,
394 line_number, function_name, module_name, component_id,
395 "%s\n", acpi_gbl_fn_exit_str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396
397 acpi_gbl_nesting_level--;
398}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399
Bob Moore83135242006-10-03 00:00:00 -0400400ACPI_EXPORT_SYMBOL(acpi_ut_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
Robert Moore44f6c012005-04-18 22:49:35 -0400402/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 *
404 * FUNCTION: acpi_ut_status_exit
405 *
406 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400407 * function_name - Caller's procedure name
408 * module_name - Caller's module name
409 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 * Status - Exit status code
411 *
412 * RETURN: None
413 *
414 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
415 * set in debug_level. Prints exit status also.
416 *
Robert Moore44f6c012005-04-18 22:49:35 -0400417 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418void
Len Brown4be44fc2005-08-05 00:44:28 -0400419acpi_ut_status_exit(u32 line_number,
420 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800421 const char *module_name,
422 u32 component_id, acpi_status status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423{
424
Len Brown4be44fc2005-08-05 00:44:28 -0400425 if (ACPI_SUCCESS(status)) {
Bob Moore50df4d82008-12-31 03:01:23 +0800426 acpi_debug_print(ACPI_LV_FUNCTIONS,
427 line_number, function_name, module_name,
428 component_id, "%s %s\n", acpi_gbl_fn_exit_str,
429 acpi_format_exception(status));
Len Brown4be44fc2005-08-05 00:44:28 -0400430 } else {
Bob Moore50df4d82008-12-31 03:01:23 +0800431 acpi_debug_print(ACPI_LV_FUNCTIONS,
432 line_number, function_name, module_name,
433 component_id, "%s ****Exception****: %s\n",
434 acpi_gbl_fn_exit_str,
435 acpi_format_exception(status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 }
437
438 acpi_gbl_nesting_level--;
439}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440
Bob Moore83135242006-10-03 00:00:00 -0400441ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
Robert Moore44f6c012005-04-18 22:49:35 -0400443/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 *
445 * FUNCTION: acpi_ut_value_exit
446 *
447 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400448 * function_name - Caller's procedure name
449 * module_name - Caller's module name
450 * component_id - Caller's component ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 * Value - Value to be printed with exit msg
452 *
453 * RETURN: None
454 *
455 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
456 * set in debug_level. Prints exit value also.
457 *
Robert Moore44f6c012005-04-18 22:49:35 -0400458 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459void
Len Brown4be44fc2005-08-05 00:44:28 -0400460acpi_ut_value_exit(u32 line_number,
461 const char *function_name,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800462 const char *module_name, u32 component_id, u64 value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463{
464
Bob Moore50df4d82008-12-31 03:01:23 +0800465 acpi_debug_print(ACPI_LV_FUNCTIONS,
466 line_number, function_name, module_name, component_id,
467 "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str,
468 ACPI_FORMAT_UINT64(value));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
470 acpi_gbl_nesting_level--;
471}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472
Bob Moore83135242006-10-03 00:00:00 -0400473ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474
Robert Moore44f6c012005-04-18 22:49:35 -0400475/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 *
477 * FUNCTION: acpi_ut_ptr_exit
478 *
479 * PARAMETERS: line_number - Caller's line number
Robert Mooref9f46012005-07-08 00:00:00 -0400480 * function_name - Caller's procedure name
481 * module_name - Caller's module name
482 * component_id - Caller's component ID
Robert Moore44f6c012005-04-18 22:49:35 -0400483 * Ptr - Pointer to display
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 *
485 * RETURN: None
486 *
487 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
488 * set in debug_level. Prints exit value also.
489 *
Robert Moore44f6c012005-04-18 22:49:35 -0400490 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491void
Len Brown4be44fc2005-08-05 00:44:28 -0400492acpi_ut_ptr_exit(u32 line_number,
493 const char *function_name,
Bob Moore4b8ed632008-06-10 13:55:53 +0800494 const char *module_name, u32 component_id, u8 *ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495{
496
Bob Moore50df4d82008-12-31 03:01:23 +0800497 acpi_debug_print(ACPI_LV_FUNCTIONS,
498 line_number, function_name, module_name, component_id,
499 "%s %p\n", acpi_gbl_fn_exit_str, ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
501 acpi_gbl_nesting_level--;
502}
503
504#endif
505
Robert Moore44f6c012005-04-18 22:49:35 -0400506/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 *
508 * FUNCTION: acpi_ut_dump_buffer
509 *
510 * PARAMETERS: Buffer - Buffer to dump
511 * Count - Amount to dump, in bytes
512 * Display - BYTE, WORD, DWORD, or QWORD display
513 * component_iD - Caller's component ID
514 *
515 * RETURN: None
516 *
517 * DESCRIPTION: Generic dump buffer in both hex and ascii.
518 *
Robert Moore44f6c012005-04-18 22:49:35 -0400519 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520
Bob Moore793c2382006-03-31 00:00:00 -0500521void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522{
Bob Moore67a119f2008-06-10 13:42:13 +0800523 u32 i = 0;
524 u32 j;
Len Brown4be44fc2005-08-05 00:44:28 -0400525 u32 temp32;
526 u8 buf_char;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527
Bob Moore5eb69182008-04-10 19:06:39 +0400528 if (!buffer) {
529 acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
530 return;
531 }
532
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 if ((count < 4) || (count & 0x01)) {
534 display = DB_BYTE_DISPLAY;
535 }
536
Robert Moore44f6c012005-04-18 22:49:35 -0400537 /* Nasty little dump buffer routine! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 while (i < count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400540
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 /* Print current offset */
542
Bob Moore67a119f2008-06-10 13:42:13 +0800543 acpi_os_printf("%6.4X: ", i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544
545 /* Print 16 hex chars */
546
547 for (j = 0; j < 16;) {
548 if (i + j >= count) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400549
Robert Moore44f6c012005-04-18 22:49:35 -0400550 /* Dump fill spaces */
551
Len Brown4be44fc2005-08-05 00:44:28 -0400552 acpi_os_printf("%*s", ((display * 2) + 1), " ");
Bob Moore67a119f2008-06-10 13:42:13 +0800553 j += display;
Robert Moore44f6c012005-04-18 22:49:35 -0400554 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 }
556
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 switch (display) {
Bob Moore793c2382006-03-31 00:00:00 -0500558 case DB_BYTE_DISPLAY:
Len Brown4be44fc2005-08-05 00:44:28 -0400559 default: /* Default is BYTE display */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560
Bob Moore67a119f2008-06-10 13:42:13 +0800561 acpi_os_printf("%02X ",
562 buffer[(acpi_size) i + j]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 break;
564
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 case DB_WORD_DISPLAY:
566
Bob Moore67a119f2008-06-10 13:42:13 +0800567 ACPI_MOVE_16_TO_32(&temp32,
568 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400569 acpi_os_printf("%04X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 break;
571
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 case DB_DWORD_DISPLAY:
573
Bob Moore67a119f2008-06-10 13:42:13 +0800574 ACPI_MOVE_32_TO_32(&temp32,
575 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400576 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 break;
578
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 case DB_QWORD_DISPLAY:
580
Bob Moore67a119f2008-06-10 13:42:13 +0800581 ACPI_MOVE_32_TO_32(&temp32,
582 &buffer[(acpi_size) i + j]);
Len Brown4be44fc2005-08-05 00:44:28 -0400583 acpi_os_printf("%08X", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584
Bob Moore67a119f2008-06-10 13:42:13 +0800585 ACPI_MOVE_32_TO_32(&temp32,
586 &buffer[(acpi_size) i + j +
587 4]);
Len Brown4be44fc2005-08-05 00:44:28 -0400588 acpi_os_printf("%08X ", temp32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 break;
590 }
Robert Moore44f6c012005-04-18 22:49:35 -0400591
Bob Moore67a119f2008-06-10 13:42:13 +0800592 j += display;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 }
594
595 /*
Robert Moore0c9938c2005-07-29 15:15:00 -0700596 * Print the ASCII equivalent characters but watch out for the bad
597 * unprintable ones (printable chars are 0x20 through 0x7E)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 */
Len Brown4be44fc2005-08-05 00:44:28 -0400599 acpi_os_printf(" ");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 for (j = 0; j < 16; j++) {
601 if (i + j >= count) {
Len Brown4be44fc2005-08-05 00:44:28 -0400602 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 return;
604 }
605
Bob Moore67a119f2008-06-10 13:42:13 +0800606 buf_char = buffer[(acpi_size) i + j];
Len Brown4be44fc2005-08-05 00:44:28 -0400607 if (ACPI_IS_PRINT(buf_char)) {
608 acpi_os_printf("%c", buf_char);
609 } else {
610 acpi_os_printf(".");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 }
612 }
613
614 /* Done with that line. */
615
Len Brown4be44fc2005-08-05 00:44:28 -0400616 acpi_os_printf("\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 i += 16;
618 }
619
620 return;
621}
Bob Moore793c2382006-03-31 00:00:00 -0500622
623/*******************************************************************************
624 *
625 * FUNCTION: acpi_ut_dump_buffer
626 *
627 * PARAMETERS: Buffer - Buffer to dump
628 * Count - Amount to dump, in bytes
629 * Display - BYTE, WORD, DWORD, or QWORD display
630 * component_iD - Caller's component ID
631 *
632 * RETURN: None
633 *
634 * DESCRIPTION: Generic dump buffer in both hex and ascii.
635 *
636 ******************************************************************************/
637
638void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
639{
640
641 /* Only dump the buffer if tracing is enabled */
642
643 if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
644 (component_id & acpi_dbg_layer))) {
645 return;
646 }
647
648 acpi_ut_dump_buffer2(buffer, count, display);
649}