acoutput.h revision 233250
167754Smsmith/******************************************************************************
267754Smsmith *
367754Smsmith * Name: acoutput.h -- debug output
467754Smsmith *
567754Smsmith *****************************************************************************/
667754Smsmith
7217365Sjkim/*
8229989Sjkim * Copyright (C) 2000 - 2012, Intel Corp.
970243Smsmith * All rights reserved.
1067754Smsmith *
11217365Sjkim * Redistribution and use in source and binary forms, with or without
12217365Sjkim * modification, are permitted provided that the following conditions
13217365Sjkim * are met:
14217365Sjkim * 1. Redistributions of source code must retain the above copyright
15217365Sjkim *    notice, this list of conditions, and the following disclaimer,
16217365Sjkim *    without modification.
17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18217365Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
19217365Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
20217365Sjkim *    including a substantially similar Disclaimer requirement for further
21217365Sjkim *    binary redistribution.
22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
23217365Sjkim *    of any contributors may be used to endorse or promote products derived
24217365Sjkim *    from this software without specific prior written permission.
2567754Smsmith *
26217365Sjkim * Alternatively, this software may be distributed under the terms of the
27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
28217365Sjkim * Software Foundation.
2967754Smsmith *
30217365Sjkim * NO WARRANTY
31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41217365Sjkim * POSSIBILITY OF SUCH DAMAGES.
42217365Sjkim */
4367754Smsmith
4467754Smsmith#ifndef __ACOUTPUT_H__
4567754Smsmith#define __ACOUTPUT_H__
4667754Smsmith
4767754Smsmith/*
48193267Sjkim * Debug levels and component IDs. These are used to control the
49193267Sjkim * granularity of the output of the ACPI_DEBUG_PRINT macro -- on a
50193267Sjkim * per-component basis and a per-exception-type basis.
5167754Smsmith */
5267754Smsmith
5382367Smsmith/* Component IDs are used in the global "DebugLayer" */
5467754Smsmith
5577424Smsmith#define ACPI_UTILITIES              0x00000001
5677424Smsmith#define ACPI_HARDWARE               0x00000002
5777424Smsmith#define ACPI_EVENTS                 0x00000004
5877424Smsmith#define ACPI_TABLES                 0x00000008
5977424Smsmith#define ACPI_NAMESPACE              0x00000010
6077424Smsmith#define ACPI_PARSER                 0x00000020
6177424Smsmith#define ACPI_DISPATCHER             0x00000040
6277424Smsmith#define ACPI_EXECUTER               0x00000080
6377424Smsmith#define ACPI_RESOURCES              0x00000100
64102550Siwasaki#define ACPI_CA_DEBUGGER            0x00000200
6578986Smsmith#define ACPI_OS_SERVICES            0x00000400
66102550Siwasaki#define ACPI_CA_DISASSEMBLER        0x00000800
6767754Smsmith
6891116Smsmith/* Component IDs for ACPI tools and utilities */
6967754Smsmith
7091116Smsmith#define ACPI_COMPILER               0x00001000
7191116Smsmith#define ACPI_TOOLS                  0x00002000
72193267Sjkim#define ACPI_EXAMPLE                0x00004000
73193267Sjkim#define ACPI_DRIVER                 0x00008000
74209746Sjkim#define DT_COMPILER                 0x00010000
75233250Sjkim#define ASL_PREPROCESSOR            0x00020000
7667754Smsmith
77209746Sjkim#define ACPI_ALL_COMPONENTS         0x0001FFFF
78102550Siwasaki#define ACPI_COMPONENT_DEFAULT      (ACPI_ALL_COMPONENTS)
79102550Siwasaki
8091116Smsmith/* Component IDs reserved for ACPI drivers */
8177424Smsmith
8291116Smsmith#define ACPI_ALL_DRIVERS            0xFFFF0000
8391116Smsmith
84114237Snjl
8582367Smsmith/*
86193267Sjkim * Raw debug output levels, do not use these in the ACPI_DEBUG_PRINT macros
8782367Smsmith */
88193267Sjkim#define ACPI_LV_INIT                0x00000001
89193267Sjkim#define ACPI_LV_DEBUG_OBJECT        0x00000002
90193267Sjkim#define ACPI_LV_INFO                0x00000004
91200553Sjkim#define ACPI_LV_REPAIR              0x00000008
92200553Sjkim#define ACPI_LV_ALL_EXCEPTIONS      0x0000000F
9382367Smsmith
9483174Smsmith/* Trace verbosity level 1 [Standard Trace Level] */
9582367Smsmith
96114237Snjl#define ACPI_LV_INIT_NAMES          0x00000020
9783174Smsmith#define ACPI_LV_PARSE               0x00000040
9883174Smsmith#define ACPI_LV_LOAD                0x00000080
9983174Smsmith#define ACPI_LV_DISPATCH            0x00000100
10083174Smsmith#define ACPI_LV_EXEC                0x00000200
10183174Smsmith#define ACPI_LV_NAMES               0x00000400
10283174Smsmith#define ACPI_LV_OPREGION            0x00000800
10383174Smsmith#define ACPI_LV_BFIELD              0x00001000
10483174Smsmith#define ACPI_LV_TABLES              0x00002000
10583174Smsmith#define ACPI_LV_VALUES              0x00004000
10683174Smsmith#define ACPI_LV_OBJECTS             0x00008000
10783174Smsmith#define ACPI_LV_RESOURCES           0x00010000
10883174Smsmith#define ACPI_LV_USER_REQUESTS       0x00020000
10983174Smsmith#define ACPI_LV_PACKAGE             0x00040000
110114237Snjl#define ACPI_LV_VERBOSITY1          0x0007FF40 | ACPI_LV_ALL_EXCEPTIONS
11183174Smsmith
11283174Smsmith/* Trace verbosity level 2 [Function tracing and memory allocation] */
11383174Smsmith
11482367Smsmith#define ACPI_LV_ALLOCATIONS         0x00100000
11583174Smsmith#define ACPI_LV_FUNCTIONS           0x00200000
116102550Siwasaki#define ACPI_LV_OPTIMIZATIONS       0x00400000
117102550Siwasaki#define ACPI_LV_VERBOSITY2          0x00700000 | ACPI_LV_VERBOSITY1
11883174Smsmith#define ACPI_LV_ALL                 ACPI_LV_VERBOSITY2
11982367Smsmith
12083174Smsmith/* Trace verbosity level 3 [Threading, I/O, and Interrupts] */
12182367Smsmith
12283174Smsmith#define ACPI_LV_MUTEX               0x01000000
12383174Smsmith#define ACPI_LV_THREADS             0x02000000
12483174Smsmith#define ACPI_LV_IO                  0x04000000
12583174Smsmith#define ACPI_LV_INTERRUPTS          0x08000000
12683174Smsmith#define ACPI_LV_VERBOSITY3          0x0F000000 | ACPI_LV_VERBOSITY2
12783174Smsmith
12899679Siwasaki/* Exceptionally verbose output -- also used in the global "DebugLevel"  */
12999679Siwasaki
13099679Siwasaki#define ACPI_LV_AML_DISASSEMBLE     0x10000000
13199679Siwasaki#define ACPI_LV_VERBOSE_INFO        0x20000000
13299679Siwasaki#define ACPI_LV_FULL_TABLES         0x40000000
13399679Siwasaki#define ACPI_LV_EVENTS              0x80000000
13499679Siwasaki#define ACPI_LV_VERBOSE             0xF0000000
13599679Siwasaki
13699679Siwasaki
13782367Smsmith/*
13882367Smsmith * Debug level macros that are used in the DEBUG_PRINT macros
13982367Smsmith */
140151937Sjkim#define ACPI_DEBUG_LEVEL(dl)        (UINT32) dl,ACPI_DEBUG_PARAMETERS
14182367Smsmith
142193267Sjkim/*
143193267Sjkim * Exception level -- used in the global "DebugLevel"
144193267Sjkim *
145193267Sjkim * Note: For errors, use the ACPI_ERROR or ACPI_EXCEPTION interfaces.
146193267Sjkim * For warnings, use ACPI_WARNING.
147193267Sjkim */
148114237Snjl#define ACPI_DB_INIT                ACPI_DEBUG_LEVEL (ACPI_LV_INIT)
14982367Smsmith#define ACPI_DB_DEBUG_OBJECT        ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT)
150114237Snjl#define ACPI_DB_INFO                ACPI_DEBUG_LEVEL (ACPI_LV_INFO)
151200553Sjkim#define ACPI_DB_REPAIR              ACPI_DEBUG_LEVEL (ACPI_LV_REPAIR)
15282367Smsmith#define ACPI_DB_ALL_EXCEPTIONS      ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS)
15367754Smsmith
15467754Smsmith/* Trace level -- also used in the global "DebugLevel" */
15567754Smsmith
156114237Snjl#define ACPI_DB_INIT_NAMES          ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES)
15782367Smsmith#define ACPI_DB_THREADS             ACPI_DEBUG_LEVEL (ACPI_LV_THREADS)
15882367Smsmith#define ACPI_DB_PARSE               ACPI_DEBUG_LEVEL (ACPI_LV_PARSE)
15982367Smsmith#define ACPI_DB_DISPATCH            ACPI_DEBUG_LEVEL (ACPI_LV_DISPATCH)
16082367Smsmith#define ACPI_DB_LOAD                ACPI_DEBUG_LEVEL (ACPI_LV_LOAD)
16182367Smsmith#define ACPI_DB_EXEC                ACPI_DEBUG_LEVEL (ACPI_LV_EXEC)
16282367Smsmith#define ACPI_DB_NAMES               ACPI_DEBUG_LEVEL (ACPI_LV_NAMES)
16382367Smsmith#define ACPI_DB_OPREGION            ACPI_DEBUG_LEVEL (ACPI_LV_OPREGION)
16482367Smsmith#define ACPI_DB_BFIELD              ACPI_DEBUG_LEVEL (ACPI_LV_BFIELD)
16582367Smsmith#define ACPI_DB_TABLES              ACPI_DEBUG_LEVEL (ACPI_LV_TABLES)
16682367Smsmith#define ACPI_DB_FUNCTIONS           ACPI_DEBUG_LEVEL (ACPI_LV_FUNCTIONS)
167102550Siwasaki#define ACPI_DB_OPTIMIZATIONS       ACPI_DEBUG_LEVEL (ACPI_LV_OPTIMIZATIONS)
16882367Smsmith#define ACPI_DB_VALUES              ACPI_DEBUG_LEVEL (ACPI_LV_VALUES)
16982367Smsmith#define ACPI_DB_OBJECTS             ACPI_DEBUG_LEVEL (ACPI_LV_OBJECTS)
17082367Smsmith#define ACPI_DB_ALLOCATIONS         ACPI_DEBUG_LEVEL (ACPI_LV_ALLOCATIONS)
17182367Smsmith#define ACPI_DB_RESOURCES           ACPI_DEBUG_LEVEL (ACPI_LV_RESOURCES)
17282367Smsmith#define ACPI_DB_IO                  ACPI_DEBUG_LEVEL (ACPI_LV_IO)
17382367Smsmith#define ACPI_DB_INTERRUPTS          ACPI_DEBUG_LEVEL (ACPI_LV_INTERRUPTS)
17482367Smsmith#define ACPI_DB_USER_REQUESTS       ACPI_DEBUG_LEVEL (ACPI_LV_USER_REQUESTS)
17582367Smsmith#define ACPI_DB_PACKAGE             ACPI_DEBUG_LEVEL (ACPI_LV_PACKAGE)
17682367Smsmith#define ACPI_DB_MUTEX               ACPI_DEBUG_LEVEL (ACPI_LV_MUTEX)
177193267Sjkim#define ACPI_DB_EVENTS              ACPI_DEBUG_LEVEL (ACPI_LV_EVENTS)
17867754Smsmith
17999679Siwasaki#define ACPI_DB_ALL                 ACPI_DEBUG_LEVEL (ACPI_LV_ALL)
18067754Smsmith
18167754Smsmith/* Defaults for DebugLevel, debug and normal */
18267754Smsmith
183200553Sjkim#define ACPI_DEBUG_DEFAULT          (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR)
184200553Sjkim#define ACPI_NORMAL_DEFAULT         (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR)
185114237Snjl#define ACPI_DEBUG_ALL              (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL)
18667754Smsmith
18767754Smsmith
188193267Sjkim#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES)
189193267Sjkim/*
190218590Sjkim * The module name is used primarily for error and debug messages.
191218590Sjkim * The __FILE__ macro is not very useful for this, because it
192218590Sjkim * usually includes the entire pathname to the module making the
193218590Sjkim * debug output difficult to read.
194193267Sjkim */
195193267Sjkim#define ACPI_MODULE_NAME(Name)          static const char ACPI_UNUSED_VAR _AcpiModuleName[] = Name;
196193267Sjkim#else
197218590Sjkim/*
198218590Sjkim * For the no-debug and no-error-msg cases, we must at least define
199218590Sjkim * a null module name.
200218590Sjkim */
201193267Sjkim#define ACPI_MODULE_NAME(Name)
202218590Sjkim#define _AcpiModuleName ""
203193267Sjkim#endif
204193267Sjkim
205193267Sjkim/*
206193267Sjkim * Ascii error messages can be configured out
207193267Sjkim */
208193267Sjkim#ifndef ACPI_NO_ERROR_MESSAGES
209193267Sjkim#define AE_INFO                         _AcpiModuleName, __LINE__
210193267Sjkim
211193267Sjkim/*
212193267Sjkim * Error reporting. Callers module and line number are inserted by AE_INFO,
213193267Sjkim * the plist contains a set of parens to allow variable-length lists.
214193267Sjkim * These macros are used for both the debug and non-debug versions of the code.
215193267Sjkim */
216193267Sjkim#define ACPI_INFO(plist)                AcpiInfo plist
217193267Sjkim#define ACPI_WARNING(plist)             AcpiWarning plist
218193267Sjkim#define ACPI_EXCEPTION(plist)           AcpiException plist
219193267Sjkim#define ACPI_ERROR(plist)               AcpiError plist
220204773Sjkim#define ACPI_DEBUG_OBJECT(obj,l,i)      AcpiExDoDebugObject(obj,l,i)
221193267Sjkim
222193267Sjkim#else
223193267Sjkim
224193267Sjkim/* No error messages */
225193267Sjkim
226193267Sjkim#define ACPI_INFO(plist)
227193267Sjkim#define ACPI_WARNING(plist)
228193267Sjkim#define ACPI_EXCEPTION(plist)
229193267Sjkim#define ACPI_ERROR(plist)
230204773Sjkim#define ACPI_DEBUG_OBJECT(obj,l,i)
231193267Sjkim
232193267Sjkim#endif /* ACPI_NO_ERROR_MESSAGES */
233193267Sjkim
234193267Sjkim
235193267Sjkim/*
236193267Sjkim * Debug macros that are conditionally compiled
237193267Sjkim */
238193267Sjkim#ifdef ACPI_DEBUG_OUTPUT
239193267Sjkim
240193267Sjkim/*
241193267Sjkim * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header,
242193267Sjkim * define it now. This is the case where there the compiler does not support
243193267Sjkim * a __FUNCTION__ macro or equivalent.
244193267Sjkim */
245193267Sjkim#ifndef ACPI_GET_FUNCTION_NAME
246193267Sjkim#define ACPI_GET_FUNCTION_NAME          _AcpiFunctionName
247193267Sjkim
248193267Sjkim/*
249193267Sjkim * The Name parameter should be the procedure name as a quoted string.
250193267Sjkim * The function name is also used by the function exit macros below.
251193267Sjkim * Note: (const char) is used to be compatible with the debug interfaces
252193267Sjkim * and macros such as __FUNCTION__.
253193267Sjkim */
254193267Sjkim#define ACPI_FUNCTION_NAME(Name)        static const char _AcpiFunctionName[] = #Name;
255193267Sjkim
256193267Sjkim#else
257193267Sjkim/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */
258193267Sjkim
259193267Sjkim#define ACPI_FUNCTION_NAME(Name)
260193267Sjkim#endif /* ACPI_GET_FUNCTION_NAME */
261193267Sjkim
262193267Sjkim/*
263193267Sjkim * Common parameters used for debug output functions:
264193267Sjkim * line number, function name, module(file) name, component ID
265193267Sjkim */
266193267Sjkim#define ACPI_DEBUG_PARAMETERS           __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT
267193267Sjkim
268193267Sjkim/*
269193267Sjkim * Master debug print macros
270193267Sjkim * Print message if and only if:
271193267Sjkim *    1) Debug print for the current component is enabled
272193267Sjkim *    2) Debug error level or trace level for the print statement is enabled
273193267Sjkim */
274193267Sjkim#define ACPI_DEBUG_PRINT(plist)         AcpiDebugPrint plist
275193267Sjkim#define ACPI_DEBUG_PRINT_RAW(plist)     AcpiDebugPrintRaw plist
276193267Sjkim
277193267Sjkim#else
278193267Sjkim/*
279193267Sjkim * This is the non-debug case -- make everything go away,
280193267Sjkim * leaving no executable debug code!
281193267Sjkim */
282193267Sjkim#define ACPI_FUNCTION_NAME(a)
283193267Sjkim#define ACPI_DEBUG_PRINT(pl)
284193267Sjkim#define ACPI_DEBUG_PRINT_RAW(pl)
285193267Sjkim
286193267Sjkim#endif /* ACPI_DEBUG_OUTPUT */
287193267Sjkim
288193267Sjkim
28967754Smsmith#endif /* __ACOUTPUT_H__ */
290