debug.h revision 1.11 1 1.11 uwe /* $NetBSD: debug.h,v 1.11 2010/08/09 23:07:20 uwe Exp $ */
2 1.1 uch
3 1.1 uch /*-
4 1.1 uch * Copyright (c) 1999-2002 The NetBSD Foundation, Inc.
5 1.1 uch * All rights reserved.
6 1.1 uch *
7 1.1 uch * This code is derived from software contributed to The NetBSD Foundation
8 1.1 uch * by UCHIYAMA Yasushi.
9 1.1 uch *
10 1.1 uch * Redistribution and use in source and binary forms, with or without
11 1.1 uch * modification, are permitted provided that the following conditions
12 1.1 uch * are met:
13 1.1 uch * 1. Redistributions of source code must retain the above copyright
14 1.1 uch * notice, this list of conditions and the following disclaimer.
15 1.1 uch * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 uch * notice, this list of conditions and the following disclaimer in the
17 1.1 uch * documentation and/or other materials provided with the distribution.
18 1.1 uch *
19 1.1 uch * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 uch * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 uch * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 uch * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 uch * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 uch * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 uch * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 uch * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 uch * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 uch * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 uch * POSSIBILITY OF SUCH DAMAGE.
30 1.1 uch */
31 1.1 uch
32 1.1 uch /*
33 1.1 uch * debug version exports all symbols.
34 1.1 uch */
35 1.1 uch #ifdef DEBUG
36 1.1 uch #define STATIC
37 1.1 uch #else
38 1.1 uch #define STATIC static
39 1.1 uch #endif
40 1.1 uch
41 1.1 uch /*
42 1.1 uch * printf control
43 1.1 uch * sample:
44 1.1 uch * #ifdef FOO_DEBUG
45 1.1 uch * #define DPRINTF_ENABLE
46 1.1 uch * #define DPRINTF_DEBUG foo_debug
47 1.1 uch * #define DPRINTF_LEVEL 2
48 1.1 uch * #endif
49 1.1 uch */
50 1.1 uch #ifdef USE_HPC_DPRINTF
51 1.11 uwe
52 1.1 uch #ifdef DPRINTF_ENABLE
53 1.11 uwe
54 1.1 uch #ifndef DPRINTF_DEBUG
55 1.11 uwe #error "specify unique debug variable"
56 1.1 uch #endif
57 1.11 uwe
58 1.1 uch #ifndef DPRINTF_LEVEL
59 1.1 uch #define DPRINTF_LEVEL 1
60 1.1 uch #endif
61 1.11 uwe
62 1.11 uwe int DPRINTF_DEBUG = DPRINTF_LEVEL;
63 1.1 uch #endif /* DPRINTF_ENABLE */
64 1.1 uch
65 1.11 uwe
66 1.11 uwe #ifdef __DPRINTF_EXT
67 1.11 uwe /*
68 1.11 uwe * printf with function name prepended
69 1.11 uwe */
70 1.11 uwe
71 1.11 uwe #define PRINTF(fmt, args...) do { \
72 1.11 uwe printf("%s: " fmt, __func__ , ##args); \
73 1.11 uwe } while (/* CONSTCOND */0)
74 1.11 uwe
75 1.11 uwe #ifdef DPRINTF_ENABLE
76 1.11 uwe
77 1.11 uwe #define DPRINTF(fmt, args...) do { \
78 1.11 uwe if (DPRINTF_DEBUG) \
79 1.11 uwe PRINTF(fmt, ##args); \
80 1.11 uwe } while (/* CONSTCOND */0)
81 1.11 uwe
82 1.11 uwe #define _DPRINTF(fmt, args...) do { \
83 1.11 uwe if (DPRINTF_DEBUG) \
84 1.11 uwe printf(fmt, ##args); \
85 1.11 uwe } while (/* CONSTCOND */0)
86 1.11 uwe
87 1.11 uwe #define DPRINTFN(n, fmt, args...) do { \
88 1.11 uwe if (DPRINTF_DEBUG > (n)) \
89 1.11 uwe PRINTF(fmt, ##args); \
90 1.11 uwe } while (/* CONSTCOND */0)
91 1.11 uwe
92 1.11 uwe #define _DPRINTFN(n, fmt, args...) do { \
93 1.11 uwe if (DPRINTF_DEBUG > (n)) \
94 1.11 uwe printf(fmt, ##args); \
95 1.11 uwe } while (/* CONSTCOND */0)
96 1.11 uwe
97 1.11 uwe #else /* !DPRINTF_ENABLE */
98 1.11 uwe #define DPRINTF(args...) do {} while (/* CONSTCOND */ 0)
99 1.11 uwe #define _DPRINTF(args...) do {} while (/* CONSTCOND */ 0)
100 1.11 uwe #define DPRINTFN(n, args...) do {} while (/* CONSTCOND */ 0)
101 1.11 uwe #define _DPRINTFN(n, args...) do {} while (/* CONSTCOND */ 0)
102 1.11 uwe #endif /* !DPRINTF_ENABLE */
103 1.11 uwe
104 1.11 uwe #else /* !__DPRINTF_EXT */
105 1.1 uch /*
106 1.1 uch * normal debug printf
107 1.1 uch */
108 1.11 uwe
109 1.1 uch #ifdef DPRINTF_ENABLE
110 1.1 uch
111 1.11 uwe #define DPRINTF(arg) do { \
112 1.11 uwe if (DPRINTF_DEBUG) \
113 1.11 uwe printf arg; \
114 1.11 uwe } while (/* CONSTCOND */0)
115 1.11 uwe
116 1.11 uwe #define DPRINTFN(n, arg) do { \
117 1.11 uwe if (DPRINTF_DEBUG > (n)) \
118 1.11 uwe printf arg; \
119 1.11 uwe } while (/* CONSTCOND */0)
120 1.11 uwe
121 1.11 uwe #else /* !DPRINTF_ENABLE */
122 1.11 uwe #define DPRINTF(arg) do {} while (/* CONSTCOND */ 0)
123 1.11 uwe #define DPRINTFN(n, arg) do {} while (/* CONSTCOND */ 0)
124 1.11 uwe #endif /* !DPRINTF_ENABLE */
125 1.11 uwe
126 1.11 uwe #endif /* !__DPRINT_EXT */
127 1.1 uch #endif /* USE_HPC_DPRINTF */
128 1.1 uch
129 1.11 uwe
130 1.1 uch /*
131 1.1 uch * debug print utility
132 1.1 uch */
133 1.4 takemura #define DBG_BIT_PRINT_COUNT (1 << 0)
134 1.4 takemura #define DBG_BIT_PRINT_QUIET (1 << 1)
135 1.11 uwe
136 1.11 uwe void __dbg_bit_print(uint32_t, int, int, int, const char *, int);
137 1.11 uwe
138 1.11 uwe #define dbg_bit_print(a) do { \
139 1.11 uwe __dbg_bit_print((a), sizeof(typeof(a)), 0, 0, NULL, \
140 1.11 uwe DBG_BIT_PRINT_COUNT); \
141 1.11 uwe } while (/* CONSTCOND */0)
142 1.11 uwe
143 1.11 uwe #define dbg_bit_print_msg(a, m) do { \
144 1.11 uwe __dbg_bit_print((a), sizeof(typeof(a)), 0, 0, (m), \
145 1.11 uwe DBG_BIT_PRINT_COUNT); \
146 1.11 uwe } while (/* CONSTCOND */0)
147 1.11 uwe
148 1.11 uwe #define dbg_bit_display(a) do { \
149 1.11 uwe __dbg_bit_print((a), sizeof(typeof(a)), 0, 0, NULL, \
150 1.11 uwe DBG_BIT_PRINT_QUIET); \
151 1.11 uwe } while (/* CONSTCOND */0)
152 1.11 uwe
153 1.11 uwe void dbg_bitmask_print(uint32_t, uint32_t, const char *);
154 1.1 uch void dbg_draw_line(int);
155 1.1 uch void dbg_banner_title(const char *, size_t);
156 1.1 uch void dbg_banner_line(void);
157 1.11 uwe
158 1.11 uwe #define dbg_banner_function() do { \
159 1.11 uwe dbg_banner_title(__func__, sizeof(__func__) - 1); \
160 1.11 uwe } while (/* CONSTCOND */ 0)
161 1.3 uch
162 1.3 uch /* HPC_DEBUG_LCD */
163 1.3 uch #define RGB565_BLACK 0x0000
164 1.3 uch #define RGB565_RED 0xf800
165 1.3 uch #define RGB565_GREEN 0x07e0
166 1.3 uch #define RGB565_YELLOW 0xffe0
167 1.3 uch #define RGB565_BLUE 0x001f
168 1.3 uch #define RGB565_MAGENTA 0xf81f
169 1.3 uch #define RGB565_CYAN 0x07ff
170 1.3 uch #define RGB565_WHITE 0xffff
171 1.3 uch
172 1.3 uch void dbg_lcd_test(void);
173