linux/include/acpi/acoutput.h

/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
/******************************************************************************
 *
 * Name: acoutput.h -- debug output
 *
 * Copyright (C) 2000 - 2023, Intel Corp.
 *
 *****************************************************************************/

#ifndef __ACOUTPUT_H__
#define __ACOUTPUT_H__

/*
 * Debug levels and component IDs. These are used to control the
 * granularity of the output of the ACPI_DEBUG_PRINT macro -- on a
 * per-component basis and a per-exception-type basis.
 */

/* Component IDs are used in the global "DebugLayer" */

#define ACPI_UTILITIES
#define ACPI_HARDWARE
#define ACPI_EVENTS
#define ACPI_TABLES
#define ACPI_NAMESPACE
#define ACPI_PARSER
#define ACPI_DISPATCHER
#define ACPI_EXECUTER
#define ACPI_RESOURCES
#define ACPI_CA_DEBUGGER
#define ACPI_OS_SERVICES
#define ACPI_CA_DISASSEMBLER

/* Component IDs for ACPI tools and utilities */

#define ACPI_COMPILER
#define ACPI_TOOLS
#define ACPI_EXAMPLE
#define ACPI_DRIVER
#define DT_COMPILER
#define ASL_PREPROCESSOR

#define ACPI_ALL_COMPONENTS
#define ACPI_COMPONENT_DEFAULT

/* Component IDs reserved for ACPI drivers */

#define ACPI_ALL_DRIVERS

/*
 * Raw debug output levels, do not use these in the ACPI_DEBUG_PRINT macros
 */
#define ACPI_LV_INIT
#define ACPI_LV_DEBUG_OBJECT
#define ACPI_LV_INFO
#define ACPI_LV_REPAIR
#define ACPI_LV_TRACE_POINT
#define ACPI_LV_ALL_EXCEPTIONS

/* Trace verbosity level 1 [Standard Trace Level] */

#define ACPI_LV_INIT_NAMES
#define ACPI_LV_PARSE
#define ACPI_LV_LOAD
#define ACPI_LV_DISPATCH
#define ACPI_LV_EXEC
#define ACPI_LV_NAMES
#define ACPI_LV_OPREGION
#define ACPI_LV_BFIELD
#define ACPI_LV_TABLES
#define ACPI_LV_VALUES
#define ACPI_LV_OBJECTS
#define ACPI_LV_RESOURCES
#define ACPI_LV_USER_REQUESTS
#define ACPI_LV_PACKAGE
#define ACPI_LV_EVALUATION
#define ACPI_LV_VERBOSITY1

/* Trace verbosity level 2 [Function tracing and memory allocation] */

#define ACPI_LV_ALLOCATIONS
#define ACPI_LV_FUNCTIONS
#define ACPI_LV_OPTIMIZATIONS
#define ACPI_LV_PARSE_TREES
#define ACPI_LV_VERBOSITY2
#define ACPI_LV_ALL

/* Trace verbosity level 3 [Threading, I/O, and Interrupts] */

#define ACPI_LV_MUTEX
#define ACPI_LV_THREADS
#define ACPI_LV_IO
#define ACPI_LV_INTERRUPTS
#define ACPI_LV_VERBOSITY3

/* Exceptionally verbose output -- also used in the global "DebugLevel"  */

#define ACPI_LV_AML_DISASSEMBLE
#define ACPI_LV_VERBOSE_INFO
#define ACPI_LV_FULL_TABLES
#define ACPI_LV_EVENTS
#define ACPI_LV_VERBOSE

/*
 * Debug level macros that are used in the DEBUG_PRINT macros
 */
#define ACPI_DEBUG_LEVEL(dl)

/*
 * Exception level -- used in the global "DebugLevel"
 *
 * Note: For errors, use the ACPI_ERROR or ACPI_EXCEPTION interfaces.
 * For warnings, use ACPI_WARNING.
 */
#define ACPI_DB_INIT
#define ACPI_DB_DEBUG_OBJECT
#define ACPI_DB_INFO
#define ACPI_DB_REPAIR
#define ACPI_DB_TRACE_POINT
#define ACPI_DB_ALL_EXCEPTIONS

/* Trace level -- also used in the global "DebugLevel" */

#define ACPI_DB_INIT_NAMES
#define ACPI_DB_THREADS
#define ACPI_DB_PARSE
#define ACPI_DB_DISPATCH
#define ACPI_DB_LOAD
#define ACPI_DB_EXEC
#define ACPI_DB_NAMES
#define ACPI_DB_OPREGION
#define ACPI_DB_BFIELD
#define ACPI_DB_TABLES
#define ACPI_DB_FUNCTIONS
#define ACPI_DB_OPTIMIZATIONS
#define ACPI_DB_PARSE_TREES
#define ACPI_DB_VALUES
#define ACPI_DB_OBJECTS
#define ACPI_DB_ALLOCATIONS
#define ACPI_DB_RESOURCES
#define ACPI_DB_IO
#define ACPI_DB_INTERRUPTS
#define ACPI_DB_USER_REQUESTS
#define ACPI_DB_PACKAGE
#define ACPI_DB_EVALUATION
#define ACPI_DB_MUTEX
#define ACPI_DB_EVENTS

#define ACPI_DB_ALL

/* Defaults for debug_level, debug and normal */

#ifndef ACPI_DEBUG_DEFAULT
#define ACPI_DEBUG_DEFAULT
#endif

#define ACPI_NORMAL_DEFAULT
#define ACPI_DEBUG_ALL

/*
 * Global trace flags
 */
#define ACPI_TRACE_ENABLED
#define ACPI_TRACE_ONESHOT
#define ACPI_TRACE_OPCODE

/* Defaults for trace debugging level/layer */

#define ACPI_TRACE_LEVEL_ALL
#define ACPI_TRACE_LAYER_ALL
#define ACPI_TRACE_LEVEL_DEFAULT
#define ACPI_TRACE_LAYER_DEFAULT

#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES)
/*
 * The module name is used primarily for error and debug messages.
 * The __FILE__ macro is not very useful for this, because it
 * usually includes the entire pathname to the module making the
 * debug output difficult to read.
 */
#define ACPI_MODULE_NAME(name)
#else
/*
 * For the no-debug and no-error-msg cases, we must at least define
 * a null module name.
 */
#define ACPI_MODULE_NAME
#define _acpi_module_name
#endif

/*
 * Ascii error messages can be configured out
 */
#ifndef ACPI_NO_ERROR_MESSAGES
#define AE_INFO

/*
 * Error reporting. Callers module and line number are inserted by AE_INFO,
 * the plist contains a set of parens to allow variable-length lists.
 * These macros are used for both the debug and non-debug versions of the code.
 */
#define ACPI_INFO(plist)
#define ACPI_WARNING(plist)
#define ACPI_EXCEPTION(plist)
#define ACPI_ERROR(plist)
#define ACPI_BIOS_WARNING(plist)
#define ACPI_BIOS_EXCEPTION(plist)
#define ACPI_BIOS_ERROR(plist)
#define ACPI_DEBUG_OBJECT(obj,l,i)

#else

/* No error messages */

#define ACPI_INFO
#define ACPI_WARNING
#define ACPI_EXCEPTION
#define ACPI_ERROR
#define ACPI_BIOS_WARNING
#define ACPI_BIOS_EXCEPTION
#define ACPI_BIOS_ERROR
#define ACPI_DEBUG_OBJECT

#endif				/* ACPI_NO_ERROR_MESSAGES */

/*
 * Debug macros that are conditionally compiled
 */
#ifdef ACPI_DEBUG_OUTPUT

/*
 * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header,
 * define it now. This is the case where there the compiler does not support
 * a __func__ macro or equivalent.
 */
#ifndef ACPI_GET_FUNCTION_NAME
#define ACPI_GET_FUNCTION_NAME

/*
 * The Name parameter should be the procedure name as a non-quoted string.
 * The function name is also used by the function exit macros below.
 * Note: (const char) is used to be compatible with the debug interfaces
 * and macros such as __func__.
 */
#define ACPI_FUNCTION_NAME

#else
/* Compiler supports __func__ (or equivalent) -- Ignore this macro */

#define ACPI_FUNCTION_NAME
#endif				/* ACPI_GET_FUNCTION_NAME */

/*
 * Common parameters used for debug output functions:
 * line number, function name, module(file) name, component ID
 */
#define ACPI_DEBUG_PARAMETERS

/* Check if debug output is currently dynamically enabled */

#define ACPI_IS_DEBUG_ENABLED

/*
 * Master debug print macros
 * Print message if and only if:
 *    1) Debug print for the current component is enabled
 *    2) Debug error level or trace level for the print statement is enabled
 *
 * November 2012: Moved the runtime check for whether to actually emit the
 * debug message outside of the print function itself. This improves overall
 * performance at a relatively small code cost. Implementation involves the
 * use of variadic macros supported by C99.
 *
 * Note: the ACPI_DO_WHILE0 macro is used to prevent some compilers from
 * complaining about these constructs. On other compilers the do...while
 * adds some extra code, so this feature is optional.
 */
#ifdef ACPI_USE_DO_WHILE_0
#define ACPI_DO_WHILE0
#else
#define ACPI_DO_WHILE0
#endif

/* DEBUG_PRINT functions */

#ifndef COMPILER_VA_MACRO

#define ACPI_DEBUG_PRINT
#define ACPI_DEBUG_PRINT_RAW

#else

/* Helper macros for DEBUG_PRINT */

#define ACPI_DO_DEBUG_PRINT

#define ACPI_ACTUAL_DEBUG

#define ACPI_ACTUAL_DEBUG_RAW

#define ACPI_DEBUG_PRINT
#define ACPI_DEBUG_PRINT_RAW

#endif

/*
 * Function entry tracing
 *
 * The name of the function is emitted as a local variable that is
 * intended to be used by both the entry trace and the exit trace.
 */

/* Helper macro */

#define ACPI_TRACE_ENTRY

/* The actual entry trace macros */

#define ACPI_FUNCTION_TRACE

#define ACPI_FUNCTION_TRACE_PTR

#define ACPI_FUNCTION_TRACE_U32

#define ACPI_FUNCTION_TRACE_STR

#define ACPI_FUNCTION_ENTRY

/*
 * Function exit tracing
 *
 * These macros include a return statement. This is usually considered
 * bad form, but having a separate exit macro before the actual return
 * is very ugly and difficult to maintain.
 *
 * One of the FUNCTION_TRACE macros above must be used in conjunction
 * with these macros so that "_AcpiFunctionName" is defined.
 *
 * There are two versions of most of the return macros. The default version is
 * safer, since it avoids side-effects by guaranteeing that the argument will
 * not be evaluated twice.
 *
 * A less-safe version of the macros is provided for optional use if the
 * compiler uses excessive CPU stack (for example, this may happen in the
 * debug case if code optimization is disabled.)
 */

/* Exit trace helper macro */

#ifndef ACPI_SIMPLE_RETURN_MACROS

#define ACPI_TRACE_EXIT

#else				/* Use original less-safe macros */

#define ACPI_TRACE_EXIT

#endif				/* ACPI_SIMPLE_RETURN_MACROS */

/* The actual exit macros */

#define return_VOID

#define return_ACPI_STATUS

#define return_PTR

#define return_STR

#define return_VALUE

#define return_UINT32

#define return_UINT8

/* Conditional execution */

#define ACPI_DEBUG_EXEC
#define ACPI_DEBUG_ONLY_MEMBERS
#define _VERBOSE_STRUCTURES

/* Various object display routines for debug */

#define ACPI_DUMP_STACK_ENTRY
#define ACPI_DUMP_OPERANDS
#define ACPI_DUMP_ENTRY
#define ACPI_DUMP_PATHNAME
#define ACPI_DUMP_BUFFER

#define ACPI_TRACE_POINT

#else				/* ACPI_DEBUG_OUTPUT */
/*
 * This is the non-debug case -- make everything go away,
 * leaving no executable debug code!
 */
#define ACPI_DEBUG_PRINT(pl)
#define ACPI_DEBUG_PRINT_RAW(pl)
#define ACPI_DEBUG_EXEC(a)
#define ACPI_DEBUG_ONLY_MEMBERS(a)
#define ACPI_FUNCTION_NAME(a)
#define ACPI_FUNCTION_TRACE(a)
#define ACPI_FUNCTION_TRACE_PTR(a, b)
#define ACPI_FUNCTION_TRACE_U32(a, b)
#define ACPI_FUNCTION_TRACE_STR(a, b)
#define ACPI_FUNCTION_ENTRY()
#define ACPI_DUMP_STACK_ENTRY(a)
#define ACPI_DUMP_OPERANDS(a, b, c)
#define ACPI_DUMP_ENTRY(a, b)
#define ACPI_DUMP_PATHNAME(a, b, c, d)
#define ACPI_DUMP_BUFFER(a, b)
#define ACPI_IS_DEBUG_ENABLED(level, component)
#define ACPI_TRACE_POINT(a, b, c, d)

/* Return macros must have a return statement at the minimum */

#define return_VOID
#define return_ACPI_STATUS(s)
#define return_PTR(s)
#define return_STR(s)
#define return_VALUE(s)
#define return_UINT8(s)
#define return_UINT32(s)

#endif				/* ACPI_DEBUG_OUTPUT */

#endif				/* __ACOUTPUT_H__ */