Home | History | Annotate | Line # | Download | only in include
debug.h revision 1.3
      1 /*	$NetBSD: debug.h,v 1.3 2002/02/13 16:25:33 uch 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(a) __dbg_bit_print((a), sizeof(typeof(a)), 0, 0, 0, 1)
    107 #define dbg_bit_print_msg(a, m)						\
    108 	__dbg_bit_print((a), sizeof(typeof(a)), 0, 0, (m), 1)
    109 void __dbg_bit_print(u_int32_t, int, int, int, char *, int);
    110 void dbg_bitmask_print(u_int32_t, u_int32_t, const char *);
    111 void dbg_draw_line(int);
    112 void dbg_banner_title(const char *, size_t);
    113 void dbg_banner_line(void);
    114 #define dbg_banner_function()						\
    115 {									\
    116 	const char funcname[] = __FUNCTION__;				\
    117 	dbg_banner_title(funcname, sizeof funcname);			\
    118 }
    119 
    120 /* HPC_DEBUG_LCD */
    121 #define RGB565_BLACK		0x0000
    122 #define RGB565_RED		0xf800
    123 #define RGB565_GREEN		0x07e0
    124 #define RGB565_YELLOW		0xffe0
    125 #define RGB565_BLUE		0x001f
    126 #define RGB565_MAGENTA		0xf81f
    127 #define RGB565_CYAN		0x07ff
    128 #define RGB565_WHITE		0xffff
    129 
    130 void dbg_lcd_test(void);
    131