esp.c revision 1.15 1 /* $NetBSD: esp.c,v 1.15 1998/05/02 16:45:30 scottr Exp $ */
2
3 /*
4 * Copyright (c) 1997 Jason R. Thorpe.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed for the NetBSD Project
18 * by Jason R. Thorpe.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /*
35 * Copyright (c) 1994 Peter Galbavy
36 * Copyright (c) 1995 Paul Kranenburg
37 * All rights reserved.
38 *
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
41 * are met:
42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
47 * 3. All advertising materials mentioning features or use of this software
48 * must display the following acknowledgement:
49 * This product includes software developed by Peter Galbavy
50 * 4. The name of the author may not be used to endorse or promote products
51 * derived from this software without specific prior written permission.
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
54 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
55 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
56 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
57 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
58 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
59 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
61 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
62 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
63 * POSSIBILITY OF SUCH DAMAGE.
64 */
65
66 /*
67 * Based on aic6360 by Jarle Greipsland
68 *
69 * Acknowledgements: Many of the algorithms used in this driver are
70 * inspired by the work of Julian Elischer (julian (at) tfs.com) and
71 * Charles Hannum (mycroft (at) duality.gnu.ai.mit.edu). Thanks a million!
72 */
73
74 /*
75 * Initial m68k mac support from Allen Briggs <briggs (at) macbsd.com>
76 * (basically consisting of the match, a bit of the attach, and the
77 * "DMA" glue functions).
78 */
79
80 #include <sys/types.h>
81 #include <sys/param.h>
82 #include <sys/systm.h>
83 #include <sys/kernel.h>
84 #include <sys/errno.h>
85 #include <sys/ioctl.h>
86 #include <sys/device.h>
87 #include <sys/buf.h>
88 #include <sys/proc.h>
89 #include <sys/user.h>
90 #include <sys/queue.h>
91
92 #include <dev/scsipi/scsi_all.h>
93 #include <dev/scsipi/scsipi_all.h>
94 #include <dev/scsipi/scsiconf.h>
95 #include <dev/scsipi/scsi_message.h>
96
97 #include <machine/cpu.h>
98 #include <machine/bus.h>
99 #include <machine/param.h>
100
101 #include <dev/ic/ncr53c9xreg.h>
102 #include <dev/ic/ncr53c9xvar.h>
103
104 #include <machine/viareg.h>
105
106 #include <mac68k/obio/espvar.h>
107 #include <mac68k/obio/obiovar.h>
108
109 void espattach __P((struct device *, struct device *, void *));
110 int espmatch __P((struct device *, struct cfdata *, void *));
111
112 /* Linkup to the rest of the kernel */
113 struct cfattach esp_ca = {
114 sizeof(struct esp_softc), espmatch, espattach
115 };
116
117 struct scsipi_adapter esp_switch = {
118 ncr53c9x_scsi_cmd,
119 minphys, /* no max at this level; handled by DMA code */
120 NULL,
121 NULL,
122 };
123
124 struct scsipi_device esp_dev = {
125 NULL, /* Use default error handler */
126 NULL, /* have a queue, served by this */
127 NULL, /* have no async handler */
128 NULL, /* Use default 'done' routine */
129 };
130
131 /*
132 * Functions and the switch for the MI code.
133 */
134 u_char esp_read_reg __P((struct ncr53c9x_softc *, int));
135 void esp_write_reg __P((struct ncr53c9x_softc *, int, u_char));
136 int esp_dma_isintr __P((struct ncr53c9x_softc *));
137 void esp_dma_reset __P((struct ncr53c9x_softc *));
138 int esp_dma_intr __P((struct ncr53c9x_softc *));
139 int esp_dma_setup __P((struct ncr53c9x_softc *, caddr_t *,
140 size_t *, int, size_t *));
141 void esp_dma_go __P((struct ncr53c9x_softc *));
142 void esp_dma_stop __P((struct ncr53c9x_softc *));
143 int esp_dma_isactive __P((struct ncr53c9x_softc *));
144 void esp_quick_write_reg __P((struct ncr53c9x_softc *, int, u_char));
145 int esp_quick_dma_intr __P((struct ncr53c9x_softc *));
146 int esp_quick_dma_setup __P((struct ncr53c9x_softc *, caddr_t *,
147 size_t *, int, size_t *));
148 void esp_quick_dma_go __P((struct ncr53c9x_softc *));
149
150 static __inline__ int esp_dafb_have_dreq __P((struct esp_softc *esc));
151 static __inline__ int esp_iosb_have_dreq __P((struct esp_softc *esc));
152 int (*esp_have_dreq) __P((struct esp_softc *esc));
153
154 struct ncr53c9x_glue esp_glue = {
155 esp_read_reg,
156 esp_write_reg,
157 esp_dma_isintr,
158 esp_dma_reset,
159 esp_dma_intr,
160 esp_dma_setup,
161 esp_dma_go,
162 esp_dma_stop,
163 esp_dma_isactive,
164 NULL, /* gl_clear_latched_intr */
165 };
166
167 int
168 espmatch(parent, cf, aux)
169 struct device *parent;
170 struct cfdata *cf;
171 void *aux;
172 {
173 int found = 0;
174
175 if ((cf->cf_unit == 0) && mac68k_machine.scsi96) {
176 found = 1;
177 }
178 if ((cf->cf_unit == 1) && mac68k_machine.scsi96_2) {
179 found = 1;
180 }
181
182 return found;
183 }
184
185 /*
186 * Attach this instance, and then all the sub-devices
187 */
188 void
189 espattach(parent, self, aux)
190 struct device *parent, *self;
191 void *aux;
192 {
193 struct obio_attach_args *oa = (struct obio_attach_args *)aux;
194 extern vm_offset_t SCSIBase;
195 struct esp_softc *esc = (void *)self;
196 struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x;
197 int quick = 0;
198 unsigned long reg_offset;
199
200 reg_offset = SCSIBase - IOBase;
201 esc->sc_tag = oa->oa_tag;
202 /*
203 * For Wombat, Primus and Optimus motherboards, DREQ is
204 * visible on bit 0 of the IOSB's emulated VIA2 vIFR (and
205 * the scsi registers are offset 0x1000 bytes from IOBase).
206 *
207 * For the Q700/900/950 it's at f9800024 for bus 0 and
208 * f9800028 for bus 1 (900/950). For these machines, that is also
209 * a (12-bit) configuration register for DAFB's control of the
210 * pseudo-DMA timing. The default value is 0x1d1.
211 */
212 esp_have_dreq = esp_dafb_have_dreq;
213 if (sc->sc_dev.dv_unit == 0) {
214 if (reg_offset == 0x10000) {
215 quick = 1;
216 esp_have_dreq = esp_iosb_have_dreq;
217 } else if (reg_offset == 0x18000) {
218 quick = 0;
219 } else {
220 if (bus_space_map(esc->sc_tag, 0xf9800024,
221 4, 0, &esc->sc_bsh)) {
222 printf("failed to map 4 at 0xf9800024.\n");
223 } else {
224 quick = 1;
225 bus_space_write_4(esc->sc_tag,
226 esc->sc_bsh, 0, 0x1d1);
227 }
228 }
229 } else {
230 if (bus_space_map(esc->sc_tag, 0xf9800028,
231 4, 0, &esc->sc_bsh)) {
232 printf("failed to map 4 at 0xf9800028.\n");
233 } else {
234 quick = 1;
235 bus_space_write_4(esc->sc_tag, esc->sc_bsh, 0, 0x1d1);
236 }
237 }
238 if (quick) {
239 esp_glue.gl_write_reg = esp_quick_write_reg;
240 esp_glue.gl_dma_intr = esp_quick_dma_intr;
241 esp_glue.gl_dma_setup = esp_quick_dma_setup;
242 esp_glue.gl_dma_go = esp_quick_dma_go;
243 }
244
245 /*
246 * Set up the glue for MI code early; we use some of it here.
247 */
248 sc->sc_glue = &esp_glue;
249
250 /*
251 * Save the regs
252 */
253 if (sc->sc_dev.dv_unit == 0) {
254
255 esc->sc_reg = (volatile u_char *) SCSIBase;
256 via2_register_irq(VIA2_SCSIIRQ,
257 (void (*)(void *))ncr53c9x_intr, esc);
258 esc->irq_mask = V2IF_SCSIIRQ;
259 if (reg_offset == 0x10000) {
260 sc->sc_freq = 16500000;
261 } else {
262 sc->sc_freq = 25000000;
263 }
264
265 if (esp_glue.gl_dma_go == esp_quick_dma_go) {
266 printf(" (quick)");
267 }
268 } else {
269 esc->sc_reg = (volatile u_char *) SCSIBase + 0x402;
270 via2_register_irq(VIA2_SCSIDRQ,
271 (void (*)(void *))ncr53c9x_intr, esc);
272 esc->irq_mask = V2IF_SCSIDRQ; /* V2IF_T1? */
273 sc->sc_freq = 25000000;
274
275 if (esp_glue.gl_dma_go == esp_quick_dma_go) {
276 printf(" (quick)");
277 }
278 }
279
280 printf(": address %p", esc->sc_reg);
281
282 sc->sc_id = 7;
283
284 /* gimme Mhz */
285 sc->sc_freq /= 1000000;
286
287 /*
288 * It is necessary to try to load the 2nd config register here,
289 * to find out what rev the esp chip is, else the esp_reset
290 * will not set up the defaults correctly.
291 */
292 sc->sc_cfg1 = sc->sc_id; /* | NCRCFG1_PARENB; */
293 sc->sc_cfg2 = NCRCFG2_SCSI2;
294 sc->sc_cfg3 = 0;
295 sc->sc_rev = NCR_VARIANT_NCR53C96;
296
297 /*
298 * This is the value used to start sync negotiations
299 * Note that the NCR register "SYNCTP" is programmed
300 * in "clocks per byte", and has a minimum value of 4.
301 * The SCSI period used in negotiation is one-fourth
302 * of the time (in nanoseconds) needed to transfer one byte.
303 * Since the chip's clock is given in MHz, we have the following
304 * formula: 4 * period = (1000 / freq) * 4
305 */
306 sc->sc_minsync = 1000 / sc->sc_freq;
307
308 sc->sc_minsync = 0; /* No synchronous xfers w/o DMA */
309 /* Really no limit, but since we want to fit into the TCR... */
310 sc->sc_maxxfer = 8 * 1024; /*64 * 1024; XXX */
311
312 /*
313 * Now try to attach all the sub-devices
314 */
315 ncr53c9x_attach(sc, &esp_switch, &esp_dev);
316
317 /*
318 * Configure interrupts.
319 */
320 via2_reg(vPCR) = 0x22;
321 via2_reg(vIFR) = esc->irq_mask;
322 via2_reg(vIER) = 0x80 | esc->irq_mask;
323 }
324
325 /*
326 * Glue functions.
327 */
328
329 u_char
330 esp_read_reg(sc, reg)
331 struct ncr53c9x_softc *sc;
332 int reg;
333 {
334 struct esp_softc *esc = (struct esp_softc *)sc;
335
336 return esc->sc_reg[reg * 16];
337 }
338
339 void
340 esp_write_reg(sc, reg, val)
341 struct ncr53c9x_softc *sc;
342 int reg;
343 u_char val;
344 {
345 struct esp_softc *esc = (struct esp_softc *)sc;
346 u_char v = val;
347
348 if (reg == NCR_CMD && v == (NCRCMD_TRANS|NCRCMD_DMA)) {
349 v = NCRCMD_TRANS;
350 }
351 esc->sc_reg[reg * 16] = v;
352 }
353
354 void
355 esp_dma_stop(sc)
356 struct ncr53c9x_softc *sc;
357 {
358 }
359
360 int
361 esp_dma_isactive(sc)
362 struct ncr53c9x_softc *sc;
363 {
364 struct esp_softc *esc = (struct esp_softc *)sc;
365
366 return esc->sc_active;
367 }
368
369 int
370 esp_dma_isintr(sc)
371 struct ncr53c9x_softc *sc;
372 {
373 struct esp_softc *esc = (struct esp_softc *)sc;
374
375 return esc->sc_reg[NCR_STAT * 16] & 0x80;
376 }
377
378 void
379 esp_dma_reset(sc)
380 struct ncr53c9x_softc *sc;
381 {
382 struct esp_softc *esc = (struct esp_softc *)sc;
383
384 esc->sc_active = 0;
385 esc->sc_tc = 0;
386 }
387
388 int
389 esp_dma_intr(sc)
390 struct ncr53c9x_softc *sc;
391 {
392 register struct esp_softc *esc = (struct esp_softc *)sc;
393 register u_char *p;
394 volatile u_char *cmdreg, *intrreg, *statreg, *fiforeg;
395 register u_int espphase, espstat, espintr;
396 register int cnt;
397
398 if (esc->sc_active == 0) {
399 printf("dma_intr--inactive DMA\n");
400 return -1;
401 }
402
403 if ((sc->sc_espintr & NCRINTR_BS) == 0) {
404 esc->sc_active = 0;
405 return 0;
406 }
407
408 cnt = *esc->sc_dmalen;
409 if (*esc->sc_dmalen == 0) {
410 printf("data interrupt, but no count left.");
411 }
412
413 p = *esc->sc_dmaaddr;
414 espphase = sc->sc_phase;
415 espstat = (u_int) sc->sc_espstat;
416 espintr = (u_int) sc->sc_espintr;
417 cmdreg = esc->sc_reg + NCR_CMD * 16;
418 fiforeg = esc->sc_reg + NCR_FIFO * 16;
419 statreg = esc->sc_reg + NCR_STAT * 16;
420 intrreg = esc->sc_reg + NCR_INTR * 16;
421 do {
422 if (esc->sc_datain) {
423 *p++ = *fiforeg;
424 cnt--;
425 if (espphase == DATA_IN_PHASE) {
426 *cmdreg = NCRCMD_TRANS;
427 } else {
428 esc->sc_active = 0;
429 }
430 } else {
431 if ( (espphase == DATA_OUT_PHASE)
432 || (espphase == MESSAGE_OUT_PHASE)) {
433 *fiforeg = *p++;
434 cnt--;
435 *cmdreg = NCRCMD_TRANS;
436 } else {
437 esc->sc_active = 0;
438 }
439 }
440
441 if (esc->sc_active) {
442 while (!(*statreg & 0x80));
443 espstat = *statreg;
444 espintr = *intrreg;
445 espphase = (espintr & NCRINTR_DIS)
446 ? /* Disconnected */ BUSFREE_PHASE
447 : espstat & PHASE_MASK;
448 }
449 } while (esc->sc_active && (espintr & NCRINTR_BS));
450 sc->sc_phase = espphase;
451 sc->sc_espstat = (u_char) espstat;
452 sc->sc_espintr = (u_char) espintr;
453 *esc->sc_dmaaddr = p;
454 *esc->sc_dmalen = cnt;
455
456 if (*esc->sc_dmalen == 0) {
457 esc->sc_tc = NCRSTAT_TC;
458 }
459 sc->sc_espstat |= esc->sc_tc;
460 return 0;
461 }
462
463 int
464 esp_dma_setup(sc, addr, len, datain, dmasize)
465 struct ncr53c9x_softc *sc;
466 caddr_t *addr;
467 size_t *len;
468 int datain;
469 size_t *dmasize;
470 {
471 struct esp_softc *esc = (struct esp_softc *)sc;
472
473 esc->sc_dmaaddr = addr;
474 esc->sc_dmalen = len;
475 esc->sc_datain = datain;
476 esc->sc_dmasize = *dmasize;
477 esc->sc_tc = 0;
478
479 return 0;
480 }
481
482 void
483 esp_dma_go(sc)
484 struct ncr53c9x_softc *sc;
485 {
486 struct esp_softc *esc = (struct esp_softc *)sc;
487
488 if (esc->sc_datain == 0) {
489 esc->sc_reg[NCR_FIFO * 16] = **esc->sc_dmaaddr;
490 (*esc->sc_dmalen)--;
491 (*esc->sc_dmaaddr)++;
492 }
493 esc->sc_active = 1;
494 }
495
496 void
497 esp_quick_write_reg(sc, reg, val)
498 struct ncr53c9x_softc *sc;
499 int reg;
500 u_char val;
501 {
502 struct esp_softc *esc = (struct esp_softc *)sc;
503 u_char v = val;
504
505 esc->sc_reg[reg * 16] = v;
506 }
507
508 int
509 esp_quick_dma_intr(sc)
510 struct ncr53c9x_softc *sc;
511 {
512 struct esp_softc *esc = (struct esp_softc *)sc;
513 int trans=0, resid=0;
514
515 if (esc->sc_active == 0)
516 panic("dma_intr--inactive DMA\n");
517
518 esc->sc_active = 0;
519
520 if (esc->sc_dmasize == 0) {
521 int res;
522
523 res = 65536;
524 res -= NCR_READ_REG(sc, NCR_TCL);
525 res -= NCR_READ_REG(sc, NCR_TCM) << 8;
526 printf("dmaintr: discarded %d b (last transfer was %d b).\n",
527 res, esc->sc_prevdmasize);
528 return 0;
529 }
530
531 if (esc->sc_datain &&
532 (resid = (NCR_READ_REG(sc, NCR_FFLAG) & NCRFIFO_FF)) != 0) {
533 printf("dmaintr: empty FIFO of %d\n", resid);
534 DELAY(1);
535 }
536
537 if ((sc->sc_espstat & NCRSTAT_TC) == 0) {
538 resid += NCR_READ_REG(sc, NCR_TCL);
539 resid += NCR_READ_REG(sc, NCR_TCM) << 8;
540
541 if (resid == 0)
542 resid = 65536;
543 }
544
545 trans = esc->sc_dmasize - resid;
546 if (trans < 0) {
547 printf("dmaintr: trans < 0????");
548 trans = esc->sc_dmasize;
549 }
550
551 NCR_DMA(("dmaintr: trans %d, resid %d.\n", trans, resid));
552 *esc->sc_dmaaddr += trans;
553 *esc->sc_dmalen -= trans;
554
555 return 0;
556 }
557
558 int
559 esp_quick_dma_setup(sc, addr, len, datain, dmasize)
560 struct ncr53c9x_softc *sc;
561 caddr_t *addr;
562 size_t *len;
563 int datain;
564 size_t *dmasize;
565 {
566 struct esp_softc *esc = (struct esp_softc *)sc;
567
568 esc->sc_dmaaddr = addr;
569 esc->sc_dmalen = len;
570
571 esc->sc_pdmaddr = (u_int16_t *) *addr;
572 esc->sc_pdmalen = *len;
573 if (esc->sc_pdmalen & 1) {
574 esc->sc_pdmalen--;
575 esc->sc_pad = 1;
576 } else {
577 esc->sc_pad = 0;
578 }
579
580 esc->sc_datain = datain;
581 esc->sc_prevdmasize = esc->sc_dmasize;
582 esc->sc_dmasize = *dmasize;
583
584 return 0;
585 }
586
587 static __inline__ int
588 esp_dafb_have_dreq(esc)
589 struct esp_softc *esc;
590 {
591 u_int32_t r;
592
593 r = bus_space_read_4(esc->sc_tag, esc->sc_bsh, 0);
594 return (r & 0x200);
595 }
596
597 static __inline__ int
598 esp_iosb_have_dreq(esc)
599 struct esp_softc *esc;
600 {
601 return (via2_reg(vIFR) & V2IF_SCSIDRQ);
602 }
603
604 static int espspl=-1;
605 #define __splx(s) __asm __volatile ("movew %0,sr" : : "di" (s));
606 #define __spl2() __splx(PSL_S|PSL_IPL2)
607 #define __spl4() __splx(PSL_S|PSL_IPL4)
608
609 void
610 esp_quick_dma_go(sc)
611 struct ncr53c9x_softc *sc;
612 {
613 struct esp_softc *esc = (struct esp_softc *)sc;
614 extern int *nofault;
615 label_t faultbuf;
616 u_int16_t volatile *pdma;
617 u_char volatile *statreg;
618
619 esc->sc_active = 1;
620
621 espspl = spl2();
622
623 restart_dmago:
624 nofault = (int *) &faultbuf;
625 if (setjmp((label_t *) nofault)) {
626 int i=0;
627
628 nofault = (int *) 0;
629 statreg = esc->sc_reg + NCR_STAT * 16;
630 for (;;) {
631 if (*statreg & 0x80) {
632 goto gotintr;
633 }
634
635 if (esp_have_dreq(esc)) {
636 break;
637 }
638
639 DELAY(1);
640 if (i++ > 10000)
641 panic("esp_dma_go: Argh!");
642 }
643 goto restart_dmago;
644 }
645
646 statreg = esc->sc_reg + NCR_STAT * 16;
647 pdma = (u_int16_t *) (esc->sc_reg + 0x100);
648
649 #define WAIT while (!esp_have_dreq(esc)) if (*statreg & 0x80) goto gotintr
650
651 if (esc->sc_datain == 0) {
652 while (esc->sc_pdmalen) {
653 WAIT;
654 __spl4(); *pdma = *(esc->sc_pdmaddr)++; __spl2()
655 esc->sc_pdmalen -= 2;
656 }
657 if (esc->sc_pad) {
658 unsigned short us;
659 unsigned char *c;
660 c = (unsigned char *) esc->sc_pdmaddr;
661 us = *c;
662 WAIT;
663 __spl4(); *pdma = us; __spl2()
664 }
665 } else {
666 while (esc->sc_pdmalen) {
667 WAIT;
668 __spl4(); *(esc->sc_pdmaddr)++ = *pdma; __spl2()
669 esc->sc_pdmalen -= 2;
670 }
671 if (esc->sc_pad) {
672 unsigned short us;
673 unsigned char *c;
674 WAIT;
675 __spl4(); us = *pdma; __spl2()
676 c = (unsigned char *) esc->sc_pdmaddr;
677 *c = us & 0xff;
678 }
679 }
680 #undef WAIT
681
682 nofault = (int *) 0;
683
684 if ((*statreg & 0x80) == 0) {
685 if (espspl != -1) splx(espspl); espspl = -1;
686 return;
687 }
688
689 gotintr:
690 ncr53c9x_intr(sc);
691 if (espspl != -1) splx(espspl); espspl = -1;
692 }
693