xref: /titanic_41/usr/src/uts/intel/sys/acpi/acoutput.h (revision de5d74c22760a6d2cefd94d0e7f0fd87214fb71f)
17c478bd9Sstevel@tonic-gate /******************************************************************************
27c478bd9Sstevel@tonic-gate  *
37c478bd9Sstevel@tonic-gate  * Name: acoutput.h -- debug output
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  *****************************************************************************/
67c478bd9Sstevel@tonic-gate 
726f3cdf0SGordon Ross /*
8*de5d74c2SJerry Jelinek  * Copyright (C) 2000 - 2016, Intel Corp.
97c478bd9Sstevel@tonic-gate  * All rights reserved.
107c478bd9Sstevel@tonic-gate  *
1126f3cdf0SGordon Ross  * Redistribution and use in source and binary forms, with or without
1226f3cdf0SGordon Ross  * modification, are permitted provided that the following conditions
1326f3cdf0SGordon Ross  * are met:
1426f3cdf0SGordon Ross  * 1. Redistributions of source code must retain the above copyright
1526f3cdf0SGordon Ross  *    notice, this list of conditions, and the following disclaimer,
1626f3cdf0SGordon Ross  *    without modification.
1726f3cdf0SGordon Ross  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1826f3cdf0SGordon Ross  *    substantially similar to the "NO WARRANTY" disclaimer below
1926f3cdf0SGordon Ross  *    ("Disclaimer") and any redistribution must be conditioned upon
2026f3cdf0SGordon Ross  *    including a substantially similar Disclaimer requirement for further
2126f3cdf0SGordon Ross  *    binary redistribution.
2226f3cdf0SGordon Ross  * 3. Neither the names of the above-listed copyright holders nor the names
2326f3cdf0SGordon Ross  *    of any contributors may be used to endorse or promote products derived
2426f3cdf0SGordon Ross  *    from this software without specific prior written permission.
257c478bd9Sstevel@tonic-gate  *
2626f3cdf0SGordon Ross  * Alternatively, this software may be distributed under the terms of the
2726f3cdf0SGordon Ross  * GNU General Public License ("GPL") version 2 as published by the Free
2826f3cdf0SGordon Ross  * Software Foundation.
297c478bd9Sstevel@tonic-gate  *
3026f3cdf0SGordon Ross  * NO WARRANTY
3126f3cdf0SGordon Ross  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3226f3cdf0SGordon Ross  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3326f3cdf0SGordon Ross  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3426f3cdf0SGordon Ross  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3526f3cdf0SGordon Ross  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3626f3cdf0SGordon Ross  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3726f3cdf0SGordon Ross  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3826f3cdf0SGordon Ross  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3926f3cdf0SGordon Ross  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4026f3cdf0SGordon Ross  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4126f3cdf0SGordon Ross  * POSSIBILITY OF SUCH DAMAGES.
4226f3cdf0SGordon Ross  */
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifndef __ACOUTPUT_H__
457c478bd9Sstevel@tonic-gate #define __ACOUTPUT_H__
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate /*
487c478bd9Sstevel@tonic-gate  * Debug levels and component IDs. These are used to control the
49aa2aa9a6SDana Myers  * granularity of the output of the ACPI_DEBUG_PRINT macro -- on a
50aa2aa9a6SDana Myers  * per-component basis and a per-exception-type basis.
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /* Component IDs are used in the global "DebugLayer" */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #define ACPI_UTILITIES              0x00000001
567c478bd9Sstevel@tonic-gate #define ACPI_HARDWARE               0x00000002
577c478bd9Sstevel@tonic-gate #define ACPI_EVENTS                 0x00000004
587c478bd9Sstevel@tonic-gate #define ACPI_TABLES                 0x00000008
597c478bd9Sstevel@tonic-gate #define ACPI_NAMESPACE              0x00000010
607c478bd9Sstevel@tonic-gate #define ACPI_PARSER                 0x00000020
617c478bd9Sstevel@tonic-gate #define ACPI_DISPATCHER             0x00000040
627c478bd9Sstevel@tonic-gate #define ACPI_EXECUTER               0x00000080
637c478bd9Sstevel@tonic-gate #define ACPI_RESOURCES              0x00000100
647c478bd9Sstevel@tonic-gate #define ACPI_CA_DEBUGGER            0x00000200
657c478bd9Sstevel@tonic-gate #define ACPI_OS_SERVICES            0x00000400
667c478bd9Sstevel@tonic-gate #define ACPI_CA_DISASSEMBLER        0x00000800
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /* Component IDs for ACPI tools and utilities */
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate #define ACPI_COMPILER               0x00001000
717c478bd9Sstevel@tonic-gate #define ACPI_TOOLS                  0x00002000
72aa2aa9a6SDana Myers #define ACPI_EXAMPLE                0x00004000
73aa2aa9a6SDana Myers #define ACPI_DRIVER                 0x00008000
7426f3cdf0SGordon Ross #define DT_COMPILER                 0x00010000
75*de5d74c2SJerry Jelinek #define ASL_PREPROCESSOR            0x00020000
767c478bd9Sstevel@tonic-gate 
7726f3cdf0SGordon Ross #define ACPI_ALL_COMPONENTS         0x0001FFFF
787c478bd9Sstevel@tonic-gate #define ACPI_COMPONENT_DEFAULT      (ACPI_ALL_COMPONENTS)
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /* Component IDs reserved for ACPI drivers */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate #define ACPI_ALL_DRIVERS            0xFFFF0000
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /*
86aa2aa9a6SDana Myers  * Raw debug output levels, do not use these in the ACPI_DEBUG_PRINT macros
877c478bd9Sstevel@tonic-gate  */
88db2bae30SDana Myers #define ACPI_LV_INIT                0x00000001
89db2bae30SDana Myers #define ACPI_LV_DEBUG_OBJECT        0x00000002
90db2bae30SDana Myers #define ACPI_LV_INFO                0x00000004
9126f3cdf0SGordon Ross #define ACPI_LV_REPAIR              0x00000008
92*de5d74c2SJerry Jelinek #define ACPI_LV_TRACE_POINT         0x00000010
93*de5d74c2SJerry Jelinek #define ACPI_LV_ALL_EXCEPTIONS      0x0000001F
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /* Trace verbosity level 1 [Standard Trace Level] */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate #define ACPI_LV_INIT_NAMES          0x00000020
987c478bd9Sstevel@tonic-gate #define ACPI_LV_PARSE               0x00000040
997c478bd9Sstevel@tonic-gate #define ACPI_LV_LOAD                0x00000080
1007c478bd9Sstevel@tonic-gate #define ACPI_LV_DISPATCH            0x00000100
1017c478bd9Sstevel@tonic-gate #define ACPI_LV_EXEC                0x00000200
1027c478bd9Sstevel@tonic-gate #define ACPI_LV_NAMES               0x00000400
1037c478bd9Sstevel@tonic-gate #define ACPI_LV_OPREGION            0x00000800
1047c478bd9Sstevel@tonic-gate #define ACPI_LV_BFIELD              0x00001000
1057c478bd9Sstevel@tonic-gate #define ACPI_LV_TABLES              0x00002000
1067c478bd9Sstevel@tonic-gate #define ACPI_LV_VALUES              0x00004000
1077c478bd9Sstevel@tonic-gate #define ACPI_LV_OBJECTS             0x00008000
1087c478bd9Sstevel@tonic-gate #define ACPI_LV_RESOURCES           0x00010000
1097c478bd9Sstevel@tonic-gate #define ACPI_LV_USER_REQUESTS       0x00020000
1107c478bd9Sstevel@tonic-gate #define ACPI_LV_PACKAGE             0x00040000
1117c478bd9Sstevel@tonic-gate #define ACPI_LV_VERBOSITY1          0x0007FF40 | ACPI_LV_ALL_EXCEPTIONS
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate /* Trace verbosity level 2 [Function tracing and memory allocation] */
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate #define ACPI_LV_ALLOCATIONS         0x00100000
1167c478bd9Sstevel@tonic-gate #define ACPI_LV_FUNCTIONS           0x00200000
1177c478bd9Sstevel@tonic-gate #define ACPI_LV_OPTIMIZATIONS       0x00400000
1187c478bd9Sstevel@tonic-gate #define ACPI_LV_VERBOSITY2          0x00700000 | ACPI_LV_VERBOSITY1
1197c478bd9Sstevel@tonic-gate #define ACPI_LV_ALL                 ACPI_LV_VERBOSITY2
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate /* Trace verbosity level 3 [Threading, I/O, and Interrupts] */
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate #define ACPI_LV_MUTEX               0x01000000
1247c478bd9Sstevel@tonic-gate #define ACPI_LV_THREADS             0x02000000
1257c478bd9Sstevel@tonic-gate #define ACPI_LV_IO                  0x04000000
1267c478bd9Sstevel@tonic-gate #define ACPI_LV_INTERRUPTS          0x08000000
1277c478bd9Sstevel@tonic-gate #define ACPI_LV_VERBOSITY3          0x0F000000 | ACPI_LV_VERBOSITY2
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /* Exceptionally verbose output -- also used in the global "DebugLevel"  */
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate #define ACPI_LV_AML_DISASSEMBLE     0x10000000
1327c478bd9Sstevel@tonic-gate #define ACPI_LV_VERBOSE_INFO        0x20000000
1337c478bd9Sstevel@tonic-gate #define ACPI_LV_FULL_TABLES         0x40000000
1347c478bd9Sstevel@tonic-gate #define ACPI_LV_EVENTS              0x80000000
1357c478bd9Sstevel@tonic-gate #define ACPI_LV_VERBOSE             0xF0000000
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate /*
1397c478bd9Sstevel@tonic-gate  * Debug level macros that are used in the DEBUG_PRINT macros
1407c478bd9Sstevel@tonic-gate  */
141450d6964Smyers #define ACPI_DEBUG_LEVEL(dl)        (UINT32) dl,ACPI_DEBUG_PARAMETERS
1427c478bd9Sstevel@tonic-gate 
143db2bae30SDana Myers /*
144db2bae30SDana Myers  * Exception level -- used in the global "DebugLevel"
145db2bae30SDana Myers  *
146db2bae30SDana Myers  * Note: For errors, use the ACPI_ERROR or ACPI_EXCEPTION interfaces.
147db2bae30SDana Myers  * For warnings, use ACPI_WARNING.
148db2bae30SDana Myers  */
1497c478bd9Sstevel@tonic-gate #define ACPI_DB_INIT                ACPI_DEBUG_LEVEL (ACPI_LV_INIT)
1507c478bd9Sstevel@tonic-gate #define ACPI_DB_DEBUG_OBJECT        ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT)
1517c478bd9Sstevel@tonic-gate #define ACPI_DB_INFO                ACPI_DEBUG_LEVEL (ACPI_LV_INFO)
15226f3cdf0SGordon Ross #define ACPI_DB_REPAIR              ACPI_DEBUG_LEVEL (ACPI_LV_REPAIR)
153*de5d74c2SJerry Jelinek #define ACPI_DB_TRACE_POINT         ACPI_DEBUG_LEVEL (ACPI_LV_TRACE_POINT)
1547c478bd9Sstevel@tonic-gate #define ACPI_DB_ALL_EXCEPTIONS      ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS)
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate /* Trace level -- also used in the global "DebugLevel" */
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate #define ACPI_DB_INIT_NAMES          ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES)
1597c478bd9Sstevel@tonic-gate #define ACPI_DB_THREADS             ACPI_DEBUG_LEVEL (ACPI_LV_THREADS)
1607c478bd9Sstevel@tonic-gate #define ACPI_DB_PARSE               ACPI_DEBUG_LEVEL (ACPI_LV_PARSE)
1617c478bd9Sstevel@tonic-gate #define ACPI_DB_DISPATCH            ACPI_DEBUG_LEVEL (ACPI_LV_DISPATCH)
1627c478bd9Sstevel@tonic-gate #define ACPI_DB_LOAD                ACPI_DEBUG_LEVEL (ACPI_LV_LOAD)
1637c478bd9Sstevel@tonic-gate #define ACPI_DB_EXEC                ACPI_DEBUG_LEVEL (ACPI_LV_EXEC)
1647c478bd9Sstevel@tonic-gate #define ACPI_DB_NAMES               ACPI_DEBUG_LEVEL (ACPI_LV_NAMES)
1657c478bd9Sstevel@tonic-gate #define ACPI_DB_OPREGION            ACPI_DEBUG_LEVEL (ACPI_LV_OPREGION)
1667c478bd9Sstevel@tonic-gate #define ACPI_DB_BFIELD              ACPI_DEBUG_LEVEL (ACPI_LV_BFIELD)
1677c478bd9Sstevel@tonic-gate #define ACPI_DB_TABLES              ACPI_DEBUG_LEVEL (ACPI_LV_TABLES)
1687c478bd9Sstevel@tonic-gate #define ACPI_DB_FUNCTIONS           ACPI_DEBUG_LEVEL (ACPI_LV_FUNCTIONS)
1697c478bd9Sstevel@tonic-gate #define ACPI_DB_OPTIMIZATIONS       ACPI_DEBUG_LEVEL (ACPI_LV_OPTIMIZATIONS)
1707c478bd9Sstevel@tonic-gate #define ACPI_DB_VALUES              ACPI_DEBUG_LEVEL (ACPI_LV_VALUES)
1717c478bd9Sstevel@tonic-gate #define ACPI_DB_OBJECTS             ACPI_DEBUG_LEVEL (ACPI_LV_OBJECTS)
1727c478bd9Sstevel@tonic-gate #define ACPI_DB_ALLOCATIONS         ACPI_DEBUG_LEVEL (ACPI_LV_ALLOCATIONS)
1737c478bd9Sstevel@tonic-gate #define ACPI_DB_RESOURCES           ACPI_DEBUG_LEVEL (ACPI_LV_RESOURCES)
1747c478bd9Sstevel@tonic-gate #define ACPI_DB_IO                  ACPI_DEBUG_LEVEL (ACPI_LV_IO)
1757c478bd9Sstevel@tonic-gate #define ACPI_DB_INTERRUPTS          ACPI_DEBUG_LEVEL (ACPI_LV_INTERRUPTS)
1767c478bd9Sstevel@tonic-gate #define ACPI_DB_USER_REQUESTS       ACPI_DEBUG_LEVEL (ACPI_LV_USER_REQUESTS)
1777c478bd9Sstevel@tonic-gate #define ACPI_DB_PACKAGE             ACPI_DEBUG_LEVEL (ACPI_LV_PACKAGE)
1787c478bd9Sstevel@tonic-gate #define ACPI_DB_MUTEX               ACPI_DEBUG_LEVEL (ACPI_LV_MUTEX)
179db2bae30SDana Myers #define ACPI_DB_EVENTS              ACPI_DEBUG_LEVEL (ACPI_LV_EVENTS)
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate #define ACPI_DB_ALL                 ACPI_DEBUG_LEVEL (ACPI_LV_ALL)
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate /* Defaults for DebugLevel, debug and normal */
1847c478bd9Sstevel@tonic-gate 
18526f3cdf0SGordon Ross #define ACPI_DEBUG_DEFAULT          (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR)
18626f3cdf0SGordon Ross #define ACPI_NORMAL_DEFAULT         (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR)
1877c478bd9Sstevel@tonic-gate #define ACPI_DEBUG_ALL              (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL)
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate 
190*de5d74c2SJerry Jelinek /*
191*de5d74c2SJerry Jelinek  * Global trace flags
192*de5d74c2SJerry Jelinek  */
193*de5d74c2SJerry Jelinek #define ACPI_TRACE_ENABLED          ((UINT32) 4)
194*de5d74c2SJerry Jelinek #define ACPI_TRACE_ONESHOT          ((UINT32) 2)
195*de5d74c2SJerry Jelinek #define ACPI_TRACE_OPCODE           ((UINT32) 1)
196*de5d74c2SJerry Jelinek 
197*de5d74c2SJerry Jelinek /* Defaults for trace debugging level/layer */
198*de5d74c2SJerry Jelinek 
199*de5d74c2SJerry Jelinek #define ACPI_TRACE_LEVEL_ALL        ACPI_LV_ALL
200*de5d74c2SJerry Jelinek #define ACPI_TRACE_LAYER_ALL        0x000001FF
201*de5d74c2SJerry Jelinek #define ACPI_TRACE_LEVEL_DEFAULT    ACPI_LV_TRACE_POINT
202*de5d74c2SJerry Jelinek #define ACPI_TRACE_LAYER_DEFAULT    ACPI_EXECUTER
203*de5d74c2SJerry Jelinek 
204*de5d74c2SJerry Jelinek 
205aa2aa9a6SDana Myers #if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES)
206aa2aa9a6SDana Myers /*
20726f3cdf0SGordon Ross  * The module name is used primarily for error and debug messages.
20826f3cdf0SGordon Ross  * The __FILE__ macro is not very useful for this, because it
20926f3cdf0SGordon Ross  * usually includes the entire pathname to the module making the
21026f3cdf0SGordon Ross  * debug output difficult to read.
211aa2aa9a6SDana Myers  */
212aa2aa9a6SDana Myers #define ACPI_MODULE_NAME(Name)          static const char ACPI_UNUSED_VAR _AcpiModuleName[] = Name;
213aa2aa9a6SDana Myers #else
21426f3cdf0SGordon Ross /*
21526f3cdf0SGordon Ross  * For the no-debug and no-error-msg cases, we must at least define
21626f3cdf0SGordon Ross  * a null module name.
21726f3cdf0SGordon Ross  */
218aa2aa9a6SDana Myers #define ACPI_MODULE_NAME(Name)
21926f3cdf0SGordon Ross #define _AcpiModuleName ""
220aa2aa9a6SDana Myers #endif
221aa2aa9a6SDana Myers 
222aa2aa9a6SDana Myers /*
223aa2aa9a6SDana Myers  * Ascii error messages can be configured out
224aa2aa9a6SDana Myers  */
225aa2aa9a6SDana Myers #ifndef ACPI_NO_ERROR_MESSAGES
226aa2aa9a6SDana Myers #define AE_INFO                         _AcpiModuleName, __LINE__
227aa2aa9a6SDana Myers 
228aa2aa9a6SDana Myers /*
229aa2aa9a6SDana Myers  * Error reporting. Callers module and line number are inserted by AE_INFO,
230aa2aa9a6SDana Myers  * the plist contains a set of parens to allow variable-length lists.
231aa2aa9a6SDana Myers  * These macros are used for both the debug and non-debug versions of the code.
232aa2aa9a6SDana Myers  */
233aa2aa9a6SDana Myers #define ACPI_INFO(plist)                AcpiInfo plist
234aa2aa9a6SDana Myers #define ACPI_WARNING(plist)             AcpiWarning plist
235aa2aa9a6SDana Myers #define ACPI_EXCEPTION(plist)           AcpiException plist
236aa2aa9a6SDana Myers #define ACPI_ERROR(plist)               AcpiError plist
237*de5d74c2SJerry Jelinek #define ACPI_BIOS_WARNING(plist)        AcpiBiosWarning plist
238*de5d74c2SJerry Jelinek #define ACPI_BIOS_ERROR(plist)          AcpiBiosError plist
23926f3cdf0SGordon Ross #define ACPI_DEBUG_OBJECT(obj,l,i)      AcpiExDoDebugObject(obj,l,i)
240aa2aa9a6SDana Myers 
241aa2aa9a6SDana Myers #else
242aa2aa9a6SDana Myers 
243aa2aa9a6SDana Myers /* No error messages */
244aa2aa9a6SDana Myers 
245aa2aa9a6SDana Myers #define ACPI_INFO(plist)
246aa2aa9a6SDana Myers #define ACPI_WARNING(plist)
247aa2aa9a6SDana Myers #define ACPI_EXCEPTION(plist)
248aa2aa9a6SDana Myers #define ACPI_ERROR(plist)
249*de5d74c2SJerry Jelinek #define ACPI_BIOS_WARNING(plist)
250*de5d74c2SJerry Jelinek #define ACPI_BIOS_ERROR(plist)
25126f3cdf0SGordon Ross #define ACPI_DEBUG_OBJECT(obj,l,i)
252aa2aa9a6SDana Myers 
253aa2aa9a6SDana Myers #endif /* ACPI_NO_ERROR_MESSAGES */
254aa2aa9a6SDana Myers 
255aa2aa9a6SDana Myers 
256aa2aa9a6SDana Myers /*
257aa2aa9a6SDana Myers  * Debug macros that are conditionally compiled
258aa2aa9a6SDana Myers  */
259aa2aa9a6SDana Myers #ifdef ACPI_DEBUG_OUTPUT
260aa2aa9a6SDana Myers 
261aa2aa9a6SDana Myers /*
262aa2aa9a6SDana Myers  * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header,
263aa2aa9a6SDana Myers  * define it now. This is the case where there the compiler does not support
264aa2aa9a6SDana Myers  * a __FUNCTION__ macro or equivalent.
265aa2aa9a6SDana Myers  */
266aa2aa9a6SDana Myers #ifndef ACPI_GET_FUNCTION_NAME
267aa2aa9a6SDana Myers #define ACPI_GET_FUNCTION_NAME          _AcpiFunctionName
268aa2aa9a6SDana Myers 
269aa2aa9a6SDana Myers /*
270*de5d74c2SJerry Jelinek  * The Name parameter should be the procedure name as a non-quoted string.
271aa2aa9a6SDana Myers  * The function name is also used by the function exit macros below.
272aa2aa9a6SDana Myers  * Note: (const char) is used to be compatible with the debug interfaces
273aa2aa9a6SDana Myers  * and macros such as __FUNCTION__.
274aa2aa9a6SDana Myers  */
275aa2aa9a6SDana Myers #define ACPI_FUNCTION_NAME(Name)        static const char _AcpiFunctionName[] = #Name;
276aa2aa9a6SDana Myers 
277aa2aa9a6SDana Myers #else
278aa2aa9a6SDana Myers /* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */
279aa2aa9a6SDana Myers 
280aa2aa9a6SDana Myers #define ACPI_FUNCTION_NAME(Name)
281aa2aa9a6SDana Myers #endif /* ACPI_GET_FUNCTION_NAME */
282aa2aa9a6SDana Myers 
283aa2aa9a6SDana Myers /*
284aa2aa9a6SDana Myers  * Common parameters used for debug output functions:
285aa2aa9a6SDana Myers  * line number, function name, module(file) name, component ID
286aa2aa9a6SDana Myers  */
287*de5d74c2SJerry Jelinek #define ACPI_DEBUG_PARAMETERS \
288*de5d74c2SJerry Jelinek     __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT
289*de5d74c2SJerry Jelinek 
290*de5d74c2SJerry Jelinek /* Check if debug output is currently dynamically enabled */
291*de5d74c2SJerry Jelinek 
292*de5d74c2SJerry Jelinek #define ACPI_IS_DEBUG_ENABLED(Level, Component) \
293*de5d74c2SJerry Jelinek     ((Level & AcpiDbgLevel) && (Component & AcpiDbgLayer))
294aa2aa9a6SDana Myers 
295aa2aa9a6SDana Myers /*
296aa2aa9a6SDana Myers  * Master debug print macros
297aa2aa9a6SDana Myers  * Print message if and only if:
298aa2aa9a6SDana Myers  *    1) Debug print for the current component is enabled
299aa2aa9a6SDana Myers  *    2) Debug error level or trace level for the print statement is enabled
300*de5d74c2SJerry Jelinek  *
301*de5d74c2SJerry Jelinek  * November 2012: Moved the runtime check for whether to actually emit the
302*de5d74c2SJerry Jelinek  * debug message outside of the print function itself. This improves overall
303*de5d74c2SJerry Jelinek  * performance at a relatively small code cost. Implementation involves the
304*de5d74c2SJerry Jelinek  * use of variadic macros supported by C99.
305*de5d74c2SJerry Jelinek  *
306*de5d74c2SJerry Jelinek  * Note: the ACPI_DO_WHILE0 macro is used to prevent some compilers from
307*de5d74c2SJerry Jelinek  * complaining about these constructs. On other compilers the do...while
308*de5d74c2SJerry Jelinek  * adds some extra code, so this feature is optional.
309aa2aa9a6SDana Myers  */
310*de5d74c2SJerry Jelinek #ifdef ACPI_USE_DO_WHILE_0
311*de5d74c2SJerry Jelinek #define ACPI_DO_WHILE0(a)               do a while(0)
312*de5d74c2SJerry Jelinek #else
313*de5d74c2SJerry Jelinek #define ACPI_DO_WHILE0(a)               a
314*de5d74c2SJerry Jelinek #endif
315*de5d74c2SJerry Jelinek 
316*de5d74c2SJerry Jelinek /* DEBUG_PRINT functions */
317*de5d74c2SJerry Jelinek 
318*de5d74c2SJerry Jelinek #ifndef COMPILER_VA_MACRO
319*de5d74c2SJerry Jelinek 
320aa2aa9a6SDana Myers #define ACPI_DEBUG_PRINT(plist)         AcpiDebugPrint plist
321aa2aa9a6SDana Myers #define ACPI_DEBUG_PRINT_RAW(plist)     AcpiDebugPrintRaw plist
322aa2aa9a6SDana Myers 
323aa2aa9a6SDana Myers #else
324*de5d74c2SJerry Jelinek 
325*de5d74c2SJerry Jelinek /* Helper macros for DEBUG_PRINT */
326*de5d74c2SJerry Jelinek 
327*de5d74c2SJerry Jelinek #define ACPI_DO_DEBUG_PRINT(Function, Level, Line, Filename, Modulename, Component, ...) \
328*de5d74c2SJerry Jelinek     ACPI_DO_WHILE0 ({ \
329*de5d74c2SJerry Jelinek         if (ACPI_IS_DEBUG_ENABLED (Level, Component)) \
330*de5d74c2SJerry Jelinek         { \
331*de5d74c2SJerry Jelinek             Function (Level, Line, Filename, Modulename, Component, __VA_ARGS__); \
332*de5d74c2SJerry Jelinek         } \
333*de5d74c2SJerry Jelinek     })
334*de5d74c2SJerry Jelinek 
335*de5d74c2SJerry Jelinek #define ACPI_ACTUAL_DEBUG(Level, Line, Filename, Modulename, Component, ...) \
336*de5d74c2SJerry Jelinek     ACPI_DO_DEBUG_PRINT (AcpiDebugPrint, Level, Line, \
337*de5d74c2SJerry Jelinek         Filename, Modulename, Component, __VA_ARGS__)
338*de5d74c2SJerry Jelinek 
339*de5d74c2SJerry Jelinek #define ACPI_ACTUAL_DEBUG_RAW(Level, Line, Filename, Modulename, Component, ...) \
340*de5d74c2SJerry Jelinek     ACPI_DO_DEBUG_PRINT (AcpiDebugPrintRaw, Level, Line, \
341*de5d74c2SJerry Jelinek         Filename, Modulename, Component, __VA_ARGS__)
342*de5d74c2SJerry Jelinek 
343*de5d74c2SJerry Jelinek #define ACPI_DEBUG_PRINT(plist)         ACPI_ACTUAL_DEBUG plist
344*de5d74c2SJerry Jelinek #define ACPI_DEBUG_PRINT_RAW(plist)     ACPI_ACTUAL_DEBUG_RAW plist
345*de5d74c2SJerry Jelinek 
346*de5d74c2SJerry Jelinek #endif
347*de5d74c2SJerry Jelinek 
348*de5d74c2SJerry Jelinek 
349*de5d74c2SJerry Jelinek /*
350*de5d74c2SJerry Jelinek  * Function entry tracing
351*de5d74c2SJerry Jelinek  *
352*de5d74c2SJerry Jelinek  * The name of the function is emitted as a local variable that is
353*de5d74c2SJerry Jelinek  * intended to be used by both the entry trace and the exit trace.
354*de5d74c2SJerry Jelinek  */
355*de5d74c2SJerry Jelinek 
356*de5d74c2SJerry Jelinek /* Helper macro */
357*de5d74c2SJerry Jelinek 
358*de5d74c2SJerry Jelinek #define ACPI_TRACE_ENTRY(Name, Function, Type, Param) \
359*de5d74c2SJerry Jelinek     ACPI_FUNCTION_NAME (Name) \
360*de5d74c2SJerry Jelinek     Function (ACPI_DEBUG_PARAMETERS, (Type) (Param))
361*de5d74c2SJerry Jelinek 
362*de5d74c2SJerry Jelinek /* The actual entry trace macros */
363*de5d74c2SJerry Jelinek 
364*de5d74c2SJerry Jelinek #define ACPI_FUNCTION_TRACE(Name) \
365*de5d74c2SJerry Jelinek     ACPI_FUNCTION_NAME(Name) \
366*de5d74c2SJerry Jelinek     AcpiUtTrace (ACPI_DEBUG_PARAMETERS)
367*de5d74c2SJerry Jelinek 
368*de5d74c2SJerry Jelinek #define ACPI_FUNCTION_TRACE_PTR(Name, Pointer) \
369*de5d74c2SJerry Jelinek     ACPI_TRACE_ENTRY (Name, AcpiUtTracePtr, void *, Pointer)
370*de5d74c2SJerry Jelinek 
371*de5d74c2SJerry Jelinek #define ACPI_FUNCTION_TRACE_U32(Name, Value) \
372*de5d74c2SJerry Jelinek     ACPI_TRACE_ENTRY (Name, AcpiUtTraceU32, UINT32, Value)
373*de5d74c2SJerry Jelinek 
374*de5d74c2SJerry Jelinek #define ACPI_FUNCTION_TRACE_STR(Name, String) \
375*de5d74c2SJerry Jelinek     ACPI_TRACE_ENTRY (Name, AcpiUtTraceStr, const char *, String)
376*de5d74c2SJerry Jelinek 
377*de5d74c2SJerry Jelinek #define ACPI_FUNCTION_ENTRY() \
378*de5d74c2SJerry Jelinek     AcpiUtTrackStackPtr()
379*de5d74c2SJerry Jelinek 
380*de5d74c2SJerry Jelinek 
381*de5d74c2SJerry Jelinek /*
382*de5d74c2SJerry Jelinek  * Function exit tracing
383*de5d74c2SJerry Jelinek  *
384*de5d74c2SJerry Jelinek  * These macros include a return statement. This is usually considered
385*de5d74c2SJerry Jelinek  * bad form, but having a separate exit macro before the actual return
386*de5d74c2SJerry Jelinek  * is very ugly and difficult to maintain.
387*de5d74c2SJerry Jelinek  *
388*de5d74c2SJerry Jelinek  * One of the FUNCTION_TRACE macros above must be used in conjunction
389*de5d74c2SJerry Jelinek  * with these macros so that "_AcpiFunctionName" is defined.
390*de5d74c2SJerry Jelinek  *
391*de5d74c2SJerry Jelinek  * There are two versions of most of the return macros. The default version is
392*de5d74c2SJerry Jelinek  * safer, since it avoids side-effects by guaranteeing that the argument will
393*de5d74c2SJerry Jelinek  * not be evaluated twice.
394*de5d74c2SJerry Jelinek  *
395*de5d74c2SJerry Jelinek  * A less-safe version of the macros is provided for optional use if the
396*de5d74c2SJerry Jelinek  * compiler uses excessive CPU stack (for example, this may happen in the
397*de5d74c2SJerry Jelinek  * debug case if code optimzation is disabled.)
398*de5d74c2SJerry Jelinek  */
399*de5d74c2SJerry Jelinek 
400*de5d74c2SJerry Jelinek /* Exit trace helper macro */
401*de5d74c2SJerry Jelinek 
402*de5d74c2SJerry Jelinek #ifndef ACPI_SIMPLE_RETURN_MACROS
403*de5d74c2SJerry Jelinek 
404*de5d74c2SJerry Jelinek #define ACPI_TRACE_EXIT(Function, Type, Param) \
405*de5d74c2SJerry Jelinek     ACPI_DO_WHILE0 ({ \
406*de5d74c2SJerry Jelinek         register Type _Param = (Type) (Param); \
407*de5d74c2SJerry Jelinek         Function (ACPI_DEBUG_PARAMETERS, _Param); \
408*de5d74c2SJerry Jelinek         return (_Param); \
409*de5d74c2SJerry Jelinek     })
410*de5d74c2SJerry Jelinek 
411*de5d74c2SJerry Jelinek #else /* Use original less-safe macros */
412*de5d74c2SJerry Jelinek 
413*de5d74c2SJerry Jelinek #define ACPI_TRACE_EXIT(Function, Type, Param) \
414*de5d74c2SJerry Jelinek     ACPI_DO_WHILE0 ({ \
415*de5d74c2SJerry Jelinek         Function (ACPI_DEBUG_PARAMETERS, (Type) (Param)); \
416*de5d74c2SJerry Jelinek         return (Param); \
417*de5d74c2SJerry Jelinek     })
418*de5d74c2SJerry Jelinek 
419*de5d74c2SJerry Jelinek #endif /* ACPI_SIMPLE_RETURN_MACROS */
420*de5d74c2SJerry Jelinek 
421*de5d74c2SJerry Jelinek /* The actual exit macros */
422*de5d74c2SJerry Jelinek 
423*de5d74c2SJerry Jelinek #define return_VOID \
424*de5d74c2SJerry Jelinek     ACPI_DO_WHILE0 ({ \
425*de5d74c2SJerry Jelinek         AcpiUtExit (ACPI_DEBUG_PARAMETERS); \
426*de5d74c2SJerry Jelinek         return; \
427*de5d74c2SJerry Jelinek     })
428*de5d74c2SJerry Jelinek 
429*de5d74c2SJerry Jelinek #define return_ACPI_STATUS(Status) \
430*de5d74c2SJerry Jelinek     ACPI_TRACE_EXIT (AcpiUtStatusExit, ACPI_STATUS, Status)
431*de5d74c2SJerry Jelinek 
432*de5d74c2SJerry Jelinek #define return_PTR(Pointer) \
433*de5d74c2SJerry Jelinek     ACPI_TRACE_EXIT (AcpiUtPtrExit, void *, Pointer)
434*de5d74c2SJerry Jelinek 
435*de5d74c2SJerry Jelinek #define return_STR(String) \
436*de5d74c2SJerry Jelinek     ACPI_TRACE_EXIT (AcpiUtStrExit, const char *, String)
437*de5d74c2SJerry Jelinek 
438*de5d74c2SJerry Jelinek #define return_VALUE(Value) \
439*de5d74c2SJerry Jelinek     ACPI_TRACE_EXIT (AcpiUtValueExit, UINT64, Value)
440*de5d74c2SJerry Jelinek 
441*de5d74c2SJerry Jelinek #define return_UINT32(Value) \
442*de5d74c2SJerry Jelinek     ACPI_TRACE_EXIT (AcpiUtValueExit, UINT32, Value)
443*de5d74c2SJerry Jelinek 
444*de5d74c2SJerry Jelinek #define return_UINT8(Value) \
445*de5d74c2SJerry Jelinek     ACPI_TRACE_EXIT (AcpiUtValueExit, UINT8, Value)
446*de5d74c2SJerry Jelinek 
447*de5d74c2SJerry Jelinek /* Conditional execution */
448*de5d74c2SJerry Jelinek 
449*de5d74c2SJerry Jelinek #define ACPI_DEBUG_EXEC(a)              a
450*de5d74c2SJerry Jelinek #define ACPI_DEBUG_ONLY_MEMBERS(a)      a;
451*de5d74c2SJerry Jelinek #define _VERBOSE_STRUCTURES
452*de5d74c2SJerry Jelinek 
453*de5d74c2SJerry Jelinek 
454*de5d74c2SJerry Jelinek /* Various object display routines for debug */
455*de5d74c2SJerry Jelinek 
456*de5d74c2SJerry Jelinek #define ACPI_DUMP_STACK_ENTRY(a)        AcpiExDumpOperand((a), 0)
457*de5d74c2SJerry Jelinek #define ACPI_DUMP_OPERANDS(a, b ,c)     AcpiExDumpOperands(a, b, c)
458*de5d74c2SJerry Jelinek #define ACPI_DUMP_ENTRY(a, b)           AcpiNsDumpEntry (a, b)
459*de5d74c2SJerry Jelinek #define ACPI_DUMP_PATHNAME(a, b, c, d)  AcpiNsDumpPathname(a, b, c, d)
460*de5d74c2SJerry Jelinek #define ACPI_DUMP_BUFFER(a, b)          AcpiUtDebugDumpBuffer((UINT8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
461*de5d74c2SJerry Jelinek 
462*de5d74c2SJerry Jelinek #define ACPI_TRACE_POINT(a, b, c, d)    AcpiTracePoint (a, b, c, d)
463*de5d74c2SJerry Jelinek 
464*de5d74c2SJerry Jelinek #else /* ACPI_DEBUG_OUTPUT */
465aa2aa9a6SDana Myers /*
466aa2aa9a6SDana Myers  * This is the non-debug case -- make everything go away,
467aa2aa9a6SDana Myers  * leaving no executable debug code!
468aa2aa9a6SDana Myers  */
469aa2aa9a6SDana Myers #define ACPI_DEBUG_PRINT(pl)
470aa2aa9a6SDana Myers #define ACPI_DEBUG_PRINT_RAW(pl)
471*de5d74c2SJerry Jelinek #define ACPI_DEBUG_EXEC(a)
472*de5d74c2SJerry Jelinek #define ACPI_DEBUG_ONLY_MEMBERS(a)
473*de5d74c2SJerry Jelinek #define ACPI_FUNCTION_NAME(a)
474*de5d74c2SJerry Jelinek #define ACPI_FUNCTION_TRACE(a)
475*de5d74c2SJerry Jelinek #define ACPI_FUNCTION_TRACE_PTR(a, b)
476*de5d74c2SJerry Jelinek #define ACPI_FUNCTION_TRACE_U32(a, b)
477*de5d74c2SJerry Jelinek #define ACPI_FUNCTION_TRACE_STR(a, b)
478*de5d74c2SJerry Jelinek #define ACPI_FUNCTION_ENTRY()
479*de5d74c2SJerry Jelinek #define ACPI_DUMP_STACK_ENTRY(a)
480*de5d74c2SJerry Jelinek #define ACPI_DUMP_OPERANDS(a, b, c)
481*de5d74c2SJerry Jelinek #define ACPI_DUMP_ENTRY(a, b)
482*de5d74c2SJerry Jelinek #define ACPI_DUMP_PATHNAME(a, b, c, d)
483*de5d74c2SJerry Jelinek #define ACPI_DUMP_BUFFER(a, b)
484*de5d74c2SJerry Jelinek #define ACPI_IS_DEBUG_ENABLED(Level, Component) 0
485*de5d74c2SJerry Jelinek #define ACPI_TRACE_POINT(a, b, c, d)
486*de5d74c2SJerry Jelinek 
487*de5d74c2SJerry Jelinek /* Return macros must have a return statement at the minimum */
488*de5d74c2SJerry Jelinek 
489*de5d74c2SJerry Jelinek #define return_VOID                     return
490*de5d74c2SJerry Jelinek #define return_ACPI_STATUS(s)           return(s)
491*de5d74c2SJerry Jelinek #define return_PTR(s)                   return(s)
492*de5d74c2SJerry Jelinek #define return_STR(s)                   return(s)
493*de5d74c2SJerry Jelinek #define return_VALUE(s)                 return(s)
494*de5d74c2SJerry Jelinek #define return_UINT8(s)                 return(s)
495*de5d74c2SJerry Jelinek #define return_UINT32(s)                return(s)
496aa2aa9a6SDana Myers 
497aa2aa9a6SDana Myers #endif /* ACPI_DEBUG_OUTPUT */
498aa2aa9a6SDana Myers 
499aa2aa9a6SDana Myers 
5007c478bd9Sstevel@tonic-gate #endif /* __ACOUTPUT_H__ */
501