0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #define EXPORT_ACPI_INTERFACES
0011
0012 #include <acpi/acpi.h>
0013 #include "accommon.h"
0014 #include "acinterp.h"
0015
0016 #define _COMPONENT ACPI_UTILITIES
0017 ACPI_MODULE_NAME("utdebug")
0018
0019 #ifdef ACPI_DEBUG_OUTPUT
0020 static acpi_thread_id acpi_gbl_previous_thread_id = (acpi_thread_id) 0xFFFFFFFF;
0021 static const char *acpi_gbl_function_entry_prefix = "----Entry";
0022 static const char *acpi_gbl_function_exit_prefix = "----Exit-";
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 void acpi_ut_init_stack_ptr_trace(void)
0037 {
0038 acpi_size current_sp;
0039
0040 acpi_gbl_entry_stack_pointer = ¤t_sp;
0041 }
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 void acpi_ut_track_stack_ptr(void)
0056 {
0057 acpi_size current_sp;
0058
0059 if (¤t_sp < acpi_gbl_lowest_stack_pointer) {
0060 acpi_gbl_lowest_stack_pointer = ¤t_sp;
0061 }
0062
0063 if (acpi_gbl_nesting_level > acpi_gbl_deepest_nesting) {
0064 acpi_gbl_deepest_nesting = acpi_gbl_nesting_level;
0065 }
0066 }
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 static const char *acpi_ut_trim_function_name(const char *function_name)
0083 {
0084
0085
0086
0087 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) {
0088
0089
0090
0091 return (function_name + 4);
0092 }
0093
0094 if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) {
0095
0096
0097
0098 return (function_name + 5);
0099 }
0100
0101 return (function_name);
0102 }
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123 void ACPI_INTERNAL_VAR_XFACE
0124 acpi_debug_print(u32 requested_debug_level,
0125 u32 line_number,
0126 const char *function_name,
0127 const char *module_name,
0128 u32 component_id, const char *format, ...)
0129 {
0130 acpi_thread_id thread_id;
0131 va_list args;
0132 #ifdef ACPI_APPLICATION
0133 int fill_count;
0134 #endif
0135
0136
0137
0138 if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
0139 return;
0140 }
0141
0142
0143
0144
0145 thread_id = acpi_os_get_thread_id();
0146 if (thread_id != acpi_gbl_previous_thread_id) {
0147 if (ACPI_LV_THREADS & acpi_dbg_level) {
0148 acpi_os_printf
0149 ("\n**** Context Switch from TID %u to TID %u ****\n\n",
0150 (u32)acpi_gbl_previous_thread_id, (u32)thread_id);
0151 }
0152
0153 acpi_gbl_previous_thread_id = thread_id;
0154 acpi_gbl_nesting_level = 0;
0155 }
0156
0157
0158
0159
0160
0161 acpi_os_printf("%9s-%04d ", module_name, line_number);
0162
0163 #ifdef ACPI_APPLICATION
0164
0165
0166
0167
0168
0169
0170 if (ACPI_LV_THREADS & acpi_dbg_level) {
0171 acpi_os_printf("[%u] ", (u32)thread_id);
0172 }
0173
0174 fill_count = 48 - acpi_gbl_nesting_level -
0175 strlen(acpi_ut_trim_function_name(function_name));
0176 if (fill_count < 0) {
0177 fill_count = 0;
0178 }
0179
0180 acpi_os_printf("[%02d] %*s",
0181 acpi_gbl_nesting_level, acpi_gbl_nesting_level + 1, " ");
0182 acpi_os_printf("%s%*s: ",
0183 acpi_ut_trim_function_name(function_name), fill_count,
0184 " ");
0185
0186 #else
0187 acpi_os_printf("%-22.22s: ", acpi_ut_trim_function_name(function_name));
0188 #endif
0189
0190 va_start(args, format);
0191 acpi_os_vprintf(format, args);
0192 va_end(args);
0193 }
0194
0195 ACPI_EXPORT_SYMBOL(acpi_debug_print)
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215 void ACPI_INTERNAL_VAR_XFACE
0216 acpi_debug_print_raw(u32 requested_debug_level,
0217 u32 line_number,
0218 const char *function_name,
0219 const char *module_name,
0220 u32 component_id, const char *format, ...)
0221 {
0222 va_list args;
0223
0224
0225
0226 if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
0227 return;
0228 }
0229
0230 va_start(args, format);
0231 acpi_os_vprintf(format, args);
0232 va_end(args);
0233 }
0234
0235 ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252 void
0253 acpi_ut_trace(u32 line_number,
0254 const char *function_name,
0255 const char *module_name, u32 component_id)
0256 {
0257
0258 acpi_gbl_nesting_level++;
0259 acpi_ut_track_stack_ptr();
0260
0261
0262
0263 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
0264 acpi_debug_print(ACPI_LV_FUNCTIONS,
0265 line_number, function_name, module_name,
0266 component_id, "%s\n",
0267 acpi_gbl_function_entry_prefix);
0268 }
0269 }
0270
0271 ACPI_EXPORT_SYMBOL(acpi_ut_trace)
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289 void
0290 acpi_ut_trace_ptr(u32 line_number,
0291 const char *function_name,
0292 const char *module_name,
0293 u32 component_id, const void *pointer)
0294 {
0295
0296 acpi_gbl_nesting_level++;
0297 acpi_ut_track_stack_ptr();
0298
0299
0300
0301 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
0302 acpi_debug_print(ACPI_LV_FUNCTIONS,
0303 line_number, function_name, module_name,
0304 component_id, "%s %p\n",
0305 acpi_gbl_function_entry_prefix, pointer);
0306 }
0307 }
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326 void
0327 acpi_ut_trace_str(u32 line_number,
0328 const char *function_name,
0329 const char *module_name, u32 component_id, const char *string)
0330 {
0331
0332 acpi_gbl_nesting_level++;
0333 acpi_ut_track_stack_ptr();
0334
0335
0336
0337 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
0338 acpi_debug_print(ACPI_LV_FUNCTIONS,
0339 line_number, function_name, module_name,
0340 component_id, "%s %s\n",
0341 acpi_gbl_function_entry_prefix, string);
0342 }
0343 }
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362 void
0363 acpi_ut_trace_u32(u32 line_number,
0364 const char *function_name,
0365 const char *module_name, u32 component_id, u32 integer)
0366 {
0367
0368 acpi_gbl_nesting_level++;
0369 acpi_ut_track_stack_ptr();
0370
0371
0372
0373 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
0374 acpi_debug_print(ACPI_LV_FUNCTIONS,
0375 line_number, function_name, module_name,
0376 component_id, "%s %08X\n",
0377 acpi_gbl_function_entry_prefix, integer);
0378 }
0379 }
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397 void
0398 acpi_ut_exit(u32 line_number,
0399 const char *function_name,
0400 const char *module_name, u32 component_id)
0401 {
0402
0403
0404
0405 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
0406 acpi_debug_print(ACPI_LV_FUNCTIONS,
0407 line_number, function_name, module_name,
0408 component_id, "%s\n",
0409 acpi_gbl_function_exit_prefix);
0410 }
0411
0412 if (acpi_gbl_nesting_level) {
0413 acpi_gbl_nesting_level--;
0414 }
0415 }
0416
0417 ACPI_EXPORT_SYMBOL(acpi_ut_exit)
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435 void
0436 acpi_ut_status_exit(u32 line_number,
0437 const char *function_name,
0438 const char *module_name,
0439 u32 component_id, acpi_status status)
0440 {
0441
0442
0443
0444 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
0445 if (ACPI_SUCCESS(status)) {
0446 acpi_debug_print(ACPI_LV_FUNCTIONS,
0447 line_number, function_name,
0448 module_name, component_id, "%s %s\n",
0449 acpi_gbl_function_exit_prefix,
0450 acpi_format_exception(status));
0451 } else {
0452 acpi_debug_print(ACPI_LV_FUNCTIONS,
0453 line_number, function_name,
0454 module_name, component_id,
0455 "%s ****Exception****: %s\n",
0456 acpi_gbl_function_exit_prefix,
0457 acpi_format_exception(status));
0458 }
0459 }
0460
0461 if (acpi_gbl_nesting_level) {
0462 acpi_gbl_nesting_level--;
0463 }
0464 }
0465
0466 ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
0467
0468
0469
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484 void
0485 acpi_ut_value_exit(u32 line_number,
0486 const char *function_name,
0487 const char *module_name, u32 component_id, u64 value)
0488 {
0489
0490
0491
0492 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
0493 acpi_debug_print(ACPI_LV_FUNCTIONS,
0494 line_number, function_name, module_name,
0495 component_id, "%s %8.8X%8.8X\n",
0496 acpi_gbl_function_exit_prefix,
0497 ACPI_FORMAT_UINT64(value));
0498 }
0499
0500 if (acpi_gbl_nesting_level) {
0501 acpi_gbl_nesting_level--;
0502 }
0503 }
0504
0505 ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523 void
0524 acpi_ut_ptr_exit(u32 line_number,
0525 const char *function_name,
0526 const char *module_name, u32 component_id, u8 *ptr)
0527 {
0528
0529
0530
0531 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
0532 acpi_debug_print(ACPI_LV_FUNCTIONS,
0533 line_number, function_name, module_name,
0534 component_id, "%s %p\n",
0535 acpi_gbl_function_exit_prefix, ptr);
0536 }
0537
0538 if (acpi_gbl_nesting_level) {
0539 acpi_gbl_nesting_level--;
0540 }
0541 }
0542
0543
0544
0545
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560 void
0561 acpi_ut_str_exit(u32 line_number,
0562 const char *function_name,
0563 const char *module_name, u32 component_id, const char *string)
0564 {
0565
0566
0567
0568 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
0569 acpi_debug_print(ACPI_LV_FUNCTIONS,
0570 line_number, function_name, module_name,
0571 component_id, "%s %s\n",
0572 acpi_gbl_function_exit_prefix, string);
0573 }
0574
0575 if (acpi_gbl_nesting_level) {
0576 acpi_gbl_nesting_level--;
0577 }
0578 }
0579
0580
0581
0582
0583
0584
0585
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595
0596 void
0597 acpi_trace_point(acpi_trace_event_type type, u8 begin, u8 *aml, char *pathname)
0598 {
0599
0600 ACPI_FUNCTION_ENTRY();
0601
0602 acpi_ex_trace_point(type, begin, aml, pathname);
0603
0604 #ifdef ACPI_USE_SYSTEM_TRACER
0605 acpi_os_trace_point(type, begin, aml, pathname);
0606 #endif
0607 }
0608
0609 ACPI_EXPORT_SYMBOL(acpi_trace_point)
0610
0611 #endif