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