xref: /illumos-gate/usr/src/uts/intel/io/dktp/hba/ghd/ghd_debug.h (revision a4955f4fa65e38d70c07d38e657a9aff43fa155f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _GHD_DEBUG_H
28 #define	_GHD_DEBUG_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/varargs.h>
35 
36 /*PRINTFLIKE1*/
37 extern void ghd_err(const char *fmt, ...) __PRINTFLIKE(1);
38 extern ulong_t ghd_debug_flags;
39 
40 #define	GDBG_FLAG_ERROR		0x0001
41 #define	GDBG_FLAG_INTR		0x0002
42 #define	GDBG_FLAG_PEND_INTR	0x0004
43 #define	GDBG_FLAG_START		0x0008
44 #define	GDBG_FLAG_WARN		0x0010
45 #define	GDBG_FLAG_DMA		0x0020
46 #define	GDBG_FLAG_PKT		0x0040
47 #define	GDBG_FLAG_INIT		0x0080
48 #define	GDBG_FLAG_WAITQ		0x0100
49 
50 /*
51  * Use prom_printf() or vcmn_err()
52  */
53 #ifdef GHD_DEBUG_PROM_PRINTF
54 #define	GDBG_PRF(fmt)	prom_printf fmt
55 #include <sys/promif.h>
56 #else
57 #define	GDBG_PRF(fmt)	ghd_err fmt
58 #endif
59 
60 #if defined(GHD_DEBUG) || defined(__lint)
61 
62 #define	GDBG_FLAG_CHK(flag, fmt) if (ghd_debug_flags & (flag)) GDBG_PRF(fmt)
63 
64 #else	/* GHD_DEBUG || __lint */
65 
66 #define	GDBG_FLAG_CHK(flag, fmt)
67 
68 #endif	/* GHD_DEBUG || __lint */
69 
70 /*
71  * Always print "real" error messages on non-debugging kernels
72  */
73 
74 #if defined(GHD_DEBUG) || defined(__lint)
75 #define	GDBG_ERROR(fmt)		GDBG_FLAG_CHK(GDBG_FLAG_ERROR, fmt)
76 #else
77 #define	GDBG_ERROR(fmt)	ghd_err fmt
78 #endif
79 
80 /*
81  * Debugging printf macros
82  */
83 
84 #define	GDBG_INTR(fmt)		GDBG_FLAG_CHK(GDBG_FLAG_INTR, fmt)
85 #define	GDBG_PEND_INTR(fmt)	GDBG_FLAG_CHK(GDBG_FLAG_PEND_INTR, fmt)
86 #define	GDBG_START(fmt)		GDBG_FLAG_CHK(GDBG_FLAG_START, fmt)
87 #define	GDBG_WARN(fmt)		GDBG_FLAG_CHK(GDBG_FLAG_WARN, fmt)
88 #define	GDBG_DMA(fmt)		GDBG_FLAG_CHK(GDBG_FLAG_DMA, fmt)
89 #define	GDBG_PKT(fmt)		GDBG_FLAG_CHK(GDBG_FLAG_PKT, fmt)
90 #define	GDBG_INIT(fmt)		GDBG_FLAG_CHK(GDBG_FLAG_INIT, fmt)
91 #define	GDBG_WAITQ(fmt)		GDBG_FLAG_CHK(GDBG_FLAG_WAITQ, fmt)
92 
93 #ifdef	__cplusplus
94 }
95 #endif
96 
97 #endif /* _GHD_DEBUG_H */
98