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