1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
/* $NetBSD: tc.c,v 1.6 1995/12/28 06:44:57 jonathan Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <sys/param.h>
#include <sys/device.h>
#include <machine/autoconf.h>
#ifdef alpha
#include <machine/rpb.h>
#include <alpha/tc/tc.h>
#endif
#ifdef pmax
#include <pmax/tc/tc.h>
#endif
struct tc_softc {
struct device sc_dv;
struct abus sc_bus;
struct tc_cpu_desc *sc_desc;
};
/* Definition of the driver for autoconfig. */
int tcmatch(struct device *, void *, void *);
void tcattach(struct device *, struct device *, void *);
int tcprint(void *, char *);
struct cfdriver tccd =
{ NULL, "tc", tcmatch, tcattach, DV_DULL, sizeof (struct tc_softc) };
void tc_intr_establish __P((struct confargs *, intr_handler_t handler,
intr_arg_t));
void tc_intr_disestablish __P((struct confargs *));
caddr_t tc_cvtaddr __P((struct confargs *));
int tc_matchname __P((struct confargs *, char *));
extern int cputype;
/*XXX*/ /* should be in separate source file */
/*
* tc config structures for DECstations.
* Since there will never be new decstations, we just
* bash it in here, for now.
*/
#include <machine/machConst.h>
#include <pmax/pmax/pmaxtype.h>
#include <pmax/pmax/trap.h>
#include <pmax/pmax/asic.h>
#include <pmax/pmax/kn03.h>
#include <pmax/pmax/kn02.h>
#include <pmax/pmax/kmin.h>
#include <pmax/pmax/maxine.h>
#include <pmax/pmax/turbochannel.h>
#include <pmax/pmax/nameglue.h>
void tc_ds_ioasic_intr_setup __P((void));
void tc_ds_ioasic_intr_establish
__P((struct confargs *, intr_handler_t, void *));
void tc_ds_ioasic_intr_disestablish __P((struct confargs *));
void tc_ds_ioasic_iointr __P((void *, int));
int tc_ds_ioasic_getdev __P((struct confargs *));
/* XXX*/
/* should be handled elsewhere? */
typedef void (*tc_enable_t) __P ((u_int slotno, intr_handler_t,
void *intr_arg, int on));
typedef int (*tc_handler_t) __P((void *intr_arg));
extern void (*tc_enable_interrupt) __P ((u_int slotno, tc_handler_t,
void *intr_arg, int on));
extern void kn03_enable_intr __P((u_int slot, tc_handler_t,
void *intr_arg, int on));
extern void kn02_enable_intr __P ((u_int slot, tc_handler_t,
void *intr_arg, int on));
extern void kmin_enable_intr __P ((u_int slot, tc_handler_t,
void *intr_arg, int on));
extern void xine_enable_intr __P ((u_int slot, tc_handler_t,
void *intr_arg, int on));
/*
* configuration tables for the four models of
* Decstation that have turbochannels.
* None of the four are the same.
*/
#include "ds-tc-conf.c"
/*
* Mapping from CPU type to a tc_cpu_desc for that CPU type.
* (Alpha-specific.)
*/
struct tc_cpu_desc *tc_cpu_devs[] = {
NULL, /* Unused */
NULL, /* ST_ADU */
NULL, /* ST_DEC_4000 */
NULL, /* ST_DEC_7000 */
#ifdef DEC_3000_500
&dec_3000_500_cpu, /* ST_DEC_3000_500 */
#else
NULL,
#endif
NULL, /* Unused */
NULL, /* ST_DEC_2000_300 */
#ifdef DEC_3000_300
&dec_3000_300_cpu, /* ST_DEC_3000_300 */
#else
NULL,
#endif
};
int ntc_cpu_devs = sizeof tc_cpu_devs / sizeof tc_cpu_devs[0];
/*
* Function to map from a CPU code to a tc_cpu_desc.
* This hould really be in machine-dependent code, where
* it could even be a macro.
*/
struct tc_cpu_desc *
cpu_tcdesc(cpu)
int cpu;
{
/*XXX*/
#ifdef pmax
if (cpu == DS_3MAXPLUS) {
tc_enable_interrupt = kn03_enable_intr;
return &kn03_tc_desc;
} else if (cpu == DS_3MAX) {
tc_enable_interrupt = kn02_enable_intr;
return &kn02_tc_desc;
} else if (cpu == DS_3MIN) {
DPRINTF(("tcattach: 3MIN Turbochannel\n"));
tc_enable_interrupt = kmin_enable_intr;
return &kmin_tc_desc;
} else if (cpu == DS_MAXINE) {
DPRINTF(("MAXINE turbochannel\n"));
tc_enable_interrupt = xine_enable_intr;
return &xine_tc_desc;
} else if (cpu == DS_PMAX) {
DPRINTF(("tcattach: PMAX, no turbochannel\n"));
return NULL;
} else if (cpu == DS_MIPSFAIR) {
DPRINTF(("tcattach: Mipsfair (5100), no turbochannel\n"));
} else {
panic("tcattach: Unrecognized bus type 0x%x\n", cpu);
}
#else /* alpha?*/
return tc_cpu_devs[cputype];
#endif /* alpha?*/
}
int
tcmatch(parent, cfdata, aux)
struct device *parent;
void *cfdata;
void *aux;
{
struct cfdata *cf = cfdata;
struct confargs *ca = aux;
/* Make sure that we're looking for a TC. */
if (strcmp(ca->ca_name, tccd.cd_name) != 0)
return (0);
/* Make sure that unit exists. */
if (cf->cf_unit != 0 ||
#ifdef pmax
0
#else
cputype > ntc_cpu_devs || tc_cpu_devs[cputype] == NULL
#endif
)
return (0);
return (1);
}
/*
* Attach a turbochannel bus. Once the turbochannel is attached,
* search recursively for a system slot (which contains registers
* for baseboard devices in "subslots"), and for "real" on-board or
* option turbochannel slots (that have their own turbochannel ROM
* signature.
*/
void
tcattach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct tc_softc *sc = (struct tc_softc *)self;
struct confargs *nca;
char namebuf[TC_ROM_LLEN+1];
int i;
printf("\n");
/* keep our CPU description handy */
sc->sc_desc = cpu_tcdesc(cputype);
#ifndef pmax /*XXX*/
/* set up interrupt handlers */
(*sc->sc_desc->tc_intr_setup)();
set_iointr(sc->sc_desc->tc_iointr);
#endif /*!PMAX*/
sc->sc_bus.ab_dv = (struct device *)sc;
sc->sc_bus.ab_type = BUS_TC;
sc->sc_bus.ab_intr_establish = tc_intr_establish;
sc->sc_bus.ab_intr_disestablish = tc_intr_disestablish;
sc->sc_bus.ab_cvtaddr = tc_cvtaddr;
sc->sc_bus.ab_matchname = tc_matchname;
if (sc->sc_desc == NULL)
return;
/* Try to configure each turbochannel (or CPU-internal) device */
for (i = 0; i < sc->sc_desc->tcd_ndevs; i++) {
nca = &sc->sc_desc->tcd_devs[i];
if (nca == NULL) {
printf("tcattach: bad config for slot %d\n", i);
break;
}
nca->ca_bus = &sc->sc_bus;
#if defined(DIAGNOSTIC) || defined(DEBUG)
if (nca->ca_slot > sc->sc_desc->tcd_nslots)
panic("tcattach: dev slot > number of slots for %s",
nca->ca_name);
#endif
if (tc_checkdevmem(BUS_CVTADDR(nca)) == 0)
continue;
/* If no name, we have to see what might be there. */
if (nca->ca_name == NULL) {
if (tc_checkslot(BUS_CVTADDR(nca), namebuf) == 0)
continue;
nca->ca_name = namebuf;
}
/* Tell the autoconfig machinery we've found the hardware. */
config_found(self, nca, tcprint);
}
}
int
tcprint(aux, pnp)
void *aux;
char *pnp;
{
struct confargs *ca = aux;
if (pnp)
printf("%s at %s", ca->ca_name, pnp);
printf(" slot %ld offset 0x%lx", ca->ca_slot, ca->ca_offset);
return (UNCONF);
}
caddr_t
tc_cvtaddr(ca)
struct confargs *ca;
{
struct tc_softc *sc = tccd.cd_devs[0];
return (sc->sc_desc->tcd_slots[ca->ca_slot].tsd_dense + ca->ca_offset);
}
void
tc_intr_establish(ca, handler, val)
struct confargs *ca;
intr_handler_t handler;
intr_arg_t val;
{
struct tc_softc *sc = tccd.cd_devs[0];
(*sc->sc_desc->tc_intr_establish)(ca, handler, val);
}
void
tc_intr_disestablish(ca)
struct confargs *ca;
{
struct tc_softc *sc = tccd.cd_devs[0];
(*sc->sc_desc->tc_intr_disestablish)(ca);
}
int
tc_matchname(ca, name)
struct confargs *ca;
char *name;
{
return (bcmp(name, ca->ca_name, TC_ROM_LLEN) == 0);
}
int
tc_checkdevmem(addr)
caddr_t addr;
{
u_int32_t *datap = (u_int32_t *) addr;
/* Return non-zero if memory was there (i.e. address wasn't bad). */
return (!badaddr(datap, sizeof (u_int32_t)));
}
u_int tc_slot_romoffs[] = { TC_SLOT_ROM, TC_SLOT_PROTOROM };
int ntc_slot_romoffs = sizeof tc_slot_romoffs / sizeof tc_slot_romoffs[0];
int
tc_checkslot(addr, namep)
caddr_t addr;
char *namep;
{
struct tc_rommap *romp;
int i, j;
for (i = 0; i < ntc_slot_romoffs; i++) {
romp = (struct tc_rommap *)
(addr + tc_slot_romoffs[i]);
switch (romp->tcr_width.v) {
case 1:
case 2:
case 4:
break;
default:
continue;
}
if (romp->tcr_stride.v != 4)
continue;
for (j = 0; j < 4; j++)
if (romp->tcr_test[j+0*romp->tcr_stride.v] != 0x55 ||
romp->tcr_test[j+1*romp->tcr_stride.v] != 0x00 ||
romp->tcr_test[j+2*romp->tcr_stride.v] != 0xaa ||
romp->tcr_test[j+3*romp->tcr_stride.v] != 0xff)
continue;
for (j = 0; j < TC_ROM_LLEN; j++)
namep[j] = romp->tcr_modname[j].v;
namep[TC_ROM_LLEN] = '\0';
return (1);
}
return (0);
}
int
tc_intrnull(val)
void *val;
{
panic("uncaught TC intr for slot %ld\n", (long)val);
}
/* hack for kn03 */
void
tc_ds_ioasic_intr_setup ()
{
printf("not setting up TC intrs\n");
}
void
tc_ds_ioasic_intr_establish(ca, handler, val)
struct confargs *ca;
intr_handler_t handler;
void *val;
{
int unit = (int) val;
if (BUS_MATCHNAME(ca, "IOCTL ")) {
printf("(no interrupt for asic");
return;
}
/* The kn02 doesn't really have an ASIC */
if (BUS_MATCHNAME(ca, KN02_ASIC_NAME)) {
printf("(no interrupt for proto-asic)\n");
return;
}
/* Never tested on these processors */
if (cputype == DS_3MIN || cputype == DS_MAXINE)
printf("tc_enable %s%d slot %d\n",
ca->ca_name, (int)unit, ca->ca_slotpri);
#ifdef DIAGNOSTIC
if (tc_enable_interrupt == NULL)
panic("tc_intr_establish: tc_enable not set\n");
#endif
(*tc_enable_interrupt) (ca->ca_slotpri, handler, (void*)unit, 1);
}
void
tc_ds_ioasic_intr_disestablish(args)
struct confargs *args;
{
/*(*tc_enable_interrupt) (ca->ca_slot, handler, 0);*/
printf("cannot dis-establish TC intrs\n");
}
void
tc_ds_ioasic_iointr (framep, vec)
void * framep;
int vec;
{
printf("bogus interrupt handler\n");
}
|