Home | History | Annotate | Line # | Download | only in dev
siop.c revision 1.25
      1 /*	$NetBSD: siop.c,v 1.25 1995/09/29 13:52:04 chopps Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1994 Michael L. Hitch
      5  * Copyright (c) 1990 The Regents of the University of California.
      6  * All rights reserved.
      7  *
      8  * This code is derived from software contributed to Berkeley by
      9  * Van Jacobson of Lawrence Berkeley Laboratory.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the University of
     22  *	California, Berkeley and its contributors.
     23  * 4. Neither the name of the University nor the names of its contributors
     24  *    may be used to endorse or promote products derived from this software
     25  *    without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     30  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     31  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     32  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     33  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     36  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     37  * SUCH DAMAGE.
     38  *
     39  *	@(#)siop.c	7.5 (Berkeley) 5/4/91
     40  */
     41 
     42 /*
     43  * AMIGA 53C710 scsi adaptor driver
     44  */
     45 
     46 #include <sys/param.h>
     47 #include <sys/systm.h>
     48 #include <sys/device.h>
     49 #include <sys/disklabel.h>
     50 #include <sys/dkstat.h>
     51 #include <sys/buf.h>
     52 #include <scsi/scsi_all.h>
     53 #include <scsi/scsiconf.h>
     54 #include <machine/cpu.h>
     55 #include <amiga/amiga/custom.h>
     56 #include <amiga/amiga/isr.h>
     57 #include <amiga/dev/siopreg.h>
     58 #include <amiga/dev/siopvar.h>
     59 
     60 extern u_int	kvtop();
     61 
     62 /*
     63  * SCSI delays
     64  * In u-seconds, primarily for state changes on the SPC.
     65  */
     66 #define	SCSI_CMD_WAIT	500000	/* wait per step of 'immediate' cmds */
     67 #define	SCSI_DATA_WAIT	500000	/* wait per data in/out step */
     68 #define	SCSI_INIT_WAIT	500000	/* wait per step (both) during init */
     69 
     70 void siop_select __P((struct siop_softc *));
     71 void siopabort __P((struct siop_softc *, siop_regmap_p, char *));
     72 void sioperror __P((struct siop_softc *, siop_regmap_p, u_char));
     73 void siopstart __P((struct siop_softc *));
     74 void siopreset __P((struct siop_softc *));
     75 void siopsetdelay __P((int));
     76 void siop_scsidone __P((struct siop_acb *, int));
     77 void siop_sched __P((struct siop_softc *));
     78 int  siop_poll __P((struct siop_softc *, struct siop_acb *));
     79 int  siopintr __P((struct siop_softc *));
     80 
     81 /* 53C710 script */
     82 const
     83 #include <amiga/dev/siop_script.out>
     84 
     85 /* default to not inhibit sync negotiation on any drive */
     86 u_char siop_inhibit_sync[8] = { 0, 0, 0, 0, 0, 0, 0 }; /* initialize, so patchable */
     87 u_char siop_allow_disc[8] = {3, 3, 3, 3, 3, 3, 3, 3};
     88 int siop_no_dma = 0;
     89 
     90 int siop_reset_delay = 250;	/* delay after reset, in milleseconds */
     91 
     92 int siop_cmd_wait = SCSI_CMD_WAIT;
     93 int siop_data_wait = SCSI_DATA_WAIT;
     94 int siop_init_wait = SCSI_INIT_WAIT;
     95 
     96 #ifdef DEBUG
     97 /*
     98  * sync period transfer lookup - only valid for 66Mhz clock
     99  */
    100 static struct {
    101 	unsigned char p;	/* period from sync request message */
    102 	unsigned char r;	/* siop_period << 4 | sbcl */
    103 } sync_tab[] = {
    104 	{ 60/4, 0<<4 | 1},
    105 	{ 76/4, 1<<4 | 1},
    106 	{ 92/4, 2<<4 | 1},
    107 	{ 92/4, 0<<4 | 2},
    108 	{108/4, 3<<4 | 1},
    109 	{116/4, 1<<4 | 2},
    110 	{120/4, 4<<4 | 1},
    111 	{120/4, 0<<4 | 3},
    112 	{136/4, 5<<4 | 1},
    113 	{140/4, 2<<4 | 2},
    114 	{152/4, 6<<4 | 1},
    115 	{152/4, 1<<4 | 3},
    116 	{164/4, 3<<4 | 2},
    117 	{168/4, 7<<4 | 1},
    118 	{180/4, 2<<4 | 3},
    119 	{184/4, 4<<4 | 2},
    120 	{208/4, 5<<4 | 2},
    121 	{212/4, 3<<4 | 3},
    122 	{232/4, 6<<4 | 2},
    123 	{240/4, 4<<4 | 3},
    124 	{256/4, 7<<4 | 2},
    125 	{272/4, 5<<4 | 3},
    126 	{300/4, 6<<4 | 3},
    127 	{332/4, 7<<4 | 3}
    128 };
    129 #endif
    130 
    131 #ifdef DEBUG
    132 /*
    133  *	0x01 - full debug
    134  *	0x02 - DMA chaining
    135  *	0x04 - siopintr
    136  *	0x08 - phase mismatch
    137  *	0x10 - <not used>
    138  *	0x20 - panic on unhandled exceptions
    139  *	0x100 - disconnect/reselect
    140  */
    141 int	siop_debug = 0;
    142 int	siopsync_debug = 0;
    143 int	siopdma_hits = 0;
    144 int	siopdma_misses = 0;
    145 int	siopchain_ints = 0;
    146 int	siopstarts = 0;
    147 int	siopints = 0;
    148 int	siopphmm = 0;
    149 #define SIOP_TRACE_SIZE	128
    150 #define SIOP_TRACE(a,b,c,d) \
    151 	siop_trbuf[siop_trix] = (a); \
    152 	siop_trbuf[siop_trix+1] = (b); \
    153 	siop_trbuf[siop_trix+2] = (c); \
    154 	siop_trbuf[siop_trix+3] = (d); \
    155 	siop_trix = (siop_trix + 4) & (SIOP_TRACE_SIZE - 1);
    156 u_char	siop_trbuf[SIOP_TRACE_SIZE];
    157 int	siop_trix;
    158 void siop_dump __P((struct siop_softc *));
    159 void siop_dump_trace __P((void));
    160 #else
    161 #define SIOP_TRACE(a,b,c,d)
    162 #endif
    163 
    164 
    165 /*
    166  * default minphys routine for siop based controllers
    167  */
    168 void
    169 siop_minphys(bp)
    170 	struct buf *bp;
    171 {
    172 
    173 	/*
    174 	 * No max transfer at this level.
    175 	 */
    176 	minphys(bp);
    177 }
    178 
    179 /*
    180  * used by specific siop controller
    181  *
    182  */
    183 int
    184 siop_scsicmd(xs)
    185 	struct scsi_xfer *xs;
    186 {
    187 	struct siop_acb *acb;
    188 	struct siop_softc *sc;
    189 	struct scsi_link *slp;
    190 	int flags, s, i;
    191 
    192 	slp = xs->sc_link;
    193 	sc = slp->adapter_softc;
    194 	flags = xs->flags;
    195 
    196 	/* XXXX ?? */
    197 	if (flags & SCSI_DATA_UIO)
    198 		panic("siop: scsi data uio requested");
    199 
    200 	/* XXXX ?? */
    201 	if (sc->sc_nexus && flags & SCSI_POLL)
    202 /*		panic("siop_scsicmd: busy");*/
    203 		printf("siop_scsicmd: busy\n");
    204 
    205 	s = splbio();
    206 	acb = sc->free_list.tqh_first;
    207 	if (acb) {
    208 		TAILQ_REMOVE(&sc->free_list, acb, chain);
    209 	}
    210 	splx(s);
    211 
    212 	if (acb == NULL) {
    213 		xs->error = XS_DRIVER_STUFFUP;
    214 		return(TRY_AGAIN_LATER);
    215 	}
    216 
    217 	acb->flags = ACB_ACTIVE;
    218 	acb->xs = xs;
    219 	bcopy(xs->cmd, &acb->cmd, xs->cmdlen);
    220 	acb->clen = xs->cmdlen;
    221 	acb->daddr = xs->data;
    222 	acb->dleft = xs->datalen;
    223 
    224 	s = splbio();
    225 	TAILQ_INSERT_TAIL(&sc->ready_list, acb, chain);
    226 
    227 	if (sc->sc_nexus == NULL)
    228 		siop_sched(sc);
    229 
    230 	splx(s);
    231 
    232 	if (flags & SCSI_POLL || siop_no_dma)
    233 		return(siop_poll(sc, acb));
    234 	return(SUCCESSFULLY_QUEUED);
    235 }
    236 
    237 int
    238 siop_poll(sc, acb)
    239 	struct siop_softc *sc;
    240 	struct siop_acb *acb;
    241 {
    242 	siop_regmap_p rp = sc->sc_siopp;
    243 	struct scsi_xfer *xs = acb->xs;
    244 	int i;
    245 	int status;
    246 	u_char istat;
    247 	u_char dstat;
    248 	u_char sstat0;
    249 	int s;
    250 	int to;
    251 
    252 	s = splbio();
    253 	to = xs->timeout / 1000;
    254 	if (sc->nexus_list.tqh_first)
    255 		printf("%s: siop_poll called with disconnected device\n",
    256 		    sc->sc_dev.dv_xname);
    257 	for (;;) {
    258 		/* use cmd_wait values? */
    259 		i = 50000;
    260 		spl0();
    261 		while (((istat = rp->siop_istat) &
    262 		    (SIOP_ISTAT_SIP | SIOP_ISTAT_DIP)) == 0) {
    263 			if (--i <= 0) {
    264 #ifdef DEBUG
    265 				printf ("waiting: tgt %d cmd %02x sbcl %02x dsp %x (+%x) dcmd %x ds %x timeout %d\n",
    266 				    xs->sc_link->target, acb->cmd.opcode,
    267 				    rp->siop_sbcl, rp->siop_dsp,
    268 				    rp->siop_dsp - sc->sc_scriptspa,
    269 				    *((long *)&rp->siop_dcmd), &acb->ds, acb->xs->timeout);
    270 #endif
    271 				i = 50000;
    272 				--to;
    273 				if (to <= 0) {
    274 					siopreset(sc);
    275 					return(COMPLETE);
    276 				}
    277 			}
    278 			delay(10);
    279 		}
    280 		sstat0 = rp->siop_sstat0;
    281 		dstat = rp->siop_dstat;
    282 		if (siop_checkintr(sc, istat, dstat, sstat0, &status)) {
    283 			if (acb != sc->sc_nexus)
    284 				printf("%s: siop_poll disconnected device completed\n",
    285 				    sc->sc_dev.dv_xname);
    286 			else if ((sc->sc_flags & SIOP_INTDEFER) == 0) {
    287 				sc->sc_flags &= ~SIOP_INTSOFF;
    288 				rp->siop_sien = sc->sc_sien;
    289 				rp->siop_dien = sc->sc_dien;
    290 			}
    291 			siop_scsidone(sc->sc_nexus, status);
    292 		}
    293 		if (xs->flags & ITSDONE)
    294 			break;
    295 	}
    296 	splx(s);
    297 	return (COMPLETE);
    298 }
    299 
    300 /*
    301  * start next command that's ready
    302  */
    303 void
    304 siop_sched(sc)
    305 	struct siop_softc *sc;
    306 {
    307 	struct scsi_link *slp;
    308 	struct siop_acb *acb;
    309 	int stat, i;
    310 
    311 #ifdef DEBUG
    312 	if (sc->sc_nexus) {
    313 		printf("%s: siop_sched- nexus %x/%d ready %x/%d\n",
    314 		    sc->sc_dev.dv_xname, sc->sc_nexus,
    315 		    sc->sc_nexus->xs->sc_link->target,
    316 		    sc->ready_list.tqh_first,
    317 		    sc->ready_list.tqh_first->xs->sc_link->target);
    318 		return;
    319 	}
    320 #endif
    321 	for (acb = sc->ready_list.tqh_first; acb; acb = acb->chain.tqe_next) {
    322 		slp = acb->xs->sc_link;
    323 		i = slp->target;
    324 		if(!(sc->sc_tinfo[i].lubusy & (1 << slp->lun))) {
    325 			struct siop_tinfo *ti = &sc->sc_tinfo[i];
    326 
    327 			TAILQ_REMOVE(&sc->ready_list, acb, chain);
    328 			sc->sc_nexus = acb;
    329 			slp = acb->xs->sc_link;
    330 			ti = &sc->sc_tinfo[slp->target];
    331 			ti->lubusy |= (1 << slp->lun);
    332 			break;
    333 		}
    334 	}
    335 
    336 	if (acb == NULL) {
    337 #ifdef DEBUGXXX
    338 		printf("%s: siop_sched didn't find ready command\n",
    339 		    sc->sc_dev.dv_xname);
    340 #endif
    341 		return;
    342 	}
    343 
    344 	if (acb->xs->flags & SCSI_RESET)
    345 		siopreset(sc);
    346 
    347 #if 0
    348 	acb->cmd.bytes[0] |= slp->lun << 5;	/* XXXX */
    349 #endif
    350 	++sc->sc_active;
    351 	siop_select(sc);
    352 }
    353 
    354 void
    355 siop_scsidone(acb, stat)
    356 	struct siop_acb *acb;
    357 	int stat;
    358 {
    359 	struct scsi_xfer *xs = acb->xs;
    360 	struct scsi_link *slp = xs->sc_link;
    361 	struct siop_softc *sc = slp->adapter_softc;
    362 	int s, dosched = 0;
    363 
    364 #ifdef DIAGNOSTIC
    365 	if (acb == NULL || xs == NULL)
    366 		panic("siop_scsidone");
    367 #endif
    368 	if (slp->device_softc &&
    369 	    ((struct device *)(slp->device_softc))->dv_unit < dk_ndrive)
    370 		++dk_xfer[((struct device *)(slp->device_softc))->dv_unit];
    371 	/*
    372 	 * is this right?
    373 	 */
    374 	xs->status = stat;
    375 
    376 	if (xs->error == XS_NOERROR && !(acb->flags & ACB_CHKSENSE)) {
    377 		if (stat == SCSI_CHECK) {
    378 			struct scsi_sense *ss = (void *)&acb->cmd;
    379 			bzero(ss, sizeof(*ss));
    380 			ss->opcode = REQUEST_SENSE;
    381 			ss->byte2 = slp->lun << 5;
    382 			ss->length = sizeof(struct scsi_sense_data);
    383 			acb->clen = sizeof(*ss);
    384 			acb->daddr = (char *)&xs->sense;
    385 			acb->dleft = sizeof(struct scsi_sense_data);
    386 			acb->flags = ACB_ACTIVE | ACB_CHKSENSE;
    387 			TAILQ_INSERT_HEAD(&sc->ready_list, acb, chain);
    388 			--sc->sc_active;
    389 			sc->sc_tinfo[slp->target].lubusy &=
    390 			    ~(1 << slp->lun);
    391 			sc->sc_tinfo[slp->target].senses++;
    392 			if (sc->sc_nexus == acb) {
    393 				sc->sc_nexus = NULL;
    394 				siop_sched(sc);
    395 			}
    396 			SIOP_TRACE('d','s',0,0)
    397 			return;
    398 		}
    399 	}
    400 	if (xs->error == XS_NOERROR && (acb->flags & ACB_CHKSENSE)) {
    401 		xs->error = XS_SENSE;
    402 	} else {
    403 		xs->resid = 0;		/* XXXX */
    404 	}
    405 #if whataboutthisone
    406 		case SCSI_BUSY:
    407 			xs->error = XS_BUSY;
    408 			break;
    409 #endif
    410 	xs->flags |= ITSDONE;
    411 
    412 	/*
    413 	 * Remove the ACB from whatever queue it's on.  We have to do a bit of
    414 	 * a hack to figure out which queue it's on.  Note that it is *not*
    415 	 * necessary to cdr down the ready queue, but we must cdr down the
    416 	 * nexus queue and see if it's there, so we can mark the unit as no
    417 	 * longer busy.  This code is sickening, but it works.
    418 	 */
    419 	if (acb == sc->sc_nexus) {
    420 		sc->sc_nexus = NULL;
    421 		sc->sc_tinfo[slp->target].lubusy &= ~(1<<slp->lun);
    422 		if (sc->ready_list.tqh_first)
    423 			dosched = 1;	/* start next command */
    424 		--sc->sc_active;
    425 		SIOP_TRACE('d','a',stat,0)
    426 	} else if (sc->ready_list.tqh_last == &acb->chain.tqe_next) {
    427 		TAILQ_REMOVE(&sc->ready_list, acb, chain);
    428 		SIOP_TRACE('d','r',stat,0)
    429 	} else {
    430 		register struct siop_acb *acb2;
    431 		for (acb2 = sc->nexus_list.tqh_first; acb2;
    432 		    acb2 = acb2->chain.tqe_next)
    433 			if (acb2 == acb) {
    434 				TAILQ_REMOVE(&sc->nexus_list, acb, chain);
    435 				sc->sc_tinfo[slp->target].lubusy
    436 					&= ~(1<<slp->lun);
    437 				--sc->sc_active;
    438 				break;
    439 			}
    440 		if (acb2)
    441 			;
    442 		else if (acb->chain.tqe_next) {
    443 			TAILQ_REMOVE(&sc->ready_list, acb, chain);
    444 			--sc->sc_active;
    445 		} else {
    446 			printf("%s: can't find matching acb\n",
    447 			    sc->sc_dev.dv_xname);
    448 #ifdef DDB
    449 /*			Debugger(); */
    450 #endif
    451 		}
    452 		SIOP_TRACE('d','n',stat,0);
    453 	}
    454 	/* Put it on the free list. */
    455 	acb->flags = ACB_FREE;
    456 	TAILQ_INSERT_HEAD(&sc->free_list, acb, chain);
    457 
    458 	sc->sc_tinfo[slp->target].cmds++;
    459 
    460 	scsi_done(xs);
    461 
    462 	if (dosched && sc->sc_nexus == NULL)
    463 		siop_sched(sc);
    464 }
    465 
    466 void
    467 siopabort(sc, rp, where)
    468 	register struct siop_softc *sc;
    469 	siop_regmap_p rp;
    470 	char *where;
    471 {
    472 	int i;
    473 
    474 	printf ("%s: abort %s: dstat %02x, sstat0 %02x sbcl %02x\n",
    475 	    sc->sc_dev.dv_xname,
    476 	    where, rp->siop_dstat, rp->siop_sstat0, rp->siop_sbcl);
    477 
    478 	if (sc->sc_active > 0) {
    479 #ifdef TODO
    480       SET_SBIC_cmd (rp, SBIC_CMD_ABORT);
    481       WAIT_CIP (rp);
    482 
    483       GET_SBIC_asr (rp, asr);
    484       if (asr & (SBIC_ASR_BSY|SBIC_ASR_LCI))
    485         {
    486           /* ok, get more drastic.. */
    487 
    488 	  SET_SBIC_cmd (rp, SBIC_CMD_RESET);
    489 	  delay(25);
    490 	  SBIC_WAIT(rp, SBIC_ASR_INT, 0);
    491 	  GET_SBIC_csr (rp, csr);       /* clears interrupt also */
    492 
    493           return;
    494         }
    495 
    496       do
    497         {
    498           SBIC_WAIT (rp, SBIC_ASR_INT, 0);
    499           GET_SBIC_csr (rp, csr);
    500         }
    501       while ((csr != SBIC_CSR_DISC) && (csr != SBIC_CSR_DISC_1)
    502 	      && (csr != SBIC_CSR_CMD_INVALID));
    503 #endif
    504 
    505 		/* lets just hope it worked.. */
    506 #ifdef fix_this
    507 		for (i = 0; i < 2; ++i) {
    508 			if (sc->sc_iob[i].sc_xs && &sc->sc_iob[i] !=
    509 			    sc->sc_cur) {
    510 				printf ("siopabort: cleanup!\n");
    511 				sc->sc_iob[i].sc_xs = NULL;
    512 			}
    513 		}
    514 #endif	/* fix_this */
    515 /*		sc->sc_active = 0; */
    516 	}
    517 }
    518 
    519 void
    520 siopinitialize(sc)
    521 	struct siop_softc *sc;
    522 {
    523 	/*
    524 	 * Need to check that scripts is on a long word boundary
    525 	 * and that DS is on a long word boundary.
    526 	 * Also should verify that dev doesn't span non-contiguous
    527 	 * physical pages.
    528 	 */
    529 	sc->sc_scriptspa = kvtop(scripts);
    530 	sc->sc_tcp[1] = 1000 / sc->sc_clock_freq;
    531 	sc->sc_tcp[2] = 1500 / sc->sc_clock_freq;
    532 	sc->sc_tcp[3] = 2000 / sc->sc_clock_freq;
    533 	sc->sc_minsync = sc->sc_tcp[1];		/* in 4ns units */
    534 	if (sc->sc_minsync < 25)
    535 		sc->sc_minsync = 25;
    536 	if (sc->sc_clock_freq <= 25) {
    537 		sc->sc_dcntl = 0x80;		/* SCLK/1 */
    538 		sc->sc_tcp[0] = sc->sc_tcp[1];
    539 	} else if (sc->sc_clock_freq <= 37) {
    540 		sc->sc_dcntl = 0x40;		/* SCLK/1.5 */
    541 		sc->sc_tcp[0] = sc->sc_tcp[2];
    542 	} else if (sc->sc_clock_freq <= 50) {
    543 		sc->sc_dcntl = 0x00;		/* SCLK/2 */
    544 		sc->sc_tcp[0] = sc->sc_tcp[3];
    545 	} else {
    546 		sc->sc_dcntl = 0xc0;		/* SCLK/3 */
    547 		sc->sc_tcp[0] = 3000 / sc->sc_clock_freq;
    548 	}
    549 
    550 	siopreset (sc);
    551 }
    552 
    553 void
    554 siopreset(sc)
    555 	struct siop_softc *sc;
    556 {
    557 	siop_regmap_p rp;
    558 	u_int i, s;
    559 	u_char  dummy;
    560 	struct siop_acb *acb;
    561 
    562 	rp = sc->sc_siopp;
    563 
    564 	if (sc->sc_flags & SIOP_ALIVE)
    565 		siopabort(sc, rp, "reset");
    566 
    567 	printf("%s: ", sc->sc_dev.dv_xname);		/* XXXX */
    568 
    569 	s = splbio();
    570 
    571 	/*
    572 	 * Reset the chip
    573 	 * XXX - is this really needed?
    574 	 */
    575 	rp->siop_istat |= SIOP_ISTAT_ABRT;	/* abort current script */
    576 	rp->siop_istat |= SIOP_ISTAT_RST;		/* reset chip */
    577 	rp->siop_istat &= ~SIOP_ISTAT_RST;
    578 	/*
    579 	 * Reset SCSI bus (do we really want this?)
    580 	 */
    581 	rp->siop_sien = 0;
    582 	rp->siop_scntl1 |= SIOP_SCNTL1_RST;
    583 	delay(1);
    584 	rp->siop_scntl1 &= ~SIOP_SCNTL1_RST;
    585 
    586 	/*
    587 	 * Set up various chip parameters
    588 	 */
    589 	rp->siop_scntl0 = SIOP_ARB_FULL | SIOP_SCNTL0_EPC | SIOP_SCNTL0_EPG;
    590 	rp->siop_scntl1 = SIOP_SCNTL1_ESR;
    591 	rp->siop_dcntl = sc->sc_dcntl;
    592 	rp->siop_dmode = 0x80;	/* burst length = 4 */
    593 	rp->siop_sien = 0x00;	/* don't enable interrupts yet */
    594 	rp->siop_dien = 0x00;	/* don't enable interrupts yet */
    595 	rp->siop_scid = 1 << sc->sc_link.adapter_target;
    596 	rp->siop_dwt = 0x00;
    597 	rp->siop_ctest0 |= SIOP_CTEST0_BTD | SIOP_CTEST0_EAN;
    598 	rp->siop_ctest7 |= sc->sc_ctest7;
    599 
    600 	/* will need to re-negotiate sync xfers */
    601 	bzero(&sc->sc_sync, sizeof (sc->sc_sync));
    602 
    603 	i = rp->siop_istat;
    604 	if (i & SIOP_ISTAT_SIP)
    605 		dummy = rp->siop_sstat0;
    606 	if (i & SIOP_ISTAT_DIP)
    607 		dummy = rp->siop_dstat;
    608 
    609 	splx (s);
    610 
    611 	delay (siop_reset_delay * 1000);
    612 	printf("siop id %d reset V%d\n", sc->sc_link.adapter_target,
    613 	    rp->siop_ctest8 >> 4);
    614 
    615 	if ((sc->sc_flags & SIOP_ALIVE) == 0) {
    616 		TAILQ_INIT(&sc->ready_list);
    617 		TAILQ_INIT(&sc->nexus_list);
    618 		TAILQ_INIT(&sc->free_list);
    619 		sc->sc_nexus = NULL;
    620 		acb = sc->sc_acb;
    621 		bzero(acb, sizeof(sc->sc_acb));
    622 		for (i = 0; i < sizeof(sc->sc_acb) / sizeof(*acb); i++) {
    623 			TAILQ_INSERT_TAIL(&sc->free_list, acb, chain);
    624 			acb++;
    625 		}
    626 		bzero(sc->sc_tinfo, sizeof(sc->sc_tinfo));
    627 	} else {
    628 		if (sc->sc_nexus != NULL) {
    629 			sc->sc_nexus->xs->error = XS_DRIVER_STUFFUP;
    630 			siop_scsidone(sc->sc_nexus, sc->sc_nexus->stat[0]);
    631 		}
    632 		while (acb = sc->nexus_list.tqh_first) {
    633 			acb->xs->error = XS_DRIVER_STUFFUP;
    634 			siop_scsidone(acb, acb->stat[0]);
    635 		}
    636 	}
    637 
    638 	sc->sc_flags |= SIOP_ALIVE;
    639 	sc->sc_flags &= ~(SIOP_INTDEFER|SIOP_INTSOFF);
    640 	/* enable SCSI and DMA interrupts */
    641 	sc->sc_sien = SIOP_SIEN_M_A | SIOP_SIEN_STO | /*SIOP_SIEN_SEL |*/ SIOP_SIEN_SGE |
    642 	    SIOP_SIEN_UDC | SIOP_SIEN_RST | SIOP_SIEN_PAR;
    643 	sc->sc_dien = SIOP_DIEN_BF | SIOP_DIEN_ABRT | SIOP_DIEN_SIR |
    644 	    /*SIOP_DIEN_WTD |*/ SIOP_DIEN_IID;
    645 	rp->siop_sien = sc->sc_sien;
    646 	rp->siop_dien = sc->sc_dien;
    647 }
    648 
    649 /*
    650  * Setup Data Storage for 53C710 and start SCRIPTS processing
    651  */
    652 
    653 void
    654 siop_start (sc, target, lun, cbuf, clen, buf, len)
    655 	struct siop_softc *sc;
    656 	int target;
    657 	int lun;
    658 	u_char *cbuf;
    659 	int clen;
    660 	u_char *buf;
    661 	int len;
    662 {
    663 	siop_regmap_p rp = sc->sc_siopp;
    664 	int i;
    665 	int nchain;
    666 	int count, tcount;
    667 	char *addr, *dmaend;
    668 	struct siop_acb *acb = sc->sc_nexus;
    669 
    670 #ifdef DEBUG
    671 	if (siop_debug & 0x100 && rp->siop_sbcl & SIOP_BSY) {
    672 		printf ("ACK! siop was busy: rp %x script %x dsa %x active %d\n",
    673 		    rp, &scripts, &acb->ds, sc->sc_active);
    674 		printf ("istat %02x sfbr %02x lcrc %02x sien %02x dien %02x\n",
    675 		    rp->siop_istat, rp->siop_sfbr, rp->siop_lcrc,
    676 		    rp->siop_sien, rp->siop_dien);
    677 #ifdef DDB
    678 		/*Debugger();*/
    679 #endif
    680 	}
    681 #endif
    682 	acb->msgout[0] = MSG_IDENTIFY | lun;
    683 	if (siop_allow_disc[target] & 2 ||
    684 	    (siop_allow_disc[target] && len == 0))
    685 		acb->msgout[0] = MSG_IDENTIFY_DR | lun;
    686 	acb->status = 0;
    687 	acb->stat[0] = -1;
    688 	acb->msg[0] = -1;
    689 	acb->ds.scsi_addr = (0x10000 << target) | (sc->sc_sync[target].sxfer << 8);
    690 	acb->ds.idlen = 1;
    691 	acb->ds.idbuf = (char *) kvtop(&acb->msgout[0]);
    692 	acb->ds.cmdlen = clen;
    693 	acb->ds.cmdbuf = (char *) kvtop(cbuf);
    694 	acb->ds.stslen = 1;
    695 	acb->ds.stsbuf = (char *) kvtop(&acb->stat[0]);
    696 	acb->ds.msglen = 1;
    697 	acb->ds.msgbuf = (char *) kvtop(&acb->msg[0]);
    698 	acb->msg[1] = -1;
    699 	acb->ds.msginlen = 1;
    700 	acb->ds.extmsglen = 1;
    701 	acb->ds.synmsglen = 3;
    702 	acb->ds.msginbuf = (char *) kvtop(&acb->msg[1]);
    703 	acb->ds.extmsgbuf = (char *) kvtop(&acb->msg[2]);
    704 	acb->ds.synmsgbuf = (char *) kvtop(&acb->msg[3]);
    705 	bzero(&acb->ds.chain, sizeof (acb->ds.chain));
    706 
    707 	if (sc->sc_sync[target].state == SYNC_START) {
    708 		if (siop_inhibit_sync[target]) {
    709 			sc->sc_sync[target].state = SYNC_DONE;
    710 			sc->sc_sync[target].sbcl = 0;
    711 			sc->sc_sync[target].sxfer = 0;
    712 #ifdef DEBUG
    713 			if (siopsync_debug)
    714 				printf ("Forcing target %d asynchronous\n", target);
    715 #endif
    716 		}
    717 		else {
    718 			acb->msg[2] = -1;
    719 			acb->msgout[1] = MSG_EXT_MESSAGE;
    720 			acb->msgout[2] = 3;
    721 			acb->msgout[3] = MSG_SYNC_REQ;
    722 #ifdef MAXTOR_SYNC_KLUDGE
    723 			acb->msgout[4] = 50 / 4;	/* ask for ridiculous period */
    724 #else
    725 			acb->msgout[4] = sc->sc_minsync;
    726 #endif
    727 			acb->msgout[5] = SIOP_MAX_OFFSET;
    728 			acb->ds.idlen = 6;
    729 			sc->sc_sync[target].state = SYNC_SENT;
    730 #ifdef DEBUG
    731 			if (siopsync_debug)
    732 				printf ("Sending sync request to target %d\n", target);
    733 #endif
    734 		}
    735 	}
    736 
    737 /*
    738  * Build physical DMA addresses for scatter/gather I/O
    739  */
    740 	acb->iob_buf = buf;
    741 	acb->iob_len = len;
    742 	acb->iob_curbuf = acb->iob_curlen = 0;
    743 	nchain = 0;
    744 	count = len;
    745 	addr = buf;
    746 	dmaend = NULL;
    747 	while (count > 0) {
    748 		acb->ds.chain[nchain].databuf = (char *) kvtop (addr);
    749 		if (count < (tcount = NBPG - ((int) addr & PGOFSET)))
    750 			tcount = count;
    751 		acb->ds.chain[nchain].datalen = tcount;
    752 		addr += tcount;
    753 		count -= tcount;
    754 		if (acb->ds.chain[nchain].databuf == dmaend) {
    755 			dmaend += acb->ds.chain[nchain].datalen;
    756 			acb->ds.chain[nchain].datalen = 0;
    757 			acb->ds.chain[--nchain].datalen += tcount;
    758 #ifdef DEBUG
    759 			++siopdma_hits;
    760 #endif
    761 		}
    762 		else {
    763 			dmaend = acb->ds.chain[nchain].databuf +
    764 			    acb->ds.chain[nchain].datalen;
    765 			acb->ds.chain[nchain].datalen = tcount;
    766 #ifdef DEBUG
    767 			if (nchain)	/* Don't count miss on first one */
    768 				++siopdma_misses;
    769 #endif
    770 		}
    771 		++nchain;
    772 	}
    773 #ifdef DEBUG
    774 	if (nchain != 1 && len != 0 && siop_debug & 3) {
    775 		printf ("DMA chaining set: %d\n", nchain);
    776 		for (i = 0; i < nchain; ++i) {
    777 			printf ("  [%d] %8x %4x\n", i, acb->ds.chain[i].databuf,
    778 			    acb->ds.chain[i].datalen);
    779 		}
    780 	}
    781 #endif
    782 
    783 	/* push data cache for all data the 53c710 needs to access */
    784 	dma_cachectl (sc, sizeof (struct siop_softc));
    785 	dma_cachectl (cbuf, clen);
    786 	if (buf != NULL && len != 0)
    787 		dma_cachectl (buf, len);
    788 #ifdef DEBUG
    789 	if (siop_debug & 0x100 && rp->siop_sbcl & SIOP_BSY) {
    790 		printf ("ACK! siop was busy at start: rp %x script %x dsa %x active %d\n",
    791 		    rp, &scripts, &acb->ds, sc->sc_active);
    792 #ifdef DDB
    793 		/*Debugger();*/
    794 #endif
    795 	}
    796 #endif
    797 	if (sc->nexus_list.tqh_first == NULL) {
    798 		if (rp->siop_istat & SIOP_ISTAT_CON)
    799 			printf("%s: siop_select while connected?\n",
    800 			    sc->sc_dev.dv_xname);
    801 		rp->siop_temp = 0;
    802 		rp->siop_sbcl = sc->sc_sync[target].sbcl;
    803 		rp->siop_dsa = kvtop(&acb->ds);
    804 		rp->siop_dsp = sc->sc_scriptspa;
    805 		SIOP_TRACE('s',1,0,0)
    806 	} else {
    807 		if ((rp->siop_istat & SIOP_ISTAT_CON) == 0) {
    808 			rp->siop_istat = SIOP_ISTAT_SIGP;
    809 			SIOP_TRACE('s',2,0,0);
    810 		}
    811 		else {
    812 			SIOP_TRACE('s',3,rp->siop_istat,0);
    813 		}
    814 	}
    815 #ifdef DEBUG
    816 	++siopstarts;
    817 #endif
    818 }
    819 
    820 /*
    821  * Process a DMA or SCSI interrupt from the 53C710 SIOP
    822  */
    823 
    824 int
    825 siop_checkintr(sc, istat, dstat, sstat0, status)
    826 	struct	siop_softc *sc;
    827 	u_char	istat;
    828 	u_char	dstat;
    829 	u_char	sstat0;
    830 	int	*status;
    831 {
    832 	siop_regmap_p rp = sc->sc_siopp;
    833 	struct siop_acb *acb = sc->sc_nexus;
    834 	int	target;
    835 	int	dfifo, dbc, sstat1;
    836 
    837 	dfifo = rp->siop_dfifo;
    838 	dbc = rp->siop_dbc0;
    839 	sstat1 = rp->siop_sstat1;
    840 	rp->siop_ctest8 |= SIOP_CTEST8_CLF;
    841 	while ((rp->siop_ctest1 & SIOP_CTEST1_FMT) != SIOP_CTEST1_FMT)
    842 		;
    843 	rp->siop_ctest8 &= ~SIOP_CTEST8_CLF;
    844 #ifdef DEBUG
    845 	++siopints;
    846 #if 0
    847 	if (siop_debug & 0x100) {
    848 		DCIAS(&acb->stat[0]);	/* XXX */
    849 		printf ("siopchkintr: istat %x dstat %x sstat0 %x dsps %x sbcl %x sts %x msg %x\n",
    850 		    istat, dstat, sstat0, rp->siop_dsps, rp->siop_sbcl, acb->stat[0], acb->msg[0]);
    851 		printf ("sync msg in: %02x %02x %02x %02x %02x %02x\n",
    852 		    acb->msg[0], acb->msg[1], acb->msg[2],
    853 		    acb->msg[3], acb->msg[4], acb->msg[5]);
    854 	}
    855 #endif
    856 	if (rp->siop_dsp && (rp->siop_dsp < sc->sc_scriptspa ||
    857 	    rp->siop_dsp >= sc->sc_scriptspa + sizeof(scripts))) {
    858 		printf ("%s: dsp not within script dsp %x scripts %x:%x",
    859 		    sc->sc_dev.dv_xname, rp->siop_dsp, sc->sc_scriptspa,
    860 		    sc->sc_scriptspa + sizeof(scripts));
    861 		printf(" istat %x dstat %x sstat0 %x\n",
    862 		    istat, dstat, sstat0);
    863 		Debugger();
    864 	}
    865 #endif
    866 	SIOP_TRACE('i',dstat,istat,(istat&SIOP_ISTAT_DIP)?rp->siop_dsps&0xff:sstat0);
    867 	if (dstat & SIOP_DSTAT_SIR && rp->siop_dsps == 0xff00) {
    868 		/* Normal completion status, or check condition */
    869 #ifdef DEBUG
    870 		if (rp->siop_dsa != kvtop(&acb->ds)) {
    871 			printf ("siop: invalid dsa: %x %x\n", rp->siop_dsa,
    872 			    kvtop(&acb->ds));
    873 			panic("*** siop DSA invalid ***");
    874 		}
    875 #endif
    876 		target = acb->xs->sc_link->target;
    877 		if (sc->sc_sync[target].state == SYNC_SENT) {
    878 #ifdef DEBUG
    879 			if (siopsync_debug)
    880 				printf ("sync msg in: %02x %02x %02x %02x %02x %02x\n",
    881 				    acb->msg[0], acb->msg[1], acb->msg[2],
    882 				    acb->msg[3], acb->msg[4], acb->msg[5]);
    883 #endif
    884 			if (acb->msg[1] == 0xff)
    885 				printf ("%s: target %d ignored sync request\n",
    886 				    sc->sc_dev.dv_xname, target);
    887 			else if (acb->msg[1] == MSG_REJECT)
    888 				printf ("%s: target %d rejected sync request\n",
    889 				    sc->sc_dev.dv_xname, target);
    890 			sc->sc_sync[target].state = SYNC_DONE;
    891 			sc->sc_sync[target].sxfer = 0;
    892 			sc->sc_sync[target].sbcl = 0;
    893 			if (acb->msg[2] == 3 &&
    894 			    acb->msg[3] == MSG_SYNC_REQ &&
    895 			    acb->msg[5] != 0) {
    896 #ifdef MAXTOR_KLUDGE
    897 				/*
    898 				 * Kludge for my Maxtor XT8580S
    899 				 * It accepts whatever we request, even
    900 				 * though it won't work.  So we ask for
    901 				 * a short period than we can handle.  If
    902 				 * the device says it can do it, use 208ns.
    903 				 * If the device says it can do less than
    904 				 * 100ns, then we limit it to 100ns.
    905 				 */
    906 				if (acb->msg[4] && acb->msg[4] < 100 / 4) {
    907 #ifdef DEBUG
    908 					printf ("%d: target %d wanted %dns period\n",
    909 					    sc->sc_dev.dv_xname, target,
    910 					    acb->msg[4] * 4);
    911 #endif
    912 					if (acb->msg[4] == 50 / 4)
    913 						acb->msg[4] = 208 / 4;
    914 					else
    915 						acb->msg[4] = 100 / 4;
    916 				}
    917 #endif /* MAXTOR_KLUDGE */
    918 				printf ("%s: target %d now synchronous, period=%dns, offset=%d\n",
    919 				    sc->sc_dev.dv_xname, target,
    920 				    acb->msg[4] * 4, acb->msg[5]);
    921 				scsi_period_to_siop (sc, target);
    922 			}
    923 		}
    924 		dma_cachectl(&acb->stat[0], 1);
    925 		*status = acb->stat[0];
    926 #ifdef DEBUG
    927 		if (rp->siop_sbcl & SIOP_BSY) {
    928 			/*printf ("ACK! siop was busy at end: rp %x script %x dsa %x\n",
    929 			    rp, &scripts, &acb->ds);*/
    930 #ifdef DDB
    931 			/*Debugger();*/
    932 #endif
    933 		}
    934 		if (acb->msg[0] != 0x00)
    935 			printf("%s: message was not COMMAND COMPLETE: %x\n",
    936 			    sc->sc_dev.dv_xname, acb->msg[0]);
    937 #endif
    938 		if (sc->nexus_list.tqh_first)
    939 			rp->siop_dcntl |= SIOP_DCNTL_STD;
    940 		return 1;
    941 	}
    942 	if (sstat0 & SIOP_SSTAT0_M_A) {		/* Phase mismatch */
    943 #ifdef DEBUG
    944 		++siopphmm;
    945 		if (acb == NULL)
    946 			printf("%s: Phase mismatch with no active command?\n",
    947 			    sc->sc_dev.dv_xname);
    948 #endif
    949 		if (acb->iob_len) {
    950 			int adjust;
    951 			adjust = ((dfifo - (dbc & 0x7f)) & 0x7f);
    952 			if (sstat1 & SIOP_SSTAT1_ORF)
    953 				++adjust;
    954 			if (sstat1 & SIOP_SSTAT1_OLF)
    955 				++adjust;
    956 			acb->iob_curlen = *((long *)&rp->siop_dcmd) & 0xffffff;
    957 			acb->iob_curlen += adjust;
    958 			acb->iob_curbuf = *((long *)&rp->siop_dnad) - adjust;
    959 #ifdef DEBUG
    960 			if (siop_debug & 0x100) {
    961 				int i;
    962 				printf ("Phase mismatch: curbuf %x curlen %x dfifo %x dbc %x sstat1 %x adjust %x sbcl %x starts %d acb %x\n",
    963 				    acb->iob_curbuf, acb->iob_curlen, dfifo,
    964 				    dbc, sstat1, adjust, rp->siop_sbcl, siopstarts, acb);
    965 				if (acb->ds.chain[1].datalen) {
    966 					for (i = 0; acb->ds.chain[i].datalen; ++i)
    967 						printf("chain[%d] addr %x len %x\n",
    968 						    i, acb->ds.chain[i].databuf,
    969 						    acb->ds.chain[i].datalen);
    970 				}
    971 			}
    972 #endif
    973 			dma_cachectl (acb, sizeof(*acb));
    974 		}
    975 #ifdef DEBUG
    976 		SIOP_TRACE('m',rp->siop_sbcl,(rp->siop_dsp>>8),rp->siop_dsp);
    977 		if (siop_debug & 9)
    978 			printf ("Phase mismatch: %x dsp +%x dcmd %x\n",
    979 			    rp->siop_sbcl,
    980 			    rp->siop_dsp - sc->sc_scriptspa,
    981 			    *((long *)&rp->siop_dcmd));
    982 #endif
    983 		if ((rp->siop_sbcl & SIOP_REQ) == 0) {
    984 			printf ("Phase mismatch: REQ not asserted! %02x dsp %x\n",
    985 			    rp->siop_sbcl, rp->siop_dsp);
    986 #ifdef DEBUG
    987 			Debugger();
    988 #endif
    989 		}
    990 		switch (rp->siop_sbcl & 7) {
    991 		case 0:		/* data out */
    992 		case 1:		/* data in */
    993 		case 2:		/* status */
    994 		case 3:		/* command */
    995 		case 6:		/* message in */
    996 		case 7:		/* message out */
    997 			rp->siop_dsp = sc->sc_scriptspa + Ent_switch;
    998 			break;
    999 		default:
   1000 			goto bad_phase;
   1001 		}
   1002 		return 0;
   1003 	}
   1004 	if (sstat0 & SIOP_SSTAT0_STO) {		/* Select timed out */
   1005 #ifdef DEBUG
   1006 		if (acb == NULL)
   1007 			printf("%s: Select timeout with no active command?\n",
   1008 			    sc->sc_dev.dv_xname);
   1009 		if (rp->siop_sbcl & SIOP_BSY) {
   1010 			printf ("ACK! siop was busy at timeout: rp %x script %x dsa %x\n",
   1011 			    rp, &scripts, &acb->ds);
   1012 			printf(" sbcl %x sdid %x istat %x dstat %x sstat0 %x\n",
   1013 			    rp->siop_sbcl, rp->siop_sdid, istat, dstat, sstat0);
   1014 			if (!(rp->siop_sbcl & SIOP_BSY)) {
   1015 				printf ("Yikes, it's not busy now!\n");
   1016 #if 0
   1017 				*status = -1;
   1018 				if (sc->nexus_list.tqh_first)
   1019 					rp->siop_dsp = sc->sc_scriptspa + Ent_wait_reselect;
   1020 				return 1;
   1021 #endif
   1022 			}
   1023 /*			rp->siop_dcntl |= SIOP_DCNTL_STD;*/
   1024 			return (0);
   1025 #ifdef DDB
   1026 			Debugger();
   1027 #endif
   1028 		}
   1029 #endif
   1030 		*status = -1;
   1031 		acb->xs->error = XS_SELTIMEOUT;
   1032 		if (sc->nexus_list.tqh_first)
   1033 			rp->siop_dsp = sc->sc_scriptspa + Ent_wait_reselect;
   1034 		return 1;
   1035 	}
   1036 	if (acb)
   1037 		target = acb->xs->sc_link->target;
   1038 	else
   1039 		target = 7;
   1040 	if (sstat0 & SIOP_SSTAT0_UDC) {
   1041 #ifdef DEBUG
   1042 		if (acb == NULL)
   1043 			printf("%s: Unexpected disconnect with no active command?\n",
   1044 			    sc->sc_dev.dv_xname);
   1045 		printf ("%s: target %d disconnected unexpectedly\n",
   1046 		   sc->sc_dev.dv_xname, target);
   1047 #endif
   1048 #if 0
   1049 		siopabort (sc, rp, "siopchkintr");
   1050 #endif
   1051 		*status = STS_BUSY;
   1052 		if (sc->nexus_list.tqh_first)
   1053 			rp->siop_dsp = sc->sc_scriptspa + Ent_wait_reselect;
   1054 		return 1;
   1055 	}
   1056 	if (dstat & SIOP_DSTAT_SIR && (rp->siop_dsps == 0xff01 ||
   1057 	    rp->siop_dsps == 0xff02)) {
   1058 #ifdef DEBUG
   1059 		if (siop_debug & 0x100)
   1060 			printf ("%s: ID %02x disconnected TEMP %x (+%x) curbuf %x curlen %x buf %x len %x dfifo %x dbc %x sstat1 %x starts %d acb %x\n",
   1061 			    sc->sc_dev.dv_xname, 1 << target, rp->siop_temp,
   1062 			    rp->siop_temp ? rp->siop_temp - sc->sc_scriptspa : 0,
   1063 			    acb->iob_curbuf, acb->iob_curlen,
   1064 			    acb->ds.chain[0].databuf, acb->ds.chain[0].datalen, dfifo, dbc, sstat1, siopstarts, acb);
   1065 #endif
   1066 		if (acb == NULL) {
   1067 			printf("%s: Disconnect with no active command?\n",
   1068 			    sc->sc_dev.dv_xname);
   1069 			return (0);
   1070 		}
   1071 		/*
   1072 		 * XXXX need to update iob_curbuf/iob_curlen to reflect
   1073 		 * current data transferred.  If device disconnected in
   1074 		 * the middle of a DMA block, they should already be set
   1075 		 * by the phase change interrupt.  If the disconnect
   1076 		 * occurs on a DMA block boundary, we have to figure out
   1077 		 * which DMA block it was.
   1078 		 */
   1079 		if (acb->iob_len && rp->siop_temp) {
   1080 			int n = rp->siop_temp - sc->sc_scriptspa;
   1081 
   1082 			if (acb->iob_curlen && acb->iob_curlen != acb->ds.chain[0].datalen)
   1083 				printf("%s: iob_curbuf/len already set? n %x iob %x/%x chain[0] %x/%x\n",
   1084 				    sc->sc_dev.dv_xname, n, acb->iob_curbuf, acb->iob_curlen,
   1085 				    acb->ds.chain[0].databuf, acb->ds.chain[0].datalen);
   1086 			if (n < Ent_datain)
   1087 				n = (n - Ent_dataout) / 16;
   1088 			else
   1089 				n = (n - Ent_datain) / 16;
   1090 			if (n <= 0 && n > DMAMAXIO)
   1091 				printf("TEMP invalid %d\n", n);
   1092 			else {
   1093 				acb->iob_curbuf = (u_long)acb->ds.chain[n].databuf;
   1094 				acb->iob_curlen = acb->ds.chain[n].datalen;
   1095 			}
   1096 #ifdef DEBUG
   1097 			if (siop_debug & 0x100) {
   1098 				printf("%s: TEMP offset %d", sc->sc_dev.dv_xname, n);
   1099 				printf(" curbuf %x curlen %x\n", acb->iob_curbuf,
   1100 				    acb->iob_curlen);
   1101 			}
   1102 #endif
   1103 		}
   1104 		/*
   1105 		 * If data transfer was interrupted by disconnect, iob_curbuf
   1106 		 * and iob_curlen should reflect the point of interruption.
   1107 		 * Adjust the DMA chain so that the data transfer begins
   1108 		 * at the appropriate place upon reselection.
   1109 		 * XXX This should only be done on save data pointer message?
   1110 		 */
   1111 		if (acb->iob_curlen) {
   1112 			int i, j;
   1113 
   1114 #ifdef DEBUG
   1115 			if (siop_debug & 0x100)
   1116 				printf ("%s: adjusting DMA chain\n",
   1117 				    sc->sc_dev.dv_xname);
   1118 			if (rp->siop_dsps == 0xff02)
   1119 				printf ("%s: ID %02x disconnected without Save Data Pointers\n",
   1120 				    sc->sc_dev.dv_xname, 1 << target);
   1121 #endif
   1122 			for (i = 0; i < DMAMAXIO; ++i) {
   1123 				if (acb->ds.chain[i].datalen == 0)
   1124 					break;
   1125 				if (acb->iob_curbuf >= (long)acb->ds.chain[i].databuf &&
   1126 				    acb->iob_curbuf < (long)(acb->ds.chain[i].databuf +
   1127 				    acb->ds.chain[i].datalen))
   1128 					break;
   1129 			}
   1130 			if (i >= DMAMAXIO || acb->ds.chain[i].datalen == 0)
   1131 				printf("couldn't find saved data pointer\n");
   1132 #ifdef DEBUG
   1133 			if (siop_debug & 0x100)
   1134 				printf("  chain[0]: %x/%x -> %x/%x\n",
   1135 				    acb->ds.chain[0].databuf,
   1136 				    acb->ds.chain[0].datalen,
   1137 				    acb->iob_curbuf,
   1138 				    acb->iob_curlen);
   1139 #endif
   1140 			acb->ds.chain[0].databuf = (char *)acb->iob_curbuf;
   1141 			acb->ds.chain[0].datalen = acb->iob_curlen;
   1142 			for (j = 1, ++i; i < DMAMAXIO && acb->ds.chain[i].datalen; ++i, ++j) {
   1143 #ifdef DEBUG
   1144 			if (siop_debug & 0x100)
   1145 				printf("  chain[%d]: %x/%x -> %x/%x\n", j,
   1146 				    acb->ds.chain[j].databuf,
   1147 				    acb->ds.chain[j].datalen,
   1148 				    acb->ds.chain[i].databuf,
   1149 				    acb->ds.chain[i].datalen);
   1150 #endif
   1151 				acb->ds.chain[j].databuf = acb->ds.chain[i].databuf;
   1152 				acb->ds.chain[j].datalen = acb->ds.chain[i].datalen;
   1153 			}
   1154 			if (j < DMAMAXIO)
   1155 				acb->ds.chain[j].datalen = 0;
   1156 			DCIAS(kvtop(&acb->ds.chain));
   1157 		}
   1158 		++sc->sc_tinfo[target].dconns;
   1159 		/*
   1160 		 * add nexus to waiting list
   1161 		 * clear nexus
   1162 		 * try to start another command for another target/lun
   1163 		 */
   1164 		acb->status = sc->sc_flags & SIOP_INTSOFF;
   1165 		TAILQ_INSERT_HEAD(&sc->nexus_list, acb, chain);
   1166 		sc->sc_nexus = NULL;		/* no current device */
   1167 		/* start script to wait for reselect */
   1168 		if (sc->sc_nexus == NULL)
   1169 			rp->siop_dsp = sc->sc_scriptspa + Ent_wait_reselect;
   1170 /* XXXX start another command ? */
   1171 		if (sc->ready_list.tqh_first)
   1172 			siop_sched(sc);
   1173 		return (0);
   1174 	}
   1175 	if (dstat & SIOP_DSTAT_SIR && rp->siop_dsps == 0xff03) {
   1176 		int reselid = rp->siop_scratch & 0x7f;
   1177 		int reselun = rp->siop_sfbr & 0x07;
   1178 
   1179 		sc->sc_sstat1 = rp->siop_sbcl;	/* XXXX save current SBCL */
   1180 #ifdef DEBUG
   1181 		if (siop_debug & 0x100)
   1182 			printf ("%s: target ID %02x reselected dsps %x\n",
   1183 			     sc->sc_dev.dv_xname, reselid,
   1184 			     rp->siop_dsps);
   1185 		if ((rp->siop_sfbr & 0x80) == 0)
   1186 			printf("%s: Reselect message in was not identify: %x\n",
   1187 			    sc->sc_dev.dv_xname, rp->siop_sfbr);
   1188 #endif
   1189 		if (sc->sc_nexus) {
   1190 #ifdef DEBUG
   1191 			if (siop_debug & 0x100)
   1192 				printf ("%s: reselect ID %02x w/active\n",
   1193 				    sc->sc_dev.dv_xname, reselid);
   1194 #endif
   1195 			TAILQ_INSERT_HEAD(&sc->ready_list, sc->sc_nexus, chain);
   1196 			sc->sc_tinfo[sc->sc_nexus->xs->sc_link->target].lubusy
   1197 			    &= ~(1 << sc->sc_nexus->xs->sc_link->lun);
   1198 			--sc->sc_active;
   1199 		}
   1200 		/*
   1201 		 * locate acb of reselecting device
   1202 		 * set sc->sc_nexus to acb
   1203 		 */
   1204 		for (acb = sc->nexus_list.tqh_first; acb;
   1205 		    acb = acb->chain.tqe_next) {
   1206 			if (reselid != (acb->ds.scsi_addr >> 16) ||
   1207 			    reselun != (acb->msgout[0] & 0x07))
   1208 				continue;
   1209 			TAILQ_REMOVE(&sc->nexus_list, acb, chain);
   1210 			sc->sc_nexus = acb;
   1211 			sc->sc_flags |= acb->status;
   1212 			acb->status = 0;
   1213 			DCIAS(kvtop(&acb->stat[0]));
   1214 			rp->siop_dsa = kvtop(&acb->ds);
   1215 			rp->siop_sxfer = sc->sc_sync[acb->xs->sc_link->target].sxfer;
   1216 			rp->siop_sbcl = sc->sc_sync[acb->xs->sc_link->target].sbcl;
   1217 			break;
   1218 		}
   1219 		if (acb == NULL) {
   1220 			printf("%s: target ID %02x reselect nexus_list %x\n",
   1221 			    sc->sc_dev.dv_xname, reselid,
   1222 			    sc->nexus_list.tqh_first);
   1223 			panic("unable to find reselecting device");
   1224 		}
   1225 		dma_cachectl (acb, sizeof(*acb));
   1226 		rp->siop_temp = 0;
   1227 		rp->siop_dcntl |= SIOP_DCNTL_STD;
   1228 		return (0);
   1229 	}
   1230 	if (dstat & SIOP_DSTAT_SIR && rp->siop_dsps == 0xff04) {
   1231 		u_short ctest2 = rp->siop_ctest2;
   1232 
   1233 		/* reselect was interrupted (by Sig_P or select) */
   1234 #ifdef DEBUG
   1235 		if (siop_debug & 0x100 ||
   1236 		    (ctest2 & SIOP_CTEST2_SIGP) == 0)
   1237 			printf ("%s: reselect interrupted (Sig_P?) scntl1 %x ctest2 %x sfbr %x istat %x/%x\n",
   1238 			    sc->sc_dev.dv_xname, rp->siop_scntl1,
   1239 			    ctest2, rp->siop_sfbr, istat, rp->siop_istat);
   1240 #endif
   1241 		/* XXX assumes it was not select */
   1242 		if (sc->sc_nexus == NULL) {
   1243 			printf("%s: reselect interrupted, sc_nexus == NULL\n",
   1244 			    sc->sc_dev.dv_xname);
   1245 #if 0
   1246 			siop_dump(sc);
   1247 #ifdef DDB
   1248 			Debugger();
   1249 #endif
   1250 #endif
   1251 			rp->siop_dcntl |= SIOP_DCNTL_STD;
   1252 			return(0);
   1253 		}
   1254 		target = sc->sc_nexus->xs->sc_link->target;
   1255 		rp->siop_temp = 0;
   1256 		rp->siop_dsa = kvtop(&sc->sc_nexus->ds);
   1257 		rp->siop_sxfer = sc->sc_sync[target].sxfer;
   1258 		rp->siop_sbcl = sc->sc_sync[target].sbcl;
   1259 		rp->siop_dsp = sc->sc_scriptspa;
   1260 		return (0);
   1261 	}
   1262 	if (dstat & SIOP_DSTAT_SIR && rp->siop_dsps == 0xff06) {
   1263 		if (acb == NULL)
   1264 			printf("%s: Bad message-in with no active command?\n",
   1265 			    sc->sc_dev.dv_xname);
   1266 		/* Unrecognized message in byte */
   1267 		dma_cachectl (&acb->msg[1],1);
   1268 		printf ("%s: Unrecognized message in data sfbr %x msg %x sbcl %x\n",
   1269 			sc->sc_dev.dv_xname, rp->siop_sfbr, acb->msg[1], rp->siop_sbcl);
   1270 		/* what should be done here? */
   1271 		DCIAS(kvtop(&acb->msg[1]));
   1272 		rp->siop_dsp = sc->sc_scriptspa + Ent_switch;
   1273 		return (0);
   1274 	}
   1275 	if (dstat & SIOP_DSTAT_SIR && rp->siop_dsps == 0xff0a) {
   1276 		/* Status phase wasn't followed by message in phase? */
   1277 		printf ("%s: Status phase not followed by message in phase? sbcl %x sbdl %x\n",
   1278 			sc->sc_dev.dv_xname, rp->siop_sbcl, rp->siop_sbdl);
   1279 		if (rp->siop_sbcl == 0xa7) {
   1280 			/* It is now, just continue the script? */
   1281 			rp->siop_dcntl |= SIOP_DCNTL_STD;
   1282 			return (0);
   1283 		}
   1284 	}
   1285 	if (sstat0 == 0 && dstat & SIOP_DSTAT_SIR) {
   1286 		dma_cachectl (&acb->stat[0], 1);
   1287 		dma_cachectl (&acb->msg[0], 1);
   1288 		printf ("SIOP interrupt: %x sts %x msg %x %x sbcl %x\n",
   1289 		    rp->siop_dsps, acb->stat[0], acb->msg[0], acb->msg[1],
   1290 		    rp->siop_sbcl);
   1291 		siopreset (sc);
   1292 		*status = -1;
   1293 		return 0;	/* siopreset has cleaned up */
   1294 	}
   1295 	if (sstat0 & SIOP_SSTAT0_SGE)
   1296 		printf ("SIOP: SCSI Gross Error\n");
   1297 	if (sstat0 & SIOP_SSTAT0_PAR)
   1298 		printf ("SIOP: Parity Error\n");
   1299 	if (dstat & SIOP_DSTAT_IID)
   1300 		printf ("SIOP: Invalid instruction detected\n");
   1301 bad_phase:
   1302 	/*
   1303 	 * temporary panic for unhandled conditions
   1304 	 * displays various things about the 53C710 status and registers
   1305 	 * then panics.
   1306 	 * XXXX need to clean this up to print out the info, reset, and continue
   1307 	 */
   1308 	printf ("siopchkintr: target %x ds %x\n", target, &acb->ds);
   1309 	printf ("scripts %x ds %x rp %x dsp %x dcmd %x\n", sc->sc_scriptspa,
   1310 	    kvtop(&acb->ds), kvtop(rp), rp->siop_dsp,
   1311 	    *((long *)&rp->siop_dcmd));
   1312 	printf ("siopchkintr: istat %x dstat %x sstat0 %x dsps %x dsa %x sbcl %x sts %x msg %x %x sfbr %x\n",
   1313 	    istat, dstat, sstat0, rp->siop_dsps, rp->siop_dsa,
   1314 	     rp->siop_sbcl, acb->stat[0], acb->msg[0], acb->msg[1], rp->siop_sfbr);
   1315 #ifdef DEBUG
   1316 	if (siop_debug & 0x20)
   1317 		panic("siopchkintr: **** temp ****");
   1318 #endif
   1319 #ifdef DDB
   1320 	Debugger ();
   1321 #endif
   1322 	siopreset (sc);		/* hard reset */
   1323 	*status = -1;
   1324 	return 0;		/* siopreset cleaned up */
   1325 }
   1326 
   1327 void
   1328 siop_select(sc)
   1329 	struct siop_softc *sc;
   1330 {
   1331 	siop_regmap_p rp;
   1332 	struct siop_acb *acb = sc->sc_nexus;
   1333 
   1334 #ifdef DEBUG
   1335 	if (siop_debug & 1)
   1336 		printf ("%s: select ", sc->sc_dev.dv_xname);
   1337 #endif
   1338 
   1339 	rp = sc->sc_siopp;
   1340 	if (acb->xs->flags & SCSI_POLL || siop_no_dma) {
   1341 		sc->sc_flags |= SIOP_INTSOFF;
   1342 		sc->sc_flags &= ~SIOP_INTDEFER;
   1343 		if ((rp->siop_istat & 0x08) == 0) {
   1344 			rp->siop_sien = 0;
   1345 			rp->siop_dien = 0;
   1346 		}
   1347 #if 0
   1348 	} else if ((sc->sc_flags & SIOP_INTDEFER) == 0) {
   1349 		sc->sc_flags &= ~SIOP_INTSOFF;
   1350 		if ((rp->siop_istat & 0x08) == 0) {
   1351 			rp->siop_sien = sc->sc_sien;
   1352 			rp->siop_dien = sc->sc_dien;
   1353 		}
   1354 #endif
   1355 	}
   1356 #ifdef DEBUG
   1357 	if (siop_debug & 1)
   1358 		printf ("siop_select: target %x cmd %02x ds %x\n",
   1359 		    acb->xs->sc_link->target, acb->cmd.opcode,
   1360 		    &sc->sc_nexus->ds);
   1361 #endif
   1362 
   1363 	siop_start(sc, acb->xs->sc_link->target, acb->xs->sc_link->lun,
   1364 	    &acb->cmd, acb->clen, acb->daddr, acb->dleft);
   1365 
   1366 	return;
   1367 }
   1368 
   1369 /*
   1370  * 53C710 interrupt handler
   1371  */
   1372 
   1373 int
   1374 siopintr (sc)
   1375 	register struct siop_softc *sc;
   1376 {
   1377 	siop_regmap_p rp;
   1378 	register u_char istat, dstat, sstat0;
   1379 	int status;
   1380 	int s = splbio();
   1381 
   1382 	istat = sc->sc_istat;
   1383 	if ((istat & (SIOP_ISTAT_SIP | SIOP_ISTAT_DIP)) == 0) {
   1384 		splx(s);
   1385 		return;
   1386 	}
   1387 
   1388 	/* Got a valid interrupt on this device */
   1389 	rp = sc->sc_siopp;
   1390 	dstat = sc->sc_dstat;
   1391 	sstat0 = sc->sc_sstat0;
   1392 	if (dstat & SIOP_DSTAT_SIR)
   1393 		sc->sc_intcode = rp->siop_dsps;
   1394 	sc->sc_istat = 0;
   1395 #ifdef DEBUG
   1396 	if (siop_debug & 1)
   1397 		printf ("%s: intr istat %x dstat %x sstat0 %x\n",
   1398 		    sc->sc_dev.dv_xname, istat, dstat, sstat0);
   1399 	if (!sc->sc_active) {
   1400 		printf ("%s: spurious interrupt? istat %x dstat %x sstat0 %x status %x\n",
   1401 		    sc->sc_dev.dv_xname, istat, dstat, sstat0, sc->sc_nexus->stat[0]);
   1402 	}
   1403 #endif
   1404 
   1405 #ifdef DEBUG
   1406 	if (siop_debug & 5) {
   1407 		DCIAS(kvtop(&sc->sc_nexus->stat[0]));
   1408 		printf ("%s: intr istat %x dstat %x sstat0 %x dsps %x sbcl %x sts %x msg %x\n",
   1409 		    sc->sc_dev.dv_xname, istat, dstat, sstat0,
   1410 		    rp->siop_dsps,  rp->siop_sbcl,
   1411 		    sc->sc_nexus->stat[0], sc->sc_nexus->msg[0]);
   1412 	}
   1413 #endif
   1414 	if (sc->sc_flags & SIOP_INTDEFER) {
   1415 		sc->sc_flags &= ~(SIOP_INTDEFER | SIOP_INTSOFF);
   1416 		rp->siop_sien = sc->sc_sien;
   1417 		rp->siop_dien = sc->sc_dien;
   1418 	}
   1419 	if (siop_checkintr (sc, istat, dstat, sstat0, &status)) {
   1420 #if 1
   1421 		if (status == 0xff)
   1422 			printf ("siopintr: status == 0xff\n");
   1423 #endif
   1424 		if ((sc->sc_flags & (SIOP_INTSOFF | SIOP_INTDEFER)) != SIOP_INTSOFF) {
   1425 #if 0
   1426 			if (rp->siop_sbcl & SIOP_BSY) {
   1427 				printf ("%s: SCSI bus busy at completion",
   1428 					sc->sc_dev.dv_xname);
   1429 				printf(" targ %d sbcl %02x sfbr %x lcrc %02x dsp +%x\n",
   1430 				    sc->sc_nexus->xs->sc_link->target,
   1431 				    rp->siop_sbcl, rp->siop_sfbr, rp->siop_lcrc,
   1432 				    rp->siop_dsp - sc->sc_scriptspa);
   1433 			}
   1434 #endif
   1435 			siop_scsidone(sc->sc_nexus, sc->sc_nexus->stat[0]);
   1436 		}
   1437 	}
   1438 	splx(s);
   1439 }
   1440 
   1441 /*
   1442  * This is based on the Progressive Peripherals 33Mhz Zeus driver and will
   1443  * not be correct for other 53c710 boards.
   1444  *
   1445  */
   1446 scsi_period_to_siop (sc, target)
   1447 	struct siop_softc *sc;
   1448 {
   1449 	int period, offset, i, sxfer, sbcl;
   1450 
   1451 	period = sc->sc_nexus->msg[4];
   1452 	offset = sc->sc_nexus->msg[5];
   1453 #ifdef DEBUG
   1454 	sxfer = 0;
   1455 	if (offset <= SIOP_MAX_OFFSET)
   1456 		sxfer = offset;
   1457 	for (i = 0; i < sizeof (sync_tab) / 2; ++i) {
   1458 		if (period <= sync_tab[i].p) {
   1459 			sxfer |= sync_tab[i].r & 0x70;
   1460 			sbcl = sync_tab[i].r & 0x03;
   1461 			break;
   1462 		}
   1463 	}
   1464 	printf ("siop sync old: siop_sxfr %02x, siop_sbcl %02x\n", sxfer, sbcl);
   1465 #endif
   1466 	for (sbcl = 1; sbcl < 4; ++sbcl) {
   1467 		sxfer = (period * 4 - 1) / sc->sc_tcp[sbcl] - 3;
   1468 		if (sxfer >= 0 && sxfer <= 7)
   1469 			break;
   1470 	}
   1471 	if (sbcl > 3) {
   1472 		printf("siop sync: unable to compute sync params for period %dns\n",
   1473 		    period * 4);
   1474 		/*
   1475 		 * XXX need to pick a value we can do and renegotiate
   1476 		 */
   1477 		sxfer = sbcl = 0;
   1478 	} else {
   1479 		sxfer = (sxfer << 4) | ((offset <= SIOP_MAX_OFFSET) ?
   1480 		    offset : SIOP_MAX_OFFSET);
   1481 		printf("siop sync: params for period %dns: sxfer %x sbcl %x",
   1482 		    period * 4, sxfer, sbcl);
   1483 		printf(" actual period %dns\n",
   1484 		    sc->sc_tcp[sbcl] * ((sxfer >> 4) + 4));
   1485 	}
   1486 	sc->sc_sync[target].sxfer = sxfer;
   1487 	sc->sc_sync[target].sbcl = sbcl;
   1488 #ifdef DEBUG
   1489 	printf ("siop sync: siop_sxfr %02x, siop_sbcl %02x\n", sxfer, sbcl);
   1490 #endif
   1491 }
   1492 
   1493 #ifdef DEBUG
   1494 
   1495 #if SIOP_TRACE_SIZE
   1496 void
   1497 siop_dump_trace()
   1498 {
   1499 	int i;
   1500 
   1501 	printf("siop trace: next index %d\n", siop_trix);
   1502 	i = siop_trix;
   1503 	do {
   1504 		printf("%3d: '%c' %02x %02x %02x\n", i, siop_trbuf[i],
   1505 		    siop_trbuf[i + 1], siop_trbuf[i + 2], siop_trbuf[i + 3]);
   1506 		i = (i + 4) & (SIOP_TRACE_SIZE - 1);
   1507 	} while (i != siop_trix);
   1508 }
   1509 #endif
   1510 
   1511 void
   1512 siop_dump_acb(acb)
   1513 	struct siop_acb *acb;
   1514 {
   1515 	u_char *b = (u_char *) &acb->cmd;
   1516 	int i;
   1517 
   1518 	printf("acb@%x ", acb);
   1519 	if (acb->xs == NULL) {
   1520 		printf("<unused>\n");
   1521 		return;
   1522 	}
   1523 	printf("(%d:%d) flags %2x clen %2d cmd ", acb->xs->sc_link->target,
   1524 	    acb->xs->sc_link->lun, acb->flags, acb->clen);
   1525 	for (i = acb->clen; i; --i)
   1526 		printf(" %02x", *b++);
   1527 	printf("\n");
   1528 	printf("  xs: %08x data %8x:%04x ", acb->xs, acb->xs->data,
   1529 	    acb->xs->datalen);
   1530 	printf("va %8x:%04x ", acb->iob_buf, acb->iob_len);
   1531 	printf("cur %8x:%04x\n", acb->iob_curbuf, acb->iob_curlen);
   1532 }
   1533 
   1534 void
   1535 siop_dump(sc)
   1536 	struct siop_softc *sc;
   1537 {
   1538 	struct siop_acb *acb;
   1539 	siop_regmap_p rp = sc->sc_siopp;
   1540 	int s;
   1541 	int i;
   1542 
   1543 	s = splbio();
   1544 #if SIOP_TRACE_SIZE
   1545 	siop_dump_trace();
   1546 #endif
   1547 	printf("%s@%x regs %x istat %x\n",
   1548 	    sc->sc_dev.dv_xname, sc, rp, rp->siop_istat);
   1549 	if (acb = sc->free_list.tqh_first) {
   1550 		printf("Free list:\n");
   1551 		while (acb) {
   1552 			siop_dump_acb(acb);
   1553 			acb = acb->chain.tqe_next;
   1554 		}
   1555 	}
   1556 	if (acb = sc->ready_list.tqh_first) {
   1557 		printf("Ready list:\n");
   1558 		while (acb) {
   1559 			siop_dump_acb(acb);
   1560 			acb = acb->chain.tqe_next;
   1561 		}
   1562 	}
   1563 	if (acb = sc->nexus_list.tqh_first) {
   1564 		printf("Nexus list:\n");
   1565 		while (acb) {
   1566 			siop_dump_acb(acb);
   1567 			acb = acb->chain.tqe_next;
   1568 		}
   1569 	}
   1570 	if (sc->sc_nexus) {
   1571 		printf("Nexus:\n");
   1572 		siop_dump_acb(sc->sc_nexus);
   1573 	}
   1574 	for (i = 0; i < 8; ++i) {
   1575 		if (sc->sc_tinfo[i].cmds > 2) {
   1576 			printf("tgt %d: cmds %d disc %d senses %d lubusy %x\n",
   1577 			    i, sc->sc_tinfo[i].cmds,
   1578 			    sc->sc_tinfo[i].dconns,
   1579 			    sc->sc_tinfo[i].senses,
   1580 			    sc->sc_tinfo[i].lubusy);
   1581 		}
   1582 	}
   1583 	splx(s);
   1584 }
   1585 #endif
   1586