Home | History | Annotate | Line # | Download | only in tx
tx39var.h revision 1.2
      1 /*	$NetBSD: tx39var.h,v 1.2 1999/12/22 15:35:35 uch Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1999, by UCHIYAMA Yasushi
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. The name of the developer may NOT be used to endorse or promote products
     13  *    derived from this software without specific prior written permission.
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25  * SUCH DAMAGE.
     26  *
     27  */
     28 
     29 struct tx_chipset_tag {
     30 	void *tc_intrt;  /* interrupt tag */
     31 	void *tc_powert; /* power/clock tag */
     32 };
     33 
     34 typedef struct tx_chipset_tag* tx_chipset_tag_t;
     35 typedef u_int32_t txreg_t;
     36 
     37 /*
     38  *	TX39 Internal Function Register access
     39  */
     40 #define TX39_SYSADDR_CONFIG_REG_KSEG1	0xb0c00000
     41 
     42 #ifdef TX39_PREFER_FUNCTION
     43 
     44 tx_chipset_tag_t tx_conf_get_tag __P((void));
     45 u_int32_t	 tx_conf_read __P((tx_chipset_tag_t, int));
     46 void		 tx_conf_write __P((tx_chipset_tag_t, int, txreg_t));
     47 
     48 #else /* TX39_PREFER_FUNCTION */
     49 
     50 extern struct tx_chipset_tag tx_chipset;
     51 #define tx_conf_read(t, reg) ((void)(t), \
     52 	(*((volatile txreg_t*)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg)))))
     53 #define tx_conf_write(t, reg, val) ((void)(t), \
     54 	(*((volatile txreg_t*)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg))) \
     55 	= (val)))
     56 #define tx_conf_get_tag() (&tx_chipset)
     57 
     58 #endif /* TX39_PREFER_FUNCTION */
     59 
     60 /*
     61  *	txsim attach arguments. (txsim ... TX System Internal Module)
     62  */
     63 struct txsimbus_attach_args {
     64 	char *tba_busname;
     65 };
     66 
     67 /*
     68  *	txsim module attach arguments.
     69  */
     70 struct txsim_attach_args {
     71 	tx_chipset_tag_t ta_tc; /* Chipset tag */
     72 };
     73 
     74 /*
     75  *	Interrupt staff
     76  */
     77 #define MAKEINTR(s, b) ((s) * 32 + (ffs(b) - 1))
     78 void*	tx_intr_establish __P((tx_chipset_tag_t, int, int, int, int (*) __P((void*)),	void*));
     79 void	tx_intr_disestablish __P((tx_chipset_tag_t, void*));
     80 #ifdef USE_POLL
     81 void*	tx39_poll_establish __P((tx_chipset_tag_t, int, int, int, int (*) __P((void*)),	void*));
     82 void	tx39_poll_disestablish __P((tx_chipset_tag_t, void*));
     83 #endif /* USE_POLL */
     84 void	tx_conf_register_intr __P((tx_chipset_tag_t, void*));
     85 
     86 #ifdef TX39_DEBUG
     87 extern u_int32_t tx39debugflag, tx39intrvec;
     88 /*
     89  *	Debugging use.
     90  */
     91 #define __bitdisp(a, s, e, m, c)					\
     92 ({									\
     93 	u_int32_t __j, __j1;						\
     94 	int __i, __s, __e, __n;						\
     95 	__n = sizeof(typeof(a)) * NBBY - 1;				\
     96 	__j1 = 1 << __n;						\
     97 	__e = e ? e : __n;						\
     98 	__s = s;							\
     99 	for (__j = __j1, __i = __n; __j > 0; __j >>=1, __i--) {		\
    100 		if (__i > __e || __i < __s) {				\
    101 			printf("%c", a & __j ? '+' : '-');		\
    102 		} else {						\
    103 			printf("%c", a & __j ? '|' : '.');		\
    104 		}							\
    105 	}								\
    106 	if (m) {							\
    107 		printf("[%s]", (char*)m);				\
    108 	}								\
    109 	if (c) {							\
    110 		for (__j = __j1, __i = __n; __j > 0; __j >>=1, __i--) {	\
    111 			if (!(__i > __e || __i < __s) && (a & __j)) {	\
    112 				printf(" %d", __i);			\
    113 			}						\
    114 		}							\
    115 	}								\
    116 	printf("\n");							\
    117 })
    118 #define bitdisp(a) __bitdisp(a, 0, 0, 0, 1)
    119 #else /* TX39_DEBUG */
    120 #define __bitdisp(a, s, e, m, c)
    121 #define bitdisp(a)
    122 #endif /* TX39_DEBUG */
    123 
    124 int	__is_set_print __P((u_int32_t, int, char*));
    125