summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authormsaitoh <msaitoh@NetBSD.org>2019-04-25 10:08:45 +0000
committermsaitoh <msaitoh@NetBSD.org>2019-04-25 10:08:45 +0000
commitea20c19bec2534495931321f7846abd1ca0146a2 (patch)
treea4625f8a1ec247d82c7d1b64bb177785acb12ddf /sys/arch
parentc518611761c3db696659d546fcbad5d18967fe52 (diff)
No functional change:
- Use __arraycount(). - u_int_{8,16,32}_t -> uint_{8,16,32}_t - KNF. - Tabify. - Remove extra space.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/acorn32/eb7500atx/if_cs.c52
-rw-r--r--sys/arch/acorn32/podulebus/if_ne_pbus.c94
-rw-r--r--sys/arch/hppa/gsc/if_ie_gsc.c54
-rw-r--r--sys/arch/macppc/dev/if_mc.c54
-rw-r--r--sys/arch/sparc/dev/if_ie_obio.c48
-rw-r--r--sys/arch/sparc/dev/if_le_obio.c33
-rw-r--r--sys/arch/sun2/dev/if_ie_mbmem.c82
-rw-r--r--sys/arch/sun2/dev/if_ie_obio.c62
8 files changed, 228 insertions, 251 deletions
diff --git a/sys/arch/acorn32/eb7500atx/if_cs.c b/sys/arch/acorn32/eb7500atx/if_cs.c
index cdad6328369..a6d9a5582bb 100644
--- a/sys/arch/acorn32/eb7500atx/if_cs.c
+++ b/sys/arch/acorn32/eb7500atx/if_cs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_cs.c,v 1.10 2015/04/13 21:18:40 riastradh Exp $ */
+/* $NetBSD: if_cs.c,v 1.11 2019/04/25 10:08:45 msaitoh Exp $ */
/*
* Copyright (c) 2004 Christopher Gilbert
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cs.c,v 1.10 2015/04/13 21:18:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cs.c,v 1.11 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -86,14 +86,14 @@ __KERNEL_RCSID(0, "$NetBSD: if_cs.c,v 1.10 2015/04/13 21:18:40 riastradh Exp $")
*
* IRQ is mapped as:
* CS8920 IRQ 3 INT5
- *
+ *
* It must be configured as the following:
* The CS8920 PNP address should be configured for ISA base at 0x300
- * to achieve the default register mapping as specified.
+ * to achieve the default register mapping as specified.
* Note memory addresses are all have bit 23 tied high in hardware.
* This only effects the value programmed into the CS8920 memory offset
- * registers.
- *
+ * registers.
+ *
* Just to add to the fun the I/O registers are layed out as:
* xxxxR1R0
* xxxxR3R2
@@ -102,8 +102,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_cs.c,v 1.10 2015/04/13 21:18:40 riastradh Exp $")
* This works fine for 16bit accesses, but it makes access to single
* register hard (which does happen on a reset, as we've got to toggle
* the chip into 16bit mode)
- *
- * Network DRQ is connected to DRQ5
+ *
+ * Network DRQ is connected to DRQ5
*/
/*
@@ -121,18 +121,18 @@ CFATTACH_DECL_NEW(cs_rsbus, sizeof(struct cs_softc),
/* Available media */
int cs_rbus_media [] = {
- IFM_ETHER|IFM_10_T|IFM_FDX,
- IFM_ETHER|IFM_10_T
+ IFM_ETHER | IFM_10_T | IFM_FDX,
+ IFM_ETHER | IFM_10_T
};
-int
+int
cs_rsbus_probe(device_t parent, cfdata_t cf, void *aux)
{
- /* for now it'll always attach */
+ /* For now it'll always attach */
return 1;
}
-void
+void
cs_rsbus_attach(device_t parent, device_t self, void *aux)
{
struct cs_softc *sc = device_private(self);
@@ -141,12 +141,12 @@ cs_rsbus_attach(device_t parent, device_t self, void *aux)
sc->sc_dev = self;
- /* member copy */
+ /* Member copy */
cs_rsbus_bs_tag = *rs->sa_iot;
-
- /* registers are normally accessed in pairs, on a 4 byte aligned */
+
+ /* Registers are normally accessed in pairs, on a 4 byte aligned */
cs_rsbus_bs_tag.bs_cookie = (void *) 1;
-
+
sc->sc_iot = sc->sc_memt = &cs_rsbus_bs_tag;
#if 0 /* Do DMA later */
@@ -156,14 +156,12 @@ cs_rsbus_attach(device_t parent, device_t self, void *aux)
isc->sc_drq = -1;
#endif
- /* device always interrupts on 3 but that routes to IRQ 5 */
+ /* Device always interrupts on 3 but that routes to IRQ 5 */
sc->sc_irq = 3;
printf("\n");
- /*
- * Map the device.
- */
+ /* Map the device. */
iobase = 0x03010600;
if (bus_space_map(sc->sc_iot, iobase, CS8900_IOSIZE * 4,
0, &sc->sc_ioh)) {
@@ -178,7 +176,7 @@ cs_rsbus_attach(device_t parent, device_t self, void *aux)
} else {
sc->sc_cfgflags |= CFGFLG_MEM_MODE | CFGFLG_USE_SA;
sc->sc_pktpgaddr = 1<<23;
- //(0x4000 >> 1) | (1<<23);
+ //(0x4000 >> 1) | (1<<23);
}
#endif
sc->sc_ih = intr_claim(IRQ_INT5, IPL_NET, "cs", cs_intr, sc);
@@ -196,12 +194,12 @@ cs_rsbus_attach(device_t parent, device_t self, void *aux)
sc->sc_cfgflags |= CFGFLG_PARSE_EEPROM;
sc->sc_io_read_1 = cs_rbus_read_1;
- /*
+ /*
* also provide media, otherwise it attempts to read the media from
* the EEPROM, which again fails
*/
- cs_attach(sc, NULL, cs_rbus_media, sizeof(cs_rbus_media) / sizeof(cs_rbus_media[0]),
- IFM_ETHER|IFM_10_T|IFM_FDX);
+ cs_attach(sc, NULL, cs_rbus_media, __arraycount(cs_rbus_media),
+ IFM_ETHER |IFM_10_T | IFM_FDX);
}
/*
@@ -212,14 +210,14 @@ static uint8_t
cs_rbus_read_1(struct cs_softc *sc, bus_size_t a)
{
bus_size_t offset;
- /*
+ /*
* if it's an even address then just use the bus_space_read_1
*/
if ((a & 1) == 0)
{
return bus_space_read_1(sc->sc_iot, sc->sc_ioh, a);
}
- /*
+ /*
* otherwise we've get to work out the aligned address and then add
* one
*/
diff --git a/sys/arch/acorn32/podulebus/if_ne_pbus.c b/sys/arch/acorn32/podulebus/if_ne_pbus.c
index 862fc80fc26..1570d78910b 100644
--- a/sys/arch/acorn32/podulebus/if_ne_pbus.c
+++ b/sys/arch/acorn32/podulebus/if_ne_pbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ne_pbus.c,v 1.18 2014/01/21 19:30:46 christos Exp $ */
+/* $NetBSD: if_ne_pbus.c,v 1.19 2019/04/25 10:08:45 msaitoh Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ne_pbus.c,v 1.18 2014/01/21 19:30:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ne_pbus.c,v 1.19 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -211,16 +211,16 @@ struct ne_clone {
static int
ne_pbus_probe(device_t parent, cfdata_t cf, void *aux)
{
- struct podule_attach_args *pa = (void *) aux;
+ struct podule_attach_args *pa = (void *)aux;
int loop;
/* Scan the list of known interfaces looking for a match */
for (loop = 0; loop < sizeof(ne_clones) / sizeof(struct ne_clone);
++loop) {
if (pa->pa_product == ne_clones[loop].product)
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
/*
@@ -358,7 +358,7 @@ ne_pbus_attach(device_t parent, device_t self, void *aux)
if (ne->preattach)
ne->preattach(npsc);
- /* if the interface has media support initialise it */
+ /* If the interface has media support initialise it */
if (ne->init_media) {
dsc->sc_mediachange = ne->mediachange;
dsc->sc_mediastatus = ne->mediastatus;
@@ -389,7 +389,7 @@ ne_pbus_attach(device_t parent, device_t self, void *aux)
case NE2000_TYPE_DL10019:
aprint_normal("DL10019");
break;
- case NE2000_TYPE_DL10022:
+ case NE2000_TYPE_DL10022:
aprint_normal("DL10022");
break;
default:
@@ -409,7 +409,7 @@ ne_pbus_attach(device_t parent, device_t self, void *aux)
if (npsc->sc_ih == NULL)
panic("%s: Cannot install interrupt handler",
device_xname(self));
- /* this feels wrong to do this here */
+ /* This feels wrong to do this here */
npsc->sc_ih->ih_maskaddr = npsc->sc_podule->irq_addr;
npsc->sc_ih->ih_maskbits = npsc->sc_podule->irq_mask;
}
@@ -430,7 +430,7 @@ em_ea(struct ne_pbus_softc *sc, uint8_t *buffer)
*/
netslot_ea(buffer);
- return(buffer);
+ return buffer;
}
/*
@@ -479,8 +479,8 @@ em_postattach(struct ne_pbus_softc *sc)
/*
* eh600_preattach()
*
- * pre-initialise the AT/Lantic chipset so that the card probes and
- * detects properly.
+ * pre-initialise the AT/Lantic chipset so that the card probes and
+ * detects properly.
*/
static void
eh600_preattach(struct ne_pbus_softc *sc)
@@ -490,22 +490,22 @@ eh600_preattach(struct ne_pbus_softc *sc)
struct dp8390_softc *dsc = &nsc->sc_dp8390;
bus_space_tag_t nict = dsc->sc_regt;
bus_space_handle_t nich = dsc->sc_regh;
-
- /* initialise EH600 config register */
+
+ /* Initialise EH600 config register */
bus_space_read_1(nict, nich, DP83905_MCRA);
bus_space_write_1(nict, nich, DP83905_MCRA, DP83905_MCRA_INT3);
- /* enable interrupts for the card */
- tmp = bus_space_read_1(&sc->sc_tag,sc->sc_extrah,0);
+ /* Enable interrupts for the card */
+ tmp = bus_space_read_1(&sc->sc_tag,sc->sc_extrah,0);
tmp |= EH_INTR_MASK;
- bus_space_write_1(&sc->sc_tag,sc->sc_extrah,0,tmp);
+ bus_space_write_1(&sc->sc_tag,sc->sc_extrah,0,tmp);
}
/*
* eh600_postattach()
*
- * Etherlan 600 has 32k of buffer memory as it runs the AT/Lantic
- * DP8390 clone in IO non-compatible mode. We need to adjust the memory
+ * Etherlan 600 has 32k of buffer memory as it runs the AT/Lantic
+ * DP8390 clone in IO non-compatible mode. We need to adjust the memory
* description set up by dp8390.c and ne2000.c to reflect this.
*/
static void
@@ -513,24 +513,25 @@ eh600_postattach(struct ne_pbus_softc *sc)
{
struct ne2000_softc *nsc = &sc->sc_ne2000;
struct dp8390_softc *dsc = &nsc->sc_dp8390;
- /* first page is mapped to the PROM. so start at 2nd page */
+
+ /* First page is mapped to the PROM. so start at 2nd page */
dsc->mem_start = EH600_MEM_START;
dsc->mem_size = EH600_MEM_END - EH600_MEM_START;
dsc->mem_end = EH600_MEM_END;
dsc->txb_cnt = 3; /* >16k of ram setup 3 tx buffers */
- /* recompute the mem ring (taken straight from the ne2000 init code) */
- dsc->mem_ring =
- dsc->mem_start +
+ /* Recompute the mem ring (taken straight from the ne2000 init code) */
+ dsc->mem_ring =
+ dsc->mem_start +
(((dsc->txb_cnt + 1) * ED_TXBUF_SIZE ) <<
ED_PAGE_SHIFT);
- /* recompute the dp8390 register values. (from dp8390 init code) */
+ /* Recompute the dp8390 register values. (from dp8390 init code) */
dsc->tx_page_start = dsc->mem_start >> ED_PAGE_SHIFT;
- dsc->rec_page_start = dsc->tx_page_start +
+ dsc->rec_page_start = dsc->tx_page_start +
(dsc->txb_cnt + 1) * ED_TXBUF_SIZE;
- dsc->rec_page_stop = dsc->tx_page_start +
+ dsc->rec_page_stop = dsc->tx_page_start +
(dsc->mem_size >> ED_PAGE_SHIFT);
aprint_normal_dev(dsc->sc_dev, "32KB buffer memory\n");
}
@@ -540,13 +541,12 @@ eh600_postattach(struct ne_pbus_softc *sc)
void eh600_init_media(struct dp8390_softc *sc)
{
static int eh600_media[] = {
- IFM_ETHER|IFM_AUTO,
- IFM_ETHER|IFM_10_T,
- IFM_ETHER|IFM_10_2,
+ IFM_ETHER | IFM_AUTO,
+ IFM_ETHER | IFM_10_T,
+ IFM_ETHER | IFM_10_2,
};
- int i, defmedia = IFM_ETHER|IFM_AUTO;
- static const int eh600_nmedia =
- sizeof(eh600_media) / sizeof(eh600_media[0]);
+ int i, defmedia = IFM_ETHER | IFM_AUTO;
+ static const int eh600_nmedia = __arraycount(eh600_media);
aprint_normal_dev(sc->sc_dev,
"10base2, 10baseT, auto, default auto\n");
@@ -555,7 +555,6 @@ void eh600_init_media(struct dp8390_softc *sc)
for (i = 0; i < eh600_nmedia; i++)
ifmedia_add(&sc->sc_media, eh600_media[i], 0, NULL);
ifmedia_set(&sc->sc_media, defmedia);
-
}
@@ -575,6 +574,7 @@ en_init_media(struct dp8390_softc *sc)
static int en_media[] = {
IFM_ETHER|IFM_10_T
};
+
aprint_normal_dev(sc->sc_dev, "10baseT, default 10baseT\n");
ifmedia_init(&sc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus);
@@ -583,12 +583,12 @@ en_init_media(struct dp8390_softc *sc)
}
-/*
+/*
* extracts the station address from the Podule description string.
- * The description has to be re-read here since the podule description
+ * The description has to be re-read here since the podule description
* string is not always long enough to contain the full address.
*
- * If for any reason we cannot extract the address this routine will
+ * If for any reason we cannot extract the address this routine will
* use netslot_ea() to return the generic address for the network slot.
*/
@@ -605,21 +605,21 @@ eh600_ea(struct ne_pbus_softc *sc, uint8_t *buffer)
address = 0x40;
memset(buffer, 0, 6);
- /* read chunks from the podule */
+ /* Read chunks from the podule */
do {
id = POD_READ(address);
- /* check for description chunk. */
+ /* Check for description chunk. */
if (id == 0xf5) {
u_int size;
u_int pod_addr;
int loop;
- /* read the size */
+ /* Read the size */
size = POD_READ(address + 4);
size |= (POD_READ(address + 8) << 8);
size |= (POD_READ(address + 12) << 16);
- /* read address of description */
+ /* Read address of description */
pod_addr = POD_READ(address + 16);
pod_addr |= (POD_READ(address + 20) << 8);
pod_addr |= (POD_READ(address + 24) << 16);
@@ -631,33 +631,33 @@ eh600_ea(struct ne_pbus_softc *sc, uint8_t *buffer)
int found_ether = 0;
/*
- * start scanning for ethernet address
+ * Start scanning for ethernet address
* which starts with a '('
*/
for (loop = 0; loop < size; ++loop) {
if (found_ether) {
- /* we have found a '(' so start decoding the address */
+ /* We have found a '(' so start decoding the address */
tmp = POD_READ((pod_addr + loop) * 4);
if (tmp >= '0' && tmp <= '9') {
buffer[addr_index >> 1] |= (tmp - '0') << ((addr_index & 1) ? 0 : 4);
++addr_index;
}
- else if (tmp >= 'a' && tmp <= 'f'){
+ else if (tmp >= 'a' && tmp <= 'f'){
buffer[addr_index >> 1] |= (10 + (tmp - 'a')) << ((addr_index & 1) ? 0 : 4);
++addr_index;
}
- else if (tmp >= 'A' && tmp <= 'F'){
+ else if (tmp >= 'A' && tmp <= 'F'){
buffer[addr_index >> 1] |= (10 + (tmp - 'A')) << ((addr_index & 1) ? 0 : 4);
++addr_index;
}
else if (tmp == ')') {
- /* we have read the whole address so we can stop scanning
+ /* We have read the whole address so we can stop scanning
* the podule description */
break;
}
}
/*
- * we have found the start of the ethernet address (decode begins
+ * We have found the start of the ethernet address (decode begins
* on the next run round the loop. */
if (POD_READ((pod_addr + loop) * 4) == '(') {
found_ether = 1;
@@ -669,7 +669,7 @@ eh600_ea(struct ne_pbus_softc *sc, uint8_t *buffer)
*/
if (!found_ether)
netslot_ea(buffer);
- return(buffer);
+ return buffer;
}
}
address += 32;
@@ -680,5 +680,5 @@ eh600_ea(struct ne_pbus_softc *sc, uint8_t *buffer)
* In this case the best solution is to go with the netslot addrness
*/
netslot_ea(buffer);
- return(buffer);
+ return buffer;
}
diff --git a/sys/arch/hppa/gsc/if_ie_gsc.c b/sys/arch/hppa/gsc/if_ie_gsc.c
index a88f4678d3c..154e8b47cb7 100644
--- a/sys/arch/hppa/gsc/if_ie_gsc.c
+++ b/sys/arch/hppa/gsc/if_ie_gsc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ie_gsc.c,v 1.3 2019/04/16 12:22:13 skrll Exp $ */
+/* $NetBSD: if_ie_gsc.c,v 1.4 2019/04/25 10:08:45 msaitoh Exp $ */
/* $OpenBSD: if_ie_gsc.c,v 1.6 2001/01/12 22:57:04 mickey Exp $ */
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ie_gsc.c,v 1.3 2019/04/16 12:22:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie_gsc.c,v 1.4 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -120,7 +120,7 @@ CFATTACH_DECL_NEW(ie_gsc, sizeof(struct ie_gsc_softc),
static int ie_gsc_media[] = {
IFM_ETHER | IFM_10_2,
};
-#define IE_NMEDIA (sizeof(ie_gsc_media) / sizeof(ie_gsc_media[0]))
+#define IE_NMEDIA __arraycount(ie_gsc_media)
void ie_gsc_reset(struct ie_softc *, int);
void ie_gsc_attend(struct ie_softc *, int);
@@ -137,7 +137,7 @@ void ie_gsc_memcopyout(struct ie_softc *, const void *, int, size_t);
void
ie_gsc_reset(struct ie_softc *sc, int what)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
int i;
switch (what) {
@@ -149,14 +149,14 @@ ie_gsc_reset(struct ie_softc *sc, int what)
bus_space_write_4(gsc->iot, gsc->ioh, IE_GSC_REG_RESET, 0);
/*
- * per [2] 4.6.2.1
+ * Per [2] 4.6.2.1
* delay for 10 system clocks + 5 transmit clocks,
* NB: works for system clocks over 10MHz
*/
DELAY(1000);
/*
- * after the hardware reset:
+ * After the hardware reset:
* inform i825[89]6 about new SCP address,
* which must be at least 16-byte aligned
*/
@@ -165,7 +165,8 @@ ie_gsc_reset(struct ie_softc *sc, int what)
for (i = 9000; i-- && ie_gsc_read16(sc, IE_ISCP_BUSY(sc->iscp));
DELAY(100))
- pdcache(0, (vaddr_t)sc->sc_maddr + sc->iscp, IE_ISCP_SZ);
+ pdcache(0, (vaddr_t)sc->sc_maddr + sc->iscp,
+ IE_ISCP_SZ);
#if I82596_DEBUG
if (i < 0) {
@@ -183,7 +184,7 @@ ie_gsc_reset(struct ie_softc *sc, int what)
void
ie_gsc_attend(struct ie_softc *sc, int why)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
bus_space_write_4(gsc->iot, gsc->ioh, IE_GSC_REG_ATTN, 0);
}
@@ -198,7 +199,7 @@ ie_gsc_run(struct ie_softc *sc)
void
ie_gsc_port(struct ie_softc *sc, u_int cmd)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
switch (cmd) {
case IE_PORT_RESET:
@@ -239,7 +240,7 @@ ie_gsc_read16(struct ie_softc *sc, int offset)
" fdc %%r0(%1) \n"
: "=&r" (val)
: "r" ((char *)sc->sc_maddr + offset));
- return (val);
+ return val;
}
void
@@ -277,7 +278,7 @@ ie_gsc_write24(struct ie_softc *sc, int offset, int addr)
void
ie_gsc_memcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
if (size == 0)
return;
@@ -291,7 +292,7 @@ ie_gsc_memcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
void
ie_gsc_memcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
if (size == 0)
return;
@@ -309,7 +310,7 @@ int i82596_probe(struct ie_softc *);
int
i82596_probe(struct ie_softc *sc)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
int i;
/* Set up the SCP. */
@@ -342,9 +343,7 @@ i82596_probe(struct ie_softc *sc)
bus_dmamap_sync(gsc->iemt, sc->sc_dmamap, 0, sc->sc_msize,
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
ie_gsc_port(sc, IE_PORT_SELF_TEST);
- for (i = 9000; i-- &&
- sc->ie_bus_read16(sc, 4);
- DELAY(100))
+ for (i = 9000; i-- && sc->ie_bus_read16(sc, 4); DELAY(100))
pdcache(0, (vaddr_t)sc->sc_maddr, sc->sc_msize);
#if I82596_DEBUG
@@ -388,9 +387,7 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
if (ga->ga_type.iodc_sv_model == HPPA_FIO_GLAN)
gsc->flags |= IEGSC_GECKO;
- /*
- * Map the GSC registers.
- */
+ /* Map the GSC registers. */
if (bus_space_map(ga->ga_iot, ga->ga_hpa,
IE_GSC_BANK_SZ, 0, &gsc->ioh)) {
printf(": can't map i/o space\n");
@@ -417,9 +414,7 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
return;
}
- /*
- * Map that physical memory into kernel virtual space.
- */
+ /* Map that physical memory into kernel virtual space. */
if (bus_dmamem_map(gsc->iemt, &seg, rseg, sc->sc_msize,
(void **)&sc->sc_maddr, BUS_DMA_NOWAIT)) {
printf (": can't map DMA memory\n");
@@ -427,9 +422,7 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
return;
}
- /*
- * Create a DMA map for the memory.
- */
+ /* Create a DMA map for the memory. */
if (bus_dmamap_create(gsc->iemt, sc->sc_msize, rseg, sc->sc_msize,
0, BUS_DMA_NOWAIT, &sc->sc_dmamap)) {
printf(": can't create DMA map\n");
@@ -439,12 +432,9 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
return;
}
- /*
- * Load the mapped DMA memory into the DMA map.
- */
- if (bus_dmamap_load(gsc->iemt, sc->sc_dmamap,
- sc->sc_maddr, sc->sc_msize,
- NULL, BUS_DMA_NOWAIT)) {
+ /* Load the mapped DMA memory into the DMA map. */
+ if (bus_dmamap_load(gsc->iemt, sc->sc_dmamap, sc->sc_maddr,
+ sc->sc_msize, NULL, BUS_DMA_NOWAIT)) {
printf(": can't load DMA map\n");
bus_dmamap_destroy(gsc->iemt, sc->sc_dmamap);
bus_dmamem_unmap(gsc->iemt,
@@ -455,7 +445,7 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
#if 1
/* XXX - this should go away. */
- sc->bh = (bus_space_handle_t) sc->sc_maddr;
+ sc->bh = (bus_space_handle_t)sc->sc_maddr;
#endif
#if I82596_DEBUG
diff --git a/sys/arch/macppc/dev/if_mc.c b/sys/arch/macppc/dev/if_mc.c
index 22e6fe49581..e7bc9cc787e 100644
--- a/sys/arch/macppc/dev/if_mc.c
+++ b/sys/arch/macppc/dev/if_mc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_mc.c,v 1.23 2016/07/15 22:10:47 macallan Exp $ */
+/* $NetBSD: if_mc.c,v 1.24 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1997 David Huang <khym@bga.com>
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.23 2016/07/15 22:10:47 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.24 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -61,15 +61,15 @@ __KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.23 2016/07/15 22:10:47 macallan Exp $");
hide int mc_match(device_t, cfdata_t, void *);
hide void mc_attach(device_t, device_t, void *);
-hide void mc_init(struct mc_softc *sc);
-hide void mc_putpacket(struct mc_softc *sc, u_int len);
-hide int mc_dmaintr(void *arg);
-hide void mc_reset_rxdma(struct mc_softc *sc);
-hide void mc_reset_txdma(struct mc_softc *sc);
-hide void mc_select_utp(struct mc_softc *sc);
-hide void mc_select_aui(struct mc_softc *sc);
-hide int mc_mediachange(struct mc_softc *sc);
-hide void mc_mediastatus(struct mc_softc *sc, struct ifmediareq *);
+hide void mc_init(struct mc_softc *);
+hide void mc_putpacket(struct mc_softc *, u_int);
+hide int mc_dmaintr(void *);
+hide void mc_reset_rxdma(struct mc_softc *);
+hide void mc_reset_txdma(struct mc_softc *);
+hide void mc_select_utp(struct mc_softc *);
+hide void mc_select_aui(struct mc_softc *);
+hide int mc_mediachange(struct mc_softc *);
+hide void mc_mediastatus(struct mc_softc *, struct ifmediareq *);
int mc_supmedia[] = {
IFM_ETHER | IFM_10_T,
@@ -77,7 +77,7 @@ int mc_supmedia[] = {
/*IFM_ETHER | IFM_AUTO,*/
};
-#define N_SUPMEDIA (sizeof(mc_supmedia) / sizeof(int));
+#define N_SUPMEDIA __arraycount(mc_supmedia)
CFATTACH_DECL_NEW(mc, sizeof(struct mc_softc),
mc_match, mc_attach, NULL, NULL);
@@ -106,7 +106,7 @@ mc_attach(device_t parent, device_t self, void *aux)
{
struct confargs *ca = aux;
struct mc_softc *sc = device_private(self);
- u_int8_t myaddr[ETHER_ADDR_LEN];
+ uint8_t myaddr[ETHER_ADDR_LEN];
u_int *reg;
sc->sc_dev = self;
@@ -137,13 +137,13 @@ mc_attach(device_t parent, device_t self, void *aux)
return;
}
- /* allocate memory for transmit buffer and mark it non-cacheable */
+ /* Allocate memory for transmit buffer and mark it non-cacheable */
sc->sc_txbuf = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
sc->sc_txbuf_phys = kvtop(sc->sc_txbuf);
memset(sc->sc_txbuf, 0, PAGE_SIZE);
/*
- * allocate memory for receive buffer and mark it non-cacheable
+ * Allocate memory for receive buffer and mark it non-cacheable
* XXX This should use the bus_dma interface, since the buffer
* needs to be physically contiguous. However, it seems that
* at least on my system, malloc() does allocate contiguous
@@ -162,14 +162,13 @@ mc_attach(device_t parent, device_t self, void *aux)
sc->sc_bus_init = mc_init;
sc->sc_putpacket = mc_putpacket;
-
- /* disable receive DMA */
+ /* Disable receive DMA */
dbdma_reset(sc->sc_rxdma);
- /* disable transmit DMA */
+ /* Disable transmit DMA */
dbdma_reset(sc->sc_txdma);
- /* install interrupt handlers */
+ /* Install interrupt handlers */
/*intr_establish(ca->ca_intr[1], IST_EDGE, IPL_NET, mc_dmaintr, sc);*/
intr_establish(ca->ca_intr[2], IST_EDGE, IPL_NET, mc_dmaintr, sc);
intr_establish(ca->ca_intr[0], IST_EDGE, IPL_NET, mcintr, sc);
@@ -266,9 +265,9 @@ mc_dmaintr(void *arg)
sc->sc_rxframe.rx_rcvcnt = sc->sc_rxbuf[statoff + 0];
sc->sc_rxframe.rx_rcvsts = sc->sc_rxbuf[statoff + 1];
- sc->sc_rxframe.rx_rntpc = sc->sc_rxbuf[statoff + 2];
- sc->sc_rxframe.rx_rcvcc = sc->sc_rxbuf[statoff + 3];
- sc->sc_rxframe.rx_frame = sc->sc_rxbuf + offset;
+ sc->sc_rxframe.rx_rntpc = sc->sc_rxbuf[statoff + 2];
+ sc->sc_rxframe.rx_rcvcc = sc->sc_rxbuf[statoff + 3];
+ sc->sc_rxframe.rx_frame = sc->sc_rxbuf + offset;
mc_rint(sc);
@@ -292,7 +291,7 @@ mc_reset_rxdma(struct mc_softc *sc)
dbdma_command_t *cmd = sc->sc_rxdmacmd;
dbdma_regmap_t *dmareg = sc->sc_rxdma;
int i;
- u_int8_t maccc;
+ uint8_t maccc;
/* Disable receiver, reset the DMA channels */
maccc = NIC_GET(sc, MACE_MACCC);
@@ -325,9 +324,9 @@ mc_reset_txdma(struct mc_softc *sc)
{
dbdma_command_t *cmd = sc->sc_txdmacmd;
dbdma_regmap_t *dmareg = sc->sc_txdma;
- u_int8_t maccc;
+ uint8_t maccc;
- /* disable transmitter */
+ /* Disable transmitter */
maccc = NIC_GET(sc, MACE_MACCC);
NIC_PUT(sc, MACE_MACCC, maccc & ~ENXMT);
@@ -342,19 +341,21 @@ mc_reset_txdma(struct mc_softc *sc)
out32rb(&dmareg->d_cmdptrhi, 0);
out32rb(&dmareg->d_cmdptrlo, kvtop((void *)sc->sc_txdmacmd));
- /* restore old value */
+ /* Restore old value */
NIC_PUT(sc, MACE_MACCC, maccc);
}
void
mc_select_utp(struct mc_softc *sc)
{
+
sc->sc_plscc = PORTSEL_GPSI | ENPLSIO;
}
void
mc_select_aui(struct mc_softc *sc)
{
+
sc->sc_plscc = PORTSEL_AUI;
}
@@ -386,6 +387,7 @@ mc_mediachange(struct mc_softc *sc)
void
mc_mediastatus(struct mc_softc *sc, struct ifmediareq *ifmr)
{
+
if (sc->sc_plscc == PORTSEL_AUI)
ifmr->ifm_active = IFM_ETHER | IFM_10_5;
else
diff --git a/sys/arch/sparc/dev/if_ie_obio.c b/sys/arch/sparc/dev/if_ie_obio.c
index 6c9299225b6..b31bda332be 100644
--- a/sys/arch/sparc/dev/if_ie_obio.c
+++ b/sys/arch/sparc/dev/if_ie_obio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ie_obio.c,v 1.41 2013/10/19 19:40:23 mrg Exp $ */
+/* $NetBSD: if_ie_obio.c,v 1.42 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.41 2013/10/19 19:40:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.42 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -130,7 +130,7 @@ CFATTACH_DECL_NEW(ie_obio, sizeof(struct ie_softc),
static int media[] = {
IFM_ETHER | IFM_10_2,
};
-#define NMEDIA (sizeof(media) / sizeof(media[0]))
+#define NMEDIA __arraycount(media)
/*
@@ -188,9 +188,9 @@ ie_obio_memcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
wcopy(p, addr, size);
}
-/* read a 16-bit value at BH offset */
+/* Read a 16-bit value at BH offset */
uint16_t ie_obio_read16(struct ie_softc *, int);
-/* write a 16-bit value at BH offset */
+/* Write a 16-bit value at BH offset */
void ie_obio_write16(struct ie_softc *, int, uint16_t);
void ie_obio_write24(struct ie_softc *, int, int);
@@ -205,6 +205,7 @@ ie_obio_read16(struct ie_softc *sc, int offset)
void
ie_obio_write16(struct ie_softc *sc, int offset, uint16_t v)
{
+
v = (((v&0xff)<<8) | ((v>>8)&0xff));
bus_space_write_2(sc->bt, sc->bh, offset, v);
}
@@ -232,14 +233,14 @@ ie_obio_match(device_t parent, cfdata_t cf, void *aux)
struct obio4_attach_args *oba;
if (uoba->uoba_isobio4 == 0)
- return (0);
+ return 0;
oba = &uoba->uoba_oba4;
- return (bus_space_probe(oba->oba_bustag, oba->oba_paddr,
+ return bus_space_probe(oba->oba_bustag, oba->oba_paddr,
1, /* probe size */
0, /* offset */
0, /* flags */
- NULL, NULL));
+ NULL, NULL);
}
void
@@ -274,27 +275,21 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
sc->sc_msize = memsize = 65536; /* XXX */
if (bus_space_map(oba->oba_bustag, oba->oba_paddr,
- sizeof(struct ieob),
- BUS_SPACE_MAP_LINEAR,
- &bh) != 0) {
+ sizeof(struct ieob), BUS_SPACE_MAP_LINEAR, &bh) != 0) {
printf("%s: cannot map registers\n", device_xname(self));
return;
}
sc->sc_reg = (void *)bh;
- /*
- * Allocate control & buffer memory.
- */
+ /* Allocate control & buffer memory. */
if ((error = bus_dmamap_create(dmatag, memsize, 1, memsize, 0,
- BUS_DMA_NOWAIT|BUS_DMA_24BIT,
- &sc->sc_dmamap)) != 0) {
+ BUS_DMA_NOWAIT|BUS_DMA_24BIT, &sc->sc_dmamap)) != 0) {
printf("%s: DMA map create error %d\n",
device_xname(self), error);
return;
}
- if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0,
- &seg, 1, &rseg,
- BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
+ if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0, &seg, 1,
+ &rseg, BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
printf("%s: DMA memory allocation error %d\n",
device_xname(self), error);
return;
@@ -302,8 +297,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
/* Map DMA buffer in CPU addressable space */
if ((error = bus_dmamem_map(dmatag, &seg, rseg, memsize,
- (void **)&sc->sc_maddr,
- BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
+ (void **)&sc->sc_maddr, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
printf("%s: DMA buffer map error %d\n",
device_xname(self), error);
bus_dmamem_free(dmatag, &seg, rseg);
@@ -311,9 +305,8 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
}
/* Load the segment */
- if ((error = bus_dmamap_load(dmatag, sc->sc_dmamap,
- sc->sc_maddr, memsize, NULL,
- BUS_DMA_NOWAIT)) != 0) {
+ if ((error = bus_dmamap_load(dmatag, sc->sc_dmamap, sc->sc_maddr,
+ memsize, NULL, BUS_DMA_NOWAIT)) != 0) {
printf("%s: DMA buffer map load error %d\n",
device_xname(self), error);
bus_dmamem_unmap(dmatag, sc->sc_maddr, memsize);
@@ -337,7 +330,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
* SCP; the actual buffers start at maddr+PAGE_SIZE.
*
* In a picture:
-
+
|---//--- ISCP-SCB-----scp-|--//- buffers -//-|... |iscp-scb-----SCP-|
| | | | | | |
| |<---PAGE_SIZE-->| | |<--PAGE_SIZE-+-->|
@@ -391,7 +384,6 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
i82586_attach(sc, "onboard", myaddr, media, NMEDIA, media[0]);
/* Establish interrupt channel */
- (void)bus_intr_establish(oba->oba_bustag,
- oba->oba_pri, IPL_NET,
- i82586_intr, sc);
+ (void)bus_intr_establish(oba->oba_bustag, oba->oba_pri, IPL_NET,
+ i82586_intr, sc);
}
diff --git a/sys/arch/sparc/dev/if_le_obio.c b/sys/arch/sparc/dev/if_le_obio.c
index 7b64ad9fbc7..4ea42377c5f 100644
--- a/sys/arch/sparc/dev/if_le_obio.c
+++ b/sys/arch/sparc/dev/if_le_obio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_obio.c,v 1.27 2011/07/01 18:50:41 dyoung Exp $ */
+/* $NetBSD: if_le_obio.c,v 1.28 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_obio.c,v 1.27 2011/07/01 18:50:41 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_obio.c,v 1.28 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -72,9 +72,9 @@ struct le_softc {
* Media types supported.
*/
static int lemedia[] = {
- IFM_ETHER|IFM_10_T,
+ IFM_ETHER | IFM_10_T,
};
-#define NLEMEDIA (sizeof(lemedia) / sizeof(lemedia[0]))
+#define NLEMEDIA __arraycount(lemedia)
static int lematch_obio(device_t, cfdata_t, void *);
static void leattach_obio(device_t, device_t, void *);
@@ -105,7 +105,7 @@ lerdcsr(struct lance_softc *sc, uint16_t port)
bus_space_handle_t h = lesc->sc_reg;
bus_space_write_2(t, h, LEREG1_RAP, port);
- return (bus_space_read_2(t, h, LEREG1_RDP));
+ return bus_space_read_2(t, h, LEREG1_RDP);
}
static int
@@ -115,14 +115,14 @@ lematch_obio(device_t parent, cfdata_t cf, void *aux)
struct obio4_attach_args *oba;
if (uoba->uoba_isobio4 == 0)
- return (0);
+ return 0;
oba = &uoba->uoba_oba4;
- return (bus_space_probe(oba->oba_bustag, oba->oba_paddr,
+ return bus_space_probe(oba->oba_bustag, oba->oba_paddr,
2, /* probe size */
0, /* offset */
0, /* flags */
- NULL, NULL));
+ NULL, NULL);
}
static void
@@ -142,39 +142,34 @@ leattach_obio(device_t parent, device_t self, void *aux)
lesc->sc_dmatag = dmatag = oba->oba_dmatag;
if (bus_space_map(oba->oba_bustag, oba->oba_paddr,
- 2 * sizeof(uint16_t),
- 0, &lesc->sc_reg) != 0) {
+ 2 * sizeof(uint16_t), 0, &lesc->sc_reg) != 0) {
aprint_error(": cannot map registers\n");
return;
}
/* Get a DMA handle */
if ((error = bus_dmamap_create(dmatag, MEMSIZE, 1, MEMSIZE, 0,
- BUS_DMA_NOWAIT|BUS_DMA_24BIT,
- &lesc->sc_dmamap)) != 0) {
+ BUS_DMA_NOWAIT|BUS_DMA_24BIT, &lesc->sc_dmamap)) != 0) {
aprint_error(": DMA map create error %d\n", error);
return;
}
/* Allocate DMA buffer */
if ((error = bus_dmamem_alloc(dmatag, MEMSIZE, PAGE_SIZE, 0,
- &seg, 1, &rseg,
- BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
+ &seg, 1, &rseg, BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
aprint_error(": DMA memory allocation error %d\n", error);
return;
}
/* Map DMA buffer into kernel space */
if ((error = bus_dmamem_map(dmatag, &seg, rseg, MEMSIZE,
- (void **)&sc->sc_mem,
- BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
+ (void **)&sc->sc_mem, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
aprint_error(": DMA memory 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) {
+ sc->sc_mem, MEMSIZE, NULL, BUS_DMA_NOWAIT)) != 0) {
aprint_error(": DMA buffer map load error %d\n", error);
bus_dmamem_unmap(dmatag, (void *)sc->sc_mem, MEMSIZE);
bus_dmamem_free(dmatag, &seg, rseg);
@@ -204,5 +199,5 @@ leattach_obio(device_t parent, device_t self, void *aux)
/* Install interrupt */
(void)bus_intr_establish(lesc->sc_bustag, oba->oba_pri, IPL_NET,
- am7990_intr, sc);
+ am7990_intr, sc);
}
diff --git a/sys/arch/sun2/dev/if_ie_mbmem.c b/sys/arch/sun2/dev/if_ie_mbmem.c
index 4fba9f7cec6..c4266f61a0b 100644
--- a/sys/arch/sun2/dev/if_ie_mbmem.c
+++ b/sys/arch/sun2/dev/if_ie_mbmem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ie_mbmem.c,v 1.11 2011/06/03 16:28:40 tsutsui Exp $ */
+/* $NetBSD: if_ie_mbmem.c,v 1.12 2019/04/25 10:08:45 msaitoh Exp $ */
/*
* Copyright (c) 1995 Charles D. Cranor
@@ -111,7 +111,7 @@
*
* The page map to control where ram appears in the address space.
* We choose to have RAM start at 0 in the 24 bit address space.
- *
+ *
* to get the phyiscal address of the board's RAM you must take the
* top 12 bits of the physical address of the register address and
* or in the 4 bits from the status word as bits 17-20 (remember that
@@ -140,7 +140,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ie_mbmem.c,v 1.11 2011/06/03 16:28:40 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie_mbmem.c,v 1.12 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -171,8 +171,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_ie_mbmem.c,v 1.11 2011/06/03 16:28:40 tsutsui Exp
*/
#define IEMBMEM_PAGESIZE 1024 /* bytes */
#define IEMBMEM_PAGSHIFT 10 /* bits */
-#define IEMBMEM_NPAGES 256 /* number of pages on chip */
-#define IEMBMEM_MAPSZ 1024 /* number of entries in the map */
+#define IEMBMEM_NPAGES 256 /* number of pages on chip */
+#define IEMBMEM_MAPSZ 1024 /* number of entries in the map */
/*
* PTE for the page map
@@ -219,8 +219,8 @@ struct iembmem {
/* Supported media */
static int media[] = {
IFM_ETHER | IFM_10_2,
-};
-#define NMEDIA (sizeof(media) / sizeof(media[0]))
+};
+#define NMEDIA __arraycount(media)
/*
* the 3E board not supported (yet?)
@@ -252,7 +252,7 @@ CFATTACH_DECL_NEW(ie_mbmem, sizeof(struct ie_mbmem_softc),
/*
* MULTIBUS support routines
*/
-void
+void
ie_mbmemreset(struct ie_softc *sc, int what)
{
struct ie_mbmem_softc *vsc = (struct ie_mbmem_softc *)sc;
@@ -261,18 +261,18 @@ ie_mbmemreset(struct ie_softc *sc, int what)
write_iev(vsc, status, 0);
}
-void
+void
ie_mbmemattend(struct ie_softc *sc, int why)
{
struct ie_mbmem_softc *vsc = (struct ie_mbmem_softc *)sc;
- /* flag! */
+ /* Flag! */
write_iev(vsc, status, read_iev(vsc, status) | IEMBMEM_ATTEN);
- /* down. */
+ /* Down. */
write_iev(vsc, status, read_iev(vsc, status) & ~IEMBMEM_ATTEN);
}
-void
+void
ie_mbmemrun(struct ie_softc *sc)
{
struct ie_mbmem_softc *vsc = (struct ie_mbmem_softc *)sc;
@@ -281,17 +281,15 @@ ie_mbmemrun(struct ie_softc *sc)
| IEMBMEM_ONAIR | IEMBMEM_IENAB | IEMBMEM_PEINT);
}
-int
+int
ie_mbmemintr(struct ie_softc *sc, int where)
{
struct ie_mbmem_softc *vsc = (struct ie_mbmem_softc *)sc;
if (where != INTR_ENTER)
- return (0);
+ return 0;
- /*
- * check for parity error
- */
+ /* check for parity error */
if (read_iev(vsc, status) & IEMBMEM_PERR) {
printf("%s: parity error (ctrl 0x%x @ 0x%02x%04x)\n",
device_xname(sc->sc_dev), read_iev(vsc, pectrl),
@@ -299,7 +297,7 @@ ie_mbmemintr(struct ie_softc *sc, int where)
read_iev(vsc, peaddr));
write_iev(vsc, pectrl, read_iev(vsc, pectrl) | IEMBMEM_PARACK);
}
- return (0);
+ return 0;
}
void ie_mbmemcopyin(struct ie_softc *, void *, int, size_t);
@@ -308,28 +306,30 @@ void ie_mbmemcopyout(struct ie_softc *, const void *, int, size_t);
/*
* Copy board memory to kernel.
*/
-void
+void
ie_mbmemcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
{
+
bus_space_copyin(sc->bt, sc->bh, offset, p, size);
}
/*
* Copy from kernel space to board memory.
*/
-void
+void
ie_mbmemcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
{
+
bus_space_copyout(sc->bt, sc->bh, offset, p, size);
}
-/* read a 16-bit value at BH offset */
+/* Read a 16-bit value at BH offset */
uint16_t ie_mbmem_read16(struct ie_softc *, int offset);
-/* write a 16-bit value at BH offset */
+/* Write a 16-bit value at BH offset */
void ie_mbmem_write16(struct ie_softc *, int offset, uint16_t value);
void ie_mbmem_write24(struct ie_softc *, int offset, int addr);
-uint16_t
+uint16_t
ie_mbmem_read16(struct ie_softc *sc, int offset)
{
uint16_t v;
@@ -339,7 +339,7 @@ ie_mbmem_read16(struct ie_softc *sc, int offset)
return (((v&0xff)<<8) | ((v>>8)&0xff));
}
-void
+void
ie_mbmem_write16(struct ie_softc *sc, int offset, uint16_t v)
{
int v0 = ((((v)&0xff)<<8) | (((v)>>8)&0xff));
@@ -348,7 +348,7 @@ ie_mbmem_write16(struct ie_softc *sc, int offset, uint16_t v)
bus_space_barrier(sc->bt, sc->bh, offset, 2, BUS_SPACE_BARRIER_WRITE);
}
-void
+void
ie_mbmem_write24(struct ie_softc *sc, int offset, int addr)
{
u_char *f = (u_char *)&addr;
@@ -366,7 +366,7 @@ ie_mbmem_write24(struct ie_softc *sc, int offset, int addr)
bus_space_barrier(sc->bt, sc->bh, offset, 4, BUS_SPACE_BARRIER_WRITE);
}
-int
+int
ie_mbmem_match(device_t parent, cfdata_t cf, void *aux)
{
struct mbmem_attach_args *mbma = aux;
@@ -375,25 +375,25 @@ ie_mbmem_match(device_t parent, cfdata_t cf, void *aux)
/* No default Multibus address. */
if (mbma->mbma_paddr == -1)
- return(0);
+ return 0;
/* Make sure there is something there... */
- if (bus_space_map(mbma->mbma_bustag, mbma->mbma_paddr, sizeof(struct iembmem),
- 0, &bh))
- return (0);
+ if (bus_space_map(mbma->mbma_bustag, mbma->mbma_paddr,
+ sizeof(struct iembmem), 0, &bh))
+ return 0;
matched = (bus_space_peek_2(mbma->mbma_bustag, bh, 0, NULL) == 0);
bus_space_unmap(mbma->mbma_bustag, bh, sizeof(struct iembmem));
if (!matched)
- return (0);
+ return 0;
/* Default interrupt priority. */
if (mbma->mbma_pri == -1)
mbma->mbma_pri = 3;
- return (1);
+ return 1;
}
-void
+void
ie_mbmem_attach(device_t parent, device_t self, void *aux)
{
uint8_t myaddr[ETHER_ADDR_LEN];
@@ -427,8 +427,8 @@ ie_mbmem_attach(device_t parent, device_t self, void *aux)
/* Map in the board control regs. */
vsc->ievt = mbma->mbma_bustag;
- if (bus_space_map(mbma->mbma_bustag, mbma->mbma_paddr, sizeof(struct iembmem),
- 0, &vsc->ievh))
+ if (bus_space_map(mbma->mbma_bustag, mbma->mbma_paddr,
+ sizeof(struct iembmem), 0, &vsc->ievh))
panic("ie_mbmem_attach: can't map regs");
/*
@@ -449,8 +449,10 @@ ie_mbmem_attach(device_t parent, device_t self, void *aux)
* which is mapped at zero and at high address (for scp)
*/
for (lcv = 0; lcv < IEMBMEM_MAPSZ - 1; lcv++)
- write_iev(vsc, pgmap[lcv], IEMBMEM_SBORDR | IEMBMEM_OBMEM | lcv);
- write_iev(vsc, pgmap[IEMBMEM_MAPSZ - 1], IEMBMEM_SBORDR | IEMBMEM_OBMEM | 0);
+ write_iev(vsc, pgmap[lcv],
+ IEMBMEM_SBORDR | IEMBMEM_OBMEM | lcv);
+ write_iev(vsc, pgmap[IEMBMEM_MAPSZ - 1],
+ IEMBMEM_SBORDR | IEMBMEM_OBMEM | 0);
/* Clear all ram */
bus_space_set_region_2(sc->bt, sc->bh, 0, 0, memsize/2);
@@ -479,9 +481,7 @@ ie_mbmem_attach(device_t parent, device_t self, void *aux)
return;
}
- /*
- * Rest of first page is unused; rest of ram for buffers.
- */
+ /* Rest of first page is unused; rest of ram for buffers. */
sc->buf_area = IEMBMEM_PAGESIZE;
sc->buf_area_sz = memsize - IEMBMEM_PAGESIZE;
@@ -495,5 +495,5 @@ ie_mbmem_attach(device_t parent, device_t self, void *aux)
i82586_attach(sc, "multibus", myaddr, media, NMEDIA, media[0]);
bus_intr_establish(mbma->mbma_bustag, mbma->mbma_pri, IPL_NET, 0,
- i82586_intr, sc);
+ i82586_intr, sc);
}
diff --git a/sys/arch/sun2/dev/if_ie_obio.c b/sys/arch/sun2/dev/if_ie_obio.c
index 92b948767ef..5c0b14cc2a1 100644
--- a/sys/arch/sun2/dev/if_ie_obio.c
+++ b/sys/arch/sun2/dev/if_ie_obio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ie_obio.c,v 1.16 2014/03/24 18:50:31 christos Exp $ */
+/* $NetBSD: if_ie_obio.c,v 1.17 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.16 2014/03/24 18:50:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.17 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -103,7 +103,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.16 2014/03/24 18:50:31 christos Exp
* the on-board interface
*/
struct ieob {
- u_char obctrl;
+ u_char obctrl;
};
#define IEOB_NORSET 0x80 /* don't reset the board */
#define IEOB_ONAIR 0x40 /* put us on the air */
@@ -130,14 +130,14 @@ CFATTACH_DECL_NEW(ie_obio, sizeof(struct ie_softc),
/* Supported media */
static int media[] = {
IFM_ETHER | IFM_10_2,
-};
-#define NMEDIA (sizeof(media) / sizeof(media[0]))
+};
+#define NMEDIA __arraycount(media)
/*
* OBIO ie support routines
*/
-void
+void
ie_obreset(struct ie_softc *sc, int what)
{
volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
@@ -145,7 +145,7 @@ ie_obreset(struct ie_softc *sc, int what)
delay(100); /* XXX could be shorter? */
ieo->obctrl = IEOB_NORSET;
}
-void
+void
ie_obattend(struct ie_softc *sc, int why)
{
volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
@@ -154,7 +154,7 @@ ie_obattend(struct ie_softc *sc, int why)
ieo->obctrl &= ~IEOB_ATTEN; /* down. */
}
-void
+void
ie_obrun(struct ie_softc *sc)
{
volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
@@ -168,18 +168,20 @@ void ie_obio_memcopyout(struct ie_softc *, const void *, int, size_t);
/*
* Copy board memory to kernel.
*/
-void
+void
ie_obio_memcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
{
+
bus_space_copyin(sc->bt, sc->bh, offset, p, size);
}
/*
* Copy from kernel space to naord memory.
*/
-void
+void
ie_obio_memcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
{
+
bus_space_copyout(sc->bt, sc->bh, offset, p, size);
}
@@ -189,21 +191,23 @@ uint16_t ie_obio_read16(struct ie_softc *, int);
void ie_obio_write16(struct ie_softc *, int, uint16_t);
void ie_obio_write24(struct ie_softc *, int, int);
-uint16_t
+uint16_t
ie_obio_read16(struct ie_softc *sc, int offset)
{
uint16_t v = bus_space_read_2(sc->bt, sc->bh, offset);
+
return (((v&0xff)<<8) | ((v>>8)&0xff));
}
-void
+void
ie_obio_write16(struct ie_softc *sc, int offset, uint16_t v)
{
+
v = (((v&0xff)<<8) | ((v>>8)&0xff));
bus_space_write_2(sc->bt, sc->bh, offset, v);
}
-void
+void
ie_obio_write24(struct ie_softc *sc, int offset, int addr)
{
u_char *f = (u_char *)&addr;
@@ -219,7 +223,7 @@ ie_obio_write24(struct ie_softc *sc, int offset, int addr)
bus_space_write_2(sc->bt, sc->bh, offset+2, v1);
}
-int
+int
ie_obio_match(device_t parent, cfdata_t cf, void *aux)
{
struct obio_attach_args *oba = aux;
@@ -229,27 +233,27 @@ ie_obio_match(device_t parent, cfdata_t cf, void *aux)
/* No default obio address. */
if (oba->oba_paddr == -1)
- return(0);
-
+ return 0;
+
/* Make sure there is something there... */
- if (bus_space_map(oba->oba_bustag, oba->oba_paddr, sizeof(struct ieob),
- 0, &bh))
- return (0);
+ if (bus_space_map(oba->oba_bustag, oba->oba_paddr,
+ sizeof(struct ieob), 0, &bh))
+ return 0;
matched = (!bus_space_poke_1(oba->oba_bustag, bh, 0, IEOB_NORSET) &&
!bus_space_peek_1(oba->oba_bustag, bh, 0, &ctrl) &&
(ctrl & (IEOB_ONAIR|IEOB_IENAB)) == 0);
bus_space_unmap(oba->oba_bustag, bh, sizeof(struct ieob));
if (!matched)
- return (0);
+ return 0;
/* Default interrupt priority. */
if (oba->oba_pri == -1)
oba->oba_pri = 3;
- return (1);
+ return 1;
}
-void
+void
ie_obio_attach(device_t parent, device_t self, void *aux)
{
struct obio_attach_args *oba = aux;
@@ -280,7 +284,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
sc->sc_msize = memsize = 65536; /* XXX */
if (bus_space_map(oba->oba_bustag, oba->oba_paddr, sizeof(struct ieob),
- 0, &bh))
+ 0, &bh))
panic("ie_obio_attach: can't map regs");
sc->sc_reg = (void *)bh;
@@ -288,15 +292,13 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
* Allocate control & buffer memory.
*/
if ((error = bus_dmamap_create(dmatag, memsize, 1, memsize, 0,
- BUS_DMA_NOWAIT|BUS_DMA_24BIT,
- &sc->sc_dmamap)) != 0) {
+ BUS_DMA_NOWAIT|BUS_DMA_24BIT, &sc->sc_dmamap)) != 0) {
printf("%s: DMA map create error %d\n",
device_xname(self), error);
return;
}
if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0,
- &seg, 1, &rseg,
- BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
+ &seg, 1, &rseg, BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
printf("%s: DMA memory allocation error %d\n",
device_xname(self), error);
return;
@@ -304,8 +306,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
/* Map DMA buffer in CPU addressable space */
if ((error = bus_dmamem_map(dmatag, &seg, rseg, memsize,
- (void **)&sc->sc_maddr,
- BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
+ (void **)&sc->sc_maddr, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
printf("%s: DMA buffer map error %d\n",
device_xname(self), error);
bus_dmamem_free(dmatag, &seg, rseg);
@@ -314,8 +315,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
/* Load the segment */
if ((error = bus_dmamap_load(dmatag, sc->sc_dmamap,
- sc->sc_maddr, memsize, NULL,
- BUS_DMA_NOWAIT)) != 0) {
+ sc->sc_maddr, memsize, NULL, BUS_DMA_NOWAIT)) != 0) {
printf("%s: DMA buffer map load error %d\n",
device_xname(self), error);
bus_dmamem_unmap(dmatag, sc->sc_maddr, memsize);