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