1*95b482a8SLen Brown /****************************************************************************** 2*95b482a8SLen Brown * 3*95b482a8SLen Brown * Module Name: utdebug - Debug print routines 4*95b482a8SLen Brown * 5*95b482a8SLen Brown *****************************************************************************/ 6*95b482a8SLen Brown 7*95b482a8SLen Brown /* 8*95b482a8SLen Brown * Copyright (C) 2000 - 2008, Intel Corp. 9*95b482a8SLen Brown * All rights reserved. 10*95b482a8SLen Brown * 11*95b482a8SLen Brown * Redistribution and use in source and binary forms, with or without 12*95b482a8SLen Brown * modification, are permitted provided that the following conditions 13*95b482a8SLen Brown * are met: 14*95b482a8SLen Brown * 1. Redistributions of source code must retain the above copyright 15*95b482a8SLen Brown * notice, this list of conditions, and the following disclaimer, 16*95b482a8SLen Brown * without modification. 17*95b482a8SLen Brown * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18*95b482a8SLen Brown * substantially similar to the "NO WARRANTY" disclaimer below 19*95b482a8SLen Brown * ("Disclaimer") and any redistribution must be conditioned upon 20*95b482a8SLen Brown * including a substantially similar Disclaimer requirement for further 21*95b482a8SLen Brown * binary redistribution. 22*95b482a8SLen Brown * 3. Neither the names of the above-listed copyright holders nor the names 23*95b482a8SLen Brown * of any contributors may be used to endorse or promote products derived 24*95b482a8SLen Brown * from this software without specific prior written permission. 25*95b482a8SLen Brown * 26*95b482a8SLen Brown * Alternatively, this software may be distributed under the terms of the 27*95b482a8SLen Brown * GNU General Public License ("GPL") version 2 as published by the Free 28*95b482a8SLen Brown * Software Foundation. 29*95b482a8SLen Brown * 30*95b482a8SLen Brown * NO WARRANTY 31*95b482a8SLen Brown * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32*95b482a8SLen Brown * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33*95b482a8SLen Brown * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34*95b482a8SLen Brown * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35*95b482a8SLen Brown * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36*95b482a8SLen Brown * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37*95b482a8SLen Brown * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38*95b482a8SLen Brown * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39*95b482a8SLen Brown * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40*95b482a8SLen Brown * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41*95b482a8SLen Brown * POSSIBILITY OF SUCH DAMAGES. 42*95b482a8SLen Brown */ 43*95b482a8SLen Brown 44*95b482a8SLen Brown #include <acpi/acpi.h> 45*95b482a8SLen Brown #include <acpi/accommon.h> 46*95b482a8SLen Brown 47*95b482a8SLen Brown #define _COMPONENT ACPI_UTILITIES 48*95b482a8SLen Brown ACPI_MODULE_NAME("utdebug") 49*95b482a8SLen Brown #ifdef ACPI_DEBUG_OUTPUT 50*95b482a8SLen Brown static acpi_thread_id acpi_gbl_prev_thread_id; 51*95b482a8SLen Brown static char *acpi_gbl_fn_entry_str = "----Entry"; 52*95b482a8SLen Brown static char *acpi_gbl_fn_exit_str = "----Exit-"; 53*95b482a8SLen Brown 54*95b482a8SLen Brown /* Local prototypes */ 55*95b482a8SLen Brown 56*95b482a8SLen Brown static const char *acpi_ut_trim_function_name(const char *function_name); 57*95b482a8SLen Brown 58*95b482a8SLen Brown /******************************************************************************* 59*95b482a8SLen Brown * 60*95b482a8SLen Brown * FUNCTION: acpi_ut_init_stack_ptr_trace 61*95b482a8SLen Brown * 62*95b482a8SLen Brown * PARAMETERS: None 63*95b482a8SLen Brown * 64*95b482a8SLen Brown * RETURN: None 65*95b482a8SLen Brown * 66*95b482a8SLen Brown * DESCRIPTION: Save the current CPU stack pointer at subsystem startup 67*95b482a8SLen Brown * 68*95b482a8SLen Brown ******************************************************************************/ 69*95b482a8SLen Brown 70*95b482a8SLen Brown void acpi_ut_init_stack_ptr_trace(void) 71*95b482a8SLen Brown { 72*95b482a8SLen Brown acpi_size current_sp; 73*95b482a8SLen Brown 74*95b482a8SLen Brown acpi_gbl_entry_stack_pointer = ¤t_sp; 75*95b482a8SLen Brown } 76*95b482a8SLen Brown 77*95b482a8SLen Brown /******************************************************************************* 78*95b482a8SLen Brown * 79*95b482a8SLen Brown * FUNCTION: acpi_ut_track_stack_ptr 80*95b482a8SLen Brown * 81*95b482a8SLen Brown * PARAMETERS: None 82*95b482a8SLen Brown * 83*95b482a8SLen Brown * RETURN: None 84*95b482a8SLen Brown * 85*95b482a8SLen Brown * DESCRIPTION: Save the current CPU stack pointer 86*95b482a8SLen Brown * 87*95b482a8SLen Brown ******************************************************************************/ 88*95b482a8SLen Brown 89*95b482a8SLen Brown void acpi_ut_track_stack_ptr(void) 90*95b482a8SLen Brown { 91*95b482a8SLen Brown acpi_size current_sp; 92*95b482a8SLen Brown 93*95b482a8SLen Brown if (¤t_sp < acpi_gbl_lowest_stack_pointer) { 94*95b482a8SLen Brown acpi_gbl_lowest_stack_pointer = ¤t_sp; 95*95b482a8SLen Brown } 96*95b482a8SLen Brown 97*95b482a8SLen Brown if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) { 98*95b482a8SLen Brown acpi_gbl_deepest_nesting = acpi_gbl_nesting_level; 99*95b482a8SLen Brown } 100*95b482a8SLen Brown } 101*95b482a8SLen Brown 102*95b482a8SLen Brown /******************************************************************************* 103*95b482a8SLen Brown * 104*95b482a8SLen Brown * FUNCTION: acpi_ut_trim_function_name 105*95b482a8SLen Brown * 106*95b482a8SLen Brown * PARAMETERS: function_name - Ascii string containing a procedure name 107*95b482a8SLen Brown * 108*95b482a8SLen Brown * RETURN: Updated pointer to the function name 109*95b482a8SLen Brown * 110*95b482a8SLen Brown * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. 111*95b482a8SLen Brown * This allows compiler macros such as __func__ to be used 112*95b482a8SLen Brown * with no change to the debug output. 113*95b482a8SLen Brown * 114*95b482a8SLen Brown ******************************************************************************/ 115*95b482a8SLen Brown 116*95b482a8SLen Brown static const char *acpi_ut_trim_function_name(const char *function_name) 117*95b482a8SLen Brown { 118*95b482a8SLen Brown 119*95b482a8SLen Brown /* All Function names are longer than 4 chars, check is safe */ 120*95b482a8SLen Brown 121*95b482a8SLen Brown if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) { 122*95b482a8SLen Brown 123*95b482a8SLen Brown /* This is the case where the original source has not been modified */ 124*95b482a8SLen Brown 125*95b482a8SLen Brown return (function_name + 4); 126*95b482a8SLen Brown } 127*95b482a8SLen Brown 128*95b482a8SLen Brown if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) { 129*95b482a8SLen Brown 130*95b482a8SLen Brown /* This is the case where the source has been 'linuxized' */ 131*95b482a8SLen Brown 132*95b482a8SLen Brown return (function_name + 5); 133*95b482a8SLen Brown } 134*95b482a8SLen Brown 135*95b482a8SLen Brown return (function_name); 136*95b482a8SLen Brown } 137*95b482a8SLen Brown 138*95b482a8SLen Brown /******************************************************************************* 139*95b482a8SLen Brown * 140*95b482a8SLen Brown * FUNCTION: acpi_debug_print 141*95b482a8SLen Brown * 142*95b482a8SLen Brown * PARAMETERS: requested_debug_level - Requested debug print level 143*95b482a8SLen Brown * line_number - Caller's line number (for error output) 144*95b482a8SLen Brown * function_name - Caller's procedure name 145*95b482a8SLen Brown * module_name - Caller's module name 146*95b482a8SLen Brown * component_id - Caller's component ID 147*95b482a8SLen Brown * Format - Printf format field 148*95b482a8SLen Brown * ... - Optional printf arguments 149*95b482a8SLen Brown * 150*95b482a8SLen Brown * RETURN: None 151*95b482a8SLen Brown * 152*95b482a8SLen Brown * DESCRIPTION: Print error message with prefix consisting of the module name, 153*95b482a8SLen Brown * line number, and component ID. 154*95b482a8SLen Brown * 155*95b482a8SLen Brown ******************************************************************************/ 156*95b482a8SLen Brown 157*95b482a8SLen Brown void ACPI_INTERNAL_VAR_XFACE 158*95b482a8SLen Brown acpi_debug_print(u32 requested_debug_level, 159*95b482a8SLen Brown u32 line_number, 160*95b482a8SLen Brown const char *function_name, 161*95b482a8SLen Brown const char *module_name, 162*95b482a8SLen Brown u32 component_id, const char *format, ...) 163*95b482a8SLen Brown { 164*95b482a8SLen Brown acpi_thread_id thread_id; 165*95b482a8SLen Brown va_list args; 166*95b482a8SLen Brown 167*95b482a8SLen Brown /* 168*95b482a8SLen Brown * Stay silent if the debug level or component ID is disabled 169*95b482a8SLen Brown */ 170*95b482a8SLen Brown if (!(requested_debug_level & acpi_dbg_level) || 171*95b482a8SLen Brown !(component_id & acpi_dbg_layer)) { 172*95b482a8SLen Brown return; 173*95b482a8SLen Brown } 174*95b482a8SLen Brown 175*95b482a8SLen Brown /* 176*95b482a8SLen Brown * Thread tracking and context switch notification 177*95b482a8SLen Brown */ 178*95b482a8SLen Brown thread_id = acpi_os_get_thread_id(); 179*95b482a8SLen Brown if (thread_id != acpi_gbl_prev_thread_id) { 180*95b482a8SLen Brown if (ACPI_LV_THREADS & acpi_dbg_level) { 181*95b482a8SLen Brown acpi_os_printf 182*95b482a8SLen Brown ("\n**** Context Switch from TID %lX to TID %lX ****\n\n", 183*95b482a8SLen Brown (unsigned long)acpi_gbl_prev_thread_id, 184*95b482a8SLen Brown (unsigned long)thread_id); 185*95b482a8SLen Brown } 186*95b482a8SLen Brown 187*95b482a8SLen Brown acpi_gbl_prev_thread_id = thread_id; 188*95b482a8SLen Brown } 189*95b482a8SLen Brown 190*95b482a8SLen Brown /* 191*95b482a8SLen Brown * Display the module name, current line number, thread ID (if requested), 192*95b482a8SLen Brown * current procedure nesting level, and the current procedure name 193*95b482a8SLen Brown */ 194*95b482a8SLen Brown acpi_os_printf("%8s-%04ld ", module_name, line_number); 195*95b482a8SLen Brown 196*95b482a8SLen Brown if (ACPI_LV_THREADS & acpi_dbg_level) { 197*95b482a8SLen Brown acpi_os_printf("[%04lX] ", (unsigned long)thread_id); 198*95b482a8SLen Brown } 199*95b482a8SLen Brown 200*95b482a8SLen Brown acpi_os_printf("[%02ld] %-22.22s: ", 201*95b482a8SLen Brown acpi_gbl_nesting_level, 202*95b482a8SLen Brown acpi_ut_trim_function_name(function_name)); 203*95b482a8SLen Brown 204*95b482a8SLen Brown va_start(args, format); 205*95b482a8SLen Brown acpi_os_vprintf(format, args); 206*95b482a8SLen Brown va_end(args); 207*95b482a8SLen Brown } 208*95b482a8SLen Brown 209*95b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_debug_print) 210*95b482a8SLen Brown 211*95b482a8SLen Brown /******************************************************************************* 212*95b482a8SLen Brown * 213*95b482a8SLen Brown * FUNCTION: acpi_debug_print_raw 214*95b482a8SLen Brown * 215*95b482a8SLen Brown * PARAMETERS: requested_debug_level - Requested debug print level 216*95b482a8SLen Brown * line_number - Caller's line number 217*95b482a8SLen Brown * function_name - Caller's procedure name 218*95b482a8SLen Brown * module_name - Caller's module name 219*95b482a8SLen Brown * component_id - Caller's component ID 220*95b482a8SLen Brown * Format - Printf format field 221*95b482a8SLen Brown * ... - Optional printf arguments 222*95b482a8SLen Brown * 223*95b482a8SLen Brown * RETURN: None 224*95b482a8SLen Brown * 225*95b482a8SLen Brown * DESCRIPTION: Print message with no headers. Has same interface as 226*95b482a8SLen Brown * debug_print so that the same macros can be used. 227*95b482a8SLen Brown * 228*95b482a8SLen Brown ******************************************************************************/ 229*95b482a8SLen Brown void ACPI_INTERNAL_VAR_XFACE 230*95b482a8SLen Brown acpi_debug_print_raw(u32 requested_debug_level, 231*95b482a8SLen Brown u32 line_number, 232*95b482a8SLen Brown const char *function_name, 233*95b482a8SLen Brown const char *module_name, 234*95b482a8SLen Brown u32 component_id, const char *format, ...) 235*95b482a8SLen Brown { 236*95b482a8SLen Brown va_list args; 237*95b482a8SLen Brown 238*95b482a8SLen Brown if (!(requested_debug_level & acpi_dbg_level) || 239*95b482a8SLen Brown !(component_id & acpi_dbg_layer)) { 240*95b482a8SLen Brown return; 241*95b482a8SLen Brown } 242*95b482a8SLen Brown 243*95b482a8SLen Brown va_start(args, format); 244*95b482a8SLen Brown acpi_os_vprintf(format, args); 245*95b482a8SLen Brown va_end(args); 246*95b482a8SLen Brown } 247*95b482a8SLen Brown 248*95b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_debug_print_raw) 249*95b482a8SLen Brown 250*95b482a8SLen Brown /******************************************************************************* 251*95b482a8SLen Brown * 252*95b482a8SLen Brown * FUNCTION: acpi_ut_trace 253*95b482a8SLen Brown * 254*95b482a8SLen Brown * PARAMETERS: line_number - Caller's line number 255*95b482a8SLen Brown * function_name - Caller's procedure name 256*95b482a8SLen Brown * module_name - Caller's module name 257*95b482a8SLen Brown * component_id - Caller's component ID 258*95b482a8SLen Brown * 259*95b482a8SLen Brown * RETURN: None 260*95b482a8SLen Brown * 261*95b482a8SLen Brown * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 262*95b482a8SLen Brown * set in debug_level 263*95b482a8SLen Brown * 264*95b482a8SLen Brown ******************************************************************************/ 265*95b482a8SLen Brown void 266*95b482a8SLen Brown acpi_ut_trace(u32 line_number, 267*95b482a8SLen Brown const char *function_name, 268*95b482a8SLen Brown const char *module_name, u32 component_id) 269*95b482a8SLen Brown { 270*95b482a8SLen Brown 271*95b482a8SLen Brown acpi_gbl_nesting_level++; 272*95b482a8SLen Brown acpi_ut_track_stack_ptr(); 273*95b482a8SLen Brown 274*95b482a8SLen Brown acpi_debug_print(ACPI_LV_FUNCTIONS, 275*95b482a8SLen Brown line_number, function_name, module_name, component_id, 276*95b482a8SLen Brown "%s\n", acpi_gbl_fn_entry_str); 277*95b482a8SLen Brown } 278*95b482a8SLen Brown 279*95b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_trace) 280*95b482a8SLen Brown 281*95b482a8SLen Brown /******************************************************************************* 282*95b482a8SLen Brown * 283*95b482a8SLen Brown * FUNCTION: acpi_ut_trace_ptr 284*95b482a8SLen Brown * 285*95b482a8SLen Brown * PARAMETERS: line_number - Caller's line number 286*95b482a8SLen Brown * function_name - Caller's procedure name 287*95b482a8SLen Brown * module_name - Caller's module name 288*95b482a8SLen Brown * component_id - Caller's component ID 289*95b482a8SLen Brown * Pointer - Pointer to display 290*95b482a8SLen Brown * 291*95b482a8SLen Brown * RETURN: None 292*95b482a8SLen Brown * 293*95b482a8SLen Brown * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 294*95b482a8SLen Brown * set in debug_level 295*95b482a8SLen Brown * 296*95b482a8SLen Brown ******************************************************************************/ 297*95b482a8SLen Brown void 298*95b482a8SLen Brown acpi_ut_trace_ptr(u32 line_number, 299*95b482a8SLen Brown const char *function_name, 300*95b482a8SLen Brown const char *module_name, u32 component_id, void *pointer) 301*95b482a8SLen Brown { 302*95b482a8SLen Brown acpi_gbl_nesting_level++; 303*95b482a8SLen Brown acpi_ut_track_stack_ptr(); 304*95b482a8SLen Brown 305*95b482a8SLen Brown acpi_debug_print(ACPI_LV_FUNCTIONS, 306*95b482a8SLen Brown line_number, function_name, module_name, component_id, 307*95b482a8SLen Brown "%s %p\n", acpi_gbl_fn_entry_str, pointer); 308*95b482a8SLen Brown } 309*95b482a8SLen Brown 310*95b482a8SLen Brown /******************************************************************************* 311*95b482a8SLen Brown * 312*95b482a8SLen Brown * FUNCTION: acpi_ut_trace_str 313*95b482a8SLen Brown * 314*95b482a8SLen Brown * PARAMETERS: line_number - Caller's line number 315*95b482a8SLen Brown * function_name - Caller's procedure name 316*95b482a8SLen Brown * module_name - Caller's module name 317*95b482a8SLen Brown * component_id - Caller's component ID 318*95b482a8SLen Brown * String - Additional string to display 319*95b482a8SLen Brown * 320*95b482a8SLen Brown * RETURN: None 321*95b482a8SLen Brown * 322*95b482a8SLen Brown * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 323*95b482a8SLen Brown * set in debug_level 324*95b482a8SLen Brown * 325*95b482a8SLen Brown ******************************************************************************/ 326*95b482a8SLen Brown 327*95b482a8SLen Brown void 328*95b482a8SLen Brown acpi_ut_trace_str(u32 line_number, 329*95b482a8SLen Brown const char *function_name, 330*95b482a8SLen Brown const char *module_name, u32 component_id, char *string) 331*95b482a8SLen Brown { 332*95b482a8SLen Brown 333*95b482a8SLen Brown acpi_gbl_nesting_level++; 334*95b482a8SLen Brown acpi_ut_track_stack_ptr(); 335*95b482a8SLen Brown 336*95b482a8SLen Brown acpi_debug_print(ACPI_LV_FUNCTIONS, 337*95b482a8SLen Brown line_number, function_name, module_name, component_id, 338*95b482a8SLen Brown "%s %s\n", acpi_gbl_fn_entry_str, string); 339*95b482a8SLen Brown } 340*95b482a8SLen Brown 341*95b482a8SLen Brown /******************************************************************************* 342*95b482a8SLen Brown * 343*95b482a8SLen Brown * FUNCTION: acpi_ut_trace_u32 344*95b482a8SLen Brown * 345*95b482a8SLen Brown * PARAMETERS: line_number - Caller's line number 346*95b482a8SLen Brown * function_name - Caller's procedure name 347*95b482a8SLen Brown * module_name - Caller's module name 348*95b482a8SLen Brown * component_id - Caller's component ID 349*95b482a8SLen Brown * Integer - Integer to display 350*95b482a8SLen Brown * 351*95b482a8SLen Brown * RETURN: None 352*95b482a8SLen Brown * 353*95b482a8SLen Brown * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 354*95b482a8SLen Brown * set in debug_level 355*95b482a8SLen Brown * 356*95b482a8SLen Brown ******************************************************************************/ 357*95b482a8SLen Brown 358*95b482a8SLen Brown void 359*95b482a8SLen Brown acpi_ut_trace_u32(u32 line_number, 360*95b482a8SLen Brown const char *function_name, 361*95b482a8SLen Brown const char *module_name, u32 component_id, u32 integer) 362*95b482a8SLen Brown { 363*95b482a8SLen Brown 364*95b482a8SLen Brown acpi_gbl_nesting_level++; 365*95b482a8SLen Brown acpi_ut_track_stack_ptr(); 366*95b482a8SLen Brown 367*95b482a8SLen Brown acpi_debug_print(ACPI_LV_FUNCTIONS, 368*95b482a8SLen Brown line_number, function_name, module_name, component_id, 369*95b482a8SLen Brown "%s %08X\n", acpi_gbl_fn_entry_str, integer); 370*95b482a8SLen Brown } 371*95b482a8SLen Brown 372*95b482a8SLen Brown /******************************************************************************* 373*95b482a8SLen Brown * 374*95b482a8SLen Brown * FUNCTION: acpi_ut_exit 375*95b482a8SLen Brown * 376*95b482a8SLen Brown * PARAMETERS: line_number - Caller's line number 377*95b482a8SLen Brown * function_name - Caller's procedure name 378*95b482a8SLen Brown * module_name - Caller's module name 379*95b482a8SLen Brown * component_id - Caller's component ID 380*95b482a8SLen Brown * 381*95b482a8SLen Brown * RETURN: None 382*95b482a8SLen Brown * 383*95b482a8SLen Brown * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 384*95b482a8SLen Brown * set in debug_level 385*95b482a8SLen Brown * 386*95b482a8SLen Brown ******************************************************************************/ 387*95b482a8SLen Brown 388*95b482a8SLen Brown void 389*95b482a8SLen Brown acpi_ut_exit(u32 line_number, 390*95b482a8SLen Brown const char *function_name, 391*95b482a8SLen Brown const char *module_name, u32 component_id) 392*95b482a8SLen Brown { 393*95b482a8SLen Brown 394*95b482a8SLen Brown acpi_debug_print(ACPI_LV_FUNCTIONS, 395*95b482a8SLen Brown line_number, function_name, module_name, component_id, 396*95b482a8SLen Brown "%s\n", acpi_gbl_fn_exit_str); 397*95b482a8SLen Brown 398*95b482a8SLen Brown acpi_gbl_nesting_level--; 399*95b482a8SLen Brown } 400*95b482a8SLen Brown 401*95b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_exit) 402*95b482a8SLen Brown 403*95b482a8SLen Brown /******************************************************************************* 404*95b482a8SLen Brown * 405*95b482a8SLen Brown * FUNCTION: acpi_ut_status_exit 406*95b482a8SLen Brown * 407*95b482a8SLen Brown * PARAMETERS: line_number - Caller's line number 408*95b482a8SLen Brown * function_name - Caller's procedure name 409*95b482a8SLen Brown * module_name - Caller's module name 410*95b482a8SLen Brown * component_id - Caller's component ID 411*95b482a8SLen Brown * Status - Exit status code 412*95b482a8SLen Brown * 413*95b482a8SLen Brown * RETURN: None 414*95b482a8SLen Brown * 415*95b482a8SLen Brown * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 416*95b482a8SLen Brown * set in debug_level. Prints exit status also. 417*95b482a8SLen Brown * 418*95b482a8SLen Brown ******************************************************************************/ 419*95b482a8SLen Brown void 420*95b482a8SLen Brown acpi_ut_status_exit(u32 line_number, 421*95b482a8SLen Brown const char *function_name, 422*95b482a8SLen Brown const char *module_name, 423*95b482a8SLen Brown u32 component_id, acpi_status status) 424*95b482a8SLen Brown { 425*95b482a8SLen Brown 426*95b482a8SLen Brown if (ACPI_SUCCESS(status)) { 427*95b482a8SLen Brown acpi_debug_print(ACPI_LV_FUNCTIONS, 428*95b482a8SLen Brown line_number, function_name, module_name, 429*95b482a8SLen Brown component_id, "%s %s\n", acpi_gbl_fn_exit_str, 430*95b482a8SLen Brown acpi_format_exception(status)); 431*95b482a8SLen Brown } else { 432*95b482a8SLen Brown acpi_debug_print(ACPI_LV_FUNCTIONS, 433*95b482a8SLen Brown line_number, function_name, module_name, 434*95b482a8SLen Brown component_id, "%s ****Exception****: %s\n", 435*95b482a8SLen Brown acpi_gbl_fn_exit_str, 436*95b482a8SLen Brown acpi_format_exception(status)); 437*95b482a8SLen Brown } 438*95b482a8SLen Brown 439*95b482a8SLen Brown acpi_gbl_nesting_level--; 440*95b482a8SLen Brown } 441*95b482a8SLen Brown 442*95b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_status_exit) 443*95b482a8SLen Brown 444*95b482a8SLen Brown /******************************************************************************* 445*95b482a8SLen Brown * 446*95b482a8SLen Brown * FUNCTION: acpi_ut_value_exit 447*95b482a8SLen Brown * 448*95b482a8SLen Brown * PARAMETERS: line_number - Caller's line number 449*95b482a8SLen Brown * function_name - Caller's procedure name 450*95b482a8SLen Brown * module_name - Caller's module name 451*95b482a8SLen Brown * component_id - Caller's component ID 452*95b482a8SLen Brown * Value - Value to be printed with exit msg 453*95b482a8SLen Brown * 454*95b482a8SLen Brown * RETURN: None 455*95b482a8SLen Brown * 456*95b482a8SLen Brown * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 457*95b482a8SLen Brown * set in debug_level. Prints exit value also. 458*95b482a8SLen Brown * 459*95b482a8SLen Brown ******************************************************************************/ 460*95b482a8SLen Brown void 461*95b482a8SLen Brown acpi_ut_value_exit(u32 line_number, 462*95b482a8SLen Brown const char *function_name, 463*95b482a8SLen Brown const char *module_name, 464*95b482a8SLen Brown u32 component_id, acpi_integer value) 465*95b482a8SLen Brown { 466*95b482a8SLen Brown 467*95b482a8SLen Brown acpi_debug_print(ACPI_LV_FUNCTIONS, 468*95b482a8SLen Brown line_number, function_name, module_name, component_id, 469*95b482a8SLen Brown "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, 470*95b482a8SLen Brown ACPI_FORMAT_UINT64(value)); 471*95b482a8SLen Brown 472*95b482a8SLen Brown acpi_gbl_nesting_level--; 473*95b482a8SLen Brown } 474*95b482a8SLen Brown 475*95b482a8SLen Brown ACPI_EXPORT_SYMBOL(acpi_ut_value_exit) 476*95b482a8SLen Brown 477*95b482a8SLen Brown /******************************************************************************* 478*95b482a8SLen Brown * 479*95b482a8SLen Brown * FUNCTION: acpi_ut_ptr_exit 480*95b482a8SLen Brown * 481*95b482a8SLen Brown * PARAMETERS: line_number - Caller's line number 482*95b482a8SLen Brown * function_name - Caller's procedure name 483*95b482a8SLen Brown * module_name - Caller's module name 484*95b482a8SLen Brown * component_id - Caller's component ID 485*95b482a8SLen Brown * Ptr - Pointer to display 486*95b482a8SLen Brown * 487*95b482a8SLen Brown * RETURN: None 488*95b482a8SLen Brown * 489*95b482a8SLen Brown * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 490*95b482a8SLen Brown * set in debug_level. Prints exit value also. 491*95b482a8SLen Brown * 492*95b482a8SLen Brown ******************************************************************************/ 493*95b482a8SLen Brown void 494*95b482a8SLen Brown acpi_ut_ptr_exit(u32 line_number, 495*95b482a8SLen Brown const char *function_name, 496*95b482a8SLen Brown const char *module_name, u32 component_id, u8 *ptr) 497*95b482a8SLen Brown { 498*95b482a8SLen Brown 499*95b482a8SLen Brown acpi_debug_print(ACPI_LV_FUNCTIONS, 500*95b482a8SLen Brown line_number, function_name, module_name, component_id, 501*95b482a8SLen Brown "%s %p\n", acpi_gbl_fn_exit_str, ptr); 502*95b482a8SLen Brown 503*95b482a8SLen Brown acpi_gbl_nesting_level--; 504*95b482a8SLen Brown } 505*95b482a8SLen Brown 506*95b482a8SLen Brown #endif 507*95b482a8SLen Brown 508*95b482a8SLen Brown /******************************************************************************* 509*95b482a8SLen Brown * 510*95b482a8SLen Brown * FUNCTION: acpi_ut_dump_buffer 511*95b482a8SLen Brown * 512*95b482a8SLen Brown * PARAMETERS: Buffer - Buffer to dump 513*95b482a8SLen Brown * Count - Amount to dump, in bytes 514*95b482a8SLen Brown * Display - BYTE, WORD, DWORD, or QWORD display 515*95b482a8SLen Brown * component_iD - Caller's component ID 516*95b482a8SLen Brown * 517*95b482a8SLen Brown * RETURN: None 518*95b482a8SLen Brown * 519*95b482a8SLen Brown * DESCRIPTION: Generic dump buffer in both hex and ascii. 520*95b482a8SLen Brown * 521*95b482a8SLen Brown ******************************************************************************/ 522*95b482a8SLen Brown 523*95b482a8SLen Brown void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display) 524*95b482a8SLen Brown { 525*95b482a8SLen Brown u32 i = 0; 526*95b482a8SLen Brown u32 j; 527*95b482a8SLen Brown u32 temp32; 528*95b482a8SLen Brown u8 buf_char; 529*95b482a8SLen Brown 530*95b482a8SLen Brown if (!buffer) { 531*95b482a8SLen Brown acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n"); 532*95b482a8SLen Brown return; 533*95b482a8SLen Brown } 534*95b482a8SLen Brown 535*95b482a8SLen Brown if ((count < 4) || (count & 0x01)) { 536*95b482a8SLen Brown display = DB_BYTE_DISPLAY; 537*95b482a8SLen Brown } 538*95b482a8SLen Brown 539*95b482a8SLen Brown /* Nasty little dump buffer routine! */ 540*95b482a8SLen Brown 541*95b482a8SLen Brown while (i < count) { 542*95b482a8SLen Brown 543*95b482a8SLen Brown /* Print current offset */ 544*95b482a8SLen Brown 545*95b482a8SLen Brown acpi_os_printf("%6.4X: ", i); 546*95b482a8SLen Brown 547*95b482a8SLen Brown /* Print 16 hex chars */ 548*95b482a8SLen Brown 549*95b482a8SLen Brown for (j = 0; j < 16;) { 550*95b482a8SLen Brown if (i + j >= count) { 551*95b482a8SLen Brown 552*95b482a8SLen Brown /* Dump fill spaces */ 553*95b482a8SLen Brown 554*95b482a8SLen Brown acpi_os_printf("%*s", ((display * 2) + 1), " "); 555*95b482a8SLen Brown j += display; 556*95b482a8SLen Brown continue; 557*95b482a8SLen Brown } 558*95b482a8SLen Brown 559*95b482a8SLen Brown switch (display) { 560*95b482a8SLen Brown case DB_BYTE_DISPLAY: 561*95b482a8SLen Brown default: /* Default is BYTE display */ 562*95b482a8SLen Brown 563*95b482a8SLen Brown acpi_os_printf("%02X ", 564*95b482a8SLen Brown buffer[(acpi_size) i + j]); 565*95b482a8SLen Brown break; 566*95b482a8SLen Brown 567*95b482a8SLen Brown case DB_WORD_DISPLAY: 568*95b482a8SLen Brown 569*95b482a8SLen Brown ACPI_MOVE_16_TO_32(&temp32, 570*95b482a8SLen Brown &buffer[(acpi_size) i + j]); 571*95b482a8SLen Brown acpi_os_printf("%04X ", temp32); 572*95b482a8SLen Brown break; 573*95b482a8SLen Brown 574*95b482a8SLen Brown case DB_DWORD_DISPLAY: 575*95b482a8SLen Brown 576*95b482a8SLen Brown ACPI_MOVE_32_TO_32(&temp32, 577*95b482a8SLen Brown &buffer[(acpi_size) i + j]); 578*95b482a8SLen Brown acpi_os_printf("%08X ", temp32); 579*95b482a8SLen Brown break; 580*95b482a8SLen Brown 581*95b482a8SLen Brown case DB_QWORD_DISPLAY: 582*95b482a8SLen Brown 583*95b482a8SLen Brown ACPI_MOVE_32_TO_32(&temp32, 584*95b482a8SLen Brown &buffer[(acpi_size) i + j]); 585*95b482a8SLen Brown acpi_os_printf("%08X", temp32); 586*95b482a8SLen Brown 587*95b482a8SLen Brown ACPI_MOVE_32_TO_32(&temp32, 588*95b482a8SLen Brown &buffer[(acpi_size) i + j + 589*95b482a8SLen Brown 4]); 590*95b482a8SLen Brown acpi_os_printf("%08X ", temp32); 591*95b482a8SLen Brown break; 592*95b482a8SLen Brown } 593*95b482a8SLen Brown 594*95b482a8SLen Brown j += display; 595*95b482a8SLen Brown } 596*95b482a8SLen Brown 597*95b482a8SLen Brown /* 598*95b482a8SLen Brown * Print the ASCII equivalent characters but watch out for the bad 599*95b482a8SLen Brown * unprintable ones (printable chars are 0x20 through 0x7E) 600*95b482a8SLen Brown */ 601*95b482a8SLen Brown acpi_os_printf(" "); 602*95b482a8SLen Brown for (j = 0; j < 16; j++) { 603*95b482a8SLen Brown if (i + j >= count) { 604*95b482a8SLen Brown acpi_os_printf("\n"); 605*95b482a8SLen Brown return; 606*95b482a8SLen Brown } 607*95b482a8SLen Brown 608*95b482a8SLen Brown buf_char = buffer[(acpi_size) i + j]; 609*95b482a8SLen Brown if (ACPI_IS_PRINT(buf_char)) { 610*95b482a8SLen Brown acpi_os_printf("%c", buf_char); 611*95b482a8SLen Brown } else { 612*95b482a8SLen Brown acpi_os_printf("."); 613*95b482a8SLen Brown } 614*95b482a8SLen Brown } 615*95b482a8SLen Brown 616*95b482a8SLen Brown /* Done with that line. */ 617*95b482a8SLen Brown 618*95b482a8SLen Brown acpi_os_printf("\n"); 619*95b482a8SLen Brown i += 16; 620*95b482a8SLen Brown } 621*95b482a8SLen Brown 622*95b482a8SLen Brown return; 623*95b482a8SLen Brown } 624*95b482a8SLen Brown 625*95b482a8SLen Brown /******************************************************************************* 626*95b482a8SLen Brown * 627*95b482a8SLen Brown * FUNCTION: acpi_ut_dump_buffer 628*95b482a8SLen Brown * 629*95b482a8SLen Brown * PARAMETERS: Buffer - Buffer to dump 630*95b482a8SLen Brown * Count - Amount to dump, in bytes 631*95b482a8SLen Brown * Display - BYTE, WORD, DWORD, or QWORD display 632*95b482a8SLen Brown * component_iD - Caller's component ID 633*95b482a8SLen Brown * 634*95b482a8SLen Brown * RETURN: None 635*95b482a8SLen Brown * 636*95b482a8SLen Brown * DESCRIPTION: Generic dump buffer in both hex and ascii. 637*95b482a8SLen Brown * 638*95b482a8SLen Brown ******************************************************************************/ 639*95b482a8SLen Brown 640*95b482a8SLen Brown void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id) 641*95b482a8SLen Brown { 642*95b482a8SLen Brown 643*95b482a8SLen Brown /* Only dump the buffer if tracing is enabled */ 644*95b482a8SLen Brown 645*95b482a8SLen Brown if (!((ACPI_LV_TABLES & acpi_dbg_level) && 646*95b482a8SLen Brown (component_id & acpi_dbg_layer))) { 647*95b482a8SLen Brown return; 648*95b482a8SLen Brown } 649*95b482a8SLen Brown 650*95b482a8SLen Brown acpi_ut_dump_buffer2(buffer, count, display); 651*95b482a8SLen Brown } 652