uda.c revision 1.29 1 1.28 ragge /* $NetBSD: uda.c,v 1.29 1999/05/29 17:03:17 ragge Exp $ */
2 1.1 ragge /*
3 1.17 ragge * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
4 1.1 ragge * Copyright (c) 1988 Regents of the University of California.
5 1.1 ragge * All rights reserved.
6 1.1 ragge *
7 1.1 ragge * This code is derived from software contributed to Berkeley by
8 1.1 ragge * Chris Torek.
9 1.1 ragge *
10 1.1 ragge * Redistribution and use in source and binary forms, with or without
11 1.1 ragge * modification, are permitted provided that the following conditions
12 1.1 ragge * are met:
13 1.1 ragge * 1. Redistributions of source code must retain the above copyright
14 1.1 ragge * notice, this list of conditions and the following disclaimer.
15 1.1 ragge * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 ragge * notice, this list of conditions and the following disclaimer in the
17 1.1 ragge * documentation and/or other materials provided with the distribution.
18 1.1 ragge * 3. All advertising materials mentioning features or use of this software
19 1.1 ragge * must display the following acknowledgement:
20 1.1 ragge * This product includes software developed by the University of
21 1.1 ragge * California, Berkeley and its contributors.
22 1.1 ragge * 4. Neither the name of the University nor the names of its contributors
23 1.1 ragge * may be used to endorse or promote products derived from this software
24 1.1 ragge * without specific prior written permission.
25 1.1 ragge *
26 1.1 ragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 1.1 ragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 1.1 ragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 1.1 ragge * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 1.1 ragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 1.1 ragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 1.1 ragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 1.1 ragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 1.1 ragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 1.1 ragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 1.1 ragge * SUCH DAMAGE.
37 1.1 ragge *
38 1.3 cgd * @(#)uda.c 7.32 (Berkeley) 2/13/91
39 1.1 ragge */
40 1.1 ragge
41 1.1 ragge /*
42 1.18 ragge * UDA50 disk device driver
43 1.1 ragge */
44 1.1 ragge
45 1.11 mycroft #include <sys/param.h>
46 1.17 ragge #include <sys/kernel.h>
47 1.20 ragge #include <sys/systm.h>
48 1.11 mycroft
49 1.18 ragge #include <machine/sid.h>
50 1.11 mycroft #include <machine/pte.h>
51 1.20 ragge #include <machine/cpu.h>
52 1.1 ragge
53 1.26 ragge #include <vax/uba/ubareg.h>
54 1.18 ragge #include <vax/uba/ubavar.h>
55 1.11 mycroft #include <vax/uba/udareg.h>
56 1.8 ragge
57 1.17 ragge #include <vax/mscp/mscp.h>
58 1.17 ragge #include <vax/mscp/mscpvar.h>
59 1.17 ragge #include <vax/mscp/mscpreg.h>
60 1.1 ragge
61 1.1 ragge /*
62 1.20 ragge * Variants of SIMPLEQ macros for use with buf structs.
63 1.20 ragge */
64 1.20 ragge #define BUFQ_INSERT_TAIL(head, elm) { \
65 1.20 ragge (elm)->b_actf = NULL; \
66 1.20 ragge *(head)->sqh_last = (elm); \
67 1.20 ragge (head)->sqh_last = &(elm)->b_actf; \
68 1.20 ragge }
69 1.20 ragge
70 1.20 ragge #define BUFQ_REMOVE_HEAD(head, elm) { \
71 1.20 ragge if (((head)->sqh_first = (elm)->b_actf) == NULL) \
72 1.20 ragge (head)->sqh_last = &(head)->sqh_first; \
73 1.20 ragge }
74 1.20 ragge
75 1.20 ragge /*
76 1.1 ragge * Software status, per controller.
77 1.1 ragge */
78 1.1 ragge struct uda_softc {
79 1.17 ragge struct device sc_dev; /* Autoconfig info */
80 1.17 ragge struct uba_unit sc_unit; /* Struct common for UBA to communicate */
81 1.20 ragge SIMPLEQ_HEAD(, buf) sc_bufq; /* bufs awaiting for resources */
82 1.17 ragge struct mscp_pack *sc_uuda; /* Unibus address of uda struct */
83 1.17 ragge struct mscp_pack sc_uda; /* Struct for uda communication */
84 1.17 ragge struct udadevice *sc_udadev; /* pointer to ip/sa regs */
85 1.17 ragge struct mscp *sc_mscp; /* Keep pointer to active mscp */
86 1.1 ragge short sc_ipl; /* interrupt priority, Q-bus */
87 1.17 ragge struct mscp_softc *sc_softc; /* MSCP info (per mscpvar.h) */
88 1.1 ragge int sc_wticks; /* watchdog timer ticks */
89 1.17 ragge };
90 1.1 ragge
91 1.28 ragge static int udamatch __P((struct device *, struct cfdata *, void *));
92 1.20 ragge static void udaattach __P((struct device *, struct device *, void *));
93 1.20 ragge static void udareset __P((int));
94 1.20 ragge static void mtcreset __P((int));
95 1.20 ragge static void reset __P((struct uda_softc *));
96 1.20 ragge static void udaintr __P((int));
97 1.20 ragge static void mtcintr __P((int));
98 1.20 ragge static void intr __P((struct uda_softc *));
99 1.20 ragge int udaready __P((struct uba_unit *));
100 1.17 ragge void udactlrdone __P((struct device *, int));
101 1.21 cgd int udaprint __P((void *, const char *));
102 1.17 ragge void udasaerror __P((struct device *, int));
103 1.20 ragge int udago __P((struct device *, struct buf *));
104 1.20 ragge
105 1.27 thorpej extern struct cfdriver mtc_cd;
106 1.20 ragge
107 1.20 ragge struct cfattach mtc_ca = {
108 1.20 ragge sizeof(struct uda_softc), udamatch, udaattach
109 1.20 ragge };
110 1.10 ragge
111 1.27 thorpej extern struct cfdriver uda_cd;
112 1.15 ragge
113 1.15 ragge struct cfattach uda_ca = {
114 1.17 ragge sizeof(struct uda_softc), udamatch, udaattach
115 1.10 ragge };
116 1.10 ragge
117 1.1 ragge /*
118 1.1 ragge * More driver definitions, for generic MSCP code.
119 1.1 ragge */
120 1.17 ragge struct mscp_ctlr uda_mscp_ctlr = {
121 1.17 ragge udactlrdone,
122 1.17 ragge udago,
123 1.17 ragge udasaerror,
124 1.17 ragge };
125 1.1 ragge
126 1.1 ragge /*
127 1.1 ragge * Miscellaneous private variables.
128 1.1 ragge */
129 1.17 ragge static int ivec_no;
130 1.1 ragge
131 1.17 ragge int
132 1.17 ragge udaprint(aux, name)
133 1.17 ragge void *aux;
134 1.21 cgd const char *name;
135 1.17 ragge {
136 1.17 ragge if (name)
137 1.23 christos printf("%s: mscpbus", name);
138 1.17 ragge return UNCONF;
139 1.17 ragge }
140 1.1 ragge
141 1.1 ragge /*
142 1.1 ragge * Poke at a supposed UDA50 to see if it is there.
143 1.1 ragge */
144 1.10 ragge int
145 1.28 ragge udamatch(parent, cf, aux)
146 1.28 ragge struct device *parent;
147 1.28 ragge struct cfdata *cf;
148 1.28 ragge void *aux;
149 1.1 ragge {
150 1.17 ragge struct uba_attach_args *ua = aux;
151 1.18 ragge struct mscp_softc mi; /* Nice hack */
152 1.17 ragge struct uba_softc *ubasc;
153 1.20 ragge int tries;
154 1.20 ragge #if QBA && notyet
155 1.18 ragge extern volatile int rbr;
156 1.1 ragge int s;
157 1.1 ragge #endif
158 1.1 ragge
159 1.17 ragge /* Get an interrupt vector. */
160 1.17 ragge ubasc = (void *)parent;
161 1.17 ragge ivec_no = ubasc->uh_lastiv - 4;
162 1.1 ragge
163 1.18 ragge mi.mi_sa = &((struct udadevice *)ua->ua_addr)->udasa;
164 1.18 ragge mi.mi_ip = &((struct udadevice *)ua->ua_addr)->udaip;
165 1.1 ragge
166 1.1 ragge /*
167 1.1 ragge * Initialise the controller (partially). The UDA50 programmer's
168 1.1 ragge * manual states that if initialisation fails, it should be retried
169 1.1 ragge * at least once, but after a second failure the port should be
170 1.1 ragge * considered `down'; it also mentions that the controller should
171 1.1 ragge * initialise within ten seconds. Or so I hear; I have not seen
172 1.1 ragge * this manual myself.
173 1.1 ragge */
174 1.18 ragge #if 0
175 1.1 ragge s = spl6();
176 1.1 ragge #endif
177 1.1 ragge tries = 0;
178 1.1 ragge again:
179 1.8 ragge
180 1.18 ragge *mi.mi_ip = 0;
181 1.18 ragge if (mscp_waitstep(&mi, MP_STEP1, MP_STEP1) == 0)
182 1.18 ragge return 0; /* Nothing here... */
183 1.8 ragge
184 1.18 ragge *mi.mi_sa = MP_ERR | (NCMDL2 << 11) | (NRSPL2 << 8) | MP_IE |
185 1.17 ragge (ivec_no >> 2);
186 1.8 ragge
187 1.18 ragge if (mscp_waitstep(&mi, MP_STEP2, MP_STEP2) == 0) {
188 1.23 christos printf("udaprobe: init step2 no change. sa=%x\n", *mi.mi_sa);
189 1.8 ragge goto bad;
190 1.8 ragge }
191 1.8 ragge
192 1.1 ragge /* should have interrupted by now */
193 1.18 ragge #if 0
194 1.18 ragge rbr = qbgetpri();
195 1.17 ragge #endif
196 1.28 ragge if (strcmp(cf->cf_driver->cd_name, mtc_cd.cd_name)) {
197 1.20 ragge ua->ua_ivec = udaintr;
198 1.20 ragge ua->ua_reset = udareset;
199 1.20 ragge } else {
200 1.20 ragge ua->ua_ivec = mtcintr;
201 1.20 ragge ua->ua_reset = mtcreset;
202 1.20 ragge }
203 1.20 ragge
204 1.17 ragge return 1;
205 1.1 ragge bad:
206 1.1 ragge if (++tries < 2)
207 1.1 ragge goto again;
208 1.18 ragge #if 0
209 1.1 ragge splx(s);
210 1.1 ragge #endif
211 1.17 ragge return 0;
212 1.1 ragge }
213 1.1 ragge
214 1.17 ragge void
215 1.17 ragge udaattach(parent, self, aux)
216 1.17 ragge struct device *parent, *self;
217 1.17 ragge void *aux;
218 1.1 ragge {
219 1.17 ragge struct uda_softc *sc = (void *)self;
220 1.19 ragge struct uba_attach_args *ua = aux;
221 1.17 ragge struct uba_softc *uh = (void *)parent;
222 1.17 ragge struct mscp_attach_args ma;
223 1.20 ragge int ctlr, ubinfo;
224 1.6 ragge
225 1.23 christos printf("\n");
226 1.1 ragge
227 1.17 ragge uh->uh_lastiv -= 4; /* remove dynamic interrupt vector */
228 1.18 ragge #ifdef QBA
229 1.18 ragge sc->sc_ipl = ua->ua_br;
230 1.18 ragge #endif
231 1.1 ragge
232 1.17 ragge ctlr = sc->sc_dev.dv_unit;
233 1.17 ragge sc->sc_udadev = (struct udadevice *)ua->ua_addr;
234 1.20 ragge SIMPLEQ_INIT(&sc->sc_bufq);
235 1.1 ragge
236 1.1 ragge /*
237 1.17 ragge * Fill in the uba_unit struct, so we can communicate with the uba.
238 1.1 ragge */
239 1.17 ragge sc->sc_unit.uu_softc = sc; /* Backpointer to softc */
240 1.20 ragge sc->sc_unit.uu_ready = udaready;/* go routine called from adapter */
241 1.19 ragge sc->sc_unit.uu_keepbdp = vax_cputype == VAX_750 ? 1 : 0;
242 1.1 ragge
243 1.18 ragge /*
244 1.18 ragge * Map the communication area and command and
245 1.18 ragge * response packets into Unibus space.
246 1.18 ragge */
247 1.20 ragge ubinfo = uballoc((struct uba_softc *)sc->sc_dev.dv_parent,
248 1.20 ragge (caddr_t) &sc->sc_uda, sizeof (struct mscp_pack), UBA_CANTWAIT);
249 1.20 ragge
250 1.20 ragge #ifdef DIAGNOSTIC
251 1.18 ragge if (ubinfo == 0) {
252 1.23 christos printf("%s: uballoc map failed\n", sc->sc_dev.dv_xname);
253 1.18 ragge return;
254 1.1 ragge }
255 1.20 ragge #endif
256 1.18 ragge sc->sc_uuda = (struct mscp_pack *) UBAI_ADDR(ubinfo);
257 1.18 ragge
258 1.17 ragge bzero(&sc->sc_uda, sizeof (struct mscp_pack));
259 1.1 ragge
260 1.20 ragge /*
261 1.20 ragge * The only thing that differ UDA's and Tape ctlr's is
262 1.20 ragge * their vcid. Beacuse there are no way to determine which
263 1.20 ragge * ctlr type it is, we check what is generated and later
264 1.20 ragge * set the correct vcid.
265 1.20 ragge */
266 1.20 ragge ma.ma_type = (strcmp(self->dv_cfdata->cf_driver->cd_name,
267 1.20 ragge mtc_cd.cd_name) ? MSCPBUS_DISK : MSCPBUS_TAPE);
268 1.20 ragge
269 1.17 ragge ma.ma_mc = &uda_mscp_ctlr;
270 1.20 ragge ma.ma_type |= MSCPBUS_UDA;
271 1.17 ragge ma.ma_uuda = sc->sc_uuda;
272 1.17 ragge ma.ma_uda = &sc->sc_uda;
273 1.20 ragge ma.ma_softc = &sc->sc_softc;
274 1.17 ragge ma.ma_ip = &sc->sc_udadev->udaip;
275 1.17 ragge ma.ma_sa = ma.ma_sw = &sc->sc_udadev->udasa;
276 1.17 ragge ma.ma_ivec = ivec_no;
277 1.25 ragge ma.ma_ctlrnr = (ua->ua_iaddr == 0172150 ? 0 : 1); /* XXX */
278 1.18 ragge ma.ma_adapnr = uh->uh_nr;
279 1.17 ragge config_found(&sc->sc_dev, &ma, udaprint);
280 1.17 ragge }
281 1.1 ragge
282 1.20 ragge /*
283 1.20 ragge * Start a transfer if there are free resources available, otherwise
284 1.20 ragge * let it go in udaready, forget it for now.
285 1.20 ragge */
286 1.17 ragge int
287 1.20 ragge udago(usc, bp)
288 1.17 ragge struct device *usc;
289 1.20 ragge struct buf *bp;
290 1.17 ragge {
291 1.17 ragge struct uda_softc *sc = (void *)usc;
292 1.20 ragge struct uba_unit *uu = &sc->sc_unit;
293 1.1 ragge
294 1.20 ragge /*
295 1.20 ragge * If we already are queued for resources, don't call ubaqueue
296 1.20 ragge * again. (Then we would trash the wait queue). Just queue the
297 1.20 ragge * buf and let the rest be done in udaready.
298 1.20 ragge */
299 1.20 ragge if (sc->sc_bufq.sqh_first)
300 1.20 ragge BUFQ_INSERT_TAIL(&sc->sc_bufq, bp)
301 1.20 ragge else {
302 1.20 ragge if (ubaqueue(uu, bp))
303 1.20 ragge mscp_dgo(sc->sc_softc, (UBAI_ADDR(uu->uu_ubinfo) |
304 1.20 ragge (UBAI_BDP(uu->uu_ubinfo) << 24)),uu->uu_ubinfo,bp);
305 1.20 ragge else
306 1.20 ragge BUFQ_INSERT_TAIL(&sc->sc_bufq, bp)
307 1.20 ragge }
308 1.20 ragge
309 1.20 ragge return 0;
310 1.1 ragge }
311 1.1 ragge
312 1.1 ragge /*
313 1.20 ragge * Called if we have been blocked for resources, and resources
314 1.20 ragge * have been freed again. Return 1 if we could start all
315 1.20 ragge * transfers again, 0 if we still are waiting.
316 1.1 ragge */
317 1.20 ragge int
318 1.20 ragge udaready(uu)
319 1.20 ragge struct uba_unit *uu;
320 1.1 ragge {
321 1.17 ragge struct uda_softc *sc = uu->uu_softc;
322 1.20 ragge struct buf *bp;
323 1.17 ragge
324 1.20 ragge while ((bp = sc->sc_bufq.sqh_first)) {
325 1.20 ragge if (ubaqueue(uu, bp)) {
326 1.20 ragge BUFQ_REMOVE_HEAD(&sc->sc_bufq, bp);
327 1.20 ragge mscp_dgo(sc->sc_softc, (UBAI_ADDR(uu->uu_ubinfo) |
328 1.20 ragge (UBAI_BDP(uu->uu_ubinfo) << 24)),uu->uu_ubinfo,bp);
329 1.20 ragge } else
330 1.20 ragge return 0;
331 1.20 ragge }
332 1.20 ragge return 1;
333 1.17 ragge }
334 1.17 ragge
335 1.17 ragge static struct saerr {
336 1.17 ragge int code; /* error code (including UDA_ERR) */
337 1.17 ragge char *desc; /* what it means: Efoo => foo error */
338 1.17 ragge } saerr[] = {
339 1.17 ragge { 0100001, "Eunibus packet read" },
340 1.17 ragge { 0100002, "Eunibus packet write" },
341 1.17 ragge { 0100003, "EUDA ROM and RAM parity" },
342 1.17 ragge { 0100004, "EUDA RAM parity" },
343 1.17 ragge { 0100005, "EUDA ROM parity" },
344 1.17 ragge { 0100006, "Eunibus ring read" },
345 1.17 ragge { 0100007, "Eunibus ring write" },
346 1.17 ragge { 0100010, " unibus interrupt master failure" },
347 1.17 ragge { 0100011, "Ehost access timeout" },
348 1.17 ragge { 0100012, " host exceeded command limit" },
349 1.17 ragge { 0100013, " unibus bus master failure" },
350 1.17 ragge { 0100014, " DM XFC fatal error" },
351 1.17 ragge { 0100015, " hardware timeout of instruction loop" },
352 1.17 ragge { 0100016, " invalid virtual circuit id" },
353 1.17 ragge { 0100017, "Eunibus interrupt write" },
354 1.17 ragge { 0104000, "Efatal sequence" },
355 1.17 ragge { 0104040, " D proc ALU" },
356 1.17 ragge { 0104041, "ED proc control ROM parity" },
357 1.17 ragge { 0105102, "ED proc w/no BD#2 or RAM parity" },
358 1.17 ragge { 0105105, "ED proc RAM buffer" },
359 1.17 ragge { 0105152, "ED proc SDI" },
360 1.17 ragge { 0105153, "ED proc write mode wrap serdes" },
361 1.17 ragge { 0105154, "ED proc read mode serdes, RSGEN & ECC" },
362 1.17 ragge { 0106040, "EU proc ALU" },
363 1.17 ragge { 0106041, "EU proc control reg" },
364 1.17 ragge { 0106042, " U proc DFAIL/cntl ROM parity/BD #1 test CNT" },
365 1.17 ragge { 0106047, " U proc const PROM err w/D proc running SDI test" },
366 1.17 ragge { 0106055, " unexpected trap" },
367 1.17 ragge { 0106071, "EU proc const PROM" },
368 1.17 ragge { 0106072, "EU proc control ROM parity" },
369 1.17 ragge { 0106200, "Estep 1 data" },
370 1.17 ragge { 0107103, "EU proc RAM parity" },
371 1.17 ragge { 0107107, "EU proc RAM buffer" },
372 1.17 ragge { 0107115, " test count wrong (BD 12)" },
373 1.17 ragge { 0112300, "Estep 2" },
374 1.17 ragge { 0122240, "ENPR" },
375 1.17 ragge { 0122300, "Estep 3" },
376 1.17 ragge { 0142300, "Estep 4" },
377 1.17 ragge { 0, " unknown error code" }
378 1.17 ragge };
379 1.6 ragge
380 1.17 ragge /*
381 1.17 ragge * If the error bit was set in the controller status register, gripe,
382 1.17 ragge * then (optionally) reset the controller and requeue pending transfers.
383 1.17 ragge */
384 1.17 ragge void
385 1.17 ragge udasaerror(usc, doreset)
386 1.17 ragge struct device *usc;
387 1.17 ragge int doreset;
388 1.17 ragge {
389 1.17 ragge struct uda_softc *sc = (void *)usc;
390 1.17 ragge register int code = sc->sc_udadev->udasa;
391 1.17 ragge register struct saerr *e;
392 1.1 ragge
393 1.17 ragge if ((code & MP_ERR) == 0)
394 1.1 ragge return;
395 1.17 ragge for (e = saerr; e->code; e++)
396 1.17 ragge if (e->code == code)
397 1.17 ragge break;
398 1.23 christos printf("%s: controller error, sa=0%o (%s%s)\n",
399 1.17 ragge sc->sc_dev.dv_xname, code, e->desc + 1,
400 1.17 ragge *e->desc == 'E' ? " error" : "");
401 1.24 ragge #if 0 /* XXX we just avoid panic when autoconfig non-existent KFQSA devices */
402 1.17 ragge if (doreset) {
403 1.17 ragge mscp_requeue(sc->sc_softc);
404 1.17 ragge /* (void) udainit(sc); XXX */
405 1.1 ragge }
406 1.24 ragge #endif
407 1.1 ragge }
408 1.1 ragge
409 1.1 ragge /*
410 1.17 ragge * Interrupt routine. Depending on the state of the controller,
411 1.17 ragge * continue initialisation, or acknowledge command and response
412 1.17 ragge * interrupts, and process responses.
413 1.1 ragge */
414 1.20 ragge static void
415 1.17 ragge udaintr(ctlr)
416 1.20 ragge int ctlr;
417 1.20 ragge {
418 1.20 ragge intr(uda_cd.cd_devs[ctlr]);
419 1.20 ragge }
420 1.20 ragge
421 1.20 ragge static void
422 1.20 ragge mtcintr(ctlr)
423 1.20 ragge int ctlr;
424 1.20 ragge {
425 1.20 ragge intr(mtc_cd.cd_devs[ctlr]);
426 1.20 ragge }
427 1.20 ragge
428 1.20 ragge static void
429 1.20 ragge intr(sc)
430 1.20 ragge struct uda_softc *sc;
431 1.1 ragge {
432 1.17 ragge volatile struct udadevice *udaddr = sc->sc_udadev;
433 1.17 ragge struct uba_softc *uh;
434 1.17 ragge struct mscp_pack *ud;
435 1.1 ragge
436 1.17 ragge #ifdef QBA
437 1.19 ragge if(vax_cputype == VAX_TYP_UV2)
438 1.17 ragge splx(sc->sc_ipl); /* Qbus interrupt protocol is odd */
439 1.17 ragge #endif
440 1.17 ragge sc->sc_wticks = 0; /* reset interrupt watchdog */
441 1.1 ragge
442 1.17 ragge if (udaddr->udasa & MP_ERR) { /* ctlr fatal error */
443 1.17 ragge udasaerror(&sc->sc_dev, 1);
444 1.17 ragge return;
445 1.17 ragge }
446 1.17 ragge ud = &sc->sc_uda;
447 1.1 ragge /*
448 1.17 ragge * Handle buffer purge requests.
449 1.1 ragge */
450 1.17 ragge uh = (void *)sc->sc_dev.dv_parent;
451 1.17 ragge if (ud->mp_ca.ca_bdp) {
452 1.20 ragge if (uh->uh_ubapurge)
453 1.20 ragge (*uh->uh_ubapurge)(uh, ud->mp_ca.ca_bdp);
454 1.17 ragge ud->mp_ca.ca_bdp = 0;
455 1.17 ragge udaddr->udasa = 0; /* signal purge complete */
456 1.1 ragge }
457 1.1 ragge
458 1.17 ragge mscp_intr(sc->sc_softc);
459 1.1 ragge }
460 1.1 ragge
461 1.1 ragge /*
462 1.17 ragge * A Unibus reset has occurred on UBA uban. Reinitialise the controller(s)
463 1.17 ragge * on that Unibus, and requeue outstanding I/O.
464 1.1 ragge */
465 1.17 ragge void
466 1.17 ragge udareset(ctlr)
467 1.17 ragge int ctlr;
468 1.1 ragge {
469 1.20 ragge reset(uda_cd.cd_devs[ctlr]);
470 1.20 ragge }
471 1.20 ragge
472 1.20 ragge void
473 1.20 ragge mtcreset(ctlr)
474 1.20 ragge int ctlr;
475 1.20 ragge {
476 1.20 ragge reset(mtc_cd.cd_devs[ctlr]);
477 1.20 ragge }
478 1.17 ragge
479 1.20 ragge static void
480 1.20 ragge reset(sc)
481 1.20 ragge struct uda_softc *sc;
482 1.20 ragge {
483 1.23 christos printf(" %s", sc->sc_dev.dv_xname);
484 1.1 ragge
485 1.1 ragge /*
486 1.17 ragge * Our BDP (if any) is gone; our command (if any) is
487 1.17 ragge * flushed; the device is no longer mapped; and the
488 1.17 ragge * UDA50 is not yet initialised.
489 1.1 ragge */
490 1.17 ragge if (sc->sc_unit.uu_bdp) {
491 1.23 christos printf("<%d>", UBAI_BDP(sc->sc_unit.uu_bdp));
492 1.17 ragge sc->sc_unit.uu_bdp = 0;
493 1.1 ragge }
494 1.17 ragge sc->sc_unit.uu_ubinfo = 0;
495 1.17 ragge /* sc->sc_unit.uu_cmd = 0; XXX */
496 1.1 ragge
497 1.17 ragge /* reset queues and requeue pending transfers */
498 1.17 ragge mscp_requeue(sc->sc_softc);
499 1.1 ragge
500 1.1 ragge /*
501 1.17 ragge * If it fails to initialise we will notice later and
502 1.17 ragge * try again (and again...). Do not call udastart()
503 1.17 ragge * here; it will be done after the controller finishes
504 1.17 ragge * initialisation.
505 1.1 ragge */
506 1.17 ragge /* XXX if (udainit(sc)) */
507 1.23 christos printf(" (hung)");
508 1.1 ragge }
509 1.1 ragge
510 1.17 ragge void
511 1.17 ragge udactlrdone(usc, info)
512 1.17 ragge struct device *usc;
513 1.17 ragge int info;
514 1.1 ragge {
515 1.17 ragge struct uda_softc *sc = (void *)usc;
516 1.1 ragge
517 1.17 ragge /* XXX check if we shall release the BDP */
518 1.17 ragge sc->sc_unit.uu_ubinfo = info;
519 1.17 ragge ubadone(&sc->sc_unit);
520 1.1 ragge }
521