diff options
author | 1996-05-02 13:51:45 +0000 | |
---|---|---|
committer | 1996-05-02 13:51:45 +0000 | |
commit | fbc5a27f3f8dff3ccdceac266613f56f99f35fe1 (patch) | |
tree | 4df0285c12feea1f62c3d6f0c5e09b28ee57dd57 /sys/dev/tc | |
parent | more verbose interrupt handling? (diff) | |
download | wireguard-openbsd-fbc5a27f3f8dff3ccdceac266613f56f99f35fe1.tar.xz wireguard-openbsd-fbc5a27f3f8dff3ccdceac266613f56f99f35fe1.zip |
make these work together
Diffstat (limited to 'sys/dev/tc')
-rw-r--r-- | sys/dev/tc/if_le.c | 237 | ||||
-rw-r--r-- | sys/dev/tc/if_le_ioasic.c | 104 | ||||
-rw-r--r-- | sys/dev/tc/if_le_tc.c | 110 | ||||
-rw-r--r-- | sys/dev/tc/if_levar.h | 7 | ||||
-rw-r--r-- | sys/dev/tc/tc.c | 38 |
5 files changed, 267 insertions, 229 deletions
diff --git a/sys/dev/tc/if_le.c b/sys/dev/tc/if_le.c index b528f8c831e..51415a94208 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.3 1996/04/21 22:26:24 deraadt Exp $ */ -/* $NetBSD: if_le.c,v 1.6 1996/04/08 20:09:56 jonathan Exp $ */ +/* $OpenBSD: if_le.c,v 1.4 1996/05/02 13:51:48 deraadt Exp $ */ +/* $NetBSD: if_le.c,v 1.9 1996/04/22 02:54:10 christos Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -40,37 +40,6 @@ * @(#)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 -#endif -#ifdef pmax -#define CAN_HAVE_IOASIC 1 -#define CAN_HAVE_TC 1 -#define CAN_HAVE_MAINBUS 1 -#endif /* pmax */ - - -/* - * For each bus on which a LANCE device might appear, determine - * if that bus was configured into the current kernel. - */ - -#ifdef CAN_HAVE_MAINBUS -/*XXX TEST FOR KN01 OR MIPSFAIR? */ -#endif -#ifdef CAN_HAVE_TC -#include "tc.h" -#endif -#ifdef CAN_HAVE_IOASIC -#include "ioasic.h" -#endif - #include "bpfilter.h" #include <sys/param.h> @@ -87,53 +56,55 @@ #include <netinet/if_ether.h> #endif -#include <machine/autoconf.h> - -#if CAN_HAVE_TC && (NTC > 0) -#include <dev/tc/tcvar.h> -#endif -#if CAN_HAVE_IOASIC && (NIOASIC > 0) -#include <dev/tc/ioasicvar.h> -#endif -#if CAN_HAVE_MAINBUS -#include <pmax/pmax/kn01.h> -#include <pmax/pmax/kn01var.h> -extern struct cfdriver mainbus_cd; /* XXX */ -#endif - #include <dev/tc/if_levar.h> #include <dev/ic/am7990reg.h> #define LE_NEED_BUF_CONTIG #define LE_NEED_BUF_GAP2 #define LE_NEED_BUF_GAP16 #include <dev/ic/am7990var.h> +#include <dev/tc/tcvar.h> /* access LANCE registers */ 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)) -#define LE_OFFSET_RAM 0x0 -#define LE_OFFSET_LANCE 0x100000 -#define LE_OFFSET_ROM 0x1c0000 - -extern caddr_t le_iomem; - #define LE_SOFTC(unit) le_cd.cd_devs[unit] #define LE_DELAY(x) DELAY(x) -int le_tc_match __P((struct device *, void *, void *)); -void le_tc_attach __P((struct device *, struct device *, void *)); -int leintr __P((void *)); - -struct cfattach le_tc_ca = { - sizeof(struct le_softc), le_tc_match, le_tc_attach -}; - struct cfdriver le_cd = { NULL, "le", DV_IFNET }; +void +dec_le_common_attach(sc, eap) + struct le_softc *sc; + u_char *eap; +{ + int i; + + sc->sc_conf3 = 0; + sc->sc_addr = 0; + sc->sc_memsize = 65536; + + /* + * Get the ethernet address out of rom + */ + for (i = 0; i < sizeof(sc->sc_arpcom.ac_enaddr); i++) { + sc->sc_arpcom.ac_enaddr[i] = *eap; + eap += 4; + } + + sc->sc_arpcom.ac_if.if_name = le_cd.cd_name; + leconfig(sc); +} + +integrate void +lehwinit(sc) + struct le_softc *sc; +{ +} + integrate void lewrcsr(sc, port, val) struct le_softc *sc; @@ -158,150 +129,6 @@ lerdcsr(sc, port) return (val); } -int -le_tc_match(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - -#if CAN_HAVE_IOASIC && (NIOASIC > 0) - if (parent->dv_cfdata->cf_driver == &ioasic_cd) { - struct ioasicdev_attach_args *d = aux; - - if (!ioasic_submatch(match, aux)) { - return (0); - } - 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 == &tc_cd) { - struct tc_attach_args *d = aux; - - 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 && 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); - - return (1); -} - -typedef void (*ie_fn_t) __P((struct device *, void *, - tc_intrlevel_t, int (*)(void *), void *)); - -void -le_tc_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - register struct le_softc *sc = (void *)self; - 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 == &ioasic_cd) { - struct ioasicdev_attach_args *d = aux; - - /* It's on the system IOCTL ASIC */ - sc->sc_r1 = (struct lereg1 *) - TC_DENSE_TO_SPARSE(TC_PHYS_TO_UNCACHED(d->iada_addr)); - sc->sc_mem = (void *)TC_PHYS_TO_UNCACHED(le_iomem); - cp = ioasic_lance_ether_address(); - - sc->sc_copytodesc = copytobuf_gap2; - sc->sc_copyfromdesc = copyfrombuf_gap2; - sc->sc_copytobuf = copytobuf_gap16; - sc->sc_copyfrombuf = copyfrombuf_gap16; - sc->sc_zerobuf = zerobuf_gap16; - - ioasic_lance_dma_setup(le_iomem); /* XXX more thought */ - ie_fn = ioasic_intr_establish; - sc->sc_cookie = (void*)d->iada_cookie; - } else -#endif /* IOASIC */ -#if CAN_HAVE_TC && (NTC > 0) - 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->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; - sc->sc_copytobuf = copytobuf_contig; - sc->sc_copyfrombuf = copyfrombuf_contig; - sc->sc_zerobuf = zerobuf_contig; - - sc->sc_cookie = d->ta_cookie; - /* - * TC lance boards have onboard SRAM buffers. DMA - * between the onbard RAM and main memory is not possible, - * so DMA setup is not required. - */ - ie_fn = tc_intr_establish; - } else -#endif /* TC */ -#if CAN_HAVE_MAINBUS && defined(DS3100) - if (parent->dv_cfdata->cf_driver == &mainbus_cd) { - struct confargs *ca = aux; - - /* - * It's on the baseboeard, with a dedicated interrupt line. - */ -/*XXX*/ sc->sc_r1 = (struct lereg1 *)(ca->ca_addr); -/*XXX*/ sc->sc_mem = (void *)TC_PHYS_TO_UNCACHED(0x19000000); -/*XXX*/ cp = (u_char *)(TC_PHYS_TO_UNCACHED(KN01_SYS_CLOCK) + 1); - - sc->sc_copytodesc = copytobuf_gap2; - sc->sc_copyfromdesc = copyfrombuf_gap2; - sc->sc_copytobuf = copytobuf_gap2; - sc->sc_copyfrombuf = copyfrombuf_gap2; - sc->sc_zerobuf = zerobuf_gap2; - - sc->sc_cookie = (void *)ca->ca_slotpri; /*XXX more thought */ - ie_fn = (ie_fn_t) kn01_intr_establish; - } else -#endif /* MAINBUS */ - - panic("le_tc_attach: can't be here"); - - sc->sc_conf3 = 0; - sc->sc_addr = 0; - sc->sc_memsize = 65536; - - /* - * Get the ethernet address out of rom - */ - for (i = 0; i < sizeof(sc->sc_arpcom.ac_enaddr); i++) { - sc->sc_arpcom.ac_enaddr[i] = *cp; - cp += 4; - } - - sc->sc_arpcom.ac_if.if_name = le_cd.cd_name; - leconfig(sc); - - (*ie_fn)(parent, sc->sc_cookie, TC_IPL_NET, leintr, sc); -} - /* * Write a lance register port, reading it back to ensure success. This seems * to be necessary during initialization, since the chip appears to be a bit diff --git a/sys/dev/tc/if_le_ioasic.c b/sys/dev/tc/if_le_ioasic.c new file mode 100644 index 00000000000..2a1fea050b6 --- /dev/null +++ b/sys/dev/tc/if_le_ioasic.c @@ -0,0 +1,104 @@ +/* $NetBSD: if_le_ioasic.c,v 1.1 1996/04/18 00:50:13 cgd Exp $ */ + +/* + * Copyright (c) 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * LANCE on DEC IOCTL ASIC. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/mbuf.h> +#include <sys/syslog.h> +#include <sys/socket.h> +#include <sys/device.h> + +#include <net/if.h> + +#ifdef INET +#include <netinet/in.h> +#include <netinet/if_ether.h> +#endif + +#include <dev/tc/if_levar.h> +#include <dev/ic/am7990reg.h> +#define LE_NEED_BUF_GAP2 +#define LE_NEED_BUF_GAP16 +#include <dev/ic/am7990var.h> + +#include <dev/tc/tcvar.h> +#include <dev/tc/ioasicvar.h> + +extern caddr_t le_iomem; + +int le_ioasic_match __P((struct device *, void *, void *)); +void le_ioasic_attach __P((struct device *, struct device *, void *)); + +struct cfattach le_ioasic_ca = { + sizeof(struct le_softc), le_ioasic_match, le_ioasic_attach +}; + +int +le_ioasic_match(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct ioasicdev_attach_args *d = aux; + + if (!ioasic_submatch(match, aux)) + return (0); + if (strncmp("lance", d->iada_modname, TC_ROM_LLEN)) + return (0); + + return (1); +} + +void +le_ioasic_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct ioasicdev_attach_args *d = aux; + register struct le_softc *sc = (void *)self; + + sc->sc_r1 = (struct lereg1 *) + TC_DENSE_TO_SPARSE(TC_PHYS_TO_UNCACHED(d->iada_addr)); + sc->sc_mem = (void *)TC_PHYS_TO_UNCACHED(le_iomem); + + sc->sc_copytodesc = am7990_copytobuf_gap2; + sc->sc_copyfromdesc = am7990_copyfrombuf_gap2; + sc->sc_copytobuf = am7990_copytobuf_gap16; + sc->sc_copyfrombuf = am7990_copyfrombuf_gap16; + sc->sc_zerobuf = am7990_zerobuf_gap16; + + ioasic_lance_dma_setup(le_iomem); /* XXX more thought */ + + dec_le_common_attach(sc, ioasic_lance_ether_address()); + + ioasic_intr_establish(parent, d->iada_cookie, TC_IPL_NET, leintr, sc); +} diff --git a/sys/dev/tc/if_le_tc.c b/sys/dev/tc/if_le_tc.c new file mode 100644 index 00000000000..194a5e394d7 --- /dev/null +++ b/sys/dev/tc/if_le_tc.c @@ -0,0 +1,110 @@ +/* $NetBSD: if_le_tc.c,v 1.1 1996/04/18 00:50:14 cgd Exp $ */ + +/* + * Copyright (c) 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * LANCE on TurboChannel. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/mbuf.h> +#include <sys/syslog.h> +#include <sys/socket.h> +#include <sys/device.h> + +#include <net/if.h> + +#ifdef INET +#include <netinet/in.h> +#include <netinet/if_ether.h> +#endif + +#include <dev/tc/if_levar.h> +#include <dev/ic/am7990reg.h> +#define LE_NEED_BUF_CONTIG +#include <dev/ic/am7990var.h> + +#include <dev/tc/tcvar.h> + +int le_tc_match __P((struct device *, void *, void *)); +void le_tc_attach __P((struct device *, struct device *, void *)); + +struct cfattach le_tc_ca = { + sizeof(struct le_softc), le_tc_match, le_tc_attach +}; + +#define LE_OFFSET_RAM 0x0 +#define LE_OFFSET_LANCE 0x100000 +#define LE_OFFSET_ROM 0x1c0000 + +int +le_tc_match(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct tc_attach_args *d = aux; + + if (strncmp("PMAD-AA ", d->ta_modname, TC_ROM_LLEN) && + strncmp("PMAD-BA ", d->ta_modname, TC_ROM_LLEN)) + return (0); + + return (1); +} + +void +le_tc_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + register struct le_softc *sc = (void *)self; + 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->ta_addr + LE_OFFSET_LANCE); + sc->sc_mem = (void *)(d->ta_addr + LE_OFFSET_RAM); + + sc->sc_copytodesc = am7990_copytobuf_contig; + sc->sc_copyfromdesc = am7990_copyfrombuf_contig; + sc->sc_copytobuf = am7990_copytobuf_contig; + sc->sc_copyfrombuf = am7990_copyfrombuf_contig; + sc->sc_zerobuf = am7990_zerobuf_contig; + + /* + * TC lance boards have onboard SRAM buffers. DMA + * between the onbard RAM and main memory is not possible, + * so DMA setup is not required. + */ + + dec_le_common_attach(sc, (u_char *)(d->ta_addr + LE_OFFSET_ROM + 2)); + + tc_intr_establish(parent, d->ta_cookie, TC_IPL_NET, leintr, sc); +} diff --git a/sys/dev/tc/if_levar.h b/sys/dev/tc/if_levar.h index 731df829faf..5d6f0c44e8f 100644 --- a/sys/dev/tc/if_levar.h +++ b/sys/dev/tc/if_levar.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_levar.h,v 1.1 1995/12/20 00:52:18 cgd Exp $ */ +/* $NetBSD: if_levar.h,v 1.2 1996/04/18 00:50:15 cgd Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -63,8 +63,6 @@ struct le_softc { struct device sc_dev; /* base structure */ struct arpcom sc_arpcom; /* Ethernet common part */ - void *sc_cookie; /* bus interrupt/DMA cookie */ - void (*sc_copytodesc) /* Copy to descriptor */ __P((struct le_softc *, void *, int, int)); void (*sc_copyfromdesc) /* Copy from descriptor */ @@ -100,3 +98,6 @@ struct le_softc { struct lereg1 *sc_r1; /* LANCE registers */ }; + +int leintr __P((void *)); +void dec_le_common_attach __P((struct le_softc *, u_char *)); diff --git a/sys/dev/tc/tc.c b/sys/dev/tc/tc.c index 1b861c032be..490860c94e2 100644 --- a/sys/dev/tc/tc.c +++ b/sys/dev/tc/tc.c @@ -1,22 +1,22 @@ -/* $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 $ */ +/* $OpenBSD: tc.c,v 1.4 1996/05/02 13:51:51 deraadt Exp $ */ +/* $NetBSD: tc.c,v 1.14 1996/04/18 01:12:41 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. * All rights reserved. * * Author: Chris G. Demetriou - * + * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU @@ -36,8 +36,6 @@ #include <dev/tc/tcvar.h> #include <dev/tc/tcdevs.h> -#include <machine/autoconf.h> - struct tc_softc { struct device sc_dv; @@ -79,8 +77,6 @@ tcmatch(parent, cfdata, aux) if (strcmp(tba->tba_busname, cf->cf_driver->cd_name)) return (0); - /* XXX check other indicators */ - return (1); } @@ -139,7 +135,7 @@ tcattach(parent, self, aux) ta.ta_addr = tcaddr; ta.ta_cookie = builtin->tcb_cookie; ta.ta_busspeed = sc->sc_speed; - + /* * Mark the slot as used, so we don't check it later. */ @@ -200,17 +196,17 @@ tcprint(aux, pnp) if (pnp) { tc_devinfo(ta->ta_modname, devinfo); - printf("%s at %s", devinfo, pnp); + printf("%s at %s", devinfo, pnp); } printf(" slot %d offset 0x%lx", ta->ta_slot, (long)ta->ta_offset); return (UNCONF); } -int -tcsubmatch(parent, match, aux) - struct device *parent; - void *match, *aux; +int +tcsubmatch(parent, match, aux) + struct device *parent; + void *match, *aux; { struct cfdata *cf = match; struct tc_attach_args *d = aux; @@ -281,7 +277,7 @@ tc_intr_establish(dev, cookie, level, handler, arg) { struct tc_softc *sc = (struct tc_softc *)dev; - (*sc->sc_intr_establish)(sc->sc_dv.dv_parent, cookie, level, + (*sc->sc_intr_establish)(sc->sc_dv.dv_parent, cookie, level, handler, arg); } @@ -296,12 +292,12 @@ tc_intr_disestablish(dev, cookie) } #ifdef TCVERBOSE -/* +/* * Descriptions of of known devices. - */ + */ struct tc_knowndev { const char *id, *driver, *description; -}; +}; #include <dev/tc/tcdevs_data.h> #endif /* TCVERBOSE */ |