1 /* $NetBSD: tx39var.h,v 1.3 2000/01/03 18:24:05 uch Exp $ */ 2 3 /* 4 * Copyright (c) 1999, 2000 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 tag */ 32 void *tc_clockt; /* clock/timer tag */ 33 }; 34 35 typedef struct tx_chipset_tag* tx_chipset_tag_t; 36 typedef u_int32_t txreg_t; 37 38 void tx_conf_register_intr __P((tx_chipset_tag_t, void*)); 39 void tx_conf_register_power __P((tx_chipset_tag_t, void*)); 40 void tx_conf_register_clock __P((tx_chipset_tag_t, void*)); 41 42 /* 43 * TX39 Internal Function Register access 44 */ 45 #define TX39_SYSADDR_CONFIG_REG_KSEG1 0xb0c00000 46 47 #ifdef TX39_PREFER_FUNCTION 48 49 tx_chipset_tag_t tx_conf_get_tag __P((void)); 50 u_int32_t tx_conf_read __P((tx_chipset_tag_t, int)); 51 void tx_conf_write __P((tx_chipset_tag_t, int, txreg_t)); 52 53 #else /* TX39_PREFER_FUNCTION */ 54 55 extern struct tx_chipset_tag tx_chipset; 56 #define tx_conf_read(t, reg) ((void)(t), \ 57 (*((volatile txreg_t*)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg))))) 58 #define tx_conf_write(t, reg, val) ((void)(t), \ 59 (*((volatile txreg_t*)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg))) \ 60 = (val))) 61 #define tx_conf_get_tag() (&tx_chipset) 62 63 #endif /* TX39_PREFER_FUNCTION */ 64 65 /* 66 * txsim attach arguments. (txsim ... TX System Internal Module) 67 */ 68 struct txsimbus_attach_args { 69 char *tba_busname; 70 }; 71 72 /* 73 * txsim module attach arguments. 74 */ 75 struct txsim_attach_args { 76 tx_chipset_tag_t ta_tc; /* Chipset tag */ 77 }; 78 79 /* 80 * Interrupt staff 81 */ 82 #define MAKEINTR(s, b) ((s) * 32 + (ffs(b) - 1)) 83 void* tx_intr_establish __P((tx_chipset_tag_t, int, int, int, int (*) __P((void*)), void*)); 84 void tx_intr_disestablish __P((tx_chipset_tag_t, void*)); 85 86 #ifdef USE_POLL 87 void* tx39_poll_establish __P((tx_chipset_tag_t, int, int, int (*) __P((void*)), void*)); 88 void tx39_poll_disestablish __P((tx_chipset_tag_t, void*)); 89 #define POLL_CONT 0 90 #define POLL_END 1 91 #endif /* USE_POLL */ 92 93 #ifdef TX39_DEBUG 94 extern u_int32_t tx39debugflag, tx39intrvec; 95 /* 96 * Debugging use. 97 */ 98 #define __bitdisp(a, s, e, m, c) \ 99 ({ \ 100 u_int32_t __j, __j1; \ 101 int __i, __s, __e, __n; \ 102 __n = sizeof(typeof(a)) * NBBY - 1; \ 103 __j1 = 1 << __n; \ 104 __e = e ? e : __n; \ 105 __s = s; \ 106 for (__j = __j1, __i = __n; __j > 0; __j >>=1, __i--) { \ 107 if (__i > __e || __i < __s) { \ 108 printf("%c", a & __j ? '+' : '-'); \ 109 } else { \ 110 printf("%c", a & __j ? '|' : '.'); \ 111 } \ 112 } \ 113 if (m) { \ 114 printf("[%s]", (char*)m); \ 115 } \ 116 if (c) { \ 117 for (__j = __j1, __i = __n; __j > 0; __j >>=1, __i--) { \ 118 if (!(__i > __e || __i < __s) && (a & __j)) { \ 119 printf(" %d", __i); \ 120 } \ 121 } \ 122 } \ 123 printf("\n"); \ 124 }) 125 #define bitdisp(a) __bitdisp(a, 0, 0, 0, 1) 126 #else /* TX39_DEBUG */ 127 #define __bitdisp(a, s, e, m, c) 128 #define bitdisp(a) 129 #endif /* TX39_DEBUG */ 130 131 int __is_set_print __P((u_int32_t, int, char*)); 132