summaryrefslogtreecommitdiffstats
path: root/sys/dev/tc
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1996-04-21 22:14:33 +0000
committerderaadt <deraadt@openbsd.org>1996-04-21 22:14:33 +0000
commitd724e01ae4dac35949585b9083e28ff2ba35b0b5 (patch)
tree37282f1ae947a4e9508b73ff86cad13f75eb9860 /sys/dev/tc
parentno need to remove limits.h; another workaround exists (diff)
downloadwireguard-openbsd-d724e01ae4dac35949585b9083e28ff2ba35b0b5.tar.xz
wireguard-openbsd-d724e01ae4dac35949585b9083e28ff2ba35b0b5.zip
partial sync with netbsd 960418, more to come
Diffstat (limited to 'sys/dev/tc')
-rw-r--r--sys/dev/tc/asc.c153
-rw-r--r--sys/dev/tc/files.tc10
-rw-r--r--sys/dev/tc/if_le.c99
-rw-r--r--sys/dev/tc/ioasicvar.h4
-rw-r--r--sys/dev/tc/tc.c20
-rw-r--r--sys/dev/tc/tcvar.h6
6 files changed, 167 insertions, 125 deletions
diff --git a/sys/dev/tc/asc.c b/sys/dev/tc/asc.c
index d41fc46f32b..c61f99c5774 100644
--- a/sys/dev/tc/asc.c
+++ b/sys/dev/tc/asc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: asc.c,v 1.16 1996/01/04 17:43:23 jonathan Exp $ */
+/* $NetBSD: asc.c,v 1.18 1996/03/18 01:39:47 jonathan Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -129,6 +129,8 @@
#include <sys/conf.h>
#include <sys/errno.h>
#include <sys/device.h>
+#include <dev/tc/tcvar.h>
+#include <dev/tc/ioasicvar.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
@@ -145,7 +147,8 @@
#include <pmax/pmax/pmaxtype.h>
-#define readback(a) { register int foo; foo = (a); }
+/*#define readback(a) { register int foo; wbflush(); foo = (a); }*/
+#define readback(a) { register int foo; foo = (a); }
extern int pmax_boardtype;
/*
@@ -273,38 +276,38 @@ static int asc_disconnect(); /* process an expected disconnect */
*/
script_t asc_scripts[] = {
/* start data in */
- {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, ASC_PHASE_DATAI), /* 0 */
+ {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, SCSI_PHASE_DATAI), /* 0 */
asc_dma_in, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_IN + 1]},
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_STATUS), /* 1 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_STATUS), /* 1 */
asc_last_dma_in, ASC_CMD_I_COMPLETE,
&asc_scripts[SCRIPT_GET_STATUS]},
/* continue data in after a chunk is finished */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAI), /* 2 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAI), /* 2 */
asc_dma_in, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_IN + 1]},
/* start data out */
- {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, ASC_PHASE_DATAO), /* 3 */
+ {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, SCSI_PHASE_DATAO), /* 3 */
asc_dma_out, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_OUT + 1]},
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_STATUS), /* 4 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_STATUS), /* 4 */
asc_last_dma_out, ASC_CMD_I_COMPLETE,
&asc_scripts[SCRIPT_GET_STATUS]},
/* continue data out after a chunk is finished */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAO), /* 5 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAO), /* 5 */
asc_dma_out, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_OUT + 1]},
/* simple command with no data transfer */
- {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, ASC_PHASE_STATUS), /* 6 */
+ {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, SCSI_PHASE_STATUS), /* 6 */
script_nop, ASC_CMD_I_COMPLETE,
&asc_scripts[SCRIPT_GET_STATUS]},
/* get status and finish command */
- {SCRIPT_MATCH(ASC_INT_FC, ASC_PHASE_MSG_IN), /* 7 */
+ {SCRIPT_MATCH(ASC_INT_FC, SCSI_PHASE_MSG_IN), /* 7 */
asc_get_status, ASC_CMD_MSG_ACPT,
&asc_scripts[SCRIPT_DONE]},
{SCRIPT_MATCH(ASC_INT_DISC, 0), /* 8 */
@@ -312,61 +315,61 @@ script_t asc_scripts[] = {
&asc_scripts[SCRIPT_DONE]},
/* message in */
- {SCRIPT_MATCH(ASC_INT_FC, ASC_PHASE_MSG_IN), /* 9 */
+ {SCRIPT_MATCH(ASC_INT_FC, SCSI_PHASE_MSG_IN), /* 9 */
asc_msg_in, ASC_CMD_MSG_ACPT,
&asc_scripts[SCRIPT_MSG_IN + 1]},
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_MSG_IN), /* 10 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_MSG_IN), /* 10 */
script_nop, ASC_CMD_XFER_INFO,
&asc_scripts[SCRIPT_MSG_IN]},
/* send synchonous negotiation reply */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_MSG_OUT), /* 11 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_MSG_OUT), /* 11 */
asc_replysync, ASC_CMD_XFER_INFO,
&asc_scripts[SCRIPT_REPLY_SYNC]},
/* try to negotiate synchonous transfer parameters */
- {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, ASC_PHASE_MSG_OUT), /* 12 */
+ {SCRIPT_MATCH(ASC_INT_FC | ASC_INT_BS, SCSI_PHASE_MSG_OUT), /* 12 */
asc_sendsync, ASC_CMD_XFER_INFO,
&asc_scripts[SCRIPT_TRY_SYNC + 1]},
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_MSG_IN), /* 13 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_MSG_IN), /* 13 */
script_nop, ASC_CMD_XFER_INFO,
&asc_scripts[SCRIPT_MSG_IN]},
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_COMMAND), /* 14 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_COMMAND), /* 14 */
script_nop, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_RESUME_NO_DATA]},
/* handle a disconnect */
- {SCRIPT_MATCH(ASC_INT_DISC, ASC_PHASE_DATAO), /* 15 */
+ {SCRIPT_MATCH(ASC_INT_DISC, SCSI_PHASE_DATAO), /* 15 */
asc_disconnect, ASC_CMD_ENABLE_SEL,
&asc_scripts[SCRIPT_RESEL]},
/* reselect sequence: this is just a placeholder so match fails */
- {SCRIPT_MATCH(0, ASC_PHASE_MSG_IN), /* 16 */
+ {SCRIPT_MATCH(0, SCSI_PHASE_MSG_IN), /* 16 */
script_nop, ASC_CMD_MSG_ACPT,
&asc_scripts[SCRIPT_RESEL]},
/* resume data in after a message */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAI), /* 17 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAI), /* 17 */
asc_resume_in, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_IN + 1]},
/* resume partial DMA data in after a message */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAI), /* 18 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAI), /* 18 */
asc_resume_dma_in, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_IN + 1]},
/* resume data out after a message */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAO), /* 19 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAO), /* 19 */
asc_resume_out, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_OUT + 1]},
/* resume partial DMA data out after a message */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_DATAO), /* 20 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_DATAO), /* 20 */
asc_resume_dma_out, ASC_CMD_XFER_INFO | ASC_CMD_DMA,
&asc_scripts[SCRIPT_DATA_OUT + 1]},
/* resume after a message when there is no more data */
- {SCRIPT_MATCH(ASC_INT_BS, ASC_PHASE_STATUS), /* 21 */
+ {SCRIPT_MATCH(ASC_INT_BS, SCSI_PHASE_STATUS), /* 21 */
script_nop, ASC_CMD_I_COMPLETE,
&asc_scripts[SCRIPT_GET_STATUS]},
};
@@ -446,7 +449,7 @@ typedef struct asc_softc *asc_softc_t;
#define ASCDMA_WRITE 2
static void tb_dma_start(), tb_dma_end(), asic_dma_start(), asic_dma_end();
extern u_long asc_iomem;
-extern u_long asic_base;
+
/*
* Autoconfiguration data for config.
@@ -455,11 +458,16 @@ int ascmatch __P((struct device * parent, void *cfdata, void *aux));
void ascattach __P((struct device *parent, struct device *self, void *aux));
int ascprint(void*, char*);
-extern struct cfdriver asccd;
-struct cfdriver asccd = {
- NULL, "asc", ascmatch, ascattach, DV_DULL, sizeof(struct asc_softc)
+struct cfattach asc_ca = {
+ sizeof(struct asc_softc), ascmatch, ascattach
+};
+
+extern struct cfdriver asc_cd;
+struct cfdriver asc_cd = {
+ NULL, "as", DV_DULL
};
+
#ifdef USE_NEW_SCSI
/* Glue to the machine-independent scsi */
struct scsi_adapter asc_switch = {
@@ -498,19 +506,22 @@ ascmatch(parent, match, aux)
{
struct cfdata *cf = match;
struct confargs *ca = aux;
- void *sccaddr;
+ void *ascaddr;
- if (!BUS_MATCHNAME(ca, "asc") && !BUS_MATCHNAME(ca, "PMAZ-AA "))
+ /*if (parent->dv_cfdata->cf_driver == &ioasic_cd) */
+ if (!TC_BUS_MATCHNAME(ca, "asc") && !TC_BUS_MATCHNAME(ca, "PMAZ-AA "))
return (0);
- sccaddr = BUS_CVTADDR(ca);
+ ascaddr = (void*)ca->ca_addr;
- if (badaddr(sccaddr + ASC_OFFSET_53C94, 4))
+ if (badaddr(ascaddr + ASC_OFFSET_53C94, 4))
return (0);
return (1);
}
+extern struct cfdriver ioasic_cd; /* XXX */
+
void
ascattach(parent, self, aux)
struct device *parent;
@@ -526,7 +537,7 @@ ascattach(parent, self, aux)
void *ascaddr;
int unit;
- ascaddr = (void *)MACH_PHYS_TO_UNCACHED(BUS_CVTADDR(ca));
+ ascaddr = (void*)MACH_PHYS_TO_UNCACHED(ca->ca_addr);
unit = asc->sc_dev.dv_unit;
/*
@@ -539,25 +550,20 @@ ascattach(parent, self, aux)
* (1) how to do dma
* (2) timing based on turbochannel frequency
*/
- switch (pmax_boardtype) {
- case DS_3MIN:
- case DS_MAXINE:
- case DS_3MAXPLUS:
- if (unit == 0) {
+
+ if (asc->sc_dev.dv_parent->dv_cfdata->cf_driver == &ioasic_cd) {
asc->buff = (u_char *)MACH_PHYS_TO_UNCACHED(asc_iomem);
bufsiz = 8192;
- *((volatile int *)ASIC_REG_SCSI_DMAPTR(asic_base)) = -1;
- *((volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base)) = -1;
- *((volatile int *)ASIC_REG_SCSI_SCR(asic_base)) = 0;
+ *((volatile int *)IOASIC_REG_SCSI_DMAPTR(ioasic_base)) = -1;
+ *((volatile int *)IOASIC_REG_SCSI_DMANPTR(ioasic_base)) = -1;
+ *((volatile int *)IOASIC_REG_SCSI_SCR(ioasic_base)) = 0;
asc->dma_start = asic_dma_start;
asc->dma_end = asic_dma_end;
- break;
- }
+ } else
+ {
/*
* Fall through for turbochannel option.
*/
- case DS_3MAX:
- default:
asc->dmar = (volatile int *)(ascaddr + ASC_OFFSET_DMAR);
asc->buff = (u_char *)(ascaddr + ASC_OFFSET_RAM);
bufsiz = PER_TGT_DMA_SIZE;
@@ -639,6 +645,7 @@ ascattach(parent, self, aux)
/* tie pseudo-slot to device */
BUS_INTR_ESTABLISH(ca, asc_intr, asc);
+
printf(": target %d\n", id);
@@ -690,7 +697,7 @@ asc_start(scsicmd)
register ScsiCmd *scsicmd; /* command to start */
{
register struct pmax_scsi_device *sdp = scsicmd->sd;
- register asc_softc_t asc = asccd.cd_devs[sdp->sd_ctlr];
+ register asc_softc_t asc = asc_cd.cd_devs[sdp->sd_ctlr];
int s;
s = splbio();
@@ -979,18 +986,18 @@ again:
state = &asc->st[asc->target];
switch (ASC_PHASE(status)) {
- case ASC_PHASE_DATAI:
- case ASC_PHASE_DATAO:
+ case SCSI_PHASE_DATAI:
+ case SCSI_PHASE_DATAO:
ASC_TC_GET(regs, len);
fifo = regs->asc_flags & ASC_FLAGS_FIFO_CNT;
printf("asc_intr: data overrun: buflen %d dmalen %d tc %d fifo %d\n",
state->buflen, state->dmalen, len, fifo);
goto abort;
- case ASC_PHASE_MSG_IN:
+ case SCSI_PHASE_MSG_IN:
break;
- case ASC_PHASE_MSG_OUT:
+ case SCSI_PHASE_MSG_OUT:
/*
* Check for parity error.
* Hardware will automatically set ATN
@@ -1008,7 +1015,7 @@ again:
readback(regs->asc_cmd);
goto done;
- case ASC_PHASE_STATUS:
+ case SCSI_PHASE_STATUS:
/* probably an error in the SCSI command */
asc->script = &asc_scripts[SCRIPT_GET_STATUS];
regs->asc_cmd = ASC_CMD_I_COMPLETE;
@@ -1176,7 +1183,7 @@ again:
/*
* Disconnects can happen normally when the
* command is complete with the phase being
- * either ASC_PHASE_DATAO or ASC_PHASE_MSG_IN.
+ * either SCSI_PHASE_DATAO or SCSI_PHASE_MSG_IN.
* The SCRIPT_MATCH() only checks for one phase
* so we can wind up here.
* Perform the appropriate operation, then proceed.
@@ -1955,7 +1962,7 @@ asc_msg_in(asc, status, ss, ir)
status = asc_wait(regs, ASC_CSR_INT);
ir = regs->asc_intr;
/* some just break out here, some dont */
- if (ASC_PHASE(status) == ASC_PHASE_MSG_OUT) {
+ if (ASC_PHASE(status) == SCSI_PHASE_MSG_OUT) {
regs->asc_fifo = SCSI_ABORT;
regs->asc_cmd = ASC_CMD_XFER_INFO;
readback(regs->asc_cmd);
@@ -2079,12 +2086,12 @@ asic_dma_start(asc, state, cp, flag)
int flag;
{
register volatile u_int *ssr = (volatile u_int *)
- ASIC_REG_CSR(asic_base);
+ IOASIC_REG_CSR(ioasic_base);
u_int phys, nphys;
/* stop DMA engine first */
- *ssr &= ~ASIC_CSR_DMAEN_SCSI;
- *((volatile int *)ASIC_REG_SCSI_SCR(asic_base)) = 0;
+ *ssr &= ~IOASIC_CSR_DMAEN_SCSI;
+ *((volatile int *)IOASIC_REG_SCSI_SCR(ioasic_base)) = 0;
phys = MACH_CACHED_TO_PHYS(cp);
cp = (caddr_t)pmax_trunc_page(cp + NBPG);
@@ -2093,14 +2100,14 @@ asic_dma_start(asc, state, cp, flag)
asc->dma_next = cp;
asc->dma_xfer = state->dmalen - (nphys - phys);
- *(volatile int *)ASIC_REG_SCSI_DMAPTR(asic_base) =
- ASIC_DMA_ADDR(phys);
- *(volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base) =
- ASIC_DMA_ADDR(nphys);
+ *(volatile int *)IOASIC_REG_SCSI_DMAPTR(ioasic_base) =
+ IOASIC_DMA_ADDR(phys);
+ *(volatile int *)IOASIC_REG_SCSI_DMANPTR(ioasic_base) =
+ IOASIC_DMA_ADDR(nphys);
if (flag == ASCDMA_READ)
- *ssr |= ASIC_CSR_SCSI_DIR | ASIC_CSR_DMAEN_SCSI;
+ *ssr |= IOASIC_CSR_SCSI_DIR | IOASIC_CSR_DMAEN_SCSI;
else
- *ssr = (*ssr & ~ASIC_CSR_SCSI_DIR) | ASIC_CSR_DMAEN_SCSI;
+ *ssr = (*ssr & ~IOASIC_CSR_SCSI_DIR) | IOASIC_CSR_DMAEN_SCSI;
MachEmptyWriteBuffer();
}
@@ -2111,34 +2118,34 @@ asic_dma_end(asc, state, flag)
int flag;
{
register volatile u_int *ssr = (volatile u_int *)
- ASIC_REG_CSR(asic_base);
+ IOASIC_REG_CSR(ioasic_base);
register volatile u_int *dmap = (volatile u_int *)
- ASIC_REG_SCSI_DMAPTR(asic_base);
+ IOASIC_REG_SCSI_DMAPTR(ioasic_base);
register u_short *to;
register int w;
int nb;
- *ssr &= ~ASIC_CSR_DMAEN_SCSI;
+ *ssr &= ~IOASIC_CSR_DMAEN_SCSI;
to = (u_short *)MACH_PHYS_TO_CACHED(*dmap >> 3);
*dmap = -1;
- *((volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base)) = -1;
+ *((volatile int *)IOASIC_REG_SCSI_DMANPTR(ioasic_base)) = -1;
MachEmptyWriteBuffer();
if (flag == ASCDMA_READ) {
MachFlushDCache(MACH_PHYS_TO_CACHED(
MACH_UNCACHED_TO_PHYS(state->dmaBufAddr)), state->dmalen);
- if (nb = *((int *)ASIC_REG_SCSI_SCR(asic_base))) {
+ if (nb = *((int *)IOASIC_REG_SCSI_SCR(ioasic_base))) {
/* pick up last upto6 bytes, sigh. */
/* Last byte really xferred is.. */
- w = *(int *)ASIC_REG_SCSI_SDR0(asic_base);
+ w = *(int *)IOASIC_REG_SCSI_SDR0(ioasic_base);
*to++ = w;
if (--nb > 0) {
w >>= 16;
*to++ = w;
}
if (--nb > 0) {
- w = *(int *)ASIC_REG_SCSI_SDR1(asic_base);
+ w = *(int *)IOASIC_REG_SCSI_SDR1(ioasic_base);
*to++ = w;
}
}
@@ -2152,20 +2159,20 @@ asic_dma_end(asc, state, flag)
void
asc_dma_intr()
{
- asc_softc_t asc = &asccd.cd_devs[0]; /*XXX*/
+ asc_softc_t asc = &asc_cd.cd_devs[0]; /*XXX*/
u_int next_phys;
asc->dma_xfer -= NBPG;
if (asc->dma_xfer <= -NBPG) {
volatile u_int *ssr = (volatile u_int *)
- ASIC_REG_CSR(asic_base);
- *ssr &= ~ASIC_CSR_DMAEN_SCSI;
+ IOASIC_REG_CSR(ioasic_base);
+ *ssr &= ~IOASIC_CSR_DMAEN_SCSI;
} else {
asc->dma_next += NBPG;
next_phys = MACH_CACHED_TO_PHYS(asc->dma_next);
}
- *(volatile int *)ASIC_REG_SCSI_DMANPTR(asic_base) =
- ASIC_DMA_ADDR(next_phys);
+ *(volatile int *)IOASIC_REG_SCSI_DMANPTR(ioasic_base) =
+ IOASIC_DMA_ADDR(next_phys);
MachEmptyWriteBuffer();
}
#endif /*notdef*/
diff --git a/sys/dev/tc/files.tc b/sys/dev/tc/files.tc
index e0e77a12141..053a8463a77 100644
--- a/sys/dev/tc/files.tc
+++ b/sys/dev/tc/files.tc
@@ -1,12 +1,14 @@
-# $OpenBSD: files.tc,v 1.2 1996/04/18 23:48:21 niklas Exp $
-# $NetBSD: files.tc,v 1.2 1996/02/27 22:00:04 cgd Exp $
+# $OpenBSD: files.tc,v 1.3 1996/04/21 22:26:22 deraadt Exp $
+# $NetBSD: files.tc,v 1.3 1996/03/17 00:58:33 thorpej Exp $
#
# Config.new file and device description for machine-independent
# TurboChannel code. Included by ports that need it.
-device tc at tcbus {[slot = -1], [offset = -1]}
+device tc {[slot = -1], [offset = -1]}
+attach tc at tcbus
file dev/tc/tc.c tc needs-flag
# XXX conflicts with ISA if_le.c
-#device le at ioasic, tc: ether, ifnet # XXX PMAX BASEBOARD OPTIONS
+#device le: ether, ifnet # XXX PMAX BASEBOARD OPTIONS
+#attach le at ioasic, tc with le_tc
#file dev/tc/if_le.c le needs-flag # for le_iomem
diff --git a/sys/dev/tc/if_le.c b/sys/dev/tc/if_le.c
index b7909dfabbb..b528f8c831e 100644
--- a/sys/dev/tc/if_le.c
+++ b/sys/dev/tc/if_le.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: if_le.c,v 1.2 1996/04/18 23:48:21 niklas Exp $ */
-/* $NetBSD: if_le.c,v 1.3 1996/02/26 23:38:38 cgd Exp $ */
+/* $OpenBSD: if_le.c,v 1.3 1996/04/21 22:26:24 deraadt Exp $ */
+/* $NetBSD: if_le.c,v 1.6 1996/04/08 20:09:56 jonathan Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@@ -40,6 +40,11 @@
* @(#)if_le.c 8.2 (Berkeley) 11/16/93
*/
+
+/*
+ * Supported busses: DEC IOCTL asic baseboard device, TurboChannel option,
+ * plus baseboard device on "busless" DECstations.
+ */
#ifdef alpha
#define CAN_HAVE_IOASIC 1
#define CAN_HAVE_TC 1
@@ -48,9 +53,14 @@
#define CAN_HAVE_IOASIC 1
#define CAN_HAVE_TC 1
#define CAN_HAVE_MAINBUS 1
-#endif
+#endif /* pmax */
+
+
+/*
+ * For each bus on which a LANCE device might appear, determine
+ * if that bus was configured into the current kernel.
+ */
-#include "bpfilter.h"
#ifdef CAN_HAVE_MAINBUS
/*XXX TEST FOR KN01 OR MIPSFAIR? */
#endif
@@ -61,6 +71,8 @@
#include "ioasic.h"
#endif
+#include "bpfilter.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
@@ -85,7 +97,8 @@
#endif
#if CAN_HAVE_MAINBUS
#include <pmax/pmax/kn01.h>
-extern struct cfdriver mainbuscd; /* XXX */
+#include <pmax/pmax/kn01var.h>
+extern struct cfdriver mainbus_cd; /* XXX */
#endif
#include <dev/tc/if_levar.h>
@@ -96,7 +109,7 @@ extern struct cfdriver mainbuscd; /* XXX */
#include <dev/ic/am7990var.h>
/* access LANCE registers */
-void lewritereg();
+void lewritereg __P((volatile u_short *regptr, u_short val));
#define LERDWR(cntl, src, dst) { (dst) = (src); tc_mb(); }
#define LEWREG(src, dst) lewritereg(&(dst), (src))
@@ -106,15 +119,19 @@ void lewritereg();
extern caddr_t le_iomem;
-#define LE_SOFTC(unit) lecd.cd_devs[unit]
+#define LE_SOFTC(unit) le_cd.cd_devs[unit]
#define LE_DELAY(x) DELAY(x)
-int lematch __P((struct device *, void *, void *));
-void leattach __P((struct device *, struct device *, void *));
+int le_tc_match __P((struct device *, void *, void *));
+void le_tc_attach __P((struct device *, struct device *, void *));
int leintr __P((void *));
-struct cfdriver lecd = {
- NULL, "le", lematch, leattach, DV_IFNET, sizeof (struct le_softc)
+struct cfattach le_tc_ca = {
+ sizeof(struct le_softc), le_tc_match, le_tc_attach
+};
+
+struct cfdriver le_cd = {
+ NULL, "le", DV_IFNET
};
integrate void
@@ -142,33 +159,39 @@ lerdcsr(sc, port)
}
int
-lematch(parent, match, aux)
+le_tc_match(parent, match, aux)
struct device *parent;
void *match, *aux;
{
#if CAN_HAVE_IOASIC && (NIOASIC > 0)
- if (parent->dv_cfdata->cf_driver == &ioasiccd) {
+ if (parent->dv_cfdata->cf_driver == &ioasic_cd) {
struct ioasicdev_attach_args *d = aux;
- if (!ioasic_submatch(match, aux))
+ if (!ioasic_submatch(match, aux)) {
return (0);
- if (strncmp("lance ", d->iada_modname, TC_ROM_LLEN))
+ }
+ if (strncmp("lance", d->iada_modname, TC_ROM_LLEN)) {
return (0);
+ }
} else
#endif /* IOASIC */
+
#if CAN_HAVE_TC && (NTC > 0)
- if (parent->dv_cfdata->cf_driver == &tccd) {
- struct tcdev_attach_args *d = aux;
+ if (parent->dv_cfdata->cf_driver == &tc_cd) {
+ struct tc_attach_args *d = aux;
- if (strncmp("PMAD-AA ", d->tcda_modname, TC_ROM_LLEN) &&
- strncmp("PMAD-BA ", d->tcda_modname, TC_ROM_LLEN))
+ if (strncmp("PMAD-AA ", d->ta_modname, TC_ROM_LLEN) &&
+ strncmp("PMAD-BA ", d->ta_modname, TC_ROM_LLEN))
return (0);
} else
#endif /* TC */
-#if CAN_HAVE_MAINBUS /* XXX TEST FOR KN01 OR MIPSFAIR? */
- if (parent->dv_cfdata->cf_driver == &mainbuscd) {
- /* XXX VARIOUS PMAX BASEBOARD CASES? */
+
+#if CAN_HAVE_MAINBUS && defined(DS3100)
+ if (parent->dv_cfdata->cf_driver == &mainbus_cd) {
+ struct confargs *d = aux;
+ if (strcmp("lance", d->ca_name) != 0)
+ return (0);
} else
#endif /* MAINBUS */
return (0);
@@ -176,19 +199,21 @@ lematch(parent, match, aux)
return (1);
}
+typedef void (*ie_fn_t) __P((struct device *, void *,
+ tc_intrlevel_t, int (*)(void *), void *));
+
void
-leattach(parent, self, aux)
+le_tc_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
register struct le_softc *sc = (void *)self;
- void (*ie_fn) __P((struct device *, void *, tc_intrlevel_t,
- int (*)(void *), void *));
+ ie_fn_t ie_fn;
u_char *cp; /* pointer to MAC address */
int i;
#if CAN_HAVE_IOASIC && (NIOASIC > 0)
- if (parent->dv_cfdata->cf_driver == &ioasiccd) {
+ if (parent->dv_cfdata->cf_driver == &ioasic_cd) {
struct ioasicdev_attach_args *d = aux;
/* It's on the system IOCTL ASIC */
@@ -209,16 +234,16 @@ leattach(parent, self, aux)
} else
#endif /* IOASIC */
#if CAN_HAVE_TC && (NTC > 0)
- if (parent->dv_cfdata->cf_driver == &tccd) {
- struct tcdev_attach_args *d = aux;
+ if (parent->dv_cfdata->cf_driver == &tc_cd) {
+ struct tc_attach_args *d = aux;
/*
* It's on the turbochannel proper, or a kn02
* baseboard implementation of a TC option card.
*/
- sc->sc_r1 = (struct lereg1 *)(d->tcda_addr + LE_OFFSET_LANCE);
- sc->sc_mem = (void *)(d->tcda_addr + LE_OFFSET_RAM);
- cp = (u_char *)(d->tcda_addr + LE_OFFSET_ROM + 2);
+ sc->sc_r1 = (struct lereg1 *)(d->ta_addr + LE_OFFSET_LANCE);
+ sc->sc_mem = (void *)(d->ta_addr + LE_OFFSET_RAM);
+ cp = (u_char *)(d->ta_addr + LE_OFFSET_ROM + 2);
sc->sc_copytodesc = copytobuf_contig;
sc->sc_copyfromdesc = copyfrombuf_contig;
@@ -226,7 +251,7 @@ leattach(parent, self, aux)
sc->sc_copyfrombuf = copyfrombuf_contig;
sc->sc_zerobuf = zerobuf_contig;
- sc->sc_cookie = d->tcda_cookie;
+ sc->sc_cookie = d->ta_cookie;
/*
* TC lance boards have onboard SRAM buffers. DMA
* between the onbard RAM and main memory is not possible,
@@ -235,8 +260,8 @@ leattach(parent, self, aux)
ie_fn = tc_intr_establish;
} else
#endif /* TC */
-#if CAN_HAVE_MAINBUS /* XXX TEST FOR KN01 OR MIPSFAIR? */
- if (parent->dv_cfdata->cf_driver == &mainbuscd) {
+#if CAN_HAVE_MAINBUS && defined(DS3100)
+ if (parent->dv_cfdata->cf_driver == &mainbus_cd) {
struct confargs *ca = aux;
/*
@@ -253,11 +278,11 @@ leattach(parent, self, aux)
sc->sc_zerobuf = zerobuf_gap2;
sc->sc_cookie = (void *)ca->ca_slotpri; /*XXX more thought */
- /* XXX BASEBOARD INTERRUPT ESTABLISH FUNCTION? */
+ ie_fn = (ie_fn_t) kn01_intr_establish;
} else
#endif /* MAINBUS */
- panic("leattach: can't be here");
+ panic("le_tc_attach: can't be here");
sc->sc_conf3 = 0;
sc->sc_addr = 0;
@@ -271,7 +296,7 @@ leattach(parent, self, aux)
cp += 4;
}
- sc->sc_arpcom.ac_if.if_name = lecd.cd_name;
+ sc->sc_arpcom.ac_if.if_name = le_cd.cd_name;
leconfig(sc);
(*ie_fn)(parent, sc->sc_cookie, TC_IPL_NET, leintr, sc);
diff --git a/sys/dev/tc/ioasicvar.h b/sys/dev/tc/ioasicvar.h
index f060c1b3209..ed312acd9df 100644
--- a/sys/dev/tc/ioasicvar.h
+++ b/sys/dev/tc/ioasicvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: ioasicvar.h,v 1.1 1995/12/20 00:50:42 cgd Exp $ */
+/* $NetBSD: ioasicvar.h,v 1.2 1996/03/17 21:37:45 jonathan Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
@@ -48,7 +48,7 @@ struct ioasicdev_attach_args {
* The IOASIC (bus) cfdriver, so that subdevices can more
* easily tell what bus they're on.
*/
-extern struct cfdriver ioasiccd;
+extern struct cfdriver ioasic_cd;
/*
diff --git a/sys/dev/tc/tc.c b/sys/dev/tc/tc.c
index ba5d3b5b8ed..1b861c032be 100644
--- a/sys/dev/tc/tc.c
+++ b/sys/dev/tc/tc.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: tc.c,v 1.2 1996/04/18 23:48:22 niklas Exp $ */
-/* $NetBSD: tc.c,v 1.10 1996/03/05 23:15:07 cgd Exp $ */
+/* $OpenBSD: tc.c,v 1.3 1996/04/21 22:26:28 deraadt Exp $ */
+/* $NetBSD: tc.c,v 1.13 1996/04/09 20:50:06 jonathan Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -29,12 +29,15 @@
*/
#include <sys/param.h>
+#include <sys/systm.h>
#include <sys/device.h>
#include <dev/tc/tcreg.h>
#include <dev/tc/tcvar.h>
#include <dev/tc/tcdevs.h>
+#include <machine/autoconf.h>
+
struct tc_softc {
struct device sc_dv;
@@ -50,8 +53,14 @@ struct tc_softc {
/* Definition of the driver for autoconfig. */
int tcmatch __P((struct device *, void *, void *));
void tcattach __P((struct device *, struct device *, void *));
-struct cfdriver tccd =
- { NULL, "tc", tcmatch, tcattach, DV_DULL, sizeof (struct tc_softc) };
+
+struct cfattach tc_ca = {
+ sizeof(struct tc_softc), tcmatch, tcattach
+};
+
+struct cfdriver tc_cd = {
+ NULL, "tc", DV_DULL
+};
int tcprint __P((void *, char *));
int tcsubmatch __P((struct device *, void *, void *));
@@ -87,7 +96,6 @@ tcattach(parent, self, aux)
const struct tc_builtin *builtin;
struct tc_slotdesc *slot;
tc_addr_t tcaddr;
- void *match;
int i;
printf("%s MHz clock\n",
@@ -214,7 +222,7 @@ tcsubmatch(parent, match, aux)
(cf->tccf_offset != d->ta_offset))
return 0;
- return ((*cf->cf_driver->cd_match)(parent, match, aux));
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
}
diff --git a/sys/dev/tc/tcvar.h b/sys/dev/tc/tcvar.h
index e8473dcb5b5..970d5334635 100644
--- a/sys/dev/tc/tcvar.h
+++ b/sys/dev/tc/tcvar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: tcvar.h,v 1.2 1996/04/18 23:48:24 niklas Exp $ */
-/* $NetBSD: tcvar.h,v 1.3 1996/02/27 01:37:33 cgd Exp $ */
+/* $OpenBSD: tcvar.h,v 1.3 1996/04/21 22:26:30 deraadt Exp $ */
+/* $NetBSD: tcvar.h,v 1.4 1996/03/17 21:37:47 jonathan Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
@@ -128,6 +128,6 @@ void tc_intr_disestablish __P((struct device *, void *));
* The TurboChannel bus cfdriver, so that subdevices can more
* easily tell what bus they're on.
*/
-extern struct cfdriver tccd;
+extern struct cfdriver tc_cd;
#endif /* __DEV_TC_TCVAR_H__ */