Home | History | Annotate | Line # | Download | only in include
debug.h revision 1.8.10.2
      1  1.8.10.2      yamt /*	$NetBSD: debug.h,v 1.8.10.2 2010/08/11 22:52:03 yamt 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.8.10.2      yamt 
     52       1.1       uch #ifdef DPRINTF_ENABLE
     53  1.8.10.2      yamt 
     54       1.1       uch #ifndef DPRINTF_DEBUG
     55  1.8.10.2      yamt #error "specify unique debug variable"
     56       1.1       uch #endif
     57  1.8.10.2      yamt 
     58       1.1       uch #ifndef DPRINTF_LEVEL
     59       1.1       uch #define DPRINTF_LEVEL	1
     60       1.1       uch #endif
     61  1.8.10.2      yamt 
     62  1.8.10.2      yamt int DPRINTF_DEBUG = DPRINTF_LEVEL;
     63       1.1       uch #endif /* DPRINTF_ENABLE */
     64       1.1       uch 
     65  1.8.10.2      yamt 
     66  1.8.10.2      yamt #ifdef __DPRINTF_EXT
     67  1.8.10.2      yamt /*
     68  1.8.10.2      yamt  * printf with function name prepended
     69  1.8.10.2      yamt  */
     70  1.8.10.2      yamt 
     71  1.8.10.2      yamt #define	PRINTF(fmt, args...)	do {			\
     72  1.8.10.2      yamt 		printf("%s: " fmt, __func__ , ##args);	\
     73  1.8.10.2      yamt 	} while (/* CONSTCOND */0)
     74  1.8.10.2      yamt 
     75  1.8.10.2      yamt #ifdef DPRINTF_ENABLE
     76  1.8.10.2      yamt 
     77  1.8.10.2      yamt #define	DPRINTF(fmt, args...)	do {		\
     78  1.8.10.2      yamt 		if (DPRINTF_DEBUG)		\
     79  1.8.10.2      yamt 			PRINTF(fmt, ##args);	\
     80  1.8.10.2      yamt 	} while (/* CONSTCOND */0)
     81  1.8.10.2      yamt 
     82  1.8.10.2      yamt #define	_DPRINTF(fmt, args...)	do {		\
     83  1.8.10.2      yamt 		if (DPRINTF_DEBUG)		\
     84  1.8.10.2      yamt 			printf(fmt, ##args);	\
     85  1.8.10.2      yamt 	} while (/* CONSTCOND */0)
     86  1.8.10.2      yamt 
     87  1.8.10.2      yamt #define DPRINTFN(n, fmt, args...)	do {	\
     88  1.8.10.2      yamt 		if (DPRINTF_DEBUG > (n))	\
     89  1.8.10.2      yamt 			PRINTF(fmt, ##args);	\
     90  1.8.10.2      yamt 	} while (/* CONSTCOND */0)
     91  1.8.10.2      yamt 
     92  1.8.10.2      yamt #define _DPRINTFN(n, fmt, args...) do {		\
     93  1.8.10.2      yamt 		if (DPRINTF_DEBUG > (n))	\
     94  1.8.10.2      yamt 			printf(fmt, ##args);	\
     95  1.8.10.2      yamt 	} while (/* CONSTCOND */0)
     96  1.8.10.2      yamt 
     97  1.8.10.2      yamt #else  /* !DPRINTF_ENABLE */
     98  1.8.10.2      yamt #define	DPRINTF(args...)	do {} while (/* CONSTCOND */ 0)
     99  1.8.10.2      yamt #define	_DPRINTF(args...)	do {} while (/* CONSTCOND */ 0)
    100  1.8.10.2      yamt #define DPRINTFN(n, args...)	do {} while (/* CONSTCOND */ 0)
    101  1.8.10.2      yamt #define _DPRINTFN(n, args...)	do {} while (/* CONSTCOND */ 0)
    102  1.8.10.2      yamt #endif /* !DPRINTF_ENABLE */
    103  1.8.10.2      yamt 
    104  1.8.10.2      yamt #else  /* !__DPRINTF_EXT */
    105       1.1       uch /*
    106       1.1       uch  * normal debug printf
    107       1.1       uch  */
    108  1.8.10.2      yamt 
    109       1.1       uch #ifdef DPRINTF_ENABLE
    110       1.1       uch 
    111  1.8.10.2      yamt #define	DPRINTF(arg)	do {			\
    112  1.8.10.2      yamt 		if (DPRINTF_DEBUG)		\
    113  1.8.10.2      yamt 			printf arg;		\
    114  1.8.10.2      yamt 	} while (/* CONSTCOND */0)
    115  1.8.10.2      yamt 
    116  1.8.10.2      yamt #define DPRINTFN(n, arg)	do {		\
    117  1.8.10.2      yamt 		if (DPRINTF_DEBUG > (n))	\
    118  1.8.10.2      yamt 			printf arg;		\
    119  1.8.10.2      yamt 	} while (/* CONSTCOND */0)
    120  1.8.10.2      yamt 
    121  1.8.10.2      yamt #else  /* !DPRINTF_ENABLE */
    122  1.8.10.2      yamt #define	DPRINTF(arg)		do {} while (/* CONSTCOND */ 0)
    123  1.8.10.2      yamt #define DPRINTFN(n, arg)	do {} while (/* CONSTCOND */ 0)
    124  1.8.10.2      yamt #endif /* !DPRINTF_ENABLE */
    125  1.8.10.2      yamt 
    126  1.8.10.2      yamt #endif /* !__DPRINT_EXT */
    127       1.1       uch #endif /* USE_HPC_DPRINTF */
    128       1.1       uch 
    129  1.8.10.2      yamt 
    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.8.10.2      yamt 
    136  1.8.10.2      yamt void __dbg_bit_print(uint32_t, int, int, int, const char *, int);
    137  1.8.10.2      yamt 
    138  1.8.10.2      yamt #define dbg_bit_print(a) do {						\
    139  1.8.10.2      yamt 		__dbg_bit_print((a), sizeof(typeof(a)), 0, 0, NULL,	\
    140  1.8.10.2      yamt 			DBG_BIT_PRINT_COUNT);				\
    141  1.8.10.2      yamt 	} while (/* CONSTCOND */0)
    142  1.8.10.2      yamt 
    143  1.8.10.2      yamt #define dbg_bit_print_msg(a, m) do {					\
    144  1.8.10.2      yamt 		__dbg_bit_print((a), sizeof(typeof(a)), 0, 0, (m),	\
    145  1.8.10.2      yamt 			DBG_BIT_PRINT_COUNT);				\
    146  1.8.10.2      yamt 	} while (/* CONSTCOND */0)
    147  1.8.10.2      yamt 
    148  1.8.10.2      yamt #define dbg_bit_display(a) do {						\
    149  1.8.10.2      yamt 		__dbg_bit_print((a), sizeof(typeof(a)), 0, 0, NULL,	\
    150  1.8.10.2      yamt 			DBG_BIT_PRINT_QUIET);				\
    151  1.8.10.2      yamt 	} while (/* CONSTCOND */0)
    152  1.8.10.2      yamt 
    153  1.8.10.2      yamt 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.8.10.2      yamt 
    158  1.8.10.2      yamt #define dbg_banner_function() do {					\
    159  1.8.10.2      yamt 		dbg_banner_title(__func__, sizeof(__func__) - 1);	\
    160  1.8.10.2      yamt 	} 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