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
|
/* $OpenBSD: vxtbus.c,v 1.3 2010/09/20 06:33:48 matthew Exp $ */
/*
* Copyright (c) 2006 Miodrag Vallat.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice, this permission notice, and the disclaimer below
* appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/evcount.h>
#include <sys/queue.h>
#include <machine/cpu.h>
#include <machine/nexus.h>
#include <machine/scb.h>
#include <vax/vxt/vxtbusvar.h>
struct vxtbus_softc {
struct device sc_dev;
LIST_HEAD(, vxtbus_ih) sc_intrlist;
};
void vxtbus_attach(struct device *, struct device *, void *);
int vxtbus_match(struct device *, void*, void *);
struct cfdriver vxtbus_cd = {
NULL, "vxtbus", DV_DULL
};
struct cfattach vxtbus_ca = {
sizeof(struct vxtbus_softc), vxtbus_match, vxtbus_attach
};
void vxtbus_intr(void *);
int vxtbus_print(void *, const char *);
int
vxtbus_match(struct device *parent, void *vcf, void *aux)
{
struct mainbus_attach_args *maa = aux;
return (maa->maa_bustype == VAX_VXTBUS ? 1 : 0);
}
void
vxtbus_attach(struct device *parent, struct device *self, void *aux)
{
struct vxtbus_softc *sc = (void *)self;
struct bp_conf bp;
LIST_INIT(&sc->sc_intrlist);
scb_vecalloc(VXT_INTRVEC, vxtbus_intr, sc, SCB_ISTACK, NULL);
printf("\n");
bp.type = "sgec";
config_found(self, &bp, vxtbus_print);
bp.type = "qsc";
config_found(self, &bp, vxtbus_print);
bp.type = "lcspx";
config_found(self, &bp, vxtbus_print);
}
int
vxtbus_print(void *aux, const char *name)
{
struct bp_conf *bp = aux;
if (name)
printf("%s at %s", bp->type, name);
return (UNCONF);
}
/*
* VXT2000 interrupt code.
*
* All device interrupts end up on the same vector, which is controllable
* by the SC26C94 chip.
*
* Interrupts are handled at spl4 (ipl 0x14).
*
* The following routines implement shared interrupts for vxtbus subdevices.
*/
struct vxtbus_ih {
LIST_ENTRY(vxtbus_ih) ih_link;
int (*ih_fn)(void *);
void * ih_arg;
int ih_vec;
struct evcount ih_cnt;
};
void
vxtbus_intr_establish(const char *name, int ipl, int (*fn)(void *), void *arg)
{
struct vxtbus_softc *sc = (void *)vxtbus_cd.cd_devs[0];
struct vxtbus_ih *ih;
ih = (struct vxtbus_ih *)malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
ih->ih_fn = fn;
ih->ih_arg = arg;
ih->ih_vec = VXT_INTRVEC;
evcount_attach(&ih->ih_cnt, name, &ih->ih_vec);
LIST_INSERT_HEAD(&sc->sc_intrlist, ih, ih_link);
}
void
vxtbus_intr(void *arg)
{
struct vxtbus_softc *sc = arg;
struct vxtbus_ih *ih;
int rc;
#ifdef DIAGNOSTIC
int handled = 0;
static int strayintr = 0;
#endif
LIST_FOREACH(ih, &sc->sc_intrlist, ih_link) {
rc = (*ih->ih_fn)(ih->ih_arg);
if (rc != 0) {
#ifdef DIAGNOSTIC
handled = 1;
#endif
ih->ih_cnt.ec_count++;
if (rc > 0)
break;
}
}
#ifdef DIAGNOSTIC
if (handled == 0) {
if (++strayintr == 10)
panic("%s: too many stray interrupts",
sc->sc_dev.dv_xname);
else
printf("%s: stray interrupt\n", sc->sc_dev.dv_xname);
}
#endif
}
|