Split device_t/softc of i82586. No crash on TME emulating sun2.

This commit is contained in:
tsutsui 2011-06-03 16:28:40 +00:00
parent 66224643cd
commit c22ffc3803
12 changed files with 144 additions and 132 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ie_gsc.c,v 1.23 2011/02/01 18:33:24 skrll Exp $ */ /* $NetBSD: if_ie_gsc.c,v 1.24 2011/06/03 16:28:40 tsutsui Exp $ */
/* $OpenBSD: if_ie_gsc.c,v 1.6 2001/01/12 22:57:04 mickey Exp $ */ /* $OpenBSD: if_ie_gsc.c,v 1.6 2001/01/12 22:57:04 mickey Exp $ */
@ -38,7 +38,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ie_gsc.c,v 1.23 2011/02/01 18:33:24 skrll Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ie_gsc.c,v 1.24 2011/06/03 16:28:40 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -123,7 +123,7 @@ struct ie_gsc_softc {
int ie_gsc_probe(device_t, cfdata_t, void *); int ie_gsc_probe(device_t, cfdata_t, void *);
void ie_gsc_attach(device_t, device_t, void *); void ie_gsc_attach(device_t, device_t, void *);
CFATTACH_DECL(ie_gsc, sizeof(struct ie_gsc_softc), CFATTACH_DECL_NEW(ie_gsc, sizeof(struct ie_gsc_softc),
ie_gsc_probe, ie_gsc_attach, NULL, NULL); ie_gsc_probe, ie_gsc_attach, NULL, NULL);
static int ie_gsc_media[] = { static int ie_gsc_media[] = {
@ -340,7 +340,7 @@ i82596_probe(struct ie_softc *sc)
/* Make sure that BUSY got cleared. */ /* Make sure that BUSY got cleared. */
if (sc->ie_bus_read16(sc, IE_ISCP_BUSY(sc->iscp))) { if (sc->ie_bus_read16(sc, IE_ISCP_BUSY(sc->iscp))) {
#if I82596_DEBUG #if I82596_DEBUG
printf ("%s: ISCP set failed\n", sc->sc_dev.dv_xname); printf ("%s: ISCP set failed\n", device_xname(sc->sc_dev));
#endif #endif
return 0; return 0;
} }
@ -360,7 +360,7 @@ i82596_probe(struct ie_softc *sc)
printf (": test %x:%x\n%s", printf (": test %x:%x\n%s",
*((volatile int32_t *)((char *)sc->sc_maddr + 0)), *((volatile int32_t *)((char *)sc->sc_maddr + 0)),
*((volatile int32_t *)((char *)sc->sc_maddr + 4)), *((volatile int32_t *)((char *)sc->sc_maddr + 4)),
sc->sc_dev.dv_xname); device_xname(sc->sc_dev));
#endif #endif
return 1; return 1;
} }
@ -407,6 +407,7 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
} }
/* Set up some initial glue. */ /* Set up some initial glue. */
sc->sc_dev = self;
gsc->iot = ga->ga_iot; gsc->iot = ga->ga_iot;
gsc->iemt = ga->ga_dmatag; gsc->iemt = ga->ga_dmatag;
sc->bt = ga->ga_iot; sc->bt = ga->ga_iot;
@ -471,7 +472,7 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
(u_int)sc->sc_dmamap->dm_segs[0].ds_addr, (u_int)sc->sc_dmamap->dm_segs[0].ds_addr,
sc->sc_maddr, sc->sc_maddr,
sc->sc_msize, sc->sc_msize,
sc->sc_dev.dv_xname); device_xname(self));
sc->sc_debug = IED_ALL; sc->sc_debug = IED_ALL;
#endif #endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ie_obio.c,v 1.38 2011/02/01 20:19:31 chuck Exp $ */ /* $NetBSD: if_ie_obio.c,v 1.39 2011/06/03 16:28:40 tsutsui Exp $ */
/*- /*-
* Copyright (c) 1997 The NetBSD Foundation, Inc. * Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -73,7 +73,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.38 2011/02/01 20:19:31 chuck Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.39 2011/06/03 16:28:40 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -123,7 +123,7 @@ static void ie_obrun(struct ie_softc *);
int ie_obio_match(device_t, cfdata_t, void *); int ie_obio_match(device_t, cfdata_t, void *);
void ie_obio_attach(device_t, device_t, void *); void ie_obio_attach(device_t, device_t, void *);
CFATTACH_DECL(ie_obio, sizeof(struct ie_softc), CFATTACH_DECL_NEW(ie_obio, sizeof(struct ie_softc),
ie_obio_match, ie_obio_attach, NULL, NULL); ie_obio_match, ie_obio_attach, NULL, NULL);
/* Supported media */ /* Supported media */
@ -259,6 +259,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
u_long iebase; u_long iebase;
uint8_t myaddr[ETHER_ADDR_LEN]; uint8_t myaddr[ETHER_ADDR_LEN];
sc->sc_dev = self;
sc->bt = oba->oba_bustag; sc->bt = oba->oba_bustag;
sc->hwreset = ie_obreset; sc->hwreset = ie_obreset;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ie_mbmem.c,v 1.10 2011/02/01 20:19:31 chuck Exp $ */ /* $NetBSD: if_ie_mbmem.c,v 1.11 2011/06/03 16:28:40 tsutsui Exp $ */
/* /*
* Copyright (c) 1995 Charles D. Cranor * Copyright (c) 1995 Charles D. Cranor
@ -140,7 +140,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ie_mbmem.c,v 1.10 2011/02/01 20:19:31 chuck Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ie_mbmem.c,v 1.11 2011/06/03 16:28:40 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -232,8 +232,8 @@ static void ie_mbmemattend(struct ie_softc *, int);
static void ie_mbmemrun(struct ie_softc *); static void ie_mbmemrun(struct ie_softc *);
static int ie_mbmemintr(struct ie_softc *, int); static int ie_mbmemintr(struct ie_softc *, int);
int ie_mbmem_match(struct device *, struct cfdata *, void *); int ie_mbmem_match(device_t, cfdata_t, void *);
void ie_mbmem_attach(struct device *, struct device *, void *); void ie_mbmem_attach(device_t, device_t, void *);
struct ie_mbmem_softc { struct ie_mbmem_softc {
struct ie_softc ie; struct ie_softc ie;
@ -241,7 +241,7 @@ struct ie_mbmem_softc {
bus_space_handle_t ievh; bus_space_handle_t ievh;
}; };
CFATTACH_DECL(ie_mbmem, sizeof(struct ie_mbmem_softc), CFATTACH_DECL_NEW(ie_mbmem, sizeof(struct ie_mbmem_softc),
ie_mbmem_match, ie_mbmem_attach, NULL, NULL); ie_mbmem_match, ie_mbmem_attach, NULL, NULL);
#define read_iev(sc, reg) \ #define read_iev(sc, reg) \
@ -294,7 +294,7 @@ ie_mbmemintr(struct ie_softc *sc, int where)
*/ */
if (read_iev(vsc, status) & IEMBMEM_PERR) { if (read_iev(vsc, status) & IEMBMEM_PERR) {
printf("%s: parity error (ctrl 0x%x @ 0x%02x%04x)\n", printf("%s: parity error (ctrl 0x%x @ 0x%02x%04x)\n",
sc->sc_dev.dv_xname, read_iev(vsc, pectrl), device_xname(sc->sc_dev), read_iev(vsc, pectrl),
read_iev(vsc, pectrl) & IEMBMEM_HADDR, read_iev(vsc, pectrl) & IEMBMEM_HADDR,
read_iev(vsc, peaddr)); read_iev(vsc, peaddr));
write_iev(vsc, pectrl, read_iev(vsc, pectrl) | IEMBMEM_PARACK); write_iev(vsc, pectrl, read_iev(vsc, pectrl) | IEMBMEM_PARACK);
@ -367,7 +367,7 @@ ie_mbmem_write24(struct ie_softc *sc, int offset, int addr)
} }
int int
ie_mbmem_match(struct device *parent, struct cfdata *cf, void *aux) ie_mbmem_match(device_t parent, cfdata_t cf, void *aux)
{ {
struct mbmem_attach_args *mbma = aux; struct mbmem_attach_args *mbma = aux;
bus_space_handle_t bh; bus_space_handle_t bh;
@ -394,10 +394,10 @@ ie_mbmem_match(struct device *parent, struct cfdata *cf, void *aux)
} }
void void
ie_mbmem_attach(struct device *parent, struct device *self, void *aux) ie_mbmem_attach(device_t parent, device_t self, void *aux)
{ {
uint8_t myaddr[ETHER_ADDR_LEN]; uint8_t myaddr[ETHER_ADDR_LEN];
struct ie_mbmem_softc *vsc = (void *) self; struct ie_mbmem_softc *vsc = device_private(self);
struct mbmem_attach_args *mbma = aux; struct mbmem_attach_args *mbma = aux;
struct ie_softc *sc; struct ie_softc *sc;
bus_size_t memsize; bus_size_t memsize;
@ -405,6 +405,7 @@ ie_mbmem_attach(struct device *parent, struct device *self, void *aux)
int lcv; int lcv;
sc = &vsc->ie; sc = &vsc->ie;
sc->sc_dev = self;
sc->hwreset = ie_mbmemreset; sc->hwreset = ie_mbmemreset;
sc->hwinit = ie_mbmemrun; sc->hwinit = ie_mbmemrun;
@ -486,7 +487,7 @@ ie_mbmem_attach(struct device *parent, struct device *self, void *aux)
sc->do_xmitnopchain = 0; sc->do_xmitnopchain = 0;
printf("\n%s:", self->dv_xname); printf("\n%s:", device_xname(self));
/* Set the ethernet address. */ /* Set the ethernet address. */
idprom_etheraddr(myaddr); idprom_etheraddr(myaddr);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ie_obio.c,v 1.14 2011/02/01 20:19:31 chuck Exp $ */ /* $NetBSD: if_ie_obio.c,v 1.15 2011/06/03 16:28:40 tsutsui Exp $ */
/*- /*-
* Copyright (c) 1997 The NetBSD Foundation, Inc. * Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -73,7 +73,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.14 2011/02/01 20:19:31 chuck Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.15 2011/06/03 16:28:40 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -121,10 +121,10 @@ static void ie_obreset(struct ie_softc *, int);
static void ie_obattend(struct ie_softc *, int); static void ie_obattend(struct ie_softc *, int);
static void ie_obrun(struct ie_softc *); static void ie_obrun(struct ie_softc *);
int ie_obio_match(struct device *, struct cfdata *, void *); int ie_obio_match(device_t, cfdata_t, void *);
void ie_obio_attach(struct device *, struct device *, void *); void ie_obio_attach(device_t, device_t, void *);
CFATTACH_DECL(ie_obio, sizeof(struct ie_softc), CFATTACH_DECL_NEW(ie_obio, sizeof(struct ie_softc),
ie_obio_match, ie_obio_attach, NULL, NULL); ie_obio_match, ie_obio_attach, NULL, NULL);
/* Supported media */ /* Supported media */
@ -220,7 +220,7 @@ ie_obio_write24(struct ie_softc *sc, int offset, int addr)
} }
int int
ie_obio_match(struct device *parent, struct cfdata *cf, void *aux) ie_obio_match(device_t parent, cfdata_t cf, void *aux)
{ {
struct obio_attach_args *oba = aux; struct obio_attach_args *oba = aux;
bus_space_handle_t bh; bus_space_handle_t bh;
@ -250,10 +250,10 @@ ie_obio_match(struct device *parent, struct cfdata *cf, void *aux)
} }
void void
ie_obio_attach(struct device *parent, struct device *self, void *aux) ie_obio_attach(device_t parent, device_t self, void *aux)
{ {
struct obio_attach_args *oba = aux; struct obio_attach_args *oba = aux;
struct ie_softc *sc = (void *) self; struct ie_softc *sc = device_private(self);
bus_dma_tag_t dmatag = oba->oba_dmatag; bus_dma_tag_t dmatag = oba->oba_dmatag;
bus_space_handle_t bh; bus_space_handle_t bh;
bus_dma_segment_t seg; bus_dma_segment_t seg;
@ -265,6 +265,7 @@ ie_obio_attach(struct device *parent, struct device *self, void *aux)
u_long iebase; u_long iebase;
uint8_t myaddr[ETHER_ADDR_LEN]; uint8_t myaddr[ETHER_ADDR_LEN];
sc->sc_dev = self;
sc->bt = oba->oba_bustag; sc->bt = oba->oba_bustag;
sc->hwreset = ie_obreset; sc->hwreset = ie_obreset;
@ -291,14 +292,14 @@ ie_obio_attach(struct device *parent, struct device *self, void *aux)
BUS_DMA_NOWAIT|BUS_DMA_24BIT, BUS_DMA_NOWAIT|BUS_DMA_24BIT,
&sc->sc_dmamap)) != 0) { &sc->sc_dmamap)) != 0) {
printf("%s: DMA map create error %d\n", printf("%s: DMA map create error %d\n",
sc->sc_dev.dv_xname, error); device_xname(self), error);
return; return;
} }
if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0, if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0,
&seg, 1, &rseg, &seg, 1, &rseg,
BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) { BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
printf("%s: DMA memory allocation error %d\n", printf("%s: DMA memory allocation error %d\n",
self->dv_xname, error); device_xname(self), error);
return; return;
} }
@ -307,7 +308,7 @@ ie_obio_attach(struct device *parent, struct device *self, void *aux)
(void **)&sc->sc_maddr, (void **)&sc->sc_maddr,
BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) { BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
printf("%s: DMA buffer map error %d\n", printf("%s: DMA buffer map error %d\n",
sc->sc_dev.dv_xname, error); device_xname(self), error);
bus_dmamem_free(dmatag, &seg, rseg); bus_dmamem_free(dmatag, &seg, rseg);
return; return;
} }
@ -317,7 +318,7 @@ ie_obio_attach(struct device *parent, struct device *self, void *aux)
sc->sc_maddr, memsize, NULL, sc->sc_maddr, memsize, NULL,
BUS_DMA_NOWAIT)) != 0) { BUS_DMA_NOWAIT)) != 0) {
printf("%s: DMA buffer map load error %d\n", printf("%s: DMA buffer map load error %d\n",
sc->sc_dev.dv_xname, error); device_xname(self), error);
bus_dmamem_unmap(dmatag, sc->sc_maddr, memsize); bus_dmamem_unmap(dmatag, sc->sc_maddr, memsize);
bus_dmamem_free(dmatag, &seg, rseg); bus_dmamem_free(dmatag, &seg, rseg);
return; return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: i82586.c,v 1.68 2010/04/05 07:19:34 joerg Exp $ */ /* $NetBSD: i82586.c,v 1.69 2011/06/03 16:28:40 tsutsui Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -137,7 +137,7 @@ Mode of operation:
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i82586.c,v 1.68 2010/04/05 07:19:34 joerg Exp $"); __KERNEL_RCSID(0, "$NetBSD: i82586.c,v 1.69 2011/06/03 16:28:40 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
@ -236,7 +236,7 @@ i82586_attach(struct ie_softc *sc, const char *name, u_int8_t *etheraddr, int *m
int i; int i;
struct ifnet *ifp = &sc->sc_ethercom.ec_if; struct ifnet *ifp = &sc->sc_ethercom.ec_if;
strlcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ); strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
ifp->if_softc = sc; ifp->if_softc = sc;
ifp->if_start = i82586_start; ifp->if_start = i82586_start;
ifp->if_ioctl = i82586_ioctl; ifp->if_ioctl = i82586_ioctl;
@ -262,7 +262,7 @@ i82586_attach(struct ie_softc *sc, const char *name, u_int8_t *etheraddr, int *m
padbuf = malloc(ETHER_MIN_LEN - ETHER_CRC_LEN, M_DEVBUF, padbuf = malloc(ETHER_MIN_LEN - ETHER_CRC_LEN, M_DEVBUF,
M_ZERO | M_NOWAIT); M_ZERO | M_NOWAIT);
if (padbuf == NULL) { if (padbuf == NULL) {
aprint_error_dev(&sc->sc_dev, "can't allocate pad buffer\n"); aprint_error_dev(sc->sc_dev, "can't allocate pad buffer\n");
return; return;
} }
} }
@ -285,7 +285,7 @@ i82586_watchdog(struct ifnet *ifp)
{ {
struct ie_softc *sc = ifp->if_softc; struct ie_softc *sc = ifp->if_softc;
log(LOG_ERR, "%s: device timeout\n", device_xname(&sc->sc_dev)); log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev));
++ifp->if_oerrors; ++ifp->if_oerrors;
i82586_reset(sc, 1); i82586_reset(sc, 1);
@ -424,7 +424,7 @@ i82586_rx_errors(struct ie_softc *sc, int fn, int status)
char bits[128]; char bits[128];
snprintb(bits, sizeof(bits), IE_FD_STATUSBITS, status); snprintb(bits, sizeof(bits), IE_FD_STATUSBITS, status);
log(LOG_ERR, "%s: rx error (frame# %d): %s\n", log(LOG_ERR, "%s: rx error (frame# %d): %s\n",
device_xname(&sc->sc_dev), fn, bits); device_xname(sc->sc_dev), fn, bits);
} }
@ -472,7 +472,7 @@ loop:
#if I82586_DEBUG #if I82586_DEBUG
if ((status & IE_ST_CNA) && (sc->sc_debug & IED_CNA)) if ((status & IE_ST_CNA) && (sc->sc_debug & IED_CNA))
printf("%s: cna; status=0x%x\n", device_xname(&sc->sc_dev), status); printf("%s: cna; status=0x%x\n", device_xname(sc->sc_dev), status);
#endif #endif
if (sc->intrhook) if (sc->intrhook)
(sc->intrhook)(sc, INTR_LOOP); (sc->intrhook)(sc, INTR_LOOP);
@ -516,7 +516,7 @@ static int timesthru = 1024;
#if I82586_DEBUG #if I82586_DEBUG
if (sc->sc_debug & IED_RINT) if (sc->sc_debug & IED_RINT)
printf("%s: rint: status 0x%x\n", printf("%s: rint: status 0x%x\n",
device_xname(&sc->sc_dev), scbstatus); device_xname(sc->sc_dev), scbstatus);
#endif #endif
for (;;) { for (;;) {
@ -530,12 +530,12 @@ static int timesthru = 1024;
#if I82586_DEBUG #if I82586_DEBUG
if (sc->sc_debug & IED_RINT) if (sc->sc_debug & IED_RINT)
printf("%s: rint: frame(%d) status 0x%x\n", printf("%s: rint: frame(%d) status 0x%x\n",
device_xname(&sc->sc_dev), i, status); device_xname(sc->sc_dev), i, status);
#endif #endif
if ((status & IE_FD_COMPLETE) == 0) { if ((status & IE_FD_COMPLETE) == 0) {
if ((status & IE_FD_OK) != 0) { if ((status & IE_FD_OK) != 0) {
printf("%s: rint: weird: ", printf("%s: rint: weird: ",
device_xname(&sc->sc_dev)); device_xname(sc->sc_dev));
i82586_rx_errors(sc, i, status); i82586_rx_errors(sc, i, status);
break; break;
} }
@ -558,7 +558,7 @@ static int timesthru = 1024;
#if I82586_DEBUG #if I82586_DEBUG
if ((status & IE_FD_BUSY) != 0) if ((status & IE_FD_BUSY) != 0)
printf("%s: rint: frame(%d) busy; status=0x%x\n", printf("%s: rint: frame(%d) busy; status=0x%x\n",
device_xname(&sc->sc_dev), i, status); device_xname(sc->sc_dev), i, status);
#endif #endif
@ -616,7 +616,7 @@ static int timesthru = 1024;
scbstatus); scbstatus);
if (i82586_start_cmd(sc, IE_RUC_RESUME, 0, 0, 0) == 0) if (i82586_start_cmd(sc, IE_RUC_RESUME, 0, 0, 0) == 0)
return (0); return (0);
aprint_error_dev(&sc->sc_dev, "RU RESUME command timed out\n"); aprint_error_dev(sc->sc_dev, "RU RESUME command timed out\n");
return (1); /* Ask for a reset */ return (1); /* Ask for a reset */
} }
@ -645,7 +645,7 @@ static int timesthru = 1024;
return (0); return (0);
} else } else
printf("%s: receiver not ready; scbstatus=0x%x\n", printf("%s: receiver not ready; scbstatus=0x%x\n",
device_xname(&sc->sc_dev), scbstatus); device_xname(sc->sc_dev), scbstatus);
sc->sc_ethercom.ec_if.if_ierrors++; sc->sc_ethercom.ec_if.if_ierrors++;
return (1); /* Ask for a reset */ return (1); /* Ask for a reset */
@ -682,7 +682,7 @@ i82586_tint(struct ie_softc *sc, int scbstatus)
#if I82586_DEBUG #if I82586_DEBUG
if (sc->sc_debug & IED_TINT) if (sc->sc_debug & IED_TINT)
printf("%s: tint: SCB status 0x%x; xmit status 0x%x\n", printf("%s: tint: SCB status 0x%x; xmit status 0x%x\n",
device_xname(&sc->sc_dev), scbstatus, status); device_xname(sc->sc_dev), scbstatus, status);
#endif #endif
if ((status & IE_STAT_COMPL) == 0 || (status & IE_STAT_BUSY)) { if ((status & IE_STAT_COMPL) == 0 || (status & IE_STAT_BUSY)) {
@ -701,15 +701,15 @@ i82586_tint(struct ie_softc *sc, int scbstatus)
* What if more than one bit is set? * What if more than one bit is set?
*/ */
if (status & IE_STAT_ABORT) if (status & IE_STAT_ABORT)
aprint_error_dev(&sc->sc_dev, "send aborted\n"); aprint_error_dev(sc->sc_dev, "send aborted\n");
else if (status & IE_XS_NOCARRIER) else if (status & IE_XS_NOCARRIER)
aprint_error_dev(&sc->sc_dev, "no carrier\n"); aprint_error_dev(sc->sc_dev, "no carrier\n");
else if (status & IE_XS_LOSTCTS) else if (status & IE_XS_LOSTCTS)
aprint_error_dev(&sc->sc_dev, "lost CTS\n"); aprint_error_dev(sc->sc_dev, "lost CTS\n");
else if (status & IE_XS_UNDERRUN) else if (status & IE_XS_UNDERRUN)
aprint_error_dev(&sc->sc_dev, "DMA underrun\n"); aprint_error_dev(sc->sc_dev, "DMA underrun\n");
else if (status & IE_XS_EXCMAX) { else if (status & IE_XS_EXCMAX) {
aprint_error_dev(&sc->sc_dev, "too many collisions\n"); aprint_error_dev(sc->sc_dev, "too many collisions\n");
sc->sc_ethercom.ec_if.if_collisions += 16; sc->sc_ethercom.ec_if.if_collisions += 16;
} }
} }
@ -763,7 +763,7 @@ i82586_get_rbd_list(struct ie_softc *sc, u_int16_t *start, u_int16_t *end, int *
#endif #endif
log(LOG_ERR, log(LOG_ERR,
"%s: receive descriptors out of sync at %d\n", "%s: receive descriptors out of sync at %d\n",
device_xname(&sc->sc_dev), rbindex); device_xname(sc->sc_dev), rbindex);
return (0); return (0);
} }
plen += (rbdstatus & IE_RBD_CNTMASK); plen += (rbdstatus & IE_RBD_CNTMASK);
@ -850,7 +850,7 @@ i82586_chk_rx_ring(struct ie_softc *sc)
/* `rbtail' and EOL flag out of sync */ /* `rbtail' and EOL flag out of sync */
log(LOG_ERR, log(LOG_ERR,
"%s: rx buffer descriptors out of sync at %d\n", "%s: rx buffer descriptors out of sync at %d\n",
device_xname(&sc->sc_dev), n); device_xname(sc->sc_dev), n);
return (1); return (1);
} }
@ -864,7 +864,7 @@ i82586_chk_rx_ring(struct ie_softc *sc)
/* `rftail' and EOL flag out of sync */ /* `rftail' and EOL flag out of sync */
log(LOG_ERR, log(LOG_ERR,
"%s: rx frame list out of sync at %d\n", "%s: rx frame list out of sync at %d\n",
device_xname(&sc->sc_dev), n); device_xname(sc->sc_dev), n);
return (1); return (1);
} }
} }
@ -1026,7 +1026,7 @@ ie_readframe(
struct ether_header *eh = mtod(m, struct ether_header *); struct ether_header *eh = mtod(m, struct ether_header *);
printf("%s: frame from ether %s type 0x%x len %d\n", printf("%s: frame from ether %s type 0x%x len %d\n",
device_xname(&sc->sc_dev), device_xname(sc->sc_dev),
ether_sprintf(eh->ether_shost), ether_sprintf(eh->ether_shost),
(u_int)ntohs(eh->ether_type), (u_int)ntohs(eh->ether_type),
pktlen); pktlen);
@ -1059,7 +1059,7 @@ iexmit(struct ie_softc *sc)
#if I82586_DEBUG #if I82586_DEBUG
if (sc->sc_debug & IED_XMIT) if (sc->sc_debug & IED_XMIT)
printf("%s: xmit buffer %d\n", device_xname(&sc->sc_dev), cur); printf("%s: xmit buffer %d\n", device_xname(sc->sc_dev), cur);
#endif #endif
/* /*
@ -1112,7 +1112,7 @@ iexmit(struct ie_softc *sc)
IE_BUS_BARRIER(sc, off, 2, BUS_SPACE_BARRIER_READ); IE_BUS_BARRIER(sc, off, 2, BUS_SPACE_BARRIER_READ);
if (i82586_start_cmd(sc, IE_CUC_START, 0, 0, 1)) if (i82586_start_cmd(sc, IE_CUC_START, 0, 0, 1))
aprint_error_dev(&sc->sc_dev, "iexmit: start xmit command timed out\n"); aprint_error_dev(sc->sc_dev, "iexmit: start xmit command timed out\n");
} }
sc->sc_ethercom.ec_if.if_timer = 5; sc->sc_ethercom.ec_if.if_timer = 5;
@ -1156,12 +1156,12 @@ i82586_start(struct ifnet *ifp)
#if I82586_DEBUG #if I82586_DEBUG
if (sc->sc_debug & IED_ENQ) if (sc->sc_debug & IED_ENQ)
printf("%s: fill buffer %d\n", device_xname(&sc->sc_dev), printf("%s: fill buffer %d\n", device_xname(sc->sc_dev),
sc->xchead); sc->xchead);
#endif #endif
if (m0->m_pkthdr.len > IE_TBUF_SIZE) if (m0->m_pkthdr.len > IE_TBUF_SIZE)
printf("%s: tbuf overflow\n", device_xname(&sc->sc_dev)); printf("%s: tbuf overflow\n", device_xname(sc->sc_dev));
buffer = IE_XBUF_ADDR(sc, head); buffer = IE_XBUF_ADDR(sc, head);
for (m = m0; m != 0; m = m->m_next) { for (m = m0; m != 0; m = m->m_next) {
@ -1244,7 +1244,7 @@ i82586_reset(struct ie_softc *sc, int hard)
int s = splnet(); int s = splnet();
if (hard) if (hard)
printf("%s: reset\n", device_xname(&sc->sc_dev)); printf("%s: reset\n", device_xname(sc->sc_dev));
/* Clear OACTIVE in case we're called from watchdog (frozen xmit). */ /* Clear OACTIVE in case we're called from watchdog (frozen xmit). */
sc->sc_ethercom.ec_if.if_timer = 0; sc->sc_ethercom.ec_if.if_timer = 0;
@ -1254,7 +1254,7 @@ i82586_reset(struct ie_softc *sc, int hard)
* Stop i82586 dead in its tracks. * Stop i82586 dead in its tracks.
*/ */
if (i82586_start_cmd(sc, IE_RUC_ABORT | IE_CUC_ABORT, 0, 0, 0)) if (i82586_start_cmd(sc, IE_RUC_ABORT | IE_CUC_ABORT, 0, 0, 0))
aprint_error_dev(&sc->sc_dev, "abort commands timed out\n"); aprint_error_dev(sc->sc_dev, "abort commands timed out\n");
/* /*
* This can really slow down the i82586_reset() on some cards, but it's * This can really slow down the i82586_reset() on some cards, but it's
@ -1314,17 +1314,17 @@ ie_run_tdr(struct ie_softc *sc, int cmd)
return; return;
if (result & 0x10000) if (result & 0x10000)
aprint_error_dev(&sc->sc_dev, "TDR command failed\n"); aprint_error_dev(sc->sc_dev, "TDR command failed\n");
else if (result & IE_TDR_XCVR) else if (result & IE_TDR_XCVR)
aprint_error_dev(&sc->sc_dev, "transceiver problem\n"); aprint_error_dev(sc->sc_dev, "transceiver problem\n");
else if (result & IE_TDR_OPEN) else if (result & IE_TDR_OPEN)
aprint_error_dev(&sc->sc_dev, "TDR detected incorrect termination %d clocks away\n", aprint_error_dev(sc->sc_dev, "TDR detected incorrect termination %d clocks away\n",
result & IE_TDR_TIME); result & IE_TDR_TIME);
else if (result & IE_TDR_SHORT) else if (result & IE_TDR_SHORT)
aprint_error_dev(&sc->sc_dev, "TDR detected a short circuit %d clocks away\n", aprint_error_dev(sc->sc_dev, "TDR detected a short circuit %d clocks away\n",
result & IE_TDR_TIME); result & IE_TDR_TIME);
else else
aprint_error_dev(&sc->sc_dev, "TDR returned unknown status 0x%x\n", aprint_error_dev(sc->sc_dev, "TDR returned unknown status 0x%x\n",
result); result);
} }
@ -1401,7 +1401,7 @@ i82586_setup_bufs(struct ie_softc *sc)
ptr += sc->nrxbuf * IE_RBUF_SIZE; ptr += sc->nrxbuf * IE_RBUF_SIZE;
#if I82586_DEBUG #if I82586_DEBUG
printf("%s: %d frames %d bufs\n", device_xname(&sc->sc_dev), sc->nframes, printf("%s: %d frames %d bufs\n", device_xname(sc->sc_dev), sc->nframes,
sc->nrxbuf); sc->nrxbuf);
#endif #endif
@ -1489,7 +1489,7 @@ i82586_setup_bufs(struct ie_softc *sc)
/* link in recv frames * and buffer into the scb. */ /* link in recv frames * and buffer into the scb. */
#if I82586_DEBUG #if I82586_DEBUG
printf("%s: reserved %d bytes\n", printf("%s: reserved %d bytes\n",
device_xname(&sc->sc_dev), ptr - sc->buf_area); device_xname(sc->sc_dev), ptr - sc->buf_area);
#endif #endif
} }
@ -1518,11 +1518,11 @@ ie_cfg_setup(struct ie_softc *sc, int cmd, int promiscuous, int manchester)
cmdresult = i82586_start_cmd(sc, IE_CUC_START, cmd, IE_STAT_COMPL, 0); cmdresult = i82586_start_cmd(sc, IE_CUC_START, cmd, IE_STAT_COMPL, 0);
status = sc->ie_bus_read16(sc, IE_CMD_COMMON_STATUS(cmd)); status = sc->ie_bus_read16(sc, IE_CMD_COMMON_STATUS(cmd));
if (cmdresult != 0) { if (cmdresult != 0) {
aprint_error_dev(&sc->sc_dev, "configure command timed out; status %x\n", status); aprint_error_dev(sc->sc_dev, "configure command timed out; status %x\n", status);
return (0); return (0);
} }
if ((status & IE_STAT_OK) == 0) { if ((status & IE_STAT_OK) == 0) {
aprint_error_dev(&sc->sc_dev, "configure command failed; status %x\n", status); aprint_error_dev(sc->sc_dev, "configure command failed; status %x\n", status);
return (0); return (0);
} }
@ -1545,11 +1545,11 @@ ie_ia_setup(struct ie_softc *sc, int cmdbuf)
cmdresult = i82586_start_cmd(sc, IE_CUC_START, cmdbuf, IE_STAT_COMPL, 0); cmdresult = i82586_start_cmd(sc, IE_CUC_START, cmdbuf, IE_STAT_COMPL, 0);
status = sc->ie_bus_read16(sc, IE_CMD_COMMON_STATUS(cmdbuf)); status = sc->ie_bus_read16(sc, IE_CMD_COMMON_STATUS(cmdbuf));
if (cmdresult != 0) { if (cmdresult != 0) {
aprint_error_dev(&sc->sc_dev, "individual address command timed out; status %x\n", status); aprint_error_dev(sc->sc_dev, "individual address command timed out; status %x\n", status);
return (0); return (0);
} }
if ((status & IE_STAT_OK) == 0) { if ((status & IE_STAT_OK) == 0) {
aprint_error_dev(&sc->sc_dev, "individual address command failed; status %x\n", status); aprint_error_dev(sc->sc_dev, "individual address command failed; status %x\n", status);
return (0); return (0);
} }
@ -1583,11 +1583,11 @@ ie_mc_setup(struct ie_softc *sc, int cmdbuf)
cmdresult = i82586_start_cmd(sc, IE_CUC_START, cmdbuf, IE_STAT_COMPL, 0); cmdresult = i82586_start_cmd(sc, IE_CUC_START, cmdbuf, IE_STAT_COMPL, 0);
status = sc->ie_bus_read16(sc, IE_CMD_COMMON_STATUS(cmdbuf)); status = sc->ie_bus_read16(sc, IE_CMD_COMMON_STATUS(cmdbuf));
if (cmdresult != 0) { if (cmdresult != 0) {
aprint_error_dev(&sc->sc_dev, "multicast setup command timed out; status %x\n", status); aprint_error_dev(sc->sc_dev, "multicast setup command timed out; status %x\n", status);
return (0); return (0);
} }
if ((status & IE_STAT_OK) == 0) { if ((status & IE_STAT_OK) == 0) {
aprint_error_dev(&sc->sc_dev, "multicast setup command failed; status %x\n", aprint_error_dev(sc->sc_dev, "multicast setup command failed; status %x\n",
status); status);
return (0); return (0);
} }
@ -1680,7 +1680,7 @@ i82586_start_transceiver(struct ie_softc *sc)
if (sc->do_xmitnopchain) { if (sc->do_xmitnopchain) {
/* Stop transmit command chain */ /* Stop transmit command chain */
if (i82586_start_cmd(sc, IE_CUC_SUSPEND|IE_RUC_SUSPEND, 0, 0, 0)) if (i82586_start_cmd(sc, IE_CUC_SUSPEND|IE_RUC_SUSPEND, 0, 0, 0))
aprint_error_dev(&sc->sc_dev, "CU/RU stop command timed out\n"); aprint_error_dev(sc->sc_dev, "CU/RU stop command timed out\n");
/* Start the receiver & transmitter chain */ /* Start the receiver & transmitter chain */
/* sc->scb->ie_command_list = /* sc->scb->ie_command_list =
@ -1691,10 +1691,10 @@ i82586_start_transceiver(struct ie_softc *sc)
(sc->xctail + NTXBUF - 1) % NTXBUF)); (sc->xctail + NTXBUF - 1) % NTXBUF));
if (i82586_start_cmd(sc, IE_CUC_START|IE_RUC_START, 0, 0, 0)) if (i82586_start_cmd(sc, IE_CUC_START|IE_RUC_START, 0, 0, 0))
aprint_error_dev(&sc->sc_dev, "CU/RU command timed out\n"); aprint_error_dev(sc->sc_dev, "CU/RU command timed out\n");
} else { } else {
if (i82586_start_cmd(sc, IE_RUC_START, 0, 0, 0)) if (i82586_start_cmd(sc, IE_RUC_START, 0, 0, 0))
aprint_error_dev(&sc->sc_dev, "RU command timed out\n"); aprint_error_dev(sc->sc_dev, "RU command timed out\n");
} }
} }
@ -1706,7 +1706,7 @@ i82586_stop(
struct ie_softc *sc = ifp->if_softc; struct ie_softc *sc = ifp->if_softc;
if (i82586_start_cmd(sc, IE_RUC_SUSPEND | IE_CUC_SUSPEND, 0, 0, 0)) if (i82586_start_cmd(sc, IE_RUC_SUSPEND | IE_CUC_SUSPEND, 0, 0, 0))
aprint_error_dev(&sc->sc_dev, "iestop: disable commands timed out\n"); aprint_error_dev(sc->sc_dev, "iestop: disable commands timed out\n");
} }
int int

View File

@ -1,4 +1,4 @@
/* $NetBSD: i82586var.h,v 1.22 2008/04/28 20:23:50 martin Exp $ */ /* $NetBSD: i82586var.h,v 1.23 2011/06/03 16:28:40 tsutsui Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -166,7 +166,7 @@
*/ */
struct ie_softc { struct ie_softc {
struct device sc_dev; /* device structure */ device_t sc_dev; /* device structure */
bus_space_tag_t bt; /* bus-space tag of card memory */ bus_space_tag_t bt; /* bus-space tag of card memory */
bus_space_handle_t bh; /* bus-space handle of card memory */ bus_space_handle_t bh; /* bus-space handle of card memory */

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ai.c,v 1.32 2009/05/12 09:10:15 cegger Exp $ */ /* $NetBSD: if_ai.c,v 1.33 2011/06/03 16:28:40 tsutsui Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ai.c,v 1.32 2009/05/12 09:10:15 cegger Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ai.c,v 1.33 2011/06/03 16:28:40 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -304,7 +304,7 @@ out:
void void
ai_attach(device_t parent, device_t self, void *aux) ai_attach(device_t parent, device_t self, void *aux)
{ {
struct ai_softc *asc = (void *)self; struct ai_softc *asc = device_private(self);
struct ie_softc *sc = &asc->sc_ie; struct ie_softc *sc = &asc->sc_ie;
struct isa_attach_args *ia = aux; struct isa_attach_args *ia = aux;
@ -313,10 +313,12 @@ ai_attach(device_t parent, device_t self, void *aux)
u_int8_t ethaddr[ETHER_ADDR_LEN]; u_int8_t ethaddr[ETHER_ADDR_LEN];
char name[80]; char name[80];
sc->sc_dev = self;
if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr,
ia->ia_io[0].ir_size, 0, &ioh) != 0) { ia->ia_io[0].ir_size, 0, &ioh) != 0) {
DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n", DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n",
device_xname(&sc->sc_dev), device_xname(self),
ia->ia_io[0].ir_addr, ia->ia_io[0].ir_addr + ia->ia_io[0].ir_addr, ia->ia_io[0].ir_addr +
ia->ia_io[0].ir_size - 1)); ia->ia_io[0].ir_size - 1));
return; return;
@ -325,7 +327,7 @@ ai_attach(device_t parent, device_t self, void *aux)
if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr,
ia->ia_iomem[0].ir_size, 0, &memh) != 0) { ia->ia_iomem[0].ir_size, 0, &memh) != 0) {
DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n", DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n",
device_xname(&sc->sc_dev), device_xname(self),
ia->ia_iomem[0].ir_addr, ia->ia_iomem[0].ir_addr + ia->ia_iomem[0].ir_addr, ia->ia_iomem[0].ir_addr +
ia->ia_iomem[0].ir_size - 1)); ia->ia_iomem[0].ir_size - 1));
bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size); bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size);
@ -386,7 +388,7 @@ ai_attach(device_t parent, device_t self, void *aux)
BUS_SPACE_BARRIER_WRITE); BUS_SPACE_BARRIER_WRITE);
if (!i82586_proberam(sc)) { if (!i82586_proberam(sc)) {
DPRINTF(("\n%s: can't talk to i82586!\n", DPRINTF(("\n%s: can't talk to i82586!\n",
device_xname(&sc->sc_dev))); device_xname(self)));
bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size); bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size);
bus_space_unmap(ia->ia_memt, memh, ia->ia_iomem[0].ir_size); bus_space_unmap(ia->ia_memt, memh, ia->ia_iomem[0].ir_size);
return; return;
@ -404,7 +406,7 @@ ai_attach(device_t parent, device_t self, void *aux)
IST_EDGE, IPL_NET, i82586_intr, sc); IST_EDGE, IPL_NET, i82586_intr, sc);
if (asc->sc_ih == NULL) { if (asc->sc_ih == NULL) {
DPRINTF(("\n%s: can't establish interrupt\n", DPRINTF(("\n%s: can't establish interrupt\n",
device_xname(&sc->sc_dev))); device_xname(self)));
} }
} }
@ -475,5 +477,5 @@ check_ie_present(struct ie_softc* sc, bus_space_tag_t memt, bus_space_handle_t m
return (size); return (size);
} }
CFATTACH_DECL(ai, sizeof(struct ai_softc), CFATTACH_DECL_NEW(ai, sizeof(struct ai_softc),
ai_match, ai_attach, NULL, NULL); ai_match, ai_attach, NULL, NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ef.c,v 1.30 2009/05/12 09:10:15 cegger Exp $ */ /* $NetBSD: if_ef.c,v 1.31 2011/06/03 16:28:40 tsutsui Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ef.c,v 1.30 2009/05/12 09:10:15 cegger Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ef.c,v 1.31 2011/06/03 16:28:40 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -472,7 +472,7 @@ ef_match(device_t parent, cfdata_t cf, void *aux)
void void
ef_attach(device_t parent, device_t self, void *aux) ef_attach(device_t parent, device_t self, void *aux)
{ {
struct ef_softc *esc = (void *)self; struct ef_softc *esc = device_private(self);
struct ie_softc *sc = &esc->sc_ie; struct ie_softc *sc = &esc->sc_ie;
struct isa_attach_args *ia = aux; struct isa_attach_args *ia = aux;
bus_space_tag_t iot = ia->ia_iot; bus_space_tag_t iot = ia->ia_iot;
@ -484,6 +484,7 @@ ef_attach(device_t parent, device_t self, void *aux)
bus_space_handle_t ioh, memh; bus_space_handle_t ioh, memh;
u_int8_t ethaddr[ETHER_ADDR_LEN]; u_int8_t ethaddr[ETHER_ADDR_LEN];
sc->sc_dev = self;
sc->hwinit = ef_hwinit; sc->hwinit = ef_hwinit;
sc->hwreset = ef_reset; sc->hwreset = ef_reset;
sc->chan_attn = ef_atten; sc->chan_attn = ef_atten;
@ -518,14 +519,14 @@ ef_attach(device_t parent, device_t self, void *aux)
} }
if (bus == NULL) if (bus == NULL)
panic("%s: Can't find parent bus!", device_xname(&sc->sc_dev)); panic("%s: Can't find parent bus!", device_xname(self));
/* If the bus hasn't been transitioned to the RUN state, do so now */ /* If the bus hasn't been transitioned to the RUN state, do so now */
if (bus->bus_state == 1) { if (bus->bus_state == 1) {
if (bus_space_map(iot, ELINK_ID_PORT, 1, 0, &ioh) != 0) { if (bus_space_map(iot, ELINK_ID_PORT, 1, 0, &ioh) != 0) {
DPRINTF(("\n%s: Can't map Elink ID port!\n", DPRINTF(("\n%s: Can't map Elink ID port!\n",
device_xname(&sc->sc_dev))); device_xname(self)));
return; return;
} }
@ -542,7 +543,7 @@ ef_attach(device_t parent, device_t self, void *aux)
ia->ia_io[0].ir_size, 0, &ioh) != 0) { ia->ia_io[0].ir_size, 0, &ioh) != 0) {
DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n", DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n",
device_xname(&sc->sc_dev), ia->ia_io[0].ir_addr, device_xname(self), ia->ia_io[0].ir_addr,
ia->ia_io[0].ir_addr + ia->ia_io[0].ir_size - 1)); ia->ia_io[0].ir_addr + ia->ia_io[0].ir_size - 1));
return; return;
} }
@ -554,7 +555,7 @@ ef_attach(device_t parent, device_t self, void *aux)
ia->ia_iomem[0].ir_size, 0, &memh) != 0) { ia->ia_iomem[0].ir_size, 0, &memh) != 0) {
DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n", DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n",
device_xname(&sc->sc_dev), ia->ia_maddr, device_xname(self), ia->ia_maddr,
ia->ia_maddr + ia->ia_msize - 1)); ia->ia_maddr + ia->ia_msize - 1));
bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size); bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size);
return; return;
@ -592,7 +593,7 @@ ef_attach(device_t parent, device_t self, void *aux)
BUS_SPACE_BARRIER_WRITE); BUS_SPACE_BARRIER_WRITE);
if (!i82586_proberam(sc)) { if (!i82586_proberam(sc)) {
DPRINTF(("\n%s: can't talk to i82586!\n", DPRINTF(("\n%s: can't talk to i82586!\n",
device_xname(&sc->sc_dev))); device_xname(self)));
bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size); bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size);
bus_space_unmap(ia->ia_memt, memh, ia->ia_iomem[0].ir_size); bus_space_unmap(ia->ia_memt, memh, ia->ia_iomem[0].ir_size);
return; return;
@ -644,7 +645,7 @@ ef_attach(device_t parent, device_t self, void *aux)
IST_EDGE, IPL_NET, i82586_intr, sc); IST_EDGE, IPL_NET, i82586_intr, sc);
if (esc->sc_ih == NULL) { if (esc->sc_ih == NULL) {
DPRINTF(("\n%s: can't establish interrupt\n", DPRINTF(("\n%s: can't establish interrupt\n",
device_xname(&sc->sc_dev))); device_xname(self)));
} }
} }
@ -669,6 +670,6 @@ ef_port_check(bus_space_tag_t iot, bus_space_handle_t ioh)
return 1; return 1;
} }
CFATTACH_DECL(ef, sizeof(struct ef_softc), CFATTACH_DECL_NEW(ef, sizeof(struct ef_softc),
ef_match, ef_attach, NULL, NULL); ef_match, ef_attach, NULL, NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ix.c,v 1.33 2009/05/12 09:10:15 cegger Exp $ */ /* $NetBSD: if_ix.c,v 1.34 2011/06/03 16:28:40 tsutsui Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ix.c,v 1.33 2009/05/12 09:10:15 cegger Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ix.c,v 1.34 2011/06/03 16:28:40 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -674,7 +674,7 @@ out:
void void
ix_attach(device_t parent, device_t self, void *aux) ix_attach(device_t parent, device_t self, void *aux)
{ {
struct ix_softc *isc = (void *)self; struct ix_softc *isc = device_private(self);
struct ie_softc *sc = &isc->sc_ie; struct ie_softc *sc = &isc->sc_ie;
struct isa_attach_args *ia = aux; struct isa_attach_args *ia = aux;
@ -688,6 +688,7 @@ ix_attach(device_t parent, device_t self, void *aux)
u_short irq_encoded; u_short irq_encoded;
u_int8_t ethaddr[ETHER_ADDR_LEN]; u_int8_t ethaddr[ETHER_ADDR_LEN];
sc->sc_dev = self;
iot = ia->ia_iot; iot = ia->ia_iot;
/* /*
@ -701,7 +702,7 @@ ix_attach(device_t parent, device_t self, void *aux)
ia->ia_io[0].ir_size, 0, &ioh) != 0) { ia->ia_io[0].ir_size, 0, &ioh) != 0) {
DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n", DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n",
device_xname(&sc->sc_dev), ia->ia_[0].ir_addr, device_xname(self), ia->ia_[0].ir_addr,
ia->ia_io[0].ir_addr + ia->ia_io[0].ir_size - 1)); ia->ia_io[0].ir_addr + ia->ia_io[0].ir_size - 1));
return; return;
} }
@ -711,7 +712,7 @@ ix_attach(device_t parent, device_t self, void *aux)
if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr,
ia->ia_iomem[0].ir_size, 0, &memh) != 0) { ia->ia_iomem[0].ir_size, 0, &memh) != 0) {
DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n", DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n",
device_xname(&sc->sc_dev), ia->ia_iomem[0].ir_addr, device_xname(self), ia->ia_iomem[0].ir_addr,
ia->ia_iomem[0].ir_addr + ia->ia_iomem[0].ir_size - 1)); ia->ia_iomem[0].ir_addr + ia->ia_iomem[0].ir_size - 1));
bus_space_unmap(iot, ioh, ia->ia_io[0].ir_size); bus_space_unmap(iot, ioh, ia->ia_io[0].ir_size);
return; return;
@ -849,7 +850,7 @@ ix_attach(device_t parent, device_t self, void *aux)
/* Memory tests failed, punt... */ /* Memory tests failed, punt... */
if (memsize == 0) { if (memsize == 0) {
DPRINTF(("\n%s: can't determine size of on-card RAM\n", DPRINTF(("\n%s: can't determine size of on-card RAM\n",
device_xname(&sc->sc_dev))); device_xname(self)));
bus_space_unmap(iot, ioh, ia->ia_io[0].ir_size); bus_space_unmap(iot, ioh, ia->ia_io[0].ir_size);
return; return;
} }
@ -913,7 +914,7 @@ ix_attach(device_t parent, device_t self, void *aux)
if (!i82586_proberam(sc)) { if (!i82586_proberam(sc)) {
DPRINTF(("\n%s: Can't talk to i82586!\n", DPRINTF(("\n%s: Can't talk to i82586!\n",
device_xname(&sc->sc_dev))); device_xname(self)));
bus_space_unmap(iot, ioh, ia->ia_io[0].ir_size); bus_space_unmap(iot, ioh, ia->ia_io[0].ir_size);
if (ia->ia_iomem[0].ir_size) if (ia->ia_iomem[0].ir_size)
@ -957,15 +958,15 @@ ix_attach(device_t parent, device_t self, void *aux)
ix_media, NIX_MEDIA, media); ix_media, NIX_MEDIA, media);
if (isc->use_pio) if (isc->use_pio)
aprint_error_dev(&sc->sc_dev, "unsupported memory config, using PIO to access %d bytes of memory\n", sc->sc_msize); aprint_error_dev(self, "unsupported memory config, using PIO to access %d bytes of memory\n", sc->sc_msize);
isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
IST_EDGE, IPL_NET, i82586_intr, sc); IST_EDGE, IPL_NET, i82586_intr, sc);
if (isc->sc_ih == NULL) { if (isc->sc_ih == NULL) {
DPRINTF(("\n%s: can't establish interrupt\n", DPRINTF(("\n%s: can't establish interrupt\n",
device_xname(&sc->sc_dev))); device_xname(self)));
} }
} }
CFATTACH_DECL(ix, sizeof(struct ix_softc), CFATTACH_DECL_NEW(ix, sizeof(struct ix_softc),
ix_match, ix_attach, NULL, NULL); ix_match, ix_attach, NULL, NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_elmc_mca.c,v 1.29 2009/05/12 14:31:00 cegger Exp $ */ /* $NetBSD: if_elmc_mca.c,v 1.30 2011/06/03 16:28:40 tsutsui Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_elmc_mca.c,v 1.29 2009/05/12 14:31:00 cegger Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_elmc_mca.c,v 1.30 2011/06/03 16:28:40 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -144,6 +144,7 @@ elmc_mca_attach(device_t parent, device_t self, void *aux)
return; return;
} }
sc->sc_dev = self;
pbram_addr = ELMC_MADDR_BASE + (((pos2 & 0x18) >> 3) * 0x8000); pbram_addr = ELMC_MADDR_BASE + (((pos2 & 0x18) >> 3) * 0x8000);
printf(" slot %d irq %d: 3Com EtherLink/MC Ethernet Adapter (3C523)\n", printf(" slot %d irq %d: 3Com EtherLink/MC Ethernet Adapter (3C523)\n",
@ -151,7 +152,7 @@ elmc_mca_attach(device_t parent, device_t self, void *aux)
/* map the pio registers */ /* map the pio registers */
if (bus_space_map(ma->ma_iot, iobase, ELMC_IOADDR_SIZE, 0, &ioh)) { if (bus_space_map(ma->ma_iot, iobase, ELMC_IOADDR_SIZE, 0, &ioh)) {
aprint_error_dev(&sc->sc_dev, "unable to map i/o space\n"); aprint_error_dev(self, "unable to map i/o space\n");
return; return;
} }
@ -161,9 +162,9 @@ elmc_mca_attach(device_t parent, device_t self, void *aux)
* about. Just use the first 16K. * about. Just use the first 16K.
*/ */
if (bus_space_map(ma->ma_memt, pbram_addr, ELMC_MADDR_SIZE, 0, &memh)) { if (bus_space_map(ma->ma_memt, pbram_addr, ELMC_MADDR_SIZE, 0, &memh)) {
aprint_error_dev(&sc->sc_dev, "unable to map memory space\n"); aprint_error_dev(self, "unable to map memory space\n");
if (pbram_addr == 0xc0000) { if (pbram_addr == 0xc0000) {
aprint_error_dev(&sc->sc_dev, "memory space 0xc0000 may conflict with vga\n"); aprint_error_dev(self, "memory space 0xc0000 may conflict with vga\n");
} }
bus_space_unmap(ma->ma_iot, ioh, ELMC_IOADDR_SIZE); bus_space_unmap(ma->ma_iot, ioh, ELMC_IOADDR_SIZE);
@ -234,7 +235,7 @@ elmc_mca_attach(device_t parent, device_t self, void *aux)
bus_space_barrier(sc->bt, sc->bh, 0, sc->sc_msize, bus_space_barrier(sc->bt, sc->bh, 0, sc->sc_msize,
BUS_SPACE_BARRIER_WRITE); BUS_SPACE_BARRIER_WRITE);
if (!i82586_proberam(sc)) { if (!i82586_proberam(sc)) {
aprint_error_dev(&sc->sc_dev, "can't talk to i82586!\n"); aprint_error_dev(self, "can't talk to i82586!\n");
bus_space_unmap(asc->sc_regt, asc->sc_regh, ELMC_IOADDR_SIZE); bus_space_unmap(asc->sc_regt, asc->sc_regh, ELMC_IOADDR_SIZE);
bus_space_unmap(sc->bt, sc->bh, ELMC_MADDR_SIZE); bus_space_unmap(sc->bt, sc->bh, ELMC_MADDR_SIZE);
@ -247,7 +248,7 @@ elmc_mca_attach(device_t parent, device_t self, void *aux)
/* dump known info */ /* dump known info */
printf("%s: rev %d, i/o %#04x-%#04x, mem %#06x-%#06x, %sternal xcvr\n", printf("%s: rev %d, i/o %#04x-%#04x, mem %#06x-%#06x, %sternal xcvr\n",
device_xname(&sc->sc_dev), revision, device_xname(self), revision,
iobase, iobase + ELMC_IOADDR_SIZE - 1, iobase, iobase + ELMC_IOADDR_SIZE - 1,
pbram_addr, pbram_addr + ELMC_MADDR_SIZE - 1, pbram_addr, pbram_addr + ELMC_MADDR_SIZE - 1,
(pos2 & 0x20) ? "ex" : "in"); (pos2 & 0x20) ? "ex" : "in");
@ -259,14 +260,14 @@ elmc_mca_attach(device_t parent, device_t self, void *aux)
for(i=0; i < MIN(6, ETHER_ADDR_LEN); i++) for(i=0; i < MIN(6, ETHER_ADDR_LEN); i++)
myaddr[i] = bus_space_read_1(asc->sc_regt, asc->sc_regh, i); myaddr[i] = bus_space_read_1(asc->sc_regt, asc->sc_regh, i);
printf("%s:", device_xname(&sc->sc_dev)); printf("%s:", device_xname(self));
i82586_attach((void *)sc, "3C523", myaddr, NULL, 0, 0); i82586_attach(sc, "3C523", myaddr, NULL, 0, 0);
/* establish interrupt handler */ /* establish interrupt handler */
asc->sc_ih = mca_intr_establish(ma->ma_mc, irq, IPL_NET, i82586_intr, asc->sc_ih = mca_intr_establish(ma->ma_mc, irq, IPL_NET, i82586_intr,
sc); sc);
if (asc->sc_ih == NULL) { if (asc->sc_ih == NULL) {
aprint_error_dev(&sc->sc_dev, "couldn't establish interrupt handler\n"); aprint_error_dev(self, "couldn't establish interrupt handler\n");
return; return;
} }
} }
@ -405,5 +406,5 @@ elmc_mca_intrhook(struct ie_softc *sc, int why)
return (0); return (0);
} }
CFATTACH_DECL(elmc_mca, sizeof(struct elmc_mca_softc), CFATTACH_DECL_NEW(elmc_mca, sizeof(struct elmc_mca_softc),
elmc_mca_match, elmc_mca_attach, NULL, NULL); elmc_mca_match, elmc_mca_attach, NULL, NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ei.c,v 1.16 2009/05/12 14:42:58 cegger Exp $ */ /* $NetBSD: if_ei.c,v 1.17 2011/06/03 16:28:40 tsutsui Exp $ */
/*- /*-
* Copyright (c) 2000, 2001 Ben Harris * Copyright (c) 2000, 2001 Ben Harris
@ -36,7 +36,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ei.c,v 1.16 2009/05/12 14:42:58 cegger Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ei.c,v 1.17 2011/06/03 16:28:40 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
@ -85,7 +85,7 @@ struct ei_softc {
struct evcnt sc_intrcnt; struct evcnt sc_intrcnt;
}; };
CFATTACH_DECL(ei, sizeof(struct ei_softc), CFATTACH_DECL_NEW(ei, sizeof(struct ei_softc),
ei_match, ei_attach, NULL, NULL); ei_match, ei_attach, NULL, NULL);
static inline void static inline void
@ -118,6 +118,8 @@ ei_attach(device_t parent, device_t self, void *aux)
int i; int i;
char descr[16]; char descr[16];
sc->sc_ie.sc_dev = self;
/* Set up bus spaces */ /* Set up bus spaces */
sc->sc_ctl_t = sc->sc_mem_t = pa->pa_fast_t; sc->sc_ctl_t = sc->sc_mem_t = pa->pa_fast_t;
bus_space_map(pa->pa_fast_t, pa->pa_fast_base, EI_MEMOFF, 0, bus_space_map(pa->pa_fast_t, pa->pa_fast_base, EI_MEMOFF, 0,
@ -252,7 +254,7 @@ ei_copyin(struct ie_softc *sc_ie, void *dest, int src, size_t size)
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if (src % 2 != 0 || !ALIGNED_POINTER(dest, u_int16_t)) if (src % 2 != 0 || !ALIGNED_POINTER(dest, u_int16_t))
panic("%s: unaligned copyin", device_xname(&sc_ie->sc_dev)); panic("%s: unaligned copyin", device_xname(sc_ie->sc_dev));
#endif #endif
wptr = dest; wptr = dest;
extra_byte = size % 2; extra_byte = size % 2;
@ -292,13 +294,13 @@ ei_copyout(struct ie_softc *sc_ie, const void *src, int dest, size_t size)
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if (dest % 2 != 0) if (dest % 2 != 0)
panic("%s: unaligned copyout", device_xname(&sc_ie->sc_dev)); panic("%s: unaligned copyout", device_xname(sc_ie->sc_dev));
#endif #endif
if (!ALIGNED_POINTER(src, u_int16_t)) { if (!ALIGNED_POINTER(src, u_int16_t)) {
bounce = (u_int16_t *) malloc(size, M_DEVBUF, M_NOWAIT); bounce = (u_int16_t *) malloc(size, M_DEVBUF, M_NOWAIT);
if (bounce == NULL) if (bounce == NULL)
panic("%s: no memory to align copyout", panic("%s: no memory to align copyout",
device_xname(&sc_ie->sc_dev)); device_xname(sc_ie->sc_dev));
memcpy(bounce, src, size); memcpy(bounce, src, size);
src = bounce; src = bounce;
} }
@ -331,7 +333,7 @@ ei_read16(struct ie_softc *sc_ie, int addr)
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if (addr % 2 != 0) if (addr % 2 != 0)
panic("%s: unaligned read16", device_xname(&sc_ie->sc_dev)); panic("%s: unaligned read16", device_xname(sc_ie->sc_dev));
#endif #endif
s = splnet(); s = splnet();
ei_setpage(sc, ei_atop(addr)); ei_setpage(sc, ei_atop(addr));
@ -349,7 +351,7 @@ ei_write16(struct ie_softc *sc_ie, int addr, u_int16_t value)
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if (addr % 2 != 0) if (addr % 2 != 0)
panic("%s: unaligned write16", device_xname(&sc_ie->sc_dev)); panic("%s: unaligned write16", device_xname(sc_ie->sc_dev));
#endif #endif
s = splnet(); s = splnet();
ei_setpage(sc, ei_atop(addr)); ei_setpage(sc, ei_atop(addr));
@ -365,7 +367,7 @@ ei_write24(struct ie_softc *sc_ie, int addr, int value)
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if (addr % 2 != 0) if (addr % 2 != 0)
panic("%s: unaligned write24", device_xname(&sc_ie->sc_dev)); panic("%s: unaligned write24", device_xname(sc_ie->sc_dev));
#endif #endif
s = splnet(); s = splnet();
ei_write16(sc_ie, addr, value & 0xffff); ei_write16(sc_ie, addr, value & 0xffff);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ie_vme.c,v 1.29 2011/02/01 19:36:24 chuck Exp $ */ /* $NetBSD: if_ie_vme.c,v 1.30 2011/06/03 16:28:41 tsutsui Exp $ */
/* /*
* Copyright (c) 1995 Charles D. Cranor * Copyright (c) 1995 Charles D. Cranor
@ -140,7 +140,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ie_vme.c,v 1.29 2011/02/01 19:36:24 chuck Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_ie_vme.c,v 1.30 2011/06/03 16:28:41 tsutsui Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -239,7 +239,7 @@ struct ie_vme_softc {
bus_space_handle_t ievh; bus_space_handle_t ievh;
}; };
CFATTACH_DECL(ie_vme, sizeof(struct ie_vme_softc), CFATTACH_DECL_NEW(ie_vme, sizeof(struct ie_vme_softc),
ie_vme_match, ie_vme_attach, NULL, NULL); ie_vme_match, ie_vme_attach, NULL, NULL);
#define read_iev(sc, reg) \ #define read_iev(sc, reg) \
@ -291,7 +291,7 @@ ie_vmeintr(struct ie_softc *sc, int where)
* check for parity error * check for parity error
*/ */
if (read_iev(vsc, status) & IEVME_PERR) { if (read_iev(vsc, status) & IEVME_PERR) {
aprint_error_dev(&sc->sc_dev, "parity error (ctrl 0x%x @ 0x%02x%04x)\n", aprint_error_dev(sc->sc_dev, "parity error (ctrl 0x%x @ 0x%02x%04x)\n",
read_iev(vsc, pectrl), read_iev(vsc, pectrl),
read_iev(vsc, pectrl) & IEVME_HADDR, read_iev(vsc, pectrl) & IEVME_HADDR,
read_iev(vsc, peaddr)); read_iev(vsc, peaddr));
@ -459,7 +459,7 @@ void
ie_vme_attach(device_t parent, device_t self, void *aux) ie_vme_attach(device_t parent, device_t self, void *aux)
{ {
u_int8_t myaddr[ETHER_ADDR_LEN]; u_int8_t myaddr[ETHER_ADDR_LEN];
struct ie_vme_softc *vsc = (void *) self; struct ie_vme_softc *vsc = device_private(self);
struct vme_attach_args *va = aux; struct vme_attach_args *va = aux;
vme_chipset_tag_t ct = va->va_vct; vme_chipset_tag_t ct = va->va_vct;
struct ie_softc *sc; struct ie_softc *sc;
@ -484,6 +484,7 @@ ie_vme_attach(device_t parent, device_t self, void *aux)
panic("if_ie: vme alloc"); panic("if_ie: vme alloc");
sc = &vsc->ie; sc = &vsc->ie;
sc->sc_dev = self;
sc->hwreset = ie_vmereset; sc->hwreset = ie_vmereset;
sc->hwinit = ie_vmerun; sc->hwinit = ie_vmerun;