summaryrefslogtreecommitdiff
path: root/sys/arch/pmax/dev/sii.c
diff options
context:
space:
mode:
authorThomas Graichen <graichen@cvs.openbsd.org>1996-12-22 15:19:07 +0000
committerThomas Graichen <graichen@cvs.openbsd.org>1996-12-22 15:19:07 +0000
commitca1c7fedd990e6b1e7244233df5a6a638f0e4e31 (patch)
tree20016b11dce3c72001f0e250c8f1a714ed64e546 /sys/arch/pmax/dev/sii.c
parentde4c3561677938c64d13b1e5112686a88b0b47fe (diff)
update the pmax stuff to NetBSD 961107 - this version i got somehow
compiled on my decstation 2100 (PLUTO) - but it will not fully work out of the box - but i want to bring it into the tree because i get my own pmax on 961228 - so that i have a good startpoint then :-) all the OpenBSD changes to the pmax tree will follow in the next commit
Diffstat (limited to 'sys/arch/pmax/dev/sii.c')
-rw-r--r--sys/arch/pmax/dev/sii.c157
1 files changed, 66 insertions, 91 deletions
diff --git a/sys/arch/pmax/dev/sii.c b/sys/arch/pmax/dev/sii.c
index f170f614ee6..aadc25d0c94 100644
--- a/sys/arch/pmax/dev/sii.c
+++ b/sys/arch/pmax/dev/sii.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sii.c,v 1.12.4.2 1996/09/09 20:24:36 thorpej Exp $ */
+/* $NetBSD: sii.c,v 1.20 1996/10/22 23:15:10 mhitch Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -60,74 +60,37 @@
#endif
#include <machine/autoconf.h>
-#include <machine/machConst.h>
+
+/* old 4.4bsd/pmax scsi drivers */
#include <pmax/dev/device.h>
#include <pmax/dev/scsi.h>
#include <pmax/dev/siireg.h>
+#include <pmax/dev/siivar.h>
-#include <pmax/pmax/kn01.h>
-
-typedef struct scsi_state {
- int statusByte; /* status byte returned during STATUS_PHASE */
- int dmaDataPhase; /* which data phase to expect */
- int dmaCurPhase; /* SCSI phase if DMA is in progress */
- int dmaPrevPhase; /* SCSI phase of DMA suspended by disconnect */
- u_short *dmaAddr[2]; /* DMA buffer memory address */
- int dmaBufIndex; /* which of the above is currently in use */
- int dmalen; /* amount to transfer in this chunk */
- int cmdlen; /* total remaining amount of cmd to transfer */
- u_char *cmd; /* current pointer within scsicmd->cmd */
- int buflen; /* total remaining amount of data to transfer */
- char *buf; /* current pointer within scsicmd->buf */
- u_short flags; /* see below */
- u_short prevComm; /* command reg before disconnect */
- u_short dmaCtrl; /* DMA control register if disconnect */
- u_short dmaAddrL; /* DMA address register if disconnect */
- u_short dmaAddrH; /* DMA address register if disconnect */
- u_short dmaCnt; /* DMA count if disconnect */
- u_short dmaByte; /* DMA byte if disconnect on odd boundary */
- u_short dmaReqAck; /* DMA synchronous xfer offset or 0 if async */
-} State;
-
-/* state flags */
-#define FIRST_DMA 0x01 /* true if no data DMA started yet */
-#define PARITY_ERR 0x02 /* true if parity error seen */
-
-#define SII_NCMD 7
-struct siisoftc {
- struct device sc_dev; /* us as a device */
- SIIRegs *sc_regs; /* HW address of SII controller chip */
- int sc_flags;
- int sc_target; /* target SCSI ID if connected */
- ScsiCmd *sc_cmd[SII_NCMD]; /* active command indexed by ID */
- State sc_st[SII_NCMD]; /* state info for each active command */
-#ifdef NEW_SCSI
- struct scsi_link sc_link; /* scsi lint struct */
-#endif
-};
+
+/* Machine-indepedent back-end attach entry point */
+void siiattach __P((struct siisoftc *sc));
/*
- * Device definition for autoconfiguration.
- *
+ * Autoconfig definition of driver front-end
*/
-int siimatch __P((struct device * parent, void *cfdata, void *aux));
-void siiattach __P((struct device *parent, struct device *self, void *aux));
-int siiprint(void*, const char*);
-
-int sii_doprobe __P((void *addr, int unit, int flags, int pri,
- struct device *self));
-int siiintr __P((void *sc));
-
-extern struct cfdriver sii_cd;
+#include <machine/machConst.h>
+int old_siimatch __P((struct device * parent, void *cfdata, void *aux));
+void old_siiattach __P((struct device *parent, struct device *self, void *aux));
+extern struct cfattach sii_ca;
struct cfattach sii_ca = {
- sizeof(struct siisoftc), siimatch, siiattach
+ sizeof(struct siisoftc), old_siimatch, old_siiattach
};
+extern struct cfdriver sii_cd;
struct cfdriver sii_cd = {
NULL, "sii", DV_DULL
};
+int siiprint(void*, char*);
+int siiintr __P((void *sc));
+
#ifdef USE_NEW_SCSI
/* Glue to the machine-independent scsi */
struct scsi_adapter asc_switch = {
@@ -149,15 +112,6 @@ struct scsi_device sii_dev = {
};
#endif
-/*
- * Definition of the controller for the old auto-configuration program
- * and old-style pmax scsi drivers.
- */
-void siistart();
-struct pmax_driver siidriver = {
- "sii", NULL, siistart, 0,
-};
-
/*
* MACROS for timing out spin loops.
@@ -211,10 +165,12 @@ u_char sii_buf[256]; /* used for extended messages */
#define NOWAIT 0
#define WAIT 1
-/* define a safe address in the SCSI buffer for doing status & message DMA */
-#define SII_BUF_ADDR (MACH_PHYS_TO_UNCACHED(KN01_SYS_SII_B_START) \
- + SII_MAX_DMA_XFER_LENGTH * 14)
+/*
+ * Define a safe address in the SCSI buffer for doing status & message DMA
+ * XXX why not add another field to softc?
+ */
+#define SII_BUF_ADDR(sc) ((sc)->sc_buf + SII_MAX_DMA_XFER_LENGTH * 14)
/*
* Other forward references
@@ -239,12 +195,20 @@ void CopyToBuffer __P((u_short *src, /* NOTE: must be short aligned */
void CopyFromBuffer __P((volatile u_short *src, char *dst, int length));
+/*
+ * Definition of the controller for the old-style, non-MI
+ * pmax scsi drivers, and for autoconfiguring devices via those
+ * drivers.
+ */
+struct pmax_driver siidriver = {
+ "sii", NULL, siistart, 0,
+};
/*
* Match driver based on name
*/
int
-siimatch(parent, match, aux)
+old_siimatch(parent, match, aux)
struct device *parent;
void *match;
void *aux;
@@ -267,21 +231,32 @@ siimatch(parent, match, aux)
}
void
-siiattach(parent, self, aux)
+old_siiattach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
register struct confargs *ca = aux;
register struct siisoftc *sc = (struct siisoftc *) self;
- register void *siiaddr;
- register int i;
-
- siiaddr = (void*)MACH_PHYS_TO_UNCACHED(ca->ca_addr);
- sc->sc_regs = (SIIRegs *)siiaddr;
+ sc->sc_regs = (SIIRegs *)MACH_PHYS_TO_UNCACHED(ca->ca_addr);
sc->sc_flags = sc->sc_dev.dv_cfdata->cf_flags;
+
+ siiattach(sc);
+
+ /* tie pseudo-slot to device */
+ BUS_INTR_ESTABLISH(ca, siiintr, sc);
+ printf("\n");
+}
+
+void
+siiattach(sc)
+ register struct siisoftc *sc;
+{
+ register int i;
+
sc->sc_target = -1; /* no command active */
+
/*
* Give each target its own DMA buffer region.
* Make it big enough for 2 max transfers so we can ping pong buffers
@@ -289,8 +264,7 @@ siiattach(parent, self, aux)
*/
for (i = 0; i < SII_NCMD; i++) {
sc->sc_st[i].dmaAddr[0] = (u_short *)
- MACH_PHYS_TO_UNCACHED(KN01_SYS_SII_B_START) +
- 2 * SII_MAX_DMA_XFER_LENGTH * i;
+ sc->sc_buf + 2 * SII_MAX_DMA_XFER_LENGTH * i;
sc->sc_st[i].dmaAddr[1] = sc->sc_st[i].dmaAddr[0] +
SII_MAX_DMA_XFER_LENGTH;
}
@@ -299,13 +273,13 @@ siiattach(parent, self, aux)
(void) pmax_add_scsi(&siidriver, sc->sc_dev.dv_unit);
sii_Reset(sc, RESET);
-
- /*priority = ca->ca_slot;*/
- /* tie pseudo-slot to device */
- BUS_INTR_ESTABLISH(ca, siiintr, sc);
- printf("\n");
+#ifdef USE_NEW_SCSI
+ /* XXX probe SCSI bus and attach slave devices */
+#endif
}
+
+
/*
* Start activity on a SCSI device.
* We maintain information on each device separately since devices can
@@ -518,11 +492,11 @@ sii_StartCmd(sc, target)
state->dmaCurPhase = SII_MSG_OUT_PHASE,
state->dmalen = 6;
CopyToBuffer((u_short *)sii_buf,
- (volatile u_short *)SII_BUF_ADDR, 6);
+ (volatile u_short *)SII_BUF_ADDR(sc), 6);
regs->slcsr = target;
regs->dmctrl = state->dmaReqAck;
- regs->dmaddrl = (u_short)(SII_BUF_ADDR >> 1);
- regs->dmaddrh = (u_short)(SII_BUF_ADDR >> 17) & 03;
+ regs->dmaddrl = (u_short)(SII_BUF_ADDR(sc) >> 1);
+ regs->dmaddrh = (u_short)(SII_BUF_ADDR(sc) >> 17) & 03;
regs->dmlotc = 6;
regs->comm = SII_DMA | SII_INXFER | SII_SELECT | SII_ATN |
SII_CON | SII_MSG_OUT_PHASE;
@@ -1748,15 +1722,16 @@ sii_DoSync(regs, state)
regs->dstat = SII_DNE;
wbflush();
}
-#else
- CopyToBuffer((u_short *)sii_buf, (volatile u_short *)SII_BUF_ADDR, 5);
+#else /* 0 */
+ CopyToBuffer((u_short *)sii_buf,
+ (volatile u_short *)SII_BUF_ADDR(sc), 5);
printf("sii_DoSync: %x %x %x ds %x\n",
- ((volatile u_short *)SII_BUF_ADDR)[0],
- ((volatile u_short *)SII_BUF_ADDR)[2],
- ((volatile u_short *)SII_BUF_ADDR)[4],
+ ((volatile u_short *)SII_BUF_ADDR(sc))[0],
+ ((volatile u_short *)SII_BUF_ADDR(sc))[2],
+ ((volatile u_short *)SII_BUF_ADDR(sc))[4],
regs->dstat); /* XXX */
- regs->dmaddrl = (u_short)(SII_BUF_ADDR >> 1);
- regs->dmaddrh = (u_short)(SII_BUF_ADDR >> 17) & 03;
+ regs->dmaddrl = (u_short)(SII_BUF_ADDR(sc) >> 1);
+ regs->dmaddrh = (u_short)(SII_BUF_ADDR(sc) >> 17) & 03;
regs->dmlotc = 5;
regs->comm = SII_DMA | SII_INXFER | SII_ATN |
(regs->cstat & SII_STATE_MSK) | SII_MSG_OUT_PHASE;
@@ -1776,7 +1751,7 @@ sii_DoSync(regs, state)
/* clear the DNE, other errors handled later */
regs->dstat = SII_DNE;
wbflush();
-#endif
+#endif /* 0 */
#if 0
SII_WAIT_UNTIL(dstat, regs->dstat, dstat & (SII_CI | SII_DI),