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