Home | History | Annotate | Line # | Download | only in include
debug.h revision 1.4.10.2
      1 /*	$NetBSD: debug.h,v 1.4.10.2 2004/09/18 14:34:39 skrll 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 #define _DPRINTFN(n, fmt, args...)					\
     76 			   	if (DPRINTF_DEBUG > (n)) printf(fmt, ##args)
     77 #else /* DPRINTF_ENABLE */
     78 #define	DPRINTF(args...)	((void)0)
     79 #define	_DPRINTF(args...)	((void)0)
     80 #define DPRINTFN(n, args...)	((void)0)
     81 #define _DPRINTFN(n, args...)	((void)0)
     82 #endif /* DPRINTF_ENABLE */
     83 
     84 #else	/* __DPRINTF_EXT */
     85 /*
     86  * normal debug printf
     87  */
     88 #ifdef DPRINTF_ENABLE
     89 #ifndef DPRINTF_DEBUG
     90 #error "specify unique debug symbol"
     91 #endif
     92 #ifndef DPRINTF_LEVEL
     93 #define DPRINTF_LEVEL	1
     94 #endif
     95 int	DPRINTF_DEBUG = DPRINTF_LEVEL;
     96 #define	DPRINTF(arg)		if (DPRINTF_DEBUG) printf arg
     97 #define DPRINTFN(n, arg)	if (DPRINTF_DEBUG > (n)) printf arg
     98 #else /* DPRINTF_ENABLE */
     99 #define	DPRINTF(arg)		((void)0)
    100 #define DPRINTFN(n, arg)	((void)0)
    101 #endif /* DPRINTF_ENABLE */
    102 
    103 #endif /* __DPRINT_EXT */
    104 #endif /* USE_HPC_DPRINTF */
    105 
    106 /*
    107  * debug print utility
    108  */
    109 #define DBG_BIT_PRINT_COUNT	(1 << 0)
    110 #define DBG_BIT_PRINT_QUIET	(1 << 1)
    111 #define dbg_bit_print(a)						\
    112 	__dbg_bit_print((a), sizeof(typeof(a)), 0, 0, 0, DBG_BIT_PRINT_COUNT)
    113 #define dbg_bit_print_msg(a, m)						\
    114 	__dbg_bit_print((a), sizeof(typeof(a)), 0, 0, (m), DBG_BIT_PRINT_COUNT)
    115 #define dbg_bit_display(a)						\
    116 	__dbg_bit_print((a), sizeof(typeof(a)), 0, 0, 0, DBG_BIT_PRINT_QUIET)
    117 void __dbg_bit_print(u_int32_t, int, int, int, char *, int);
    118 void dbg_bitmask_print(u_int32_t, u_int32_t, const char *);
    119 void dbg_draw_line(int);
    120 void dbg_banner_title(const char *, size_t);
    121 void dbg_banner_line(void);
    122 #define dbg_banner_function()						\
    123 {									\
    124 	const char funcname[] = __FUNCTION__;				\
    125 	dbg_banner_title(funcname, sizeof funcname);			\
    126 }
    127 
    128 /* HPC_DEBUG_LCD */
    129 #define RGB565_BLACK		0x0000
    130 #define RGB565_RED		0xf800
    131 #define RGB565_GREEN		0x07e0
    132 #define RGB565_YELLOW		0xffe0
    133 #define RGB565_BLUE		0x001f
    134 #define RGB565_MAGENTA		0xf81f
    135 #define RGB565_CYAN		0x07ff
    136 #define RGB565_WHITE		0xffff
    137 
    138 void dbg_lcd_test(void);
    139