diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2005-11-07 00:29:22 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2005-11-07 00:29:22 +0000 |
commit | 8ed0fb7c6e1868376ab3ec3913342b2a80256df6 (patch) | |
tree | 547014869077df2d37dbc58db31194fbf9830a73 /sys/dev/pci | |
parent | 74b4801bf823186fbd97fc03a6f5de0c8fc926ed (diff) |
first round of lmc(4) cleaning. removes a good portion of the ifdef
crud making this readable.
ok dlg@
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/if_lmc.c | 246 | ||||
-rw-r--r-- | sys/dev/pci/if_lmc_common.c | 80 | ||||
-rw-r--r-- | sys/dev/pci/if_lmc_media.c | 82 | ||||
-rw-r--r-- | sys/dev/pci/if_lmc_obsd.c | 87 | ||||
-rw-r--r-- | sys/dev/pci/if_lmc_types.h | 33 | ||||
-rw-r--r-- | sys/dev/pci/if_lmcioctl.h | 43 | ||||
-rw-r--r-- | sys/dev/pci/if_lmcvar.h | 100 |
7 files changed, 28 insertions, 643 deletions
diff --git a/sys/dev/pci/if_lmc.c b/sys/dev/pci/if_lmc.c index 1105c903fe7..ac693eaefdb 100644 --- a/sys/dev/pci/if_lmc.c +++ b/sys/dev/pci/if_lmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lmc.c,v 1.19 2005/11/05 11:49:01 brad Exp $ */ +/* $OpenBSD: if_lmc.c,v 1.20 2005/11/07 00:29:21 brad Exp $ */ /* $NetBSD: if_lmc.c,v 1.1 1999/03/25 03:32:43 explorer Exp $ */ /*- @@ -79,6 +79,8 @@ * frequency generator. (ST not available for LMC5200) */ +#include "bpfilter.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/mbuf.h> @@ -88,102 +90,30 @@ #include <sys/malloc.h> #include <sys/kernel.h> #include <sys/proc.h> -#if defined(__FreeBSD__) -#include <machine/clock.h> -#elif defined(__bsdi__) || defined(__NetBSD__) || defined(__OpenBSD__) #include <sys/device.h> -#endif -#if defined(__OpenBSD__) #include <dev/pci/pcidevs.h> -#endif - -#if defined(__NetBSD__) -#include <dev/pci/pcidevs.h> -#include "rnd.h" -#if NRND > 0 -#include <sys/rnd.h> -#endif -#endif #include <net/if.h> #include <net/if_types.h> #include <net/if_dl.h> #include <net/netisr.h> -#include "bpfilter.h" #if NBPFILTER > 0 #include <net/bpf.h> #endif -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include <net/if_sppp.h> -#endif - -#if defined(__bsdi__) -#if INET -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/ip.h> -#endif - -#include <net/netisr.h> -#include <net/if.h> -#include <net/netisr.h> -#include <net/if_types.h> -#include <net/if_p2p.h> -#include <net/if_c_hdlc.h> -#endif - -#if defined(__FreeBSD__) -#include <vm/pmap.h> -#include <pci.h> -#if NPCI > 0 -#include <pci/pcivar.h> -#include <pci/dc21040reg.h> -#define INCLUDE_PATH_PREFIX "pci/" -#endif -#endif /* __FreeBSD__ */ - -#if defined(__bsdi__) -#include <i386/pci/ic/dc21040.h> -#include <i386/isa/isa.h> -#include <i386/isa/icu.h> -#include <i386/isa/dma.h> -#include <i386/isa/isavar.h> -#include <i386/pci/pci.h> -#define INCLUDE_PATH_PREFIX "i386/pci/" -#endif /* __bsdi__ */ - -#if defined(__NetBSD__) || defined(__OpenBSD__) #include <machine/bus.h> -#if defined(__alpha__) && defined(__NetBSD__) -#include <machine/intr.h> -#endif + #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> #include <dev/ic/dc21040reg.h> -#define INCLUDE_PATH_PREFIX "dev/pci/" -#endif /* __NetBSD__ */ -/* - * Sigh. Every OS puts these in different places. NetBSD and FreeBSD use - * a C preprocessor that allows this hack, but BSDI does not. Grr. - */ -#if defined(__NetBSD__) || defined(__FreeBSD__) -#include INCLUDE_PATH_PREFIX "if_lmc_types.h" -#include INCLUDE_PATH_PREFIX "if_lmcioctl.h" -#include INCLUDE_PATH_PREFIX "if_lmcvar.h" -#elif defined(__OpenBSD__) #include <dev/pci/if_lmc_types.h> #include <dev/pci/if_lmcioctl.h> #include <dev/pci/if_lmcvar.h> -#else /* BSDI */ -#include "i386/pci/if_lmctypes.h" -#include "i386/pci/if_lmcioctl.h" -#include "i386/pci/if_lmcvar.h" -#endif /* * This module supports @@ -194,16 +124,10 @@ static ifnet_ret_t lmc_ifstart(struct ifnet *ifp); static struct mbuf *lmc_txput(lmc_softc_t * const sc, struct mbuf *m); static void lmc_rx_intr(lmc_softc_t * const sc); -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) static void lmc_watchdog(struct ifnet *ifp); -#endif -#if defined(__bsdi__) -static int lmc_watchdog(int); -#endif static void lmc_ifup(lmc_softc_t * const sc); static void lmc_ifdown(lmc_softc_t * const sc); - /* * Code the read the SROM and MII bit streams (I2C) */ @@ -214,7 +138,6 @@ lmc_delay_300ns(lmc_softc_t * const sc) for (idx = (300 / 33) + 1; idx > 0; idx--) (void)LMC_CSR_READ(sc, csr_busmode); } - #define EMIT \ do { \ @@ -399,22 +322,10 @@ lmc_read_macaddr(lmc_softc_t * const sc) * Check to make certain there is a signal from the modem, and flicker * lights as needed. */ -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) static void lmc_watchdog(struct ifnet *ifp) -#endif -#if defined(__bsdi__) -static int -lmc_watchdog(int unit) -#endif { -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) lmc_softc_t * const sc = LMC_IFP_TO_SOFTC(ifp); -#endif -#if defined(__bsdi__) - lmc_softc_t * const sc = LMC_UNIT_TO_SOFTC(unit); - struct ifnet *ifp = &sc->lmc_if; -#endif int state; u_int32_t ostatus; u_int32_t link_status; @@ -757,12 +668,7 @@ lmc_rx_intr(lmc_softc_t * const sc) if (accept) { ms->m_pkthdr.len = total_len; ms->m_pkthdr.rcvif = ifp; -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) sppp_input(ifp, ms); -#endif -#if defined(__bsdi__) - sc->lmc_p2pcom.p2p_input(&sc->lmc_p2pcom, ms); -#endif } ms = m0; } @@ -916,12 +822,6 @@ lmc_intr_handler(lmc_softc_t * const sc, int *progress_p) while ((csr = LMC_CSR_READ(sc, csr_status)) & sc->lmc_intrmask) { -#if defined(__NetBSD__) -#if NRND > 0 - rnd_add_uint32(&sc->lmc_rndsource, csr); -#endif -#endif - *progress_p = 1; LMC_CSR_WRITE(sc, csr_status, csr); @@ -1294,15 +1194,13 @@ lmc_txput(lmc_softc_t * const sc, struct mbuf *m) /* - * This routine is entered at splnet() (splsoftnet() on NetBSD) + * This routine is entered at splnet() */ static int lmc_ifioctl(struct ifnet * ifp, ioctl_cmd_t cmd, caddr_t data) { lmc_softc_t * const sc = LMC_IFP_TO_SOFTC(ifp); -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) - lmc_spl_t s; -#endif + int s; struct proc *p = curproc; int error = 0; struct ifreq *ifr = (struct ifreq *)data; @@ -1310,9 +1208,7 @@ lmc_ifioctl(struct ifnet * ifp, ioctl_cmd_t cmd, caddr_t data) u_int32_t old_state; lmc_ctl_t ctl; -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) s = LMC_RAISESPL(); -#endif switch (cmd) { case LMCIOCGINFO: @@ -1335,7 +1231,6 @@ lmc_ifioctl(struct ifnet * ifp, ioctl_cmd_t cmd, caddr_t data) goto out; break; -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) case SIOCSIFMTU: /* * Don't allow the MTU to get larger than we can handle @@ -1347,23 +1242,15 @@ lmc_ifioctl(struct ifnet * ifp, ioctl_cmd_t cmd, caddr_t data) ifp->if_mtu = ifr->ifr_mtu; } break; -#endif } -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) /* * call the sppp ioctl layer */ error = sppp_ioctl(ifp, cmd, data); if (error != 0) goto out; -#endif -#if defined(__bsdi__) - error = p2p_ioctl(ifp, cmd, data); -#endif - -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) /* * If we are transitioning from up to down or down to up, call * our init routine. @@ -1375,21 +1262,17 @@ lmc_ifioctl(struct ifnet * ifp, ioctl_cmd_t cmd, caddr_t data) lmc_ifup(sc); else if (!new_state && old_state) lmc_ifdown(sc); -#endif out: -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) LMC_RESTORESPL(s); -#endif return error; } - + /* * These routines gets called at device spl (from sppp_output). */ -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) static ifnet_ret_t lmc_ifstart(struct ifnet * const ifp) { @@ -1431,104 +1314,6 @@ lmc_ifstart_one(struct ifnet * const ifp) LMC_CSR_WRITE(sc, csr_txpoll, 1); } } -#endif - -#if defined(__bsdi__) -static ifnet_ret_t -lmc_ifstart(struct ifnet * const ifp) -{ - lmc_softc_t * const sc = LMC_IFP_TO_SOFTC(ifp); - struct mbuf *m; - struct ifqueue *ifq; - - if ((sc->lmc_flags & LMC_IFUP) == 0) - return; - - for (;;) { - ifq = &sc->lmc_p2pcom.p2p_isnd; - - m = ifq->ifq_head; - if (m == NULL) { - ifq = &sc->lmc_if.if_snd; - m = ifq->ifq_head; - } - if (m == NULL) - break; - IF_DEQUEUE(ifq, m); - - m = lmc_txput(sc, m); - if (m != NULL) { - IF_PREPEND(ifq, m); - break; - } - } - - LMC_CSR_WRITE(sc, csr_txpoll, 1); -} - -static ifnet_ret_t -lmc_ifstart_one(struct ifnet * const ifp) -{ - lmc_softc_t * const sc = LMC_IFP_TO_SOFTC(ifp); - struct mbuf *m; - struct ifqueue *ifq; - - if ((sc->lmc_flags & LMC_IFUP) == 0) - return; - - ifq = &sc->lmc_p2pcom.p2p_isnd; - - m = ifq->ifq_head; - { - if (m == NULL) { - ifq = &sc->lmc_if.if_snd; - m = ifq->ifq_head; - } - if (m == NULL) - return 0; - IF_DEQUEUE(ifq, m); - - m = lmc_txput(sc, m); - } - if (m != NULL) - IF_PREPEND(ifq, m); - - LMC_CSR_WRITE(sc, csr_txpoll, 1); -} -#endif - -#if defined(__bsdi__) -int -lmc_getmdm(struct p2pcom *pp, caddr_t b) -{ - lmc_softc_t *sc = LMC_UNIT_TO_SOFTC(pp->p2p_if.if_unit); - - if (sc->lmc_media->get_link_status(sc)) { - *(int *)b = TIOCM_CAR; - } else { - *(int *)b = 0; - } - - return (0); -} - -int -lmc_mdmctl(struct p2pcom *pp, int flag) -{ - lmc_softc_t *sc = LMC_UNIT_TO_SOFTC(pp->p2p_if.if_unit); - - sc->lmc_media->set_link_status(sc, flag); - - if (flag) - if ((sc->lmc_flags & LMC_IFUP) == 0) - lmc_ifup(sc); - else - if ((sc->lmc_flags & LMC_IFUP) == LMC_IFUP) - lmc_ifdown(sc); - - return (0); -} -#endif /* * Set up the OS interface magic and attach to the operating system @@ -1546,35 +1331,18 @@ lmc_attach(lmc_softc_t * const sc) ifp->if_timer = 1; ifp->if_mtu = LMC_MTU; IFQ_SET_READY(&ifp->if_snd); - -#if defined(__bsdi__) - ifp->if_type = IFT_NONE; - ifp->if_unit = (sc->lmc_dev.dv_unit); -#endif if_attach(ifp); if_alloc_sadl(ifp); -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) sppp_attach((struct ifnet *)&sc->lmc_sppp); sc->lmc_sppp.pp_flags = PP_CISCO | PP_KEEPALIVE; sc->lmc_sppp.pp_framebytes = 3; -#endif -#if defined(__bsdi__) - sc->lmc_p2pcom.p2p_mdmctl = lmc_mdmctl; - sc->lmc_p2pcom.p2p_getmdm = lmc_getmdm; - p2p_attach(&sc->lmc_p2pcom); -#endif #if NBPFILTER > 0 LMC_BPF_ATTACH(sc); #endif -#if defined(__NetBSD__) && NRND > 0 - rnd_attach_source(&sc->lmc_rndsource, sc->lmc_dev.dv_xname, - RND_TYPE_NET, 0); -#endif - /* * turn off those LEDs... */ diff --git a/sys/dev/pci/if_lmc_common.c b/sys/dev/pci/if_lmc_common.c index 3f2ecc72e38..af256dd46a3 100644 --- a/sys/dev/pci/if_lmc_common.c +++ b/sys/dev/pci/if_lmc_common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lmc_common.c,v 1.10 2005/11/05 11:49:01 brad Exp $ */ +/* $OpenBSD: if_lmc_common.c,v 1.11 2005/11/07 00:29:21 brad Exp $ */ /* $NetBSD: if_lmc_common.c,v 1.1 1999/03/25 03:32:43 explorer Exp $ */ /*- @@ -63,6 +63,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "bpfilter.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/mbuf.h> @@ -72,108 +74,34 @@ #include <sys/malloc.h> #include <sys/kernel.h> #include <sys/proc.h> /* only for declaration of wakeup() used by vm.h */ -#if defined(__FreeBSD__) -#include <machine/clock.h> -#elif defined(__bsdi__) || defined(__NetBSD__) || defined(__OpenBSD__) #include <sys/device.h> -#endif - -#if defined(__NetBSD__) -#include <dev/pci/pcidevs.h> -#include "rnd.h" -#if NRND > 0 -#include <sys/rnd.h> -#endif -#endif -#if defined(__OpenBSD__) #include <dev/pci/pcidevs.h> -#endif #include <net/if.h> #include <net/if_types.h> #include <net/if_dl.h> #include <net/netisr.h> -#include "bpfilter.h" #if NBPFILTER > 0 #include <net/bpf.h> #endif -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include <net/if_sppp.h> -#endif -#if defined(__bsdi__) -#if INET -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/ip.h> -#endif - -#include <net/netisr.h> -#include <net/if.h> -#include <net/netisr.h> -#include <net/if_types.h> -#include <net/if_p2p.h> -#include <net/if_c_hdlc.h> -#endif - -#if defined(__FreeBSD__) -#include <vm/pmap.h> -#include <pci.h> -#if NPCI > 0 -#include <pci/pcivar.h> -#include <pci/dc21040reg.h> -#define INCLUDE_PATH_PREFIX "pci/" -#endif -#endif /* __FreeBSD__ */ - -#if defined(__bsdi__) -#include <i386/pci/ic/dc21040.h> -#include <i386/isa/isa.h> -#include <i386/isa/icu.h> -#include <i386/isa/dma.h> -#include <i386/isa/isavar.h> -#include <i386/pci/pci.h> - -#define INCLUDE_PATH_PREFIX "i386/pci/" -#endif /* __bsdi__ */ - -#if defined(__NetBSD__) || defined(__OpenBSD__) #include <machine/bus.h> -#if defined(__alpha__) && defined(__NetBSD__) -#include <machine/intr.h> -#endif + #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> #include <dev/ic/dc21040reg.h> -#define INCLUDE_PATH_PREFIX "dev/pci/" -#endif /* __NetBSD__ */ -#if defined(__OpenBSD__) #define d_length1 u.bd_length1 #define d_length2 u.bd_length2 #define d_flag u.bd_flag -#endif -/* - * Sigh. Every OS puts these in different places. NetBSD and FreeBSD use - * a C preprocessor that allows this hack, but BSDI does not. - */ -#if defined(__NetBSD__) || defined(__FreeBSD__) -#include INCLUDE_PATH_PREFIX "if_lmc_types.h" -#include INCLUDE_PATH_PREFIX "if_lmcioctl.h" -#include INCLUDE_PATH_PREFIX "if_lmcvar.h" -#elif defined(__OpenBSD__) #include <dev/pci/if_lmc_types.h> #include <dev/pci/if_lmcioctl.h> #include <dev/pci/if_lmcvar.h> -#else /* BSDI */ -#include "i386/pci/if_lmc_types.h" -#include "i386/pci/if_lmcioctl.h" -#include "i386/pci/if_lmcvar.h" -#endif void lmc_gpio_mkinput(lmc_softc_t * const sc, u_int32_t bits) diff --git a/sys/dev/pci/if_lmc_media.c b/sys/dev/pci/if_lmc_media.c index 548a2fc344b..6b5f87013c3 100644 --- a/sys/dev/pci/if_lmc_media.c +++ b/sys/dev/pci/if_lmc_media.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_lmc_media.c,v 1.15 2005/11/05 11:49:01 brad Exp $ */ -/* $Id: if_lmc_media.c,v 1.15 2005/11/05 11:49:01 brad Exp $ */ +/* $OpenBSD: if_lmc_media.c,v 1.16 2005/11/07 00:29:21 brad Exp $ */ +/* $Id: if_lmc_media.c,v 1.16 2005/11/07 00:29:21 brad Exp $ */ /*- * Copyright (c) 1997-1999 LAN Media Corporation (LMC) @@ -39,6 +39,8 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "bpfilter.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/mbuf.h> @@ -48,102 +50,30 @@ #include <sys/malloc.h> #include <sys/kernel.h> #include <sys/proc.h> /* only for declaration of wakeup() used by vm.h */ -#if defined(__FreeBSD__) -#include <machine/clock.h> -#elif defined(__bsdi__) || defined(__NetBSD__) || defined(__OpenBSD__) #include <sys/device.h> -#endif - -#if defined(__NetBSD__) -#include <dev/pci/pcidevs.h> -#include "rnd.h" -#if NRND > 0 -#include <sys/rnd.h> -#endif -#endif -#if defined(__OpenBSD__) #include <dev/pci/pcidevs.h> -#endif #include <net/if.h> #include <net/if_types.h> #include <net/if_dl.h> #include <net/netisr.h> -#include "bpfilter.h" #if NBPFILTER > 0 #include <net/bpf.h> #endif -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include <net/if_sppp.h> -#endif - -#if defined(__bsdi__) -#if INET -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/ip.h> -#endif - -#include <net/netisr.h> -#include <net/if.h> -#include <net/netisr.h> -#include <net/if_types.h> -#include <net/if_p2p.h> -#include <net/if_c_hdlc.h> -#endif - -#if defined(__FreeBSD__) -#include <vm/pmap.h> -#include <pci.h> -#if NPCI > 0 -#include <pci/pcivar.h> -#include <pci/dc21040reg.h> -#define INCLUDE_PATH_PREFIX "pci/" -#endif -#endif /* __FreeBSD__ */ - -#if defined(__bsdi__) -#include <i386/pci/ic/dc21040.h> -#include <i386/isa/isa.h> -#include <i386/isa/icu.h> -#include <i386/isa/dma.h> -#include <i386/isa/isavar.h> -#include <i386/pci/pci.h> -#define INCLUDE_PATH_PREFIX "i386/pci/" -#endif /* __bsdi__ */ - -#if defined(__NetBSD__) || defined(__OpenBSD__) #include <machine/bus.h> -#if defined(__alpha__) && defined(__NetBSD__) -#include <machine/intr.h> -#endif + #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> #include <dev/ic/dc21040reg.h> -#define INCLUDE_PATH_PREFIX "dev/pci/" -#endif /* __NetBSD__ */ -/* - * Sigh. Every OS puts these in different places. NetBSD and FreeBSD use - * a C preprocessor that allows this hack, but BSDI does not. - */ -#if defined(__NetBSD__) || defined(__FreeBSD__) -#include INCLUDE_PATH_PREFIX "if_lmc_types.h" -#include INCLUDE_PATH_PREFIX "if_lmcioctl.h" -#include INCLUDE_PATH_PREFIX "if_lmcvar.h" -#elif defined(__OpenBSD__) #include <dev/pci/if_lmc_types.h> #include <dev/pci/if_lmcioctl.h> #include <dev/pci/if_lmcvar.h> -#else /* BSDI */ -#include "i386/pci/if_lmc_types.h" -#include "i386/pci/if_lmcioctl.h" -#include "i386/pci/if_lmcvar.h" -#endif /* * For lack of a better place, put the T1 cable stuff here. @@ -1182,7 +1112,6 @@ lmc_set_protocol(lmc_softc_t * const sc, lmc_ctl_t *ctl) return; } -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) if (ctl->keepalive_onoff != sc->ictl.keepalive_onoff) { switch (ctl->keepalive_onoff) { case LMC_CTL_ON: @@ -1198,5 +1127,4 @@ lmc_set_protocol(lmc_softc_t * const sc, lmc_ctl_t *ctl) sc->lmc_sppp.pp_flags = PP_CISCO; } } -#endif } diff --git a/sys/dev/pci/if_lmc_obsd.c b/sys/dev/pci/if_lmc_obsd.c index ab11e24ede2..6b73e56fa24 100644 --- a/sys/dev/pci/if_lmc_obsd.c +++ b/sys/dev/pci/if_lmc_obsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lmc_obsd.c,v 1.18 2005/11/06 23:27:33 brad Exp $ */ +/* $OpenBSD: if_lmc_obsd.c,v 1.19 2005/11/07 00:29:21 brad Exp $ */ /* $NetBSD: if_lmc_nbsd.c,v 1.1 1999/03/25 03:32:43 explorer Exp $ */ /*- @@ -63,6 +63,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "bpfilter.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/mbuf.h> @@ -72,102 +74,30 @@ #include <sys/malloc.h> #include <sys/kernel.h> #include <sys/proc.h> /* only for declaration of wakeup() used by vm.h */ -#if defined(__FreeBSD__) -#include <machine/clock.h> -#elif defined(__bsdi__) || defined(__NetBSD__) || defined(__OpenBSD__) #include <sys/device.h> -#endif - -#if defined(__NetBSD__) -#include <dev/pci/pcidevs.h> -#include "rnd.h" -#if NRND > 0 -#include <sys/rnd.h> -#endif -#endif -#if defined(__OpenBSD__) #include <dev/pci/pcidevs.h> -#endif #include <net/if.h> #include <net/if_types.h> #include <net/if_dl.h> #include <net/netisr.h> -#include "bpfilter.h" #if NBPFILTER > 0 #include <net/bpf.h> #endif -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include <net/if_sppp.h> -#endif - -#if defined(__bsdi__) -#if INET -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/ip.h> -#endif - -#include <net/netisr.h> -#include <net/if.h> -#include <net/netisr.h> -#include <net/if_types.h> -#include <net/if_p2p.h> -#include <net/if_c_hdlc.h> -#endif - -#if defined(__FreeBSD__) -#include <vm/pmap.h> -#include <pci.h> -#if NPCI > 0 -#include <pci/pcivar.h> -#include <pci/dc21040reg.h> -#define INCLUDE_PATH_PREFIX "pci/" -#endif -#endif /* __FreeBSD__ */ -#if defined(__bsdi__) -#include <i386/pci/ic/dc21040.h> -#include <i386/isa/isa.h> -#include <i386/isa/icu.h> -#include <i386/isa/dma.h> -#include <i386/isa/isavar.h> -#include <i386/pci/pci.h> - -#define INCLUDE_PATH_PREFIX "i386/pci/" -#endif /* __bsdi__ */ - -#if defined(__NetBSD__) || defined(__OpenBSD__) #include <machine/bus.h> -#if defined(__alpha__) && defined(__NetBSD__) -#include <machine/intr.h> -#endif + #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> #include <dev/ic/dc21040reg.h> -#define INCLUDE_PATH_PREFIX "dev/pci/" -#endif /* __NetBSD__ */ -/* - * Sigh. Every OS puts these in different places. NetBSD and FreeBSD use - * a C preprocessor that allows this hack, but BSDI does not. Grr. - */ -#if defined(__NetBSD__) || defined(__FreeBSD__) -#include INCLUDE_PATH_PREFIX "if_lmc_types.h" -#include INCLUDE_PATH_PREFIX "if_lmcioctl.h" -#include INCLUDE_PATH_PREFIX "if_lmcvar.h" -#elif defined(__OpenBSD__) #include <dev/pci/if_lmc_types.h> #include <dev/pci/if_lmcioctl.h> #include <dev/pci/if_lmcvar.h> -#else /* BSDI */ -#include "i386/pci/if_lmctypes.h" -#include "i386/pci/if_lmcioctl.h" -#include "i386/pci/if_lmcvar.h" -#endif /* * This file is INCLUDED (gross, I know, but...) @@ -300,15 +230,11 @@ lmc_pci_attach(struct device * const parent, bus_space_handle_t ioh, memh; int ioh_valid, memh_valid; -#if defined(__NetBSD__) || defined(__OpenBSD__) - ioh_valid = (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0, &iot, &ioh, NULL, NULL, 0) == 0); memh_valid = (pci_mapreg_map(pa, PCI_CBMA, PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0, &memt, &memh, NULL, NULL, 0) == 0); -#endif - if (memh_valid) { sc->lmc_bustag = memt; @@ -363,13 +289,8 @@ lmc_pci_attach(struct device * const parent, } intrstr = pci_intr_string(pa->pa_pc, intrhandle); -#if defined(__OpenBSD__) sc->lmc_ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_NET, intr_rtn, sc, self->dv_xname); -#else - sc->lmc_ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_NET, - intr_rtn, sc); -#endif if (sc->lmc_ih == NULL) { printf("%s: couldn't establish interrupt", diff --git a/sys/dev/pci/if_lmc_types.h b/sys/dev/pci/if_lmc_types.h index 674a5690e9b..3af9ea23d0c 100644 --- a/sys/dev/pci/if_lmc_types.h +++ b/sys/dev/pci/if_lmc_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lmc_types.h,v 1.3 2005/11/05 11:49:01 brad Exp $ */ +/* $OpenBSD: if_lmc_types.h,v 1.4 2005/11/07 00:29:21 brad Exp $ */ /* $NetBSD: if_lmc_types.h,v 1.2 1999/03/25 04:09:33 explorer Exp $ */ /*- @@ -42,20 +42,7 @@ #ifndef LMC_TYPES_H #define LMC_TYPES_H -/* - * NetBSD uses _KERNEL, FreeBSD uses KERNEL. - */ -#if defined(_KERNEL) && (defined(__NetBSD__) || defined(__OpenBSD__)) -#define LMC_IS_KERNEL -#endif -#if defined(KERNEL) && defined(__FreeBSD__) -#define LMC_IS_KERNEL -#endif -#if defined(__KERNEL__) && defined(linux) -#define LMC_IS_KERNEL -#endif - -#if defined(LMC_IS_KERNEL) +#if defined(_KERNEL) /* * LMC has weird endianness issues, so we can't use the tulip_desc_t. @@ -72,29 +59,15 @@ typedef struct { #define LMC_CTL_LEN1(x) ((x)&0x7ff) #define LMC_CTL(f,l1,l2) ((((f)&0x3ff)<<22)|(((l2)&0x7ff)<<11)|((l1)&0x7ff)) -#if defined(__NetBSD__) || defined(__OpenBSD__) typedef bus_addr_t lmc_csrptr_t; -#else -typedef volatile u_int32_t *lmc_csrptr_t; -#endif - -#if defined(__NetBSD__) || defined(__OpenBSD__) -#define lmc_intrfunc_t int -#endif /* __NetBSD__ */ - -#if defined(__FreeBSD__) -#define lmc_intrfunc_t void -#endif /* __FreeBSD__ */ -#if defined(__bsdi__) #define lmc_intrfunc_t int -#endif /* __bsdi__ */ typedef struct lmc___softc lmc_softc_t; typedef struct lmc___media lmc_media_t; typedef struct lmc_ringinfo lmc_ringinfo_t; -#endif /* LMC_IS_KERNEL */ +#endif /* _KERNEL */ typedef struct lmc___ctl lmc_ctl_t; diff --git a/sys/dev/pci/if_lmcioctl.h b/sys/dev/pci/if_lmcioctl.h index 679d5e95d72..597f0168738 100644 --- a/sys/dev/pci/if_lmcioctl.h +++ b/sys/dev/pci/if_lmcioctl.h @@ -1,5 +1,5 @@ -/* $OpenBSD: if_lmcioctl.h,v 1.5 2005/11/05 11:49:01 brad Exp $ */ -/* $Id: if_lmcioctl.h,v 1.5 2005/11/05 11:49:01 brad Exp $ */ +/* $OpenBSD: if_lmcioctl.h,v 1.6 2005/11/07 00:29:21 brad Exp $ */ +/* $Id: if_lmcioctl.h,v 1.6 2005/11/07 00:29:21 brad Exp $ */ /* * Copyright (c) 1997-1999 LAN Media Corporation (LMC) @@ -39,40 +39,12 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#if defined(linux) -#include <linux/types.h> -/* - * IOCTLs that we use for linux. The structures passed in really should - * go into an OS inspecific file, since BSD will use these as well. - * - * Under linux, the 16 reserved-for-device IOCTLs are numbered 0x89f0 - * through 0x89ff. - */ -#define LMCIOCGINFO SIOCDEVPRIVATE+3 /* get current state */ -#define LMCIOCSINFO SIOCDEVPRIVATE+4 /* set state to user values */ -#define LMCIOCSKEEPALIVE SIOCDEVPRIVATE+5 /* Turn keepalives on/off */ -#ifdef LMC_DEBUG_FILE -#define LMCIOCLEARSTATS LMCIOCSINFO + 1 /* Clear debug stats */ -#endif -#ifdef LMC_BAZ -#define LMCIOCGETLMCSTATS LMCIOCSINFO + 3 -#define LMCIOCCLEARLMCSTATS LMCIOCSINFO + 4 -#define LMCIOCDUMPEVENTLOG LMCIOCSINFO + 5 -#define LMCIOCGETXINFO LMCIOCSINFO + 6 -#define LMCIOCREADLEDS LMCIOCSINFO + 7 -#define LMCIOCSETLEDS LMCIOCSINFO + 8 -#define LMCIOCRESET LMCIOCSINFO + 9 -#endif - -#else /* * IOCTLs for the sane world. */ #define LMCIOCGINFO _IOW('i', 240, struct ifreq) #define LMCIOCSINFO _IOWR('i', 241, struct ifreq) -#endif - typedef struct { u_int32_t n; u_int32_t m; @@ -108,7 +80,6 @@ struct lmc___ctl { #define LMC_CARDTYPE_SSI 3 /* probed card is a SSI card */ #define LMC_CARDTYPE_T1 4 /* probed card is a T1 card */ - #define LMC_CTL_CARDTYPE_LMC5200 0 /* HSSI */ #define LMC_CTL_CARDTYPE_LMC5245 1 /* DS3 */ #define LMC_CTL_CARDTYPE_LMC1000 2 /* SSI, V.35 */ @@ -125,7 +96,6 @@ struct lmc___ctl { #define LMC_CTL_CRC_BYTESIZE_2 2 #define LMC_CTL_CRC_BYTESIZE_4 4 - #define LMC_CTL_CABLE_LENGTH_LT_100FT 0 /* DS3 cable < 100 feet */ #define LMC_CTL_CABLE_LENGTH_GT_100FT 1 /* DS3 cable >= 100 feet */ @@ -207,7 +177,6 @@ struct lmc___ctl { #define LMC_FRAMER_REG0_CIS 0x10 /* channel idle */ #define LMC_FRAMER_REG0_LOC 0x08 /* loss of clock */ - /* * And SSI, LMC1000 */ @@ -255,7 +224,6 @@ struct lmc___ctl { #define LMC_MII16_T1_CRC 0x1000 /* CRC select - RW */ #define LMC_MII16_T1_UNUSED2 0xe000 - /* 8370 framer registers */ #define T1FRAMER_ALARM1_STATUS 0x47 @@ -289,10 +257,7 @@ struct lmc___ctl { #define LMC_MII_LedMask 0x0780 #define LMC_MII_LedBitPos 7 -/* - * OpenBSD, NetBSD uses _KERNEL, FreeBSD uses KERNEL. - */ -#if defined(_KERNEL) || defined(KERNEL) || defined(__KERNEL__) +#if defined(_KERNEL) /* * media independent methods to check on media status, link, light LEDs, * etc. @@ -329,4 +294,4 @@ int lmc_read_macaddr(lmc_softc_t * const sc); void lmc_attach(lmc_softc_t * const sc); void lmc_initring(lmc_softc_t * const sc, lmc_ringinfo_t * const ri, lmc_desc_t *descs, int ndescs); -#endif /* LMC_IS_KERNEL */ +#endif /* _KERNEL */ diff --git a/sys/dev/pci/if_lmcvar.h b/sys/dev/pci/if_lmcvar.h index 2b4d064b4f7..5248f169072 100644 --- a/sys/dev/pci/if_lmcvar.h +++ b/sys/dev/pci/if_lmcvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lmcvar.h,v 1.7 2005/11/05 11:49:01 brad Exp $ */ +/* $OpenBSD: if_lmcvar.h,v 1.8 2005/11/07 00:29:21 brad Exp $ */ /* $NetBSD: if_lmcvar.h,v 1.1 1999/03/25 03:32:43 explorer Exp $ */ /*- @@ -137,16 +137,6 @@ typedef enum { #define TULIP_BUSMODE_READMULTIPLE 0x00200000L #endif -#if defined(__NetBSD__) - -#include "rnd.h" -#if NRND > 0 -#include <sys/rnd.h> -#endif - -#endif /* NetBSD */ - -#if defined(__NetBSD__) || defined(__OpenBSD__) #define LMC_CSR_READ(sc, csr) \ bus_space_read_4((sc)->lmc_bustag, (sc)->lmc_bushandle, (sc)->lmc_csrs.csr) #define LMC_CSR_WRITE(sc, csr, val) \ @@ -156,29 +146,10 @@ typedef enum { bus_space_read_1((sc)->lmc_bustag, (sc)->lmc_bushandle, (sc)->lmc_csrs.csr) #define LMC_CSR_WRITEBYTE(sc, csr, val) \ bus_space_write_1((sc)->lmc_bustag, (sc)->lmc_bushandle, (sc)->lmc_csrs.csr, (val)) -#endif /* __NetBSD__ */ - -#if !defined(__NetBSD__) && !defined(__OpenBSD__) -#define LMC_CSR_READ(sc, csr) (inl((sc)->lmc_csrs.csr)) -#define LMC_CSR_WRITE(sc, csr, val) outl((sc)->lmc_csrs.csr, val) - -#define LMC_CSR_READBYTE(sc, csr) (inb((sc)->lmc_csrs.csr)) -#define LMC_CSR_WRITEBYTE(sc, csr, val) outb((sc)->lmc_csrs.csr, val) -#endif /* __NetBSD__ */ #define LMC_PCI_CSRSIZE 8 #define LMC_PCI_CSROFFSET 0 -#if !defined(__NetBSD__) && !defined(__OpenBSD__) -/* - * macros to read and write CSRs. Note that the "0 +" in - * READ_CSR is to prevent the macro from being an lvalue - * and WRITE_CSR shouldn't be assigned from. - */ -#define LMC_CSR_READ(sc, csr) (0 + *(sc)->lmc_csrs.csr) -#define LMC_CSR_WRITE(sc, csr, val) ((void)(*(sc)->lmc_csrs.csr = (val))) -#endif /* __NetBSD__ */ - /* * This structure contains "pointers" for the registers on * the various 21x4x chips. @@ -304,29 +275,15 @@ typedef struct { * */ struct lmc___softc { -#if defined(__bsdi__) - struct device lmc_dev; /* base device */ - struct isadev lmc_id; /* ISA device */ - struct intrhand lmc_ih; /* intrrupt vectoring */ - struct atshutdown lmc_ats; /* shutdown hook */ - struct p2pcom lmc_p2pcom; /* point-to-point common stuff */ - -#define lmc_if lmc_p2pcom.p2p_if /* network-visible interface */ -#endif /* __bsdi__ */ - -#if defined(__NetBSD__) || defined(__OpenBSD__) struct device lmc_dev; /* base device */ void *lmc_ih; /* intrrupt vectoring */ void *lmc_ats; /* shutdown hook */ bus_space_tag_t lmc_bustag; bus_space_handle_t lmc_bushandle; /* CSR region handle */ pci_chipset_tag_t lmc_pc; -#endif -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) struct sppp lmc_sppp; #define lmc_if lmc_sppp.pp_if -#endif u_int8_t lmc_enaddr[6]; /* yes, a small hack... */ lmc_regfile_t lmc_csrs; @@ -367,17 +324,10 @@ struct lmc___softc { bus_dmamap_t lmc_rxmaps[LMC_RXDESCS]; unsigned lmc_rxmaps_free; -#if defined(__NetBSD__) || defined(__OpenBSD__) struct device *lmc_pci_busno; /* needed for multiport boards */ -#else - u_int8_t lmc_pci_busno; /* needed for multiport boards */ -#endif u_int8_t lmc_pci_devno; /* needed for multiport boards */ lmc_desc_t *lmc_rxdescs; lmc_desc_t *lmc_txdescs; -#if defined(__NetBSD__) && NRND > 0 - rndsource_element_t lmc_rndsource; -#endif u_int32_t lmc_crcSize; u_int32_t tx_clockState; @@ -551,48 +501,6 @@ static const char * const lmc_status_bits[] = { LMC_MAX_TXSEG, LMC_DATA_PER_DESC, \ 0, BUS_DMA_NOWAIT, (mapp)) -#if defined(__FreeBSD__) -typedef void ifnet_ret_t; -typedef int ioctl_cmd_t; -static lmc_softc_t *tulips[LMC_MAX_DEVICES]; -#if BSD >= 199506 -#define LMC_IFP_TO_SOFTC(ifp) ((lmc_softc_t *)((ifp)->if_softc)) -#if NBPFILTER > 0 -#define LMC_BPF_MTAP(sc, m) bpf_mtap(&(sc)->lmc_sppp.pp_if, m) -#define LMC_BPF_TAP(sc, p, l) bpf_tap(&(sc)->lmc_sppp.pp_if, p, l) -#define LMC_BPF_ATTACH(sc) bpfattach(&(sc)->lmc_sppp.pp_if, DLT_PPP, PPP_HEADER_LEN) -#endif -#define LMC_VOID_INTRFUNC -#define IFF_NOTRAILERS 0 -#define LMC_EADDR_FMT "%6D" -#define LMC_EADDR_ARGS(addr) addr, ":" -#else -extern int bootverbose; -#define LMC_IFP_TO_SOFTC(ifp) (LMC_UNIT_TO_SOFTC((ifp)->if_unit)) -#include <sys/devconf.h> -#define LMC_DEVCONF -#endif -#define LMC_UNIT_TO_SOFTC(unit) (tulips[unit]) -#define LMC_BURSTSIZE(unit) pci_max_burst_len -#define loudprintf if (bootverbose) printf -#endif - -#if defined(__bsdi__) -typedef int ifnet_ret_t; -typedef u_long ioctl_cmd_t; -extern struct cfdriver lmccd; -#define LMC_UNIT_TO_SOFTC(unit) ((lmc_softc_t *)lmccd.cd_devs[unit]) -#define LMC_IFP_TO_SOFTC(ifp) (LMC_UNIT_TO_SOFTC((ifp)->if_unit)) -#define loudprintf aprint_verbose -#define MCNT(x) (sizeof(x) / sizeof(struct ifmedia_entry)) -#define lmc_unit lmc_dev.dv_unit -#define lmc_name lmc_p2pcom.p2p_if.if_name -#define LMC_BPF_MTAP(sc, m) -#define LMC_BPF_TAP(sc, p, l) -#define LMC_BPF_ATTACH(sc) -#endif /* __bsdi__ */ - -#if defined(__NetBSD__) || defined(__OpenBSD__) typedef void ifnet_ret_t; typedef u_long ioctl_cmd_t; extern struct cfattach lmc_ca; @@ -608,7 +516,6 @@ extern struct cfdriver lmc_cd; #define loudprintf printf #define LMC_PRINTF_FMT "%s" #define LMC_PRINTF_ARGS sc->lmc_xname -#endif /* __NetBSD__ */ #ifndef LMC_PRINTF_FMT #define LMC_PRINTF_FMT "%s%d" @@ -630,13 +537,8 @@ extern struct cfdriver lmc_cd; #endif #if !defined(lmc_bpf) -#if defined(__NetBSD__) || defined(__FreeBSD__) | defined(__OpenBSD__) #define lmc_bpf lmc_sppp.pp_if.if_bpf #endif -#if defined(__bsdi__) -#define lmc_bpf lmc_if.if_bpf -#endif -#endif #ifndef LMC_RAISESPL #define LMC_RAISESPL() splnet() |