1 /* $NetBSD: debug.h,v 1.9 2008/04/28 20:23:20 martin 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 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * debug version exports all symbols. 34 */ 35 #ifdef DEBUG 36 #define STATIC 37 #else 38 #define STATIC static 39 #endif 40 41 /* 42 * printf control 43 * sample: 44 * #ifdef FOO_DEBUG 45 * #define DPRINTF_ENABLE 46 * #define DPRINTF_DEBUG foo_debug 47 * #define DPRINTF_LEVEL 2 48 * #endif 49 */ 50 #ifdef USE_HPC_DPRINTF 51 #ifdef __DPRINTF_EXT 52 /* 53 * debug printf with Function name 54 */ 55 #define PRINTF(fmt, args...) printf("%s: " fmt, __func__ , ##args) 56 #ifdef DPRINTF_ENABLE 57 #ifndef DPRINTF_DEBUG 58 #error "specify unique debug symbol" 59 #endif 60 #ifndef DPRINTF_LEVEL 61 #define DPRINTF_LEVEL 1 62 #endif 63 int DPRINTF_DEBUG = DPRINTF_LEVEL; 64 #define DPRINTF(fmt, args...) if (DPRINTF_DEBUG) PRINTF(fmt, ##args) 65 #define _DPRINTF(fmt, args...) if (DPRINTF_DEBUG) printf(fmt, ##args) 66 #define DPRINTFN(n, fmt, args...) \ 67 if (DPRINTF_DEBUG > (n)) PRINTF(fmt, ##args) 68 #define _DPRINTFN(n, fmt, args...) \ 69 if (DPRINTF_DEBUG > (n)) printf(fmt, ##args) 70 #else /* DPRINTF_ENABLE */ 71 #define DPRINTF(args...) ((void)0) 72 #define _DPRINTF(args...) ((void)0) 73 #define DPRINTFN(n, args...) ((void)0) 74 #define _DPRINTFN(n, args...) ((void)0) 75 #endif /* DPRINTF_ENABLE */ 76 77 #else /* __DPRINTF_EXT */ 78 /* 79 * normal debug printf 80 */ 81 #ifdef DPRINTF_ENABLE 82 #ifndef DPRINTF_DEBUG 83 #error "specify unique debug symbol" 84 #endif 85 #ifndef DPRINTF_LEVEL 86 #define DPRINTF_LEVEL 1 87 #endif 88 int DPRINTF_DEBUG = DPRINTF_LEVEL; 89 #define DPRINTF(arg) if (DPRINTF_DEBUG) printf arg 90 #define DPRINTFN(n, arg) if (DPRINTF_DEBUG > (n)) printf arg 91 #else /* DPRINTF_ENABLE */ 92 #define DPRINTF(arg) ((void)0) 93 #define DPRINTFN(n, arg) ((void)0) 94 #endif /* DPRINTF_ENABLE */ 95 96 #endif /* __DPRINT_EXT */ 97 #endif /* USE_HPC_DPRINTF */ 98 99 /* 100 * debug print utility 101 */ 102 #define DBG_BIT_PRINT_COUNT (1 << 0) 103 #define DBG_BIT_PRINT_QUIET (1 << 1) 104 #define dbg_bit_print(a) \ 105 __dbg_bit_print((a), sizeof(typeof(a)), 0, 0, 0, DBG_BIT_PRINT_COUNT) 106 #define dbg_bit_print_msg(a, m) \ 107 __dbg_bit_print((a), sizeof(typeof(a)), 0, 0, (m), DBG_BIT_PRINT_COUNT) 108 #define dbg_bit_display(a) \ 109 __dbg_bit_print((a), sizeof(typeof(a)), 0, 0, 0, DBG_BIT_PRINT_QUIET) 110 void __dbg_bit_print(u_int32_t, int, int, int, const char *, int); 111 void dbg_bitmask_print(u_int32_t, u_int32_t, const char *); 112 void dbg_draw_line(int); 113 void dbg_banner_title(const char *, size_t); 114 void dbg_banner_line(void); 115 #define dbg_banner_function() \ 116 { \ 117 const char funcname[] = __func__; \ 118 dbg_banner_title(funcname, sizeof funcname); \ 119 } 120 121 /* HPC_DEBUG_LCD */ 122 #define RGB565_BLACK 0x0000 123 #define RGB565_RED 0xf800 124 #define RGB565_GREEN 0x07e0 125 #define RGB565_YELLOW 0xffe0 126 #define RGB565_BLUE 0x001f 127 #define RGB565_MAGENTA 0xf81f 128 #define RGB565_CYAN 0x07ff 129 #define RGB565_WHITE 0xffff 130 131 void dbg_lcd_test(void); 132