tc_3000_300.c revision 1.1 1 /* $NetBSD: tc_3000_300.c,v 1.1 1995/03/08 00:39:06 cgd Exp $ */
2
3 /*
4 * Copyright (c) 1994, 1995 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Chris G. Demetriou
8 *
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
28 */
29
30 #include <sys/param.h>
31 #include <sys/device.h>
32
33 #include <machine/autoconf.h>
34 #include <machine/pte.h>
35
36 #include <alpha/tc/tc.h>
37 #include <alpha/tc/tc_3000_300.h>
38
39 /* XXX ESTABLISH, DISESTABLISH */
40 void tc_3000_300_intr_setup __P((void));
41 void tc_3000_300_intr_establish
42 __P((struct confargs *, intr_handler_t, void *));
43 void tc_3000_300_intr_disestablish __P((struct confargs *));
44 void tc_3000_300_iointr __P((void *, int));
45 int tc_3000_300_getdev __P((struct confargs *));
46
47 #define KV(x) ((caddr_t)phystok0seg(x))
48 #define TC_3000_300_NSLOTS 5
49 #define TC_3000_300_MAXDEVS 5
50
51 static struct tc_slot_desc dec_3000_300_slots[TC_3000_300_NSLOTS] = {
52 { KV(0x100000000), }, /* slot 0 - TC option slot 0 */
53 { KV(0x120000000), }, /* slot 1 - TC option slot 1 */
54 { KV(0x180000000), }, /* slot 2 - TCDS ASIC on cpu board */
55 { KV(0x1a0000000), }, /* slot 3 - IOCTL ASIC on cpu board */
56 { KV(0x1c0000000), }, /* slot 4 - CXTurbo on cpu board */
57 };
58
59 static struct confargs dec_3000_300_devs[TC_3000_300_MAXDEVS] = {
60 { "PMAGB-BA", 4, 0x02000000, },
61 { "IOCTL ", 3, 0x00000000, },
62 { "PMAZ-DS ", 2, 0x00000000, },
63 { NULL, 1, 0x0, },
64 { NULL, 0, 0x0, },
65 };
66
67 /* Indices into the struct confargs array. */
68 #define TC_3000_300_DEV_CXTURBO 0
69 #define TC_3000_300_DEV_IOCTL 1
70 #define TC_3000_300_DEV_TCDS 2
71 #define TC_3000_300_DEV_OPT1 3
72 #define TC_3000_300_DEV_OPT0 4
73
74 struct tc_cpu_desc dec_3000_300_cpu = {
75 dec_3000_300_slots, TC_3000_300_NSLOTS,
76 dec_3000_300_devs, TC_3000_300_MAXDEVS,
77 tc_3000_300_intr_setup,
78 tc_3000_300_intr_establish,
79 tc_3000_300_intr_disestablish,
80 tc_3000_300_iointr,
81 };
82
83 intr_handler_t tc_3000_300_intrhand[TC_3000_300_MAXDEVS];
84 void *tc_3000_300_intrval[TC_3000_300_MAXDEVS];
85
86 void
87 tc_3000_300_intr_setup()
88 {
89 int i;
90
91 /* Set up interrupt handlers. */
92 for (i = 0; i < TC_3000_300_MAXDEVS; i++) {
93 tc_3000_300_intrhand[i] = tc_intrnull;
94 tc_3000_300_intrval[i] = (void *)(long)i;
95 }
96 }
97
98 void
99 tc_3000_300_intr_establish(ca, handler, val)
100 struct confargs *ca;
101 int (*handler) __P((void *));
102 void *val;
103 {
104 int dev = tc_3000_300_getdev(ca);
105
106 #ifdef DIAGNOSTIC
107 if (dev == -1)
108 panic("tc_3000_300_intr_establish: dev == -1");
109 #endif
110
111 if (tc_3000_300_intrhand[dev] != tc_intrnull)
112 panic("tc_3000_300_intr_establish: dev %d twice", dev);
113
114 tc_3000_300_intrhand[dev] = handler;
115 tc_3000_300_intrval[dev] = val;
116
117 /* XXX ENABLE INTERRUPT MASK FOR DEV */
118 }
119
120 void
121 tc_3000_300_intr_disestablish(ca)
122 struct confargs *ca;
123 {
124 int dev = tc_3000_300_getdev(ca);
125
126 #ifdef DIAGNOSTIC
127 if (dev == -1)
128 panic("tc_3000_300_intr_disestablish: somebody goofed");
129 #endif
130
131 if (tc_3000_300_intrhand[dev] == tc_intrnull)
132 panic("tc_3000_300_intr_disestablish: dev %d missing intr",
133 dev);
134
135 tc_3000_300_intrhand[dev] = tc_intrnull;
136 tc_3000_300_intrval[dev] = (void *)(long)dev;
137
138 /* XXX DISABLE INTERRUPT MASK FOR DEV */
139 }
140
141 void
142 tc_3000_300_iointr(framep, vec)
143 void *framep;
144 int vec;
145 {
146 u_int32_t ir;
147 int ifound;
148
149 #ifdef DIAGNOSTIC
150 int s;
151 if (vec != 0x800)
152 panic("INVALID ASSUMPTION: vec %x, not 0x800", vec);
153 s = splhigh();
154 if (s != PSL_IPL_IO)
155 panic("INVALID ASSUMPTION: IPL %d, not %d", s, PSL_IPL_IO);
156 splx(s);
157 #endif
158
159 do {
160 MB();
161 MAGIC_READ;
162 MB();
163
164 ifound = 0;
165 #define CHECKINTR(slot, bits) \
166 if (ir & bits) { \
167 ifound = 1; \
168 (*tc_3000_300_intrhand[slot]) \
169 (tc_3000_300_intrval[slot]); \
170 }
171 /* Do them in order of priority; highest slot # first. */
172 CHECKINTR(TC_3000_300_DEV_CXTURBO, TC_3000_300_IR_CXTURBO);
173 CHECKINTR(TC_3000_300_DEV_IOCTL, TC_3000_300_IR_IOCTL);
174 CHECKINTR(TC_3000_300_DEV_TCDS, TC_3000_300_IR_TCDS);
175 #if 0
176 CHECKINTR(TC_3000_300_DEV_OPT1, TC_3000_300_IR_OPT1);
177 CHECKINTR(TC_3000_300_DEV_OPT0, TC_3000_300_IR_OPT0);
178 #else
179 /* XXX XXX XXX CHECK OPTION SLOT INTERRUPTS!!! */
180 #endif
181 #undef CHECKINTR
182
183
184 #ifdef DIAGNOSTIC
185 #define PRINTINTR(msg, bits) \
186 if (ir & bits) \
187 printf(msg);
188 PRINTINTR("BCache tag parity error\n",
189 TC_3000_300_IR_BCTAGPARITY);
190 PRINTINTR("TC overrun error\n", TC_3000_300_IR_TCOVERRUN);
191 PRINTINTR("TC I/O timeout\n", TC_3000_300_IR_TCTIMEOUT);
192 PRINTINTR("Bcache parity error\n",
193 TC_3000_300_IR_BCACHEPARITY);
194 PRINTINTR("Memory parity error\n", TC_3000_300_IR_MEMPARITY);
195 #undef PRINTINTR
196 #endif
197 } while (ifound);
198 }
199
200 int
201 tc_3000_300_getdev(ca)
202 struct confargs *ca;
203 {
204 int i;
205
206 for (i = 0; i < TC_3000_300_MAXDEVS; i++)
207 if (ca->ca_slot == dec_3000_300_devs[i].ca_slot &&
208 ca->ca_offset == dec_3000_300_devs[i].ca_offset &&
209 !strncmp(ca->ca_name, dec_3000_300_devs[i].ca_name))
210 return (i);
211
212 return (-1);
213 }
214