18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 28c2ecf20Sopenharmony_ci/****************************************************************************** 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Name: acoutput.h -- debug output 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2000 - 2020, Intel Corp. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci *****************************************************************************/ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef __ACOUTPUT_H__ 118c2ecf20Sopenharmony_ci#define __ACOUTPUT_H__ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * Debug levels and component IDs. These are used to control the 158c2ecf20Sopenharmony_ci * granularity of the output of the ACPI_DEBUG_PRINT macro -- on a 168c2ecf20Sopenharmony_ci * per-component basis and a per-exception-type basis. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* Component IDs are used in the global "DebugLayer" */ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define ACPI_UTILITIES 0x00000001 228c2ecf20Sopenharmony_ci#define ACPI_HARDWARE 0x00000002 238c2ecf20Sopenharmony_ci#define ACPI_EVENTS 0x00000004 248c2ecf20Sopenharmony_ci#define ACPI_TABLES 0x00000008 258c2ecf20Sopenharmony_ci#define ACPI_NAMESPACE 0x00000010 268c2ecf20Sopenharmony_ci#define ACPI_PARSER 0x00000020 278c2ecf20Sopenharmony_ci#define ACPI_DISPATCHER 0x00000040 288c2ecf20Sopenharmony_ci#define ACPI_EXECUTER 0x00000080 298c2ecf20Sopenharmony_ci#define ACPI_RESOURCES 0x00000100 308c2ecf20Sopenharmony_ci#define ACPI_CA_DEBUGGER 0x00000200 318c2ecf20Sopenharmony_ci#define ACPI_OS_SERVICES 0x00000400 328c2ecf20Sopenharmony_ci#define ACPI_CA_DISASSEMBLER 0x00000800 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* Component IDs for ACPI tools and utilities */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define ACPI_COMPILER 0x00001000 378c2ecf20Sopenharmony_ci#define ACPI_TOOLS 0x00002000 388c2ecf20Sopenharmony_ci#define ACPI_EXAMPLE 0x00004000 398c2ecf20Sopenharmony_ci#define ACPI_DRIVER 0x00008000 408c2ecf20Sopenharmony_ci#define DT_COMPILER 0x00010000 418c2ecf20Sopenharmony_ci#define ASL_PREPROCESSOR 0x00020000 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define ACPI_ALL_COMPONENTS 0x0001FFFF 448c2ecf20Sopenharmony_ci#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* Component IDs reserved for ACPI drivers */ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define ACPI_ALL_DRIVERS 0xFFFF0000 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* 518c2ecf20Sopenharmony_ci * Raw debug output levels, do not use these in the ACPI_DEBUG_PRINT macros 528c2ecf20Sopenharmony_ci */ 538c2ecf20Sopenharmony_ci#define ACPI_LV_INIT 0x00000001 548c2ecf20Sopenharmony_ci#define ACPI_LV_DEBUG_OBJECT 0x00000002 558c2ecf20Sopenharmony_ci#define ACPI_LV_INFO 0x00000004 568c2ecf20Sopenharmony_ci#define ACPI_LV_REPAIR 0x00000008 578c2ecf20Sopenharmony_ci#define ACPI_LV_TRACE_POINT 0x00000010 588c2ecf20Sopenharmony_ci#define ACPI_LV_ALL_EXCEPTIONS 0x0000001F 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/* Trace verbosity level 1 [Standard Trace Level] */ 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#define ACPI_LV_INIT_NAMES 0x00000020 638c2ecf20Sopenharmony_ci#define ACPI_LV_PARSE 0x00000040 648c2ecf20Sopenharmony_ci#define ACPI_LV_LOAD 0x00000080 658c2ecf20Sopenharmony_ci#define ACPI_LV_DISPATCH 0x00000100 668c2ecf20Sopenharmony_ci#define ACPI_LV_EXEC 0x00000200 678c2ecf20Sopenharmony_ci#define ACPI_LV_NAMES 0x00000400 688c2ecf20Sopenharmony_ci#define ACPI_LV_OPREGION 0x00000800 698c2ecf20Sopenharmony_ci#define ACPI_LV_BFIELD 0x00001000 708c2ecf20Sopenharmony_ci#define ACPI_LV_TABLES 0x00002000 718c2ecf20Sopenharmony_ci#define ACPI_LV_VALUES 0x00004000 728c2ecf20Sopenharmony_ci#define ACPI_LV_OBJECTS 0x00008000 738c2ecf20Sopenharmony_ci#define ACPI_LV_RESOURCES 0x00010000 748c2ecf20Sopenharmony_ci#define ACPI_LV_USER_REQUESTS 0x00020000 758c2ecf20Sopenharmony_ci#define ACPI_LV_PACKAGE 0x00040000 768c2ecf20Sopenharmony_ci#define ACPI_LV_EVALUATION 0x00080000 778c2ecf20Sopenharmony_ci#define ACPI_LV_VERBOSITY1 0x000FFF40 | ACPI_LV_ALL_EXCEPTIONS 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* Trace verbosity level 2 [Function tracing and memory allocation] */ 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define ACPI_LV_ALLOCATIONS 0x00100000 828c2ecf20Sopenharmony_ci#define ACPI_LV_FUNCTIONS 0x00200000 838c2ecf20Sopenharmony_ci#define ACPI_LV_OPTIMIZATIONS 0x00400000 848c2ecf20Sopenharmony_ci#define ACPI_LV_PARSE_TREES 0x00800000 858c2ecf20Sopenharmony_ci#define ACPI_LV_VERBOSITY2 0x00F00000 | ACPI_LV_VERBOSITY1 868c2ecf20Sopenharmony_ci#define ACPI_LV_ALL ACPI_LV_VERBOSITY2 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* Trace verbosity level 3 [Threading, I/O, and Interrupts] */ 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define ACPI_LV_MUTEX 0x01000000 918c2ecf20Sopenharmony_ci#define ACPI_LV_THREADS 0x02000000 928c2ecf20Sopenharmony_ci#define ACPI_LV_IO 0x04000000 938c2ecf20Sopenharmony_ci#define ACPI_LV_INTERRUPTS 0x08000000 948c2ecf20Sopenharmony_ci#define ACPI_LV_VERBOSITY3 0x0F000000 | ACPI_LV_VERBOSITY2 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci/* Exceptionally verbose output -- also used in the global "DebugLevel" */ 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define ACPI_LV_AML_DISASSEMBLE 0x10000000 998c2ecf20Sopenharmony_ci#define ACPI_LV_VERBOSE_INFO 0x20000000 1008c2ecf20Sopenharmony_ci#define ACPI_LV_FULL_TABLES 0x40000000 1018c2ecf20Sopenharmony_ci#define ACPI_LV_EVENTS 0x80000000 1028c2ecf20Sopenharmony_ci#define ACPI_LV_VERBOSE 0xF0000000 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* 1058c2ecf20Sopenharmony_ci * Debug level macros that are used in the DEBUG_PRINT macros 1068c2ecf20Sopenharmony_ci */ 1078c2ecf20Sopenharmony_ci#define ACPI_DEBUG_LEVEL(dl) (u32) dl,ACPI_DEBUG_PARAMETERS 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* 1108c2ecf20Sopenharmony_ci * Exception level -- used in the global "DebugLevel" 1118c2ecf20Sopenharmony_ci * 1128c2ecf20Sopenharmony_ci * Note: For errors, use the ACPI_ERROR or ACPI_EXCEPTION interfaces. 1138c2ecf20Sopenharmony_ci * For warnings, use ACPI_WARNING. 1148c2ecf20Sopenharmony_ci */ 1158c2ecf20Sopenharmony_ci#define ACPI_DB_INIT ACPI_DEBUG_LEVEL (ACPI_LV_INIT) 1168c2ecf20Sopenharmony_ci#define ACPI_DB_DEBUG_OBJECT ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT) 1178c2ecf20Sopenharmony_ci#define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO) 1188c2ecf20Sopenharmony_ci#define ACPI_DB_REPAIR ACPI_DEBUG_LEVEL (ACPI_LV_REPAIR) 1198c2ecf20Sopenharmony_ci#define ACPI_DB_TRACE_POINT ACPI_DEBUG_LEVEL (ACPI_LV_TRACE_POINT) 1208c2ecf20Sopenharmony_ci#define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS) 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci/* Trace level -- also used in the global "DebugLevel" */ 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci#define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES) 1258c2ecf20Sopenharmony_ci#define ACPI_DB_THREADS ACPI_DEBUG_LEVEL (ACPI_LV_THREADS) 1268c2ecf20Sopenharmony_ci#define ACPI_DB_PARSE ACPI_DEBUG_LEVEL (ACPI_LV_PARSE) 1278c2ecf20Sopenharmony_ci#define ACPI_DB_DISPATCH ACPI_DEBUG_LEVEL (ACPI_LV_DISPATCH) 1288c2ecf20Sopenharmony_ci#define ACPI_DB_LOAD ACPI_DEBUG_LEVEL (ACPI_LV_LOAD) 1298c2ecf20Sopenharmony_ci#define ACPI_DB_EXEC ACPI_DEBUG_LEVEL (ACPI_LV_EXEC) 1308c2ecf20Sopenharmony_ci#define ACPI_DB_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_NAMES) 1318c2ecf20Sopenharmony_ci#define ACPI_DB_OPREGION ACPI_DEBUG_LEVEL (ACPI_LV_OPREGION) 1328c2ecf20Sopenharmony_ci#define ACPI_DB_BFIELD ACPI_DEBUG_LEVEL (ACPI_LV_BFIELD) 1338c2ecf20Sopenharmony_ci#define ACPI_DB_TABLES ACPI_DEBUG_LEVEL (ACPI_LV_TABLES) 1348c2ecf20Sopenharmony_ci#define ACPI_DB_FUNCTIONS ACPI_DEBUG_LEVEL (ACPI_LV_FUNCTIONS) 1358c2ecf20Sopenharmony_ci#define ACPI_DB_OPTIMIZATIONS ACPI_DEBUG_LEVEL (ACPI_LV_OPTIMIZATIONS) 1368c2ecf20Sopenharmony_ci#define ACPI_DB_PARSE_TREES ACPI_DEBUG_LEVEL (ACPI_LV_PARSE_TREES) 1378c2ecf20Sopenharmony_ci#define ACPI_DB_VALUES ACPI_DEBUG_LEVEL (ACPI_LV_VALUES) 1388c2ecf20Sopenharmony_ci#define ACPI_DB_OBJECTS ACPI_DEBUG_LEVEL (ACPI_LV_OBJECTS) 1398c2ecf20Sopenharmony_ci#define ACPI_DB_ALLOCATIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALLOCATIONS) 1408c2ecf20Sopenharmony_ci#define ACPI_DB_RESOURCES ACPI_DEBUG_LEVEL (ACPI_LV_RESOURCES) 1418c2ecf20Sopenharmony_ci#define ACPI_DB_IO ACPI_DEBUG_LEVEL (ACPI_LV_IO) 1428c2ecf20Sopenharmony_ci#define ACPI_DB_INTERRUPTS ACPI_DEBUG_LEVEL (ACPI_LV_INTERRUPTS) 1438c2ecf20Sopenharmony_ci#define ACPI_DB_USER_REQUESTS ACPI_DEBUG_LEVEL (ACPI_LV_USER_REQUESTS) 1448c2ecf20Sopenharmony_ci#define ACPI_DB_PACKAGE ACPI_DEBUG_LEVEL (ACPI_LV_PACKAGE) 1458c2ecf20Sopenharmony_ci#define ACPI_DB_EVALUATION ACPI_DEBUG_LEVEL (ACPI_LV_EVALUATION) 1468c2ecf20Sopenharmony_ci#define ACPI_DB_MUTEX ACPI_DEBUG_LEVEL (ACPI_LV_MUTEX) 1478c2ecf20Sopenharmony_ci#define ACPI_DB_EVENTS ACPI_DEBUG_LEVEL (ACPI_LV_EVENTS) 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci#define ACPI_DB_ALL ACPI_DEBUG_LEVEL (ACPI_LV_ALL) 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci/* Defaults for debug_level, debug and normal */ 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci#ifndef ACPI_DEBUG_DEFAULT 1548c2ecf20Sopenharmony_ci#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_EVALUATION | ACPI_LV_REPAIR) 1558c2ecf20Sopenharmony_ci#endif 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR) 1588c2ecf20Sopenharmony_ci#define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci/* 1618c2ecf20Sopenharmony_ci * Global trace flags 1628c2ecf20Sopenharmony_ci */ 1638c2ecf20Sopenharmony_ci#define ACPI_TRACE_ENABLED ((u32) 4) 1648c2ecf20Sopenharmony_ci#define ACPI_TRACE_ONESHOT ((u32) 2) 1658c2ecf20Sopenharmony_ci#define ACPI_TRACE_OPCODE ((u32) 1) 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci/* Defaults for trace debugging level/layer */ 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci#define ACPI_TRACE_LEVEL_ALL ACPI_LV_ALL 1708c2ecf20Sopenharmony_ci#define ACPI_TRACE_LAYER_ALL 0x000001FF 1718c2ecf20Sopenharmony_ci#define ACPI_TRACE_LEVEL_DEFAULT ACPI_LV_TRACE_POINT 1728c2ecf20Sopenharmony_ci#define ACPI_TRACE_LAYER_DEFAULT ACPI_EXECUTER 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) 1758c2ecf20Sopenharmony_ci/* 1768c2ecf20Sopenharmony_ci * The module name is used primarily for error and debug messages. 1778c2ecf20Sopenharmony_ci * The __FILE__ macro is not very useful for this, because it 1788c2ecf20Sopenharmony_ci * usually includes the entire pathname to the module making the 1798c2ecf20Sopenharmony_ci * debug output difficult to read. 1808c2ecf20Sopenharmony_ci */ 1818c2ecf20Sopenharmony_ci#define ACPI_MODULE_NAME(name) static const char ACPI_UNUSED_VAR _acpi_module_name[] = name; 1828c2ecf20Sopenharmony_ci#else 1838c2ecf20Sopenharmony_ci/* 1848c2ecf20Sopenharmony_ci * For the no-debug and no-error-msg cases, we must at least define 1858c2ecf20Sopenharmony_ci * a null module name. 1868c2ecf20Sopenharmony_ci */ 1878c2ecf20Sopenharmony_ci#define ACPI_MODULE_NAME(name) 1888c2ecf20Sopenharmony_ci#define _acpi_module_name "" 1898c2ecf20Sopenharmony_ci#endif 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci/* 1928c2ecf20Sopenharmony_ci * Ascii error messages can be configured out 1938c2ecf20Sopenharmony_ci */ 1948c2ecf20Sopenharmony_ci#ifndef ACPI_NO_ERROR_MESSAGES 1958c2ecf20Sopenharmony_ci#define AE_INFO _acpi_module_name, __LINE__ 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci/* 1988c2ecf20Sopenharmony_ci * Error reporting. Callers module and line number are inserted by AE_INFO, 1998c2ecf20Sopenharmony_ci * the plist contains a set of parens to allow variable-length lists. 2008c2ecf20Sopenharmony_ci * These macros are used for both the debug and non-debug versions of the code. 2018c2ecf20Sopenharmony_ci */ 2028c2ecf20Sopenharmony_ci#define ACPI_INFO(plist) acpi_info plist 2038c2ecf20Sopenharmony_ci#define ACPI_WARNING(plist) acpi_warning plist 2048c2ecf20Sopenharmony_ci#define ACPI_EXCEPTION(plist) acpi_exception plist 2058c2ecf20Sopenharmony_ci#define ACPI_ERROR(plist) acpi_error plist 2068c2ecf20Sopenharmony_ci#define ACPI_BIOS_WARNING(plist) acpi_bios_warning plist 2078c2ecf20Sopenharmony_ci#define ACPI_BIOS_EXCEPTION(plist) acpi_bios_exception plist 2088c2ecf20Sopenharmony_ci#define ACPI_BIOS_ERROR(plist) acpi_bios_error plist 2098c2ecf20Sopenharmony_ci#define ACPI_DEBUG_OBJECT(obj,l,i) acpi_ex_do_debug_object(obj,l,i) 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci#else 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci/* No error messages */ 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci#define ACPI_INFO(plist) 2168c2ecf20Sopenharmony_ci#define ACPI_WARNING(plist) 2178c2ecf20Sopenharmony_ci#define ACPI_EXCEPTION(plist) 2188c2ecf20Sopenharmony_ci#define ACPI_ERROR(plist) 2198c2ecf20Sopenharmony_ci#define ACPI_BIOS_WARNING(plist) 2208c2ecf20Sopenharmony_ci#define ACPI_BIOS_EXCEPTION(plist) 2218c2ecf20Sopenharmony_ci#define ACPI_BIOS_ERROR(plist) 2228c2ecf20Sopenharmony_ci#define ACPI_DEBUG_OBJECT(obj,l,i) 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci#endif /* ACPI_NO_ERROR_MESSAGES */ 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci/* 2278c2ecf20Sopenharmony_ci * Debug macros that are conditionally compiled 2288c2ecf20Sopenharmony_ci */ 2298c2ecf20Sopenharmony_ci#ifdef ACPI_DEBUG_OUTPUT 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci/* 2328c2ecf20Sopenharmony_ci * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header, 2338c2ecf20Sopenharmony_ci * define it now. This is the case where there the compiler does not support 2348c2ecf20Sopenharmony_ci * a __func__ macro or equivalent. 2358c2ecf20Sopenharmony_ci */ 2368c2ecf20Sopenharmony_ci#ifndef ACPI_GET_FUNCTION_NAME 2378c2ecf20Sopenharmony_ci#define ACPI_GET_FUNCTION_NAME _acpi_function_name 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci/* 2408c2ecf20Sopenharmony_ci * The Name parameter should be the procedure name as a non-quoted string. 2418c2ecf20Sopenharmony_ci * The function name is also used by the function exit macros below. 2428c2ecf20Sopenharmony_ci * Note: (const char) is used to be compatible with the debug interfaces 2438c2ecf20Sopenharmony_ci * and macros such as __func__. 2448c2ecf20Sopenharmony_ci */ 2458c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_NAME(name) static const char _acpi_function_name[] = #name; 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci#else 2488c2ecf20Sopenharmony_ci/* Compiler supports __func__ (or equivalent) -- Ignore this macro */ 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_NAME(name) 2518c2ecf20Sopenharmony_ci#endif /* ACPI_GET_FUNCTION_NAME */ 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci/* 2548c2ecf20Sopenharmony_ci * Common parameters used for debug output functions: 2558c2ecf20Sopenharmony_ci * line number, function name, module(file) name, component ID 2568c2ecf20Sopenharmony_ci */ 2578c2ecf20Sopenharmony_ci#define ACPI_DEBUG_PARAMETERS \ 2588c2ecf20Sopenharmony_ci __LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci/* Check if debug output is currently dynamically enabled */ 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci#define ACPI_IS_DEBUG_ENABLED(level, component) \ 2638c2ecf20Sopenharmony_ci ((level & acpi_dbg_level) && (component & acpi_dbg_layer)) 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci/* 2668c2ecf20Sopenharmony_ci * Master debug print macros 2678c2ecf20Sopenharmony_ci * Print message if and only if: 2688c2ecf20Sopenharmony_ci * 1) Debug print for the current component is enabled 2698c2ecf20Sopenharmony_ci * 2) Debug error level or trace level for the print statement is enabled 2708c2ecf20Sopenharmony_ci * 2718c2ecf20Sopenharmony_ci * November 2012: Moved the runtime check for whether to actually emit the 2728c2ecf20Sopenharmony_ci * debug message outside of the print function itself. This improves overall 2738c2ecf20Sopenharmony_ci * performance at a relatively small code cost. Implementation involves the 2748c2ecf20Sopenharmony_ci * use of variadic macros supported by C99. 2758c2ecf20Sopenharmony_ci * 2768c2ecf20Sopenharmony_ci * Note: the ACPI_DO_WHILE0 macro is used to prevent some compilers from 2778c2ecf20Sopenharmony_ci * complaining about these constructs. On other compilers the do...while 2788c2ecf20Sopenharmony_ci * adds some extra code, so this feature is optional. 2798c2ecf20Sopenharmony_ci */ 2808c2ecf20Sopenharmony_ci#ifdef ACPI_USE_DO_WHILE_0 2818c2ecf20Sopenharmony_ci#define ACPI_DO_WHILE0(a) do a while(0) 2828c2ecf20Sopenharmony_ci#else 2838c2ecf20Sopenharmony_ci#define ACPI_DO_WHILE0(a) a 2848c2ecf20Sopenharmony_ci#endif 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci/* DEBUG_PRINT functions */ 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci#ifndef COMPILER_VA_MACRO 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci#define ACPI_DEBUG_PRINT(plist) acpi_debug_print plist 2918c2ecf20Sopenharmony_ci#define ACPI_DEBUG_PRINT_RAW(plist) acpi_debug_print_raw plist 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci#else 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci/* Helper macros for DEBUG_PRINT */ 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci#define ACPI_DO_DEBUG_PRINT(function, level, line, filename, modulename, component, ...) \ 2988c2ecf20Sopenharmony_ci ACPI_DO_WHILE0 ({ \ 2998c2ecf20Sopenharmony_ci if (ACPI_IS_DEBUG_ENABLED (level, component)) \ 3008c2ecf20Sopenharmony_ci { \ 3018c2ecf20Sopenharmony_ci function (level, line, filename, modulename, component, __VA_ARGS__); \ 3028c2ecf20Sopenharmony_ci } \ 3038c2ecf20Sopenharmony_ci }) 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci#define ACPI_ACTUAL_DEBUG(level, line, filename, modulename, component, ...) \ 3068c2ecf20Sopenharmony_ci ACPI_DO_DEBUG_PRINT (acpi_debug_print, level, line, \ 3078c2ecf20Sopenharmony_ci filename, modulename, component, __VA_ARGS__) 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci#define ACPI_ACTUAL_DEBUG_RAW(level, line, filename, modulename, component, ...) \ 3108c2ecf20Sopenharmony_ci ACPI_DO_DEBUG_PRINT (acpi_debug_print_raw, level, line, \ 3118c2ecf20Sopenharmony_ci filename, modulename, component, __VA_ARGS__) 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci#define ACPI_DEBUG_PRINT(plist) ACPI_ACTUAL_DEBUG plist 3148c2ecf20Sopenharmony_ci#define ACPI_DEBUG_PRINT_RAW(plist) ACPI_ACTUAL_DEBUG_RAW plist 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci#endif 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci/* 3198c2ecf20Sopenharmony_ci * Function entry tracing 3208c2ecf20Sopenharmony_ci * 3218c2ecf20Sopenharmony_ci * The name of the function is emitted as a local variable that is 3228c2ecf20Sopenharmony_ci * intended to be used by both the entry trace and the exit trace. 3238c2ecf20Sopenharmony_ci */ 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci/* Helper macro */ 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci#define ACPI_TRACE_ENTRY(name, function, type, param) \ 3288c2ecf20Sopenharmony_ci ACPI_FUNCTION_NAME (name) \ 3298c2ecf20Sopenharmony_ci function (ACPI_DEBUG_PARAMETERS, (type) (param)) 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci/* The actual entry trace macros */ 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_TRACE(name) \ 3348c2ecf20Sopenharmony_ci ACPI_FUNCTION_NAME(name) \ 3358c2ecf20Sopenharmony_ci acpi_ut_trace (ACPI_DEBUG_PARAMETERS) 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_TRACE_PTR(name, pointer) \ 3388c2ecf20Sopenharmony_ci ACPI_TRACE_ENTRY (name, acpi_ut_trace_ptr, void *, pointer) 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_TRACE_U32(name, value) \ 3418c2ecf20Sopenharmony_ci ACPI_TRACE_ENTRY (name, acpi_ut_trace_u32, u32, value) 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_TRACE_STR(name, string) \ 3448c2ecf20Sopenharmony_ci ACPI_TRACE_ENTRY (name, acpi_ut_trace_str, const char *, string) 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_ENTRY() \ 3478c2ecf20Sopenharmony_ci acpi_ut_track_stack_ptr() 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci/* 3508c2ecf20Sopenharmony_ci * Function exit tracing 3518c2ecf20Sopenharmony_ci * 3528c2ecf20Sopenharmony_ci * These macros include a return statement. This is usually considered 3538c2ecf20Sopenharmony_ci * bad form, but having a separate exit macro before the actual return 3548c2ecf20Sopenharmony_ci * is very ugly and difficult to maintain. 3558c2ecf20Sopenharmony_ci * 3568c2ecf20Sopenharmony_ci * One of the FUNCTION_TRACE macros above must be used in conjunction 3578c2ecf20Sopenharmony_ci * with these macros so that "_AcpiFunctionName" is defined. 3588c2ecf20Sopenharmony_ci * 3598c2ecf20Sopenharmony_ci * There are two versions of most of the return macros. The default version is 3608c2ecf20Sopenharmony_ci * safer, since it avoids side-effects by guaranteeing that the argument will 3618c2ecf20Sopenharmony_ci * not be evaluated twice. 3628c2ecf20Sopenharmony_ci * 3638c2ecf20Sopenharmony_ci * A less-safe version of the macros is provided for optional use if the 3648c2ecf20Sopenharmony_ci * compiler uses excessive CPU stack (for example, this may happen in the 3658c2ecf20Sopenharmony_ci * debug case if code optimzation is disabled.) 3668c2ecf20Sopenharmony_ci */ 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci/* Exit trace helper macro */ 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci#ifndef ACPI_SIMPLE_RETURN_MACROS 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci#define ACPI_TRACE_EXIT(function, type, param) \ 3738c2ecf20Sopenharmony_ci ACPI_DO_WHILE0 ({ \ 3748c2ecf20Sopenharmony_ci register type _param = (type) (param); \ 3758c2ecf20Sopenharmony_ci function (ACPI_DEBUG_PARAMETERS, _param); \ 3768c2ecf20Sopenharmony_ci return (_param); \ 3778c2ecf20Sopenharmony_ci }) 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci#else /* Use original less-safe macros */ 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci#define ACPI_TRACE_EXIT(function, type, param) \ 3828c2ecf20Sopenharmony_ci ACPI_DO_WHILE0 ({ \ 3838c2ecf20Sopenharmony_ci function (ACPI_DEBUG_PARAMETERS, (type) (param)); \ 3848c2ecf20Sopenharmony_ci return (param); \ 3858c2ecf20Sopenharmony_ci }) 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ci#endif /* ACPI_SIMPLE_RETURN_MACROS */ 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci/* The actual exit macros */ 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci#define return_VOID \ 3928c2ecf20Sopenharmony_ci ACPI_DO_WHILE0 ({ \ 3938c2ecf20Sopenharmony_ci acpi_ut_exit (ACPI_DEBUG_PARAMETERS); \ 3948c2ecf20Sopenharmony_ci return; \ 3958c2ecf20Sopenharmony_ci }) 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci#define return_ACPI_STATUS(status) \ 3988c2ecf20Sopenharmony_ci ACPI_TRACE_EXIT (acpi_ut_status_exit, acpi_status, status) 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci#define return_PTR(pointer) \ 4018c2ecf20Sopenharmony_ci ACPI_TRACE_EXIT (acpi_ut_ptr_exit, void *, pointer) 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_ci#define return_STR(string) \ 4048c2ecf20Sopenharmony_ci ACPI_TRACE_EXIT (acpi_ut_str_exit, const char *, string) 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci#define return_VALUE(value) \ 4078c2ecf20Sopenharmony_ci ACPI_TRACE_EXIT (acpi_ut_value_exit, u64, value) 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci#define return_UINT32(value) \ 4108c2ecf20Sopenharmony_ci ACPI_TRACE_EXIT (acpi_ut_value_exit, u32, value) 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci#define return_UINT8(value) \ 4138c2ecf20Sopenharmony_ci ACPI_TRACE_EXIT (acpi_ut_value_exit, u8, value) 4148c2ecf20Sopenharmony_ci 4158c2ecf20Sopenharmony_ci/* Conditional execution */ 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci#define ACPI_DEBUG_EXEC(a) a 4188c2ecf20Sopenharmony_ci#define ACPI_DEBUG_ONLY_MEMBERS(a) a; 4198c2ecf20Sopenharmony_ci#define _VERBOSE_STRUCTURES 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ci/* Various object display routines for debug */ 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ci#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0) 4248c2ecf20Sopenharmony_ci#define ACPI_DUMP_OPERANDS(a, b ,c) acpi_ex_dump_operands(a, b, c) 4258c2ecf20Sopenharmony_ci#define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b) 4268c2ecf20Sopenharmony_ci#define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d) 4278c2ecf20Sopenharmony_ci#define ACPI_DUMP_BUFFER(a, b) acpi_ut_debug_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci#define ACPI_TRACE_POINT(a, b, c, d) acpi_trace_point (a, b, c, d) 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ci#else /* ACPI_DEBUG_OUTPUT */ 4328c2ecf20Sopenharmony_ci/* 4338c2ecf20Sopenharmony_ci * This is the non-debug case -- make everything go away, 4348c2ecf20Sopenharmony_ci * leaving no executable debug code! 4358c2ecf20Sopenharmony_ci */ 4368c2ecf20Sopenharmony_ci#define ACPI_DEBUG_PRINT(pl) 4378c2ecf20Sopenharmony_ci#define ACPI_DEBUG_PRINT_RAW(pl) 4388c2ecf20Sopenharmony_ci#define ACPI_DEBUG_EXEC(a) 4398c2ecf20Sopenharmony_ci#define ACPI_DEBUG_ONLY_MEMBERS(a) 4408c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_NAME(a) 4418c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_TRACE(a) 4428c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_TRACE_PTR(a, b) 4438c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_TRACE_U32(a, b) 4448c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_TRACE_STR(a, b) 4458c2ecf20Sopenharmony_ci#define ACPI_FUNCTION_ENTRY() 4468c2ecf20Sopenharmony_ci#define ACPI_DUMP_STACK_ENTRY(a) 4478c2ecf20Sopenharmony_ci#define ACPI_DUMP_OPERANDS(a, b, c) 4488c2ecf20Sopenharmony_ci#define ACPI_DUMP_ENTRY(a, b) 4498c2ecf20Sopenharmony_ci#define ACPI_DUMP_PATHNAME(a, b, c, d) 4508c2ecf20Sopenharmony_ci#define ACPI_DUMP_BUFFER(a, b) 4518c2ecf20Sopenharmony_ci#define ACPI_IS_DEBUG_ENABLED(level, component) 0 4528c2ecf20Sopenharmony_ci#define ACPI_TRACE_POINT(a, b, c, d) 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci/* Return macros must have a return statement at the minimum */ 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_ci#define return_VOID return 4578c2ecf20Sopenharmony_ci#define return_ACPI_STATUS(s) return(s) 4588c2ecf20Sopenharmony_ci#define return_PTR(s) return(s) 4598c2ecf20Sopenharmony_ci#define return_STR(s) return(s) 4608c2ecf20Sopenharmony_ci#define return_VALUE(s) return(s) 4618c2ecf20Sopenharmony_ci#define return_UINT8(s) return(s) 4628c2ecf20Sopenharmony_ci#define return_UINT32(s) return(s) 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci#endif /* ACPI_DEBUG_OUTPUT */ 4658c2ecf20Sopenharmony_ci 4668c2ecf20Sopenharmony_ci#endif /* __ACOUTPUT_H__ */ 467