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