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