2003-05-10 13:46:24 +04:00
|
|
|
/* $NetBSD: sc_wrap.c,v 1.24 2003/05/10 09:46:25 tsutsui Exp $ */
|
1998-06-01 23:31:04 +04:00
|
|
|
|
1998-02-18 16:48:03 +03:00
|
|
|
/*
|
1998-06-10 20:27:30 +04:00
|
|
|
* This driver is slow! Need to rewrite.
|
|
|
|
*/
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
2003-04-02 08:17:50 +04:00
|
|
|
#include <uvm/uvm_extern.h>
|
|
|
|
|
1998-02-18 16:48:03 +03:00
|
|
|
#include <dev/scsipi/scsi_all.h>
|
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
|
|
|
#include <dev/scsipi/scsi_message.h>
|
|
|
|
|
2003-05-09 17:36:39 +04:00
|
|
|
#include <newsmips/dev/hbvar.h>
|
1998-03-05 01:14:13 +03:00
|
|
|
#include <newsmips/dev/scsireg.h>
|
|
|
|
#include <newsmips/dev/dmac_0448.h>
|
|
|
|
#include <newsmips/dev/screg_1185.h>
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
#include <machine/adrsmap.h>
|
|
|
|
#include <machine/autoconf.h>
|
|
|
|
#include <machine/machConst.h>
|
|
|
|
|
2001-11-14 21:15:10 +03:00
|
|
|
#include <mips/cache.h>
|
|
|
|
|
1998-02-18 16:48:03 +03:00
|
|
|
static int cxd1185_match __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void cxd1185_attach __P((struct device *, struct device *, void *));
|
|
|
|
|
2002-10-02 08:27:51 +04:00
|
|
|
CFATTACH_DECL(sc, sizeof(struct sc_softc),
|
|
|
|
cxd1185_match, cxd1185_attach, NULL, NULL);
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
void cxd1185_init __P((struct sc_softc *));
|
1998-06-10 20:27:30 +04:00
|
|
|
static void free_scb __P((struct sc_softc *, struct sc_scb *));
|
1998-02-18 16:48:03 +03:00
|
|
|
static struct sc_scb *get_scb __P((struct sc_softc *, int));
|
2001-04-25 21:53:04 +04:00
|
|
|
static void sc_scsipi_request __P((struct scsipi_channel *,
|
|
|
|
scsipi_adapter_req_t, void *));
|
1998-06-10 20:27:30 +04:00
|
|
|
static int sc_poll __P((struct sc_softc *, int, int));
|
1998-02-18 16:48:03 +03:00
|
|
|
static void sc_sched __P((struct sc_softc *));
|
1998-06-10 20:27:30 +04:00
|
|
|
void sc_done __P((struct sc_scb *));
|
1999-12-18 08:00:56 +03:00
|
|
|
int sc_intr __P((void *));
|
1998-02-18 16:48:03 +03:00
|
|
|
static void cxd1185_timeout __P((void *));
|
|
|
|
|
1998-06-10 20:27:30 +04:00
|
|
|
extern void sc_send __P((struct sc_scb *, int, int));
|
1998-02-18 16:48:03 +03:00
|
|
|
extern int scintr __P((void));
|
|
|
|
extern void scsi_hardreset __P((void));
|
1998-06-10 20:27:30 +04:00
|
|
|
extern int sc_busy __P((struct sc_softc *, int));
|
1998-08-21 18:52:29 +04:00
|
|
|
extern paddr_t kvtophys __P((vaddr_t));
|
1998-02-18 16:48:03 +03:00
|
|
|
|
1998-06-10 20:27:30 +04:00
|
|
|
static int sc_disconnect = IDT_DISCON;
|
|
|
|
|
1998-02-18 16:48:03 +03:00
|
|
|
int
|
|
|
|
cxd1185_match(parent, cf, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
|
|
|
{
|
2003-05-09 17:36:39 +04:00
|
|
|
struct hb_attach_args *ha = aux;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
2003-05-09 17:36:39 +04:00
|
|
|
if (strcmp(ha->ha_name, "sc"))
|
1998-02-18 16:48:03 +03:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cxd1185_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct sc_softc *sc = (void *)self;
|
2003-05-09 17:36:39 +04:00
|
|
|
struct hb_attach_args *ha = aux;
|
1998-02-18 16:48:03 +03:00
|
|
|
struct sc_scb *scb;
|
1999-12-17 09:05:37 +03:00
|
|
|
int i, intlevel;
|
|
|
|
|
2003-05-09 17:36:39 +04:00
|
|
|
intlevel = ha->ha_level;
|
1999-12-17 09:05:37 +03:00
|
|
|
if (intlevel == -1) {
|
|
|
|
#if 0
|
|
|
|
printf(": interrupt level not configured\n");
|
|
|
|
return;
|
|
|
|
#else
|
|
|
|
printf(": interrupt level not configured; using");
|
|
|
|
intlevel = 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
printf(" level %d\n", intlevel);
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
if (sc_idenr & 0x08)
|
1998-06-10 20:27:30 +04:00
|
|
|
sc->scsi_1185AQ = 1;
|
|
|
|
else
|
|
|
|
sc->scsi_1185AQ = 0;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
sc->sc_adapter.adapt_dev = &sc->sc_dev;
|
|
|
|
sc->sc_adapter.adapt_nchannels = 1;
|
|
|
|
sc->sc_adapter.adapt_openings = 7;
|
|
|
|
sc->sc_adapter.adapt_max_periph = 1;
|
|
|
|
sc->sc_adapter.adapt_ioctl = NULL;
|
|
|
|
sc->sc_adapter.adapt_minphys = minphys;
|
|
|
|
sc->sc_adapter.adapt_request = sc_scsipi_request;
|
|
|
|
|
|
|
|
memset(&sc->sc_channel, 0, sizeof(sc->sc_channel));
|
|
|
|
sc->sc_channel.chan_adapter = &sc->sc_adapter;
|
|
|
|
sc->sc_channel.chan_bustype = &scsi_bustype;
|
|
|
|
sc->sc_channel.chan_channel = 0;
|
|
|
|
sc->sc_channel.chan_ntargets = 8;
|
|
|
|
sc->sc_channel.chan_nluns = 8;
|
|
|
|
sc->sc_channel.chan_id = 7;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
TAILQ_INIT(&sc->ready_list);
|
|
|
|
TAILQ_INIT(&sc->free_list);
|
|
|
|
|
|
|
|
scb = sc->sc_scb;
|
|
|
|
for (i = 0; i < 24; i++) { /* XXX 24 */
|
|
|
|
TAILQ_INSERT_TAIL(&sc->free_list, scb, chain);
|
|
|
|
scb++;
|
|
|
|
}
|
|
|
|
|
|
|
|
cxd1185_init(sc);
|
|
|
|
DELAY(100000);
|
|
|
|
|
2003-05-10 13:46:24 +04:00
|
|
|
hb_intr_establish(intlevel, INTEN1_DMA, IPL_BIO, sc_intr, sc);
|
1999-12-17 06:21:10 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
config_found(&sc->sc_dev, &sc->sc_channel, scsiprint);
|
1998-02-18 16:48:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cxd1185_init(sc)
|
|
|
|
struct sc_softc *sc;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
sc->inuse[i] = 0;
|
|
|
|
|
|
|
|
scsi_hardreset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-06-10 20:27:30 +04:00
|
|
|
free_scb(sc, scb)
|
1998-02-18 16:48:03 +03:00
|
|
|
struct sc_softc *sc;
|
|
|
|
struct sc_scb *scb;
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
|
|
|
|
TAILQ_INSERT_HEAD(&sc->free_list, scb, chain);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there were none, wake anybody waiting for one to come free,
|
|
|
|
* starting with queued entries.
|
|
|
|
*/
|
|
|
|
if (scb->chain.tqe_next == 0)
|
|
|
|
wakeup(&sc->free_list);
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct sc_scb *
|
|
|
|
get_scb(sc, flags)
|
|
|
|
struct sc_softc *sc;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
struct sc_scb *scb;
|
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
|
|
|
|
while ((scb = sc->free_list.tqh_first) == NULL &&
|
1999-10-01 02:59:52 +04:00
|
|
|
(flags & XS_CTL_NOSLEEP) == 0)
|
1998-02-18 16:48:03 +03:00
|
|
|
tsleep(&sc->free_list, PRIBIO, "sc_scb", 0);
|
|
|
|
if (scb) {
|
|
|
|
TAILQ_REMOVE(&sc->free_list, scb, chain);
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
return scb;
|
|
|
|
}
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
void
|
|
|
|
sc_scsipi_request(chan, req, arg)
|
|
|
|
struct scsipi_channel *chan;
|
|
|
|
scsipi_adapter_req_t req;
|
|
|
|
void *arg;
|
1998-02-18 16:48:03 +03:00
|
|
|
{
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipi_xfer *xs;
|
|
|
|
struct scsipi_periph *periph;
|
|
|
|
struct sc_softc *sc = (void *)chan->chan_adapter->adapt_dev;
|
1998-02-18 16:48:03 +03:00
|
|
|
struct sc_scb *scb;
|
|
|
|
int flags, s;
|
2001-04-25 21:53:04 +04:00
|
|
|
int target;
|
|
|
|
|
|
|
|
switch (req) {
|
|
|
|
case ADAPTER_REQ_RUN_XFER:
|
|
|
|
xs = arg;
|
|
|
|
periph = xs->xs_periph;
|
|
|
|
|
|
|
|
flags = xs->xs_control;
|
|
|
|
if ((scb = get_scb(sc, flags)) == NULL)
|
|
|
|
panic("sc_scsipi_request: no scb");
|
|
|
|
|
|
|
|
scb->xs = xs;
|
|
|
|
scb->flags = 0;
|
|
|
|
scb->sc_ctag = 0;
|
|
|
|
scb->sc_coffset = 0;
|
|
|
|
scb->istatus = 0;
|
|
|
|
scb->tstatus = 0;
|
|
|
|
scb->message = 0;
|
|
|
|
bzero(scb->msgbuf, sizeof(scb->msgbuf));
|
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
|
|
|
|
TAILQ_INSERT_TAIL(&sc->ready_list, scb, chain);
|
|
|
|
sc_sched(sc);
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
if (flags & XS_CTL_POLL) {
|
|
|
|
target = periph->periph_target;
|
|
|
|
if (sc_poll(sc, target, xs->timeout)) {
|
|
|
|
printf("sc: timeout (retry)\n");
|
|
|
|
if (sc_poll(sc, target, xs->timeout)) {
|
|
|
|
printf("sc: timeout\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* called during autoconfig only... */
|
2001-11-14 21:15:10 +03:00
|
|
|
mips_dcache_wbinv_all(); /* Flush DCache */
|
1998-02-18 16:48:03 +03:00
|
|
|
}
|
2001-04-25 21:53:04 +04:00
|
|
|
return;
|
|
|
|
case ADAPTER_REQ_GROW_RESOURCES:
|
|
|
|
/* XXX Not supported. */
|
|
|
|
return;
|
|
|
|
case ADAPTER_REQ_SET_XFER_MODE:
|
|
|
|
/* XXX Not supported. */
|
|
|
|
return;
|
1998-02-18 16:48:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Used when interrupt driven I/O isn't allowed, e.g. during boot.
|
|
|
|
*/
|
|
|
|
int
|
1998-06-10 20:27:30 +04:00
|
|
|
sc_poll(sc, chan, count)
|
|
|
|
struct sc_softc *sc;
|
|
|
|
int chan, count;
|
1998-02-18 16:48:03 +03:00
|
|
|
{
|
|
|
|
volatile u_char *int_stat = (void *)INTST1;
|
|
|
|
volatile u_char *int_clear = (void *)INTCLR1;
|
|
|
|
|
1998-06-10 20:27:30 +04:00
|
|
|
while (sc_busy(sc, chan)) {
|
1998-02-18 16:48:03 +03:00
|
|
|
if (*int_stat & INTST1_DMA) {
|
|
|
|
*int_clear = INTST1_DMA;
|
|
|
|
if (dmac_gstat & CH_INT(CH_SCSI)) {
|
|
|
|
if (dmac_gstat & CH_MRQ(CH_SCSI)) {
|
|
|
|
DELAY(50);
|
|
|
|
if (dmac_gstat & CH_MRQ(CH_SCSI))
|
|
|
|
printf("dma_poll\n");
|
|
|
|
}
|
|
|
|
DELAY(10);
|
|
|
|
scintr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DELAY(1000);
|
|
|
|
count--;
|
|
|
|
if (count <= 0)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sc_sched(sc)
|
|
|
|
struct sc_softc *sc;
|
|
|
|
{
|
|
|
|
struct scsipi_xfer *xs;
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipi_periph *periph;
|
1998-02-18 16:48:03 +03:00
|
|
|
int ie = 0;
|
|
|
|
int flags;
|
|
|
|
int chan, lun;
|
1998-08-21 17:19:43 +04:00
|
|
|
struct sc_scb *scb, *nextscb;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
scb = sc->ready_list.tqh_first;
|
|
|
|
start:
|
|
|
|
if (scb == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xs = scb->xs;
|
2001-04-25 21:53:04 +04:00
|
|
|
periph = xs->xs_periph;
|
|
|
|
chan = periph->periph_target;
|
1999-10-01 02:59:52 +04:00
|
|
|
flags = xs->xs_control;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
if (cold)
|
1999-10-01 02:59:52 +04:00
|
|
|
flags |= XS_CTL_POLL;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
if (sc->inuse[chan]) {
|
|
|
|
scb = scb->chain.tqe_next;
|
|
|
|
goto start;
|
|
|
|
}
|
|
|
|
sc->inuse[chan] = 1;
|
|
|
|
|
1999-10-01 02:59:52 +04:00
|
|
|
if (flags & XS_CTL_RESET)
|
1998-02-18 16:48:03 +03:00
|
|
|
printf("SCSI RESET\n");
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
lun = periph->periph_lun;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
1998-06-10 20:27:30 +04:00
|
|
|
scb->identify = MSG_IDENT | sc_disconnect | (lun & IDT_DRMASK);
|
|
|
|
scb->sc_ctrnscnt = xs->datalen;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
2003-05-03 22:10:37 +04:00
|
|
|
/* make va->pa mapping table for DMA */
|
1998-02-18 16:48:03 +03:00
|
|
|
if (xs->datalen > 0) {
|
|
|
|
int pages, offset;
|
|
|
|
int i, pn;
|
1998-08-21 18:52:29 +04:00
|
|
|
vaddr_t va;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
1998-06-10 20:27:30 +04:00
|
|
|
/* bzero(&sc->sc_map[chan], sizeof(struct sc_map)); */
|
1998-02-18 16:48:03 +03:00
|
|
|
|
1998-08-21 18:52:29 +04:00
|
|
|
va = (vaddr_t)xs->data;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
offset = va & PGOFSET;
|
2003-04-02 08:17:50 +04:00
|
|
|
pages = (offset + xs->datalen + PAGE_SIZE -1 ) >> PGSHIFT;
|
1998-02-18 16:48:03 +03:00
|
|
|
if (pages >= NSCMAP)
|
|
|
|
panic("sc_map: Too many pages");
|
|
|
|
|
|
|
|
for (i = 0; i < pages; i++) {
|
1998-08-21 18:52:29 +04:00
|
|
|
pn = kvtophys(va) >> PGSHIFT;
|
1998-02-18 16:48:03 +03:00
|
|
|
sc->sc_map[chan].mp_addr[i] = pn;
|
2003-04-02 08:17:50 +04:00
|
|
|
va += PAGE_SIZE;
|
1998-02-18 16:48:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
sc->sc_map[chan].mp_offset = offset;
|
|
|
|
sc->sc_map[chan].mp_pages = pages;
|
1998-06-10 20:27:30 +04:00
|
|
|
scb->sc_map = &sc->sc_map[chan];
|
1998-02-18 16:48:03 +03:00
|
|
|
}
|
|
|
|
|
1999-10-01 02:59:52 +04:00
|
|
|
if ((flags & XS_CTL_POLL) == 0)
|
1998-06-01 23:31:04 +04:00
|
|
|
ie = SCSI_INTEN;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
1998-06-10 20:27:30 +04:00
|
|
|
if (xs->data)
|
|
|
|
scb->sc_cpoint = (void *)xs->data;
|
|
|
|
else
|
|
|
|
scb->sc_cpoint = scb->msgbuf;
|
|
|
|
scb->scb_softc = sc;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
2000-03-23 09:40:33 +03:00
|
|
|
callout_reset(&scb->xs->xs_callout, hz * 10, cxd1185_timeout, scb);
|
1998-06-10 20:27:30 +04:00
|
|
|
sc_send(scb, chan, ie);
|
2000-03-23 09:40:33 +03:00
|
|
|
callout_stop(&scb->xs->xs_callout);
|
1998-02-18 16:48:03 +03:00
|
|
|
|
1998-08-21 17:19:43 +04:00
|
|
|
nextscb = scb->chain.tqe_next;
|
|
|
|
|
|
|
|
TAILQ_REMOVE(&sc->ready_list, scb, chain);
|
|
|
|
|
|
|
|
scb = nextscb;
|
|
|
|
|
1998-02-18 16:48:03 +03:00
|
|
|
goto start;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-06-10 20:27:30 +04:00
|
|
|
sc_done(scb)
|
|
|
|
struct sc_scb *scb;
|
1998-02-18 16:48:03 +03:00
|
|
|
{
|
1998-06-10 20:27:30 +04:00
|
|
|
struct scsipi_xfer *xs = scb->xs;
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipi_periph *periph = xs->xs_periph;
|
|
|
|
struct sc_softc *sc = (void *)periph->periph_channel->chan_adapter->adapt_dev;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
xs->resid = 0;
|
|
|
|
xs->status = 0;
|
|
|
|
|
1998-06-10 20:27:30 +04:00
|
|
|
if (scb->istatus != INST_EP) {
|
2000-12-03 04:42:29 +03:00
|
|
|
if (scb->istatus == (INST_EP|INST_TO))
|
1999-12-17 06:21:10 +03:00
|
|
|
xs->error = XS_SELTIMEOUT;
|
|
|
|
else {
|
1998-02-18 16:48:03 +03:00
|
|
|
printf("SC(i): [istatus=0x%x, tstatus=0x%x]\n",
|
1998-06-10 20:27:30 +04:00
|
|
|
scb->istatus, scb->tstatus);
|
1999-12-17 06:21:10 +03:00
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
}
|
1998-02-18 16:48:03 +03:00
|
|
|
}
|
|
|
|
|
1998-06-10 20:27:30 +04:00
|
|
|
switch (scb->tstatus) {
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
case TGST_GOOD:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TGST_CC:
|
2001-04-25 21:53:04 +04:00
|
|
|
xs->status = SCSI_CHECK;
|
|
|
|
if (xs->error == 0)
|
|
|
|
xs->error = XS_BUSY;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
printf("SC(t): [istatus=0x%x, tstatus=0x%x]\n",
|
1998-06-10 20:27:30 +04:00
|
|
|
scb->istatus, scb->tstatus);
|
1998-02-18 16:48:03 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
scsipi_done(xs);
|
1998-06-10 20:27:30 +04:00
|
|
|
free_scb(sc, scb);
|
2001-04-25 21:53:04 +04:00
|
|
|
sc->inuse[periph->periph_target] = 0;
|
1998-02-18 16:48:03 +03:00
|
|
|
sc_sched(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-12-18 08:00:56 +03:00
|
|
|
sc_intr(v)
|
|
|
|
void *v;
|
1998-02-18 16:48:03 +03:00
|
|
|
{
|
1999-12-18 08:00:56 +03:00
|
|
|
/* struct sc_softc *sc = v; */
|
|
|
|
volatile u_char *gsp = (u_char *)DMAC_GSTAT;
|
|
|
|
u_int gstat = *gsp;
|
|
|
|
int mrqb, i;
|
|
|
|
|
|
|
|
if ((gstat & CH_INT(CH_SCSI)) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* when DMA interrupt occurs there remain some untransferred data.
|
|
|
|
* wait data transfer completion.
|
|
|
|
*/
|
|
|
|
mrqb = (gstat & CH_INT(CH_SCSI)) << 1;
|
|
|
|
if (gstat & mrqb) {
|
|
|
|
/*
|
|
|
|
* XXX SHOULD USE DELAY()
|
|
|
|
*/
|
|
|
|
for (i = 0; i < 50; i++)
|
|
|
|
;
|
|
|
|
if (*gsp & mrqb)
|
|
|
|
printf("sc_intr: MRQ\n");
|
|
|
|
}
|
|
|
|
scintr();
|
|
|
|
|
|
|
|
return 1;
|
1998-02-18 16:48:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-10 20:27:30 +04:00
|
|
|
#if 0
|
1998-02-18 16:48:03 +03:00
|
|
|
/*
|
|
|
|
* SCOP_RSENSE request
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
scop_rsense(intr, sc_param, lun, ie, count, param)
|
|
|
|
register int intr;
|
|
|
|
register struct scsi *sc_param;
|
|
|
|
register int lun;
|
|
|
|
register int ie;
|
|
|
|
register int count;
|
|
|
|
register caddr_t param;
|
|
|
|
{
|
|
|
|
bzero(sc_param, sizeof(struct scsi));
|
1998-06-10 20:27:30 +04:00
|
|
|
sc_param->identify = MSG_IDENT | sc_disconnect | (lun & IDT_DRMASK);
|
1998-02-18 16:48:03 +03:00
|
|
|
sc_param->sc_lun = lun;
|
|
|
|
|
|
|
|
sc_param->sc_cpoint = (u_char *)param;
|
|
|
|
sc_param->sc_ctrnscnt = count;
|
|
|
|
|
|
|
|
/* sc_cdb */
|
|
|
|
sc_param->sc_opcode = SCOP_RSENSE;
|
|
|
|
sc_param->sc_count = count;
|
|
|
|
|
1998-06-10 20:27:30 +04:00
|
|
|
sc_go(intr, sc_param, ie, sc_param);
|
1998-02-18 16:48:03 +03:00
|
|
|
}
|
1998-06-10 20:27:30 +04:00
|
|
|
#endif
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
cxd1185_timeout(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
struct sc_scb *scb = arg;
|
|
|
|
struct scsipi_xfer *xs = scb->xs;
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipi_periph *periph = xs->xs_periph;
|
1998-02-18 16:48:03 +03:00
|
|
|
int chan;
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
chan = periph->periph_target;
|
1998-02-18 16:48:03 +03:00
|
|
|
|
|
|
|
printf("sc: timeout ch=%d\n", chan);
|
|
|
|
|
|
|
|
/* XXX abort transfer and ... */
|
|
|
|
}
|