summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authortsutsui <tsutsui@NetBSD.org>2008-04-04 12:25:06 +0000
committertsutsui <tsutsui@NetBSD.org>2008-04-04 12:25:06 +0000
commitd9941582bf2ed3c32007f8d190c32330e9a8eadc (patch)
tree1ceb0a5b06e7dd35e49e0b72d86e03db43264454 /sys/dev
parent960221ac26ae963a388e823d7219f115452067ad (diff)
Split device_t/softc for le(4) and variants and misc cosmetic changes.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/dec/if_le_dec.c32
-rw-r--r--sys/dev/eisa/depca_eisa.c47
-rw-r--r--sys/dev/ic/am7990.c66
-rw-r--r--sys/dev/ic/am79900.c68
-rw-r--r--sys/dev/ic/depca.c62
-rw-r--r--sys/dev/ic/depcavar.h4
-rw-r--r--sys/dev/ic/lance.c166
-rw-r--r--sys/dev/ic/lancevar.h20
-rw-r--r--sys/dev/isa/depca_isa.c34
-rw-r--r--sys/dev/isa/if_le_isa.c114
-rw-r--r--sys/dev/isapnp/if_le_isapnp.c53
-rw-r--r--sys/dev/mca/if_le_mca.c72
-rw-r--r--sys/dev/pci/if_le_pci.c58
-rw-r--r--sys/dev/sbus/if_le.c73
-rw-r--r--sys/dev/sbus/if_le_lebuffer.c48
-rw-r--r--sys/dev/sbus/if_le_ledma.c89
-rw-r--r--sys/dev/tc/if_le_ioasic.c115
-rw-r--r--sys/dev/tc/if_le_tc.c18
18 files changed, 518 insertions, 621 deletions
diff --git a/sys/dev/dec/if_le_dec.c b/sys/dev/dec/if_le_dec.c
index 449843efbfd..6215460d240 100644
--- a/sys/dev/dec/if_le_dec.c
+++ b/sys/dev/dec/if_le_dec.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_dec.c,v 1.18 2007/10/19 11:59:40 ad Exp $ */
+/* $NetBSD: if_le_dec.c,v 1.19 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_dec.c,v 1.18 2007/10/19 11:59:40 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_dec.c,v 1.19 2008/04/04 12:25:07 tsutsui Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -105,7 +105,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_le_dec.c,v 1.18 2007/10/19 11:59:40 ad Exp $");
#include <sys/bus.h>
/* access LANCE registers */
-void le_dec_writereg(volatile u_short *regptr, u_short val);
+void le_dec_writereg(volatile uint16_t *regptr, uint16_t val);
#define LERDWR(cntl, src, dst) { (dst) = (src); tc_mb(); }
#define LEWREG(src, dst) le_dec_writereg(&(dst), (src))
@@ -121,13 +121,11 @@ void le_dec_writereg(volatile u_short *regptr, u_short val);
#define hide static
#endif
-hide void le_dec_wrcsr(struct lance_softc *, u_int16_t, u_int16_t);
-hide u_int16_t le_dec_rdcsr(struct lance_softc *, u_int16_t);
+hide void le_dec_wrcsr(struct lance_softc *, uint16_t, uint16_t);
+hide uint16_t le_dec_rdcsr(struct lance_softc *, uint16_t);
void
-dec_le_common_attach(sc, eap)
- struct am7990_softc *sc;
- u_char *eap;
+dec_le_common_attach(struct am7990_softc *sc, uint8_t *eap)
{
int i;
@@ -151,9 +149,7 @@ dec_le_common_attach(sc, eap)
}
hide void
-le_dec_wrcsr(sc, port, val)
- struct lance_softc *sc;
- u_int16_t port, val;
+le_dec_wrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
{
struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
@@ -161,13 +157,11 @@ le_dec_wrcsr(sc, port, val)
LERDWR(port, val, ler1->ler1_rdp);
}
-hide u_int16_t
-le_dec_rdcsr(sc, port)
- struct lance_softc *sc;
- u_int16_t port;
+hide uint16_t
+le_dec_rdcsr(struct lance_softc *sc, uint16_t port)
{
struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
- u_int16_t val;
+ uint16_t val;
LEWREG(port, ler1->ler1_rap);
LERDWR(0, ler1->ler1_rdp, val);
@@ -180,11 +174,9 @@ le_dec_rdcsr(sc, port)
* pokey sometimes.
*/
void
-le_dec_writereg(regptr, val)
- register volatile u_short *regptr;
- register u_short val;
+le_dec_writereg(volatile uint16_t *regptr, uint16_t val)
{
- register int i = 0;
+ int i = 0;
while (*regptr != val) {
*regptr = val;
diff --git a/sys/dev/eisa/depca_eisa.c b/sys/dev/eisa/depca_eisa.c
index f78c12d8db2..a47b9e30e29 100644
--- a/sys/dev/eisa/depca_eisa.c
+++ b/sys/dev/eisa/depca_eisa.c
@@ -1,4 +1,4 @@
-/* $NetBSD: depca_eisa.c,v 1.10 2007/10/19 11:59:41 ad Exp $ */
+/* $NetBSD: depca_eisa.c,v 1.11 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: depca_eisa.c,v 1.10 2007/10/19 11:59:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: depca_eisa.c,v 1.11 2008/04/04 12:25:07 tsutsui Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -76,8 +76,8 @@ __KERNEL_RCSID(0, "$NetBSD: depca_eisa.c,v 1.10 2007/10/19 11:59:41 ad Exp $");
#include <dev/ic/depcareg.h>
#include <dev/ic/depcavar.h>
-static int depca_eisa_match(struct device *, struct cfdata *, void *);
-static void depca_eisa_attach(struct device *, struct device *, void *);
+static int depca_eisa_match(device_t, cfdata_t, void *);
+static void depca_eisa_attach(device_t, device_t, void *);
struct depca_eisa_softc {
struct depca_softc sc_depca;
@@ -87,14 +87,14 @@ struct depca_eisa_softc {
int sc_ist;
};
-CFATTACH_DECL(depca_eisa, sizeof(struct depca_eisa_softc),
+CFATTACH_DECL_NEW(depca_eisa, sizeof(struct depca_eisa_softc),
depca_eisa_match, depca_eisa_attach, NULL, NULL);
static void *depca_eisa_intr_establish(struct depca_softc *,
struct lance_softc *);
static int
-depca_eisa_match(struct device *parent, struct cfdata *match, void *aux)
+depca_eisa_match(device_t parent, cfdata_t cf, void *aux)
{
struct eisa_attach_args *ea = aux;
@@ -105,15 +105,16 @@ depca_eisa_match(struct device *parent, struct cfdata *match, void *aux)
#define DEPCA_ECU_FUNC_NETBUF 1
static void
-depca_eisa_attach(struct device *parent, struct device *self, void *aux)
+depca_eisa_attach(device_t parent, device_t self, void *aux)
{
- struct depca_softc *sc = device_private(self);
struct depca_eisa_softc *esc = device_private(self);
+ struct depca_softc *sc = &esc->sc_depca;
struct eisa_attach_args *ea = aux;
struct eisa_cfg_mem ecm;
struct eisa_cfg_irq eci;
- printf(": DEC DE422 Ethernet\n");
+ sc->sc_dev = self;
+ aprint_error(": DEC DE422 Ethernet\n");
sc->sc_iot = ea->ea_iot;
sc->sc_memt = ea->ea_memt;
@@ -124,31 +125,29 @@ depca_eisa_attach(struct device *parent, struct device *self, void *aux)
if (eisa_conf_read_mem(ea->ea_ec, ea->ea_slot,
DEPCA_ECU_FUNC_NETBUF, 0, &ecm) != 0) {
- printf("%s: unable to find network buffer\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "unable to find network buffer\n");
return;
}
- printf("%s: shared memory at 0x%lx-0x%lx\n", sc->sc_dev.dv_xname,
+ aprint_normal_dev(self, "shared memory at 0x%lx-0x%lx\n",
ecm.ecm_addr, ecm.ecm_addr + ecm.ecm_size - 1);
sc->sc_memsize = ecm.ecm_size;
if (bus_space_map(sc->sc_iot, EISA_SLOT_ADDR(ea->ea_slot) + 0xc00, 16,
0, &sc->sc_ioh) != 0) {
- printf("%s: unable to map i/o space\n", sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "unable to map i/o space\n");
return;
}
if (bus_space_map(sc->sc_memt, ecm.ecm_addr, sc->sc_memsize,
0, &sc->sc_memh) != 0) {
- printf("%s: unable to map memory space\n", sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "unable to map memory space\n");
return;
}
if (eisa_conf_read_irq(ea->ea_ec, ea->ea_slot,
DEPCA_ECU_FUNC_NETINTR, 0, &eci) != 0) {
- printf("%s: unable to determine IRQ\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "unable to determine IRQ\n");
return;
}
@@ -161,29 +160,29 @@ depca_eisa_attach(struct device *parent, struct device *self, void *aux)
static void *
depca_eisa_intr_establish(struct depca_softc *parent, struct lance_softc *child)
{
- struct depca_eisa_softc *esc = (void *) parent;
+ struct depca_eisa_softc *esc = (struct depca_eisa_softc *)parent;
eisa_intr_handle_t ih;
const char *intrstr;
void *rv;
if (eisa_intr_map(esc->sc_ec, esc->sc_irq, &ih)) {
- printf("%s: unable to map interrupt (%d)\n",
- parent->sc_dev.dv_xname, esc->sc_irq);
+ aprint_error_dev(parent->sc_dev,
+ "unable to map interrupt (%d)\n", esc->sc_irq);
return (NULL);
}
intrstr = eisa_intr_string(esc->sc_ec, ih);
rv = eisa_intr_establish(esc->sc_ec, ih, esc->sc_ist, IPL_NET,
(esc->sc_ist == IST_LEVEL) ? am7990_intr : depca_intredge, child);
if (rv == NULL) {
- printf("%s: unable to establish interrupt",
- parent->sc_dev.dv_xname);
+ aprint_error_dev(parent->sc_dev,
+ "unable to establish interrupt");
if (intrstr != NULL)
- printf(" at %s", intrstr);
- printf("\n");
+ aprint_error(" at %s", intrstr);
+ aprint_error("\n");
return (NULL);
}
if (intrstr != NULL)
- printf("%s: interrupting at %s\n", parent->sc_dev.dv_xname,
+ aprint_normal_dev(parent->sc_dev, "interrupting at %s\n",
intrstr);
return (rv);
diff --git a/sys/dev/ic/am7990.c b/sys/dev/ic/am7990.c
index 6a86bb6401b..c20c60f88d8 100644
--- a/sys/dev/ic/am7990.c
+++ b/sys/dev/ic/am7990.c
@@ -1,4 +1,4 @@
-/* $NetBSD: am7990.c,v 1.69 2007/08/26 22:36:35 dyoung Exp $ */
+/* $NetBSD: am7990.c,v 1.70 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: am7990.c,v 1.69 2007/08/26 22:36:35 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am7990.c,v 1.70 2008/04/04 12:25:07 tsutsui Exp $");
#include "bpfilter.h"
#include "rnd.h"
@@ -157,7 +157,7 @@ am7990_meminit(struct lance_softc *sc)
struct leinit init;
struct lermd rmd;
struct letmd tmd;
- u_int8_t *myaddr;
+ uint8_t *myaddr;
#if NBPFILTER > 0
if (ifp->if_flags & IFF_PROMISC)
@@ -245,25 +245,25 @@ am7990_rint(struct lance_softc *sc)
if ((rmd.rmd1_bits & LE_R1_OFLO) == 0) {
if (rmd.rmd1_bits & LE_R1_FRAM)
printf("%s: framing error\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
if (rmd.rmd1_bits & LE_R1_CRC)
printf("%s: crc mismatch\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
}
#endif
} else {
if (rmd.rmd1_bits & LE_R1_OFLO)
printf("%s: overflow\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
}
if (rmd.rmd1_bits & LE_R1_BUFF)
printf("%s: receive buffer error\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
ifp->if_ierrors++;
} else if ((rmd.rmd1_bits & (LE_R1_STP | LE_R1_ENP)) !=
(LE_R1_STP | LE_R1_ENP)) {
printf("%s: dropping chained buffer\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
ifp->if_ierrors++;
} else {
#ifdef LEDEBUG
@@ -328,9 +328,10 @@ am7990_tint(struct lance_softc *sc)
if (tmd.tmd1_bits & LE_T1_ERR) {
if (tmd.tmd3 & LE_T3_BUFF)
printf("%s: transmit buffer error\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
else if (tmd.tmd3 & LE_T3_UFLO)
- printf("%s: underflow\n", sc->sc_dev.dv_xname);
+ printf("%s: underflow\n",
+ device_xname(sc->sc_dev));
if (tmd.tmd3 & (LE_T3_BUFF | LE_T3_UFLO)) {
lance_reset(sc);
return;
@@ -341,14 +342,14 @@ am7990_tint(struct lance_softc *sc)
(*sc->sc_nocarrier)(sc);
else
printf("%s: lost carrier\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
}
if (tmd.tmd3 & LE_T3_LCOL)
ifp->if_collisions++;
if (tmd.tmd3 & LE_T3_RTRY) {
#ifdef LEDEBUG
printf("%s: excessive collisions, tdr %d\n",
- sc->sc_dev.dv_xname,
+ device_xname(sc->sc_dev),
tmd.tmd3 & LE_T3_TDR_MASK);
#endif
ifp->if_collisions += 16;
@@ -384,14 +385,14 @@ int
am7990_intr(void *arg)
{
struct lance_softc *sc = arg;
- u_int16_t isr;
+ uint16_t isr;
isr = (*sc->sc_rdcsr)(sc, LE_CSR0) | sc->sc_saved_csr0;
sc->sc_saved_csr0 = 0;
#if defined(LEDEBUG) && LEDEBUG > 1
if (sc->sc_debug)
printf("%s: am7990_intr entering with isr=%04x\n",
- sc->sc_dev.dv_xname, isr);
+ device_xname(sc->sc_dev), isr);
#endif
if ((isr & LE_C0_INTR) == 0)
return (0);
@@ -412,37 +413,38 @@ am7990_intr(void *arg)
if (isr & LE_C0_ERR) {
if (isr & LE_C0_BABL) {
#ifdef LEDEBUG
- printf("%s: babble\n", sc->sc_dev.dv_xname);
+ printf("%s: babble\n", device_xname(sc->sc_dev));
#endif
ifp->if_oerrors++;
}
#if 0
if (isr & LE_C0_CERR) {
- printf("%s: collision error\n", sc->sc_dev.dv_xname);
+ printf("%s: collision error\n",
+ device_xname(sc->sc_dev));
ifp->if_collisions++;
}
#endif
if (isr & LE_C0_MISS) {
#ifdef LEDEBUG
- printf("%s: missed packet\n", sc->sc_dev.dv_xname);
+ printf("%s: missed packet\n", device_xname(sc->sc_dev));
#endif
ifp->if_ierrors++;
}
if (isr & LE_C0_MERR) {
- printf("%s: memory error\n", sc->sc_dev.dv_xname);
+ printf("%s: memory error\n", device_xname(sc->sc_dev));
lance_reset(sc);
return (1);
}
}
if ((isr & LE_C0_RXON) == 0) {
- printf("%s: receiver disabled\n", sc->sc_dev.dv_xname);
+ printf("%s: receiver disabled\n", device_xname(sc->sc_dev));
ifp->if_ierrors++;
lance_reset(sc);
return (1);
}
if ((isr & LE_C0_TXON) == 0) {
- printf("%s: transmitter disabled\n", sc->sc_dev.dv_xname);
+ printf("%s: transmitter disabled\n", device_xname(sc->sc_dev));
ifp->if_oerrors++;
lance_reset(sc);
return (1);
@@ -558,21 +560,21 @@ static void
am7990_recv_print(struct lance_softc *sc, int no)
{
struct lermd rmd;
- u_int16_t len;
+ uint16_t len;
struct ether_header eh;
(*sc->sc_copyfromdesc)(sc, &rmd, LE_RMDADDR(sc, no), sizeof(rmd));
len = rmd.rmd3;
- printf("%s: receive buffer %d, len = %d\n", sc->sc_dev.dv_xname, no,
- len);
- printf("%s: status %04x\n", sc->sc_dev.dv_xname,
+ printf("%s: receive buffer %d, len = %d\n",
+ device_xname(sc->sc_dev), no, len);
+ printf("%s: status %04x\n", device_xname(sc->sc_dev),
(*sc->sc_rdcsr)(sc, LE_CSR0));
printf("%s: ladr %04x, hadr %02x, flags %02x, bcnt %04x, mcnt %04x\n",
- sc->sc_dev.dv_xname,
+ device_xname(sc->sc_dev),
rmd.rmd0, rmd.rmd1_hadr, rmd.rmd1_bits, rmd.rmd2, rmd.rmd3);
if (len >= sizeof(eh)) {
(*sc->sc_copyfrombuf)(sc, &eh, LE_RBUFADDR(sc, no), sizeof(eh));
- printf("%s: dst %s", sc->sc_dev.dv_xname,
+ printf("%s: dst %s", device_xname(sc->sc_dev),
ether_sprintf(eh.ether_dhost));
printf(" src %s type %04x\n", ether_sprintf(eh.ether_shost),
ntohs(eh.ether_type));
@@ -583,21 +585,21 @@ static void
am7990_xmit_print(struct lance_softc *sc, int no)
{
struct letmd tmd;
- u_int16_t len;
+ uint16_t len;
struct ether_header eh;
(*sc->sc_copyfromdesc)(sc, &tmd, LE_TMDADDR(sc, no), sizeof(tmd));
len = -tmd.tmd2;
- printf("%s: transmit buffer %d, len = %d\n", sc->sc_dev.dv_xname, no,
- len);
- printf("%s: status %04x\n", sc->sc_dev.dv_xname,
+ printf("%s: transmit buffer %d, len = %d\n",
+ device_xname(sc->sc_dev), no, len);
+ printf("%s: status %04x\n", device_xname(sc->sc_dev),
(*sc->sc_rdcsr)(sc, LE_CSR0));
printf("%s: ladr %04x, hadr %02x, flags %02x, bcnt %04x, mcnt %04x\n",
- sc->sc_dev.dv_xname,
+ device_xname(sc->sc_dev),
tmd.tmd0, tmd.tmd1_hadr, tmd.tmd1_bits, tmd.tmd2, tmd.tmd3);
if (len >= sizeof(eh)) {
(*sc->sc_copyfrombuf)(sc, &eh, LE_TBUFADDR(sc, no), sizeof(eh));
- printf("%s: dst %s", sc->sc_dev.dv_xname,
+ printf("%s: dst %s", device_xname(sc->sc_dev),
ether_sprintf(eh.ether_dhost));
printf(" src %s type %04x\n", ether_sprintf(eh.ether_shost),
ntohs(eh.ether_type));
diff --git a/sys/dev/ic/am79900.c b/sys/dev/ic/am79900.c
index ab96e2b20bc..00b4f23898f 100644
--- a/sys/dev/ic/am79900.c
+++ b/sys/dev/ic/am79900.c
@@ -1,4 +1,4 @@
-/* $NetBSD: am79900.c,v 1.18 2007/08/26 22:36:36 dyoung Exp $ */
+/* $NetBSD: am79900.c,v 1.19 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -110,7 +110,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: am79900.c,v 1.18 2007/08/26 22:36:36 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am79900.c,v 1.19 2008/04/04 12:25:07 tsutsui Exp $");
#include "bpfilter.h"
#include "rnd.h"
@@ -180,7 +180,7 @@ am79900_config(struct am79900_softc *sc)
sc->lsc.sc_tbufaddr[i] = mem;
if (mem > sc->lsc.sc_memsize)
- panic("%s: memsize", sc->lsc.sc_dev.dv_xname);
+ panic("%s: memsize", device_xname(sc->lsc.sc_dev));
}
/*
@@ -194,7 +194,7 @@ am79900_meminit(struct lance_softc *sc)
struct leinit init;
struct lermd rmd;
struct letmd tmd;
- u_int8_t *myaddr;
+ uint8_t *myaddr;
#if NBPFILTER > 0
if (ifp->if_flags & IFF_PROMISC)
@@ -281,25 +281,25 @@ am79900_rint(struct lance_softc *sc)
if ((rmd.rmd1 & LE_R1_OFLO) == 0) {
if (rmd.rmd1 & LE_R1_FRAM)
printf("%s: framing error\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
if (rmd.rmd1 & LE_R1_CRC)
printf("%s: crc mismatch\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
}
#endif
} else {
if (rmd.rmd1 & LE_R1_OFLO)
printf("%s: overflow\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
}
if (rmd.rmd1 & LE_R1_BUFF)
printf("%s: receive buffer error\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
ifp->if_ierrors++;
} else if ((rmd.rmd1 & (LE_R1_STP | LE_R1_ENP)) !=
(LE_R1_STP | LE_R1_ENP)) {
printf("%s: dropping chained buffer\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
ifp->if_ierrors++;
} else {
#ifdef LEDEBUG
@@ -360,9 +360,10 @@ am79900_tint(struct lance_softc *sc)
if (tmd.tmd1 & LE_T1_ERR) {
if (tmd.tmd2 & LE_T2_BUFF)
printf("%s: transmit buffer error\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
else if (tmd.tmd2 & LE_T2_UFLO)
- printf("%s: underflow\n", sc->sc_dev.dv_xname);
+ printf("%s: underflow\n",
+ device_xname(sc->sc_dev));
if (tmd.tmd2 & (LE_T2_BUFF | LE_T2_UFLO)) {
lance_reset(sc);
return;
@@ -373,14 +374,14 @@ am79900_tint(struct lance_softc *sc)
(*sc->sc_nocarrier)(sc);
else
printf("%s: lost carrier\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
}
if (tmd.tmd2 & LE_T2_LCOL)
ifp->if_collisions++;
if (tmd.tmd2 & LE_T2_RTRY) {
#ifdef LEDEBUG
printf("%s: excessive collisions\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
#endif
ifp->if_collisions += 16;
}
@@ -415,14 +416,14 @@ int
am79900_intr(void *arg)
{
struct lance_softc *sc = arg;
- u_int16_t isr;
+ uint16_t isr;
isr = (*sc->sc_rdcsr)(sc, LE_CSR0) | sc->sc_saved_csr0;
sc->sc_saved_csr0 = 0;
#if defined(LEDEBUG) && LEDEBUG > 1
if (sc->sc_debug)
printf("%s: am79900_intr entering with isr=%04x\n",
- sc->sc_dev.dv_xname, isr);
+ device_xname(sc->sc_dev), isr);
#endif
if ((isr & LE_C0_INTR) == 0)
return (0);
@@ -433,37 +434,38 @@ am79900_intr(void *arg)
if (isr & LE_C0_ERR) {
if (isr & LE_C0_BABL) {
#ifdef LEDEBUG
- printf("%s: babble\n", sc->sc_dev.dv_xname);
+ printf("%s: babble\n", device_xname(sc->sc_dev));
#endif
ifp->if_oerrors++;
}
#if 0
if (isr & LE_C0_CERR) {
- printf("%s: collision error\n", sc->sc_dev.dv_xname);
+ printf("%s: collision error\n",
+ device_xname(sc->sc_dev));
ifp->if_collisions++;
}
#endif
if (isr & LE_C0_MISS) {
#ifdef LEDEBUG
- printf("%s: missed packet\n", sc->sc_dev.dv_xname);
+ printf("%s: missed packet\n", device_xname(sc->sc_dev));
#endif
ifp->if_ierrors++;
}
if (isr & LE_C0_MERR) {
- printf("%s: memory error\n", sc->sc_dev.dv_xname);
+ printf("%s: memory error\n", device_xname(sc->sc_dev));
lance_reset(sc);
return (1);
}
}
if ((isr & LE_C0_RXON) == 0) {
- printf("%s: receiver disabled\n", sc->sc_dev.dv_xname);
+ printf("%s: receiver disabled\n", device_xname(sc->sc_dev));
ifp->if_ierrors++;
lance_reset(sc);
return (1);
}
if ((isr & LE_C0_TXON) == 0) {
- printf("%s: transmitter disabled\n", sc->sc_dev.dv_xname);
+ printf("%s: transmitter disabled\n", device_xname(sc->sc_dev));
ifp->if_oerrors++;
lance_reset(sc);
return (1);
@@ -579,20 +581,20 @@ static void
am79900_recv_print(struct lance_softc *sc, int no)
{
struct lermd rmd;
- u_int16_t len;
+ uint16_t len;
struct ether_header eh;
(*sc->sc_copyfromdesc)(sc, &rmd, LE_RMDADDR(sc, no), sizeof(rmd));
len = (rmd.rmd2 & 0xfff) - 4;
- printf("%s: receive buffer %d, len = %d\n", sc->sc_dev.dv_xname, no,
- len);
- printf("%s: status %04x\n", sc->sc_dev.dv_xname,
+ printf("%s: receive buffer %d, len = %d\n",
+ device_xname(sc->sc_dev), no, len);
+ printf("%s: status %04x\n", device_xname(sc->sc_dev),
(*sc->sc_rdcsr)(sc, LE_CSR0));
printf("%s: adr %08x, flags/blen %08x\n",
- sc->sc_dev.dv_xname, rmd.rmd0, rmd.rmd1);
+ device_xname(sc->sc_dev), rmd.rmd0, rmd.rmd1);
if (len >= sizeof(eh)) {
(*sc->sc_copyfrombuf)(sc, &eh, LE_RBUFADDR(sc, no), sizeof(eh));
- printf("%s: dst %s", sc->sc_dev.dv_xname,
+ printf("%s: dst %s", device_xname(sc->sc_dev),
ether_sprintf(eh.ether_dhost));
printf(" src %s type %04x\n", ether_sprintf(eh.ether_shost),
ntohs(eh.ether_type));
@@ -603,20 +605,20 @@ static void
am79900_xmit_print(struct lance_softc *sc, int no)
{
struct letmd tmd;
- u_int16_t len;
+ uint16_t len;
struct ether_header eh;
(*sc->sc_copyfromdesc)(sc, &tmd, LE_TMDADDR(sc, no), sizeof(tmd));
len = -(tmd.tmd1 & 0xfff);
- printf("%s: transmit buffer %d, len = %d\n", sc->sc_dev.dv_xname, no,
- len);
- printf("%s: status %04x\n", sc->sc_dev.dv_xname,
+ printf("%s: transmit buffer %d, len = %d\n",
+ device_xname(sc->sc_dev), no, len);
+ printf("%s: status %04x\n", device_xname(sc->sc_dev),
(*sc->sc_rdcsr)(sc, LE_CSR0));
printf("%s: adr %08x, flags/blen %08x\n",
- sc->sc_dev.dv_xname, tmd.tmd0, tmd.tmd1);
+ device_xname(sc->sc_dev), tmd.tmd0, tmd.tmd1);
if (len >= sizeof(eh)) {
(*sc->sc_copyfrombuf)(sc, &eh, LE_TBUFADDR(sc, no), sizeof(eh));
- printf("%s: dst %s", sc->sc_dev.dv_xname,
+ printf("%s: dst %s", device_xname(sc->sc_dev),
ether_sprintf(eh.ether_dhost));
printf(" src %s type %04x\n", ether_sprintf(eh.ether_shost),
ntohs(eh.ether_type));
diff --git a/sys/dev/ic/depca.c b/sys/dev/ic/depca.c
index e63ac8ebce7..994830f8ea4 100644
--- a/sys/dev/ic/depca.c
+++ b/sys/dev/ic/depca.c
@@ -1,4 +1,4 @@
-/* $NetBSD: depca.c,v 1.15 2007/10/19 11:59:50 ad Exp $ */
+/* $NetBSD: depca.c,v 1.16 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: depca.c,v 1.15 2007/10/19 11:59:50 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: depca.c,v 1.16 2008/04/04 12:25:07 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -105,10 +105,10 @@ struct le_depca_softc {
void *sc_ih;
};
-int le_depca_match(struct device *, struct cfdata *, void *);
-void le_depca_attach(struct device *, struct device *, void *);
+int le_depca_match(device_t, cfdata_t, void *);
+void le_depca_attach(device_t, device_t, void *);
-CFATTACH_DECL(le_depca, sizeof(struct le_depca_softc),
+CFATTACH_DECL_NEW(le_depca, sizeof(struct le_depca_softc),
le_depca_match, le_depca_attach, NULL, NULL);
void depca_copytobuf(struct lance_softc *, void *, int, int);
@@ -128,7 +128,7 @@ depca_attach(struct depca_softc *sc)
da.da_name = "le";
- (void) config_found(&sc->sc_dev, &da, depca_print);
+ (void)config_found(sc->sc_dev, &da, depca_print);
}
int
@@ -143,25 +143,25 @@ depca_print(void *aux, const char *pnp)
}
void
-depca_wrcsr(struct lance_softc *sc, u_int16_t port, u_int16_t val)
+depca_wrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
{
- struct depca_softc *dsc = (void *) device_parent(&sc->sc_dev);
+ struct depca_softc *dsc = device_private(device_parent(sc->sc_dev));
bus_space_write_2(dsc->sc_iot, dsc->sc_ioh, DEPCA_RAP, port);
bus_space_write_2(dsc->sc_iot, dsc->sc_ioh, DEPCA_RDP, val);
}
-u_int16_t
-depca_rdcsr(struct lance_softc *sc, u_int16_t port)
+uint16_t
+depca_rdcsr(struct lance_softc *sc, uint16_t port)
{
- struct depca_softc *dsc = (void *) device_parent(&sc->sc_dev);
+ struct depca_softc *dsc = device_private(device_parent(sc->sc_dev));
bus_space_write_2(dsc->sc_iot, dsc->sc_ioh, DEPCA_RAP, port);
return (bus_space_read_2(dsc->sc_iot, dsc->sc_ioh, DEPCA_RDP));
}
int
-depca_readprom(bus_space_tag_t iot, bus_space_handle_t ioh, u_int8_t *laddr)
+depca_readprom(bus_space_tag_t iot, bus_space_handle_t ioh, uint8_t *laddr)
{
int port, i;
@@ -200,7 +200,7 @@ depca_readprom(bus_space_tag_t iot, bus_space_handle_t ioh, u_int8_t *laddr)
bus_space_read_1(iot, ioh, port) == 0x55 &&
bus_space_read_1(iot, ioh, port) == 0xaa)
goto found;
- printf("depca: address not found\n");
+ aprint_error("depca: address not found\n");
return (-1);
found:
@@ -225,8 +225,8 @@ found:
rom_sum |= bus_space_read_1(iot, ioh, port) << 8;
if (sum != rom_sum) {
- printf("depca: checksum mismatch; calculated %04x != read %04x",
- sum, rom_sum);
+ aprint_error("depca: checksum mismatch; "
+ "calculated %04x != read %04x", sum, rom_sum);
return (-1);
}
#endif
@@ -235,28 +235,29 @@ found:
}
int
-le_depca_match(struct device *parent, struct cfdata *match, void *aux)
+le_depca_match(device_t parent, cfdata_t cf, void *aux)
{
struct depca_attach_args *da = aux;
- return (strcmp(da->da_name, match->cf_name) == 0);
+ return (strcmp(da->da_name, cf->cf_name) == 0);
}
void
-le_depca_attach(struct device *parent, struct device *self, void *aux)
+le_depca_attach(device_t parent, device_t self, void *aux)
{
- struct depca_softc *dsc = (void *) parent;
- struct le_depca_softc *lesc = (void *) self;
+ struct depca_softc *dsc = device_private(parent);
+ struct le_depca_softc *lesc = device_private(self);
struct lance_softc *sc = &lesc->sc_am7990.lsc;
- u_int8_t val;
+ uint8_t val;
int i;
- printf("\n");
+ sc->sc_dev = self;
+ aprint_error("\n");
/* I/O and memory spaces already mapped. */
if (depca_readprom(dsc->sc_iot, dsc->sc_ioh, sc->sc_enaddr)) {
- printf("%s: can't read PROM\n", self->dv_xname);
+ aprint_error_dev(self, "can't read PROM\n");
return;
}
@@ -266,16 +267,17 @@ le_depca_attach(struct device *parent, struct device *self, void *aux)
val = 0xff;
for (;;) {
- u_int8_t cv;
+ uint8_t cv;
bus_space_set_region_1(dsc->sc_memt, dsc->sc_memh, 0, val,
dsc->sc_memsize);
for (i = 0; i < dsc->sc_memsize; i++) {
cv = bus_space_read_1(dsc->sc_memt, dsc->sc_memh, i);
if (cv != val) {
- printf("%s: failed to clear memory at %d "
+ aprint_error_dev(self,
+ "failed to clear memory at %d "
"(0x%02x != 0x%02x)\n",
- sc->sc_dev.dv_xname, i, cv, val);
+ i, cv, val);
return;
}
}
@@ -299,7 +301,7 @@ le_depca_attach(struct device *parent, struct device *self, void *aux)
sc->sc_wrcsr = depca_wrcsr;
sc->sc_hwinit = NULL;
- printf("%s", sc->sc_dev.dv_xname);
+ aprint_error("%s", device_xname(self));
am7990_config(&lesc->sc_am7990);
lesc->sc_ih = (*dsc->sc_intr_establish)(dsc, sc);
@@ -326,7 +328,7 @@ depca_intredge(void *arg)
void
depca_copytobuf(struct lance_softc *sc, void *from, int boff, int len)
{
- struct depca_softc *dsc = (void *) device_parent(&sc->sc_dev);
+ struct depca_softc *dsc = device_private(device_parent(sc->sc_dev));
bus_space_write_region_1(dsc->sc_memt, dsc->sc_memh, boff,
from, len);
@@ -335,7 +337,7 @@ depca_copytobuf(struct lance_softc *sc, void *from, int boff, int len)
void
depca_copyfrombuf(struct lance_softc *sc, void *to, int boff, int len)
{
- struct depca_softc *dsc = (void *) device_parent(&sc->sc_dev);
+ struct depca_softc *dsc = device_private(device_parent(sc->sc_dev));
bus_space_read_region_1(dsc->sc_memt, dsc->sc_memh, boff,
to, len);
@@ -344,7 +346,7 @@ depca_copyfrombuf(struct lance_softc *sc, void *to, int boff, int len)
void
depca_zerobuf(struct lance_softc *sc, int boff, int len)
{
- struct depca_softc *dsc = (void *) device_parent(&sc->sc_dev);
+ struct depca_softc *dsc = device_private(device_parent(sc->sc_dev));
bus_space_set_region_1(dsc->sc_memt, dsc->sc_memh, boff,
0x00, len);
diff --git a/sys/dev/ic/depcavar.h b/sys/dev/ic/depcavar.h
index 5ebd1fc0d74..8f71c73dbc3 100644
--- a/sys/dev/ic/depcavar.h
+++ b/sys/dev/ic/depcavar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: depcavar.h,v 1.4 2005/12/11 12:21:26 christos Exp $ */
+/* $NetBSD: depcavar.h,v 1.5 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
*/
struct depca_softc {
- struct device sc_dev; /* base device */
+ device_t sc_dev; /* base device */
bus_space_tag_t sc_iot;
bus_space_tag_t sc_memt;
diff --git a/sys/dev/ic/lance.c b/sys/dev/ic/lance.c
index 9df40a0afdc..741436401b7 100644
--- a/sys/dev/ic/lance.c
+++ b/sys/dev/ic/lance.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lance.c,v 1.39 2007/09/01 07:32:26 dyoung Exp $ */
+/* $NetBSD: lance.c,v 1.40 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lance.c,v 1.39 2007/09/01 07:32:26 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lance.c,v 1.40 2008/04/04 12:25:07 tsutsui Exp $");
#include "bpfilter.h"
#include "rnd.h"
@@ -143,13 +143,12 @@ void lance_watchdog(struct ifnet *);
* Please do NOT tweak this without looking at the actual
* assembly code generated before and after your tweaks!
*/
-static inline u_int16_t
-ether_cmp(one, two)
- void *one, *two;
+static inline uint16_t
+ether_cmp(void *one, void *two)
{
- u_int16_t *a = (u_short *) one;
- u_int16_t *b = (u_short *) two;
- u_int16_t diff;
+ uint16_t *a = (uint16_t *)one;
+ uint16_t *b = (uint16_t *)two;
+ uint16_t diff;
#ifdef m68k
/*
@@ -176,18 +175,17 @@ ether_cmp(one, two)
#ifdef LANCE_REVC_BUG
/* Make sure this is short-aligned, for ether_cmp(). */
-static u_int16_t bcast_enaddr[3] = { ~0, ~0, ~0 };
+static uint16_t bcast_enaddr[3] = { ~0, ~0, ~0 };
#endif
void
-lance_config(sc)
- struct lance_softc *sc;
+lance_config(struct lance_softc *sc)
{
int i, nbuf;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
/* Initialize ifnet structure. */
- strcpy(ifp->if_xname, sc->sc_dev.dv_xname);
+ strcpy(ifp->if_xname, device_xname(sc->sc_dev));
ifp->if_softc = sc;
ifp->if_start = sc->sc_start;
ifp->if_ioctl = lance_ioctl;
@@ -245,9 +243,10 @@ lance_config(sc)
sc->sc_nrbuf = nbuf - sc->sc_ntbuf;
}
- printf(": address %s\n", ether_sprintf(sc->sc_enaddr));
- printf("%s: %d receive buffers, %d transmit buffers\n",
- sc->sc_dev.dv_xname, sc->sc_nrbuf, sc->sc_ntbuf);
+ aprint_normal(": address %s\n", ether_sprintf(sc->sc_enaddr));
+ aprint_normal_dev(sc->sc_dev,
+ "%d receive buffers, %d transmit buffers\n",
+ sc->sc_nrbuf, sc->sc_ntbuf);
/* Make sure the chip is stopped. */
lance_stop(ifp, 0);
@@ -267,14 +266,13 @@ lance_config(sc)
M_WAITOK);
#if NRND > 0
- rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
+ rnd_attach_source(&sc->rnd_source, device_xname(sc->sc_dev),
RND_TYPE_NET, 0);
#endif
}
void
-lance_reset(sc)
- struct lance_softc *sc;
+lance_reset(struct lance_softc *sc)
{
int s;
@@ -296,8 +294,7 @@ lance_stop(struct ifnet *ifp, int disable)
* and transmit/receive descriptor rings.
*/
int
-lance_init(ifp)
- struct ifnet *ifp;
+lance_init(struct ifnet *ifp)
{
struct lance_softc *sc = ifp->if_softc;
int timo;
@@ -339,7 +336,7 @@ lance_init(ifp)
(*sc->sc_start)(ifp);
} else
printf("%s: controller failed to initialize\n",
- sc->sc_dev.dv_xname);
+ device_xname(sc->sc_dev));
if (sc->sc_hwinit)
(*sc->sc_hwinit)(sc);
@@ -351,10 +348,7 @@ lance_init(ifp)
* network buffer memory.
*/
int
-lance_put(sc, boff, m)
- struct lance_softc *sc;
- int boff;
- struct mbuf *m;
+lance_put(struct lance_softc *sc, int boff, struct mbuf *m)
{
struct mbuf *n;
int len, tlen = 0;
@@ -384,9 +378,7 @@ lance_put(sc, boff, m)
* we copy into clusters.
*/
integrate struct mbuf *
-lance_get(sc, boff, totlen)
- struct lance_softc *sc;
- int boff, totlen;
+lance_get(struct lance_softc *sc, int boff, int totlen)
{
struct mbuf *m, *m0, *newm;
int len;
@@ -440,9 +432,7 @@ bad:
* Pass a packet to the higher levels.
*/
void
-lance_read(sc, boff, len)
- struct lance_softc *sc;
- int boff, len;
+lance_read(struct lance_softc *sc, int boff, int len)
{
struct mbuf *m;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
@@ -454,7 +444,7 @@ lance_read(sc, boff, len)
ETHERMTU + sizeof(struct ether_header))) {
#ifdef LEDEBUG
printf("%s: invalid packet size %d; dropping\n",
- sc->sc_dev.dv_xname, len);
+ device_xname(sc->sc_dev), len);
#endif
ifp->if_ierrors++;
return;
@@ -511,20 +501,18 @@ lance_read(sc, boff, len)
#undef ifp
void
-lance_watchdog(ifp)
- struct ifnet *ifp;
+lance_watchdog(struct ifnet *ifp)
{
struct lance_softc *sc = ifp->if_softc;
- log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
+ log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev));
++ifp->if_oerrors;
lance_reset(sc);
}
int
-lance_mediachange(ifp)
- struct ifnet *ifp;
+lance_mediachange(struct ifnet *ifp)
{
struct lance_softc *sc = ifp->if_softc;
@@ -534,9 +522,7 @@ lance_mediachange(ifp)
}
void
-lance_mediastatus(ifp, ifmr)
- struct ifnet *ifp;
- struct ifmediareq *ifmr;
+lance_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
{
struct lance_softc *sc = ifp->if_softc;
@@ -555,10 +541,7 @@ lance_mediastatus(ifp, ifmr)
* Process an ioctl request.
*/
int
-lance_ioctl(ifp, cmd, data)
- struct ifnet *ifp;
- u_long cmd;
- void *data;
+lance_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct lance_softc *sc = ifp->if_softc;
struct ifreq *ifr = (struct ifreq *)data;
@@ -599,8 +582,7 @@ lance_ioctl(ifp, cmd, data)
}
hide void
-lance_shutdown(arg)
- void *arg;
+lance_shutdown(void *arg)
{
lance_stop((struct ifnet *)arg, 0);
@@ -610,13 +592,11 @@ lance_shutdown(arg)
* Set up the logical address filter.
*/
void
-lance_setladrf(ac, af)
- struct ethercom *ac;
- u_int16_t *af;
+lance_setladrf(struct ethercom *ac, uint16_t *af)
{
struct ifnet *ifp = &ac->ec_if;
struct ether_multi *enm;
- u_int32_t crc;
+ uint32_t crc;
struct ether_multistep step;
/*
@@ -680,12 +660,9 @@ allmulti:
*/
void
-lance_copytobuf_contig(sc, from, boff, len)
- struct lance_softc *sc;
- void *from;
- int boff, len;
+lance_copytobuf_contig(struct lance_softc *sc, void *from, int boff, int len)
{
- char *buf = sc->sc_mem;
+ uint8_t *buf = sc->sc_mem;
/*
* Just call memcpy() to do the work.
@@ -694,12 +671,9 @@ lance_copytobuf_contig(sc, from, boff, len)
}
void
-lance_copyfrombuf_contig(sc, to, boff, len)
- struct lance_softc *sc;
- void *to;
- int boff, len;
+lance_copyfrombuf_contig(struct lance_softc *sc, void *to, int boff, int len)
{
- char *buf = sc->sc_mem;
+ uint8_t *buf = sc->sc_mem;
/*
* Just call memcpy() to do the work.
@@ -708,11 +682,9 @@ lance_copyfrombuf_contig(sc, to, boff, len)
}
void
-lance_zerobuf_contig(sc, boff, len)
- struct lance_softc *sc;
- int boff, len;
+lance_zerobuf_contig(struct lance_softc *sc, int boff, int len)
{
- char *buf = sc->sc_mem;
+ uint8_t *buf = sc->sc_mem;
/*
* Just let memset() do the work
@@ -734,24 +706,20 @@ lance_zerobuf_contig(sc, boff, len)
*/
void
-lance_copytobuf_gap2(sc, fromv, boff, len)
- struct lance_softc *sc;
- void *fromv;
- int boff;
- int len;
+lance_copytobuf_gap2(struct lance_softc *sc, void *fromv, int boff, int len)
{
volatile void *buf = sc->sc_mem;
void *from = fromv;
- volatile u_int16_t *bptr;
+ volatile uint16_t *bptr;
if (boff & 0x1) {
/* handle unaligned first byte */
- bptr = ((volatile u_int16_t *)buf) + (boff - 1);
+ bptr = ((volatile uint16_t *)buf) + (boff - 1);
*bptr = (*from++ << 8) | (*bptr & 0xff);
bptr += 2;
len--;
} else
- bptr = ((volatile u_int16_t *)buf) + boff;
+ bptr = ((volatile uint16_t *)buf) + boff;
while (len > 1) {
*bptr = (from[1] << 8) | (from[0] & 0xff);
bptr += 2;
@@ -759,28 +727,25 @@ lance_copytobuf_gap2(sc, fromv, boff, len)
len -= 2;
}
if (len == 1)
- *bptr = (u_int16_t)*from;
+ *bptr = (uint16_t)*from;
}
void
-lance_copyfrombuf_gap2(sc, tov, boff, len)
- struct lance_softc *sc;
- void *tov;
- int boff, len;
+lance_copyfrombuf_gap2(struct lance_softc *sc, void *tov, int boff, int len)
{
volatile void *buf = sc->sc_mem;
void *to = tov;
- volatile u_int16_t *bptr;
- u_int16_t tmp;
+ volatile uint16_t *bptr;
+ uint16_t tmp;
if (boff & 0x1) {
/* handle unaligned first byte */
- bptr = ((volatile u_int16_t *)buf) + (boff - 1);
+ bptr = ((volatile uint16_t *)buf) + (boff - 1);
*to++ = (*bptr >> 8) & 0xff;
bptr += 2;
len--;
} else
- bptr = ((volatile u_int16_t *)buf) + boff;
+ bptr = ((volatile uint16_t *)buf) + boff;
while (len > 1) {
tmp = *bptr;
*to++ = tmp & 0xff;
@@ -793,20 +758,18 @@ lance_copyfrombuf_gap2(sc, tov, boff, len)
}
void
-lance_zerobuf_gap2(sc, boff, len)
- struct lance_softc *sc;
- int boff, len;
+lance_zerobuf_gap2(struct lance_softc *sc, int boff, int len)
{
volatile void *buf = sc->sc_mem;
- volatile u_int16_t *bptr;
+ volatile uint16_t *bptr;
- if ((unsigned)boff & 0x1) {
- bptr = ((volatile u_int16_t *)buf) + (boff - 1);
+ if ((unsigned int)boff & 0x1) {
+ bptr = ((volatile uint16_t *)buf) + (boff - 1);
*bptr &= 0xff;
bptr += 2;
len--;
} else
- bptr = ((volatile u_int16_t *)buf) + boff;
+ bptr = ((volatile uint16_t *)buf) + boff;
while (len > 0) {
*bptr = 0;
bptr += 2;
@@ -821,15 +784,11 @@ lance_zerobuf_gap2(sc, boff, len)
*/
void
-lance_copytobuf_gap16(sc, fromv, boff, len)
- struct lance_softc *sc;
- void *fromv;
- int boff;
- int len;
+lance_copytobuf_gap16(struct lance_softc *sc, void *fromv, int boff, int len)
{
- volatile void *buf = sc->sc_mem;
+ volatile uint8_t *buf = sc->sc_mem;
void *from = fromv;
- void *bptr;
+ uint8_t *bptr;
int xfer;
bptr = buf + ((boff << 1) & ~0x1f);
@@ -846,14 +805,11 @@ lance_copytobuf_gap16(sc, fromv, boff, len)
}
void
-lance_copyfrombuf_gap16(sc, tov, boff, len)
- struct lance_softc *sc;
- void *tov;
- int boff, len;
+lance_copyfrombuf_gap16(struct lance_softc *sc, void *tov, int boff, int len)
{
- volatile void *buf = sc->sc_mem;
+ volatile uint8_t *buf = sc->sc_mem;
void *to = tov;
- void *bptr;
+ uint8_t *bptr;
int xfer;
bptr = buf + ((boff << 1) & ~0x1f);
@@ -870,12 +826,10 @@ lance_copyfrombuf_gap16(sc, tov, boff, len)
}
void
-lance_zerobuf_gap16(sc, boff, len)
- struct lance_softc *sc;
- int boff, len;
+lance_zerobuf_gap16(struct lance_softc *sc, int boff, int len)
{
- volatile void *buf = sc->sc_mem;
- void *bptr;
+ volatile uint8_t *buf = sc->sc_mem;
+ uint8_t *bptr;
int xfer;
bptr = buf + ((boff << 1) & ~0x1f);
diff --git a/sys/dev/ic/lancevar.h b/sys/dev/ic/lancevar.h
index c6ed21c9761..e5321230ee4 100644
--- a/sys/dev/ic/lancevar.h
+++ b/sys/dev/ic/lancevar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: lancevar.h,v 1.10 2005/12/11 12:21:27 christos Exp $ */
+/* $NetBSD: lancevar.h,v 1.11 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
#endif
struct lance_softc {
- struct device sc_dev; /* base device glue */
+ device_t sc_dev; /* base device glue */
struct ethercom sc_ethercom; /* Ethernet common part */
struct ifmedia sc_media; /* our supported media */
@@ -75,10 +75,10 @@ struct lance_softc {
* no carrier hook - may be NULL
* media change hook - may be NULL
*/
- u_int16_t (*sc_rdcsr)
- (struct lance_softc *, u_int16_t);
+ uint16_t (*sc_rdcsr)
+ (struct lance_softc *, uint16_t);
void (*sc_wrcsr)
- (struct lance_softc *, u_int16_t, u_int16_t);
+ (struct lance_softc *, uint16_t, uint16_t);
void (*sc_hwreset)(struct lance_softc *);
void (*sc_hwinit)(struct lance_softc *);
void (*sc_nocarrier)(struct lance_softc *);
@@ -100,8 +100,8 @@ struct lance_softc {
void *sc_sh; /* shutdownhook cookie */
- u_int16_t sc_conf3; /* CSR3 value */
- u_int16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */
+ uint16_t sc_conf3; /* CSR3 value */
+ uint16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */
void *sc_mem; /* base address of RAM -- CPU's view */
u_long sc_addr; /* base address of RAM -- LANCE's view */
@@ -122,8 +122,8 @@ struct lance_softc {
#ifdef LEDEBUG
int sc_debug;
#endif
- u_int8_t sc_enaddr[ETHER_ADDR_LEN];
- u_int8_t sc_pad[2];
+ uint8_t sc_enaddr[ETHER_ADDR_LEN];
+ uint8_t sc_pad[2];
#if NRND > 0
rndsource_element_t rnd_source;
#endif
@@ -137,7 +137,7 @@ void lance_reset(struct lance_softc *);
int lance_init(struct ifnet *);
int lance_put(struct lance_softc *, int, struct mbuf *);
void lance_read(struct lance_softc *, int, int);
-void lance_setladrf(struct ethercom *, u_int16_t *);
+void lance_setladrf(struct ethercom *, uint16_t *);
/*
* The following functions are only useful on certain CPU/bus
diff --git a/sys/dev/isa/depca_isa.c b/sys/dev/isa/depca_isa.c
index 91a0b52754e..a5080219099 100644
--- a/sys/dev/isa/depca_isa.c
+++ b/sys/dev/isa/depca_isa.c
@@ -1,4 +1,4 @@
-/* $NetBSD: depca_isa.c,v 1.12 2007/10/19 12:00:15 ad Exp $ */
+/* $NetBSD: depca_isa.c,v 1.13 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: depca_isa.c,v 1.12 2007/10/19 12:00:15 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: depca_isa.c,v 1.13 2008/04/04 12:25:07 tsutsui Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -107,8 +107,8 @@ __KERNEL_RCSID(0, "$NetBSD: depca_isa.c,v 1.12 2007/10/19 12:00:15 ad Exp $");
#include <dev/ic/depcareg.h>
#include <dev/ic/depcavar.h>
-int depca_isa_probe(struct device *, struct cfdata *, void *);
-void depca_isa_attach(struct device *, struct device *, void *);
+int depca_isa_probe(device_t, cfdata_t, void *);
+void depca_isa_attach(device_t, device_t, void *);
struct depca_isa_softc {
struct depca_softc sc_depca;
@@ -116,14 +116,13 @@ struct depca_isa_softc {
int sc_irq;
};
-CFATTACH_DECL(depca_isa, sizeof(struct depca_isa_softc),
+CFATTACH_DECL_NEW(depca_isa, sizeof(struct depca_isa_softc),
depca_isa_probe, depca_isa_attach, NULL, NULL);
void *depca_isa_intr_establish(struct depca_softc *, struct lance_softc *);
int
-depca_isa_probe(struct device *parent, struct cfdata *match,
- void *aux)
+depca_isa_probe(device_t parent, cfdata_t cf, void *aux)
{
struct isa_attach_args *ia = aux;
bus_space_tag_t iot = ia->ia_iot;
@@ -153,8 +152,8 @@ depca_isa_probe(struct device *parent, struct cfdata *match,
return 0;
if (ia->ia_iomem[0].ir_addr == ISA_UNKNOWN_IOMEM ||
- (ia->ia_iomem[0].ir_size != 32*1024 &&
- ia->ia_iomem[0].ir_size != 64*1024))
+ (ia->ia_iomem[0].ir_size != 32 * 1024 &&
+ ia->ia_iomem[0].ir_size != 64 * 1024))
goto bad;
/* Map card RAM. */
@@ -199,13 +198,14 @@ depca_isa_probe(struct device *parent, struct cfdata *match,
}
void
-depca_isa_attach(struct device *parent, struct device *self, void *aux)
+depca_isa_attach(device_t parent, device_t self, void *aux)
{
- struct depca_softc *sc = (void *) self;
- struct depca_isa_softc *isc = (void *) self;
+ struct depca_isa_softc *isc = device_private(self);
+ struct depca_softc *sc = &isc->sc_depca;
struct isa_attach_args *ia = aux;
- printf("\n");
+ sc->sc_dev = self;
+ aprint_normal("\n");
sc->sc_iot = ia->ia_iot;
sc->sc_memt = ia->ia_memt;
@@ -214,12 +214,12 @@ depca_isa_attach(struct device *parent, struct device *self, void *aux)
if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, 16,
0, &sc->sc_ioh) != 0) {
- printf("%s: unable to map i/o space\n", sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "unable to map i/o space\n");
return;
}
if (bus_space_map(sc->sc_memt, ia->ia_iomem[0].ir_addr,
ia->ia_iomem[0].ir_size, 0, &sc->sc_memh) != 0) {
- printf("%s: unable to map memory space\n", sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "unable to map memory space\n");
return;
}
@@ -233,14 +233,14 @@ depca_isa_attach(struct device *parent, struct device *self, void *aux)
void *
depca_isa_intr_establish(struct depca_softc *parent, struct lance_softc *child)
{
- struct depca_isa_softc *isc = (void *) parent;
+ struct depca_isa_softc *isc = (struct depca_isa_softc *)parent;
void *rv;
rv = isa_intr_establish(isc->sc_ic, isc->sc_irq, IST_EDGE,
IPL_NET, depca_intredge, child);
if (rv == NULL)
printf("%s: unable to establish interrupt\n",
- parent->sc_dev.dv_xname);
+ device_xname(parent->sc_dev));
return (rv);
}
diff --git a/sys/dev/isa/if_le_isa.c b/sys/dev/isa/if_le_isa.c
index 9c3cd53425e..0663470b263 100644
--- a/sys/dev/isa/if_le_isa.c
+++ b/sys/dev/isa/if_le_isa.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_isa.c,v 1.45 2007/10/19 12:00:18 ad Exp $ */
+/* $NetBSD: if_le_isa.c,v 1.46 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_isa.c,v 1.45 2007/10/19 12:00:18 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_isa.c,v 1.46 2008/04/04 12:25:07 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -102,23 +102,23 @@ __KERNEL_RCSID(0, "$NetBSD: if_le_isa.c,v 1.45 2007/10/19 12:00:18 ad Exp $");
#include <dev/isa/if_levar.h>
-int ne2100_isa_probe(struct device *, struct cfdata *, void *);
-int bicc_isa_probe(struct device *, struct cfdata *, void *);
-void le_dummyattach(struct device *, struct device *, void *);
-int le_dummyprobe(struct device *, struct cfdata *, void *);
-void le_ne2100_attach(struct device *, struct device *, void *);
-void le_bicc_attach(struct device *, struct device *, void *);
+int ne2100_isa_probe(device_t, cfdata_t, void *);
+int bicc_isa_probe(device_t, cfdata_t, void *);
+void le_dummyattach(device_t, device_t, void *);
+int le_dummyprobe(device_t, cfdata_t, void *);
+void le_ne2100_attach(device_t, device_t, void *);
+void le_bicc_attach(device_t, device_t, void *);
-CFATTACH_DECL(nele, sizeof(struct device),
+CFATTACH_DECL_NEW(nele, 0,
ne2100_isa_probe, le_dummyattach, NULL, NULL);
-CFATTACH_DECL(le_nele, sizeof(struct le_softc),
+CFATTACH_DECL_NEW(le_nele, sizeof(struct le_softc),
le_dummyprobe, le_ne2100_attach, NULL, NULL);
-CFATTACH_DECL(bicc, sizeof(struct device),
+CFATTACH_DECL_NEW(bicc, 0,
bicc_isa_probe, le_dummyattach, NULL, NULL);
-CFATTACH_DECL(le_bicc, sizeof(struct le_softc),
+CFATTACH_DECL_NEW(le_bicc, sizeof(struct le_softc),
le_dummyprobe, le_bicc_attach, NULL, NULL);
struct le_isa_params {
@@ -137,7 +137,7 @@ struct le_isa_params {
int lance_isa_probe(struct isa_attach_args *, struct le_isa_params *, int);
void le_isa_attach(struct device *, struct le_softc *,
- struct isa_attach_args *, struct le_isa_params *);
+ struct isa_attach_args *, struct le_isa_params *);
int le_isa_intredge(void *);
@@ -153,15 +153,13 @@ int le_isa_intredge(void *);
#define hide static
#endif
-hide void le_isa_wrcsr(struct lance_softc *, u_int16_t, u_int16_t);
-hide u_int16_t le_isa_rdcsr(struct lance_softc *, u_int16_t);
+hide void le_isa_wrcsr(struct lance_softc *, uint16_t, uint16_t);
+hide uint16_t le_isa_rdcsr(struct lance_softc *, uint16_t);
#define LE_ISA_MEMSIZE 16384
hide void
-le_isa_wrcsr(sc, port, val)
- struct lance_softc *sc;
- u_int16_t port, val;
+le_isa_wrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_space_tag_t iot = lesc->sc_iot;
@@ -171,15 +169,13 @@ le_isa_wrcsr(sc, port, val)
bus_space_write_2(iot, ioh, lesc->sc_rdp, val);
}
-hide u_int16_t
-le_isa_rdcsr(sc, port)
- struct lance_softc *sc;
- u_int16_t port;
+hide uint16_t
+le_isa_rdcsr(struct lance_softc *sc, uint16_t port)
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_space_tag_t iot = lesc->sc_iot;
bus_space_handle_t ioh = lesc->sc_ioh;
- u_int16_t val;
+ uint16_t val;
bus_space_write_2(iot, ioh, lesc->sc_rap, port);
val = bus_space_read_2(iot, ioh, lesc->sc_rdp);
@@ -187,26 +183,24 @@ le_isa_rdcsr(sc, port)
}
int
-ne2100_isa_probe(struct device *parent, struct cfdata *match,
- void *aux)
+ne2100_isa_probe(device_t parent, cfdata_t cf, void *aux)
{
- return (lance_isa_probe(aux, &ne2100_params, match->cf_flags));
+
+ return (lance_isa_probe(aux, &ne2100_params, cf->cf_flags));
}
int
-bicc_isa_probe(struct device *parent, struct cfdata *match, void *aux)
+bicc_isa_probe(device_t parent, cfdata_t cf, void *aux)
{
- return (lance_isa_probe(aux, &bicc_params, match->cf_flags));
+
+ return (lance_isa_probe(aux, &bicc_params, cf->cf_flags));
}
/*
* Determine which chip is present on the card.
*/
int
-lance_isa_probe(ia, p, flags)
- struct isa_attach_args *ia;
- struct le_isa_params *p;
- int flags;
+lance_isa_probe(struct isa_attach_args *ia, struct le_isa_params *p, int flags)
{
bus_space_tag_t iot = ia->ia_iot;
bus_space_handle_t ioh;
@@ -272,35 +266,39 @@ bad:
}
void
-le_dummyattach(struct device *parent, struct device *self,
- void *aux)
+le_dummyattach(device_t parent, device_t self, void *aux)
{
- printf("\n");
+
+ aprint_normal("\n");
config_found(self, aux, 0);
}
int
-le_dummyprobe(struct device *parent, struct cfdata *match,
- void *aux)
+le_dummyprobe(device_t parent, cfdata_t cf, void *aux)
{
+
return (1);
}
void
-le_ne2100_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+le_ne2100_attach(device_t parent, device_t self, void *aux)
{
- le_isa_attach(parent, (void *)self, aux, &ne2100_params);
+ struct le_softc *lesc = device_private(self);
+ struct lance_softc *sc = &lesc->sc_am7990.lsc;
+
+ sc->sc_dev = self;
+ le_isa_attach(parent, lesc, aux, &ne2100_params);
}
void
-le_bicc_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+le_bicc_attach(device_t parent, device_t self, void *aux)
{
- le_isa_attach(parent, (void *)self, aux, &bicc_params);
+ struct le_softc *lesc = device_private(self);
+ struct lance_softc *sc = &lesc->sc_am7990.lsc;
+
+ sc->sc_dev = self;
+ le_isa_attach(parent, lesc, aux, &bicc_params);
}
void
@@ -314,10 +312,10 @@ le_isa_attach(struct device *parent, struct le_softc *lesc,
bus_dma_segment_t seg;
int i, rseg, error;
- printf(": %s Ethernet\n", p->name);
+ aprint_normal(": %s Ethernet\n", p->name);
if (bus_space_map(iot, ia->ia_io[0].ir_addr, p->iosize, 0, &ioh))
- panic("%s: can't map io", sc->sc_dev.dv_xname);
+ panic("%s: can't map io", device_xname(sc->sc_dev));
/*
* Extract the physical MAC address from the ROM.
@@ -337,15 +335,14 @@ le_isa_attach(struct device *parent, struct le_softc *lesc,
*/
if (bus_dmamem_alloc(dmat, LE_ISA_MEMSIZE, PAGE_SIZE, 0, &seg, 1,
&rseg, BUS_DMA_NOWAIT)) {
- printf("%s: couldn't allocate memory for card\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(sc->sc_dev,
+ "couldn't allocate memory for card\n");
return;
}
if (bus_dmamem_map(dmat, &seg, rseg, LE_ISA_MEMSIZE,
(void **)&sc->sc_mem,
BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) {
- printf("%s: couldn't map memory for card\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(sc->sc_dev, "couldn't map memory for card\n");
return;
}
@@ -354,15 +351,13 @@ le_isa_attach(struct device *parent, struct le_softc *lesc,
*/
if (bus_dmamap_create(dmat, LE_ISA_MEMSIZE, 1,
LE_ISA_MEMSIZE, 0, BUS_DMA_NOWAIT, &lesc->sc_dmam)) {
- printf("%s: couldn't create DMA map\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(sc->sc_dev, "couldn't create DMA map\n");
bus_dmamem_free(dmat, &seg, rseg);
return;
}
if (bus_dmamap_load(dmat, lesc->sc_dmam,
sc->sc_mem, LE_ISA_MEMSIZE, NULL, BUS_DMA_NOWAIT)) {
- printf("%s: coundn't load DMA map\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(sc->sc_dev, "coundn't load DMA map\n");
bus_dmamem_free(dmat, &seg, rseg);
return;
}
@@ -384,8 +379,8 @@ le_isa_attach(struct device *parent, struct le_softc *lesc,
if (ia->ia_ndrq > 0) {
if ((error = isa_dmacascade(ia->ia_ic,
ia->ia_drq[0].ir_drq)) != 0) {
- printf("%s: unable to cascade DRQ, error = %d\n",
- sc->sc_dev.dv_xname, error);
+ aprint_error_dev(sc->sc_dev,
+ "unable to cascade DRQ, error = %d\n", error);
return;
}
}
@@ -393,7 +388,7 @@ le_isa_attach(struct device *parent, struct le_softc *lesc,
lesc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
IST_EDGE, IPL_NET, le_isa_intredge, sc);
- printf("%s", sc->sc_dev.dv_xname);
+ aprint_normal("%s", device_xname(sc->sc_dev));
am7990_config(&lesc->sc_am7990);
}
@@ -401,8 +396,7 @@ le_isa_attach(struct device *parent, struct le_softc *lesc,
* Controller interrupt.
*/
int
-le_isa_intredge(arg)
- void *arg;
+le_isa_intredge(void *arg)
{
if (am7990_intr(arg) == 0)
diff --git a/sys/dev/isapnp/if_le_isapnp.c b/sys/dev/isapnp/if_le_isapnp.c
index 6847ced27d2..13243cce3e8 100644
--- a/sys/dev/isapnp/if_le_isapnp.c
+++ b/sys/dev/isapnp/if_le_isapnp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_isapnp.c,v 1.32 2007/10/19 12:00:31 ad Exp $ */
+/* $NetBSD: if_le_isapnp.c,v 1.33 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_isapnp.c,v 1.32 2007/10/19 12:00:31 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_isapnp.c,v 1.33 2008/04/04 12:25:07 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -127,20 +127,18 @@ struct le_isapnp_softc {
int sc_rap, sc_rdp; /* offsets to LANCE registers */
};
-int le_isapnp_match(struct device *, struct cfdata *, void *);
-void le_isapnp_attach(struct device *, struct device *, void *);
+int le_isapnp_match(device_t, cfdata_t, void *);
+void le_isapnp_attach(device_t, device_t, void *);
-CFATTACH_DECL(le_isapnp, sizeof(struct le_isapnp_softc),
+CFATTACH_DECL_NEW(le_isapnp, sizeof(struct le_isapnp_softc),
le_isapnp_match, le_isapnp_attach, NULL, NULL);
int le_isapnp_intredge(void *);
-static void le_isapnp_wrcsr(struct lance_softc *, u_int16_t, u_int16_t);
-static u_int16_t le_isapnp_rdcsr(struct lance_softc *, u_int16_t);
+static void le_isapnp_wrcsr(struct lance_softc *, uint16_t, uint16_t);
+static uint16_t le_isapnp_rdcsr(struct lance_softc *, uint16_t);
static void
-le_isapnp_wrcsr(sc, port, val)
- struct lance_softc *sc;
- u_int16_t port, val;
+le_isapnp_wrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
{
struct le_isapnp_softc *lesc = (struct le_isapnp_softc *)sc;
bus_space_tag_t iot = lesc->sc_iot;
@@ -150,15 +148,13 @@ le_isapnp_wrcsr(sc, port, val)
bus_space_write_2(iot, ioh, lesc->sc_rdp, val);
}
-static u_int16_t
-le_isapnp_rdcsr(sc, port)
- struct lance_softc *sc;
- u_int16_t port;
+static uint16_t
+le_isapnp_rdcsr(struct lance_softc *sc, uint16_t port)
{
struct le_isapnp_softc *lesc = (struct le_isapnp_softc *)sc;
bus_space_tag_t iot = lesc->sc_iot;
bus_space_handle_t ioh = lesc->sc_ioh;
- u_int16_t val;
+ uint16_t val;
bus_space_write_2(iot, ioh, lesc->sc_rap, port);
val = bus_space_read_2(iot, ioh, lesc->sc_rdp);
@@ -166,8 +162,7 @@ le_isapnp_rdcsr(sc, port)
}
int
-le_isapnp_match(struct device *parent, struct cfdata *match,
- void *aux)
+le_isapnp_match(device_t parent, cfdata_t cf, void *aux)
{
int pri, variant;
@@ -178,7 +173,7 @@ le_isapnp_match(struct device *parent, struct cfdata *match,
}
void
-le_isapnp_attach(struct device *parent, struct device *self, void *aux)
+le_isapnp_attach(device_t parent, device_t self, void *aux)
{
struct le_isapnp_softc *lesc = device_private(self);
struct lance_softc *sc = &lesc->sc_am7990.lsc;
@@ -189,8 +184,10 @@ le_isapnp_attach(struct device *parent, struct device *self, void *aux)
bus_dma_segment_t seg;
int i, rseg, error;
+ sc->sc_dev = self;
+
if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
- printf(": error in region allocation\n");
+ aprint_error(": error in region allocation\n");
return;
}
@@ -212,12 +209,12 @@ le_isapnp_attach(struct device *parent, struct device *self, void *aux)
*/
if (bus_dmamem_alloc(dmat, LE_ISAPNP_MEMSIZE, PAGE_SIZE, 0, &seg, 1,
&rseg, BUS_DMA_NOWAIT)) {
- printf(": couldn't allocate memory for card\n");
+ aprint_error(": couldn't allocate memory for card\n");
return;
}
if (bus_dmamem_map(dmat, &seg, rseg, LE_ISAPNP_MEMSIZE,
(void **)&sc->sc_mem, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) {
- printf(": couldn't map memory for card\n");
+ aprint_error(": couldn't map memory for card\n");
return;
}
@@ -226,13 +223,13 @@ le_isapnp_attach(struct device *parent, struct device *self, void *aux)
*/
if (bus_dmamap_create(dmat, LE_ISAPNP_MEMSIZE, 1,
LE_ISAPNP_MEMSIZE, 0, BUS_DMA_NOWAIT, &lesc->sc_dmam)) {
- printf(": couldn't create DMA map\n");
+ aprint_error(": couldn't create DMA map\n");
bus_dmamem_free(dmat, &seg, rseg);
return;
}
if (bus_dmamap_load(dmat, lesc->sc_dmam,
sc->sc_mem, LE_ISAPNP_MEMSIZE, NULL, BUS_DMA_NOWAIT)) {
- printf(": coundn't load DMA map\n");
+ aprint_error(": coundn't load DMA map\n");
bus_dmamem_free(dmat, &seg, rseg);
return;
}
@@ -254,7 +251,8 @@ le_isapnp_attach(struct device *parent, struct device *self, void *aux)
if (ipa->ipa_ndrq > 0) {
if ((error = isa_dmacascade(ipa->ipa_ic,
ipa->ipa_drq[0].num)) != 0) {
- printf(": unable to cascade DRQ, error = %d\n", error);
+ aprint_error(": unable to cascade DRQ, error = %d\n",
+ error);
return;
}
}
@@ -262,9 +260,9 @@ le_isapnp_attach(struct device *parent, struct device *self, void *aux)
lesc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
ipa->ipa_irq[0].type, IPL_NET, le_isapnp_intredge, sc);
- printf(": %s %s\n", ipa->ipa_devident, ipa->ipa_devclass);
+ aprint_normal(": %s %s\n", ipa->ipa_devident, ipa->ipa_devclass);
- printf("%s", sc->sc_dev.dv_xname);
+ aprint_normal("%s", device_xname(self));
am7990_config(&lesc->sc_am7990);
}
@@ -273,8 +271,7 @@ le_isapnp_attach(struct device *parent, struct device *self, void *aux)
* Controller interrupt.
*/
int
-le_isapnp_intredge(arg)
- void *arg;
+le_isapnp_intredge(void *arg)
{
if (am7990_intr(arg) == 0)
diff --git a/sys/dev/mca/if_le_mca.c b/sys/dev/mca/if_le_mca.c
index 480cad9e82b..9d3264e6864 100644
--- a/sys/dev/mca/if_le_mca.c
+++ b/sys/dev/mca/if_le_mca.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_mca.c,v 1.16 2007/10/19 12:00:35 ad Exp $ */
+/* $NetBSD: if_le_mca.c,v 1.17 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_mca.c,v 1.16 2007/10/19 12:00:35 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_mca.c,v 1.17 2008/04/04 12:25:07 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -82,8 +82,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_le_mca.c,v 1.16 2007/10/19 12:00:35 ad Exp $");
#include <dev/mca/if_lereg.h>
-int le_mca_match(struct device *, struct cfdata *, void *);
-void le_mca_attach(struct device *, struct device *, void *);
+int le_mca_match(device_t, cfdata_t, void *);
+void le_mca_attach(device_t, device_t, void *);
struct le_mca_softc {
struct am7990_softc sc_am7990; /* glue to MI code */
@@ -93,8 +93,8 @@ struct le_mca_softc {
bus_space_handle_t sc_memh;
};
-static void le_mca_wrcsr(struct lance_softc *, u_int16_t, u_int16_t);
-static u_int16_t le_mca_rdcsr(struct lance_softc *, u_int16_t);
+static void le_mca_wrcsr(struct lance_softc *, uint16_t, uint16_t);
+static uint16_t le_mca_rdcsr(struct lance_softc *, uint16_t);
static void le_mca_hwreset(struct lance_softc *);
static int le_mca_intredge(void *);
@@ -106,7 +106,7 @@ static inline void le_mca_wrreg(struct le_mca_softc *, int, int);
#define le_mca_set_RAP(sc, reg_number) \
le_mca_wrreg(sc, reg_number, RAP | REGWRITE)
-CFATTACH_DECL(le_mca, sizeof(struct le_mca_softc),
+CFATTACH_DECL_NEW(le_mca, sizeof(struct le_mca_softc),
le_mca_match, le_mca_attach, NULL, NULL);
/* SKNET MC+ POS mapping */
@@ -121,8 +121,7 @@ static const u_int8_t sknet_mcp_media[] = {
};
int
-le_mca_match(struct device *parent, struct cfdata *cf,
- void *aux)
+le_mca_match(device_t parent, cfdata_t cf, void *aux)
{
struct mca_attach_args *ma = aux;
@@ -136,7 +135,7 @@ le_mca_match(struct device *parent, struct cfdata *cf,
}
void
-le_mca_attach(struct device *parent, struct device *self, void *aux)
+le_mca_attach(device_t parent, device_t self, void *aux)
{
struct le_mca_softc *lesc = device_private(self);
struct lance_softc *sc = &lesc->sc_am7990.lsc;
@@ -144,6 +143,8 @@ le_mca_attach(struct device *parent, struct device *self, void *aux)
int i, pos2, pos3, pos4, irq, membase, supmedia=0;
const char *typestr;
+ sc->sc_dev = self;
+
/*
* SKNET Personal:
*
@@ -216,8 +217,7 @@ le_mca_attach(struct device *parent, struct device *self, void *aux)
supmedia = sknet_mcp_media[(pos4 & 0xc0) >> 6];
break;
default:
- printf("%s: unknown product %d\n", sc->sc_dev.dv_xname,
- ma->ma_id);
+ aprint_error(": unknown product %d\n", ma->ma_id);
return;
}
@@ -225,11 +225,11 @@ le_mca_attach(struct device *parent, struct device *self, void *aux)
if (bus_space_map(lesc->sc_memt, membase, LE_MCA_MEMSIZE,
0, &lesc->sc_memh)) {
- printf("%s: can't map memory\n", sc->sc_dev.dv_xname);
+ aprint_error(": can't map memory\n");
return;
}
- printf(" slot %d irq %d: SKNET %s Ethernet\n",
+ aprint_normal(" slot %d irq %d: SKNET %s Ethernet\n",
ma->ma_slot + 1, irq, typestr);
/*
@@ -237,7 +237,7 @@ le_mca_attach(struct device *parent, struct device *self, void *aux)
*/
for (i = 0; i < ETHER_ADDR_LEN; i++)
sc->sc_enaddr[i] = bus_space_read_1(lesc->sc_memt,
- lesc->sc_memh, LE_PROMOFF + i*2);
+ lesc->sc_memh, LE_PROMOFF + i * 2);
sc->sc_conf3 = LE_C3_ACON;
sc->sc_addr = 0;
@@ -268,12 +268,12 @@ le_mca_attach(struct device *parent, struct device *self, void *aux)
lesc->sc_ih = mca_intr_establish(ma->ma_mc, irq, IPL_NET,
le_mca_intredge, sc);
if (lesc->sc_ih == NULL) {
- printf("%s: couldn't establish interrupt handler\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(self,
+ "couldn't establish interrupt handler\n");
return;
}
- printf("%s", sc->sc_dev.dv_xname);
+ aprint_normal("%s", device_xname(self));
am7990_config(&lesc->sc_am7990);
}
@@ -281,9 +281,9 @@ le_mca_attach(struct device *parent, struct device *self, void *aux)
* Controller interrupt.
*/
int
-le_mca_intredge(arg)
- void *arg;
+le_mca_intredge(void *arg)
{
+
/*
* We could check the IRQ bit of LE_PORT, but it seems to be unset
* at this time anyway.
@@ -300,10 +300,9 @@ le_mca_intredge(arg)
* Push a value to LANCE controller.
*/
static inline void
-le_mca_wrreg(sc, val, type)
- struct le_mca_softc *sc;
- int val, type;
+le_mca_wrreg(struct le_mca_softc *sc, int val, int type)
{
+
/*
* This follows steps in SKNET Personal/MC2+ docs:
* 1. write reg. number to LANCE register
@@ -319,14 +318,12 @@ le_mca_wrreg(sc, val, type)
REGDO);
/* Delay here doesn't seem to be necessary */
/* delay(1); */
- while(bus_space_read_1(sc->sc_memt, sc->sc_memh, LE_PORT) & REGREQ)
+ while (bus_space_read_1(sc->sc_memt, sc->sc_memh, LE_PORT) & REGREQ)
;
}
static void
-le_mca_wrcsr(sc, port, val)
- struct lance_softc *sc;
- u_int16_t port, val;
+le_mca_wrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
{
struct le_mca_softc *lsc = (struct le_mca_softc *)sc;
@@ -334,10 +331,8 @@ le_mca_wrcsr(sc, port, val)
le_mca_wrreg(lsc, val, RDATA | REGWRITE);
}
-static u_int16_t
-le_mca_rdcsr(sc, port)
- struct lance_softc *sc;
- u_int16_t port;
+static uint16_t
+le_mca_rdcsr(struct lance_softc *sc, uint16_t port)
{
struct le_mca_softc *lsc = (struct le_mca_softc *)sc;
@@ -348,8 +343,7 @@ le_mca_rdcsr(sc, port)
}
static void
-le_mca_hwreset(sc)
- struct lance_softc *sc;
+le_mca_hwreset(struct lance_softc *sc)
{
struct le_mca_softc *lsc = (struct le_mca_softc *)sc;
@@ -361,26 +355,26 @@ le_mca_hwreset(sc)
static void
le_mca_copytobuf(struct lance_softc *sc, void *from, int boff, int len)
{
- struct le_mca_softc *dsc = (void *) sc;
+ struct le_mca_softc *lsc = (struct le_mca_softc *)sc;
- bus_space_write_region_1(dsc->sc_memt, dsc->sc_memh, boff,
+ bus_space_write_region_1(lsc->sc_memt, lsc->sc_memh, boff,
from, len);
}
static void
le_mca_copyfrombuf(struct lance_softc *sc, void *to, int boff, int len)
{
- struct le_mca_softc *dsc = (void *) sc;
+ struct le_mca_softc *lsc = (struct le_mca_softc *)sc;
- bus_space_read_region_1(dsc->sc_memt, dsc->sc_memh, boff,
+ bus_space_read_region_1(lsc->sc_memt, lsc->sc_memh, boff,
to, len);
}
static void
le_mca_zerobuf(struct lance_softc *sc, int boff, int len)
{
- struct le_mca_softc *dsc = (void *) sc;
+ struct le_mca_softc *lsc = (struct le_mca_softc *)sc;
- bus_space_set_region_1(dsc->sc_memt, dsc->sc_memh, boff,
+ bus_space_set_region_1(lsc->sc_memt, lsc->sc_memh, boff,
0x00, len);
}
diff --git a/sys/dev/pci/if_le_pci.c b/sys/dev/pci/if_le_pci.c
index 41fcbcb6d6b..786642ab010 100644
--- a/sys/dev/pci/if_le_pci.c
+++ b/sys/dev/pci/if_le_pci.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_pci.c,v 1.47 2007/10/19 12:00:46 ad Exp $ */
+/* $NetBSD: if_le_pci.c,v 1.48 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_pci.c,v 1.47 2007/10/19 12:00:46 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_pci.c,v 1.48 2008/04/04 12:25:07 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -102,11 +102,11 @@ __KERNEL_RCSID(0, "$NetBSD: if_le_pci.c,v 1.47 2007/10/19 12:00:46 ad Exp $");
#include <dev/pci/if_levar.h>
-static int le_pci_match(struct device *, struct cfdata *, void *);
-static void le_pci_attach(struct device *, struct device *, void *);
+static int le_pci_match(device_t, cfdata_t, void *);
+static void le_pci_attach(device_t, device_t, void *);
static int le_pci_mediachange(struct lance_softc *);
-CFATTACH_DECL(le_pci, sizeof(struct le_softc),
+CFATTACH_DECL_NEW(le_pci, sizeof(struct le_softc),
le_pci_match, le_pci_attach, NULL, NULL);
/*
@@ -127,7 +127,7 @@ static int le_pci_supmedia[] = {
};
static void
-le_pci_wrcsr(struct lance_softc *sc, u_int16_t port, u_int16_t val)
+le_pci_wrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_space_tag_t iot = lesc->sc_iot;
@@ -137,13 +137,13 @@ le_pci_wrcsr(struct lance_softc *sc, u_int16_t port, u_int16_t val)
bus_space_write_2(iot, ioh, lesc->sc_rdp, val);
}
-static u_int16_t
-le_pci_rdcsr(struct lance_softc *sc, u_int16_t port)
+static uint16_t
+le_pci_rdcsr(struct lance_softc *sc, uint16_t port)
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_space_tag_t iot = lesc->sc_iot;
bus_space_handle_t ioh = lesc->sc_ioh;
- u_int16_t val;
+ uint16_t val;
bus_space_write_2(iot, ioh, lesc->sc_rap, port);
val = bus_space_read_2(iot, ioh, lesc->sc_rdp);
@@ -157,7 +157,7 @@ le_pci_mediachange(struct lance_softc *sc)
bus_space_tag_t iot = lesc->sc_iot;
bus_space_handle_t ioh = lesc->sc_ioh;
int newmedia = sc->sc_media.ifm_media;
- u_int16_t reg;
+ uint16_t reg;
if (IFM_SUBTYPE(newmedia) !=
IFM_SUBTYPE(lesc->sc_currentmedia)) {
@@ -213,8 +213,7 @@ le_pci_mediachange(struct lance_softc *sc)
}
static int
-le_pci_match(struct device *parent, struct cfdata *match,
- void *aux)
+le_pci_match(device_t parent, cfdata_t cf, void *aux)
{
struct pci_attach_args *pa = aux;
@@ -230,9 +229,9 @@ le_pci_match(struct device *parent, struct cfdata *match,
}
static void
-le_pci_attach(struct device *parent, struct device *self, void *aux)
+le_pci_attach(device_t parent, device_t self, void *aux)
{
- struct le_softc *lesc = (void *)self;
+ struct le_softc *lesc = device_private(self);
struct lance_softc *sc = &lesc->sc_am79900.lsc;
struct pci_attach_args *pa = aux;
pci_intr_handle_t ih;
@@ -245,6 +244,8 @@ le_pci_attach(struct device *parent, struct device *self, void *aux)
int i, rseg;
const char *model, *intrstr;
+ sc->sc_dev = self;
+
switch (PCI_PRODUCT(pa->pa_id)) {
case PCI_PRODUCT_AMD_PCNET_PCI:
model = "PCnet-PCI Ethernet";
@@ -256,11 +257,11 @@ le_pci_attach(struct device *parent, struct device *self, void *aux)
model = "unknown model!";
}
- printf(": %s\n", model);
+ aprint_normal(": %s\n", model);
if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0,
&iot, &ioh, NULL, NULL)) {
- printf("%s: can't map I/O space\n", sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "can't map I/O space\n");
return;
}
@@ -279,15 +280,13 @@ le_pci_attach(struct device *parent, struct device *self, void *aux)
*/
if (bus_dmamem_alloc(dmat, LE_PCI_MEMSIZE, PAGE_SIZE, 0, &seg, 1,
&rseg, BUS_DMA_NOWAIT)) {
- printf("%s: couldn't allocate memory for card\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "couldn't allocate memory for card\n");
return;
}
if (bus_dmamem_map(dmat, &seg, rseg, LE_PCI_MEMSIZE,
(void **)&sc->sc_mem,
BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) {
- printf("%s: couldn't map memory for card\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "couldn't map memory for card\n");
return;
}
@@ -296,15 +295,13 @@ le_pci_attach(struct device *parent, struct device *self, void *aux)
*/
if (bus_dmamap_create(dmat, LE_PCI_MEMSIZE, 1,
LE_PCI_MEMSIZE, 0, BUS_DMA_NOWAIT, &lesc->sc_dmam)) {
- printf("%s: couldn't create DMA map\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "couldn't create DMA map\n");
bus_dmamem_free(dmat, &seg, rseg);
return;
}
if (bus_dmamap_load(dmat, lesc->sc_dmam,
sc->sc_mem, LE_PCI_MEMSIZE, NULL, BUS_DMA_NOWAIT)) {
- printf("%s: coundn't load DMA map\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "coundn't load DMA map\n");
bus_dmamem_free(dmat, &seg, rseg);
return;
}
@@ -329,7 +326,7 @@ le_pci_attach(struct device *parent, struct device *self, void *aux)
sc->sc_mediachange = le_pci_mediachange;
lesc->sc_currentmedia = le_pci_supmedia[0];
- printf("%s", sc->sc_dev.dv_xname);
+ aprint_normal("%s", device_xname(self));
am79900_config(&lesc->sc_am79900);
/* Chip is stopped. Set "software style" to 32-bit. */
@@ -344,18 +341,17 @@ le_pci_attach(struct device *parent, struct device *self, void *aux)
/* Map and establish the interrupt. */
if (pci_intr_map(pa, &ih)) {
- printf("%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "couldn't map interrupt\n");
return;
}
intrstr = pci_intr_string(pc, ih);
lesc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, am79900_intr, sc);
if (lesc->sc_ih == NULL) {
- printf("%s: couldn't establish interrupt",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(self, "couldn't establish interrupt");
if (intrstr != NULL)
- printf(" at %s", intrstr);
- printf("\n");
+ aprint_error(" at %s", intrstr);
+ aprint_error("\n");
return;
}
- printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
+ aprint_normal_dev(self, "interrupting at %s\n", intrstr);
}
diff --git a/sys/dev/sbus/if_le.c b/sys/dev/sbus/if_le.c
index 233f4902b8f..12d8bde5181 100644
--- a/sys/dev/sbus/if_le.c
+++ b/sys/dev/sbus/if_le.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le.c,v 1.34 2007/10/19 12:01:11 ad Exp $ */
+/* $NetBSD: if_le.c,v 1.35 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le.c,v 1.34 2007/10/19 12:01:11 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le.c,v 1.35 2008/04/04 12:25:07 tsutsui Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -67,6 +67,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_le.c,v 1.34 2007/10/19 12:01:11 ad Exp $");
#include <dev/ic/am7990reg.h>
#include <dev/ic/am7990var.h>
+#include "ioconf.h"
+
/*
* LANCE registers.
*/
@@ -84,8 +86,8 @@ struct le_softc {
#define MEMSIZE 0x4000 /* LANCE memory size */
-int lematch_sbus(struct device *, struct cfdata *, void *);
-void leattach_sbus(struct device *, struct device *, void *);
+int lematch_sbus(device_t, cfdata_t, void *);
+void leattach_sbus(device_t, device_t, void *);
/*
* Media types supported.
@@ -93,24 +95,20 @@ void leattach_sbus(struct device *, struct device *, void *);
static int lemedia[] = {
IFM_ETHER|IFM_10_5,
};
-#define NLEMEDIA (sizeof(lemedia) / sizeof(lemedia[0]))
+#define NLEMEDIA __arraycount(lemedia)
-CFATTACH_DECL(le_sbus, sizeof(struct le_softc),
+CFATTACH_DECL_NEW(le_sbus, sizeof(struct le_softc),
lematch_sbus, leattach_sbus, NULL, NULL);
-extern struct cfdriver le_cd;
-
#if defined(_KERNEL_OPT)
#include "opt_ddb.h"
#endif
-static void lewrcsr(struct lance_softc *, u_int16_t, u_int16_t);
-static u_int16_t lerdcsr(struct lance_softc *, u_int16_t);
+static void lewrcsr(struct lance_softc *, uint16_t, uint16_t);
+static uint16_t lerdcsr(struct lance_softc *, uint16_t);
static void
-lewrcsr(sc, port, val)
- struct lance_softc *sc;
- u_int16_t port, val;
+lewrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_space_tag_t t = lesc->sc_bustag;
@@ -129,10 +127,8 @@ lewrcsr(sc, port, val)
#endif
}
-static u_int16_t
-lerdcsr(sc, port)
- struct lance_softc *sc;
- u_int16_t port;
+static uint16_t
+lerdcsr(struct lance_softc *sc, uint16_t port)
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_space_tag_t t = lesc->sc_bustag;
@@ -144,10 +140,7 @@ lerdcsr(sc, port)
int
-lematch_sbus(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+lematch_sbus(device_t parent, cfdata_t cf, void *aux)
{
struct sbus_attach_args *sa = aux;
@@ -155,16 +148,16 @@ lematch_sbus(parent, cf, aux)
}
void
-leattach_sbus(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+leattach_sbus(device_t parent, device_t self, void *aux)
{
- struct sbus_attach_args *sa = aux;
- struct le_softc *lesc = (struct le_softc *)self;
+ struct le_softc *lesc = device_private(self);
struct lance_softc *sc = &lesc->sc_am7990.lsc;
+ struct sbus_softc *sbsc = device_private(parent);
+ struct sbus_attach_args *sa = aux;
bus_dma_tag_t dmatag;
struct sbusdev *sd;
+ sc->sc_dev = self;
lesc->sc_bustag = sa->sa_bustag;
lesc->sc_dmatag = dmatag = sa->sa_dmatag;
@@ -173,7 +166,7 @@ leattach_sbus(parent, self, aux)
sa->sa_offset,
sa->sa_size,
0, &lesc->sc_reg) != 0) {
- printf("%s @ sbus: cannot map registers\n", self->dv_xname);
+ aprint_error(": cannot map registers\n");
return;
}
@@ -183,12 +176,11 @@ leattach_sbus(parent, self, aux)
* a pre-historic ROM that doesn't establish le<=>lebuffer
* parent-child relationships.
*/
- for (sd = ((struct sbus_softc *)parent)->sc_sbdev; sd != NULL;
- sd = sd->sd_bchain) {
+ for (sd = sbsc->sc_sbdev; sd != NULL; sd = sd->sd_bchain) {
- struct lebuf_softc *lebuf = (struct lebuf_softc *)sd->sd_dev;
+ struct lebuf_softc *lebuf = device_private(sd->sd_dev);
- if (strncmp("lebuffer", sd->sd_dev->dv_xname, 8) != 0)
+ if (strncmp("lebuffer", device_xname(sd->sd_dev), 8) != 0)
continue;
if (lebuf->attached != 0)
@@ -207,7 +199,7 @@ leattach_sbus(parent, self, aux)
}
lesc->sc_sd.sd_reset = (void *)lance_reset;
- sbus_establish(&lesc->sc_sd, &sc->sc_dev);
+ sbus_establish(&lesc->sc_sd, self);
if (sc->sc_mem == 0) {
bus_dma_segment_t seg;
@@ -221,8 +213,7 @@ leattach_sbus(parent, self, aux)
if ((error = bus_dmamap_create(dmatag, MEMSIZE, 1, MEMSIZE, 0,
BUS_DMA_NOWAIT|BUS_DMA_24BIT,
&lesc->sc_dmamap)) != 0) {
- printf("%s: DMA map create error %d\n",
- self->dv_xname, error);
+ aprint_error(": DMA map create error %d\n", error);
return;
}
@@ -230,8 +221,8 @@ leattach_sbus(parent, self, aux)
if ((error = bus_dmamem_alloc(dmatag, MEMSIZE, 0, 0,
&seg, 1, &rseg,
BUS_DMA_NOWAIT|BUS_DMA_24BIT)) != 0){
- printf("%s: DMA buffer allocation error %d\n",
- self->dv_xname, error);
+ aprint_error(": DMA buffer allocation error %d\n",
+ error);
return;
}
@@ -239,17 +230,15 @@ leattach_sbus(parent, self, aux)
if ((error = bus_dmamem_map(dmatag, &seg, rseg, MEMSIZE,
(void **)&sc->sc_mem,
BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
- printf("%s: DMA buffer map error %d\n",
- self->dv_xname, error);
+ aprint_error(": DMA buffer map error %d\n", error);
bus_dmamem_free(lesc->sc_dmatag, &seg, rseg);
return;
}
/* Load DMA buffer */
- if ((error = bus_dmamap_load(dmatag, lesc->sc_dmamap, sc->sc_mem,
- MEMSIZE, NULL, BUS_DMA_NOWAIT)) != 0) {
- printf("%s: DMA buffer map load error %d\n",
- self->dv_xname, error);
+ if ((error = bus_dmamap_load(dmatag, lesc->sc_dmamap,
+ sc->sc_mem, MEMSIZE, NULL, BUS_DMA_NOWAIT)) != 0) {
+ aprint_error(": DMA buffer map load error %d\n", error);
bus_dmamem_free(dmatag, &seg, rseg);
bus_dmamem_unmap(dmatag, sc->sc_mem, MEMSIZE);
return;
diff --git a/sys/dev/sbus/if_le_lebuffer.c b/sys/dev/sbus/if_le_lebuffer.c
index ef49a157372..ae2b9ef550e 100644
--- a/sys/dev/sbus/if_le_lebuffer.c
+++ b/sys/dev/sbus/if_le_lebuffer.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_lebuffer.c,v 1.22 2007/10/19 12:01:11 ad Exp $ */
+/* $NetBSD: if_le_lebuffer.c,v 1.23 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_lebuffer.c,v 1.22 2007/10/19 12:01:11 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_lebuffer.c,v 1.23 2008/04/04 12:25:07 tsutsui Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -72,6 +72,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_le_lebuffer.c,v 1.22 2007/10/19 12:01:11 ad Exp $
#include <dev/ic/am7990reg.h>
#include <dev/ic/am7990var.h>
+#include "ioconf.h"
+
/*
* LANCE registers.
*/
@@ -87,8 +89,8 @@ struct le_softc {
};
-int lematch_lebuffer(struct device *, struct cfdata *, void *);
-void leattach_lebuffer(struct device *, struct device *, void *);
+int lematch_lebuffer(device_t, cfdata_t, void *);
+void leattach_lebuffer(device_t, device_t, void *);
/*
* Media types supported.
@@ -96,24 +98,20 @@ void leattach_lebuffer(struct device *, struct device *, void *);
static int lemedia[] = {
IFM_ETHER|IFM_10_T,
};
-#define NLEMEDIA (sizeof(lemedia) / sizeof(lemedia[0]))
+#define NLEMEDIA __arraycount(lemedia)
-CFATTACH_DECL(le_lebuffer, sizeof(struct le_softc),
+CFATTACH_DECL_NEW(le_lebuffer, sizeof(struct le_softc),
lematch_lebuffer, leattach_lebuffer, NULL, NULL);
-extern struct cfdriver le_cd;
-
#if defined(_KERNEL_OPT)
#include "opt_ddb.h"
#endif
-static void lewrcsr(struct lance_softc *, u_int16_t, u_int16_t);
-static u_int16_t lerdcsr(struct lance_softc *, u_int16_t);
+static void lewrcsr(struct lance_softc *, uint16_t, uint16_t);
+static uint16_t lerdcsr(struct lance_softc *, uint16_t);
static void
-lewrcsr(sc, port, val)
- struct lance_softc *sc;
- u_int16_t port, val;
+lewrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_space_tag_t t = lesc->sc_bustag;
@@ -132,10 +130,8 @@ lewrcsr(sc, port, val)
#endif
}
-static u_int16_t
-lerdcsr(sc, port)
- struct lance_softc *sc;
- u_int16_t port;
+static uint16_t
+lerdcsr(struct lance_softc *sc, uint16_t port)
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_space_tag_t t = lesc->sc_bustag;
@@ -146,10 +142,7 @@ lerdcsr(sc, port)
}
int
-lematch_lebuffer(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+lematch_lebuffer(device_t parent, cfdata_t cf, void *aux)
{
struct sbus_attach_args *sa = aux;
@@ -158,15 +151,14 @@ lematch_lebuffer(parent, cf, aux)
void
-leattach_lebuffer(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+leattach_lebuffer(device_t parent, device_t self, void *aux)
{
- struct sbus_attach_args *sa = aux;
- struct le_softc *lesc = (struct le_softc *)self;
+ struct le_softc *lesc = device_private(self);
struct lance_softc *sc = &lesc->sc_am7990.lsc;
- struct lebuf_softc *lebuf = (struct lebuf_softc *)parent;
+ struct lebuf_softc *lebuf = device_private(parent);
+ struct sbus_attach_args *sa = aux;
+ sc->sc_dev = self;
lesc->sc_bustag = sa->sa_bustag;
lesc->sc_dmatag = sa->sa_dmatag;
@@ -175,7 +167,7 @@ leattach_lebuffer(parent, self, aux)
sa->sa_offset,
sa->sa_size,
0, &lesc->sc_reg)) {
- printf("%s @ lebuffer: cannot map registers\n", self->dv_xname);
+ aprint_error(": cannot map registers\n");
return;
}
diff --git a/sys/dev/sbus/if_le_ledma.c b/sys/dev/sbus/if_le_ledma.c
index 777ac170f44..553fb701be5 100644
--- a/sys/dev/sbus/if_le_ledma.c
+++ b/sys/dev/sbus/if_le_ledma.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_ledma.c,v 1.28 2007/10/19 12:01:11 ad Exp $ */
+/* $NetBSD: if_le_ledma.c,v 1.29 2008/04/04 12:25:07 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_ledma.c,v 1.28 2007/10/19 12:01:11 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_ledma.c,v 1.29 2008/04/04 12:25:07 tsutsui Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -74,6 +74,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_le_ledma.c,v 1.28 2007/10/19 12:01:11 ad Exp $");
#include <dev/ic/am7990reg.h>
#include <dev/ic/am7990var.h>
+#include "ioconf.h"
+
/*
* LANCE registers.
*/
@@ -93,8 +95,8 @@ struct le_softc {
#define MEMSIZE (16*1024) /* LANCE memory size */
#define LEDMA_BOUNDARY (16*1024*1024) /* must not cross 16MB boundary */
-int lematch_ledma(struct device *, struct cfdata *, void *);
-void leattach_ledma(struct device *, struct device *, void *);
+int lematch_ledma(device_t, cfdata_t, void *);
+void leattach_ledma(device_t, device_t, void *);
/*
* Media types supported by the Sun4m.
@@ -104,7 +106,7 @@ static int lemedia[] = {
IFM_ETHER|IFM_10_5,
IFM_ETHER|IFM_AUTO,
};
-#define NLEMEDIA (sizeof(lemedia) / sizeof(lemedia[0]))
+#define NLEMEDIA __arraycount(lemedia)
void lesetutp(struct lance_softc *);
void lesetaui(struct lance_softc *);
@@ -112,25 +114,21 @@ void lesetaui(struct lance_softc *);
int lemediachange(struct lance_softc *);
void lemediastatus(struct lance_softc *, struct ifmediareq *);
-CFATTACH_DECL(le_ledma, sizeof(struct le_softc),
+CFATTACH_DECL_NEW(le_ledma, sizeof(struct le_softc),
lematch_ledma, leattach_ledma, NULL, NULL);
-extern struct cfdriver le_cd;
-
#if defined(_KERNEL_OPT)
#include "opt_ddb.h"
#endif
-static void lewrcsr(struct lance_softc *, u_int16_t, u_int16_t);
-static u_int16_t lerdcsr(struct lance_softc *, u_int16_t);
+static void lewrcsr(struct lance_softc *, uint16_t, uint16_t);
+static uint16_t lerdcsr(struct lance_softc *, uint16_t);
static void lehwreset(struct lance_softc *);
static void lehwinit(struct lance_softc *);
static void lenocarrier(struct lance_softc *);
static void
-lewrcsr(sc, port, val)
- struct lance_softc *sc;
- u_int16_t port, val;
+lewrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_space_tag_t t = lesc->sc_bustag;
@@ -149,10 +147,8 @@ lewrcsr(sc, port, val)
#endif
}
-static u_int16_t
-lerdcsr(sc, port)
- struct lance_softc *sc;
- u_int16_t port;
+static uint16_t
+lerdcsr(struct lance_softc *sc, uint16_t port)
{
struct le_softc *lesc = (struct le_softc *)sc;
bus_space_tag_t t = lesc->sc_bustag;
@@ -163,11 +159,10 @@ lerdcsr(sc, port)
}
void
-lesetutp(sc)
- struct lance_softc *sc;
+lesetutp(struct lance_softc *sc)
{
struct lsi64854_softc *dma = ((struct le_softc *)sc)->sc_dma;
- u_int32_t csr;
+ uint32_t csr;
csr = L64854_GCSR(dma);
csr |= E_TP_AUI;
@@ -176,11 +171,10 @@ lesetutp(sc)
}
void
-lesetaui(sc)
- struct lance_softc *sc;
+lesetaui(struct lance_softc *sc)
{
struct lsi64854_softc *dma = ((struct le_softc *)sc)->sc_dma;
- u_int32_t csr;
+ uint32_t csr;
csr = L64854_GCSR(dma);
csr &= ~E_TP_AUI;
@@ -189,8 +183,7 @@ lesetaui(sc)
}
int
-lemediachange(sc)
- struct lance_softc *sc;
+lemediachange(struct lance_softc *sc)
{
struct ifmedia *ifm = &sc->sc_media;
@@ -223,9 +216,7 @@ lemediachange(sc)
}
void
-lemediastatus(sc, ifmr)
- struct lance_softc *sc;
- struct ifmediareq *ifmr;
+lemediastatus(struct lance_softc *sc, struct ifmediareq *ifmr)
{
struct lsi64854_softc *dma = ((struct le_softc *)sc)->sc_dma;
@@ -239,12 +230,11 @@ lemediastatus(sc, ifmr)
}
static void
-lehwreset(sc)
- struct lance_softc *sc;
+lehwreset(struct lance_softc *sc)
{
struct le_softc *lesc = (struct le_softc *)sc;
struct lsi64854_softc *dma = lesc->sc_dma;
- u_int32_t csr;
+ uint32_t csr;
u_int aui_bit;
/*
@@ -271,8 +261,7 @@ lehwreset(sc)
}
static void
-lehwinit(sc)
- struct lance_softc *sc;
+lehwinit(struct lance_softc *sc)
{
/*
@@ -291,8 +280,7 @@ lehwinit(sc)
}
static void
-lenocarrier(sc)
- struct lance_softc *sc;
+lenocarrier(struct lance_softc *sc)
{
struct le_softc *lesc = (struct le_softc *)sc;
@@ -300,7 +288,7 @@ lenocarrier(sc)
* Check if the user has requested a certain cable type, and
* if so, honor that request.
*/
- printf("%s: lost carrier on ", sc->sc_dev.dv_xname);
+ printf("%s: lost carrier on ", device_xname(sc->sc_dev));
if (L64854_GCSR(lesc->sc_dma) & E_TP_AUI) {
printf("UTP port");
@@ -323,10 +311,7 @@ lenocarrier(sc)
}
int
-lematch_ledma(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+lematch_ledma(device_t parent, cfdata_t cf, void *aux)
{
struct sbus_attach_args *sa = aux;
@@ -335,18 +320,17 @@ lematch_ledma(parent, cf, aux)
void
-leattach_ledma(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+leattach_ledma(device_t parent, device_t self, void *aux)
{
- struct sbus_attach_args *sa = aux;
- struct le_softc *lesc = (struct le_softc *)self;
- struct lsi64854_softc *lsi = (struct lsi64854_softc *)parent;
+ struct le_softc *lesc = device_private(self);
struct lance_softc *sc = &lesc->sc_am7990.lsc;
+ struct lsi64854_softc *lsi = device_private(parent);
+ struct sbus_attach_args *sa = aux;
bus_dma_tag_t dmatag = sa->sa_dmatag;
bus_dma_segment_t seg;
int rseg, error;
+ sc->sc_dev = self;
lesc->sc_bustag = sa->sa_bustag;
/* Establish link to `ledma' device */
@@ -359,7 +343,7 @@ leattach_ledma(parent, self, aux)
sa->sa_offset,
sa->sa_size,
0, &lesc->sc_reg) != 0) {
- printf("%s @ ledma: cannot map registers\n", self->dv_xname);
+ aprint_error(": cannot map registers\n");
return;
}
@@ -370,15 +354,14 @@ leattach_ledma(parent, self, aux)
if ((error = bus_dmamap_create(dmatag, MEMSIZE, 1, MEMSIZE,
LEDMA_BOUNDARY, BUS_DMA_NOWAIT,
&lesc->sc_dmamap)) != 0) {
- printf("%s: DMA map create error %d\n", self->dv_xname, error);
+ aprint_error(": DMA map create error %d\n", error);
return;
}
/* Allocate DMA buffer */
if ((error = bus_dmamem_alloc(dmatag, MEMSIZE, 0, LEDMA_BOUNDARY,
&seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
- printf("%s @ ledma: DMA buffer alloc error %d\n",
- self->dv_xname, error);
+ aprint_error(": DMA buffer alloc error %d\n",error);
return;
}
@@ -386,8 +369,7 @@ leattach_ledma(parent, self, aux)
if ((error = bus_dmamem_map(dmatag, &seg, rseg, MEMSIZE,
(void **)&sc->sc_mem,
BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
- printf("%s @ ledma: DMA buffer map error %d\n",
- self->dv_xname, error);
+ aprint_error(": DMA buffer map error %d\n", error);
bus_dmamem_free(dmatag, &seg, rseg);
return;
}
@@ -395,8 +377,7 @@ leattach_ledma(parent, self, aux)
/* Load DMA buffer */
if ((error = bus_dmamap_load(dmatag, lesc->sc_dmamap, sc->sc_mem,
MEMSIZE, NULL, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
- printf("%s: DMA buffer map load error %d\n",
- self->dv_xname, error);
+ aprint_error(": DMA buffer map load error %d\n", error);
bus_dmamem_free(dmatag, &seg, rseg);
bus_dmamem_unmap(dmatag, sc->sc_mem, MEMSIZE);
return;
diff --git a/sys/dev/tc/if_le_ioasic.c b/sys/dev/tc/if_le_ioasic.c
index 9aaf1393816..186cbd9c53f 100644
--- a/sys/dev/tc/if_le_ioasic.c
+++ b/sys/dev/tc/if_le_ioasic.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_ioasic.c,v 1.29 2007/03/04 15:17:06 yamt Exp $ */
+/* $NetBSD: if_le_ioasic.c,v 1.30 2008/04/04 12:25:07 tsutsui Exp $ */
/*
* Copyright (c) 1996 Carnegie-Mellon University.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_ioasic.c,v 1.29 2007/03/04 15:17:06 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_ioasic.c,v 1.30 2008/04/04 12:25:07 tsutsui Exp $");
#include "opt_inet.h"
@@ -71,10 +71,10 @@ struct le_ioasic_softc {
bus_dmamap_t sc_dmamap; /* bus dmamap */
};
-static int le_ioasic_match(struct device *, struct cfdata *, void *);
-static void le_ioasic_attach(struct device *, struct device *, void *);
+static int le_ioasic_match(device_t, cfdata_t, void *);
+static void le_ioasic_attach(device_t, device_t, void *);
-CFATTACH_DECL(le_ioasic, sizeof(struct le_softc),
+CFATTACH_DECL_NEW(le_ioasic, sizeof(struct le_softc),
le_ioasic_match, le_ioasic_attach, NULL, NULL);
static void le_ioasic_copytobuf_gap2(struct lance_softc *, void *, int, int);
@@ -85,7 +85,7 @@ static void le_ioasic_copyfrombuf_gap16(struct lance_softc *, void *,
static void le_ioasic_zerobuf_gap16(struct lance_softc *, int, int);
static int
-le_ioasic_match(struct device *parent, struct cfdata *match, void *aux)
+le_ioasic_match(device_t parent, cfdata_t cf, void *aux)
{
struct ioasicdev_attach_args *d = aux;
@@ -96,11 +96,11 @@ le_ioasic_match(struct device *parent, struct cfdata *match, void *aux)
}
/* IOASIC LANCE DMA needs 128KB boundary aligned 128KB chunk */
-#define LE_IOASIC_MEMSIZE (128*1024)
-#define LE_IOASIC_MEMALIGN (128*1024)
+#define LE_IOASIC_MEMSIZE (128 * 1024)
+#define LE_IOASIC_MEMALIGN (128 * 1024)
static void
-le_ioasic_attach(struct device *parent, struct device *self, void *aux)
+le_ioasic_attach(device_t parent, device_t self, void *aux)
{
struct le_ioasic_softc *sc = device_private(self);
struct ioasicdev_attach_args *d = aux;
@@ -111,10 +111,11 @@ le_ioasic_attach(struct device *parent, struct device *self, void *aux)
bus_dma_tag_t dmat;
bus_dma_segment_t seg;
tc_addr_t tca;
- u_int32_t ssr;
+ uint32_t ssr;
int rseg;
void *le_iomem;
+ le->sc_dev = self;
ioasic_bst = iosc->sc_bst;
ioasic_bsh = iosc->sc_bsh;
dmat = sc->sc_dmat = iosc->sc_dmat;
@@ -123,12 +124,12 @@ le_ioasic_attach(struct device *parent, struct device *self, void *aux)
*/
if (bus_dmamem_alloc(dmat, LE_IOASIC_MEMSIZE, LE_IOASIC_MEMALIGN,
0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) {
- printf("can't allocate DMA area for LANCE\n");
+ aprint_error(": can't allocate DMA area for LANCE\n");
return;
}
if (bus_dmamem_map(dmat, &seg, rseg, LE_IOASIC_MEMSIZE,
&le_iomem, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) {
- printf("can't map DMA area for LANCE\n");
+ aprint_error(": can't map DMA area for LANCE\n");
bus_dmamem_free(dmat, &seg, rseg);
return;
}
@@ -137,12 +138,12 @@ le_ioasic_attach(struct device *parent, struct device *self, void *aux)
*/
if (bus_dmamap_create(dmat, LE_IOASIC_MEMSIZE, 1,
LE_IOASIC_MEMSIZE, 0, BUS_DMA_NOWAIT, &sc->sc_dmamap)) {
- printf("can't create DMA map\n");
+ aprint_error(": can't create DMA map\n");
goto bad;
}
if (bus_dmamap_load(dmat, sc->sc_dmamap,
le_iomem, LE_IOASIC_MEMSIZE, NULL, BUS_DMA_NOWAIT)) {
- printf("can't load DMA map\n");
+ aprint_error(": can't load DMA map\n");
goto bad;
}
/*
@@ -164,7 +165,7 @@ le_ioasic_attach(struct device *parent, struct device *self, void *aux)
le->sc_zerobuf = le_ioasic_zerobuf_gap16;
dec_le_common_attach(&sc->sc_am7990,
- (u_char *)iosc->sc_base + IOASIC_SLOT_2_START);
+ (uint8_t *)iosc->sc_base + IOASIC_SLOT_2_START);
ioasic_intr_establish(parent, d->iada_cookie, TC_IPL_NET,
am7990_intr, sc);
@@ -191,17 +192,17 @@ void
le_ioasic_copytobuf_gap2(struct lance_softc *sc, void *fromv, int boff, int len)
{
volatile void *buf = sc->sc_mem;
- char *from = fromv;
- volatile u_int16_t *bptr;
+ uint8_t *from = fromv;
+ volatile uint16_t *bptr;
if (boff & 0x1) {
/* handle unaligned first byte */
- bptr = ((volatile u_int16_t *)buf) + (boff - 1);
+ bptr = ((volatile uint16_t *)buf) + (boff - 1);
*bptr = (*from++ << 8) | (*bptr & 0xff);
bptr += 2;
len--;
} else
- bptr = ((volatile u_int16_t *)buf) + boff;
+ bptr = ((volatile uint16_t *)buf) + boff;
while (len > 1) {
*bptr = (from[1] << 8) | (from[0] & 0xff);
bptr += 2;
@@ -209,25 +210,25 @@ le_ioasic_copytobuf_gap2(struct lance_softc *sc, void *fromv, int boff, int len)
len -= 2;
}
if (len == 1)
- *bptr = (u_int16_t)*from;
+ *bptr = (uint16_t)*from;
}
void
le_ioasic_copyfrombuf_gap2(struct lance_softc *sc, void *tov, int boff, int len)
{
volatile void *buf = sc->sc_mem;
- char *to = tov;
- volatile u_int16_t *bptr;
- u_int16_t tmp;
+ uint8_t *to = tov;
+ volatile uint16_t *bptr;
+ uint16_t tmp;
if (boff & 0x1) {
/* handle unaligned first byte */
- bptr = ((volatile u_int16_t *)buf) + (boff - 1);
+ bptr = ((volatile uint16_t *)buf) + (boff - 1);
*to++ = (*bptr >> 8) & 0xff;
bptr += 2;
len--;
} else
- bptr = ((volatile u_int16_t *)buf) + boff;
+ bptr = ((volatile uint16_t *)buf) + boff;
while (len > 1) {
tmp = *bptr;
*to++ = tmp & 0xff;
@@ -249,9 +250,9 @@ void
le_ioasic_copytobuf_gap16(struct lance_softc *sc, void *fromv, int boff,
int len)
{
- char *buf = (char *)sc->sc_mem;
- char *from = fromv;
- char *bptr;
+ uint8_t *buf = sc->sc_mem;
+ uint8_t *from = fromv;
+ uint8_t *bptr;
bptr = buf + ((boff << 1) & ~0x1f);
boff &= 0xf;
@@ -271,20 +272,20 @@ le_ioasic_copytobuf_gap16(struct lance_softc *sc, void *fromv, int boff,
/* Destination of copies is now 16-byte aligned. */
if (len >= 16)
- switch ((u_long)from & (sizeof(u_int32_t) -1)) {
+ switch ((u_long)from & (sizeof(uint32_t) -1)) {
case 2:
/* Ethernet headers make this the dominant case. */
do {
- u_int32_t *dst = (u_int32_t*)bptr;
- u_int16_t t0;
- u_int32_t t1, t2, t3, t4;
+ uint32_t *dst = (uint32_t *)bptr;
+ uint16_t t0;
+ uint32_t t1, t2, t3, t4;
/* read from odd-16-bit-aligned, cached src */
- t0 = *(u_int16_t*)from;
- t1 = *(u_int32_t*)(from+2);
- t2 = *(u_int32_t*)(from+6);
- t3 = *(u_int32_t*)(from+10);
- t4 = *(u_int16_t*)(from+14);
+ t0 = *(uint16_t *)(from + 0);
+ t1 = *(uint32_t *)(from + 2);
+ t2 = *(uint32_t *)(from + 6);
+ t3 = *(uint32_t *)(from + 10);
+ t4 = *(uint16_t *)(from + 14);
/* DMA buffer is uncached on mips */
dst[0] = t0 | (t1 << 16);
@@ -300,9 +301,9 @@ le_ioasic_copytobuf_gap16(struct lance_softc *sc, void *fromv, int boff,
case 0:
do {
- u_int32_t *src = (u_int32_t*)from;
- u_int32_t *dst = (u_int32_t*)bptr;
- u_int32_t t0, t1, t2, t3;
+ uint32_t *src = (uint32_t*)from;
+ uint32_t *dst = (uint32_t*)bptr;
+ uint32_t t0, t1, t2, t3;
t0 = src[0]; t1 = src[1]; t2 = src[2]; t3 = src[3];
dst[0] = t0; dst[1] = t1; dst[2] = t2; dst[3] = t3;
@@ -331,9 +332,9 @@ void
le_ioasic_copyfrombuf_gap16(struct lance_softc *sc, void *tov, int boff,
int len)
{
- char *buf = sc->sc_mem;
- char *to = tov;
- char *bptr;
+ uint8_t *buf = sc->sc_mem;
+ uint8_t *to = tov;
+ uint8_t *bptr;
bptr = buf + ((boff << 1) & ~0x1f);
boff &= 0xf;
@@ -342,31 +343,31 @@ le_ioasic_copyfrombuf_gap16(struct lance_softc *sc, void *tov, int boff,
if (boff) {
int xfer;
xfer = min(len, 16 - boff);
- bcopy(bptr+boff, to, xfer);
+ bcopy(bptr + boff, to, xfer);
to += xfer;
bptr += 32;
len -= xfer;
}
if (len >= 16)
- switch ((u_long)to & (sizeof(u_int32_t) -1)) {
+ switch ((u_long)to & (sizeof(uint32_t) -1)) {
case 2:
/*
* to is aligned to an odd 16-bit boundary. Ethernet headers
* make this the dominant case (98% or more).
*/
do {
- u_int32_t *src = (u_int32_t*)bptr;
- u_int32_t t0, t1, t2, t3;
+ uint32_t *src = (uint32_t *)bptr;
+ uint32_t t0, t1, t2, t3;
/* read from uncached aligned DMA buf */
t0 = src[0]; t1 = src[1]; t2 = src[2]; t3 = src[3];
/* write to odd-16-bit-word aligned dst */
- *(u_int16_t *) (to+0) = (u_short) t0;
- *(u_int32_t *) (to+2) = (t0 >> 16) | (t1 << 16);
- *(u_int32_t *) (to+6) = (t1 >> 16) | (t2 << 16);
- *(u_int32_t *) (to+10) = (t2 >> 16) | (t3 << 16);
- *(u_int16_t *) (to+14) = (t3 >> 16);
+ *(uint16_t *)(to + 0) = (uint16_t)t0;
+ *(uint32_t *)(to + 2) = (t0 >> 16) | (t1 << 16);
+ *(uint32_t *)(to + 6) = (t1 >> 16) | (t2 << 16);
+ *(uint32_t *)(to + 10) = (t2 >> 16) | (t3 << 16);
+ *(uint16_t *)(to + 14) = (t3 >> 16);
bptr += 32;
to += 16;
len -= 16;
@@ -375,9 +376,9 @@ le_ioasic_copyfrombuf_gap16(struct lance_softc *sc, void *tov, int boff,
case 0:
/* 32-bit aligned aligned copy. Rare. */
do {
- u_int32_t *src = (u_int32_t*)bptr;
- u_int32_t *dst = (u_int32_t*)to;
- u_int32_t t0, t1, t2, t3;
+ uint32_t *src = (uint32_t *)bptr;
+ uint32_t *dst = (uint32_t *)to;
+ uint32_t t0, t1, t2, t3;
t0 = src[0]; t1 = src[1]; t2 = src[2]; t3 = src[3];
dst[0] = t0; dst[1] = t1; dst[2] = t2; dst[3] = t3;
@@ -404,8 +405,8 @@ le_ioasic_copyfrombuf_gap16(struct lance_softc *sc, void *tov, int boff,
void
le_ioasic_zerobuf_gap16(struct lance_softc *sc, int boff, int len)
{
- char *buf = sc->sc_mem;
- char *bptr;
+ uint8_t *buf = sc->sc_mem;
+ uint8_t *bptr;
int xfer;
bptr = buf + ((boff << 1) & ~0x1f);
diff --git a/sys/dev/tc/if_le_tc.c b/sys/dev/tc/if_le_tc.c
index b6f22706729..dae007ea6ba 100644
--- a/sys/dev/tc/if_le_tc.c
+++ b/sys/dev/tc/if_le_tc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_tc.c,v 1.20 2006/03/31 17:39:33 thorpej Exp $ */
+/* $NetBSD: if_le_tc.c,v 1.21 2008/04/04 12:25:07 tsutsui Exp $ */
/*
* Copyright (c) 1996 Carnegie-Mellon University.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_tc.c,v 1.20 2006/03/31 17:39:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_tc.c,v 1.21 2008/04/04 12:25:07 tsutsui Exp $");
#include "opt_inet.h"
@@ -60,10 +60,10 @@ __KERNEL_RCSID(0, "$NetBSD: if_le_tc.c,v 1.20 2006/03/31 17:39:33 thorpej Exp $"
#include <dev/tc/if_levar.h>
#include <dev/tc/tcvar.h>
-static int le_tc_match(struct device *, struct cfdata *, void *);
-static void le_tc_attach(struct device *, struct device *, void *);
+static int le_tc_match(device_t, cfdata_t, void *);
+static void le_tc_attach(device_t, device_t, void *);
-CFATTACH_DECL(le_tc, sizeof(struct le_softc),
+CFATTACH_DECL_NEW(le_tc, sizeof(struct le_softc),
le_tc_match, le_tc_attach, NULL, NULL);
#define LE_OFFSET_RAM 0x0
@@ -71,7 +71,7 @@ CFATTACH_DECL(le_tc, sizeof(struct le_softc),
#define LE_OFFSET_ROM 0x1c0000
static int
-le_tc_match(struct device *parent, struct cfdata *match, void *aux)
+le_tc_match(device_t parent, cfdata_t cf, void *aux)
{
struct tc_attach_args *d = aux;
@@ -82,12 +82,14 @@ le_tc_match(struct device *parent, struct cfdata *match, void *aux)
}
static void
-le_tc_attach(struct device *parent, struct device *self, void *aux)
+le_tc_attach(device_t parent, device_t self, void *aux)
{
struct le_softc *lesc = device_private(self);
struct lance_softc *sc = &lesc->sc_am7990.lsc;
struct tc_attach_args *d = aux;
+ sc->sc_dev = self;
+
/*
* It's on the turbochannel proper, or a kn02
* baseboard implementation of a TC option card.
@@ -109,7 +111,7 @@ le_tc_attach(struct device *parent, struct device *self, void *aux)
*/
dec_le_common_attach(&lesc->sc_am7990,
- (u_char *)(d->ta_addr + LE_OFFSET_ROM + 2));
+ (uint8_t *)(d->ta_addr + LE_OFFSET_ROM + 2));
tc_intr_establish(parent, d->ta_cookie, TC_IPL_NET, am7990_intr, sc);
}