From: niklas Date: Thu, 9 May 1996 22:39:58 +0000 (+0000) Subject: From NetBSD: X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=14588912e5bc7e6387da86334a59b4df68fd3ed2;p=openbsd From NetBSD: Changed struct ifnet to have a pointer to the softc of the underlying device and a printable "external name" (name + unit number), thus eliminating if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_start)() to take a struct ifnet *, rather than a unit number. --- diff --git a/sys/arch/amiga/dev/if_ae.c b/sys/arch/amiga/dev/if_ae.c index 57d9e7f9983..a0ac1f62833 100644 --- a/sys/arch/amiga/dev/if_ae.c +++ b/sys/arch/amiga/dev/if_ae.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_ae.c,v 1.6 1996/05/05 13:36:23 mickey Exp $ */ -/* $NetBSD: if_ae.c,v 1.7 1996/04/21 21:11:40 veego Exp $ */ +/* $OpenBSD: if_ae.c,v 1.7 1996/05/09 22:39:58 niklas Exp $ */ +/* $NetBSD: if_ae.c,v 1.8 1996/05/07 00:46:37 thorpej Exp $ */ /* * Copyright (c) 1995 Bernd Ernesti and Klaus Burkert. All rights reserved. @@ -121,7 +121,7 @@ static u_int16_t revision; int aematch __P((struct device *, void *, void *)); void aeattach __P((struct device *, struct device *, void *)); -void aewatchdog __P((int)); +void aewatchdog __P((struct ifnet *)); void aestop __P((struct ae_softc *)); void aememinit __P((struct ae_softc *)); void aereset __P((struct ae_softc *)); @@ -221,8 +221,8 @@ aeattach(parent, self, aux) splx (s); - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = ae_cd.cd_name; + bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); + ifp->if_softc = sc; ifp->if_ioctl = aeioctl; ifp->if_watchdog = aewatchdog; ifp->if_output = ether_output; @@ -244,10 +244,10 @@ aeattach(parent, self, aux) } void -aewatchdog(unit) - int unit; +aewatchdog(ifp) + struct ifnet *ifp; { - struct ae_softc *sc = ae_cd.cd_devs[unit]; + struct ae_softc *sc = ifp->if_softc; log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); ++sc->sc_arpcom.ac_if.if_oerrors; @@ -432,7 +432,7 @@ void aestart(ifp) struct ifnet *ifp; { - register struct ae_softc *sc = ae_cd.cd_devs[ifp->if_unit]; + register struct ae_softc *sc = ifp->if_softc; register int bix; register struct aetmd *tmd; register struct mbuf *m; @@ -943,7 +943,7 @@ aeioctl(ifp, cmd, data) u_long cmd; caddr_t data; { - struct ae_softc *sc = ae_cd.cd_devs[ifp->if_unit]; + struct ae_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; diff --git a/sys/arch/amiga/dev/if_bah.c b/sys/arch/amiga/dev/if_bah.c index cc6913b2bb3..4c63ea441e6 100644 --- a/sys/arch/amiga/dev/if_bah.c +++ b/sys/arch/amiga/dev/if_bah.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_bah.c,v 1.5 1996/05/02 06:44:03 niklas Exp $ */ -/* $NetBSD: if_bah.c,v 1.17 1996/04/21 21:11:42 veego Exp $ */ +/* $OpenBSD: if_bah.c,v 1.6 1996/05/09 22:39:59 niklas Exp $ */ +/* $NetBSD: if_bah.c,v 1.18 1996/05/07 00:46:39 thorpej Exp $ */ /* * Copyright (c) 1994, 1995 Ignatios Souvatzis @@ -184,7 +184,7 @@ void bah_stop __P((struct bah_softc *)); void bah_start __P((struct ifnet *)); int bahintr __P((void *)); int bah_ioctl __P((struct ifnet *, unsigned long, caddr_t)); -void bah_watchdog __P((int)); +void bah_watchdog __P((struct ifnet *)); void movepout __P((u_char *from, u_char __volatile *to, int len)); void movepin __P((u_char __volatile *from, u_char *to, int len)); void bah_srint __P((void *vsc, void *dummy)); @@ -271,8 +271,8 @@ bah_zbus_attach(parent, self, aux) */ bah_stop(sc); - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = bah_cd.cd_name; + bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); + ifp->if_softc = sc; ifp->if_output = arc_output; ifp->if_start = bah_start; ifp->if_ioctl = bah_ioctl; @@ -359,8 +359,8 @@ bah_reset(sc) linkaddress = sc->sc_base->dipswitches; #if defined(BAH_DEBUG) && (BAH_DEBUG > 2) - printf("bah%ld: reset: card reset, link addr = 0x%02x (%ld)\n", - ifp->if_unit, linkaddress, linkaddress); + printf("%s: reset: card reset, link addr = 0x%02x (%ld)\n", + sc->sc_dev.dv_xname, linkaddress, linkaddress); #endif sc->sc_arccom.ac_anaddr = linkaddress; @@ -539,7 +539,7 @@ bah_start(ifp) u_long copystart, lencopy, perbyte; #endif - sc = bah_cd.cd_devs[ifp->if_unit]; + sc = ifp->if_softc; #if defined(BAH_DEBUG) && (BAH_DEBUG > 3) printf("%s: start(0x%x)\n", sc->sc_dev.dv_xname, ifp); @@ -1150,7 +1150,7 @@ bah_ioctl(ifp, command, data) int s, error; error = 0; - sc = bah_cd.cd_devs[ifp->if_unit]; + sc = ifp->if_softc; ifa = (struct ifaddr *)data; s = splnet(); @@ -1217,14 +1217,10 @@ bah_ioctl(ifp, command, data) */ void -bah_watchdog(unit) -int unit; -{ - struct bah_softc *sc; +bah_watchdog(ifp) struct ifnet *ifp; - - sc = bah_cd.cd_devs[unit]; - ifp = &(sc->sc_arccom.ac_if); +{ + struct bah_softc *sc = ifp->if_softc;; sc->sc_base->command = ARC_TXDIS; return; diff --git a/sys/arch/amiga/dev/if_ed.c b/sys/arch/amiga/dev/if_ed.c index 8ae6d2e6f62..65fcdb55c69 100644 --- a/sys/arch/amiga/dev/if_ed.c +++ b/sys/arch/amiga/dev/if_ed.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_ed.c,v 1.6 1996/05/06 08:10:17 mickey Exp $ */ -/* $NetBSD: if_ed.c,v 1.20 1996/04/21 21:11:44 veego Exp $ */ +/* $OpenBSD: if_ed.c,v 1.7 1996/05/09 22:40:00 niklas Exp $ */ +/* $NetBSD: if_ed.c,v 1.21 1996/05/07 00:46:41 thorpej Exp $ */ /* * Device driver for National Semiconductor DS8390/WD83C690 based ethernet @@ -96,7 +96,7 @@ void ed_zbus_attach __P((struct device *, struct device *, void *)); int edintr __P((void *)); int ed_ioctl __P((struct ifnet *, u_long, caddr_t)); void ed_start __P((struct ifnet *)); -void ed_watchdog __P((int)); +void ed_watchdog __P((struct ifnet *)); void ed_reset __P((struct ed_softc *)); void ed_init __P((struct ed_softc *)); void ed_stop __P((struct ed_softc *)); @@ -256,8 +256,8 @@ ed_zbus_attach(parent, self, aux) ed_stop(sc); /* Initialize ifnet structure. */ - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = ed_cd.cd_name; + bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); + ifp->if_softc = sc; ifp->if_start = ed_start; ifp->if_ioctl = ed_ioctl; ifp->if_watchdog = ed_watchdog; @@ -322,10 +322,10 @@ ed_stop(sc) * an interrupt after a transmit has been started on it. */ void -ed_watchdog(unit) - int unit; +ed_watchdog(ifp) + struct ifnet *ifp; { - struct ed_softc *sc = ed_cd.cd_devs[unit]; + struct ed_softc *sc = ifp->if_softc; log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); ++sc->sc_arpcom.ac_if.if_oerrors; @@ -498,7 +498,7 @@ void ed_start(ifp) struct ifnet *ifp; { - struct ed_softc *sc = ed_cd.cd_devs[ifp->if_unit]; + struct ed_softc *sc = ifp->if_softc; struct mbuf *m0, *m; caddr_t buffer; int len; @@ -858,7 +858,7 @@ ed_ioctl(ifp, command, data) u_long command; caddr_t data; { - struct ed_softc *sc = ed_cd.cd_devs[ifp->if_unit]; + struct ed_softc *sc = ifp->if_softc; register struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; diff --git a/sys/arch/amiga/dev/if_es.c b/sys/arch/amiga/dev/if_es.c index 375b38de25b..798b7f9d607 100644 --- a/sys/arch/amiga/dev/if_es.c +++ b/sys/arch/amiga/dev/if_es.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_es.c,v 1.8 1996/05/06 09:21:45 niklas Exp $ */ -/* $NetBSD: if_es.c,v 1.12 1996/05/01 15:55:28 mhitch Exp $ */ +/* $OpenBSD: if_es.c,v 1.9 1996/05/09 22:40:01 niklas Exp $ */ +/* $NetBSD: if_es.c,v 1.13 1996/05/07 00:46:44 thorpej Exp $ */ /* * Copyright (c) 1995 Michael L. Hitch @@ -110,7 +110,7 @@ void es_dump_smcregs __P((char *, union smcregs *)); int esintr __P((void *)); void esstart __P((struct ifnet *)); -void eswatchdog __P((int)); +void eswatchdog __P((struct ifnet *)); int esioctl __P((struct ifnet *, u_long, caddr_t)); void esrint __P((struct es_softc *)); void estint __P((struct es_softc *)); @@ -178,8 +178,8 @@ esattach(parent, self, aux) sc->sc_arpcom.ac_enaddr[5] = (ser ) & 0xff; /* Initialize ifnet structure. */ - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = es_cd.cd_name; + bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); + ifp->if_softc = sc; ifp->if_output = ether_output; ifp->if_ioctl = esioctl; ifp->if_start = esstart; @@ -751,7 +751,7 @@ void esstart(ifp) struct ifnet *ifp; { - struct es_softc *sc = es_cd.cd_devs[ifp->if_unit]; + struct es_softc *sc = ifp->if_softc; union smcregs *smc = sc->sc_base; struct mbuf *m0, *m; #ifdef USEPKTBUF @@ -960,7 +960,7 @@ esioctl(ifp, command, data) u_long command; caddr_t data; { - struct es_softc *sc = es_cd.cd_devs[ifp->if_unit]; + struct es_softc *sc = ifp->if_softc; register struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; @@ -1062,10 +1062,10 @@ esreset(sc) } void -eswatchdog(unit) - int unit; +eswatchdog(ifp) + struct ifnet *ifp; { - struct es_softc *sc = es_cd.cd_devs[unit]; + struct es_softc *sc = ifp->if_softc; log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); ++sc->sc_arpcom.ac_if.if_oerrors; diff --git a/sys/arch/amiga/dev/if_levar.h b/sys/arch/amiga/dev/if_levar.h index 42268bfe37d..2a2676424ee 100644 --- a/sys/arch/amiga/dev/if_levar.h +++ b/sys/arch/amiga/dev/if_levar.h @@ -1,5 +1,5 @@ -/* $OpenBSD: if_levar.h,v 1.2 1996/05/02 06:44:07 niklas Exp $ */ -/* $NetBSD: if_levar.h,v 1.2 1996/04/21 21:11:48 veego Exp $ */ +/* $OpenBSD: if_levar.h,v 1.3 1996/05/09 22:40:01 niklas Exp $ */ +/* $NetBSD: if_levar.h,v 1.3 1996/05/07 00:46:45 thorpej Exp $ */ /* * Copyright (c) 1982, 1990 The Regents of the University of California. @@ -50,40 +50,7 @@ struct lereg1 { * This structure contains the output queue for the interface, its address, ... */ struct le_softc { - struct device sc_dev; /* base structure */ - struct arpcom sc_arpcom; /* Ethernet common part */ - - void (*sc_copytodesc) /* Copy to descriptor */ - __P((struct le_softc *, void *, int, int)); - void (*sc_copyfromdesc) /* Copy from descriptor */ - __P((struct le_softc *, void *, int, int)); - void (*sc_copytobuf) /* Copy to buffer */ - __P((struct le_softc *, void *, int, int)); - void (*sc_copyfrombuf) /* Copy from buffer */ - __P((struct le_softc *, void *, int, int)); - void (*sc_zerobuf) /* and Zero bytes in buffer */ - __P((struct le_softc *, int, int)); - - u_int16_t sc_conf3; /* CSR3 value */ - - void *sc_mem; /* base address of RAM -- CPU's view */ - u_long sc_addr; /* base address of RAM -- LANCE's view */ - u_long sc_memsize; /* size of RAM */ - - int sc_nrbuf; /* number of receive buffers */ - int sc_ntbuf; /* number of transmit buffers */ - int sc_last_rd; - int sc_first_td, sc_last_td, sc_no_td; - - int sc_initaddr; - int sc_rmdaddr; - int sc_tmdaddr; - int sc_rbufaddr; - int sc_tbufaddr; - -#ifdef LEDEBUG - int sc_debug; -#endif + struct am7990_softc sc_am7990; /* glue to MI code */ struct isr sc_isr; struct lereg1 *sc_r1; /* LANCE registers */ diff --git a/sys/arch/amiga/dev/if_qn.c b/sys/arch/amiga/dev/if_qn.c index 4541be7a4bf..eba8567bc5a 100644 --- a/sys/arch/amiga/dev/if_qn.c +++ b/sys/arch/amiga/dev/if_qn.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_qn.c,v 1.7 1996/05/06 08:10:30 mickey Exp $ */ -/* $NetBSD: if_qn.c,v 1.5 1996/04/21 21:11:50 veego Exp $ */ +/* $OpenBSD: if_qn.c,v 1.8 1996/05/09 22:40:02 niklas Exp $ */ +/* $NetBSD: if_qn.c,v 1.6 1996/05/07 00:46:47 thorpej Exp $ */ /* * Copyright (c) 1995 Mika Kortelainen @@ -156,7 +156,7 @@ void qnattach __P((struct device *, struct device *, void *)); int qnintr __P((void *)); int qnioctl __P((struct ifnet *, u_long, caddr_t)); void qnstart __P((struct ifnet *)); -void qnwatchdog __P((int)); +void qnwatchdog __P((struct ifnet *)); void qnreset __P((struct qn_softc *)); void qninit __P((struct qn_softc *)); void qnstop __P((struct qn_softc *)); @@ -238,8 +238,8 @@ qnattach(parent, self, aux) /* set interface to stopped condition (reset) */ qnstop(sc); - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = qn_cd.cd_name; + bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); + ifp->if_softc = sc; ifp->if_ioctl = qnioctl; ifp->if_watchdog = qnwatchdog; ifp->if_output = ether_output; @@ -318,10 +318,10 @@ qninit(sc) * generate an interrupt after a transmit has been started on it. */ void -qnwatchdog(unit) - int unit; +qnwatchdog(ifp) + struct ifnet *ifp; { - struct qn_softc *sc = qn_cd.cd_devs[unit]; + struct qn_softc *sc = ifp->if_softc; log(LOG_INFO, "qn: device timeout (watchdog)\n"); ++sc->sc_arpcom.ac_if.if_oerrors; @@ -404,7 +404,7 @@ void qnstart(ifp) struct ifnet *ifp; { - struct qn_softc *sc = qn_cd.cd_devs[ifp->if_unit]; + struct qn_softc *sc = ifp->if_softc; struct mbuf *m; u_short len; int timout = 60000; @@ -863,7 +863,7 @@ qnioctl(ifp, command, data) u_long command; caddr_t data; { - struct qn_softc *sc = qn_cd.cd_devs[ifp->if_unit]; + struct qn_softc *sc = ifp->if_softc; register struct ifaddr *ifa = (struct ifaddr *)data; #if 0 struct ifreg *ifr = (struct ifreg *)data; diff --git a/sys/arch/amiga/isa/if_isaed.c b/sys/arch/amiga/isa/if_isaed.c index c4e35ebd5ec..eca4d63d549 100644 --- a/sys/arch/amiga/isa/if_isaed.c +++ b/sys/arch/amiga/isa/if_isaed.c @@ -1,4 +1,9 @@ -/* $OpenBSD: if_isaed.c,v 1.5 1996/05/05 13:36:46 mickey Exp $ */ +/* $OpenBSD: if_isaed.c,v 1.6 1996/05/09 22:41:38 niklas Exp $ */ + +/* + * Derived from sys/dev/isa/if.ed.c: +* $NetBSD: if_ed.c,v 1.98 1996/05/07 01:55:13 thorpej Exp $ + */ /* * Device driver for National Semiconductor DS8390/WD83C690 based ethernet @@ -76,6 +81,7 @@ struct ed_softc { bus_chipset_tag_t sc_bc; /* bus identifier */ bus_io_handle_t sc_ioh; /* io handle */ + bus_io_handle_t sc_delayioh; /* io handle for `delay port' XXX MI? */ bus_mem_handle_t sc_memh; /* bus memory handle */ bus_io_size_t asic_base; /* offset of ASIC I/O port */ @@ -127,7 +133,7 @@ int ed_find_Novell __P((struct ed_softc *, struct cfdata *, int edintr __P((void *)); int edioctl __P((struct ifnet *, u_long, caddr_t)); void edstart __P((struct ifnet *)); -void edwatchdog __P((int)); +void edwatchdog __P((struct ifnet *)); void edreset __P((struct ed_softc *)); void edinit __P((struct ed_softc *)); void edstop __P((struct ed_softc *)); @@ -318,8 +324,6 @@ edprobe(parent, match, aux) void *match, *aux; { struct ed_softc *sc = match; - struct cfdata *cf = sc->sc_dev.dv_cfdata; - struct isa_attach_args *ia = aux; return (ed_find(match, sc->sc_dev.dv_cfdata, aux)); } @@ -395,6 +399,8 @@ ed_find_WD80x3(sc, cf, ia) { bus_chipset_tag_t bc; bus_io_handle_t ioh; + /* XXX Read for 1.25 usec delay. Is this MI? */ + bus_io_handle_t delayioh = ia->ia_delayioh; bus_mem_handle_t memh; u_int memsize; u_char iptr, isa16bit, sum; @@ -404,6 +410,10 @@ ed_find_WD80x3(sc, cf, ia) bc = ia->ia_bc; rv = 0; + /* Set initial values for width/size. */ + memsize = 8192; + isa16bit = 0; + if (bus_io_map(bc, ia->ia_iobase, ED_WD_IO_PORTS, &ioh)) return (0); @@ -453,9 +463,6 @@ ed_find_WD80x3(sc, cf, ia) sc->vendor = ED_VENDOR_WD_SMC; sc->type = bus_io_read_1(bc, ioh, asicbase + ED_WD_CARD_ID); - /* Set initial values for width/size. */ - memsize = 8192; - isa16bit = 0; switch (sc->type) { case ED_TYPE_WD8003S: sc->type_str = "WD8003S"; @@ -480,8 +487,8 @@ ed_find_WD80x3(sc, cf, ia) isa16bit = 1; break; case ED_TYPE_WD8013EP: /* also WD8003EP */ - if (bus_io_read_1(bc, ioh, asicbase + ED_WD_ICR) & - ED_WD_ICR_16BIT) { + if (bus_io_read_1(bc, ioh, asicbase + ED_WD_ICR) + & ED_WD_ICR_16BIT) { isa16bit = 1; memsize = 16384; sc->type_str = "WD8013EP"; @@ -693,7 +700,7 @@ ed_find_WD80x3(sc, cf, ia) (sc->type == ED_TYPE_TOSHIBA1) || (sc->type == ED_TYPE_TOSHIBA4) || #endif - (sc->type == ED_TYPE_WD8013EBT) && !sc->is790) { + ((sc->type == ED_TYPE_WD8013EBT) && !sc->is790)) { sc->wd_laar_proto = ((ia->ia_maddr >> 19) & ED_WD_LAAR_ADDRHI); @@ -732,8 +739,9 @@ ed_find_WD80x3(sc, cf, ia) bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR, sc->wd_msr_proto | ED_WD_MSR_MENB); - (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */ - (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */ + /* XXX 2.5 usec delay. This code works on i386, but is it MI? */ + (void) bus_io_read_1(bc, delayioh, 0); + (void) bus_io_read_1(bc, delayioh, 0); /* Now zero memory and verify that it is clear. */ for (i = 0; i < memsize; ++i) @@ -751,8 +759,12 @@ ed_find_WD80x3(sc, cf, ia) if (isa16bit) bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR, sc->wd_laar_proto); - (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */ - (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */ + /* + * XXX 2.5 usec delay. This code works on i386, + * but is it MI? + */ + (void) bus_io_read_1(bc, delayioh, 0); + (void) bus_io_read_1(bc, delayioh, 0); goto out; } @@ -768,8 +780,9 @@ ed_find_WD80x3(sc, cf, ia) if (isa16bit) bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR, sc->wd_laar_proto); - (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */ - (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */ + /* XXX 2.5 usec delay. This code works on i386, but is it MI? */ + (void) bus_io_read_1(bc, delayioh, 0); + (void) bus_io_read_1(bc, delayioh, 0); ia->ia_iosize = ED_WD_IO_PORTS; rv = 1; @@ -810,13 +823,19 @@ ed_find_3Com(sc, cf, ia) bus_chipset_tag_t bc; bus_io_handle_t ioh; bus_mem_handle_t memh; - int i, rv, mapped_mem = 0; + int i; u_int memsize; - u_char isa16bit, sum, x; + u_char isa16bit, x; int ptr, asicbase, nicbase; + /* + * Hmmm...a 16bit 3Com board has 16k of memory, but only an 8k window + * to it. + */ + memsize = 8192; + + bc = ia->ia_bc; - rv = 0; if (bus_io_map(bc, ia->ia_iobase, ED_WD_IO_PORTS, &ioh)) return (0); @@ -834,28 +853,28 @@ ed_find_3Com(sc, cf, ia) */ x = bus_io_read_1(bc, ioh, asicbase + ED_3COM_BCFR); if (x == 0 || (x & (x - 1)) != 0) - goto out; + goto err; ptr = ffs(x) - 1; if (ia->ia_iobase != IOBASEUNK) { if (ia->ia_iobase != ed_3com_iobase[ptr]) { printf("%s: %s mismatch; kernel configured %x != board configured %x\n", "iobase", sc->sc_dev.dv_xname, ia->ia_iobase, ed_3com_iobase[ptr]); - goto out; + goto err; } } else ia->ia_iobase = ed_3com_iobase[ptr]; /* XXX --thorpej */ x = bus_io_read_1(bc, ioh, asicbase + ED_3COM_PCFR); if (x == 0 || (x & (x - 1)) != 0) - goto out; + goto err; ptr = ffs(x) - 1; if (ia->ia_maddr != MADDRUNK) { if (ia->ia_maddr != ed_3com_maddr[ptr]) { printf("%s: %s mismatch; kernel configured %x != board configured %x\n", "maddr", sc->sc_dev.dv_xname, ia->ia_maddr, ed_3com_maddr[ptr]); - goto out; + goto err; } } else ia->ia_maddr = ed_3com_maddr[ptr]; @@ -871,7 +890,7 @@ ed_find_3Com(sc, cf, ia) printf("%s: irq mismatch; kernel configured %d != board configured %d\n", sc->sc_dev.dv_xname, ia->ia_irq, ed_3com_irq[ptr]); - goto out; + goto err; } } else ia->ia_irq = ed_3com_irq[ptr]; @@ -903,12 +922,6 @@ ed_find_3Com(sc, cf, ia) sc->mem_shared = 1; sc->cr_proto = ED_CR_RD2; - /* - * Hmmm...a 16bit 3Com board has 16k of memory, but only an 8k window - * to it. - */ - memsize = 8192; - /* * Get station address from on-board ROM. * @@ -955,8 +968,7 @@ ed_find_3Com(sc, cf, ia) ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP); if (bus_mem_map(bc, ia->ia_maddr, memsize, 0, &memh)) - goto out; - mapped_mem = 1; + goto err; sc->mem_start = 0; /* offset */ sc->mem_size = memsize; sc->mem_end = sc->mem_start + memsize; @@ -1056,24 +1068,21 @@ ed_find_3Com(sc, cf, ia) ia->ia_msize = memsize; ia->ia_iosize = ED_3COM_IO_PORTS; - rv = 1; - out: /* * XXX Sould always unmap, but we can't yet. * XXX Need to squish "indirect" first. */ - if (rv == 0) { - bus_io_unmap(bc, ioh, ED_3COM_IO_PORTS); - if (mapped_mem) - bus_mem_unmap(bc, memh, memsize); - } else { - /* XXX this is all "indirect" brokenness */ - sc->sc_bc = bc; - sc->sc_ioh = ioh; - sc->sc_memh = memh; - } - return (rv); + sc->sc_bc = bc; + sc->sc_ioh = ioh; + sc->sc_memh = memh; + return 1; + + out: + bus_mem_unmap(bc, memh, memsize); + err: + bus_io_unmap(bc, ioh, ED_3COM_IO_PORTS); + return 0; } /* @@ -1087,15 +1096,13 @@ ed_find_Novell(sc, cf, ia) { bus_chipset_tag_t bc; bus_io_handle_t ioh; - bus_mem_handle_t memh; u_int memsize, n; - u_char romdata[16], isa16bit = 0, tmp; + u_char romdata[16], tmp; static u_char test_pattern[32] = "THIS is A memory TEST pattern"; u_char test_buffer[32]; - int rv, asicbase, nicbase; + int asicbase, nicbase; bc = ia->ia_bc; - rv = 0; if (bus_io_map(bc, ia->ia_iobase, ED_NOVELL_IO_PORTS, &ioh)) return (0); @@ -1251,7 +1258,7 @@ ed_find_Novell(sc, cf, ia) if (mstart == 0) { printf("%s: cannot find start of RAM\n", sc->sc_dev.dv_xname); - goto out; + goto err; } /* Search for the end of RAM. */ @@ -1310,22 +1317,19 @@ ed_find_Novell(sc, cf, ia) NIC_PUT(bc, ioh, nicbase, ED_P0_ISR, 0xff); ia->ia_iosize = ED_NOVELL_IO_PORTS; - rv = 1; - out: /* * XXX Sould always unmap, but we can't yet. * XXX Need to squish "indirect" first. */ - if (rv == 0) - bus_io_unmap(bc, ioh, ED_NOVELL_IO_PORTS); - else { - /* XXX this is all "indirect" brokenness */ - sc->sc_bc = bc; - sc->sc_ioh = ioh; - sc->sc_memh = memh; - } - return (rv); + sc->sc_bc = bc; + sc->sc_ioh = ioh; + /* sc_memh is not used by this driver */ + return 1; + out: + bus_io_unmap(bc, ioh, ED_NOVELL_IO_PORTS); + + return 0; } /* @@ -1352,13 +1356,15 @@ edattach(parent, self, aux) ioh = sc->sc_ioh; /* XXX */ asicbase = sc->asic_base; + /* XXX Read for 1.25 usec delay. Is this MI? */ + sc->sc_delayioh = ia->ia_delayioh; /* Set interface to stopped condition (reset). */ edstop(sc); /* Initialize ifnet structure. */ - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = isaed_cd.cd_name; + bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); + ifp->if_softc = sc; ifp->if_start = edstart; ifp->if_ioctl = edioctl; ifp->if_watchdog = edwatchdog; @@ -1471,10 +1477,10 @@ edstop(sc) * an interrupt after a transmit has been started on it. */ void -edwatchdog(unit) - int unit; +edwatchdog(ifp) + struct ifnet *ifp; { - struct ed_softc *sc = isaed_cd.cd_devs[unit]; + struct ed_softc *sc = ifp->if_softc; log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); ++sc->sc_arpcom.ac_if.if_oerrors; @@ -1494,7 +1500,6 @@ edinit(sc) struct ifnet *ifp = &sc->sc_arpcom.ac_if; int nicbase = sc->nic_base, asicbase = sc->asic_base; int i; - u_char command; u_long mcaf[2]; /* @@ -1689,13 +1694,13 @@ void edstart(ifp) struct ifnet *ifp; { - struct ed_softc *sc = isaed_cd.cd_devs[ifp->if_unit]; + struct ed_softc *sc = ifp->if_softc; bus_chipset_tag_t bc = sc->sc_bc; bus_io_handle_t ioh = sc->sc_ioh; struct mbuf *m0, *m; int buffer; int asicbase = sc->asic_base; - int len, i; + int len; if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) return; @@ -1750,8 +1755,12 @@ outloop: sc->wd_laar_proto | ED_WD_LAAR_M16EN); bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR, sc->wd_msr_proto | ED_WD_MSR_MENB); - (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */ - (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */ + /* + * XXX 2.5 usec delay. This code works on i386, + * but is it MI? + */ + (void) bus_io_read_1(bc, sc->sc_delayioh, 0); + (void) bus_io_read_1(bc, sc->sc_delayioh, 0); break; } @@ -1776,8 +1785,12 @@ outloop: if (sc->isa16bit) bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR, sc->wd_laar_proto); - (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */ - (void) bus_io_read_1(bc, ioh, 0x84); /* XXX */ + /* + * XXX 2.5 usec delay. This code works on i386, + * but is it MI? + */ + (void) bus_io_read_1(bc, sc->sc_delayioh, 0); + (void) bus_io_read_1(bc, sc->sc_delayioh, 0); break; } } else @@ -2074,9 +2087,14 @@ edintr(arg) bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR, sc->wd_msr_proto | ED_WD_MSR_MENB); - /* XXX */ - (void) bus_io_read_1(bc, ioh, 0x84); - (void) bus_io_read_1(bc, ioh, 0x84); + /* + * XXX 2.5 usec delay. This code + * works on i386, but is it MI? + */ + (void) bus_io_read_1(bc, + sc->sc_delayioh, 0); + (void) bus_io_read_1(bc, + sc->sc_delayioh, 0); } ed_rint(sc); @@ -2090,9 +2108,14 @@ edintr(arg) bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR, sc->wd_laar_proto); - /* XXX */ - (void) bus_io_read_1(bc, ioh, 0x84); - (void) bus_io_read_1(bc, ioh, 0x84); + /* + * XXX 2.5 usec delay. This code + * works on i386, but is it MI? + */ + (void) bus_io_read_1(bc, + sc->sc_delayioh, 0); + (void) bus_io_read_1(bc, + sc->sc_delayioh, 0); } } } @@ -2139,7 +2162,7 @@ edioctl(ifp, cmd, data) u_long cmd; caddr_t data; { - struct ed_softc *sc = isaed_cd.cd_devs[ifp->if_unit]; + struct ed_softc *sc = ifp->if_softc; register struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; @@ -2396,7 +2419,6 @@ ed_pio_write_mbufs(sc, m, dst) bus_io_handle_t ioh = sc->sc_ioh; int nicbase = sc->nic_base, asicbase = sc->asic_base; u_short len; - struct mbuf *mp; int maxwait = 100; /* about 120us */ len = m->m_pkthdr.len;