aboutsummaryrefslogtreecommitdiffstats
path: root/include/acpi/acmacros.h
diff options
context:
space:
mode:
authorRobert Moore <robert.moore@intel.com>2005-07-08 00:00:00 -0400
committerLen Brown <len.brown@intel.com>2005-07-14 00:42:23 -0400
commitf9f4601f331aa1226d7a798a01950efbb388f07f (patch)
tree62e079a9275749d16a4a0da56a427be201e15d27 /include/acpi/acmacros.h
parent4c3ffbd79529b680b3c3ef2b6f42f0c89c694ec5 (diff)
ACPICA 20050708 from Bob Moore <robert.moore@intel.com>
The use of the CPU stack in the debug version of the subsystem has been considerably reduced. Previously, a debug structure was declared in every function that used the debug macros. This structure has been removed in favor of declaring the individual elements as parameters to the debug functions. This reduces the cumulative stack use during nested execution of ACPI function calls at the cost of a small increase in the code size of the debug version of the subsystem. With assistance from Alexey Starikovskiy and Len Brown. Added the ACPI_GET_FUNCTION_NAME macro to enable the compiler-dependent headers to define a macro that will return the current function name at runtime (such as __FUNCTION__ or _func_, etc.) The function name is used by the debug trace output. If ACPI_GET_FUNCTION_NAME is not defined in the compiler-dependent header, the function name is saved on the CPU stack (one pointer per function.) This mechanism is used because apparently there exists no standard ANSI-C defined macro that that returns the function name. Alexey Starikovskiy redesigned and reimplemented the "Owner ID" mechanism used to track namespace objects created/deleted by ACPI tables and control method execution. A bitmap is now used to allocate and free the IDs, thus solving the wraparound problem present in the previous implementation. The size of the namespace node descriptor was reduced by 2 bytes as a result. Removed the UINT32_BIT and UINT16_BIT types that were used for the bitfield flag definitions within the headers for the predefined ACPI tables. These have been replaced by UINT8_BIT in order to increase the code portability of the subsystem. If the use of UINT8 remains a problem, we may be forced to eliminate bitfields entirely because of a lack of portability. Alexey Starikovksiy enhanced the performance of acpi_ut_update_object_reference. This is a frequently used function and this improvement increases the performance of the entire subsystem. Alexey Starikovskiy fixed several possible memory leaks and the inverse - premature object deletion. Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'include/acpi/acmacros.h')
-rw-r--r--include/acpi/acmacros.h100
1 files changed, 60 insertions, 40 deletions
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index 09be937d2c39..5b100cef8dfc 100644
--- a/include/acpi/acmacros.h
+++ b/include/acpi/acmacros.h
@@ -437,21 +437,22 @@
437#define ACPI_PARAM_LIST(pl) pl 437#define ACPI_PARAM_LIST(pl) pl
438 438
439/* 439/*
440 * Error reporting. These versions add callers module and line#. Since 440 * Error reporting. These versions add callers module and line#.
441 * _THIS_MODULE gets compiled out when ACPI_DEBUG_OUTPUT isn't defined, only 441 *
442 * use it in debug mode. 442 * Since _acpi_module_name gets compiled out when ACPI_DEBUG_OUTPUT
443 * isn't defined, only use it in debug mode.
443 */ 444 */
444#ifdef ACPI_DEBUG_OUTPUT 445#ifdef ACPI_DEBUG_OUTPUT
445 446
446#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info(_THIS_MODULE,__LINE__,_COMPONENT); \ 447#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info(_acpi_module_name,__LINE__,_COMPONENT); \
447 acpi_os_printf ACPI_PARAM_LIST(fp);} 448 acpi_os_printf ACPI_PARAM_LIST(fp);}
448#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error(_THIS_MODULE,__LINE__,_COMPONENT); \ 449#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error(_acpi_module_name,__LINE__,_COMPONENT); \
449 acpi_os_printf ACPI_PARAM_LIST(fp);} 450 acpi_os_printf ACPI_PARAM_LIST(fp);}
450#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning(_THIS_MODULE,__LINE__,_COMPONENT); \ 451#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning(_acpi_module_name,__LINE__,_COMPONENT); \
451 acpi_os_printf ACPI_PARAM_LIST(fp);} 452 acpi_os_printf ACPI_PARAM_LIST(fp);}
452#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error(_THIS_MODULE,__LINE__,_COMPONENT, s, e); 453#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error(_acpi_module_name,__LINE__,_COMPONENT, s, e);
453 454
454#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) acpi_ns_report_method_error(_THIS_MODULE,__LINE__,_COMPONENT, s, n, p, e); 455#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) acpi_ns_report_method_error(_acpi_module_name,__LINE__,_COMPONENT, s, n, p, e);
455 456
456#else 457#else
457 458
@@ -480,36 +481,56 @@
480 * Debug macros that are conditionally compiled 481 * Debug macros that are conditionally compiled
481 */ 482 */
482#ifdef ACPI_DEBUG_OUTPUT 483#ifdef ACPI_DEBUG_OUTPUT
484#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_acpi_module_name = name;
483 485
484#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_THIS_MODULE = name; 486/*
487 * Common parameters used for debug output functions:
488 * line number, function name, module(file) name, component ID
489 */
490#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT
485 491
486/* 492/*
487 * Function entry tracing. 493 * Function entry tracing
488 * The first parameter should be the procedure name as a quoted string. This is declared
489 * as a local string ("_proc_name) so that it can be also used by the function exit macros below.
490 */ 494 */
491#define ACPI_FUNCTION_NAME(a) struct acpi_debug_print_info _debug_info; \ 495
492 _debug_info.component_id = _COMPONENT; \ 496/*
493 _debug_info.proc_name = a; \ 497 * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header,
494 _debug_info.module_name = _THIS_MODULE; 498 * define it now. This is the case where there the compiler does not support
495 499 * a __FUNCTION__ macro or equivalent. We save the function name on the
496#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ 500 * local stack.
497 acpi_ut_trace(__LINE__,&_debug_info) 501 */
498#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ 502#ifndef ACPI_GET_FUNCTION_NAME
499 acpi_ut_trace_ptr(__LINE__,&_debug_info,(void *)b) 503#define ACPI_GET_FUNCTION_NAME _acpi_function_name
500#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ 504/*
501 acpi_ut_trace_u32(__LINE__,&_debug_info,(u32)b) 505 * The Name parameter should be the procedure name as a quoted string.
502#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ 506 * This is declared as a local string ("my_function_name") so that it can
503 acpi_ut_trace_str(__LINE__,&_debug_info,(char *)b) 507 * be also used by the function exit macros below.
504 508 */
505#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr() 509#define ACPI_FUNCTION_NAME(name) char *_acpi_function_name = name;
510
511#else
512/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */
513
514#define ACPI_FUNCTION_NAME(name)
515#endif
516
517#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
518 acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
519#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \
520 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS,(void *)b)
521#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \
522 acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS,(u32)b)
523#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \
524 acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS,(char *)b)
525
526#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr()
506 527
507/* 528/*
508 * Function exit tracing. 529 * Function exit tracing.
509 * WARNING: These macros include a return statement. This is usually considered 530 * WARNING: These macros include a return statement. This is usually considered
510 * bad form, but having a separate exit macro is very ugly and difficult to maintain. 531 * bad form, but having a separate exit macro is very ugly and difficult to maintain.
511 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros 532 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
512 * so that "_proc_name" is defined. 533 * so that "_acpi_function_name" is defined.
513 */ 534 */
514#ifdef ACPI_USE_DO_WHILE_0 535#ifdef ACPI_USE_DO_WHILE_0
515#define ACPI_DO_WHILE0(a) do a while(0) 536#define ACPI_DO_WHILE0(a) do a while(0)
@@ -517,10 +538,10 @@
517#define ACPI_DO_WHILE0(a) a 538#define ACPI_DO_WHILE0(a) a
518#endif 539#endif
519 540
520#define return_VOID ACPI_DO_WHILE0 ({acpi_ut_exit(__LINE__,&_debug_info);return;}) 541#define return_VOID ACPI_DO_WHILE0 ({acpi_ut_exit(ACPI_DEBUG_PARAMETERS);return;})
521#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({acpi_ut_status_exit(__LINE__,&_debug_info,(s));return((s));}) 542#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({acpi_ut_status_exit(ACPI_DEBUG_PARAMETERS,(s));return((s));})
522#define return_VALUE(s) ACPI_DO_WHILE0 ({acpi_ut_value_exit(__LINE__,&_debug_info,(acpi_integer)(s));return((s));}) 543#define return_VALUE(s) ACPI_DO_WHILE0 ({acpi_ut_value_exit(ACPI_DEBUG_PARAMETERS,(acpi_integer)(s));return((s));})
523#define return_PTR(s) ACPI_DO_WHILE0 ({acpi_ut_ptr_exit(__LINE__,&_debug_info,(u8 *)(s));return((s));}) 544#define return_PTR(s) ACPI_DO_WHILE0 ({acpi_ut_ptr_exit(ACPI_DEBUG_PARAMETERS,(u8 *)(s));return((s));})
524 545
525/* Conditional execution */ 546/* Conditional execution */
526 547
@@ -535,7 +556,7 @@
535/* Stack and buffer dumping */ 556/* Stack and buffer dumping */
536 557
537#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a),0) 558#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a),0)
538#define ACPI_DUMP_OPERANDS(a,b,c,d,e) acpi_ex_dump_operands(a,b,c,d,e,_THIS_MODULE,__LINE__) 559#define ACPI_DUMP_OPERANDS(a,b,c,d,e) acpi_ex_dump_operands(a,b,c,d,e,_acpi_module_name,__LINE__)
539 560
540 561
541#define ACPI_DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b) 562#define ACPI_DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b)
@@ -572,7 +593,7 @@
572 * leaving no executable debug code! 593 * leaving no executable debug code!
573 */ 594 */
574#define ACPI_MODULE_NAME(name) 595#define ACPI_MODULE_NAME(name)
575#define _THIS_MODULE "" 596#define _acpi_module_name ""
576 597
577#define ACPI_DEBUG_EXEC(a) 598#define ACPI_DEBUG_EXEC(a)
578#define ACPI_NORMAL_EXEC(a) a; 599#define ACPI_NORMAL_EXEC(a) a;
@@ -648,19 +669,18 @@
648 669
649/* Memory allocation */ 670/* Memory allocation */
650 671
651#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_THIS_MODULE,__LINE__) 672#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__)
652#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate((acpi_size)(a), _COMPONENT,_THIS_MODULE,__LINE__) 673#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__)
653#define ACPI_MEM_FREE(a) acpi_os_free(a) 674#define ACPI_MEM_FREE(a) acpi_os_free(a)
654#define ACPI_MEM_TRACKING(a) 675#define ACPI_MEM_TRACKING(a)
655 676
656
657#else 677#else
658 678
659/* Memory allocation */ 679/* Memory allocation */
660 680
661#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_THIS_MODULE,__LINE__) 681#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__)
662#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate_and_track((acpi_size)(a), _COMPONENT,_THIS_MODULE,__LINE__) 682#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate_and_track((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__)
663#define ACPI_MEM_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_THIS_MODULE,__LINE__) 683#define ACPI_MEM_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__)
664#define ACPI_MEM_TRACKING(a) a 684#define ACPI_MEM_TRACKING(a) a
665 685
666#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 686#endif /* ACPI_DBG_TRACK_ALLOCATIONS */