Linux Audio

Check our new training course

Loading...
v3.5.6
 
  1/******************************************************************************
  2 *
  3 * Module Name: utdebug - Debug print routines
 
 
  4 *
  5 *****************************************************************************/
  6
  7/*
  8 * Copyright (C) 2000 - 2012, Intel Corp.
  9 * 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
 44#include <linux/export.h>
 45#include <acpi/acpi.h>
 46#include "accommon.h"
 
 47
 48#define _COMPONENT          ACPI_UTILITIES
 49ACPI_MODULE_NAME("utdebug")
 50#ifdef ACPI_DEBUG_OUTPUT
 51static acpi_thread_id acpi_gbl_prev_thread_id;
 52static char *acpi_gbl_fn_entry_str = "----Entry";
 53static char *acpi_gbl_fn_exit_str = "----Exit-";
 54
 55/* Local prototypes */
 56
 57static const char *acpi_ut_trim_function_name(const char *function_name);
 
 58
 59/*******************************************************************************
 60 *
 61 * FUNCTION:    acpi_ut_init_stack_ptr_trace
 62 *
 63 * PARAMETERS:  None
 64 *
 65 * RETURN:      None
 66 *
 67 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
 68 *
 69 ******************************************************************************/
 70
 71void acpi_ut_init_stack_ptr_trace(void)
 72{
 73	acpi_size current_sp;
 74
 
 
 
 
 75	acpi_gbl_entry_stack_pointer = &current_sp;
 
 76}
 77
 78/*******************************************************************************
 79 *
 80 * FUNCTION:    acpi_ut_track_stack_ptr
 81 *
 82 * PARAMETERS:  None
 83 *
 84 * RETURN:      None
 85 *
 86 * DESCRIPTION: Save the current CPU stack pointer
 87 *
 88 ******************************************************************************/
 89
 90void acpi_ut_track_stack_ptr(void)
 91{
 92	acpi_size current_sp;
 93
 94	if (&current_sp < acpi_gbl_lowest_stack_pointer) {
 95		acpi_gbl_lowest_stack_pointer = &current_sp;
 96	}
 97
 98	if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
 99		acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
100	}
101}
102
103/*******************************************************************************
104 *
105 * FUNCTION:    acpi_ut_trim_function_name
106 *
107 * PARAMETERS:  function_name       - Ascii string containing a procedure name
108 *
109 * RETURN:      Updated pointer to the function name
110 *
111 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
112 *              This allows compiler macros such as __func__ to be used
113 *              with no change to the debug output.
114 *
115 ******************************************************************************/
116
117static const char *acpi_ut_trim_function_name(const char *function_name)
118{
119
120	/* All Function names are longer than 4 chars, check is safe */
121
122	if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
123
124		/* This is the case where the original source has not been modified */
125
126		return (function_name + 4);
127	}
128
129	if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
130
131		/* This is the case where the source has been 'linuxized' */
132
133		return (function_name + 5);
134	}
135
136	return (function_name);
137}
138
139/*******************************************************************************
140 *
141 * FUNCTION:    acpi_debug_print
142 *
143 * PARAMETERS:  requested_debug_level - Requested debug print level
144 *              line_number         - Caller's line number (for error output)
145 *              function_name       - Caller's procedure name
146 *              module_name         - Caller's module name
147 *              component_id        - Caller's component ID
148 *              Format              - Printf format field
149 *              ...                 - Optional printf arguments
150 *
151 * RETURN:      None
152 *
153 * DESCRIPTION: Print error message with prefix consisting of the module name,
154 *              line number, and component ID.
155 *
156 ******************************************************************************/
157
158void ACPI_INTERNAL_VAR_XFACE
159acpi_debug_print(u32 requested_debug_level,
160		 u32 line_number,
161		 const char *function_name,
162		 const char *module_name,
163		 u32 component_id, const char *format, ...)
164{
165	acpi_thread_id thread_id;
166	va_list args;
 
 
 
167
168	/*
169	 * Stay silent if the debug level or component ID is disabled
170	 */
171	if (!(requested_debug_level & acpi_dbg_level) ||
172	    !(component_id & acpi_dbg_layer)) {
173		return;
174	}
175
176	/*
177	 * Thread tracking and context switch notification
178	 */
179	thread_id = acpi_os_get_thread_id();
180	if (thread_id != acpi_gbl_prev_thread_id) {
181		if (ACPI_LV_THREADS & acpi_dbg_level) {
182			acpi_os_printf
183			    ("\n**** Context Switch from TID %u to TID %u ****\n\n",
184			     (u32)acpi_gbl_prev_thread_id, (u32)thread_id);
185		}
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	 */
194	acpi_os_printf("%8s-%04ld ", module_name, line_number);
195
 
 
 
 
 
 
 
196	if (ACPI_LV_THREADS & acpi_dbg_level) {
197		acpi_os_printf("[%u] ", (u32)thread_id);
198	}
199
200	acpi_os_printf("[%02ld] %-22.22s: ",
201		       acpi_gbl_nesting_level,
202		       acpi_ut_trim_function_name(function_name));
 
 
 
 
 
 
 
 
 
 
 
 
203
204	va_start(args, format);
205	acpi_os_vprintf(format, args);
206	va_end(args);
207}
208
209ACPI_EXPORT_SYMBOL(acpi_debug_print)
210
211/*******************************************************************************
212 *
213 * FUNCTION:    acpi_debug_print_raw
214 *
215 * PARAMETERS:  requested_debug_level - Requested debug print level
216 *              line_number         - Caller's line number
217 *              function_name       - Caller's procedure name
218 *              module_name         - Caller's module name
219 *              component_id        - Caller's component ID
220 *              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 *
228 ******************************************************************************/
229void ACPI_INTERNAL_VAR_XFACE
230acpi_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, ...)
235{
236	va_list args;
237
238	if (!(requested_debug_level & acpi_dbg_level) ||
239	    !(component_id & acpi_dbg_layer)) {
 
240		return;
241	}
242
243	va_start(args, format);
244	acpi_os_vprintf(format, args);
245	va_end(args);
246}
247
248ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
249
250/*******************************************************************************
251 *
252 * FUNCTION:    acpi_ut_trace
253 *
254 * PARAMETERS:  line_number         - Caller's line number
255 *              function_name       - Caller's procedure name
256 *              module_name         - Caller's module name
257 *              component_id        - Caller's component ID
258 *
259 * RETURN:      None
260 *
261 * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
262 *              set in debug_level
263 *
264 ******************************************************************************/
265void
266acpi_ut_trace(u32 line_number,
267	      const char *function_name,
268	      const char *module_name, u32 component_id)
269{
270
271	acpi_gbl_nesting_level++;
272	acpi_ut_track_stack_ptr();
273
274	acpi_debug_print(ACPI_LV_FUNCTIONS,
275			 line_number, function_name, module_name, component_id,
276			 "%s\n", acpi_gbl_fn_entry_str);
 
 
 
 
 
277}
278
279ACPI_EXPORT_SYMBOL(acpi_ut_trace)
280
281/*******************************************************************************
282 *
283 * FUNCTION:    acpi_ut_trace_ptr
284 *
285 * PARAMETERS:  line_number         - Caller's line number
286 *              function_name       - Caller's procedure name
287 *              module_name         - Caller's module name
288 *              component_id        - Caller's component ID
289 *              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 *
296 ******************************************************************************/
297void
298acpi_ut_trace_ptr(u32 line_number,
299		  const char *function_name,
300		  const char *module_name, u32 component_id, void *pointer)
 
301{
 
302	acpi_gbl_nesting_level++;
303	acpi_ut_track_stack_ptr();
304
305	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);
 
 
 
 
 
308}
309
310/*******************************************************************************
311 *
312 * FUNCTION:    acpi_ut_trace_str
313 *
314 * PARAMETERS:  line_number         - Caller's line number
315 *              function_name       - Caller's procedure name
316 *              module_name         - Caller's module name
317 *              component_id        - Caller's component ID
318 *              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 *
325 ******************************************************************************/
326
327void
328acpi_ut_trace_str(u32 line_number,
329		  const char *function_name,
330		  const char *module_name, u32 component_id, char *string)
331{
332
333	acpi_gbl_nesting_level++;
334	acpi_ut_track_stack_ptr();
335
336	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);
 
 
 
 
 
339}
340
341/*******************************************************************************
342 *
343 * FUNCTION:    acpi_ut_trace_u32
344 *
345 * PARAMETERS:  line_number         - Caller's line number
346 *              function_name       - Caller's procedure name
347 *              module_name         - Caller's module name
348 *              component_id        - Caller's component ID
349 *              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 *
356 ******************************************************************************/
357
358void
359acpi_ut_trace_u32(u32 line_number,
360		  const char *function_name,
361		  const char *module_name, u32 component_id, u32 integer)
362{
363
364	acpi_gbl_nesting_level++;
365	acpi_ut_track_stack_ptr();
366
367	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);
 
 
 
 
 
370}
371
372/*******************************************************************************
373 *
374 * FUNCTION:    acpi_ut_exit
375 *
376 * PARAMETERS:  line_number         - Caller's line number
377 *              function_name       - Caller's procedure name
378 *              module_name         - Caller's module name
379 *              component_id        - Caller's component ID
380 *
381 * RETURN:      None
382 *
383 * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
384 *              set in debug_level
385 *
386 ******************************************************************************/
387
388void
389acpi_ut_exit(u32 line_number,
390	     const char *function_name,
391	     const char *module_name, u32 component_id)
392{
393
394	acpi_debug_print(ACPI_LV_FUNCTIONS,
395			 line_number, function_name, module_name, component_id,
396			 "%s\n", acpi_gbl_fn_exit_str);
 
 
 
 
 
397
398	acpi_gbl_nesting_level--;
 
 
399}
400
401ACPI_EXPORT_SYMBOL(acpi_ut_exit)
402
403/*******************************************************************************
404 *
405 * FUNCTION:    acpi_ut_status_exit
406 *
407 * PARAMETERS:  line_number         - Caller's line number
408 *              function_name       - Caller's procedure name
409 *              module_name         - Caller's module name
410 *              component_id        - Caller's component ID
411 *              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 *
418 ******************************************************************************/
419void
420acpi_ut_status_exit(u32 line_number,
421		    const char *function_name,
422		    const char *module_name,
423		    u32 component_id, acpi_status status)
424{
425
426	if (ACPI_SUCCESS(status)) {
427		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));
431	} else {
432		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));
 
 
 
 
 
 
437	}
438
439	acpi_gbl_nesting_level--;
 
 
440}
441
442ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
443
444/*******************************************************************************
445 *
446 * FUNCTION:    acpi_ut_value_exit
447 *
448 * PARAMETERS:  line_number         - Caller's line number
449 *              function_name       - Caller's procedure name
450 *              module_name         - Caller's module name
451 *              component_id        - Caller's component ID
452 *              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 *
459 ******************************************************************************/
460void
461acpi_ut_value_exit(u32 line_number,
462		   const char *function_name,
463		   const char *module_name, u32 component_id, u64 value)
464{
465
466	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));
 
 
 
 
 
470
471	acpi_gbl_nesting_level--;
 
 
472}
473
474ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
475
476/*******************************************************************************
477 *
478 * FUNCTION:    acpi_ut_ptr_exit
479 *
480 * PARAMETERS:  line_number         - Caller's line number
481 *              function_name       - Caller's procedure name
482 *              module_name         - Caller's module name
483 *              component_id        - Caller's component ID
484 *              Ptr                 - Pointer to display
485 *
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 *
491 ******************************************************************************/
492void
493acpi_ut_ptr_exit(u32 line_number,
494		 const char *function_name,
495		 const char *module_name, u32 component_id, u8 *ptr)
496{
497
498	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);
501
502	acpi_gbl_nesting_level--;
503}
 
 
 
 
504
505#endif
 
 
 
506
507/*******************************************************************************
508 *
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 *
520 ******************************************************************************/
521
522void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display)
 
 
 
523{
524	u32 i = 0;
525	u32 j;
526	u32 temp32;
527	u8 buf_char;
528
529	if (!buffer) {
530		acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n");
531		return;
532	}
533
534	if ((count < 4) || (count & 0x01)) {
535		display = DB_BYTE_DISPLAY;
 
 
 
536	}
537
538	/* Nasty little dump buffer routine! */
539
540	while (i < count) {
541
542		/* Print current offset */
543
544		acpi_os_printf("%6.4X: ", i);
545
546		/* Print 16 hex chars */
547
548		for (j = 0; j < 16;) {
549			if (i + j >= count) {
550
551				/* Dump fill spaces */
552
553				acpi_os_printf("%*s", ((display * 2) + 1), " ");
554				j += display;
555				continue;
556			}
557
558			switch (display) {
559			case DB_BYTE_DISPLAY:
560			default:	/* Default is BYTE display */
561
562				acpi_os_printf("%02X ",
563					       buffer[(acpi_size) i + j]);
564				break;
565
566			case DB_WORD_DISPLAY:
567
568				ACPI_MOVE_16_TO_32(&temp32,
569						   &buffer[(acpi_size) i + j]);
570				acpi_os_printf("%04X ", temp32);
571				break;
572
573			case DB_DWORD_DISPLAY:
574
575				ACPI_MOVE_32_TO_32(&temp32,
576						   &buffer[(acpi_size) i + j]);
577				acpi_os_printf("%08X ", temp32);
578				break;
579
580			case DB_QWORD_DISPLAY:
581
582				ACPI_MOVE_32_TO_32(&temp32,
583						   &buffer[(acpi_size) i + j]);
584				acpi_os_printf("%08X", temp32);
585
586				ACPI_MOVE_32_TO_32(&temp32,
587						   &buffer[(acpi_size) i + j +
588							   4]);
589				acpi_os_printf("%08X ", temp32);
590				break;
591			}
592
593			j += display;
594		}
595
596		/*
597		 * Print the ASCII equivalent characters but watch out for the bad
598		 * unprintable ones (printable chars are 0x20 through 0x7E)
599		 */
600		acpi_os_printf(" ");
601		for (j = 0; j < 16; j++) {
602			if (i + j >= count) {
603				acpi_os_printf("\n");
604				return;
605			}
606
607			buf_char = buffer[(acpi_size) i + j];
608			if (ACPI_IS_PRINT(buf_char)) {
609				acpi_os_printf("%c", buf_char);
610			} else {
611				acpi_os_printf(".");
612			}
613		}
614
615		/* Done with that line. */
616
617		acpi_os_printf("\n");
618		i += 16;
619	}
620
621	return;
622}
623
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}
v6.9.4
  1// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2/******************************************************************************
  3 *
  4 * Module Name: utdebug - Debug print/trace routines
  5 *
  6 * Copyright (C) 2000 - 2023, Intel Corp.
  7 *
  8 *****************************************************************************/
  9
 10#define EXPORT_ACPI_INTERFACES
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 11
 
 12#include <acpi/acpi.h>
 13#include "accommon.h"
 14#include "acinterp.h"
 15
 16#define _COMPONENT          ACPI_UTILITIES
 17ACPI_MODULE_NAME("utdebug")
 
 
 
 
 18
 19#ifdef ACPI_DEBUG_OUTPUT
 20static acpi_thread_id acpi_gbl_previous_thread_id = (acpi_thread_id) 0xFFFFFFFF;
 21static const char *acpi_gbl_function_entry_prefix = "----Entry";
 22static const char *acpi_gbl_function_exit_prefix = "----Exit-";
 23
 24/*******************************************************************************
 25 *
 26 * FUNCTION:    acpi_ut_init_stack_ptr_trace
 27 *
 28 * PARAMETERS:  None
 29 *
 30 * RETURN:      None
 31 *
 32 * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
 33 *
 34 ******************************************************************************/
 35
 36void acpi_ut_init_stack_ptr_trace(void)
 37{
 38	acpi_size current_sp;
 39
 40#pragma GCC diagnostic push
 41#if defined(__GNUC__) && __GNUC__ >= 12
 42#pragma GCC diagnostic ignored "-Wdangling-pointer="
 43#endif
 44	acpi_gbl_entry_stack_pointer = &current_sp;
 45#pragma GCC diagnostic pop
 46}
 47
 48/*******************************************************************************
 49 *
 50 * FUNCTION:    acpi_ut_track_stack_ptr
 51 *
 52 * PARAMETERS:  None
 53 *
 54 * RETURN:      None
 55 *
 56 * DESCRIPTION: Save the current CPU stack pointer
 57 *
 58 ******************************************************************************/
 59
 60void acpi_ut_track_stack_ptr(void)
 61{
 62	acpi_size current_sp;
 63
 64	if (&current_sp < acpi_gbl_lowest_stack_pointer) {
 65		acpi_gbl_lowest_stack_pointer = &current_sp;
 66	}
 67
 68	if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
 69		acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
 70	}
 71}
 72
 73/*******************************************************************************
 74 *
 75 * FUNCTION:    acpi_ut_trim_function_name
 76 *
 77 * PARAMETERS:  function_name       - Ascii string containing a procedure name
 78 *
 79 * RETURN:      Updated pointer to the function name
 80 *
 81 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
 82 *              This allows compiler macros such as __func__ to be used
 83 *              with no change to the debug output.
 84 *
 85 ******************************************************************************/
 86
 87static const char *acpi_ut_trim_function_name(const char *function_name)
 88{
 89
 90	/* All Function names are longer than 4 chars, check is safe */
 91
 92	if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
 93
 94		/* This is the case where the original source has not been modified */
 95
 96		return (function_name + 4);
 97	}
 98
 99	if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
100
101		/* This is the case where the source has been 'linuxized' */
102
103		return (function_name + 5);
104	}
105
106	return (function_name);
107}
108
109/*******************************************************************************
110 *
111 * FUNCTION:    acpi_debug_print
112 *
113 * PARAMETERS:  requested_debug_level - Requested debug print level
114 *              line_number         - Caller's line number (for error output)
115 *              function_name       - Caller's procedure name
116 *              module_name         - Caller's module name
117 *              component_id        - Caller's component ID
118 *              format              - Printf format field
119 *              ...                 - Optional printf arguments
120 *
121 * RETURN:      None
122 *
123 * DESCRIPTION: Print error message with prefix consisting of the module name,
124 *              line number, and component ID.
125 *
126 ******************************************************************************/
127
128void ACPI_INTERNAL_VAR_XFACE
129acpi_debug_print(u32 requested_debug_level,
130		 u32 line_number,
131		 const char *function_name,
132		 const char *module_name,
133		 u32 component_id, const char *format, ...)
134{
135	acpi_thread_id thread_id;
136	va_list args;
137#ifdef ACPI_APPLICATION
138	int fill_count;
139#endif
140
141	/* Check if debug output enabled */
142
143	if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
 
 
144		return;
145	}
146
147	/*
148	 * Thread tracking and context switch notification
149	 */
150	thread_id = acpi_os_get_thread_id();
151	if (thread_id != acpi_gbl_previous_thread_id) {
152		if (ACPI_LV_THREADS & acpi_dbg_level) {
153			acpi_os_printf
154			    ("\n**** Context Switch from TID %u to TID %u ****\n\n",
155			     (u32)acpi_gbl_previous_thread_id, (u32)thread_id);
156		}
157
158		acpi_gbl_previous_thread_id = thread_id;
159		acpi_gbl_nesting_level = 0;
160	}
161
162	/*
163	 * Display the module name, current line number, thread ID (if requested),
164	 * current procedure nesting level, and the current procedure name
165	 */
166	acpi_os_printf("%9s-%04d ", module_name, line_number);
167
168#ifdef ACPI_APPLICATION
169	/*
170	 * For acpi_exec/iASL only, emit the thread ID and nesting level.
171	 * Note: nesting level is really only useful during a single-thread
172	 * execution. Otherwise, multiple threads will keep resetting the
173	 * level.
174	 */
175	if (ACPI_LV_THREADS & acpi_dbg_level) {
176		acpi_os_printf("[%u] ", (u32)thread_id);
177	}
178
179	fill_count = 48 - acpi_gbl_nesting_level -
180	    strlen(acpi_ut_trim_function_name(function_name));
181	if (fill_count < 0) {
182		fill_count = 0;
183	}
184
185	acpi_os_printf("[%02d] %*s",
186		       acpi_gbl_nesting_level, acpi_gbl_nesting_level + 1, " ");
187	acpi_os_printf("%s%*s: ",
188		       acpi_ut_trim_function_name(function_name), fill_count,
189		       " ");
190
191#else
192	acpi_os_printf("%-22.22s: ", acpi_ut_trim_function_name(function_name));
193#endif
194
195	va_start(args, format);
196	acpi_os_vprintf(format, args);
197	va_end(args);
198}
199
200ACPI_EXPORT_SYMBOL(acpi_debug_print)
201
202/*******************************************************************************
203 *
204 * FUNCTION:    acpi_debug_print_raw
205 *
206 * PARAMETERS:  requested_debug_level - Requested debug print level
207 *              line_number         - Caller's line number
208 *              function_name       - Caller's procedure name
209 *              module_name         - Caller's module name
210 *              component_id        - Caller's component ID
211 *              format              - Printf format field
212 *              ...                 - Optional printf arguments
213 *
214 * RETURN:      None
215 *
216 * DESCRIPTION: Print message with no headers. Has same interface as
217 *              debug_print so that the same macros can be used.
218 *
219 ******************************************************************************/
220void ACPI_INTERNAL_VAR_XFACE
221acpi_debug_print_raw(u32 requested_debug_level,
222		     u32 line_number,
223		     const char *function_name,
224		     const char *module_name,
225		     u32 component_id, const char *format, ...)
226{
227	va_list args;
228
229	/* Check if debug output enabled */
230
231	if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
232		return;
233	}
234
235	va_start(args, format);
236	acpi_os_vprintf(format, args);
237	va_end(args);
238}
239
240ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
241
242/*******************************************************************************
243 *
244 * FUNCTION:    acpi_ut_trace
245 *
246 * PARAMETERS:  line_number         - Caller's line number
247 *              function_name       - Caller's procedure name
248 *              module_name         - Caller's module name
249 *              component_id        - Caller's component ID
250 *
251 * RETURN:      None
252 *
253 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
254 *              set in debug_level
255 *
256 ******************************************************************************/
257void
258acpi_ut_trace(u32 line_number,
259	      const char *function_name,
260	      const char *module_name, u32 component_id)
261{
262
263	acpi_gbl_nesting_level++;
264	acpi_ut_track_stack_ptr();
265
266	/* Check if enabled up-front for performance */
267
268	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
269		acpi_debug_print(ACPI_LV_FUNCTIONS,
270				 line_number, function_name, module_name,
271				 component_id, "%s\n",
272				 acpi_gbl_function_entry_prefix);
273	}
274}
275
276ACPI_EXPORT_SYMBOL(acpi_ut_trace)
277
278/*******************************************************************************
279 *
280 * FUNCTION:    acpi_ut_trace_ptr
281 *
282 * PARAMETERS:  line_number         - Caller's line number
283 *              function_name       - Caller's procedure name
284 *              module_name         - Caller's module name
285 *              component_id        - Caller's component ID
286 *              pointer             - Pointer to display
287 *
288 * RETURN:      None
289 *
290 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
291 *              set in debug_level
292 *
293 ******************************************************************************/
294void
295acpi_ut_trace_ptr(u32 line_number,
296		  const char *function_name,
297		  const char *module_name,
298		  u32 component_id, const void *pointer)
299{
300
301	acpi_gbl_nesting_level++;
302	acpi_ut_track_stack_ptr();
303
304	/* Check if enabled up-front for performance */
305
306	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
307		acpi_debug_print(ACPI_LV_FUNCTIONS,
308				 line_number, function_name, module_name,
309				 component_id, "%s %p\n",
310				 acpi_gbl_function_entry_prefix, pointer);
311	}
312}
313
314/*******************************************************************************
315 *
316 * FUNCTION:    acpi_ut_trace_str
317 *
318 * PARAMETERS:  line_number         - Caller's line number
319 *              function_name       - Caller's procedure name
320 *              module_name         - Caller's module name
321 *              component_id        - Caller's component ID
322 *              string              - Additional string to display
323 *
324 * RETURN:      None
325 *
326 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
327 *              set in debug_level
328 *
329 ******************************************************************************/
330
331void
332acpi_ut_trace_str(u32 line_number,
333		  const char *function_name,
334		  const char *module_name, u32 component_id, const char *string)
335{
336
337	acpi_gbl_nesting_level++;
338	acpi_ut_track_stack_ptr();
339
340	/* Check if enabled up-front for performance */
341
342	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
343		acpi_debug_print(ACPI_LV_FUNCTIONS,
344				 line_number, function_name, module_name,
345				 component_id, "%s %s\n",
346				 acpi_gbl_function_entry_prefix, string);
347	}
348}
349
350/*******************************************************************************
351 *
352 * FUNCTION:    acpi_ut_trace_u32
353 *
354 * PARAMETERS:  line_number         - Caller's line number
355 *              function_name       - Caller's procedure name
356 *              module_name         - Caller's module name
357 *              component_id        - Caller's component ID
358 *              integer             - Integer to display
359 *
360 * RETURN:      None
361 *
362 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
363 *              set in debug_level
364 *
365 ******************************************************************************/
366
367void
368acpi_ut_trace_u32(u32 line_number,
369		  const char *function_name,
370		  const char *module_name, u32 component_id, u32 integer)
371{
372
373	acpi_gbl_nesting_level++;
374	acpi_ut_track_stack_ptr();
375
376	/* Check if enabled up-front for performance */
377
378	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
379		acpi_debug_print(ACPI_LV_FUNCTIONS,
380				 line_number, function_name, module_name,
381				 component_id, "%s %08X\n",
382				 acpi_gbl_function_entry_prefix, integer);
383	}
384}
385
386/*******************************************************************************
387 *
388 * FUNCTION:    acpi_ut_exit
389 *
390 * PARAMETERS:  line_number         - Caller's line number
391 *              function_name       - Caller's procedure name
392 *              module_name         - Caller's module name
393 *              component_id        - Caller's component ID
394 *
395 * RETURN:      None
396 *
397 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
398 *              set in debug_level
399 *
400 ******************************************************************************/
401
402void
403acpi_ut_exit(u32 line_number,
404	     const char *function_name,
405	     const char *module_name, u32 component_id)
406{
407
408	/* Check if enabled up-front for performance */
409
410	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
411		acpi_debug_print(ACPI_LV_FUNCTIONS,
412				 line_number, function_name, module_name,
413				 component_id, "%s\n",
414				 acpi_gbl_function_exit_prefix);
415	}
416
417	if (acpi_gbl_nesting_level) {
418		acpi_gbl_nesting_level--;
419	}
420}
421
422ACPI_EXPORT_SYMBOL(acpi_ut_exit)
423
424/*******************************************************************************
425 *
426 * FUNCTION:    acpi_ut_status_exit
427 *
428 * PARAMETERS:  line_number         - Caller's line number
429 *              function_name       - Caller's procedure name
430 *              module_name         - Caller's module name
431 *              component_id        - Caller's component ID
432 *              status              - Exit status code
433 *
434 * RETURN:      None
435 *
436 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
437 *              set in debug_level. Prints exit status also.
438 *
439 ******************************************************************************/
440void
441acpi_ut_status_exit(u32 line_number,
442		    const char *function_name,
443		    const char *module_name,
444		    u32 component_id, acpi_status status)
445{
446
447	/* Check if enabled up-front for performance */
448
449	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
450		if (ACPI_SUCCESS(status)) {
451			acpi_debug_print(ACPI_LV_FUNCTIONS,
452					 line_number, function_name,
453					 module_name, component_id, "%s %s\n",
454					 acpi_gbl_function_exit_prefix,
455					 acpi_format_exception(status));
456		} else {
457			acpi_debug_print(ACPI_LV_FUNCTIONS,
458					 line_number, function_name,
459					 module_name, component_id,
460					 "%s ****Exception****: %s\n",
461					 acpi_gbl_function_exit_prefix,
462					 acpi_format_exception(status));
463		}
464	}
465
466	if (acpi_gbl_nesting_level) {
467		acpi_gbl_nesting_level--;
468	}
469}
470
471ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
472
473/*******************************************************************************
474 *
475 * FUNCTION:    acpi_ut_value_exit
476 *
477 * PARAMETERS:  line_number         - Caller's line number
478 *              function_name       - Caller's procedure name
479 *              module_name         - Caller's module name
480 *              component_id        - Caller's component ID
481 *              value               - Value to be printed with exit msg
482 *
483 * RETURN:      None
484 *
485 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
486 *              set in debug_level. Prints exit value also.
487 *
488 ******************************************************************************/
489void
490acpi_ut_value_exit(u32 line_number,
491		   const char *function_name,
492		   const char *module_name, u32 component_id, u64 value)
493{
494
495	/* Check if enabled up-front for performance */
496
497	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
498		acpi_debug_print(ACPI_LV_FUNCTIONS,
499				 line_number, function_name, module_name,
500				 component_id, "%s %8.8X%8.8X\n",
501				 acpi_gbl_function_exit_prefix,
502				 ACPI_FORMAT_UINT64(value));
503	}
504
505	if (acpi_gbl_nesting_level) {
506		acpi_gbl_nesting_level--;
507	}
508}
509
510ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
511
512/*******************************************************************************
513 *
514 * FUNCTION:    acpi_ut_ptr_exit
515 *
516 * PARAMETERS:  line_number         - Caller's line number
517 *              function_name       - Caller's procedure name
518 *              module_name         - Caller's module name
519 *              component_id        - Caller's component ID
520 *              ptr                 - Pointer to display
521 *
522 * RETURN:      None
523 *
524 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
525 *              set in debug_level. Prints exit value also.
526 *
527 ******************************************************************************/
528void
529acpi_ut_ptr_exit(u32 line_number,
530		 const char *function_name,
531		 const char *module_name, u32 component_id, u8 *ptr)
532{
533
534	/* Check if enabled up-front for performance */
 
 
535
536	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
537		acpi_debug_print(ACPI_LV_FUNCTIONS,
538				 line_number, function_name, module_name,
539				 component_id, "%s %p\n",
540				 acpi_gbl_function_exit_prefix, ptr);
541	}
542
543	if (acpi_gbl_nesting_level) {
544		acpi_gbl_nesting_level--;
545	}
546}
547
548/*******************************************************************************
549 *
550 * FUNCTION:    acpi_ut_str_exit
551 *
552 * PARAMETERS:  line_number         - Caller's line number
553 *              function_name       - Caller's procedure name
554 *              module_name         - Caller's module name
555 *              component_id        - Caller's component ID
556 *              string              - String to display
557 *
558 * RETURN:      None
559 *
560 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
561 *              set in debug_level. Prints exit value also.
562 *
563 ******************************************************************************/
564
565void
566acpi_ut_str_exit(u32 line_number,
567		 const char *function_name,
568		 const char *module_name, u32 component_id, const char *string)
569{
 
 
 
 
570
571	/* Check if enabled up-front for performance */
 
 
 
572
573	if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
574		acpi_debug_print(ACPI_LV_FUNCTIONS,
575				 line_number, function_name, module_name,
576				 component_id, "%s %s\n",
577				 acpi_gbl_function_exit_prefix, string);
578	}
579
580	if (acpi_gbl_nesting_level) {
581		acpi_gbl_nesting_level--;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
582	}
 
 
583}
584
585/*******************************************************************************
586 *
587 * FUNCTION:    acpi_trace_point
588 *
589 * PARAMETERS:  type                - Trace event type
590 *              begin               - TRUE if before execution
591 *              aml                 - Executed AML address
592 *              pathname            - Object path
593 *              pointer             - Pointer to the related object
594 *
595 * RETURN:      None
596 *
597 * DESCRIPTION: Interpreter execution trace.
598 *
599 ******************************************************************************/
600
601void
602acpi_trace_point(acpi_trace_event_type type, u8 begin, u8 *aml, char *pathname)
603{
604
605	ACPI_FUNCTION_ENTRY();
606
607	acpi_ex_trace_point(type, begin, aml, pathname);
 
 
 
608
609#ifdef ACPI_USE_SYSTEM_TRACER
610	acpi_os_trace_point(type, begin, aml, pathname);
611#endif
612}
613
614ACPI_EXPORT_SYMBOL(acpi_trace_point)
615
616#endif