1997-09-06 11:53:14 +04:00
|
|
|
/* $NetBSD: sbc.c,v 1.31 1997/09/06 07:53:14 scottr Exp $ */
|
1996-04-26 02:26:52 +04:00
|
|
|
|
|
|
|
/*
|
1997-02-24 08:47:33 +03:00
|
|
|
* Copyright (C) 1996 Scott Reynolds. All rights reserved.
|
1996-04-26 02:26:52 +04:00
|
|
|
*
|
|
|
|
* 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.
|
1997-02-24 08:47:33 +03:00
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Scott Reynolds for
|
|
|
|
* the NetBSD Project.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
1996-04-26 02:26:52 +04:00
|
|
|
*
|
1997-02-24 08:47:33 +03:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
1996-04-26 02:26:52 +04:00
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
1997-02-24 08:47:33 +03:00
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
1996-04-26 02:26:52 +04:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file contains only the machine-dependent parts of the mac68k
|
|
|
|
* NCR 5380 SCSI driver. (Autoconfig stuff and PDMA functions.)
|
|
|
|
* The machine-independent parts are in ncr5380sbc.c
|
|
|
|
*
|
|
|
|
* Supported hardware includes:
|
|
|
|
* Macintosh II family 5380-based controller
|
|
|
|
*
|
|
|
|
* Credits, history:
|
|
|
|
*
|
|
|
|
* Scott Reynolds wrote this module, based on work by Allen Briggs
|
1996-06-19 05:47:28 +04:00
|
|
|
* (mac68k), Gordon W. Ross and David Jones (sun3), and Leo Weppelman
|
|
|
|
* (atari). Thanks to Allen for supplying crucial interpretation of the
|
|
|
|
* NetBSD/mac68k 1.1 'ncrscsi' driver. Also, Allen, Gordon, and Jason
|
|
|
|
* Thorpe all helped to refine this code, and were considerable sources
|
|
|
|
* of moral support.
|
1996-04-26 02:26:52 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
#include <dev/scsipi/scsi_all.h>
|
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
#include <dev/scsipi/scsipi_debug.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
1996-04-26 02:26:52 +04:00
|
|
|
|
|
|
|
#include <dev/ic/ncr5380reg.h>
|
|
|
|
#include <dev/ic/ncr5380var.h>
|
|
|
|
|
1996-06-11 07:20:23 +04:00
|
|
|
#include <machine/cpu.h>
|
1996-04-26 02:26:52 +04:00
|
|
|
#include <machine/viareg.h>
|
|
|
|
|
1997-08-12 02:53:26 +04:00
|
|
|
#include <mac68k/dev/sbcreg.h>
|
|
|
|
#include <mac68k/dev/sbcvar.h>
|
1996-04-26 02:26:52 +04:00
|
|
|
|
1997-03-01 23:18:58 +03:00
|
|
|
int sbc_debug = 0 /* | SBC_DB_INTR | SBC_DB_DMA */;
|
|
|
|
int sbc_link_flags = 0 /* | SDEV_DB2 */;
|
1997-04-18 21:38:08 +04:00
|
|
|
int sbc_options = 0 /* | SBC_PDMA */;
|
1996-04-26 02:26:52 +04:00
|
|
|
|
|
|
|
static void sbc_minphys __P((struct buf *bp));
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_adapter sbc_ops = {
|
1996-04-26 02:26:52 +04:00
|
|
|
ncr5380_scsi_cmd, /* scsi_cmd() */
|
|
|
|
sbc_minphys, /* scsi_minphys() */
|
|
|
|
NULL, /* open_target_lu() */
|
|
|
|
NULL, /* close_target_lu() */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This is copied from julian's bt driver */
|
|
|
|
/* "so we have a default dev struct for our link struct." */
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_device sbc_dev = {
|
1996-04-26 02:26:52 +04:00
|
|
|
NULL, /* Use default error handler. */
|
|
|
|
NULL, /* Use default start handler. */
|
|
|
|
NULL, /* Use default async handler. */
|
|
|
|
NULL, /* Use default "done" routine. */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfdriver sbc_cd = {
|
|
|
|
NULL, "sbc", DV_DULL
|
|
|
|
};
|
|
|
|
|
1997-09-06 11:53:14 +04:00
|
|
|
extern label_t *nofault;
|
|
|
|
extern caddr_t m68k_fault_addr;
|
|
|
|
|
1997-06-30 09:24:35 +04:00
|
|
|
static int sbc_wait_busy __P((struct ncr5380_softc *));
|
1997-03-01 23:18:58 +03:00
|
|
|
static int sbc_ready __P((struct ncr5380_softc *));
|
1997-06-30 09:24:35 +04:00
|
|
|
static int sbc_wait_dreq __P((struct ncr5380_softc *));
|
1996-04-26 02:26:52 +04:00
|
|
|
|
|
|
|
static void
|
|
|
|
sbc_minphys(struct buf *bp)
|
|
|
|
{
|
|
|
|
if (bp->b_bcount > MAX_DMA_LEN)
|
|
|
|
bp->b_bcount = MAX_DMA_LEN;
|
|
|
|
return (minphys(bp));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
* General support for Mac-specific SCSI logic.
|
|
|
|
***/
|
|
|
|
|
1997-06-30 09:24:35 +04:00
|
|
|
/* These are used in the following inline functions. */
|
|
|
|
int sbc_wait_busy_timo = 1000 * 5000; /* X2 = 10 S. */
|
|
|
|
int sbc_ready_timo = 1000 * 5000; /* X2 = 10 S. */
|
|
|
|
int sbc_wait_dreq_timo = 1000 * 5000; /* X2 = 10 S. */
|
|
|
|
|
|
|
|
/* Return zero on success. */
|
|
|
|
static __inline__ int
|
|
|
|
sbc_wait_busy(sc)
|
|
|
|
struct ncr5380_softc *sc;
|
|
|
|
{
|
|
|
|
int timo = sbc_wait_busy_timo;
|
|
|
|
for (;;) {
|
|
|
|
if (SCI_BUSY(sc)) {
|
|
|
|
timo = 0; /* return 0 */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (--timo < 0)
|
|
|
|
break; /* return -1 */
|
|
|
|
delay(2);
|
|
|
|
}
|
|
|
|
return (timo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ int
|
|
|
|
sbc_ready(sc)
|
|
|
|
struct ncr5380_softc *sc;
|
|
|
|
{
|
|
|
|
int timo = sbc_ready_timo;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
if ((*sc->sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH))
|
|
|
|
== (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
|
|
|
|
timo = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (((*sc->sci_csr & SCI_CSR_PHASE_MATCH) == 0)
|
|
|
|
|| (SCI_BUSY(sc) == 0)) {
|
|
|
|
timo = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (--timo < 0)
|
|
|
|
break; /* return -1 */
|
|
|
|
delay(2);
|
|
|
|
}
|
|
|
|
return (timo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ int
|
|
|
|
sbc_wait_dreq(sc)
|
|
|
|
struct ncr5380_softc *sc;
|
|
|
|
{
|
|
|
|
int timo = sbc_wait_dreq_timo;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
if ((*sc->sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH))
|
|
|
|
== (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
|
|
|
|
timo = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (--timo < 0)
|
|
|
|
break; /* return -1 */
|
|
|
|
delay(2);
|
|
|
|
}
|
|
|
|
return (timo);
|
|
|
|
}
|
|
|
|
|
1996-04-26 02:26:52 +04:00
|
|
|
void
|
|
|
|
sbc_irq_intr(p)
|
|
|
|
void *p;
|
|
|
|
{
|
1997-04-07 09:48:35 +04:00
|
|
|
struct ncr5380_softc *ncr_sc = p;
|
|
|
|
int claimed = 0;
|
1996-04-26 02:26:52 +04:00
|
|
|
|
|
|
|
/* How we ever arrive here without IRQ set is a mystery... */
|
|
|
|
if (*ncr_sc->sci_csr & SCI_CSR_INT) {
|
1996-04-30 21:07:17 +04:00
|
|
|
#ifdef SBC_DEBUG
|
|
|
|
if (sbc_debug & SBC_DB_INTR)
|
|
|
|
decode_5380_intr(ncr_sc);
|
|
|
|
#endif
|
1996-04-26 02:26:52 +04:00
|
|
|
claimed = ncr5380_intr(ncr_sc);
|
|
|
|
if (!claimed) {
|
|
|
|
if (((*ncr_sc->sci_csr & ~SCI_CSR_PHASE_MATCH) == SCI_CSR_INT)
|
1996-04-30 21:07:17 +04:00
|
|
|
&& ((*ncr_sc->sci_bus_csr & ~SCI_BUS_RST) == 0))
|
1996-04-26 02:26:52 +04:00
|
|
|
SCI_CLR_INTR(ncr_sc); /* RST interrupt */
|
|
|
|
#ifdef SBC_DEBUG
|
|
|
|
else {
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: spurious intr\n",
|
1996-04-26 02:26:52 +04:00
|
|
|
ncr_sc->sc_dev.dv_xname);
|
1996-04-30 21:07:17 +04:00
|
|
|
SBC_BREAK;
|
1996-04-26 02:26:52 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-04-30 21:07:17 +04:00
|
|
|
#ifdef SBC_DEBUG
|
|
|
|
void
|
|
|
|
decode_5380_intr(ncr_sc)
|
|
|
|
struct ncr5380_softc *ncr_sc;
|
|
|
|
{
|
1997-06-30 09:24:35 +04:00
|
|
|
u_int8_t csr = *ncr_sc->sci_csr;
|
|
|
|
u_int8_t bus_csr = *ncr_sc->sci_bus_csr;
|
1996-04-30 21:07:17 +04:00
|
|
|
|
|
|
|
if (((csr & ~(SCI_CSR_PHASE_MATCH | SCI_CSR_ATN)) == SCI_CSR_INT) &&
|
|
|
|
((bus_csr & ~(SCI_BUS_MSG | SCI_BUS_CD | SCI_BUS_IO | SCI_BUS_DBP)) == SCI_BUS_SEL)) {
|
|
|
|
if (csr & SCI_BUS_IO)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: reselect\n", ncr_sc->sc_dev.dv_xname);
|
1996-04-30 21:07:17 +04:00
|
|
|
else
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: select\n", ncr_sc->sc_dev.dv_xname);
|
1996-04-30 21:07:17 +04:00
|
|
|
} else if (((csr & ~SCI_CSR_ACK) == (SCI_CSR_DONE | SCI_CSR_INT)) &&
|
|
|
|
((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_SEL)) == SCI_BUS_BSY))
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: dma eop\n", ncr_sc->sc_dev.dv_xname);
|
1996-04-30 21:07:17 +04:00
|
|
|
else if (((csr & ~SCI_CSR_PHASE_MATCH) == SCI_CSR_INT) &&
|
|
|
|
((bus_csr & ~SCI_BUS_RST) == 0))
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: bus reset\n", ncr_sc->sc_dev.dv_xname);
|
1996-04-30 21:07:17 +04:00
|
|
|
else if (((csr & ~(SCI_CSR_DREQ | SCI_CSR_ATN | SCI_CSR_ACK)) == (SCI_CSR_PERR | SCI_CSR_INT | SCI_CSR_PHASE_MATCH)) &&
|
|
|
|
((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_SEL)) == SCI_BUS_BSY))
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: parity error\n", ncr_sc->sc_dev.dv_xname);
|
1996-04-30 21:07:17 +04:00
|
|
|
else if (((csr & ~SCI_CSR_ATN) == SCI_CSR_INT) &&
|
|
|
|
((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_REQ | SCI_BUS_SEL)) == (SCI_BUS_BSY | SCI_BUS_REQ)))
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: phase mismatch\n", ncr_sc->sc_dev.dv_xname);
|
1996-04-30 21:07:17 +04:00
|
|
|
else if (((csr & ~SCI_CSR_PHASE_MATCH) == (SCI_CSR_INT | SCI_CSR_DISC)) &&
|
|
|
|
(bus_csr == 0))
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: disconnect\n", ncr_sc->sc_dev.dv_xname);
|
1996-04-30 21:07:17 +04:00
|
|
|
else
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: unknown intr: csr=%x, bus_csr=%x\n",
|
1996-04-30 21:07:17 +04:00
|
|
|
ncr_sc->sc_dev.dv_xname, csr, bus_csr);
|
|
|
|
}
|
|
|
|
#endif
|
1996-04-26 02:26:52 +04:00
|
|
|
|
1996-06-11 07:20:23 +04:00
|
|
|
|
1996-04-26 02:26:52 +04:00
|
|
|
/***
|
|
|
|
* The following code implements polled PDMA.
|
|
|
|
***/
|
|
|
|
|
1997-04-07 09:48:35 +04:00
|
|
|
int
|
|
|
|
sbc_pdma_in(ncr_sc, phase, datalen, data)
|
|
|
|
struct ncr5380_softc *ncr_sc;
|
1997-06-30 09:24:35 +04:00
|
|
|
int phase;
|
|
|
|
int datalen;
|
1997-04-07 09:48:35 +04:00
|
|
|
u_char *data;
|
|
|
|
{
|
|
|
|
struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
|
1997-04-18 21:38:08 +04:00
|
|
|
volatile u_int32_t *long_data = (u_int32_t *)sc->sc_drq_addr;
|
|
|
|
volatile u_int8_t *byte_data = (u_int8_t *)sc->sc_nodrq_addr;
|
1997-04-07 09:48:35 +04:00
|
|
|
int resid, s;
|
1996-04-26 02:26:52 +04:00
|
|
|
|
1997-06-30 09:24:35 +04:00
|
|
|
if (datalen < ncr_sc->sc_min_dma_len ||
|
|
|
|
(sc->sc_options & SBC_PDMA) == 0)
|
|
|
|
return ncr5380_pio_in(ncr_sc, phase, datalen, data);
|
|
|
|
|
1997-04-07 09:48:35 +04:00
|
|
|
s = splbio();
|
1997-06-30 09:24:35 +04:00
|
|
|
if (sbc_wait_busy(ncr_sc)) {
|
|
|
|
splx(s);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-04-07 09:48:35 +04:00
|
|
|
*ncr_sc->sci_mode |= SCI_MODE_DMA;
|
|
|
|
*ncr_sc->sci_irecv = 0;
|
|
|
|
|
1997-06-30 09:24:35 +04:00
|
|
|
#define R4 *((u_int32_t *)data)++ = *long_data
|
|
|
|
#define R1 *((u_int8_t *)data)++ = *byte_data
|
1997-04-07 09:48:35 +04:00
|
|
|
for (resid = datalen; resid >= 128; resid -= 128) {
|
1997-06-30 09:24:35 +04:00
|
|
|
if (sbc_ready(ncr_sc))
|
1997-04-07 09:48:35 +04:00
|
|
|
goto interrupt;
|
|
|
|
R4; R4; R4; R4; R4; R4; R4; R4;
|
|
|
|
R4; R4; R4; R4; R4; R4; R4; R4;
|
|
|
|
R4; R4; R4; R4; R4; R4; R4; R4;
|
1997-06-30 09:24:35 +04:00
|
|
|
R4; R4; R4; R4; R4; R4; R4; R4; /* 128 */
|
1996-04-26 02:26:52 +04:00
|
|
|
}
|
1997-04-07 09:48:35 +04:00
|
|
|
while (resid) {
|
1997-06-30 09:24:35 +04:00
|
|
|
if (sbc_ready(ncr_sc))
|
1997-04-07 09:48:35 +04:00
|
|
|
goto interrupt;
|
|
|
|
R1;
|
|
|
|
resid--;
|
1996-04-26 02:26:52 +04:00
|
|
|
}
|
1997-04-07 09:48:35 +04:00
|
|
|
#undef R4
|
|
|
|
#undef R1
|
1996-04-26 02:26:52 +04:00
|
|
|
|
1997-04-07 09:48:35 +04:00
|
|
|
interrupt:
|
1996-04-26 02:26:52 +04:00
|
|
|
SCI_CLR_INTR(ncr_sc);
|
|
|
|
*ncr_sc->sci_mode &= ~SCI_MODE_DMA;
|
1997-06-30 09:24:35 +04:00
|
|
|
*ncr_sc->sci_icmd = 0;
|
1997-04-07 09:48:35 +04:00
|
|
|
splx(s);
|
1997-06-30 09:24:35 +04:00
|
|
|
return (datalen - resid);
|
1996-04-26 02:26:52 +04:00
|
|
|
}
|
|
|
|
|
1997-03-01 23:18:58 +03:00
|
|
|
int
|
1997-04-07 09:48:35 +04:00
|
|
|
sbc_pdma_out(ncr_sc, phase, datalen, data)
|
1996-04-26 02:26:52 +04:00
|
|
|
struct ncr5380_softc *ncr_sc;
|
1997-06-30 09:24:35 +04:00
|
|
|
int phase;
|
|
|
|
int datalen;
|
1996-04-26 02:26:52 +04:00
|
|
|
u_char *data;
|
|
|
|
{
|
|
|
|
struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
|
1997-04-18 21:38:08 +04:00
|
|
|
volatile u_int32_t *long_data = (u_int32_t *)sc->sc_drq_addr;
|
|
|
|
volatile u_int8_t *byte_data = (u_int8_t *)sc->sc_nodrq_addr;
|
1997-09-06 11:53:14 +04:00
|
|
|
label_t faultbuf;
|
1997-06-30 09:24:35 +04:00
|
|
|
int resid, s;
|
|
|
|
u_int8_t icmd;
|
1996-04-26 02:26:52 +04:00
|
|
|
|
1997-09-06 11:53:14 +04:00
|
|
|
#if 1
|
|
|
|
/* Work around lame gcc initialization bug */
|
|
|
|
(void)&data;
|
|
|
|
#endif
|
|
|
|
|
1997-06-30 09:24:35 +04:00
|
|
|
if (datalen < ncr_sc->sc_min_dma_len ||
|
|
|
|
(sc->sc_options & SBC_PDMA) == 0)
|
1997-04-18 21:38:08 +04:00
|
|
|
return ncr5380_pio_out(ncr_sc, phase, datalen, data);
|
|
|
|
|
1997-04-07 09:48:35 +04:00
|
|
|
s = splbio();
|
1997-06-30 09:24:35 +04:00
|
|
|
if (sbc_wait_busy(ncr_sc)) {
|
|
|
|
splx(s);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-04-07 09:48:35 +04:00
|
|
|
icmd = *(ncr_sc->sci_icmd) & SCI_ICMD_RMASK;
|
|
|
|
*ncr_sc->sci_icmd = icmd | SCI_ICMD_DATA;
|
|
|
|
*ncr_sc->sci_mode |= SCI_MODE_DMA;
|
|
|
|
*ncr_sc->sci_dma_send = 0;
|
1996-04-26 02:26:52 +04:00
|
|
|
|
1997-09-06 11:53:14 +04:00
|
|
|
/*
|
|
|
|
* Setup for a possible bus error caused by SCSI controller
|
|
|
|
* switching out of DATA OUT before we're done with the
|
|
|
|
* current transfer. (See comment before sbc_drq_intr().)
|
|
|
|
*/
|
|
|
|
nofault = &faultbuf;
|
|
|
|
|
|
|
|
if (setjmp(nofault)) {
|
|
|
|
printf("buf = 0x%lx, fault = 0x%lx\n",
|
|
|
|
(u_long)sc->sc_drq_addr, (u_long)m68k_fault_addr);
|
|
|
|
panic("Unexpected bus error in sbc_pdma_out()");
|
|
|
|
}
|
|
|
|
|
1997-06-30 09:24:35 +04:00
|
|
|
#define W1 *byte_data = *((u_int8_t *)data)++
|
|
|
|
#define W4 *long_data = *((u_int32_t *)data)++
|
|
|
|
for (resid = datalen; resid >= 64; resid -= 64) {
|
|
|
|
if (sbc_ready(ncr_sc))
|
1997-04-07 09:48:35 +04:00
|
|
|
goto interrupt;
|
|
|
|
W1;
|
1997-06-30 09:24:35 +04:00
|
|
|
if (sbc_ready(ncr_sc))
|
1997-04-07 09:48:35 +04:00
|
|
|
goto interrupt;
|
|
|
|
W1;
|
1997-06-30 09:24:35 +04:00
|
|
|
if (sbc_ready(ncr_sc))
|
1997-04-07 09:48:35 +04:00
|
|
|
goto interrupt;
|
|
|
|
W1;
|
1997-06-30 09:24:35 +04:00
|
|
|
if (sbc_ready(ncr_sc))
|
1997-04-07 09:48:35 +04:00
|
|
|
goto interrupt;
|
|
|
|
W1;
|
1997-06-30 09:24:35 +04:00
|
|
|
if (sbc_ready(ncr_sc))
|
1997-04-07 09:48:35 +04:00
|
|
|
goto interrupt;
|
|
|
|
W4; W4; W4; W4;
|
|
|
|
W4; W4; W4; W4;
|
|
|
|
W4; W4; W4; W4;
|
|
|
|
W4; W4; W4;
|
|
|
|
}
|
1997-06-30 09:24:35 +04:00
|
|
|
while (resid) {
|
|
|
|
if (sbc_ready(ncr_sc))
|
1997-04-07 09:48:35 +04:00
|
|
|
goto interrupt;
|
|
|
|
W1;
|
1997-06-30 09:24:35 +04:00
|
|
|
resid--;
|
1996-04-26 02:26:52 +04:00
|
|
|
}
|
1997-04-07 09:48:35 +04:00
|
|
|
#undef W1
|
|
|
|
#undef W4
|
1997-06-30 09:24:35 +04:00
|
|
|
if (sbc_wait_dreq(ncr_sc))
|
|
|
|
printf("%s: timeout waiting for DREQ.\n",
|
|
|
|
ncr_sc->sc_dev.dv_xname);
|
1996-04-26 02:26:52 +04:00
|
|
|
|
1997-06-30 09:24:35 +04:00
|
|
|
*byte_data = 0;
|
|
|
|
goto done;
|
1996-04-26 02:26:52 +04:00
|
|
|
|
1997-04-07 09:48:35 +04:00
|
|
|
interrupt:
|
1997-06-30 09:24:35 +04:00
|
|
|
if ((*ncr_sc->sci_csr & SCI_CSR_PHASE_MATCH) == 0) {
|
|
|
|
*ncr_sc->sci_icmd = icmd & ~SCI_ICMD_DATA;
|
|
|
|
--resid;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
1996-04-26 02:26:52 +04:00
|
|
|
SCI_CLR_INTR(ncr_sc);
|
|
|
|
*ncr_sc->sci_mode &= ~SCI_MODE_DMA;
|
1997-04-07 09:48:35 +04:00
|
|
|
*ncr_sc->sci_icmd = icmd;
|
|
|
|
splx(s);
|
|
|
|
return (datalen - resid);
|
1996-04-26 02:26:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
* The following code implements interrupt-driven PDMA.
|
|
|
|
***/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the meat of the PDMA transfer.
|
|
|
|
* When we get here, we shove data as fast as the mac can take it.
|
|
|
|
* We depend on several things:
|
|
|
|
* * All macs after the Mac Plus that have a 5380 chip should have a general
|
|
|
|
* logic IC that handshakes data for blind transfers.
|
|
|
|
* * If the SCSI controller finishes sending/receiving data before we do,
|
|
|
|
* the same general logic IC will generate a /BERR for us in short order.
|
|
|
|
* * The fault address for said /BERR minus the base address for the
|
|
|
|
* transfer will be the amount of data that was actually written.
|
|
|
|
*
|
|
|
|
* We use the nofault flag and the setjmp/longjmp in locore.s so we can
|
|
|
|
* detect and handle the bus error for early termination of a command.
|
|
|
|
* This is usually caused by a disconnecting target.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
sbc_drq_intr(p)
|
|
|
|
void *p;
|
|
|
|
{
|
1997-04-18 21:38:08 +04:00
|
|
|
struct sbc_softc *sc = (struct sbc_softc *)p;
|
|
|
|
struct ncr5380_softc *ncr_sc = (struct ncr5380_softc *)p;
|
1997-04-07 09:48:35 +04:00
|
|
|
struct sci_req *sr = ncr_sc->sc_current;
|
|
|
|
struct sbc_pdma_handle *dh = sr->sr_dma_hand;
|
|
|
|
label_t faultbuf;
|
|
|
|
volatile u_int32_t *long_drq;
|
|
|
|
u_int32_t *long_data;
|
|
|
|
volatile u_int8_t *drq;
|
|
|
|
u_int8_t *data;
|
|
|
|
int count, dcount, resid;
|
|
|
|
u_int8_t tmp;
|
1997-05-13 10:34:00 +04:00
|
|
|
|
|
|
|
/* Work around lame gcc initialization bug */
|
|
|
|
(void)&drq;
|
1996-04-26 02:26:52 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're not ready to xfer data, or have no more, just return.
|
|
|
|
*/
|
1996-04-30 21:07:17 +04:00
|
|
|
if ((*ncr_sc->sci_csr & SCI_CSR_DREQ) == 0 || dh->dh_len == 0)
|
1996-04-26 02:26:52 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef SBC_DEBUG
|
|
|
|
if (sbc_debug & SBC_DB_INTR)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: drq intr, dh_len=0x%x, dh_flags=0x%x\n",
|
1996-04-26 02:26:52 +04:00
|
|
|
ncr_sc->sc_dev.dv_xname, dh->dh_len, dh->dh_flags);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup for a possible bus error caused by SCSI controller
|
|
|
|
* switching out of DATA-IN/OUT before we're done with the
|
|
|
|
* current transfer.
|
|
|
|
*/
|
1997-09-06 11:53:14 +04:00
|
|
|
nofault = &faultbuf;
|
1996-04-26 02:26:52 +04:00
|
|
|
|
1997-04-18 21:38:08 +04:00
|
|
|
if (setjmp((label_t *)nofault)) {
|
1997-09-06 11:53:14 +04:00
|
|
|
nofault = (label_t *)0;
|
1996-06-11 07:20:23 +04:00
|
|
|
if ((dh->dh_flags & SBC_DH_DONE) == 0) {
|
1997-06-29 10:10:35 +04:00
|
|
|
count = (( (u_long)m68k_fault_addr
|
1997-04-18 21:38:08 +04:00
|
|
|
- (u_long)sc->sc_drq_addr));
|
1996-06-11 07:20:23 +04:00
|
|
|
|
|
|
|
if ((count < 0) || (count > dh->dh_len)) {
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: complete=0x%x (pending 0x%x)\n",
|
1996-06-11 07:20:23 +04:00
|
|
|
ncr_sc->sc_dev.dv_xname, count, dh->dh_len);
|
|
|
|
panic("something is wrong");
|
|
|
|
}
|
1996-04-26 02:26:52 +04:00
|
|
|
|
1996-06-11 07:20:23 +04:00
|
|
|
dh->dh_addr += count;
|
|
|
|
dh->dh_len -= count;
|
1997-01-20 07:27:49 +03:00
|
|
|
} else
|
|
|
|
count = 0;
|
1996-06-11 07:20:23 +04:00
|
|
|
|
1996-04-26 02:26:52 +04:00
|
|
|
#ifdef SBC_DEBUG
|
|
|
|
if (sbc_debug & SBC_DB_INTR)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: drq /berr, complete=0x%x (pending 0x%x)\n",
|
1996-06-11 07:20:23 +04:00
|
|
|
ncr_sc->sc_dev.dv_xname, count, dh->dh_len);
|
1996-04-26 02:26:52 +04:00
|
|
|
#endif
|
1997-06-29 10:10:35 +04:00
|
|
|
m68k_fault_addr = 0;
|
1996-04-30 21:07:17 +04:00
|
|
|
|
1996-04-26 02:26:52 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dh->dh_flags & SBC_DH_OUT) { /* Data Out */
|
1997-05-13 10:34:00 +04:00
|
|
|
dcount = 0;
|
|
|
|
|
1996-04-26 02:26:52 +04:00
|
|
|
/*
|
|
|
|
* Get the source address aligned.
|
|
|
|
*/
|
1996-05-08 07:44:56 +04:00
|
|
|
resid =
|
1997-04-18 21:38:08 +04:00
|
|
|
count = min(dh->dh_len, 4 - (((int)dh->dh_addr) & 0x3));
|
1996-04-26 02:26:52 +04:00
|
|
|
if (count && count < 4) {
|
1997-04-18 21:38:08 +04:00
|
|
|
drq = (volatile u_int8_t *)sc->sc_drq_addr;
|
|
|
|
data = (u_int8_t *)dh->dh_addr;
|
1996-06-11 07:20:23 +04:00
|
|
|
|
1996-04-26 02:26:52 +04:00
|
|
|
#define W1 *drq++ = *data++
|
|
|
|
while (count) {
|
|
|
|
W1; count--;
|
|
|
|
}
|
|
|
|
#undef W1
|
|
|
|
dh->dh_addr += resid;
|
|
|
|
dh->dh_len -= resid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-06-11 07:20:23 +04:00
|
|
|
* Start the transfer.
|
1996-04-26 02:26:52 +04:00
|
|
|
*/
|
|
|
|
while (dh->dh_len) {
|
|
|
|
dcount = count = min(dh->dh_len, MAX_DMA_LEN);
|
1997-04-18 21:38:08 +04:00
|
|
|
long_drq = (volatile u_int32_t *)sc->sc_drq_addr;
|
|
|
|
long_data = (u_int32_t *)dh->dh_addr;
|
1996-04-26 02:26:52 +04:00
|
|
|
|
|
|
|
#define W4 *long_drq++ = *long_data++
|
|
|
|
while (count >= 64) {
|
|
|
|
W4; W4; W4; W4; W4; W4; W4; W4;
|
|
|
|
W4; W4; W4; W4; W4; W4; W4; W4; /* 64 */
|
|
|
|
count -= 64;
|
|
|
|
}
|
|
|
|
while (count >= 4) {
|
|
|
|
W4; count -= 4;
|
|
|
|
}
|
|
|
|
#undef W4
|
1997-04-18 21:38:08 +04:00
|
|
|
data = (u_int8_t *)long_data;
|
|
|
|
drq = (u_int8_t *)long_drq;
|
1996-06-11 07:20:23 +04:00
|
|
|
|
1996-05-29 18:26:33 +04:00
|
|
|
#define W1 *drq++ = *data++
|
|
|
|
while (count) {
|
|
|
|
W1; count--;
|
|
|
|
}
|
|
|
|
#undef W1
|
|
|
|
dh->dh_len -= dcount;
|
|
|
|
dh->dh_addr += dcount;
|
|
|
|
}
|
1996-06-11 07:20:23 +04:00
|
|
|
dh->dh_flags |= SBC_DH_DONE;
|
1996-05-29 18:26:33 +04:00
|
|
|
|
|
|
|
/*
|
1996-06-11 07:20:23 +04:00
|
|
|
* XXX -- Read a byte from the SBC to trigger a /BERR.
|
|
|
|
* This seems to be necessary for us to notice that
|
|
|
|
* the target has disconnected. Ick. 06 jun 1996 (sr)
|
1996-05-29 18:26:33 +04:00
|
|
|
*/
|
1997-05-13 10:34:00 +04:00
|
|
|
if (dcount >= MAX_DMA_LEN)
|
1997-04-18 21:38:08 +04:00
|
|
|
drq = (volatile u_int8_t *)sc->sc_drq_addr;
|
1996-06-11 07:20:23 +04:00
|
|
|
tmp = *drq;
|
1996-04-26 02:26:52 +04:00
|
|
|
} else { /* Data In */
|
|
|
|
/*
|
|
|
|
* Get the dest address aligned.
|
|
|
|
*/
|
1996-05-08 07:44:56 +04:00
|
|
|
resid =
|
1997-04-18 21:38:08 +04:00
|
|
|
count = min(dh->dh_len, 4 - (((int)dh->dh_addr) & 0x3));
|
1996-04-26 02:26:52 +04:00
|
|
|
if (count && count < 4) {
|
1997-04-18 21:38:08 +04:00
|
|
|
data = (u_int8_t *)dh->dh_addr;
|
|
|
|
drq = (volatile u_int8_t *)sc->sc_drq_addr;
|
1996-06-11 07:20:23 +04:00
|
|
|
|
1996-04-26 02:26:52 +04:00
|
|
|
#define R1 *data++ = *drq++
|
|
|
|
while (count) {
|
|
|
|
R1; count--;
|
|
|
|
}
|
|
|
|
#undef R1
|
|
|
|
dh->dh_addr += resid;
|
|
|
|
dh->dh_len -= resid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-06-11 07:20:23 +04:00
|
|
|
* Start the transfer.
|
1996-04-26 02:26:52 +04:00
|
|
|
*/
|
|
|
|
while (dh->dh_len) {
|
|
|
|
dcount = count = min(dh->dh_len, MAX_DMA_LEN);
|
1997-04-18 21:38:08 +04:00
|
|
|
long_data = (u_int32_t *)dh->dh_addr;
|
|
|
|
long_drq = (volatile u_int32_t *)sc->sc_drq_addr;
|
1996-04-26 02:26:52 +04:00
|
|
|
|
|
|
|
#define R4 *long_data++ = *long_drq++
|
1996-06-11 07:20:23 +04:00
|
|
|
while (count >= 64) {
|
1996-04-26 02:26:52 +04:00
|
|
|
R4; R4; R4; R4; R4; R4; R4; R4;
|
|
|
|
R4; R4; R4; R4; R4; R4; R4; R4; /* 64 */
|
1996-06-11 07:20:23 +04:00
|
|
|
count -= 64;
|
1996-04-26 02:26:52 +04:00
|
|
|
}
|
|
|
|
while (count >= 4) {
|
|
|
|
R4; count -= 4;
|
|
|
|
}
|
|
|
|
#undef R4
|
1997-04-18 21:38:08 +04:00
|
|
|
data = (u_int8_t *)long_data;
|
|
|
|
drq = (volatile u_int8_t *)long_drq;
|
1996-06-11 07:20:23 +04:00
|
|
|
|
1996-04-26 02:26:52 +04:00
|
|
|
#define R1 *data++ = *drq++
|
|
|
|
while (count) {
|
|
|
|
R1; count--;
|
|
|
|
}
|
|
|
|
#undef R1
|
|
|
|
dh->dh_len -= dcount;
|
|
|
|
dh->dh_addr += dcount;
|
|
|
|
}
|
1996-06-11 07:20:23 +04:00
|
|
|
dh->dh_flags |= SBC_DH_DONE;
|
1996-04-26 02:26:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OK. No bus error occurred above. Clear the nofault flag
|
|
|
|
* so we no longer short-circuit bus errors.
|
|
|
|
*/
|
1997-09-06 11:53:14 +04:00
|
|
|
nofault = (label_t *)0;
|
1996-05-29 18:26:33 +04:00
|
|
|
|
|
|
|
#ifdef SBC_DEBUG
|
|
|
|
if (sbc_debug & (SBC_DB_REG | SBC_DB_INTR))
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: drq intr complete: csr=0x%x, bus_csr=0x%x\n",
|
1996-05-29 18:26:33 +04:00
|
|
|
ncr_sc->sc_dev.dv_xname, *ncr_sc->sci_csr,
|
|
|
|
*ncr_sc->sci_bus_csr);
|
|
|
|
#endif
|
1996-04-26 02:26:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sbc_dma_alloc(ncr_sc)
|
|
|
|
struct ncr5380_softc *ncr_sc;
|
|
|
|
{
|
1997-04-18 21:38:08 +04:00
|
|
|
struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
|
1996-04-26 02:26:52 +04:00
|
|
|
struct sci_req *sr = ncr_sc->sc_current;
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_xfer *xs = sr->sr_xs;
|
1996-04-26 02:26:52 +04:00
|
|
|
struct sbc_pdma_handle *dh;
|
|
|
|
int i, xlen;
|
|
|
|
|
1996-05-08 07:44:56 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
1996-04-26 02:26:52 +04:00
|
|
|
if (sr->sr_dma_hand != NULL)
|
|
|
|
panic("sbc_dma_alloc: already have PDMA handle");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Polled transfers shouldn't allocate a PDMA handle. */
|
|
|
|
if (sr->sr_flags & SR_IMMED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xlen = ncr_sc->sc_datalen;
|
|
|
|
|
|
|
|
/* Make sure our caller checked sc_min_dma_len. */
|
|
|
|
if (xlen < MIN_DMA_LEN)
|
|
|
|
panic("sbc_dma_alloc: len=0x%x\n", xlen);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find free PDMA handle. Guaranteed to find one since we
|
|
|
|
* have as many PDMA handles as the driver has processes.
|
|
|
|
* (instances?)
|
|
|
|
*/
|
|
|
|
for (i = 0; i < SCI_OPENINGS; i++) {
|
|
|
|
if ((sc->sc_pdma[i].dh_flags & SBC_DH_BUSY) == 0)
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
panic("sbc: no free PDMA handles");
|
|
|
|
found:
|
|
|
|
dh = &sc->sc_pdma[i];
|
|
|
|
dh->dh_flags = SBC_DH_BUSY;
|
|
|
|
dh->dh_addr = ncr_sc->sc_dataptr;
|
|
|
|
dh->dh_len = xlen;
|
|
|
|
|
|
|
|
/* Copy the 'write' flag for convenience. */
|
|
|
|
if (xs->flags & SCSI_DATA_OUT)
|
|
|
|
dh->dh_flags |= SBC_DH_OUT;
|
|
|
|
|
|
|
|
sr->sr_dma_hand = dh;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sbc_dma_free(ncr_sc)
|
|
|
|
struct ncr5380_softc *ncr_sc;
|
|
|
|
{
|
|
|
|
struct sci_req *sr = ncr_sc->sc_current;
|
|
|
|
struct sbc_pdma_handle *dh = sr->sr_dma_hand;
|
|
|
|
|
1996-05-08 07:44:56 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
1996-04-26 02:26:52 +04:00
|
|
|
if (sr->sr_dma_hand == NULL)
|
|
|
|
panic("sbc_dma_free: no DMA handle");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (ncr_sc->sc_state & NCR_DOINGDMA)
|
|
|
|
panic("sbc_dma_free: free while in progress");
|
|
|
|
|
|
|
|
if (dh->dh_flags & SBC_DH_BUSY) {
|
|
|
|
dh->dh_flags = 0;
|
|
|
|
dh->dh_addr = NULL;
|
|
|
|
dh->dh_len = 0;
|
|
|
|
}
|
|
|
|
sr->sr_dma_hand = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sbc_dma_poll(ncr_sc)
|
|
|
|
struct ncr5380_softc *ncr_sc;
|
|
|
|
{
|
|
|
|
struct sci_req *sr = ncr_sc->sc_current;
|
|
|
|
|
1996-04-30 21:07:17 +04:00
|
|
|
/*
|
|
|
|
* We shouldn't arrive here; if SR_IMMED is set, then
|
|
|
|
* dma_alloc() should have refused to allocate a handle
|
|
|
|
* for the transfer. This forces the polled PDMA code
|
|
|
|
* to handle the request...
|
|
|
|
*/
|
1996-05-08 07:44:56 +04:00
|
|
|
#ifdef SBC_DEBUG
|
1996-04-26 02:26:52 +04:00
|
|
|
if (sbc_debug & SBC_DB_DMA)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: lost DRQ interrupt?\n", ncr_sc->sc_dev.dv_xname);
|
1996-04-26 02:26:52 +04:00
|
|
|
#endif
|
1996-04-30 21:07:17 +04:00
|
|
|
sr->sr_flags |= SR_OVERDUE;
|
1996-04-26 02:26:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sbc_dma_setup(ncr_sc)
|
|
|
|
struct ncr5380_softc *ncr_sc;
|
|
|
|
{
|
|
|
|
/* Not needed; we don't have real DMA */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sbc_dma_start(ncr_sc)
|
|
|
|
struct ncr5380_softc *ncr_sc;
|
|
|
|
{
|
1997-04-18 21:38:08 +04:00
|
|
|
struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
|
1996-04-26 02:26:52 +04:00
|
|
|
struct sci_req *sr = ncr_sc->sc_current;
|
|
|
|
struct sbc_pdma_handle *dh = sr->sr_dma_hand;
|
|
|
|
|
|
|
|
/*
|
1996-05-29 18:26:33 +04:00
|
|
|
* Match bus phase, clear pending interrupts, set DMA mode, and
|
|
|
|
* assert data bus (for writing only), then start the transfer.
|
1996-04-26 02:26:52 +04:00
|
|
|
*/
|
|
|
|
if (dh->dh_flags & SBC_DH_OUT) {
|
|
|
|
*ncr_sc->sci_tcmd = PHASE_DATA_OUT;
|
|
|
|
SCI_CLR_INTR(ncr_sc);
|
1997-03-01 23:18:58 +03:00
|
|
|
if (sc->sc_clrintr)
|
|
|
|
(*sc->sc_clrintr)(ncr_sc);
|
1996-04-26 02:26:52 +04:00
|
|
|
*ncr_sc->sci_mode |= SCI_MODE_DMA;
|
|
|
|
*ncr_sc->sci_icmd = SCI_ICMD_DATA;
|
|
|
|
*ncr_sc->sci_dma_send = 0;
|
|
|
|
} else {
|
|
|
|
*ncr_sc->sci_tcmd = PHASE_DATA_IN;
|
|
|
|
SCI_CLR_INTR(ncr_sc);
|
1997-03-01 23:18:58 +03:00
|
|
|
if (sc->sc_clrintr)
|
|
|
|
(*sc->sc_clrintr)(ncr_sc);
|
1996-04-26 02:26:52 +04:00
|
|
|
*ncr_sc->sci_mode |= SCI_MODE_DMA;
|
|
|
|
*ncr_sc->sci_icmd = 0;
|
|
|
|
*ncr_sc->sci_irecv = 0;
|
|
|
|
}
|
|
|
|
ncr_sc->sc_state |= NCR_DOINGDMA;
|
|
|
|
|
1996-05-08 07:44:56 +04:00
|
|
|
#ifdef SBC_DEBUG
|
1996-04-26 02:26:52 +04:00
|
|
|
if (sbc_debug & SBC_DB_DMA)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: PDMA started, va=%p, len=0x%x\n",
|
1996-04-26 02:26:52 +04:00
|
|
|
ncr_sc->sc_dev.dv_xname, dh->dh_addr, dh->dh_len);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sbc_dma_eop(ncr_sc)
|
|
|
|
struct ncr5380_softc *ncr_sc;
|
|
|
|
{
|
|
|
|
/* Not used; the EOP pin is wired high (GMFH, pp. 389-390) */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sbc_dma_stop(ncr_sc)
|
|
|
|
struct ncr5380_softc *ncr_sc;
|
|
|
|
{
|
1997-04-18 21:38:08 +04:00
|
|
|
struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
|
1996-04-26 02:26:52 +04:00
|
|
|
struct sci_req *sr = ncr_sc->sc_current;
|
|
|
|
struct sbc_pdma_handle *dh = sr->sr_dma_hand;
|
1997-04-07 09:48:35 +04:00
|
|
|
int ntrans;
|
1996-04-26 02:26:52 +04:00
|
|
|
|
|
|
|
if ((ncr_sc->sc_state & NCR_DOINGDMA) == 0) {
|
|
|
|
#ifdef SBC_DEBUG
|
|
|
|
if (sbc_debug & SBC_DB_DMA)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: dma_stop: DMA not running\n",
|
1996-04-26 02:26:52 +04:00
|
|
|
ncr_sc->sc_dev.dv_xname);
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ncr_sc->sc_state &= ~NCR_DOINGDMA;
|
|
|
|
|
1996-04-30 21:07:17 +04:00
|
|
|
if ((ncr_sc->sc_state & NCR_ABORTING) == 0) {
|
1996-04-26 02:26:52 +04:00
|
|
|
ntrans = ncr_sc->sc_datalen - dh->dh_len;
|
|
|
|
|
|
|
|
#ifdef SBC_DEBUG
|
|
|
|
if (sbc_debug & SBC_DB_DMA)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: dma_stop: ntrans=0x%x\n",
|
1996-04-26 02:26:52 +04:00
|
|
|
ncr_sc->sc_dev.dv_xname, ntrans);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (ntrans > ncr_sc->sc_datalen)
|
|
|
|
panic("sbc_dma_stop: excess transfer\n");
|
|
|
|
|
|
|
|
/* Adjust data pointer */
|
|
|
|
ncr_sc->sc_dataptr += ntrans;
|
|
|
|
ncr_sc->sc_datalen -= ntrans;
|
|
|
|
|
|
|
|
/* Clear any pending interrupts. */
|
|
|
|
SCI_CLR_INTR(ncr_sc);
|
1997-03-01 23:18:58 +03:00
|
|
|
if (sc->sc_clrintr)
|
|
|
|
(*sc->sc_clrintr)(ncr_sc);
|
1996-04-26 02:26:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Put SBIC back into PIO mode. */
|
|
|
|
*ncr_sc->sci_mode &= ~SCI_MODE_DMA;
|
|
|
|
*ncr_sc->sci_icmd = 0;
|
|
|
|
|
|
|
|
#ifdef SBC_DEBUG
|
1996-04-30 21:07:17 +04:00
|
|
|
if (sbc_debug & SBC_DB_REG)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("%s: dma_stop: csr=0x%x, bus_csr=0x%x\n",
|
1996-04-26 02:26:52 +04:00
|
|
|
ncr_sc->sc_dev.dv_xname, *ncr_sc->sci_csr,
|
|
|
|
*ncr_sc->sci_bus_csr);
|
|
|
|
#endif
|
|
|
|
}
|