xref: /netbsd/sys/arch/hpc/include/debug.h (revision bf9ec67e)
1 /*	$NetBSD: debug.h,v 1.4 2002/05/03 07:31:24 takemura Exp $	*/
2 
3 /*-
4  * Copyright (c) 1999-2002 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by UCHIYAMA Yasushi.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 /*
40  * debug version exports all symbols.
41  */
42 #ifdef DEBUG
43 #define STATIC
44 #else
45 #define STATIC static
46 #endif
47 
48 /*
49  * printf control
50  *	sample:
51  * #ifdef FOO_DEBUG
52  * #define DPRINTF_ENABLE
53  * #define DPRINTF_DEBUG	foo_debug
54  * #define DPRINTF_LEVEL	2
55  * #endif
56  */
57 #ifdef USE_HPC_DPRINTF
58 #ifdef __DPRINTF_EXT
59 /*
60  * debug printf with Function name
61  */
62 #define	PRINTF(fmt, args...)	printf("%s: " fmt, __FUNCTION__ , ##args)
63 #ifdef DPRINTF_ENABLE
64 #ifndef DPRINTF_DEBUG
65 #error "specify unique debug symbol"
66 #endif
67 #ifndef DPRINTF_LEVEL
68 #define DPRINTF_LEVEL	1
69 #endif
70 int	DPRINTF_DEBUG = DPRINTF_LEVEL;
71 #define	DPRINTF(fmt, args...)	if (DPRINTF_DEBUG) PRINTF(fmt, ##args)
72 #define	_DPRINTF(fmt, args...)	if (DPRINTF_DEBUG) printf(fmt, ##args)
73 #define DPRINTFN(n, fmt, args...)					\
74 			   	if (DPRINTF_DEBUG > (n)) PRINTF(fmt, ##args)
75 #else /* DPRINTF_ENABLE */
76 #define	DPRINTF(args...)	((void)0)
77 #define	_DPRINTF(args...)	((void)0)
78 #define DPRINTFN(n, args...)	((void)0)
79 #endif /* DPRINTF_ENABLE */
80 
81 #else	/* __DPRINTF_EXT */
82 /*
83  * normal debug printf
84  */
85 #ifdef DPRINTF_ENABLE
86 #ifndef DPRINTF_DEBUG
87 #error "specify unique debug symbol"
88 #endif
89 #ifndef DPRINTF_LEVEL
90 #define DPRINTF_LEVEL	1
91 #endif
92 int	DPRINTF_DEBUG = DPRINTF_LEVEL;
93 #define	DPRINTF(arg)		if (DPRINTF_DEBUG) printf arg
94 #define DPRINTFN(n, arg)	if (DPRINTF_DEBUG > (n)) printf arg
95 #else /* DPRINTF_ENABLE */
96 #define	DPRINTF(arg)		((void)0)
97 #define DPRINTFN(n, arg)	((void)0)
98 #endif /* DPRINTF_ENABLE */
99 
100 #endif /* __DPRINT_EXT */
101 #endif /* USE_HPC_DPRINTF */
102 
103 /*
104  * debug print utility
105  */
106 #define DBG_BIT_PRINT_COUNT	(1 << 0)
107 #define DBG_BIT_PRINT_QUIET	(1 << 1)
108 #define dbg_bit_print(a)						\
109 	__dbg_bit_print((a), sizeof(typeof(a)), 0, 0, 0, DBG_BIT_PRINT_COUNT)
110 #define dbg_bit_print_msg(a, m)						\
111 	__dbg_bit_print((a), sizeof(typeof(a)), 0, 0, (m), DBG_BIT_PRINT_COUNT)
112 #define dbg_bit_display(a)						\
113 	__dbg_bit_print((a), sizeof(typeof(a)), 0, 0, 0, DBG_BIT_PRINT_QUIET)
114 void __dbg_bit_print(u_int32_t, int, int, int, char *, int);
115 void dbg_bitmask_print(u_int32_t, u_int32_t, const char *);
116 void dbg_draw_line(int);
117 void dbg_banner_title(const char *, size_t);
118 void dbg_banner_line(void);
119 #define dbg_banner_function()						\
120 {									\
121 	const char funcname[] = __FUNCTION__;				\
122 	dbg_banner_title(funcname, sizeof funcname);			\
123 }
124 
125 /* HPC_DEBUG_LCD */
126 #define RGB565_BLACK		0x0000
127 #define RGB565_RED		0xf800
128 #define RGB565_GREEN		0x07e0
129 #define RGB565_YELLOW		0xffe0
130 #define RGB565_BLUE		0x001f
131 #define RGB565_MAGENTA		0xf81f
132 #define RGB565_CYAN		0x07ff
133 #define RGB565_WHITE		0xffff
134 
135 void dbg_lcd_test(void);
136