1995-01-05 10:22:31 +03:00
|
|
|
/* $NetBSD: siop.c,v 1.19 1995/01/05 07:22:48 chopps Exp $ */
|
1994-10-26 05:01:24 +03:00
|
|
|
|
1994-01-27 00:05:34 +03:00
|
|
|
/*
|
1994-05-12 09:56:28 +04:00
|
|
|
* Copyright (c) 1994 Michael L. Hitch
|
1994-01-27 00:05:34 +03:00
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Van Jacobson of Lawrence Berkeley Laboratory.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* @(#)siop.c 7.5 (Berkeley) 5/4/91
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AMIGA 53C710 scsi adaptor driver
|
|
|
|
*/
|
1994-02-01 14:51:59 +03:00
|
|
|
|
|
|
|
/* need to know if any tapes have been configured */
|
|
|
|
#include "st.h"
|
|
|
|
|
1994-02-14 00:10:20 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1994-05-12 09:56:28 +04:00
|
|
|
#include <sys/device.h>
|
1994-02-14 00:10:20 +03:00
|
|
|
#include <sys/buf.h>
|
1994-05-12 09:56:28 +04:00
|
|
|
#include <scsi/scsi_all.h>
|
|
|
|
#include <scsi/scsiconf.h>
|
1994-02-14 00:10:20 +03:00
|
|
|
#include <machine/cpu.h>
|
1994-05-12 09:56:28 +04:00
|
|
|
#include <amiga/amiga/custom.h>
|
|
|
|
#include <amiga/dev/siopreg.h>
|
|
|
|
#include <amiga/dev/siopvar.h>
|
1994-01-27 00:05:34 +03:00
|
|
|
|
|
|
|
extern u_int kvtop();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SCSI delays
|
|
|
|
* In u-seconds, primarily for state changes on the SPC.
|
|
|
|
*/
|
1994-06-13 12:12:30 +04:00
|
|
|
#define SCSI_CMD_WAIT 500000 /* wait per step of 'immediate' cmds */
|
|
|
|
#define SCSI_DATA_WAIT 500000 /* wait per data in/out step */
|
|
|
|
#define SCSI_INIT_WAIT 500000 /* wait per step (both) during init */
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
int siopicmd __P((struct siop_softc *, int, int, void *, int, void *, int));
|
1994-05-12 09:56:28 +04:00
|
|
|
int siopgo __P((struct siop_softc *, struct scsi_xfer *));
|
|
|
|
int siopgetsense __P((struct siop_softc *, struct scsi_xfer *));
|
|
|
|
void siopabort __P((struct siop_softc *, siop_regmap_p, char *));
|
|
|
|
void sioperror __P((struct siop_softc *, siop_regmap_p, u_char));
|
|
|
|
void siopstart __P((struct siop_softc *));
|
|
|
|
void siopreset __P((struct siop_softc *));
|
|
|
|
void siopsetdelay __P((int));
|
|
|
|
void siop_scsidone __P((struct siop_softc *, int));
|
|
|
|
void siop_donextcmd __P((struct siop_softc *));
|
|
|
|
int siopintr __P((struct siop_softc *));
|
1994-01-27 00:05:34 +03:00
|
|
|
|
|
|
|
/* 53C710 script */
|
1994-12-28 12:24:55 +03:00
|
|
|
#include <amiga/dev/siop_script.out>
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-05-12 09:56:28 +04:00
|
|
|
/* default to not inhibit sync negotiation on any drive */
|
1994-06-22 20:20:48 +04:00
|
|
|
u_char siop_inhibit_sync[8] = { 0, 0, 0, 0, 0, 0, 0 }; /* initialize, so patchable */
|
1994-12-28 12:24:55 +03:00
|
|
|
u_char siop_allow_disc[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
1994-05-12 09:56:28 +04:00
|
|
|
int siop_no_dma = 0;
|
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
int siop_reset_delay = 250; /* delay after reset, in milleseconds */
|
1994-05-12 09:56:28 +04:00
|
|
|
int siop_sync_period = 50; /* synchronous transfer period, in nanoseconds */
|
1994-01-27 00:05:34 +03:00
|
|
|
|
|
|
|
int siop_cmd_wait = SCSI_CMD_WAIT;
|
|
|
|
int siop_data_wait = SCSI_DATA_WAIT;
|
|
|
|
int siop_init_wait = SCSI_INIT_WAIT;
|
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
/*
|
|
|
|
* sync period transfer lookup - only valid for 66Mhz clock
|
|
|
|
*/
|
1994-01-27 00:05:34 +03:00
|
|
|
static struct {
|
|
|
|
unsigned char x; /* period from sync request message */
|
|
|
|
unsigned char y; /* siop_period << 4 | sbcl */
|
|
|
|
} xxx[] = {
|
1994-12-28 12:24:55 +03:00
|
|
|
{ 60/4, 0<<4 | 1},
|
|
|
|
{ 76/4, 1<<4 | 1},
|
|
|
|
{ 92/4, 2<<4 | 1},
|
|
|
|
{ 92/4, 0<<4 | 2},
|
|
|
|
{108/4, 3<<4 | 1},
|
|
|
|
{116/4, 1<<4 | 2},
|
|
|
|
{120/4, 4<<4 | 1},
|
|
|
|
{120/4, 0<<4 | 3},
|
|
|
|
{136/4, 5<<4 | 1},
|
|
|
|
{140/4, 2<<4 | 2},
|
|
|
|
{152/4, 6<<4 | 1},
|
|
|
|
{152/4, 1<<4 | 3},
|
|
|
|
{164/4, 3<<4 | 2},
|
|
|
|
{168/4, 7<<4 | 1},
|
|
|
|
{180/4, 2<<4 | 3},
|
|
|
|
{184/4, 4<<4 | 2},
|
|
|
|
{208/4, 5<<4 | 2},
|
|
|
|
{212/4, 3<<4 | 3},
|
|
|
|
{232/4, 6<<4 | 2},
|
|
|
|
{240/4, 4<<4 | 3},
|
|
|
|
{256/4, 7<<4 | 2},
|
|
|
|
{272/4, 5<<4 | 3},
|
|
|
|
{300/4, 6<<4 | 3},
|
|
|
|
{332/4, 7<<4 | 3}
|
1994-01-27 00:05:34 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1994-05-12 09:56:28 +04:00
|
|
|
#define QPRINTF(a) if (siop_debug > 1) printf a
|
|
|
|
/*
|
|
|
|
* 0x01 - full debug
|
|
|
|
* 0x02 - DMA chaining
|
|
|
|
* 0x04 - siopintr
|
|
|
|
* 0x08 - phase mismatch
|
|
|
|
* 0x10 - panic on phase mismatch
|
1994-06-27 08:56:29 +04:00
|
|
|
* 0x20 - panic on unhandled exceptions
|
1994-12-28 12:24:55 +03:00
|
|
|
* 0x100 - disconnect/reconnect
|
1994-05-12 09:56:28 +04:00
|
|
|
*/
|
|
|
|
int siop_debug = 0;
|
|
|
|
int siopsync_debug = 0;
|
|
|
|
int siopdma_hits = 0;
|
|
|
|
int siopdma_misses = 0;
|
1994-06-22 20:20:48 +04:00
|
|
|
int siopchain_ints = 0;
|
1994-12-28 12:24:55 +03:00
|
|
|
int siopstarts = 0;
|
|
|
|
int siopints = 0;
|
|
|
|
int siopphmm = 0;
|
1994-07-18 12:06:40 +04:00
|
|
|
#else
|
|
|
|
#define QPRINTF(a)
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
1994-05-12 09:56:28 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* default minphys routine for siop based controllers
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
siop_minphys(bp)
|
|
|
|
struct buf *bp;
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* no max transfer at this level
|
|
|
|
*/
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-05-12 09:56:28 +04:00
|
|
|
* used by specific siop controller
|
1994-01-27 00:05:34 +03:00
|
|
|
*
|
1994-05-12 09:56:28 +04:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
siop_scsicmd(xs)
|
|
|
|
struct scsi_xfer *xs;
|
|
|
|
{
|
|
|
|
struct siop_pending *pendp;
|
|
|
|
struct siop_softc *dev;
|
|
|
|
struct scsi_link *slp;
|
1994-12-28 12:24:55 +03:00
|
|
|
int flags, s, i;
|
1994-05-12 09:56:28 +04:00
|
|
|
|
|
|
|
slp = xs->sc_link;
|
|
|
|
dev = slp->adapter_softc;
|
|
|
|
flags = xs->flags;
|
|
|
|
|
|
|
|
if (flags & SCSI_DATA_UIO)
|
|
|
|
panic("siop: scsi data uio requested");
|
|
|
|
|
1995-01-05 10:22:31 +03:00
|
|
|
if (dev->sc_xs && flags & SCSI_POLL)
|
1994-05-12 09:56:28 +04:00
|
|
|
panic("siop_scsicmd: busy");
|
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
pendp = &dev->sc_xsstore[slp->target][slp->lun];
|
|
|
|
if (pendp->xs) {
|
|
|
|
splx(s);
|
|
|
|
return(TRY_AGAIN_LATER);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dev->sc_xs) {
|
|
|
|
pendp->xs = xs;
|
|
|
|
TAILQ_INSERT_TAIL(&dev->sc_xslist, pendp, link);
|
|
|
|
splx(s);
|
|
|
|
return(SUCCESSFULLY_QUEUED);
|
|
|
|
}
|
|
|
|
pendp->xs = NULL;
|
|
|
|
dev->sc_xs = xs;
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* nothing is pending do it now.
|
|
|
|
*/
|
|
|
|
siop_donextcmd(dev);
|
|
|
|
|
1995-01-05 10:22:31 +03:00
|
|
|
if (flags & SCSI_POLL)
|
1994-05-12 09:56:28 +04:00
|
|
|
return(COMPLETE);
|
|
|
|
return(SUCCESSFULLY_QUEUED);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* entered with dev->sc_xs pointing to the next xfer to perform
|
1994-01-27 00:05:34 +03:00
|
|
|
*/
|
|
|
|
void
|
1994-05-12 09:56:28 +04:00
|
|
|
siop_donextcmd(dev)
|
|
|
|
struct siop_softc *dev;
|
1994-01-27 00:05:34 +03:00
|
|
|
{
|
1994-05-12 09:56:28 +04:00
|
|
|
struct scsi_xfer *xs;
|
|
|
|
struct scsi_link *slp;
|
1994-12-28 12:24:55 +03:00
|
|
|
int flags, stat, i;
|
1994-05-12 09:56:28 +04:00
|
|
|
|
|
|
|
xs = dev->sc_xs;
|
|
|
|
slp = xs->sc_link;
|
|
|
|
flags = xs->flags;
|
|
|
|
|
|
|
|
if (flags & SCSI_RESET)
|
|
|
|
siopreset(dev);
|
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
xs->cmd->bytes[0] |= slp->lun << 5;
|
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
if (dev->sc_iob[i].sc_xs == NULL) {
|
|
|
|
dev->sc_iob[i].sc_xs = xs;
|
|
|
|
dev->sc_cur = & dev->sc_iob[i];
|
|
|
|
dev->sc_iob[i].sc_stat[0] = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dev->sc_cur == NULL)
|
|
|
|
panic ("siop: too many I/O's");
|
|
|
|
++dev->sc_active;
|
1994-05-12 09:56:28 +04:00
|
|
|
#if 0
|
1994-12-28 12:24:55 +03:00
|
|
|
if (dev->sc_active > 1) {
|
|
|
|
printf ("active count %d\n", dev->sc_active);
|
|
|
|
}
|
1994-05-12 09:56:28 +04:00
|
|
|
#endif
|
1995-01-05 10:22:31 +03:00
|
|
|
if (flags & SCSI_POLL || siop_no_dma)
|
1994-12-28 12:24:55 +03:00
|
|
|
stat = siopicmd(dev, slp->target, slp->lun, xs->cmd,
|
|
|
|
xs->cmdlen, xs->data, xs->datalen);
|
1994-05-12 09:56:28 +04:00
|
|
|
else if (siopgo(dev, xs) == 0)
|
|
|
|
return;
|
|
|
|
else
|
1994-12-28 12:24:55 +03:00
|
|
|
stat = dev->sc_cur->sc_stat[0];
|
1994-05-12 09:56:28 +04:00
|
|
|
|
|
|
|
siop_scsidone(dev, stat);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
siop_scsidone(dev, stat)
|
|
|
|
struct siop_softc *dev;
|
|
|
|
int stat;
|
|
|
|
{
|
|
|
|
struct siop_pending *pendp;
|
|
|
|
struct scsi_xfer *xs;
|
|
|
|
int s, donext;
|
|
|
|
|
|
|
|
xs = dev->sc_xs;
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (xs == NULL)
|
|
|
|
panic("siop_scsidone");
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* is this right?
|
|
|
|
*/
|
|
|
|
xs->status = stat;
|
|
|
|
|
1995-01-05 10:22:31 +03:00
|
|
|
if (stat == 0)
|
1994-05-12 09:56:28 +04:00
|
|
|
xs->resid = 0;
|
|
|
|
else {
|
|
|
|
switch(stat) {
|
|
|
|
case SCSI_CHECK:
|
|
|
|
if (stat = siopgetsense(dev, xs))
|
|
|
|
goto bad_sense;
|
|
|
|
xs->error = XS_SENSE;
|
|
|
|
break;
|
|
|
|
case SCSI_BUSY:
|
|
|
|
xs->error = XS_BUSY;
|
|
|
|
break;
|
|
|
|
bad_sense:
|
|
|
|
default:
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
QPRINTF(("siop_scsicmd() bad %x\n", stat));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xs->flags |= ITSDONE;
|
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
--dev->sc_active;
|
|
|
|
dev->sc_cur->sc_xs = NULL;
|
|
|
|
dev->sc_cur = NULL;
|
|
|
|
/*
|
|
|
|
* if another command is already pending (i.e. it was pre-empted
|
|
|
|
* by a reconnecting device), make it the current command and
|
|
|
|
* continue
|
|
|
|
*/
|
|
|
|
|
1994-05-12 09:56:28 +04:00
|
|
|
/*
|
|
|
|
* grab next command before scsi_done()
|
|
|
|
* this way no single device can hog scsi resources.
|
|
|
|
*/
|
|
|
|
s = splbio();
|
|
|
|
pendp = dev->sc_xslist.tqh_first;
|
|
|
|
if (pendp == NULL) {
|
|
|
|
donext = 0;
|
|
|
|
dev->sc_xs = NULL;
|
1994-01-27 00:05:34 +03:00
|
|
|
} else {
|
1994-05-12 09:56:28 +04:00
|
|
|
donext = 1;
|
|
|
|
TAILQ_REMOVE(&dev->sc_xslist, pendp, link);
|
|
|
|
dev->sc_xs = pendp->xs;
|
|
|
|
pendp->xs = NULL;
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
1994-05-12 09:56:28 +04:00
|
|
|
splx(s);
|
|
|
|
scsi_done(xs);
|
|
|
|
|
|
|
|
if (donext)
|
|
|
|
siop_donextcmd(dev);
|
1994-12-28 12:24:55 +03:00
|
|
|
else if (dev->sc_active && dev->sc_xs == NULL) {
|
|
|
|
/* printf ("siop_scsidone: still active %d\n", dev->sc_active);*/
|
|
|
|
/* dev->sc_siopp->siop_dsp = dev->sc_scriptspa + Ent_wait_reselect;*/
|
|
|
|
}
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
|
|
|
|
1994-05-12 09:56:28 +04:00
|
|
|
int
|
|
|
|
siopgetsense(dev, xs)
|
|
|
|
struct siop_softc *dev;
|
|
|
|
struct scsi_xfer *xs;
|
|
|
|
{
|
|
|
|
struct scsi_sense rqs;
|
|
|
|
struct scsi_link *slp;
|
|
|
|
int stat;
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-05-12 09:56:28 +04:00
|
|
|
slp = xs->sc_link;
|
|
|
|
|
1995-01-05 10:22:31 +03:00
|
|
|
rqs.opcode = REQUEST_SENSE;
|
1994-05-12 09:56:28 +04:00
|
|
|
rqs.byte2 = slp->lun << 5;
|
1994-05-12 10:43:09 +04:00
|
|
|
#ifdef not_yet
|
1994-05-12 09:56:28 +04:00
|
|
|
rqs.length = xs->req_sense_length ? xs->req_sense_length :
|
|
|
|
sizeof(xs->sense);
|
1994-05-12 10:43:09 +04:00
|
|
|
#else
|
|
|
|
rqs.length = sizeof(xs->sense);
|
|
|
|
#endif
|
1994-05-12 09:56:28 +04:00
|
|
|
if (rqs.length > sizeof (xs->sense))
|
|
|
|
rqs.length = sizeof (xs->sense);
|
|
|
|
rqs.unused[0] = rqs.unused[1] = rqs.control = 0;
|
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
return(siopicmd(dev, slp->target, slp->lun, &rqs, sizeof(rqs),
|
|
|
|
&xs->sense, rqs.length));
|
1994-05-12 09:56:28 +04:00
|
|
|
}
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-05-12 09:56:28 +04:00
|
|
|
void
|
1994-01-27 00:05:34 +03:00
|
|
|
siopabort(dev, regs, where)
|
|
|
|
register struct siop_softc *dev;
|
1994-05-12 09:56:28 +04:00
|
|
|
siop_regmap_p regs;
|
1994-01-27 00:05:34 +03:00
|
|
|
char *where;
|
|
|
|
{
|
1994-12-28 12:24:55 +03:00
|
|
|
int i;
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-05-12 09:56:28 +04:00
|
|
|
printf ("%s: abort %s: dstat %02x, sstat0 %02x sbcl %02x\n",
|
|
|
|
dev->sc_dev.dv_xname,
|
1994-01-27 00:05:34 +03:00
|
|
|
where, regs->siop_dstat, regs->siop_sstat0, regs->siop_sbcl);
|
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
if (dev->sc_active > 0) {
|
1994-01-27 00:05:34 +03:00
|
|
|
#ifdef TODO
|
|
|
|
SET_SBIC_cmd (regs, SBIC_CMD_ABORT);
|
|
|
|
WAIT_CIP (regs);
|
|
|
|
|
|
|
|
GET_SBIC_asr (regs, asr);
|
|
|
|
if (asr & (SBIC_ASR_BSY|SBIC_ASR_LCI))
|
|
|
|
{
|
|
|
|
/* ok, get more drastic.. */
|
|
|
|
|
|
|
|
SET_SBIC_cmd (regs, SBIC_CMD_RESET);
|
1994-06-13 12:12:30 +04:00
|
|
|
delay(25);
|
1994-01-27 00:05:34 +03:00
|
|
|
SBIC_WAIT(regs, SBIC_ASR_INT, 0);
|
|
|
|
GET_SBIC_csr (regs, csr); /* clears interrupt also */
|
|
|
|
|
|
|
|
dev->sc_flags &= ~SIOP_SELECTED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
SBIC_WAIT (regs, SBIC_ASR_INT, 0);
|
|
|
|
GET_SBIC_csr (regs, csr);
|
|
|
|
}
|
|
|
|
while ((csr != SBIC_CSR_DISC) && (csr != SBIC_CSR_DISC_1)
|
|
|
|
&& (csr != SBIC_CSR_CMD_INVALID));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* lets just hope it worked.. */
|
|
|
|
dev->sc_flags &= ~SIOP_SELECTED;
|
1994-12-28 12:24:55 +03:00
|
|
|
for (i = 0; i < 2; ++i) {
|
|
|
|
if (dev->sc_iob[i].sc_xs && &dev->sc_iob[i] !=
|
|
|
|
dev->sc_cur) {
|
|
|
|
printf ("siopabort: cleanup!\n");
|
|
|
|
dev->sc_iob[i].sc_xs = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dev->sc_active = 0;
|
1994-05-12 09:56:28 +04:00
|
|
|
}
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
|
|
|
|
1994-06-14 04:58:05 +04:00
|
|
|
void
|
|
|
|
siopinitialize(dev)
|
|
|
|
struct siop_softc *dev;
|
|
|
|
{
|
|
|
|
/*
|
1994-06-22 20:20:48 +04:00
|
|
|
* Need to check that scripts is on a long word boundary
|
|
|
|
* and that DS is on a long word boundary.
|
1994-12-28 12:24:55 +03:00
|
|
|
* Also need to verify that dev doesn't span non-contiguous
|
1994-06-22 20:20:48 +04:00
|
|
|
* physical pages.
|
1994-06-14 04:58:05 +04:00
|
|
|
*/
|
|
|
|
dev->sc_scriptspa = kvtop(scripts);
|
1994-12-28 12:24:55 +03:00
|
|
|
#if 0
|
1994-06-14 04:58:05 +04:00
|
|
|
dev->sc_dspa = kvtop(&dev->sc_ds);
|
1994-12-28 12:24:55 +03:00
|
|
|
dev->sc_lunpa = kvtop(&dev->sc_msgout);
|
1994-06-14 04:58:05 +04:00
|
|
|
dev->sc_statuspa = kvtop(&dev->sc_stat[0]);
|
|
|
|
dev->sc_msgpa = kvtop(&dev->sc_msg[0]);
|
1994-12-28 12:24:55 +03:00
|
|
|
#endif
|
1994-06-14 04:58:05 +04:00
|
|
|
siopreset (dev);
|
|
|
|
}
|
|
|
|
|
1994-01-27 00:05:34 +03:00
|
|
|
void
|
1994-05-12 09:56:28 +04:00
|
|
|
siopreset(dev)
|
|
|
|
struct siop_softc *dev;
|
1994-01-27 00:05:34 +03:00
|
|
|
{
|
1994-05-12 09:56:28 +04:00
|
|
|
siop_regmap_p regs;
|
1994-01-27 00:05:34 +03:00
|
|
|
u_int i, s;
|
1994-12-28 12:24:55 +03:00
|
|
|
u_char my_id, dummy;
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-05-12 09:56:28 +04:00
|
|
|
regs = dev->sc_siopp;
|
|
|
|
|
1994-01-27 00:05:34 +03:00
|
|
|
if (dev->sc_flags & SIOP_ALIVE)
|
|
|
|
siopabort(dev, regs, "reset");
|
|
|
|
|
1994-06-22 20:20:48 +04:00
|
|
|
printf("%s: ", dev->sc_dev.dv_xname); /* XXXX */
|
1994-01-27 00:05:34 +03:00
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
my_id = 7;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the chip
|
|
|
|
* XXX - is this really needed?
|
|
|
|
*/
|
1994-12-28 12:24:55 +03:00
|
|
|
regs->siop_istat |= SIOP_ISTAT_ABRT; /* abort current script */
|
|
|
|
regs->siop_istat |= SIOP_ISTAT_RST; /* reset chip */
|
|
|
|
regs->siop_istat &= ~SIOP_ISTAT_RST;
|
|
|
|
/*
|
|
|
|
* Reset SCSI bus (do we really want this?)
|
|
|
|
*/
|
1994-01-27 00:05:34 +03:00
|
|
|
regs->siop_sien &= ~SIOP_SIEN_RST;
|
|
|
|
regs->siop_scntl1 |= SIOP_SCNTL1_RST;
|
1994-12-28 12:24:55 +03:00
|
|
|
delay(1);
|
1994-01-27 00:05:34 +03:00
|
|
|
regs->siop_scntl1 &= ~SIOP_SCNTL1_RST;
|
1994-12-28 12:24:55 +03:00
|
|
|
/* regs->siop_sien |= SIOP_SIEN_RST;*/
|
1994-01-27 00:05:34 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up various chip parameters
|
|
|
|
*/
|
|
|
|
regs->siop_scntl0 = SIOP_ARB_FULL | SIOP_SCNTL0_EPC | SIOP_SCNTL0_EPG;
|
1994-05-12 09:56:28 +04:00
|
|
|
regs->siop_dcntl = dev->sc_clock_freq & 0xff;
|
|
|
|
regs->siop_dmode = 0x80; /* burst length = 4 */
|
1994-01-27 00:05:34 +03:00
|
|
|
regs->siop_sien = 0x00; /* don't enable interrupts yet */
|
|
|
|
regs->siop_dien = 0x00; /* don't enable interrupts yet */
|
|
|
|
regs->siop_scid = 1 << my_id;
|
|
|
|
regs->siop_dwt = 0x00;
|
1994-12-28 12:24:55 +03:00
|
|
|
regs->siop_ctest0 |= SIOP_CTEST0_BTD | SIOP_CTEST0_EAN;
|
1994-05-12 09:56:28 +04:00
|
|
|
regs->siop_ctest7 |= (dev->sc_clock_freq >> 8) & 0xff;
|
1994-01-27 00:05:34 +03:00
|
|
|
|
|
|
|
/* will need to re-negotiate sync xfers */
|
|
|
|
bzero(&dev->sc_sync, sizeof (dev->sc_sync));
|
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
i = regs->siop_istat;
|
|
|
|
if (i & SIOP_ISTAT_SIP)
|
|
|
|
dummy = regs->siop_sstat0;
|
|
|
|
if (i & SIOP_ISTAT_DIP)
|
|
|
|
dummy = regs->siop_dstat;
|
|
|
|
|
1994-01-27 00:05:34 +03:00
|
|
|
splx (s);
|
|
|
|
|
1994-06-13 12:12:30 +04:00
|
|
|
delay (siop_reset_delay * 1000);
|
1994-12-28 12:24:55 +03:00
|
|
|
printf("siop id %d reset V%d\n", my_id, regs->siop_ctest8 >> 4);
|
1994-01-27 00:05:34 +03:00
|
|
|
dev->sc_flags |= SIOP_ALIVE;
|
|
|
|
dev->sc_flags &= ~(SIOP_SELECTED | SIOP_DMA);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup Data Storage for 53C710 and start SCRIPTS processing
|
|
|
|
*/
|
|
|
|
|
1994-05-12 09:56:28 +04:00
|
|
|
void
|
1994-12-28 12:24:55 +03:00
|
|
|
siop_setup (dev, target, lun, cbuf, clen, buf, len)
|
1994-01-27 00:05:34 +03:00
|
|
|
struct siop_softc *dev;
|
|
|
|
int target;
|
1994-12-28 12:24:55 +03:00
|
|
|
int lun;
|
1994-01-27 00:05:34 +03:00
|
|
|
u_char *cbuf;
|
|
|
|
int clen;
|
|
|
|
u_char *buf;
|
|
|
|
int len;
|
|
|
|
{
|
1994-05-12 09:56:28 +04:00
|
|
|
siop_regmap_p regs = dev->sc_siopp;
|
1994-01-27 00:05:34 +03:00
|
|
|
int i;
|
|
|
|
int nchain;
|
|
|
|
int count, tcount;
|
|
|
|
char *addr, *dmaend;
|
1994-12-28 12:24:55 +03:00
|
|
|
struct siop_iob *iob = dev->sc_cur;
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (regs->siop_sbcl & SIOP_BSY) {
|
|
|
|
printf ("ACK! siop was busy: regs %x script %x dsa %x\n",
|
|
|
|
regs, &scripts, &iob->sc_ds);
|
|
|
|
/*Debugger();*/
|
|
|
|
}
|
|
|
|
i = regs->siop_istat;
|
|
|
|
if (i & SIOP_ISTAT_DIP) {
|
|
|
|
int dstat;
|
|
|
|
dstat = regs->siop_dstat;
|
|
|
|
}
|
|
|
|
if (i & SIOP_ISTAT_SIP) {
|
|
|
|
int sstat;
|
|
|
|
sstat = regs->siop_sstat0;
|
|
|
|
}
|
|
|
|
#endif
|
1994-01-27 00:05:34 +03:00
|
|
|
dev->sc_istat = 0;
|
1994-12-28 12:24:55 +03:00
|
|
|
iob->sc_msgout[0] = MSG_IDENTIFY | lun;
|
|
|
|
/*
|
|
|
|
* HACK - if no data transfer, allow disconnects
|
|
|
|
*/
|
|
|
|
if (/*len == 0 || */ siop_allow_disc[target]) {
|
|
|
|
iob->sc_msgout[0] = MSG_IDENTIFY_DR | lun;
|
|
|
|
regs->siop_scntl1 |= SIOP_SCNTL1_ESR;
|
|
|
|
}
|
|
|
|
iob->sc_status = 0;
|
|
|
|
iob->sc_stat[0] = -1;
|
|
|
|
iob->sc_msg[0] = -1;
|
|
|
|
iob->sc_ds.scsi_addr = (0x10000 << target) | (dev->sc_sync[target].period << 8);
|
|
|
|
iob->sc_ds.idlen = 1;
|
|
|
|
iob->sc_ds.idbuf = (char *) kvtop(&iob->sc_msgout[0]);
|
|
|
|
iob->sc_ds.cmdlen = clen;
|
|
|
|
iob->sc_ds.cmdbuf = (char *) kvtop(cbuf);
|
|
|
|
iob->sc_ds.stslen = 1;
|
|
|
|
iob->sc_ds.stsbuf = (char *) kvtop(&iob->sc_stat[0]);
|
|
|
|
iob->sc_ds.msglen = 1;
|
|
|
|
iob->sc_ds.msgbuf = (char *) kvtop(&iob->sc_msg[0]);
|
|
|
|
iob->sc_msg[1] = -1;
|
|
|
|
iob->sc_ds.msginlen = 1;
|
|
|
|
iob->sc_ds.extmsglen = 1;
|
|
|
|
iob->sc_ds.synmsglen = 3;
|
|
|
|
iob->sc_ds.msginbuf = (char *) kvtop(&iob->sc_msg[1]);
|
|
|
|
iob->sc_ds.extmsgbuf = (char *) kvtop(&iob->sc_msg[2]);
|
|
|
|
iob->sc_ds.synmsgbuf = (char *) kvtop(&iob->sc_msg[3]);
|
|
|
|
bzero(&iob->sc_ds.chain, sizeof (iob->sc_ds.chain));
|
1994-01-27 00:05:34 +03:00
|
|
|
|
|
|
|
if (dev->sc_sync[target].state == SYNC_START) {
|
1994-05-12 09:56:28 +04:00
|
|
|
if (siop_inhibit_sync[target]) {
|
1994-01-27 00:05:34 +03:00
|
|
|
dev->sc_sync[target].state = SYNC_DONE;
|
|
|
|
dev->sc_sync[target].offset = 0;
|
|
|
|
dev->sc_sync[target].period = 0;
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siopsync_debug)
|
|
|
|
printf ("Forcing target %d asynchronous\n", target);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else {
|
1994-12-28 12:24:55 +03:00
|
|
|
iob->sc_msg[2] = -1;
|
|
|
|
iob->sc_msgout[1] = MSG_EXT_MESSAGE;
|
|
|
|
iob->sc_msgout[2] = 3;
|
|
|
|
iob->sc_msgout[3] = MSG_SYNC_REQ;
|
|
|
|
iob->sc_msgout[4] = siop_sync_period / 4;
|
|
|
|
iob->sc_msgout[5] = SIOP_MAX_OFFSET;
|
|
|
|
iob->sc_ds.idlen = 6;
|
1994-01-27 00:05:34 +03:00
|
|
|
dev->sc_sync[target].state = SYNC_SENT;
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siopsync_debug)
|
|
|
|
printf ("Sending sync request to target %d\n", target);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If length is > 1 page, check for consecutive physical pages
|
|
|
|
* Need to set up chaining if not
|
|
|
|
*/
|
1994-12-28 12:24:55 +03:00
|
|
|
iob->iob_buf = buf;
|
|
|
|
iob->iob_len = len;
|
|
|
|
iob->iob_curbuf = iob->iob_curlen = 0;
|
1994-01-27 00:05:34 +03:00
|
|
|
nchain = 0;
|
|
|
|
count = len;
|
|
|
|
addr = buf;
|
|
|
|
dmaend = NULL;
|
|
|
|
while (count > 0) {
|
1994-12-28 12:24:55 +03:00
|
|
|
iob->sc_ds.chain[nchain].databuf = (char *) kvtop (addr);
|
1994-01-27 00:05:34 +03:00
|
|
|
if (count < (tcount = NBPG - ((int) addr & PGOFSET)))
|
|
|
|
tcount = count;
|
1994-12-28 12:24:55 +03:00
|
|
|
iob->sc_ds.chain[nchain].datalen = tcount;
|
1994-01-27 00:05:34 +03:00
|
|
|
addr += tcount;
|
|
|
|
count -= tcount;
|
1994-12-28 12:24:55 +03:00
|
|
|
if (iob->sc_ds.chain[nchain].databuf == dmaend) {
|
|
|
|
dmaend += iob->sc_ds.chain[nchain].datalen;
|
|
|
|
iob->sc_ds.chain[--nchain].datalen += tcount;
|
1994-01-27 00:05:34 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
++siopdma_hits;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else {
|
1994-12-28 12:24:55 +03:00
|
|
|
dmaend = iob->sc_ds.chain[nchain].databuf +
|
|
|
|
iob->sc_ds.chain[nchain].datalen;
|
|
|
|
iob->sc_ds.chain[nchain].datalen = tcount;
|
1994-01-27 00:05:34 +03:00
|
|
|
#ifdef DEBUG
|
1994-06-22 20:20:48 +04:00
|
|
|
if (nchain) /* Don't count miss on first one */
|
|
|
|
++siopdma_misses;
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
++nchain;
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (nchain != 1 && len != 0 && siop_debug & 3) {
|
|
|
|
printf ("DMA chaining set: %d\n", nchain);
|
|
|
|
for (i = 0; i < nchain; ++i) {
|
1994-12-28 12:24:55 +03:00
|
|
|
printf (" [%d] %8x %4x\n", i, iob->sc_ds.chain[i].databuf,
|
|
|
|
iob->sc_ds.chain[i].datalen);
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
|
|
|
}
|
1994-12-28 12:24:55 +03:00
|
|
|
if (regs->siop_sbcl & SIOP_BSY) {
|
|
|
|
printf ("ACK! siop was busy at start: regs %x script %x dsa %x\n",
|
|
|
|
regs, &scripts, &iob->sc_ds);
|
|
|
|
/*Debugger();*/
|
|
|
|
}
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
/* push data case on data the 53c710 needs to access */
|
1994-06-14 04:58:05 +04:00
|
|
|
dma_cachectl (dev, sizeof (struct siop_softc));
|
|
|
|
dma_cachectl (cbuf, clen);
|
|
|
|
if (buf != NULL && len != 0)
|
|
|
|
dma_cachectl (buf, len);
|
1994-12-28 12:24:55 +03:00
|
|
|
if (dev->sc_active <= 1) {
|
|
|
|
regs->siop_sbcl = dev->sc_sync[target].offset;
|
|
|
|
regs->siop_dsa = kvtop(&iob->sc_ds);
|
|
|
|
/* XXX if disconnected devices pending, this may not work */
|
|
|
|
regs->siop_dsp = dev->sc_scriptspa;
|
|
|
|
} else {
|
|
|
|
regs->siop_istat = SIOP_ISTAT_SIGP;
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
++siopstarts;
|
|
|
|
#endif
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process a DMA or SCSI interrupt from the 53C710 SIOP
|
|
|
|
*/
|
|
|
|
|
1994-05-12 09:56:28 +04:00
|
|
|
int
|
1994-01-27 00:05:34 +03:00
|
|
|
siop_checkintr(dev, istat, dstat, sstat0, status)
|
|
|
|
struct siop_softc *dev;
|
|
|
|
u_char istat;
|
|
|
|
u_char dstat;
|
|
|
|
u_char sstat0;
|
|
|
|
int *status;
|
|
|
|
{
|
1994-05-12 09:56:28 +04:00
|
|
|
siop_regmap_p regs = dev->sc_siopp;
|
1994-12-28 12:24:55 +03:00
|
|
|
struct siop_iob *iob = dev->sc_cur;
|
1994-01-27 00:05:34 +03:00
|
|
|
int target;
|
1994-12-28 12:24:55 +03:00
|
|
|
int dfifo, dbc, sstat1;
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
dfifo = regs->siop_dfifo;
|
|
|
|
dbc = regs->siop_dbc0;
|
|
|
|
sstat1 = regs->siop_sstat1;
|
|
|
|
regs->siop_ctest8 |= SIOP_CTEST8_CLF;
|
1994-01-27 00:05:34 +03:00
|
|
|
while ((regs->siop_ctest1 & SIOP_CTEST1_FMT) == 0)
|
|
|
|
;
|
1994-12-28 12:24:55 +03:00
|
|
|
regs->siop_ctest8 &= ~SIOP_CTEST8_CLF;
|
1994-01-27 00:05:34 +03:00
|
|
|
#ifdef DEBUG
|
1994-12-28 12:24:55 +03:00
|
|
|
++siopints;
|
|
|
|
if (siop_debug & 0x100) {
|
|
|
|
DCIAS(&iob->sc_stat[0]); /* XXX */
|
1994-01-27 00:05:34 +03:00
|
|
|
printf ("siopchkintr: istat %x dstat %x sstat0 %x dsps %x sbcl %x sts %x msg %x\n",
|
1994-12-28 12:24:55 +03:00
|
|
|
istat, dstat, sstat0, regs->siop_dsps, regs->siop_sbcl, iob->sc_stat[0], iob->sc_msg[0]);
|
|
|
|
printf ("sync msg in: %02x %02x %02x %02x %02x %02x\n",
|
|
|
|
iob->sc_msg[0], iob->sc_msg[1], iob->sc_msg[2],
|
|
|
|
iob->sc_msg[3], iob->sc_msg[4], iob->sc_msg[5]);
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-12-28 12:24:55 +03:00
|
|
|
if (dstat & SIOP_DSTAT_SIR && regs->siop_dsps == 0xff00) {
|
1994-01-27 00:05:34 +03:00
|
|
|
/* Normal completion status, or check condition */
|
1994-12-28 12:24:55 +03:00
|
|
|
if (regs->siop_dsa != kvtop(&iob->sc_ds)) {
|
1994-01-27 00:05:34 +03:00
|
|
|
printf ("siop: invalid dsa: %x %x\n", regs->siop_dsa,
|
1994-12-28 12:24:55 +03:00
|
|
|
kvtop(&iob->sc_ds));
|
1994-01-27 00:05:34 +03:00
|
|
|
panic("*** siop DSA invalid ***");
|
|
|
|
}
|
|
|
|
target = dev->sc_slave;
|
|
|
|
if (dev->sc_sync[target].state == SYNC_SENT) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siopsync_debug)
|
|
|
|
printf ("sync msg in: %02x %02x %02x %02x %02x %02x\n",
|
1994-12-28 12:24:55 +03:00
|
|
|
iob->sc_msg[0], iob->sc_msg[1], iob->sc_msg[2],
|
|
|
|
iob->sc_msg[3], iob->sc_msg[4], iob->sc_msg[5]);
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
1994-12-28 12:24:55 +03:00
|
|
|
if (iob->sc_msg[1] == 0xff)
|
|
|
|
printf ("%s: target %d ignored sync request\n",
|
|
|
|
dev->sc_dev.dv_xname, target);
|
|
|
|
else if (iob->sc_msg[1] == MSG_REJECT)
|
|
|
|
printf ("%s: target %d rejected sync request\n",
|
|
|
|
dev->sc_dev.dv_xname, target);
|
1994-01-27 00:05:34 +03:00
|
|
|
dev->sc_sync[target].state = SYNC_DONE;
|
|
|
|
dev->sc_sync[target].period = 0;
|
|
|
|
dev->sc_sync[target].offset = 0;
|
1994-12-28 12:24:55 +03:00
|
|
|
if (iob->sc_msg[2] == 3 &&
|
|
|
|
iob->sc_msg[3] == MSG_SYNC_REQ &&
|
|
|
|
iob->sc_msg[5] != 0) {
|
|
|
|
if (iob->sc_msg[4] && iob->sc_msg[4] < 100 / 4) {
|
1994-05-12 09:56:28 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf ("%d: target %d wanted %dns period\n",
|
|
|
|
dev->sc_dev.dv_xname, target,
|
1994-12-28 12:24:55 +03:00
|
|
|
iob->sc_msg[4] * 4);
|
1994-05-12 09:56:28 +04:00
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* Kludge for Maxtor XT8580S
|
|
|
|
* It accepts whatever we request, even
|
|
|
|
* though it won't work. So we ask for
|
|
|
|
* a short period than we can handle. If
|
|
|
|
* the device says it can do it, use 208ns.
|
|
|
|
* If the device says it can do less than
|
|
|
|
* 100ns, then we limit it to 100ns.
|
|
|
|
*/
|
1994-12-28 12:24:55 +03:00
|
|
|
if (iob->sc_msg[4] == siop_sync_period / 4)
|
|
|
|
iob->sc_msg[4] = 208 / 4;
|
1994-05-12 09:56:28 +04:00
|
|
|
else
|
1994-12-28 12:24:55 +03:00
|
|
|
iob->sc_msg[4] = 100 / 4;
|
1994-05-12 09:56:28 +04:00
|
|
|
}
|
|
|
|
printf ("%s: target %d now synchronous, period=%dns, offset=%d\n",
|
|
|
|
dev->sc_dev.dv_xname, target,
|
1994-12-28 12:24:55 +03:00
|
|
|
iob->sc_msg[4] * 4, iob->sc_msg[5]);
|
1994-01-27 00:05:34 +03:00
|
|
|
scsi_period_to_siop (dev, target);
|
|
|
|
}
|
|
|
|
}
|
1994-06-14 04:58:05 +04:00
|
|
|
#if 0
|
1994-06-22 20:20:48 +04:00
|
|
|
DCIAS(dev->sc_statuspa); /* XXX */
|
1994-06-14 04:58:05 +04:00
|
|
|
#else
|
1994-12-28 12:24:55 +03:00
|
|
|
dma_cachectl(&iob->sc_stat[0], 1);
|
1994-06-13 12:12:30 +04:00
|
|
|
#endif
|
1994-12-28 12:24:55 +03:00
|
|
|
*status = iob->sc_stat[0];
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (regs->siop_sbcl & SIOP_BSY) {
|
|
|
|
/*printf ("ACK! siop was busy at end: regs %x script %x dsa %x\n",
|
|
|
|
regs, &scripts, &iob->sc_ds);*/
|
|
|
|
/*Debugger();*/
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (dev->sc_active > 1)
|
|
|
|
regs->siop_dcntl |= SIOP_DCNTL_STD;
|
1994-01-27 00:05:34 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (sstat0 & SIOP_SSTAT0_M_A) { /* Phase mismatch */
|
|
|
|
#ifdef DEBUG
|
1994-12-28 12:24:55 +03:00
|
|
|
++siopphmm;
|
|
|
|
if (iob->iob_len) {
|
|
|
|
int adjust;
|
|
|
|
adjust = ((dfifo - (dbc & 0x7f)) & 0x7f);
|
|
|
|
if (sstat1 & SIOP_SSTAT1_ORF)
|
|
|
|
++adjust;
|
|
|
|
if (sstat1 & SIOP_SSTAT1_OLF)
|
|
|
|
++adjust;
|
|
|
|
iob->iob_curlen = *((long *)®s->siop_dcmd) & 0xffffff;
|
|
|
|
iob->iob_curlen += adjust;
|
|
|
|
iob->iob_curbuf = *((long *)®s->siop_dnad);
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siop_debug & 0x100)
|
|
|
|
printf ("Phase mismatch: dnad %x dbc %x dfifo %x dbc %x sstat1 %x adjust %x sbcl %x\n",
|
|
|
|
iob->iob_curbuf, iob->iob_curlen, dfifo, dbc, sstat1, adjust, regs->siop_sbcl);
|
|
|
|
#endif
|
|
|
|
}
|
1994-01-27 00:05:34 +03:00
|
|
|
if (siop_debug & 9)
|
1994-12-28 12:24:55 +03:00
|
|
|
printf ("Phase mismatch: %x dsp +%x dcmd %x\n",
|
|
|
|
regs->siop_sbcl,
|
|
|
|
regs->siop_dsp - dev->sc_scriptspa,
|
|
|
|
*((long *)®s->siop_dcmd));
|
1994-05-12 09:56:28 +04:00
|
|
|
if (siop_debug & 0x10)
|
|
|
|
panic ("53c710 phase mismatch");
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
|
|
|
if ((regs->siop_sbcl & SIOP_REQ) == 0)
|
|
|
|
printf ("Phase mismatch: REQ not asserted! %02x\n",
|
|
|
|
regs->siop_sbcl);
|
|
|
|
switch (regs->siop_sbcl & 7) {
|
|
|
|
/*
|
|
|
|
* For data out and data in phase, check for DMA chaining
|
|
|
|
*/
|
1994-12-28 12:24:55 +03:00
|
|
|
case 0: /* data out */
|
|
|
|
case 1: /* data in */
|
|
|
|
case 2: /* status */
|
|
|
|
case 3: /* command */
|
|
|
|
case 6: /* message in */
|
|
|
|
case 7: /* message out */
|
|
|
|
regs->siop_dsp = dev->sc_scriptspa + Ent_switch;
|
1994-01-27 00:05:34 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto bad_phase;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (sstat0 & SIOP_SSTAT0_STO) { /* Select timed out */
|
|
|
|
#ifdef DEBUG
|
1994-12-28 12:24:55 +03:00
|
|
|
if (regs->siop_sbcl & SIOP_BSY) {
|
|
|
|
printf ("ACK! siop was busy at timeout: regs %x script %x dsa %x\n",
|
|
|
|
regs, &scripts, &iob->sc_ds);
|
|
|
|
printf(" sbcl %x sdid %x istat %x dstat %x sstat0 %x\n",
|
|
|
|
regs->siop_sbcl, regs->siop_sdid, istat, dstat, sstat0);
|
|
|
|
if (!(regs->siop_sbcl & SIOP_BSY)) {
|
|
|
|
printf ("Yikes, it's not busy now!\n");
|
|
|
|
#if 0
|
|
|
|
*status = -1;
|
|
|
|
if (dev->sc_active > 1)
|
|
|
|
regs->siop_dsp = dev->sc_scriptspa + Ent_wait_reselect;
|
|
|
|
return 1;
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
1994-12-28 12:24:55 +03:00
|
|
|
}
|
|
|
|
/* regs->siop_dcntl |= SIOP_DCNTL_STD;*/
|
1994-01-27 00:05:34 +03:00
|
|
|
return (0);
|
1994-12-28 12:24:55 +03:00
|
|
|
Debugger();
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
1994-12-28 12:24:55 +03:00
|
|
|
#endif
|
|
|
|
*status = -1;
|
|
|
|
if (dev->sc_active > 1)
|
|
|
|
regs->siop_dsp = dev->sc_scriptspa + Ent_wait_reselect;
|
|
|
|
return 1;
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
1994-12-28 12:24:55 +03:00
|
|
|
target = dev->sc_slave;
|
|
|
|
if (sstat0 & SIOP_SSTAT0_UDC) {
|
1994-05-12 09:56:28 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf ("%s: target %d disconnected unexpectedly\n",
|
|
|
|
dev->sc_dev.dv_xname, target);
|
|
|
|
#endif
|
|
|
|
#if 0
|
|
|
|
siopabort (dev, regs, "siopchkintr");
|
|
|
|
#endif
|
|
|
|
*status = STS_BUSY;
|
1994-12-28 12:24:55 +03:00
|
|
|
if (dev->sc_active > 1)
|
|
|
|
regs->siop_dsp = dev->sc_scriptspa + Ent_wait_reselect;
|
1994-05-12 09:56:28 +04:00
|
|
|
return 1;
|
|
|
|
}
|
1994-12-28 12:24:55 +03:00
|
|
|
if (dstat & SIOP_DSTAT_SIR && regs->siop_dsps == 0xff0a) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siop_debug & 0x100)
|
|
|
|
printf ("%s: ID %x disconnected TEMP %x (+%d) buf %x len %x buf %x len %x dfifo %x dbc %x sstat1 %x\n",
|
|
|
|
dev->sc_dev.dv_xname, 1 << target, regs->siop_temp,
|
|
|
|
regs->siop_temp - dev->sc_scriptspa,
|
|
|
|
iob->iob_curbuf, iob->iob_curlen,
|
|
|
|
iob->sc_ds.chain[0].databuf, iob->sc_ds.chain[0].datalen, dfifo, dbc, sstat1);
|
1994-05-12 09:56:28 +04:00
|
|
|
#endif
|
1994-12-28 12:24:55 +03:00
|
|
|
/*
|
|
|
|
* HACK!
|
|
|
|
* set current entry in disconnect state
|
|
|
|
* clear current
|
|
|
|
* if another iob available and another request pending,
|
|
|
|
* start another
|
|
|
|
*/
|
|
|
|
iob->sc_status = dev->sc_flags & (SIOP_SELECTED|SIOP_DMA);
|
|
|
|
dev->sc_flags &= ~(SIOP_SELECTED|SIOP_DMA);
|
|
|
|
dev->sc_cur = NULL; /* no current device */
|
|
|
|
dev->sc_xs = NULL;
|
|
|
|
/* continue script to wait for reconnect */
|
|
|
|
regs->siop_dcntl |= SIOP_DCNTL_STD;
|
|
|
|
if (dev->sc_active < 2) {
|
|
|
|
struct siop_pending *pendp;
|
|
|
|
int s = splbio();
|
|
|
|
/*
|
|
|
|
* can start another I/O, see if there are
|
|
|
|
* any pending and start them
|
|
|
|
*/
|
|
|
|
if (pendp = dev->sc_xslist.tqh_first) {
|
|
|
|
TAILQ_REMOVE(&dev->sc_xslist, pendp, link);
|
|
|
|
dev->sc_xs = pendp->xs;
|
|
|
|
pendp->xs = NULL;
|
|
|
|
splx(s);
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siop_debug & 0x100)
|
|
|
|
printf ("starting a pending command %x\n", dev->sc_xs);
|
1994-05-12 09:56:28 +04:00
|
|
|
#endif
|
1994-12-28 12:24:55 +03:00
|
|
|
siop_donextcmd(dev);
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (dstat & SIOP_DSTAT_SIR && (regs->siop_dsps == 0xff09 ||
|
|
|
|
regs->siop_dsps == 0xff06)) {
|
|
|
|
int i;
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siop_debug & 0x100)
|
|
|
|
printf ("%s: target reselected %x %x\n",
|
|
|
|
dev->sc_dev.dv_xname, regs->siop_lcrc,
|
|
|
|
regs->siop_dsps);
|
|
|
|
#endif
|
|
|
|
if (dev->sc_cur) {
|
|
|
|
printf ("siop: oops - reconnect before current done\n");
|
|
|
|
/* panic ("siop: what now?");*/
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* locate iob of reconnecting device
|
|
|
|
* set dev->sc_cur to iob
|
|
|
|
*/
|
|
|
|
for (i = 0, iob = NULL; i < 2; ++i) {
|
|
|
|
if (dev->sc_iob[i].sc_xs == NULL)
|
|
|
|
continue;
|
|
|
|
if (!dev->sc_iob[i].sc_status)
|
|
|
|
continue;
|
|
|
|
if (!(regs->siop_lcrc & (dev->sc_iob[i].sc_ds.scsi_addr >> 16)))
|
|
|
|
continue;
|
|
|
|
iob = &dev->sc_iob[i];
|
|
|
|
dev->sc_cur = iob;
|
|
|
|
dev->sc_xs = iob->sc_xs;
|
|
|
|
dev->sc_flags |= iob->sc_status;
|
|
|
|
iob->sc_status = 0;
|
|
|
|
DCIAS(kvtop(&iob->sc_stat[0]));
|
|
|
|
regs->siop_dsa = kvtop(&iob->sc_ds);
|
|
|
|
if (iob->iob_curlen) {
|
|
|
|
if (iob->iob_curbuf <= (u_long) iob->sc_ds.chain[0].databuf ||
|
|
|
|
iob->iob_curbuf >= (u_long)(iob->sc_ds.chain[0].databuf + iob->sc_ds.chain[0].datalen))
|
|
|
|
printf ("%s: saved data pointer not in chain[0]\n");
|
|
|
|
iob->sc_ds.chain[0].databuf = (char *) iob->iob_curbuf;
|
|
|
|
iob->sc_ds.chain[0].datalen = iob->iob_curlen;
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siop_debug & 0x100)
|
|
|
|
printf ("%s: reselect buf %x len %x\n",
|
|
|
|
dev->sc_dev.dv_xname, iob->iob_curbuf,
|
|
|
|
iob->iob_curlen);
|
|
|
|
#endif
|
|
|
|
DCIAS(kvtop(&iob->sc_ds.chain));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (iob == NULL)
|
|
|
|
panic("unable to find reconnecting device");
|
|
|
|
regs->siop_dcntl |= SIOP_DCNTL_STD;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (dstat & SIOP_DSTAT_SIR && regs->siop_dsps == 0xff07) {
|
|
|
|
/* reselect was interrupted */
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siop_debug & 0x100 &&
|
|
|
|
(regs->siop_sfbr & SIOP_CTEST2_SIGP) == 0)
|
|
|
|
printf ("%s: reselect interrupted (Sig_P?) scntl1 %x ctest2 %x sfbr %x\n",
|
|
|
|
dev->sc_dev.dv_xname, regs->siop_scntl1, regs->siop_ctest2, regs->siop_sfbr);
|
|
|
|
#endif
|
|
|
|
target = dev->sc_xs->sc_link->target;
|
|
|
|
regs->siop_dsa = kvtop(&dev->sc_cur->sc_ds);
|
|
|
|
regs->siop_sbcl = dev->sc_sync[target].offset;
|
|
|
|
regs->siop_dcntl |= SIOP_DCNTL_STD;
|
|
|
|
return (0);
|
1994-05-12 09:56:28 +04:00
|
|
|
}
|
1994-01-27 00:05:34 +03:00
|
|
|
if (sstat0 == 0 && dstat & SIOP_DSTAT_SIR) {
|
1994-06-14 04:58:05 +04:00
|
|
|
#if 0
|
|
|
|
DCIAS(dev->sc_statuspa);
|
|
|
|
#else
|
1994-12-28 12:24:55 +03:00
|
|
|
dma_cachectl (&iob->sc_stat[0], 1);
|
1994-06-14 04:58:05 +04:00
|
|
|
#endif
|
1994-01-27 00:05:34 +03:00
|
|
|
printf ("SIOP interrupt: %x sts %x msg %x sbcl %x\n",
|
1994-12-28 12:24:55 +03:00
|
|
|
regs->siop_dsps, iob->sc_stat[0], iob->sc_msg[0],
|
1994-01-27 00:05:34 +03:00
|
|
|
regs->siop_sbcl);
|
1994-05-12 09:56:28 +04:00
|
|
|
siopreset (dev);
|
1994-01-27 00:05:34 +03:00
|
|
|
*status = -1;
|
|
|
|
return 1;
|
|
|
|
}
|
1994-06-27 08:56:29 +04:00
|
|
|
if (sstat0 & SIOP_SSTAT0_SGE)
|
|
|
|
printf ("SIOP: SCSI Gross Error\n");
|
|
|
|
if (sstat0 & SIOP_SSTAT0_PAR)
|
|
|
|
printf ("SIOP: Parity Error\n");
|
1994-12-28 12:24:55 +03:00
|
|
|
if (dstat & SIOP_DSTAT_IID)
|
|
|
|
printf ("SIOP: Invalid instruction detected\n");
|
1994-01-27 00:05:34 +03:00
|
|
|
bad_phase:
|
1994-06-27 08:56:29 +04:00
|
|
|
/*
|
|
|
|
* temporary panic for unhandled conditions
|
|
|
|
* displays various things about the 53C710 status and registers
|
|
|
|
* then panics.
|
|
|
|
* XXXX need to clean this up to print out the info, reset, and continue
|
|
|
|
*/
|
1994-12-28 12:24:55 +03:00
|
|
|
printf ("siopchkintr: target %x ds %x\n", target, &iob->sc_ds);
|
1994-06-27 08:56:29 +04:00
|
|
|
printf ("scripts %x ds %x regs %x dsp %x dcmd %x\n", dev->sc_scriptspa,
|
1994-12-28 12:24:55 +03:00
|
|
|
kvtop(&dev->sc_iob), kvtop(regs), regs->siop_dsp,
|
1994-06-27 08:56:29 +04:00
|
|
|
*((long *)®s->siop_dcmd));
|
|
|
|
printf ("siopchkintr: istat %x dstat %x sstat0 %x dsps %x dsa %x sbcl %x sts %x msg %x\n",
|
|
|
|
istat, dstat, sstat0, regs->siop_dsps, regs->siop_dsa,
|
1994-12-28 12:24:55 +03:00
|
|
|
regs->siop_sbcl, iob->sc_stat[0], iob->sc_msg[0]);
|
1994-06-27 08:56:29 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (siop_debug & 0x20)
|
|
|
|
panic("siopchkintr: **** temp ****");
|
|
|
|
#endif
|
|
|
|
siopreset (dev); /* hard reset */
|
|
|
|
*status = -1;
|
|
|
|
return 1;
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SCSI 'immediate' command: issue a command to some SCSI device
|
|
|
|
* and get back an 'immediate' response (i.e., do programmed xfer
|
|
|
|
* to get the response data). 'cbuf' is a buffer containing a scsi
|
|
|
|
* command of length clen bytes. 'buf' is a buffer of length 'len'
|
|
|
|
* bytes for data. The transfer direction is determined by the device
|
|
|
|
* (i.e., by the scsi bus data xfer phase). If 'len' is zero, the
|
|
|
|
* command must supply no data. 'xferphase' is the bus phase the
|
|
|
|
* caller expects to happen after the command is issued. It should
|
|
|
|
* be one of DATA_IN_PHASE, DATA_OUT_PHASE or STATUS_PHASE.
|
|
|
|
*
|
|
|
|
* XXX - 53C710 will use DMA, but no interrupts (it's a heck of a
|
|
|
|
* lot easier to do than to use programmed I/O).
|
|
|
|
*
|
|
|
|
*/
|
1994-05-12 09:56:28 +04:00
|
|
|
int
|
1994-12-28 12:24:55 +03:00
|
|
|
siopicmd(dev, target, lun, cbuf, clen, buf, len)
|
1994-01-27 00:05:34 +03:00
|
|
|
struct siop_softc *dev;
|
|
|
|
int target;
|
1994-12-28 12:24:55 +03:00
|
|
|
int lun;
|
1994-05-12 09:56:28 +04:00
|
|
|
void *cbuf;
|
1994-01-27 00:05:34 +03:00
|
|
|
int clen;
|
1994-05-12 09:56:28 +04:00
|
|
|
void *buf;
|
1994-01-27 00:05:34 +03:00
|
|
|
int len;
|
|
|
|
{
|
1994-05-12 09:56:28 +04:00
|
|
|
siop_regmap_p regs = dev->sc_siopp;
|
1994-12-28 12:24:55 +03:00
|
|
|
struct siop_iob *iob = dev->sc_cur;
|
1994-01-27 00:05:34 +03:00
|
|
|
int i;
|
|
|
|
int status;
|
|
|
|
u_char istat;
|
|
|
|
u_char dstat;
|
|
|
|
u_char sstat0;
|
|
|
|
|
|
|
|
if (dev->sc_flags & SIOP_SELECTED) {
|
|
|
|
printf ("siopicmd%d: bus busy\n", target);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
regs->siop_sien = 0x00; /* disable SCSI and DMA interrupts */
|
|
|
|
regs->siop_dien = 0x00;
|
|
|
|
dev->sc_flags |= SIOP_SELECTED;
|
|
|
|
dev->sc_slave = target;
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siop_debug & 1)
|
1994-12-28 12:24:55 +03:00
|
|
|
printf ("siopicmd: target %x/%x cmd %02x ds %x\n", target,
|
|
|
|
lun, *((char *)cbuf), &iob->sc_ds);
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
1994-12-28 12:24:55 +03:00
|
|
|
siop_setup (dev, target, lun, cbuf, clen, buf, len);
|
1994-01-27 00:05:34 +03:00
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
/* use cmd_wait values? */
|
|
|
|
i = siop_cmd_wait << 1;
|
|
|
|
while (((istat = regs->siop_istat) &
|
|
|
|
(SIOP_ISTAT_SIP | SIOP_ISTAT_DIP)) == 0) {
|
|
|
|
if (--i <= 0) {
|
|
|
|
printf ("waiting: tgt %d cmd %02x sbcl %02x dsp %x (+%x) dcmd %x ds %x\n",
|
1994-05-12 09:56:28 +04:00
|
|
|
target, *((char *)cbuf),
|
1994-01-27 00:05:34 +03:00
|
|
|
regs->siop_sbcl, regs->siop_dsp,
|
1994-06-22 20:20:48 +04:00
|
|
|
regs->siop_dsp - dev->sc_scriptspa,
|
1994-12-28 12:24:55 +03:00
|
|
|
*((long *)®s->siop_dcmd), &iob->sc_ds);
|
1994-01-27 00:05:34 +03:00
|
|
|
i = siop_cmd_wait << 2;
|
1994-05-12 09:56:28 +04:00
|
|
|
/* XXXX need an upper limit and reset */
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
1994-12-28 12:24:55 +03:00
|
|
|
delay(10);
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
|
|
|
dstat = regs->siop_dstat;
|
|
|
|
sstat0 = regs->siop_sstat0;
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siop_debug & 1) {
|
1994-12-28 12:24:55 +03:00
|
|
|
DCIAS(kvtop(iob->sc_stat[0])); /* XXX should just invalidate dev->sc_stat */
|
1994-01-27 00:05:34 +03:00
|
|
|
printf ("siopicmd: istat %x dstat %x sstat0 %x dsps %x sbcl %x sts %x msg %x\n",
|
|
|
|
istat, dstat, sstat0, regs->siop_dsps, regs->siop_sbcl,
|
1994-12-28 12:24:55 +03:00
|
|
|
iob->sc_stat[0], iob->sc_msg[0]);
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (siop_checkintr(dev, istat, dstat, sstat0, &status)) {
|
|
|
|
dev->sc_flags &= ~SIOP_SELECTED;
|
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1994-05-12 09:56:28 +04:00
|
|
|
siopgo(dev, xs)
|
|
|
|
struct siop_softc *dev;
|
|
|
|
struct scsi_xfer *xs;
|
1994-01-27 00:05:34 +03:00
|
|
|
{
|
1994-05-12 09:56:28 +04:00
|
|
|
siop_regmap_p regs;
|
1994-01-27 00:05:34 +03:00
|
|
|
int i;
|
|
|
|
int nchain;
|
|
|
|
int count, tcount;
|
|
|
|
char *addr, *dmaend;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (siop_debug & 1)
|
1994-05-12 09:56:28 +04:00
|
|
|
printf ("%s: go ", dev->sc_dev.dv_xname);
|
|
|
|
#if 0
|
1994-01-27 00:05:34 +03:00
|
|
|
if ((cdb->cdb[1] & 1) == 0 &&
|
|
|
|
((cdb->cdb[0] == CMD_WRITE && cdb->cdb[2] == 0 && cdb->cdb[3] == 0) ||
|
|
|
|
(cdb->cdb[0] == CMD_WRITE_EXT && cdb->cdb[2] == 0 && cdb->cdb[3] == 0
|
|
|
|
&& cdb->cdb[4] == 0)))
|
|
|
|
panic ("siopgo: attempted write to block < 0x100");
|
|
|
|
#endif
|
1994-05-12 09:56:28 +04:00
|
|
|
#endif
|
|
|
|
#if 0
|
1994-01-27 00:05:34 +03:00
|
|
|
cdb->cdb[1] |= unit << 5;
|
1994-05-12 09:56:28 +04:00
|
|
|
#endif
|
1994-01-27 00:05:34 +03:00
|
|
|
|
|
|
|
if (dev->sc_flags & SIOP_SELECTED) {
|
1994-05-12 09:56:28 +04:00
|
|
|
printf ("%s: bus busy\n", dev->sc_dev.dv_xname);
|
1994-01-27 00:05:34 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->sc_flags |= SIOP_SELECTED | SIOP_DMA;
|
1994-05-12 09:56:28 +04:00
|
|
|
dev->sc_slave = xs->sc_link->target;
|
|
|
|
regs = dev->sc_siopp;
|
1994-01-27 00:05:34 +03:00
|
|
|
/* enable SCSI and DMA interrupts */
|
1994-12-28 12:24:55 +03:00
|
|
|
regs->siop_sien = SIOP_SIEN_M_A | SIOP_SIEN_STO | /*SIOP_SIEN_SEL |*/ SIOP_SIEN_SGE |
|
1994-01-27 00:05:34 +03:00
|
|
|
SIOP_SIEN_UDC | SIOP_SIEN_RST | SIOP_SIEN_PAR;
|
1994-12-28 12:24:55 +03:00
|
|
|
regs->siop_dien = SIOP_DIEN_BF | SIOP_DIEN_ABRT | SIOP_DIEN_SIR |
|
|
|
|
/*SIOP_DIEN_WTD |*/ SIOP_DIEN_IID;
|
1994-01-27 00:05:34 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (siop_debug & 1)
|
1994-12-28 12:24:55 +03:00
|
|
|
printf ("siopgo: target %x cmd %02x ds %x\n", dev->sc_slave, xs->cmd->opcode, &dev->sc_cur->sc_ds);
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
siop_setup(dev, dev->sc_slave, xs->sc_link->lun, xs->cmd, xs->cmdlen, xs->data, xs->datalen);
|
1994-01-27 00:05:34 +03:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for 53C710 interrupts
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
1994-05-12 09:56:28 +04:00
|
|
|
siopintr (dev)
|
1994-01-27 00:05:34 +03:00
|
|
|
register struct siop_softc *dev;
|
1994-05-12 09:56:28 +04:00
|
|
|
{
|
|
|
|
siop_regmap_p regs;
|
1994-01-27 00:05:34 +03:00
|
|
|
register u_char istat, dstat, sstat0;
|
|
|
|
int unit;
|
|
|
|
int status;
|
|
|
|
int found = 0;
|
|
|
|
|
1994-05-12 09:56:28 +04:00
|
|
|
regs = dev->sc_siopp;
|
|
|
|
istat = dev->sc_istat;
|
|
|
|
if ((istat & (SIOP_ISTAT_SIP | SIOP_ISTAT_DIP)) == 0)
|
|
|
|
return;
|
|
|
|
if ((dev->sc_flags & (SIOP_DMA | SIOP_SELECTED)) == SIOP_SELECTED)
|
|
|
|
return; /* doing non-interrupt I/O */
|
1994-12-28 12:24:55 +03:00
|
|
|
/* Got a valid interrupt on this device */
|
1994-05-12 09:56:28 +04:00
|
|
|
dstat = dev->sc_dstat;
|
|
|
|
sstat0 = dev->sc_sstat0;
|
|
|
|
dev->sc_istat = 0;
|
1994-01-27 00:05:34 +03:00
|
|
|
#ifdef DEBUG
|
1994-05-12 09:56:28 +04:00
|
|
|
if (siop_debug & 1)
|
|
|
|
printf ("%s: intr istat %x dstat %x sstat0 %x\n",
|
|
|
|
dev->sc_dev.dv_xname, istat, dstat, sstat0);
|
1994-12-28 12:24:55 +03:00
|
|
|
if (!dev->sc_active) {
|
|
|
|
printf ("%s: spurious interrupt? istat %x dstat %x sstat0 %x status %x\n",
|
|
|
|
dev->sc_dev.dv_xname, istat, dstat, sstat0, dev->sc_cur->sc_stat[0]);
|
1994-05-12 09:56:28 +04:00
|
|
|
}
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1994-05-12 09:56:28 +04:00
|
|
|
if (siop_debug & 5) {
|
1994-12-28 12:24:55 +03:00
|
|
|
DCIAS(kvtop(&dev->sc_cur->sc_stat[0]));
|
1994-05-12 09:56:28 +04:00
|
|
|
printf ("siopintr%d: istat %x dstat %x sstat0 %x dsps %x sbcl %x sts %x msg %x\n",
|
|
|
|
unit, istat, dstat, sstat0, regs->siop_dsps,
|
1994-12-28 12:24:55 +03:00
|
|
|
regs->siop_sbcl, dev->sc_cur->sc_stat[0], dev->sc_cur->sc_msg[0]);
|
1994-05-12 09:56:28 +04:00
|
|
|
}
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
1994-05-12 09:56:28 +04:00
|
|
|
if (siop_checkintr (dev, istat, dstat, sstat0, &status)) {
|
1994-01-27 00:05:34 +03:00
|
|
|
#if 1
|
1994-12-28 12:24:55 +03:00
|
|
|
if (dev->sc_active <= 1) { /* more HACK */
|
|
|
|
regs->siop_sien = 0;
|
|
|
|
regs->siop_dien = 0;
|
|
|
|
}
|
1994-05-12 09:56:28 +04:00
|
|
|
if (status == 0xff)
|
|
|
|
printf ("siopintr: status == 0xff\n");
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
1994-12-28 12:24:55 +03:00
|
|
|
if (dev->sc_flags & SIOP_DMA) {
|
|
|
|
dev->sc_flags &= ~(SIOP_DMA | SIOP_SELECTED);
|
|
|
|
if (regs->siop_sbcl & SIOP_BSY)
|
|
|
|
printf ("siopintr: SCSI bus busy at I/O completion\n");
|
|
|
|
siop_scsidone(dev, dev->sc_cur->sc_stat[0]);
|
|
|
|
}
|
1994-01-27 00:05:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
/*
|
|
|
|
* This is based on the Progressive Peripherals Zeus driver and may
|
|
|
|
* not be correct for other 53c710 boards.
|
|
|
|
*
|
|
|
|
*/
|
1994-05-12 09:56:28 +04:00
|
|
|
scsi_period_to_siop (dev, target)
|
|
|
|
struct siop_softc *dev;
|
1994-01-27 00:05:34 +03:00
|
|
|
{
|
1994-05-12 09:56:28 +04:00
|
|
|
int period, offset, i, sxfer;
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-12-28 12:24:55 +03:00
|
|
|
period = dev->sc_cur->sc_msg[4];
|
|
|
|
offset = dev->sc_cur->sc_msg[5];
|
1994-05-12 09:56:28 +04:00
|
|
|
sxfer = 0;
|
|
|
|
if (offset <= SIOP_MAX_OFFSET)
|
|
|
|
sxfer = offset;
|
|
|
|
for (i = 0; i < sizeof (xxx) / 2; ++i) {
|
|
|
|
if (period <= xxx[i].x) {
|
|
|
|
sxfer |= xxx[i].y & 0x70;
|
|
|
|
offset = xxx[i].y & 0x03;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dev->sc_sync[target].period = sxfer;
|
|
|
|
dev->sc_sync[target].offset = offset;
|
1994-01-27 00:05:34 +03:00
|
|
|
#ifdef DEBUG
|
1994-05-12 09:56:28 +04:00
|
|
|
printf ("sync: siop_sxfr %02x, siop_sbcl %02x\n", sxfer, offset);
|
1994-01-27 00:05:34 +03:00
|
|
|
#endif
|
|
|
|
}
|