tx39var.h revision 1.1 1 /* $NetBSD: tx39var.h,v 1.1 1999/11/20 19:56:39 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 #define TX39_PREFER_FUNCTION
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 #ifdef TX39_PREFER_FUNCTION
42 tx_chipset_tag_t tx_conf_get_tag __P((void));
43 u_int32_t tx_conf_read __P((tx_chipset_tag_t, int));
44 void tx_conf_write __P((tx_chipset_tag_t, int, txreg_t));
45 #else /* TX39_PREFER_FUNCTION */
46 extern struct tx_chipset_tag tx_chipset;
47 #define tx_conf_read(t, reg) ((void)(t), \
48 (*((txreg_t*)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg)))))
49 #define tx_conf_write(t, reg, val) ((void)(t), \
50 (*((txreg_t*)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg))) = (val)))
51 #define tx_conf_get_tag() (&tx_chipset)
52 #endif /* TX39_PREFER_FUNCTION */
53
54 /*
55 * txsim attach arguments. (txsim ... TX System Internal Module)
56 */
57 struct txsimbus_attach_args {
58 char *tba_busname;
59 };
60
61 /*
62 * txsim module attach arguments.
63 */
64 struct txsim_attach_args {
65 tx_chipset_tag_t ta_tc; /* Chipset tag */
66 };
67
68 /*
69 * Interrupt staff
70 */
71 #define MAKEINTR(s, b) ((s) * 32 + (ffs(b) - 1))
72 void* tx_intr_establish __P((tx_chipset_tag_t, int, int, int, int (*) __P((void*)), void*));
73 void tx_intr_disestablish __P((tx_chipset_tag_t, void*));
74 #ifdef USE_POLL
75 void* tx39_poll_establish __P((tx_chipset_tag_t, int, int, int, int (*) __P((void*)), void*));
76 void tx39_poll_disestablish __P((tx_chipset_tag_t, void*));
77 #endif /* USE_POLL */
78 void tx_conf_register_intr __P((tx_chipset_tag_t, void*));
79
80 #ifdef TX39_DEBUG
81 extern u_int32_t tx39debugflag, tx39intrvec;
82 /*
83 * Debugging use.
84 */
85 #define __bitdisp(a, s, e, m, c) \
86 ({ \
87 u_int32_t __j, __j1; \
88 int __i, __s, __e, __n; \
89 __n = sizeof(typeof(a)) * NBBY - 1; \
90 __j1 = 1 << __n; \
91 __e = e ? e : __n; \
92 __s = s; \
93 for (__j = __j1, __i = __n; __j > 0; __j >>=1, __i--) { \
94 if (__i > __e || __i < __s) { \
95 printf("%c", a & __j ? '+' : '-'); \
96 } else { \
97 printf("%c", a & __j ? '|' : '.'); \
98 } \
99 } \
100 if (m) { \
101 printf("[%s]", (char*)m); \
102 } \
103 if (c) { \
104 for (__j = __j1, __i = __n; __j > 0; __j >>=1, __i--) { \
105 if (!(__i > __e || __i < __s) && (a & __j)) { \
106 printf(" %d", __i); \
107 } \
108 } \
109 } \
110 printf("\n"); \
111 })
112 #define bitdisp(a) __bitdisp(a, 0, 0, 0, 1)
113 #else /* TX39_DEBUG */
114 #define __bitdisp(a, s, e, m, c)
115 #define bitdisp(a)
116 #endif /* TX39_DEBUG */
117
118 int __is_set_print __P((u_int32_t, int, char*));
119