Set ifp->if_init to the right function.

if_init_f_t is passed void * containing the address of ifp->if_softc
not the unit number.

Someone tell me if these things don't work as I don't have the hardware
needed to test them. (thats a first.)

I'll get if_ze and if_zp later.

Pointed out by: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
This commit is contained in:
Matthew N. Dodd 1999-08-20 14:12:14 +00:00
parent e4065e8294
commit e4fd6edfd8
7 changed files with 88 additions and 67 deletions

View File

@ -38,7 +38,7 @@
*/
/*
* $Id: if_ep.c,v 1.82 1999/08/18 06:11:58 mdodd Exp $
* $Id: if_ep.c,v 1.83 1999/08/18 22:14:20 mdodd Exp $
*
* Promiscuous mode added and interrupt logic slightly changed
* to reduce the number of adapter failures. Transceiver select
@ -112,7 +112,7 @@ static struct ep_board * ep_look_for_board_at __P((struct isa_device *is));
static int ep_isa_attach __P((struct isa_device *));
static int epioctl __P((struct ifnet * ifp, u_long, caddr_t));
static void epinit __P((struct ep_softc *));
static void epinit __P((void *));
static ointhand2_t epintr;
static void epread __P((struct ep_softc *));
void epreset __P((int));
@ -636,6 +636,7 @@ ep_attach(sc)
ifp->if_start = epstart;
ifp->if_ioctl = epioctl;
ifp->if_watchdog = epwatchdog;
ifp->if_init = epinit;
if (!attached) {
if_attach(ifp);
@ -664,9 +665,10 @@ ep_attach(sc)
* interrupts. ?!
*/
static void
epinit(sc)
struct ep_softc *sc;
epinit(xsc)
void *xsc;
{
struct ep_softc *sc = xsc;
register struct ifnet *ifp = &sc->arpcom.ac_if;
int s, i, j;

View File

@ -47,7 +47,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: if_ie.c,v 1.62 1999/08/18 06:11:59 mdodd Exp $
* $Id: if_ie.c,v 1.63 1999/08/18 22:14:22 mdodd Exp $
*/
/*
@ -172,7 +172,7 @@ static int ni_probe(struct isa_device * dvp);
static int ee16_probe(struct isa_device * dvp);
static int check_ie_present(int unit, caddr_t where, unsigned size);
static void ieinit(int unit);
static void ieinit(void *);
static void ie_stop(int unit);
static int ieioctl(struct ifnet * ifp, u_long command, caddr_t data);
static void iestart(struct ifnet * ifp);
@ -285,6 +285,7 @@ static struct ie_softc {
void (*ie_chan_attn) (int);
enum ie_hardware hard_type;
int hard_vers;
int unit;
u_short port; /* i/o base address for this interface */
caddr_t iomem; /* memory size */
@ -412,6 +413,7 @@ el_probe(struct isa_device *dvp)
u_char signature[] = "*3COM*";
int unit = dvp->id_unit;
sc->unit = unit;
sc->port = dvp->id_iobase;
sc->iomembot = dvp->id_maddr;
sc->bus_use = 0;
@ -824,6 +826,7 @@ ieattach(struct isa_device *dvp)
ifp->if_output = ether_output;
ifp->if_start = iestart;
ifp->if_ioctl = ieioctl;
ifp->if_init = ieinit;
ifp->if_type = IFT_ETHER;
ifp->if_addrlen = 6;
ifp->if_hdrlen = 14;
@ -2121,9 +2124,10 @@ mc_setup(int unit, v_caddr_t ptr,
* THIS ROUTINE MUST BE CALLED AT splimp() OR HIGHER.
*/
static void
ieinit(int unit)
ieinit(xsc)
void *xsc;
{
struct ie_softc *ie = &ie_softc[unit];
struct ie_softc *ie = xsc;
volatile struct ie_sys_ctl_block *scb = ie->scb;
v_caddr_t ptr;
int i;
@ -2144,9 +2148,9 @@ ieinit(int unit)
scb->ie_command_list = MK_16(MEM, cmd);
if (command_and_wait(unit, IE_CU_START, cmd, IE_STAT_COMPL)
if (command_and_wait(sc->unit, IE_CU_START, cmd, IE_STAT_COMPL)
|| !(cmd->com.ie_cmd_status & IE_STAT_OK)) {
printf("ie%d: configure command failed\n", unit);
printf("ie%d: configure command failed\n", sc->unit);
return;
}
}
@ -2160,13 +2164,13 @@ ieinit(int unit)
cmd->com.ie_cmd_cmd = IE_CMD_IASETUP | IE_CMD_LAST;
cmd->com.ie_cmd_link = 0xffff;
bcopy((volatile char *)ie_softc[unit].arpcom.ac_enaddr,
bcopy((volatile char *)ie_softc[sc->unit].arpcom.ac_enaddr,
(volatile char *)&cmd->ie_address, sizeof cmd->ie_address);
scb->ie_command_list = MK_16(MEM, cmd);
if (command_and_wait(unit, IE_CU_START, cmd, IE_STAT_COMPL)
if (command_and_wait(sc->unit, IE_CU_START, cmd, IE_STAT_COMPL)
|| !(cmd->com.ie_cmd_status & IE_STAT_OK)) {
printf("ie%d: individual address "
"setup command failed\n", unit);
"setup command failed\n", sc->unit);
return;
}
}
@ -2174,12 +2178,12 @@ ieinit(int unit)
/*
* Now run the time-domain reflectometer.
*/
run_tdr(unit, (volatile void *) ptr);
run_tdr(sc->unit, (volatile void *) ptr);
/*
* Acknowledge any interrupts we have generated thus far.
*/
ie_ack(ie->scb, IE_ST_WHENCE, unit, ie->ie_chan_attn);
ie_ack(ie->scb, IE_ST_WHENCE, sc->unit, ie->ie_chan_attn);
/*
* Set up the RFA.
@ -2229,11 +2233,11 @@ ieinit(int unit)
bart_config |= IEE16_BART_MCS16_TEST;
outb(PORT + IEE16_CONFIG, bart_config);
ee16_interrupt_enable(ie);
ee16_chan_attn(unit);
ee16_chan_attn(sc->unit);
}
ie->arpcom.ac_if.if_flags |= IFF_RUNNING; /* tell higher levels
* we're here */
start_receiver(unit);
start_receiver(sc->unit);
return;
}
@ -2272,12 +2276,12 @@ ieioctl(struct ifnet *ifp, u_long command, caddr_t data)
(ifp->if_flags & IFF_RUNNING) == 0) {
ie_softc[ifp->if_unit].promisc =
ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI);
ieinit(ifp->if_unit);
ieinit(ifp->if_softc);
} else if (ie_softc[ifp->if_unit].promisc ^
(ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI))) {
ie_softc[ifp->if_unit].promisc =
ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI);
ieinit(ifp->if_unit);
ieinit(ifp->if_softc);
}
break;

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: if_lnc.c,v 1.63 1999/08/18 06:11:59 mdodd Exp $
* $Id: if_lnc.c,v 1.64 1999/08/18 22:14:23 mdodd Exp $
*/
/*
@ -180,7 +180,7 @@ static int lance_probe __P((struct lnc_softc *sc));
static int pcnet_probe __P((struct lnc_softc *sc));
static int lnc_attach_sc __P((struct lnc_softc *sc, int unit));
static int lnc_attach __P((struct isa_device *isa_dev));
static void lnc_init __P((struct lnc_softc *sc));
static void lnc_init __P((void *));
static ointhand2_t lncintr;
static __inline int mbuf_to_buffer __P((struct mbuf *m, char *buffer));
static __inline struct mbuf *chain_to_cluster __P((struct mbuf *m));
@ -1278,6 +1278,7 @@ lnc_attach_sc(struct lnc_softc *sc, int unit)
sc->arpcom.ac_if.if_start = lnc_start;
sc->arpcom.ac_if.if_ioctl = lnc_ioctl;
sc->arpcom.ac_if.if_watchdog = lnc_watchdog;
sc->arpcom.ac_if.if_init = lnc_init;
sc->arpcom.ac_if.if_type = IFT_ETHER;
sc->arpcom.ac_if.if_addrlen = ETHER_ADDR_LEN;
sc->arpcom.ac_if.if_hdrlen = ETHER_HDR_LEN;
@ -1372,8 +1373,10 @@ lnc_attach_ne2100_pci(int unit, unsigned iobase)
#endif
static void
lnc_init(struct lnc_softc *sc)
lnc_init(xsc)
void *xsc;
{
struct lnc_softc *sc = xsc;
int s, i;
char *lnc_mem;

View File

@ -6,7 +6,7 @@
*
* Questions, comments, bug reports and fixes to kimmel@cs.umass.edu.
*
* $Id: if_el.c,v 1.42 1999/08/18 06:11:58 mdodd Exp $
* $Id: if_el.c,v 1.43 1999/08/18 22:14:20 mdodd Exp $
*/
/* Except of course for the portions of code lifted from other FreeBSD
* drivers (mainly elread, elget and el_ioctl)
@ -62,19 +62,19 @@ static struct el_softc {
/* Prototypes */
static int el_attach(struct isa_device *);
static void el_init(int);
static void el_init(void *);
static int el_ioctl(struct ifnet *,u_long,caddr_t);
static int el_probe(struct isa_device *);
static void el_start(struct ifnet *);
static void el_reset(int);
static void el_reset(void *);
static void el_watchdog(struct ifnet *);
static void el_stop(int);
static void el_stop(void *);
static int el_xmit(struct el_softc *,int);
static ointhand2_t elintr;
static __inline void elread(struct el_softc *,caddr_t,int);
static struct mbuf *elget(caddr_t,int,int,struct ifnet *);
static __inline void el_hardreset(int);
static __inline void el_hardreset(void *);
/* isa_driver structure for autoconf */
struct isa_driver eldriver = {
@ -137,13 +137,13 @@ el_probe(struct isa_device *idev)
/* Do a hardware reset of the 3c501. Do not call until after el_probe()! */
static __inline void
el_hardreset(int unit)
el_hardreset(xsc)
void *xsc;
{
register struct el_softc *sc;
register struct el_softc *sc = xsc;
register int base;
register int j;
sc = &el_softc[unit];
base = sc->el_base;
/* First reset the board */
@ -179,7 +179,7 @@ el_attach(struct isa_device *idev)
/* Now reset the board */
dprintf(("Resetting board...\n"));
el_hardreset(idev->id_unit);
el_hardreset(sc);
/* Initialize ifnet structure */
ifp->if_softc = sc;
@ -190,6 +190,7 @@ el_attach(struct isa_device *idev)
ifp->if_start = el_start;
ifp->if_ioctl = el_ioctl;
ifp->if_watchdog = el_watchdog;
ifp->if_init = el_init;
ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX);
/* Now we can attach the interface */
@ -213,36 +214,38 @@ el_attach(struct isa_device *idev)
/* This routine resets the interface. */
static void
el_reset(int unit)
el_reset(xsc)
void *xsc;
{
struct el_softc *sc = xsc;
int s;
dprintf(("elreset()\n"));
s = splimp();
el_stop(unit);
el_init(unit);
el_stop(sc);
el_init(sc);
splx(s);
}
static void el_stop(int unit)
static void el_stop(xsc)
void *xsc;
{
struct el_softc *sc;
struct el_softc *sc = xsc;
sc = &el_softc[unit];
outb(sc->el_base+EL_AC,0);
}
/* Initialize interface. */
static void
el_init(int unit)
el_init(xse)
void *xsc;
{
struct el_softc *sc;
struct el_softc *sc = xsc;
struct ifnet *ifp;
int s;
u_short base;
/* Set up pointers */
sc = &el_softc[unit];
ifp = &sc->arpcom.ac_if;
base = sc->el_base;
@ -254,7 +257,7 @@ el_init(int unit)
/* First, reset the board. */
dprintf(("Resetting board...\n"));
el_hardreset(unit);
el_hardreset(sc);
/* Configure rx */
dprintf(("Configuring rx...\n"));
@ -496,7 +499,7 @@ elintr(int unit)
/* If there's an overflow, reinit the board. */
if(!(rxstat & EL_RXS_NOFLOW)) {
dprintf(("overflow.\n"));
el_hardreset(unit);
el_hardreset(sc);
/* Put board back into receive mode */
if(sc->arpcom.ac_if.if_flags & IFF_PROMISC)
outb(base+EL_RXC,(EL_RXC_PROMISC|EL_RXC_AGF|EL_RXC_DSHORT|EL_RXC_DDRIB|EL_RXC_DOFLOW));
@ -657,7 +660,7 @@ el_ioctl(ifp, command, data)
*/
if (((ifp->if_flags & IFF_UP) == 0) &&
(ifp->if_flags & IFF_RUNNING)) {
el_stop(ifp->if_unit);
el_stop(ifp->if_softc);
ifp->if_flags &= ~IFF_RUNNING;
} else {
/*
@ -665,7 +668,7 @@ el_ioctl(ifp, command, data)
*/
if ((ifp->if_flags & IFF_UP) &&
((ifp->if_flags & IFF_RUNNING) == 0))
el_init(ifp->if_unit);
el_init(ifp->if_softc);
}
break;
default:
@ -681,5 +684,5 @@ el_watchdog(struct ifnet *ifp)
{
log(LOG_ERR,"el%d: device timeout\n", ifp->if_unit);
ifp->if_oerrors++;
el_reset(ifp->if_unit);
el_reset(ifp->if_softc);
}

View File

@ -38,7 +38,7 @@
*/
/*
* $Id: if_ep.c,v 1.82 1999/08/18 06:11:58 mdodd Exp $
* $Id: if_ep.c,v 1.83 1999/08/18 22:14:20 mdodd Exp $
*
* Promiscuous mode added and interrupt logic slightly changed
* to reduce the number of adapter failures. Transceiver select
@ -112,7 +112,7 @@ static struct ep_board * ep_look_for_board_at __P((struct isa_device *is));
static int ep_isa_attach __P((struct isa_device *));
static int epioctl __P((struct ifnet * ifp, u_long, caddr_t));
static void epinit __P((struct ep_softc *));
static void epinit __P((void *));
static ointhand2_t epintr;
static void epread __P((struct ep_softc *));
void epreset __P((int));
@ -636,6 +636,7 @@ ep_attach(sc)
ifp->if_start = epstart;
ifp->if_ioctl = epioctl;
ifp->if_watchdog = epwatchdog;
ifp->if_init = epinit;
if (!attached) {
if_attach(ifp);
@ -664,9 +665,10 @@ ep_attach(sc)
* interrupts. ?!
*/
static void
epinit(sc)
struct ep_softc *sc;
epinit(xsc)
void *xsc;
{
struct ep_softc *sc = xsc;
register struct ifnet *ifp = &sc->arpcom.ac_if;
int s, i, j;

View File

@ -47,7 +47,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: if_ie.c,v 1.62 1999/08/18 06:11:59 mdodd Exp $
* $Id: if_ie.c,v 1.63 1999/08/18 22:14:22 mdodd Exp $
*/
/*
@ -172,7 +172,7 @@ static int ni_probe(struct isa_device * dvp);
static int ee16_probe(struct isa_device * dvp);
static int check_ie_present(int unit, caddr_t where, unsigned size);
static void ieinit(int unit);
static void ieinit(void *);
static void ie_stop(int unit);
static int ieioctl(struct ifnet * ifp, u_long command, caddr_t data);
static void iestart(struct ifnet * ifp);
@ -285,6 +285,7 @@ static struct ie_softc {
void (*ie_chan_attn) (int);
enum ie_hardware hard_type;
int hard_vers;
int unit;
u_short port; /* i/o base address for this interface */
caddr_t iomem; /* memory size */
@ -412,6 +413,7 @@ el_probe(struct isa_device *dvp)
u_char signature[] = "*3COM*";
int unit = dvp->id_unit;
sc->unit = unit;
sc->port = dvp->id_iobase;
sc->iomembot = dvp->id_maddr;
sc->bus_use = 0;
@ -824,6 +826,7 @@ ieattach(struct isa_device *dvp)
ifp->if_output = ether_output;
ifp->if_start = iestart;
ifp->if_ioctl = ieioctl;
ifp->if_init = ieinit;
ifp->if_type = IFT_ETHER;
ifp->if_addrlen = 6;
ifp->if_hdrlen = 14;
@ -2121,9 +2124,10 @@ mc_setup(int unit, v_caddr_t ptr,
* THIS ROUTINE MUST BE CALLED AT splimp() OR HIGHER.
*/
static void
ieinit(int unit)
ieinit(xsc)
void *xsc;
{
struct ie_softc *ie = &ie_softc[unit];
struct ie_softc *ie = xsc;
volatile struct ie_sys_ctl_block *scb = ie->scb;
v_caddr_t ptr;
int i;
@ -2144,9 +2148,9 @@ ieinit(int unit)
scb->ie_command_list = MK_16(MEM, cmd);
if (command_and_wait(unit, IE_CU_START, cmd, IE_STAT_COMPL)
if (command_and_wait(sc->unit, IE_CU_START, cmd, IE_STAT_COMPL)
|| !(cmd->com.ie_cmd_status & IE_STAT_OK)) {
printf("ie%d: configure command failed\n", unit);
printf("ie%d: configure command failed\n", sc->unit);
return;
}
}
@ -2160,13 +2164,13 @@ ieinit(int unit)
cmd->com.ie_cmd_cmd = IE_CMD_IASETUP | IE_CMD_LAST;
cmd->com.ie_cmd_link = 0xffff;
bcopy((volatile char *)ie_softc[unit].arpcom.ac_enaddr,
bcopy((volatile char *)ie_softc[sc->unit].arpcom.ac_enaddr,
(volatile char *)&cmd->ie_address, sizeof cmd->ie_address);
scb->ie_command_list = MK_16(MEM, cmd);
if (command_and_wait(unit, IE_CU_START, cmd, IE_STAT_COMPL)
if (command_and_wait(sc->unit, IE_CU_START, cmd, IE_STAT_COMPL)
|| !(cmd->com.ie_cmd_status & IE_STAT_OK)) {
printf("ie%d: individual address "
"setup command failed\n", unit);
"setup command failed\n", sc->unit);
return;
}
}
@ -2174,12 +2178,12 @@ ieinit(int unit)
/*
* Now run the time-domain reflectometer.
*/
run_tdr(unit, (volatile void *) ptr);
run_tdr(sc->unit, (volatile void *) ptr);
/*
* Acknowledge any interrupts we have generated thus far.
*/
ie_ack(ie->scb, IE_ST_WHENCE, unit, ie->ie_chan_attn);
ie_ack(ie->scb, IE_ST_WHENCE, sc->unit, ie->ie_chan_attn);
/*
* Set up the RFA.
@ -2229,11 +2233,11 @@ ieinit(int unit)
bart_config |= IEE16_BART_MCS16_TEST;
outb(PORT + IEE16_CONFIG, bart_config);
ee16_interrupt_enable(ie);
ee16_chan_attn(unit);
ee16_chan_attn(sc->unit);
}
ie->arpcom.ac_if.if_flags |= IFF_RUNNING; /* tell higher levels
* we're here */
start_receiver(unit);
start_receiver(sc->unit);
return;
}
@ -2272,12 +2276,12 @@ ieioctl(struct ifnet *ifp, u_long command, caddr_t data)
(ifp->if_flags & IFF_RUNNING) == 0) {
ie_softc[ifp->if_unit].promisc =
ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI);
ieinit(ifp->if_unit);
ieinit(ifp->if_softc);
} else if (ie_softc[ifp->if_unit].promisc ^
(ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI))) {
ie_softc[ifp->if_unit].promisc =
ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI);
ieinit(ifp->if_unit);
ieinit(ifp->if_softc);
}
break;

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: if_lnc.c,v 1.63 1999/08/18 06:11:59 mdodd Exp $
* $Id: if_lnc.c,v 1.64 1999/08/18 22:14:23 mdodd Exp $
*/
/*
@ -180,7 +180,7 @@ static int lance_probe __P((struct lnc_softc *sc));
static int pcnet_probe __P((struct lnc_softc *sc));
static int lnc_attach_sc __P((struct lnc_softc *sc, int unit));
static int lnc_attach __P((struct isa_device *isa_dev));
static void lnc_init __P((struct lnc_softc *sc));
static void lnc_init __P((void *));
static ointhand2_t lncintr;
static __inline int mbuf_to_buffer __P((struct mbuf *m, char *buffer));
static __inline struct mbuf *chain_to_cluster __P((struct mbuf *m));
@ -1278,6 +1278,7 @@ lnc_attach_sc(struct lnc_softc *sc, int unit)
sc->arpcom.ac_if.if_start = lnc_start;
sc->arpcom.ac_if.if_ioctl = lnc_ioctl;
sc->arpcom.ac_if.if_watchdog = lnc_watchdog;
sc->arpcom.ac_if.if_init = lnc_init;
sc->arpcom.ac_if.if_type = IFT_ETHER;
sc->arpcom.ac_if.if_addrlen = ETHER_ADDR_LEN;
sc->arpcom.ac_if.if_hdrlen = ETHER_HDR_LEN;
@ -1372,8 +1373,10 @@ lnc_attach_ne2100_pci(int unit, unsigned iobase)
#endif
static void
lnc_init(struct lnc_softc *sc)
lnc_init(xsc)
void *xsc;
{
struct lnc_softc *sc = xsc;
int s, i;
char *lnc_mem;