diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2000-02-02 18:47:03 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2000-02-02 18:47:03 +0000 |
commit | 81587f1638fe91f5167a0b7477ced521e05f19cd (patch) | |
tree | a67d0b4f56b46cbe3953b9d1bfd966641102a832 /sys | |
parent | 75910aee3cd3e17aa9d32950c8cad5b50b964b62 (diff) |
make the activate routines do xxstop() and xxinit()
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/elink3.c | 3 | ||||
-rw-r--r-- | sys/dev/ic/elink3var.h | 3 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_ep_pcmcia.c | 10 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_ne_pcmcia.c | 10 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_wi.c | 356 |
5 files changed, 35 insertions, 347 deletions
diff --git a/sys/dev/ic/elink3.c b/sys/dev/ic/elink3.c index 953533ae5ac..b9eccaca299 100644 --- a/sys/dev/ic/elink3.c +++ b/sys/dev/ic/elink3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elink3.c,v 1.36 1999/12/08 06:08:04 itojun Exp $ */ +/* $OpenBSD: elink3.c,v 1.37 2000/02/02 18:47:01 deraadt Exp $ */ /* $NetBSD: elink3.c,v 1.32 1997/05/14 00:22:00 thorpej Exp $ */ /* @@ -149,7 +149,6 @@ void ep_vortex_probemedia __P((struct ep_softc *sc)); void ep_isa_probemedia __P((struct ep_softc *sc)); void eptxstat __P((struct ep_softc *)); int epstatus __P((struct ep_softc *)); -void epinit __P((struct ep_softc *)); int epioctl __P((struct ifnet *, u_long, caddr_t)); void epstart __P((struct ifnet *)); void epwatchdog __P((struct ifnet *)); diff --git a/sys/dev/ic/elink3var.h b/sys/dev/ic/elink3var.h index 7aa2e8c54c9..132771d84c1 100644 --- a/sys/dev/ic/elink3var.h +++ b/sys/dev/ic/elink3var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: elink3var.h,v 1.12 1999/07/26 12:31:44 niklas Exp $ */ +/* $OpenBSD: elink3var.h,v 1.13 2000/02/02 18:47:01 deraadt Exp $ */ /* $NetBSD: elink3var.h,v 1.12 1997/03/30 22:47:11 jonathan Exp $ */ /* @@ -94,3 +94,4 @@ u_int16_t epreadeeprom __P((bus_space_tag_t, bus_space_handle_t, int)); void epconfig __P((struct ep_softc *, u_short, u_int8_t *)); int epintr __P((void *)); void epstop __P((struct ep_softc *)); +void epinit __P((struct ep_softc *)); diff --git a/sys/dev/pcmcia/if_ep_pcmcia.c b/sys/dev/pcmcia/if_ep_pcmcia.c index cd32a477deb..7c409a284b6 100644 --- a/sys/dev/pcmcia/if_ep_pcmcia.c +++ b/sys/dev/pcmcia/if_ep_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ep_pcmcia.c,v 1.20 1999/08/16 16:51:19 deraadt Exp $ */ +/* $OpenBSD: if_ep_pcmcia.c,v 1.21 2000/02/02 18:47:01 deraadt Exp $ */ /* $NetBSD: if_ep_pcmcia.c,v 1.16 1998/08/17 23:20:40 thorpej Exp $ */ /*- @@ -401,17 +401,25 @@ ep_pcmcia_activate(dev, act) enum devact act; { struct ep_pcmcia_softc *sc = (struct ep_pcmcia_softc *)dev; + struct ep_softc *esc = &sc->sc_ep; + struct ifnet *ifp = &esc->sc_arpcom.ac_if; int s; s = splnet(); switch (act) { case DVACT_ACTIVATE: pcmcia_function_enable(sc->sc_pf); + printf("%s:", esc->sc_dev.dv_xname); sc->sc_ep.sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_NET, epintr, sc); + printf("\n"); + epinit(esc); break; case DVACT_DEACTIVATE: + ifp->if_timer = 0; + if (ifp->if_flags & IFF_RUNNING) + epstop(esc); pcmcia_function_disable(sc->sc_pf); pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ep.sc_ih); break; diff --git a/sys/dev/pcmcia/if_ne_pcmcia.c b/sys/dev/pcmcia/if_ne_pcmcia.c index 0e61a18e016..796bb2ce3c0 100644 --- a/sys/dev/pcmcia/if_ne_pcmcia.c +++ b/sys/dev/pcmcia/if_ne_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ne_pcmcia.c,v 1.24 2000/02/01 16:59:07 fgsch Exp $ */ +/* $OpenBSD: if_ne_pcmcia.c,v 1.25 2000/02/02 18:47:02 deraadt Exp $ */ /* $NetBSD: if_ne_pcmcia.c,v 1.17 1998/08/15 19:00:04 thorpej Exp $ */ /* @@ -603,17 +603,25 @@ ne_pcmcia_activate(dev, act) enum devact act; { struct ne_pcmcia_softc *sc = (struct ne_pcmcia_softc *)dev; + struct dp8390_softc *esc = &sc->sc_ne2000.sc_dp8390; + struct ifnet *ifp = &esc->sc_arpcom.ac_if; int s; s = splnet(); switch (act) { case DVACT_ACTIVATE: pcmcia_function_enable(sc->sc_pf); + printf("%s:", esc->sc_dev.dv_xname); sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_NET, dp8390_intr, sc); + printf("\n"); + dp8390_init(esc); break; case DVACT_DEACTIVATE: + ifp->if_timer = 0; + if (ifp->if_flags & IFF_RUNNING) + dp8390_stop(esc); pcmcia_function_disable(sc->sc_pf); pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); break; diff --git a/sys/dev/pcmcia/if_wi.c b/sys/dev/pcmcia/if_wi.c index bffaec2c243..a89b6302168 100644 --- a/sys/dev/pcmcia/if_wi.c +++ b/sys/dev/pcmcia/if_wi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi.c,v 1.6 1999/12/16 04:51:30 angelos Exp $ */ +/* $OpenBSD: if_wi.c,v 1.7 2000/02/02 18:47:02 deraadt Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -70,10 +70,6 @@ #define WI_HERMES_STATS_WAR /* Work around stats counter bug. */ #include "bpfilter.h" -#ifdef __FreeBSD__ -#include "card.h" -#include "wi.h" -#endif /* __FreeBSD__ */ #include <sys/param.h> #include <sys/systm.h> @@ -83,15 +79,9 @@ #include <sys/kernel.h> #include <sys/proc.h> #include <sys/socket.h> -#ifndef __FreeBSD__ #include <sys/device.h> -#endif /* !__FreeBSD__ */ #include <net/if.h> -#ifdef __FreeBSD__ -#include <net/if_arp.h> -#include <net/ethernet.h> -#endif /* __FreeBSD__ */ #include <net/if_dl.h> #include <net/if_media.h> #include <net/if_types.h> @@ -108,39 +98,10 @@ #include <net/bpf.h> #endif -#ifdef __FreeBSD__ -#include <machine/clock.h> -#include <machine/md_var.h> -#include <machine/bus_pio.h> -#endif /* __FreeBSD__ */ #include <machine/bus.h> #include <i386/isa/icu.h> -#ifdef __FreeBSD__ - -#include <i386/isa/isa_device.h> -#include <i386/isa/if_wireg.h> -#include <machine/if_wavelan_ieee.h> - -#if NCARD > 0 -#include <sys/select.h> -#include <pccard/cardinfo.h> -#include <pccard/slot.h> -#endif /* NCARD > 0 */ - -static struct wi_softc wi_softc[NWI]; - -#define TIMEOUT(handle,func,arg,time) (handle) = timeout((func), (arg), (time)) -#define UNTIMEOUT(func,arg,handle) untimeout((func), (arg), (handle)) -#define BPF_MTAP(if,mbuf) bpf_mtap((if), (mbuf)) -#define BPFATTACH(if_bpf,if,dlt,sz) bpfattach((if), (dlt), (sz)) -#define STATIC static -#define WI_PRT_FMT "wi%d" -#define WI_PRT_ARG(sc) (sc)->wi_unit - -#else /* !__FreeBSD__ */ - #include <dev/pcmcia/pcmciareg.h> #include <dev/pcmcia/pcmciavar.h> #include <dev/pcmcia/pcmciadevs.h> @@ -155,8 +116,6 @@ static struct wi_softc wi_softc[NWI]; #define WI_PRT_FMT "%s" #define WI_PRT_ARG(sc) (sc)->sc_dev.dv_xname -#endif /* __FreeBSD__ */ - #ifdef WIDEBUG u_int32_t widebug = WIDEBUG; @@ -176,11 +135,7 @@ u_int32_t widebug = WIDEBUG; #if !defined(lint) static const char rcsid[] = -#ifdef __FreeBSD__ - "$Id: if_wi.c,v 1.6 1999/12/16 04:51:30 angelos Exp $"; -#else /* !__FreeBSD__ */ - "$OpenBSD: if_wi.c,v 1.6 1999/12/16 04:51:30 angelos Exp $"; -#endif /* __FreeBSD__ */ + "$OpenBSD: if_wi.c,v 1.7 2000/02/02 18:47:02 deraadt Exp $"; #endif /* lint */ #ifdef foo @@ -193,11 +148,7 @@ STATIC void wi_init __P((void *)); STATIC void wi_start __P((struct ifnet *)); STATIC void wi_stop __P((struct wi_softc *)); STATIC void wi_watchdog __P((struct ifnet *)); -#ifdef __FreeBSD__ -STATIC void wi_shutdown __P((int, void *)); -#else /* !__FreeBSD__ */ STATIC void wi_shutdown __P((void *)); -#endif /* __FreeBSD__ */ STATIC void wi_rxeof __P((struct wi_softc *)); STATIC void wi_txeof __P((struct wi_softc *, int)); STATIC void wi_update_stats __P((struct wi_softc *)); @@ -216,242 +167,11 @@ STATIC void wi_inquire __P((void *)); STATIC void wi_setdef __P((struct wi_softc *, struct wi_req *)); STATIC int wi_mgmt_xmit __P((struct wi_softc *, caddr_t, int)); -#ifdef __FreeBSD__ - -STATIC int wi_probe __P((struct isa_device *)); -STATIC int wi_attach __P((struct isa_device *)); -#ifdef PCCARD_MODULE -static ointhand2_t wi_intr; -#else -void wi_intr __P((int)); -#endif /* PCCARD_MODULE */ - -struct isa_driver widriver = { - wi_probe, - wi_attach, - "wi", - 1 -}; - -#if NCARD > 0 -STATIC int wi_pccard_init __P((struct pccard_devinfo *)); -STATIC void wi_pccard_unload __P((struct pccard_devinfo *)); -STATIC int wi_pccard_intr __P((struct pccard_devinfo *)); - -#ifdef PCCARD_MODULE -PCCARD_MODULE(wi, wi_pccard_init, wi_pccard_unload, - wi_pccard_intr, 0, net_imask); -#else -static struct pccard_device wi_info = { - "wi", - wi_pccard_init, - wi_pccard_unload, - wi_pccard_intr, - 0, /* Attributes - presently unused */ - &net_imask /* Interrupt mask for device */ - /* XXX - Should this also include net_imask? */ -}; - -DATA_SET(pccarddrv_set, wi_info); -#endif - -/* Initialize the PCCARD. */ -STATIC int wi_pccard_init(sc_p) - struct pccard_devinfo *sc_p; -{ - struct wi_softc *sc; - int i; - u_int32_t irq; - - if (sc_p->isahd.id_unit >= NWI) - return(ENODEV); - - sc = &wi_softc[sc_p->isahd.id_unit]; - sc->wi_gone = 0; - sc->wi_unit = sc_p->isahd.id_unit; - sc->wi_bhandle = sc_p->isahd.id_iobase; - sc->wi_btag = I386_BUS_SPACE_IO; - - /* Make sure interrupts are disabled. */ - CSR_WRITE_2(sc, WI_INT_EN, 0); - CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF); - - /* Grr. IRQ is encoded as a bitmask. */ - irq = sc_p->isahd.id_irq; - for (i = 0; i < 32; i++) { - if (irq & 0x1) - break; - irq >>= 1; - } - - /* - * Print a nice probe message to let the operator - * know something interesting is happening. - */ - printf("wi%d: <WaveLAN/IEEE 802.11> at 0x%x-0x%x irq %d on isa\n", - sc_p->isahd.id_unit, sc_p->isahd.id_iobase, - sc_p->isahd.id_iobase + WI_IOSIZ - 1, i); - - if (wi_attach(&sc_p->isahd)) - return(ENXIO); - - return(0); -} - -STATIC void wi_pccard_unload(sc_p) - struct pccard_devinfo *sc_p; -{ - struct wi_softc *sc; - struct ifnet *ifp; - - sc = &wi_softc[sc_p->isahd.id_unit]; - ifp = &sc->arpcom.ac_if; - - if (sc->wi_gone) { - printf("wi%d: already unloaded\n", sc_p->isahd.id_unit); - return; - } - - ifp->if_flags &= ~IFF_RUNNING; - if_down(ifp); - sc->wi_gone = 1; - printf("wi%d: unloaded\n", sc_p->isahd.id_unit); - - return; -} - -STATIC int wi_pccard_intr(sc_p) - struct pccard_devinfo *sc_p; -{ - wi_intr(sc_p->isahd.id_unit); - return(1); -} - -#endif - -STATIC int wi_probe(isa_dev) - struct isa_device *isa_dev; -{ - /* - * The ISA WaveLAN/IEEE card is actually not an ISA card: - * it's a PCMCIA card plugged into a PCMCIA bridge adapter - * that fits into an ISA slot. Consequently, we will always - * be using the pccard support to probe and attach these - * devices, so we can never actually probe one from here. - */ - return(0); -} - -STATIC int wi_attach(isa_dev) - struct isa_device *isa_dev; -{ - struct wi_softc *sc; - struct wi_ltv_macaddr mac; - struct wi_ltv_gen gen; - struct ifnet *ifp; - char ifname[IFNAMSIZ]; - -#ifdef PCCARD_MODULE - isa_dev->id_ointr = wi_intr; -#endif - sc = &wi_softc[isa_dev->id_unit]; - ifp = &sc->arpcom.ac_if; - - /* Reset the NIC. */ - wi_reset(sc); - - /* Read the station address. */ - mac.wi_type = WI_RID_MAC_NODE; - mac.wi_len = 4; - wi_read_record(sc, (struct wi_ltv_gen *)&mac); - bcopy((char *)&mac.wi_mac_addr, - (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN); - - printf("wi%d: Ethernet address: %6D\n", sc->wi_unit, - sc->arpcom.ac_enaddr, ":"); - - ifp->if_softc = sc; - ifp->if_unit = sc->wi_unit; - ifp->if_name = "wi"; - ifp->if_mtu = ETHERMTU; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_ioctl = wi_ioctl; - ifp->if_output = ether_output; - ifp->if_start = wi_start; - ifp->if_watchdog = wi_watchdog; - ifp->if_init = wi_init; - ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; - - bzero(sc->wi_node_name, sizeof(sc->wi_node_name)); - bcopy(WI_DEFAULT_NODENAME, sc->wi_node_name, - sizeof(WI_DEFAULT_NODENAME) - 1); - - bzero(sc->wi_net_name, sizeof(sc->wi_net_name)); - bcopy(WI_DEFAULT_NETNAME, sc->wi_net_name, - sizeof(WI_DEFAULT_NETNAME) - 1); - - bzero(sc->wi_ibss_name, sizeof(sc->wi_ibss_name)); - bcopy(WI_DEFAULT_IBSS, sc->wi_ibss_name, - sizeof(WI_DEFAULT_IBSS) - 1); - - sc->wi_portnum = WI_DEFAULT_PORT; - sc->wi_ptype = WI_PORTTYPE_ADHOC; - sc->wi_ap_density = WI_DEFAULT_AP_DENSITY; - sc->wi_rts_thresh = WI_DEFAULT_RTS_THRESH; - sc->wi_tx_rate = WI_DEFAULT_TX_RATE; - sc->wi_max_data_len = WI_DEFAULT_DATALEN; - sc->wi_create_ibss = WI_DEFAULT_CREATE_IBSS; - sc->wi_pm_enabled = WI_DEFAULT_PM_ENABLED; - sc->wi_max_sleep = WI_DEFAULT_MAX_SLEEP; - - /* - * Read the default channel from the NIC. This may vary - * depending on the country where the NIC was purchased, so - * we can't hard-code a default and expect it to work for - * everyone. - */ - gen.wi_type = WI_RID_OWN_CHNL; - gen.wi_len = 2; - wi_read_record(sc, &gen); - sc->wi_channel = gen.wi_val; - - bzero((char *)&sc->wi_stats, sizeof(sc->wi_stats)); - - wi_init(sc); - wi_stop(sc); - - /* - * If this logical interface has already been attached, - * don't attach it again or chaos will ensue. - */ - sprintf(ifname, "wi%d", sc->wi_unit); - - if (ifunit(ifname) == NULL) { - callout_handle_init(&sc->wi_stat_ch); - /* - * Call MI attach routines. - */ - if_attach(ifp); - ether_ifattach(ifp); - -#if NBPFILTER > 0 - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif - - at_shutdown(wi_shutdown, sc, SHUTDOWN_POST_SYNC); - } - - return(0); -} - -#else /* !__FreeBSD__ */ - -int wi_pcmcia_match __P((struct device *, void *, void *)); -void wi_pcmcia_attach __P((struct device *, struct device *, void *)); -int wi_pcmcia_detach __P((struct device *, int)); -int wi_pcmcia_activate __P((struct device *, enum devact)); -int wi_intr __P((void *)); +int wi_pcmcia_match __P((struct device *, void *, void *)); +void wi_pcmcia_attach __P((struct device *, struct device *, void *)); +int wi_pcmcia_detach __P((struct device *, int)); +int wi_pcmcia_activate __P((struct device *, enum devact)); +int wi_intr __P((void *)); /* Autoconfig definition of driver back-end */ struct cfdriver wi_cd = { @@ -608,14 +328,6 @@ wi_pcmcia_attach(parent, self, aux) wi_init(sc); wi_stop(sc); - -#ifdef notyet - /* - * XXX This should be done once the framework has enable/disable hooks. - */ - pcmcia_function_disable(pf); -#endif /* notyet */ - return; bad: @@ -651,17 +363,24 @@ wi_pcmcia_activate(dev, act) enum devact act; { struct wi_softc *sc = (struct wi_softc *)dev; + struct ifnet *ifp = &sc->arpcom.ac_if; int s; s = splnet(); switch (act) { case DVACT_ACTIVATE: pcmcia_function_enable(sc->sc_pf); + printf("%s:", WI_PRT_ARG(sc)); sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_NET, wi_intr, sc); + printf("\n"); + wi_init(sc); break; case DVACT_DEACTIVATE: + ifp->if_timer = 0; + if (ifp->if_flags & IFF_RUNNING) + wi_stop(sc); pcmcia_function_disable(sc->sc_pf); pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); break; @@ -669,19 +388,11 @@ wi_pcmcia_activate(dev, act) splx(s); return (0); } -#endif /* __FreeBSD__ */ -#ifdef __FreeBSD__ -void wi_intr(unit) - int unit; -{ - struct wi_softc *sc = &wi_softc[unit]; -#else /* !__FreeBSD__ */ int wi_intr(vsc) void *vsc; { struct wi_softc *sc = vsc; -#endif /* __FreeBSD__ */ struct ifnet *ifp; u_int16_t status; @@ -1188,12 +899,8 @@ STATIC void wi_setmulti(sc) struct ifnet *ifp; int i = 0; struct wi_ltv_mcast mcast; -#ifdef __FreeBSD__ - struct ifmultiaddr *ifma; -#else struct ether_multistep step; struct ether_multi *enm; -#endif ifp = &sc->arpcom.ac_if; @@ -1207,21 +914,6 @@ STATIC void wi_setmulti(sc) return; } -#ifdef __FreeBSD__ - for (ifma = ifp->if_multiaddrs.lh_first; ifma != NULL; - ifma = ifma->ifma_link.le_next) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - if (i < 16) { - bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr), - (char *)&mcast.wi_mcast[i], ETHER_ADDR_LEN); - i++; - } else { - bzero((char *)&mcast, sizeof(mcast)); - break; - } - } -#else /* !__FreeBSD__ */ ETHER_FIRST_MULTI(step, &sc->arpcom, enm); while (enm != NULL) { if (i >= 16) { @@ -1238,7 +930,6 @@ STATIC void wi_setmulti(sc) i++; ETHER_NEXT_MULTI(step, enm); } -#endif /* __FreeBSD__ */ mcast.wi_len = (i * 3) + 1; wi_write_record(sc, (struct wi_ltv_gen *)&mcast); @@ -1253,9 +944,7 @@ STATIC void wi_setdef(sc, wreq) struct sockaddr_dl *sdl; struct ifaddr *ifa; struct ifnet *ifp; -#ifndef __FreeBSD__ extern struct ifaddr **ifnet_addrs; -#endif /* !__FreeBSD__ */ ifp = &sc->arpcom.ac_if; @@ -1326,9 +1015,7 @@ STATIC int wi_ioctl(ifp, command, data) struct wi_req wreq; struct ifreq *ifr; struct proc *p = curproc; -#ifndef __FreeBSD__ struct ifaddr *ifa = (struct ifaddr *)data; -#endif /* !__FreeBSD__ */ s = splimp(); @@ -1340,21 +1027,12 @@ STATIC int wi_ioctl(ifp, command, data) DPRINTF (WID_IOCTL, ("wi_ioctl: command %lu data %p", command, data)); -#ifndef __FreeBSD__ if ((error = ether_ioctl(ifp, &sc->arpcom, command, data)) > 0) { splx(s); return error; } -#endif /* !__FreeBSD__ */ switch(command) { -#ifdef __FreeBSD__ - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: - error = ether_ioctl(ifp, command, data); - break; -#else /* !__FreeBSD__ */ case SIOCSIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { @@ -1369,7 +1047,6 @@ STATIC int wi_ioctl(ifp, command, data) break; } break; -#endif /* __FreeBSD__ */ case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { @@ -1709,12 +1386,7 @@ STATIC void wi_watchdog(ifp) return; } -#ifdef __FreeBSD__ -STATIC void wi_shutdown(howto, arg) - int howto; -#else /* !__FreeBSD__ */ STATIC void wi_shutdown(arg) -#endif /* __FreeBSD__ */ void *arg; { struct wi_softc *sc; |