No functional change:

- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
This commit is contained in:
msaitoh 2019-04-25 10:08:45 +00:00
parent a1190bb29b
commit 14d9bb3260
15 changed files with 700 additions and 831 deletions

View File

@ -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
*/

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtl80x9.c,v 1.16 2014/06/16 16:48:16 msaitoh Exp $ */
/* $NetBSD: rtl80x9.c,v 1.17 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rtl80x9.c,v 1.16 2014/06/16 16:48:16 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: rtl80x9.c,v 1.17 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -66,14 +66,14 @@ rtl80x9_mediachange(struct dp8390_softc *dsc)
* set up in ne_pci_rtl8029_init_card() called via dp8390_init().
*/
dp8390_reset(dsc);
return (0);
return 0;
}
void
rtl80x9_mediastatus(struct dp8390_softc *sc, struct ifmediareq *ifmr)
{
struct ifnet *ifp = &sc->sc_ec.ec_if;
u_int8_t cr_proto = sc->cr_proto |
uint8_t cr_proto = sc->cr_proto |
((ifp->if_flags & IFF_RUNNING) ? ED_CR_STA : ED_CR_STP);
/*
@ -86,9 +86,9 @@ rtl80x9_mediastatus(struct dp8390_softc *sc, struct ifmediareq *ifmr)
if (NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG0) &
RTL3_CONFIG0_BNC)
ifmr->ifm_active = IFM_ETHER|IFM_10_2;
ifmr->ifm_active = IFM_ETHER | IFM_10_2;
else {
ifmr->ifm_active = IFM_ETHER|IFM_10_T;
ifmr->ifm_active = IFM_ETHER | IFM_10_T;
if (NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3) &
RTL3_CONFIG3_FUDUP)
ifmr->ifm_active |= IFM_FDX;
@ -105,14 +105,14 @@ rtl80x9_init_card(struct dp8390_softc *sc)
{
struct ifmedia *ifm = &sc->sc_media;
struct ifnet *ifp = &sc->sc_ec.ec_if;
u_int8_t cr_proto = sc->cr_proto |
uint8_t cr_proto = sc->cr_proto |
((ifp->if_flags & IFF_RUNNING) ? ED_CR_STA : ED_CR_STP);
u_int8_t reg;
uint8_t reg;
/* Set NIC to page 3 registers. */
NIC_PUT(sc->sc_regt, sc->sc_regh, ED_P0_CR, cr_proto | ED_CR_PAGE_3);
/* write enable config1-3. */
/* Write enable config1-3. */
NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_EECR,
RTL3_EECR_EEM1|RTL3_EECR_EEM0);
@ -146,7 +146,7 @@ rtl80x9_init_card(struct dp8390_softc *sc)
reg &= ~RTL3_CONFIG3_FUDUP;
NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3, reg);
/* write disable config1-3 */
/* Write disable config1-3 */
NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_EECR, 0);
/* Set NIC to page 0 registers. */
@ -157,16 +157,15 @@ void
rtl80x9_media_init(struct dp8390_softc *sc)
{
static int rtl80x9_media[] = {
IFM_ETHER|IFM_AUTO,
IFM_ETHER|IFM_10_T,
IFM_ETHER|IFM_10_T|IFM_FDX,
IFM_ETHER|IFM_10_2,
IFM_ETHER | IFM_AUTO,
IFM_ETHER | IFM_10_T,
IFM_ETHER | IFM_10_T|IFM_FDX,
IFM_ETHER | IFM_10_2,
};
static const int rtl80x9_nmedia =
sizeof(rtl80x9_media) / sizeof(rtl80x9_media[0]);
static const int rtl80x9_nmedia = __arraycount(rtl80x9_media);
int i, defmedia;
u_int8_t conf2, conf3;
uint8_t conf2, conf3;
aprint_normal_dev(sc->sc_dev,
"10base2, 10baseT, 10baseT-FDX, auto, default ");

View File

@ -1,4 +1,4 @@
/* $NetBSD: smc91cxx.c,v 1.100 2019/04/22 09:00:12 msaitoh Exp $ */
/* $NetBSD: smc91cxx.c,v 1.101 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.100 2019/04/22 09:00:12 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.101 2019/04/25 10:08:45 msaitoh Exp $");
#include "opt_inet.h"
@ -118,7 +118,7 @@ __KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.100 2019/04/22 09:00:12 msaitoh Exp $
#define bus_space_read_multi_stream_4 bus_space_read_multi_4
#define bus_space_write_stream_4 bus_space_write_4
#define bus_space_read_stream_4 bus_space_read_4
#define bus_space_read_stream_4 bus_space_read_4
#endif /* __BUS_SPACE_HAS_STREAM_METHODS */
/* XXX Hardware padding doesn't work yet(?) */
@ -145,16 +145,16 @@ const char *smc91cxx_idstrs[] = {
/* Supported media types. */
static const int smc91cxx_media[] = {
IFM_ETHER|IFM_10_T,
IFM_ETHER|IFM_10_5,
IFM_ETHER | IFM_10_T,
IFM_ETHER | IFM_10_5,
};
#define NSMC91CxxMEDIA (sizeof(smc91cxx_media) / sizeof(smc91cxx_media[0]))
#define NSMC91CxxMEDIA __arraycount(smc91cxx_media)
/*
* MII bit-bang glue.
*/
u_int32_t smc91cxx_mii_bitbang_read(device_t);
void smc91cxx_mii_bitbang_write(device_t, u_int32_t);
uint32_t smc91cxx_mii_bitbang_read(device_t);
void smc91cxx_mii_bitbang_write(device_t, uint32_t);
static const struct mii_bitbang_ops smc91cxx_mii_bitbang_ops = {
smc91cxx_mii_bitbang_read,
@ -193,8 +193,8 @@ static inline int ether_cmp(const void *, const void *);
static inline int
ether_cmp(const void *va, const void *vb)
{
const u_int8_t *a = va;
const u_int8_t *b = vb;
const uint8_t *a = va;
const uint8_t *b = vb;
return ((a[5] != b[5]) || (a[4] != b[4]) || (a[3] != b[3]) ||
(a[2] != b[2]) || (a[1] != b[1]) || (a[0] != b[0]));
@ -226,16 +226,16 @@ smc91cxx_intr_ack_write(bus_space_tag_t bst, bus_space_handle_t bsh,
}
void
smc91cxx_attach(struct smc91cxx_softc *sc, u_int8_t *myea)
smc91cxx_attach(struct smc91cxx_softc *sc, uint8_t *myea)
{
struct ifnet *ifp = &sc->sc_ec.ec_if;
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
struct ifmedia *ifm = &sc->sc_mii.mii_media;
const char *idstr;
u_int32_t miicapabilities;
u_int16_t tmp;
u_int8_t enaddr[ETHER_ADDR_LEN];
uint32_t miicapabilities;
uint16_t tmp;
uint8_t enaddr[ETHER_ADDR_LEN];
int i, aui, mult, scale, memsize;
char pbuf[9];
@ -347,20 +347,18 @@ smc91cxx_attach(struct smc91cxx_softc *sc, u_int8_t *myea)
MII_PHY_ANY, MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
ifmedia_add(&sc->sc_mii.mii_media,
IFM_ETHER|IFM_NONE, 0, NULL);
IFM_ETHER | IFM_NONE, 0, NULL);
ifmedia_set(&sc->sc_mii.mii_media,
IFM_ETHER|IFM_NONE);
IFM_ETHER | IFM_NONE);
} else {
ifmedia_set(&sc->sc_mii.mii_media,
IFM_ETHER|IFM_AUTO);
IFM_ETHER | IFM_AUTO);
}
sc->sc_flags |= SMC_FLAGS_HAS_MII;
break;
} else
if (sc->sc_chipid == CHIP_91C111) {
/*
* XXX: Should bring it out of low-power mode
*/
/* XXX: Should bring it out of low-power mode */
aprint_normal("EPH interface in low power mode\n");
sc->sc_internal_phy = 0;
return;
@ -393,7 +391,7 @@ smc91cxx_mediachange(struct ifnet *ifp)
{
struct smc91cxx_softc *sc = ifp->if_softc;
return (smc91cxx_set_media(sc, sc->sc_mii.mii_media.ifm_media));
return smc91cxx_set_media(sc, sc->sc_mii.mii_media.ifm_media);
}
int
@ -401,7 +399,7 @@ smc91cxx_set_media(struct smc91cxx_softc *sc, int media)
{
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
u_int16_t tmp;
uint16_t tmp;
int rc;
/*
@ -410,10 +408,10 @@ smc91cxx_set_media(struct smc91cxx_softc *sc, int media)
* up the media for us.
*/
if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0)
return (0);
return 0;
if (IFM_TYPE(media) != IFM_ETHER)
return (EINVAL);
return EINVAL;
if ((sc->sc_flags & SMC_FLAGS_HAS_MII) == 0 ||
(rc = mii_mediachg(&sc->sc_mii)) == ENXIO)
@ -433,7 +431,7 @@ smc91cxx_set_media(struct smc91cxx_softc *sc, int media)
break;
default:
return (EINVAL);
return EINVAL;
}
return rc;
@ -448,7 +446,7 @@ smc91cxx_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
struct smc91cxx_softc *sc = ifp->if_softc;
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
u_int16_t tmp;
uint16_t tmp;
if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0) {
ifmr->ifm_active = IFM_ETHER | IFM_NONE;
@ -456,9 +454,7 @@ smc91cxx_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
return;
}
/*
* If we have MII, go ask the PHY what's going on.
*/
/* If we have MII, go ask the PHY what's going on. */
if (sc->sc_flags & SMC_FLAGS_HAS_MII) {
mii_pollstat(&sc->sc_mii);
ifmr->ifm_active = sc->sc_mii.mii_media_active;
@ -481,8 +477,8 @@ smc91cxx_init(struct smc91cxx_softc *sc)
struct ifnet *ifp = &sc->sc_ec.ec_if;
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
u_int16_t tmp;
const u_int8_t *enaddr;
uint16_t tmp;
const uint8_t *enaddr;
int s, i;
s = splnet();
@ -502,7 +498,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
/* Set the Ethernet address. */
SMC_SELECT_BANK(sc, 1);
enaddr = (const u_int8_t *)CLLADDR(ifp->if_sadl);
enaddr = (const uint8_t *)CLLADDR(ifp->if_sadl);
for (i = 0; i < ETHER_ADDR_LEN; i += 2) {
tmp = enaddr[i + 1] << 8 | enaddr[i];
bus_space_write_2(bst, bsh, IAR_ADDR0_REG_W + i, tmp);
@ -516,16 +512,14 @@ smc91cxx_init(struct smc91cxx_softc *sc)
bus_space_write_2(bst, bsh, CONTROL_REG_W, (CTR_AUTO_RELEASE |
CTR_TE_ENABLE | CTR_CR_ENABLE | CTR_LE_ENABLE));
/*
* Reset the MMU and wait for it to be un-busy.
*/
/* Reset the MMU and wait for it to be un-busy. */
SMC_SELECT_BANK(sc, 2);
bus_space_write_2(bst, bsh, MMU_CMD_REG_W, MMUCR_RESET);
sc->sc_txpacketno = ARR_FAILED;
for (;;) {
tmp = bus_space_read_2(bst, bsh, MMU_CMD_REG_W);
if (tmp == 0xffff) {
/* card went away! */
/* Card went away! */
splx(s);
return;
}
@ -533,9 +527,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
break;
}
/*
* Disable all interrupts.
*/
/* Disable all interrupts. */
smc91cxx_intr_mask_write(bst, bsh, 0);
/*
@ -551,9 +543,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
(RPC_LS_TXRX << RPC_LSB_SHIFT));
}
/*
* Set current media.
*/
/* Set current media. */
smc91cxx_set_media(sc, sc->sc_mii.mii_media.ifm_cur->ifm_media);
/*
@ -572,9 +562,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
bus_space_write_2(bst, bsh, RECV_CONTROL_REG_W, tmp);
/*
* Set transmitter control to "enabled".
*/
/* Set transmitter control to "enabled". */
tmp = TCR_ENABLE;
#ifndef SMC91CXX_SW_PAD
@ -587,9 +575,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
bus_space_write_2(bst, bsh, TXMIT_CONTROL_REG_W, tmp);
/*
* Now, enable interrupts.
*/
/* Now, enable interrupts. */
SMC_SELECT_BANK(sc, 2);
sc->sc_intmask = IM_EPH_INT | IM_RX_OVRN_INT | IM_RCV_INT;
@ -607,9 +593,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
callout_reset(&sc->sc_mii_callout, hz, smc91cxx_tick, sc);
}
/*
* Attempt to start any pending transmission.
*/
/* Attempt to start any pending transmission. */
smc91cxx_start(ifp);
splx(s);
@ -627,18 +611,16 @@ smc91cxx_start(struct ifnet *ifp)
bus_space_handle_t bsh = sc->sc_bsh;
u_int len;
struct mbuf *m;
u_int16_t length, npages;
u_int16_t oddbyte;
u_int8_t packetno;
uint16_t length, npages;
uint16_t oddbyte;
uint8_t packetno;
int timo, pad;
if ((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING)
return;
again:
/*
* Peek at the next packet.
*/
/* Peek at the next packet. */
IFQ_POLL(&ifp->if_snd, m);
if (m == NULL)
return;
@ -652,7 +634,7 @@ smc91cxx_start(struct ifnet *ifp)
len += m->m_len;
/*
* We drop packets that are too large. Perhaps we should
* We drop packets that are too large. Perhaps we should
* truncate them instead?
*/
if (len > (ETHER_MAX_LEN - ETHER_CRC_LEN)) {
@ -666,9 +648,7 @@ smc91cxx_start(struct ifnet *ifp)
pad = 0;
#ifdef SMC91CXX_SW_PAD
/*
* Not using hardware padding; pad to ETHER_MIN_LEN.
*/
/* Not using hardware padding; pad to ETHER_MIN_LEN. */
if (len < (ETHER_MIN_LEN - ETHER_CRC_LEN))
pad = ETHER_MIN_LEN - ETHER_CRC_LEN - len;
#endif
@ -682,9 +662,7 @@ smc91cxx_start(struct ifnet *ifp)
*/
npages = ((length & ~1) + 6) >> 8;
/*
* Now allocate the memory.
*/
/* Now allocate the memory. */
SMC_SELECT_BANK(sc, 2);
bus_space_write_2(bst, bsh, MMU_CMD_REG_W, MMUCR_ALLOC | npages);
@ -695,7 +673,7 @@ smc91cxx_start(struct ifnet *ifp)
} else {
do {
if (bus_space_read_1(bst, bsh,
INTR_STAT_REG_B) & IM_ALLOC_INT)
INTR_STAT_REG_B) & IM_ALLOC_INT)
break;
delay(1);
} while (--timo);
@ -720,14 +698,10 @@ smc91cxx_start(struct ifnet *ifp)
return;
}
/*
* We have a packet number - set the data window.
*/
/* We have a packet number - set the data window. */
bus_space_write_2(bst, bsh, PACKET_NUM_REG_B, packetno);
/*
* Point to the beginning of the packet.
*/
/* Point to the beginning of the packet. */
bus_space_write_2(bst, bsh, POINTER_REG_W, PTR_AUTOINC /* | 0x0000 */);
/*
@ -756,9 +730,7 @@ smc91cxx_start(struct ifnet *ifp)
pad -= 1;
}
/*
* Push out padding.
*/
/* Push out padding. */
while (pad > 1) {
bus_space_write_2(bst, bsh, DATA_REG_W, 0);
pad -= 2;
@ -810,22 +782,20 @@ smc91cxx_copy_tx_frame(struct smc91cxx_softc *sc, struct mbuf *m0)
bus_space_handle_t bsh = sc->sc_bsh;
struct mbuf *m;
int len, leftover;
u_int16_t dbuf;
u_int8_t *p;
uint16_t dbuf;
uint8_t *p;
#ifdef DIAGNOSTIC
u_int8_t *lim;
uint8_t *lim;
#endif
/* start out with no leftover data */
/* Start out with no leftover data */
leftover = 0;
dbuf = 0;
/* Process the chain of mbufs */
for (m = m0; m != NULL; m = m->m_next) {
/*
* Process all of the data in a single mbuf.
*/
p = mtod(m, u_int8_t *);
/* Process all of the data in a single mbuf. */
p = mtod(m, uint8_t *);
len = m->m_len;
#ifdef DIAGNOSTIC
lim = p + len;
@ -843,9 +813,7 @@ smc91cxx_copy_tx_frame(struct smc91cxx_softc *sc, struct mbuf *m0)
bus_space_write_2(bst, bsh, DATA_REG_W, dbuf);
leftover = 0;
} else if ((long) p & 1) {
/*
* Misaligned data. Buffer the next byte.
*/
/* Misaligned data. Buffer the next byte. */
dbuf = *p++;
len--;
leftover = 1;
@ -859,7 +827,7 @@ smc91cxx_copy_tx_frame(struct smc91cxx_softc *sc, struct mbuf *m0)
leftover = len & 1;
len &= ~1;
bus_space_write_multi_stream_2(bst, bsh,
DATA_REG_W, (u_int16_t *)p, len >> 1);
DATA_REG_W, (uint16_t *)p, len >> 1);
p += len;
if (leftover)
@ -888,19 +856,17 @@ smc91cxx_intr(void *arg)
struct ifnet *ifp = &sc->sc_ec.ec_if;
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
u_int8_t mask, interrupts, status;
u_int16_t packetno, tx_status, card_stats;
u_int16_t v;
uint8_t mask, interrupts, status;
uint16_t packetno, tx_status, card_stats;
uint16_t v;
if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0 ||
!device_is_active(sc->sc_dev))
return (0);
return 0;
SMC_SELECT_BANK(sc, 2);
/*
* Obtain the current interrupt status and mask.
*/
/* Obtain the current interrupt status and mask. */
v = bus_space_read_2(bst, bsh, INTR_STAT_REG_B);
/*
@ -914,46 +880,34 @@ smc91cxx_intr(void *arg)
/* Ours? */
if (status == 0)
return (0);
return 0;
/*
* It's ours; disable all interrupts while we process them.
*/
/* It's ours; disable all interrupts while we process them. */
smc91cxx_intr_mask_write(bst, bsh, 0);
/*
* Receive overrun interrupts.
*/
/* Receive overrun interrupts. */
if (status & IM_RX_OVRN_INT) {
smc91cxx_intr_ack_write(bst, bsh, IM_RX_OVRN_INT, 0);
ifp->if_ierrors++;
}
/*
* Receive interrupts.
*/
/* Receive interrupts. */
if (status & IM_RCV_INT) {
smc91cxx_read(sc);
}
/*
* Memory allocation interrupts.
*/
/* Memory allocation interrupts. */
if (status & IM_ALLOC_INT) {
/* Disable this interrupt. */
mask &= ~IM_ALLOC_INT;
sc->sc_intmask &= ~IM_ALLOC_INT;
/*
* Save allocated packet number for use in start
*/
/* Save allocated packet number for use in start */
packetno = bus_space_read_1(bst, bsh, ALLOC_RESULT_REG_B);
KASSERT(sc->sc_txpacketno & ARR_FAILED);
sc->sc_txpacketno = packetno;
/*
* We can transmit again!
*/
/* We can transmit again! */
ifp->if_flags &= ~IFF_OACTIVE;
ifp->if_timer = 0;
}
@ -969,9 +923,7 @@ smc91cxx_intr(void *arg)
packetno = bus_space_read_2(bst, bsh, FIFO_PORTS_REG_W) &
FIFO_TX_MASK;
/*
* Select this as the packet to read from.
*/
/* Select this as the packet to read from. */
bus_space_write_2(bst, bsh, PACKET_NUM_REG_B, packetno);
/*
@ -1016,9 +968,7 @@ smc91cxx_intr(void *arg)
TCR_ENABLE | TCR_PAD_ENABLE);
#endif
/*
* Kill the failed packet and wait for the MMU to unbusy.
*/
/* Kill the failed packet and wait for the MMU to unbusy. */
SMC_SELECT_BANK(sc, 2);
while (bus_space_read_2(bst, bsh, MMU_CMD_REG_W) & MMUCR_BUSY)
/* XXX bound this loop! */ ;
@ -1052,30 +1002,22 @@ smc91cxx_intr(void *arg)
ifp->if_timer = 0;
}
/*
* Internal PHY status change
*/
/* Internal PHY status change */
if (sc->sc_chipid == CHIP_91C111 && sc->sc_internal_phy &&
(status & IM_MD_INT)) {
/*
* Internal PHY status change
*/
/* Internal PHY status change */
smc91cxx_intr_ack_write(bst, bsh, IM_MD_INT, 0);
mii_pollstat(&sc->sc_mii);
}
/*
* Other errors. Reset the interface.
*/
/* Other errors. Reset the interface. */
if (status & IM_EPH_INT) {
smc91cxx_stop(sc);
smc91cxx_init(sc);
}
/*
* Attempt to queue more packets for transmission.
*/
/* Attempt to queue more packets for transmission. */
if_schedule_deferred_start(ifp);
/*
@ -1088,7 +1030,7 @@ smc91cxx_intr(void *arg)
if (status)
rnd_add_uint32(&sc->rnd_source, status);
return (1);
return 1;
}
/*
@ -1103,9 +1045,9 @@ smc91cxx_read(struct smc91cxx_softc *sc)
bus_space_handle_t bsh = sc->sc_bsh;
struct ether_header *eh;
struct mbuf *m;
u_int16_t status, packetno, packetlen;
u_int8_t *data;
u_int32_t dr;
uint16_t status, packetno, packetlen;
uint8_t *data;
uint32_t dr;
bool first = true;
again:
@ -1128,12 +1070,10 @@ smc91cxx_read(struct smc91cxx_softc *sc)
PTR_READ | PTR_RCV | PTR_AUTOINC /* | 0x0000 */);
delay(1);
/*
* First two words are status and packet length.
*/
/* First two words are status and packet length. */
dr = bus_space_read_4(bst, bsh, DATA_REG_W);
status = (u_int16_t)dr;
packetlen = (u_int16_t)(dr >> 16);
status = (uint16_t)dr;
packetlen = (uint16_t)(dr >> 16);
packetlen &= RLEN_MASK;
if (packetlen < ETHER_MIN_LEN - ETHER_CRC_LEN + 6 || packetlen > 1534) {
@ -1147,23 +1087,17 @@ smc91cxx_read(struct smc91cxx_softc *sc)
*/
packetlen -= 6;
/*
* Account for receive errors and discard.
*/
/* Account for receive errors and discard. */
if (status & RS_ERRORS) {
ifp->if_ierrors++;
goto out;
}
/*
* Adjust for odd-length packet.
*/
/* Adjust for odd-length packet. */
if (status & RS_ODDFRAME)
packetlen++;
/*
* Allocate a header mbuf.
*/
/* Allocate a header mbuf. */
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
goto out;
@ -1188,32 +1122,32 @@ smc91cxx_read(struct smc91cxx_softc *sc)
* is aligned.
*/
if ((sc->sc_flags & SMC_FLAGS_32BIT_READ) == 0) {
m->m_data = (char *) ALIGN(mtod(m, char *) +
m->m_data = (char *)ALIGN(mtod(m, char *) +
sizeof(struct ether_header)) - sizeof(struct ether_header);
eh = mtod(m, struct ether_header *);
data = mtod(m, u_int8_t *);
data = mtod(m, uint8_t *);
KASSERT(trunc_page((uintptr_t)data) ==
trunc_page((uintptr_t)data + packetlen - 1));
if (packetlen > 1)
bus_space_read_multi_stream_2(bst, bsh, DATA_REG_W,
(u_int16_t *)data, packetlen >> 1);
(uint16_t *)data, packetlen >> 1);
if (packetlen & 1) {
data += packetlen & ~1;
*data = bus_space_read_1(bst, bsh, DATA_REG_B);
}
} else {
m->m_data = (void *) ALIGN(mtod(m, void *));
m->m_data = (void *)ALIGN(mtod(m, void *));
eh = mtod(m, struct ether_header *);
data = mtod(m, u_int8_t *);
data = mtod(m, uint8_t *);
KASSERT(trunc_page((uintptr_t)data) ==
trunc_page((uintptr_t)data + packetlen - 1));
if (packetlen > 3)
bus_space_read_multi_stream_4(bst, bsh, DATA_REG_W,
(u_int32_t *)data, packetlen >> 2);
(uint32_t *)data, packetlen >> 2);
if (packetlen & 3) {
data += packetlen & ~3;
*((u_int32_t *)data) =
*((uint32_t *)data) =
bus_space_read_stream_4(bst, bsh, DATA_REG_W);
}
}
@ -1225,9 +1159,7 @@ smc91cxx_read(struct smc91cxx_softc *sc)
* (should be ensured by chipset configuration)
*/
if ((ifp->if_flags & IFF_PROMISC) != 0) {
/*
* Drop packet looped back from myself.
*/
/* Drop packet looped back from myself. */
if (ether_cmp(eh->ether_shost, CLLADDR(ifp->if_sadl)) == 0) {
m_freem(m);
goto out;
@ -1239,16 +1171,12 @@ smc91cxx_read(struct smc91cxx_softc *sc)
if_percpuq_enqueue(ifp->if_percpuq, m);
out:
/*
* Tell the card to free the memory occupied by this packet.
*/
/* Tell the card to free the memory occupied by this packet. */
while (bus_space_read_2(bst, bsh, MMU_CMD_REG_W) & MMUCR_BUSY)
/* XXX bound this loop! */ ;
bus_space_write_2(bst, bsh, MMU_CMD_REG_W, MMUCR_RELEASE);
/*
* Check for another packet.
*/
/* Check for another packet. */
goto again;
}
@ -1339,7 +1267,7 @@ smc91cxx_ioctl(struct ifnet *ifp, u_long cmd, void *data)
}
splx(s);
return (error);
return error;
}
/*
@ -1378,22 +1306,16 @@ smc91cxx_stop(struct smc91cxx_softc *sc)
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
/*
* Clear interrupt mask; disable all interrupts.
*/
/* Clear interrupt mask; disable all interrupts. */
SMC_SELECT_BANK(sc, 2);
smc91cxx_intr_mask_write(bst, bsh, 0);
/*
* Disable transmitter and receiver.
*/
/* Disable transmitter and receiver. */
SMC_SELECT_BANK(sc, 0);
bus_space_write_2(bst, bsh, RECV_CONTROL_REG_W, 0);
bus_space_write_2(bst, bsh, TXMIT_CONTROL_REG_W, 0);
/*
* Cancel watchdog timer.
*/
/* Cancel watchdog timer. */
sc->sc_ec.ec_if.if_timer = 0;
}
@ -1407,12 +1329,12 @@ smc91cxx_enable(struct smc91cxx_softc *sc)
if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0 && sc->sc_enable != NULL) {
if ((*sc->sc_enable)(sc) != 0) {
aprint_error_dev(sc->sc_dev, "device enable failed\n");
return (EIO);
return EIO;
}
}
sc->sc_flags |= SMC_FLAGS_ENABLED;
return (0);
return 0;
}
/*
@ -1450,7 +1372,7 @@ smc91cxx_detach(device_t self, int flags)
/* Succeed now if there's no work to do. */
if ((sc->sc_flags & SMC_FLAGS_ATTACHED) == 0)
return (0);
return 0;
/* smc91cxx_disable() checks SMC_FLAGS_ENABLED */
smc91cxx_disable(sc);
@ -1465,20 +1387,20 @@ smc91cxx_detach(device_t self, int flags)
ether_ifdetach(ifp);
if_detach(ifp);
return (0);
return 0;
}
u_int32_t
uint32_t
smc91cxx_mii_bitbang_read(device_t self)
{
struct smc91cxx_softc *sc = device_private(self);
/* We're already in bank 3. */
return (bus_space_read_2(sc->sc_bst, sc->sc_bsh, MGMT_REG_W));
return bus_space_read_2(sc->sc_bst, sc->sc_bsh, MGMT_REG_W);
}
void
smc91cxx_mii_bitbang_write(device_t self, u_int32_t val)
smc91cxx_mii_bitbang_write(device_t self, uint32_t val)
{
struct smc91cxx_softc *sc = device_private(self);
@ -1533,7 +1455,7 @@ smc91cxx_statchg(struct ifnet *ifp)
else
mctl &= ~TCR_SWFDUP;
bus_space_write_2(bst, bsh, TXMIT_CONTROL_REG_W, mctl);
SMC_SELECT_BANK(sc, 2); /* back to operating window */
SMC_SELECT_BANK(sc, 2); /* Back to operating window */
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ef.c,v 1.33 2019/04/09 06:00:08 msaitoh Exp $ */
/* $NetBSD: if_ef.c,v 1.34 2019/04/25 10:08:46 msaitoh Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ef.c,v 1.33 2019/04/09 06:00:08 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ef.c,v 1.34 2019/04/25 10:08:46 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -80,18 +80,18 @@ static int ef_media[] = {
IFM_ETHER | IFM_10_5,
IFM_ETHER | IFM_10_2,
};
#define NEF_MEDIA (sizeof(ef_media) / sizeof(ef_media[0]))
#define NEF_MEDIA __arraycount(ef_media)
static int eftp_media[] = {
IFM_ETHER | IFM_10_T,
};
#define NEFTP_MEDIA (sizeof(eftp_media) / sizeof(eftp_media[0]))
#define NEFTP_MEDIA __arraycount(eftp_media)
/* Routines required by the MI i82586 driver API */
static void ef_reset(struct ie_softc *, int);
static void ef_hwinit(struct ie_softc *);
static void ef_atten(struct ie_softc *, int);
static int ef_intrhook(struct ie_softc *, int);
static void ef_reset(struct ie_softc *, int);
static void ef_hwinit(struct ie_softc *);
static void ef_atten(struct ie_softc *, int);
static int ef_intrhook(struct ie_softc *, int);
static void ef_copyin(struct ie_softc *, void *, int, size_t);
static void ef_copyout(struct ie_softc *, const void *, int, size_t);
@ -103,7 +103,7 @@ static void ef_write_24(struct ie_softc *, int, int);
static void ef_mediastatus(struct ie_softc *, struct ifmediareq *);
/* Local routines */
static int ef_port_check(bus_space_tag_t, bus_space_handle_t);
static int ef_port_check(bus_space_tag_t, bus_space_handle_t);
static int ef_match(device_t, cfdata_t, void *);
static void ef_attach(device_t, device_t, void *);
@ -117,7 +117,7 @@ static void ef_attach(device_t, device_t, void *);
* which will unique per ISA bus.
*/
#define MAXCARDS_PER_ISABUS 8 /* If you have more than 8, you lose */
#define MAXCARDS_PER_ISABUS 8 /* If you have more than 8, you lose */
struct ef_isabus {
LIST_ENTRY(ef_isabus) isa_link;
@ -312,10 +312,10 @@ ef_write_24(struct ie_softc *sc, int offset, int addr)
static void
ef_mediastatus(struct ie_softc *sc, struct ifmediareq *ifmr)
{
struct ifmedia *ifm = &sc->sc_media;
struct ifmedia *ifm = &sc->sc_media;
/* The currently selected media is always the active media. */
ifmr->ifm_active = ifm->ifm_cur->ifm_media;
/* The currently selected media is always the active media. */
ifmr->ifm_active = ifm->ifm_cur->ifm_media;
}
static int
@ -645,7 +645,7 @@ static int
ef_port_check(bus_space_tag_t iot, bus_space_handle_t ioh)
{
int i;
u_char ch;
u_char ch;
const u_char *signature = EF_SIGNATURE;
for (i = 0; i < strlen(signature); i++) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ix.c,v 1.37 2019/04/09 06:19:34 msaitoh Exp $ */
/* $NetBSD: if_ix.c,v 1.38 2019/04/25 10:08:46 msaitoh Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ix.c,v 1.37 2019/04/09 06:19:34 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ix.c,v 1.38 2019/04/25 10:08:46 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -68,7 +68,7 @@ static int ix_media[] = {
IFM_ETHER | IFM_10_2,
IFM_ETHER | IFM_10_T,
};
#define NIX_MEDIA (sizeof(ix_media) / sizeof(ix_media[0]))
#define NIX_MEDIA __arraycount(ix_media)
struct ix_softc {
struct ie_softc sc_ie;
@ -81,12 +81,12 @@ struct ix_softc {
void *sc_ih; /* interrupt handle */
};
static void ix_reset(struct ie_softc *, int);
static void ix_atten(struct ie_softc *, int);
static int ix_intrhook(struct ie_softc *, int);
static void ix_reset(struct ie_softc *, int);
static void ix_atten(struct ie_softc *, int);
static int ix_intrhook(struct ie_softc *, int);
static void ix_copyin(struct ie_softc *, void *, int, size_t);
static void ix_copyout(struct ie_softc *, const void *, int, size_t);
static void ix_copyin(struct ie_softc *, void *, int, size_t);
static void ix_copyout(struct ie_softc *, const void *, int, size_t);
static void ix_bus_barrier(struct ie_softc *, int, int, int);
@ -220,15 +220,15 @@ ix_intrhook(struct ie_softc *sc, int where)
switch (where) {
case INTR_ENTER:
/* entering ISR: disable card interrupts */
/* Entering ISR: disable card interrupts */
bus_space_write_1(isc->sc_regt, isc->sc_regh,
IX_IRQ, isc->irq_encoded);
break;
case INTR_EXIT:
/* exiting ISR: re-enable card interrupts */
/* Exiting ISR: re-enable card interrupts */
bus_space_write_1(isc->sc_regt, isc->sc_regh, IX_IRQ,
isc->irq_encoded | IX_IRQ_ENABLE);
isc->irq_encoded | IX_IRQ_ENABLE);
break;
}
@ -267,7 +267,7 @@ ix_copyin(struct ie_softc *sc, void *dst, int offset, size_t size)
wptr = (uint16_t*)bptr;
if (isc->use_pio) {
for (i = 0; i < size / 2; i++) {
for (i = 0; i < size / 2; i++) {
*wptr = bus_space_read_2(sc->bt, sc->bh, IX_DATAPORT);
wptr++;
}
@ -416,7 +416,7 @@ ix_write_24 (struct ie_softc *sc, int offset, int addr)
bus_space_barrier(sc->bt, sc->bh, IX_DATAPORT, 2,
BUS_SPACE_BARRIER_WRITE);
} else {
bus_space_write_4(sc->bt, sc->bh, offset, val);
bus_space_write_4(sc->bt, sc->bh, offset, val);
bus_space_barrier(sc->bt, sc->bh, offset, 4,
BUS_SPACE_BARRIER_WRITE);
}
@ -440,7 +440,7 @@ ix_zeromem(struct ie_softc *sc, int offset, int count)
count--;
}
dribble = count % 2;
dribble = count % 2;
for (i = 0; i < count / 2; i++)
bus_space_write_2(sc->bt, sc->bh, IX_DATAPORT, 0);
@ -459,10 +459,10 @@ ix_zeromem(struct ie_softc *sc, int offset, int count)
static void
ix_mediastatus(struct ie_softc *sc, struct ifmediareq *ifmr)
{
struct ifmedia *ifm = &sc->sc_media;
struct ifmedia *ifm = &sc->sc_media;
/* The currently selected media is always the active media. */
ifmr->ifm_active = ifm->ifm_cur->ifm_media;
/* The currently selected media is always the active media. */
ifmr->ifm_active = ifm->ifm_cur->ifm_media;
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_le_pci.c,v 1.53 2018/12/09 11:14:02 jdolecek Exp $ */
/* $NetBSD: if_le_pci.c,v 1.54 2019/04/25 10:08:46 msaitoh Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_le_pci.c,v 1.53 2018/12/09 11:14:02 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_le_pci.c,v 1.54 2019/04/25 10:08:46 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -109,12 +109,12 @@ CFATTACH_DECL_NEW(le_pci, sizeof(struct le_softc),
#define LE_PCI_MEMSIZE 16384
static int le_pci_supmedia[] = {
IFM_ETHER|IFM_AUTO,
IFM_ETHER|IFM_AUTO|IFM_FDX,
IFM_ETHER|IFM_10_T,
IFM_ETHER|IFM_10_T|IFM_FDX,
IFM_ETHER|IFM_10_5,
IFM_ETHER|IFM_10_5|IFM_FDX,
IFM_ETHER | IFM_AUTO,
IFM_ETHER | IFM_AUTO | IFM_FDX,
IFM_ETHER | IFM_10_T,
IFM_ETHER | IFM_10_T | IFM_FDX,
IFM_ETHER | IFM_10_5,
IFM_ETHER | IFM_10_5 | IFM_FDX,
};
static void
@ -138,7 +138,7 @@ le_pci_rdcsr(struct lance_softc *sc, uint16_t port)
bus_space_write_2(iot, ioh, lesc->sc_rap, port);
val = bus_space_read_2(iot, ioh, lesc->sc_rdp);
return (val);
return val;
}
static int
@ -153,14 +153,14 @@ le_pci_mediachange(struct lance_softc *sc)
if (IFM_SUBTYPE(newmedia) !=
IFM_SUBTYPE(lesc->sc_currentmedia)) {
if (IFM_SUBTYPE(newmedia) == IFM_AUTO) {
/* switch to autoselect - BCR2 bit 1 */
/* Switch to autoselect - BCR2 bit 1 */
bus_space_write_2(iot, ioh, PCNET_PCI_RAP, 2);
reg = bus_space_read_2(iot, ioh, PCNET_PCI_BDP);
reg |= 2;
bus_space_write_2(iot, ioh, PCNET_PCI_RAP, 2);
bus_space_write_2(iot, ioh, PCNET_PCI_BDP, reg);
} else {
/* force media type (in init block) */
/* Force media type (in init block) */
lance_reset(sc);
if (IFM_SUBTYPE(newmedia) == IFM_10_T)
sc->sc_initmodemedia = 1; /* UTP */
@ -169,7 +169,7 @@ le_pci_mediachange(struct lance_softc *sc)
lance_init(&sc->sc_ethercom.ec_if);
if (IFM_SUBTYPE(lesc->sc_currentmedia) == IFM_AUTO) {
/* take away autoselect - BCR2 bit 1 */
/* Take away autoselect - BCR2 bit 1 */
bus_space_write_2(iot, ioh, PCNET_PCI_RAP, 2);
reg = bus_space_read_2(iot, ioh, PCNET_PCI_BDP);
reg &= ~2;
@ -182,13 +182,15 @@ le_pci_mediachange(struct lance_softc *sc)
if ((IFM_OPTIONS(newmedia) ^ IFM_OPTIONS(lesc->sc_currentmedia))
& IFM_FDX) {
/* toggle full duplex - BCR9 */
/* Toggle full duplex - BCR9 */
bus_space_write_2(iot, ioh, PCNET_PCI_RAP, 9);
reg = bus_space_read_2(iot, ioh, PCNET_PCI_BDP);
if (IFM_OPTIONS(newmedia) & IFM_FDX) {
reg |= 1; /* FDEN */
/* allow FDX on AUI only if explicitly chosen,
not in autoselect mode */
/*
* Allow FDX on AUI only if explicitly chosen, not in
* autoselect mode
*/
if (IFM_SUBTYPE(newmedia) == IFM_10_5)
reg |= 2; /* AUIFD */
else
@ -200,7 +202,7 @@ le_pci_mediachange(struct lance_softc *sc)
}
lesc->sc_currentmedia = newmedia;
return (0);
return 0;
}
static int
@ -209,14 +211,14 @@ le_pci_match(device_t parent, cfdata_t cf, void *aux)
struct pci_attach_args *pa = aux;
if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_AMD)
return (0);
return 0;
switch (PCI_PRODUCT(pa->pa_id)) {
case PCI_PRODUCT_AMD_PCNET_PCI:
return (1);
return 1;
}
return (0);
return 0;
}
static void
@ -257,9 +259,7 @@ le_pci_attach(device_t parent, device_t self, void *aux)
return;
}
/*
* Extract the physical MAC address from the ROM.
*/
/* Extract the physical MAC address from the ROM. */
for (i = 0; i < sizeof(sc->sc_enaddr); i++)
sc->sc_enaddr[i] = bus_space_read_1(iot, ioh, i);
@ -267,9 +267,7 @@ le_pci_attach(device_t parent, device_t self, void *aux)
lesc->sc_ioh = ioh;
lesc->sc_dmat = dmat;
/*
* Allocate a DMA area for the card.
*/
/* Allocate a DMA area for the card. */
if (bus_dmamem_alloc(dmat, LE_PCI_MEMSIZE, PAGE_SIZE, 0, &seg, 1,
&rseg, BUS_DMA_NOWAIT)) {
aprint_error_dev(self, "couldn't allocate memory for card\n");
@ -282,9 +280,7 @@ le_pci_attach(device_t parent, device_t self, void *aux)
return;
}
/*
* Create and load the DMA map for the DMA area.
*/
/* Create and load the DMA map for the DMA area. */
if (bus_dmamap_create(dmat, LE_PCI_MEMSIZE, 1,
LE_PCI_MEMSIZE, 0, BUS_DMA_NOWAIT, &lesc->sc_dmam)) {
aprint_error_dev(self, "couldn't create DMA map\n");
@ -313,7 +309,7 @@ le_pci_attach(device_t parent, device_t self, void *aux)
sc->sc_hwinit = NULL;
sc->sc_supmedia = le_pci_supmedia;
sc->sc_nsupmedia = sizeof(le_pci_supmedia) / sizeof(int);
sc->sc_nsupmedia = __arraycount(le_pci_supmedia);
sc->sc_defaultmedia = le_pci_supmedia[0];
sc->sc_mediachange = le_pci_mediachange;
lesc->sc_currentmedia = le_pci_supmedia[0];

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ie_vme.c,v 1.31 2014/08/18 04:26:38 riastradh Exp $ */
/* $NetBSD: if_ie_vme.c,v 1.32 2019/04/25 10:08:46 msaitoh Exp $ */
/*
* Copyright (c) 1995 Charles D. Cranor
@ -140,7 +140,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ie_vme.c,v 1.31 2014/08/18 04:26:38 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ie_vme.c,v 1.32 2019/04/25 10:08:46 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -184,12 +184,12 @@ __KERNEL_RCSID(0, "$NetBSD: if_ie_vme.c,v 1.31 2014/08/18 04:26:38 riastradh Exp
#define IEVME_PGMASK 0x0fff /* gives the physical page frame number */
struct ievme {
u_int16_t pgmap[IEVME_MAPSZ];
u_int16_t xxx[32]; /* prom */
u_int16_t status; /* see below for bits */
u_int16_t xxx2; /* filler */
u_int16_t pectrl; /* parity control (see below) */
u_int16_t peaddr; /* low 16 bits of address */
uint16_t pgmap[IEVME_MAPSZ];
uint16_t xxx[32]; /* prom */
uint16_t status; /* see below for bits */
uint16_t xxx2; /* filler */
uint16_t pectrl; /* parity control (see below) */
uint16_t peaddr; /* low 16 bits of address */
};
/*
@ -218,7 +218,7 @@ struct ievme {
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?)
@ -254,6 +254,7 @@ void
ie_vmereset(struct ie_softc *sc, int what)
{
struct ie_vme_softc *vsc = (struct ie_vme_softc *)sc;
write_iev(vsc, status, IEVME_RESET);
delay(100); /* XXX could be shorter? */
write_iev(vsc, status, 0);
@ -264,9 +265,9 @@ ie_vmeattend(struct ie_softc *sc, int why)
{
struct ie_vme_softc *vsc = (struct ie_vme_softc *)sc;
/* flag! */
/* Flag! */
write_iev(vsc, status, read_iev(vsc, status) | IEVME_ATTEN);
/* down. */
/* Down. */
write_iev(vsc, status, read_iev(vsc, status) & ~IEVME_ATTEN);
}
@ -285,19 +286,20 @@ ie_vmeintr(struct ie_softc *sc, int where)
struct ie_vme_softc *vsc = (struct ie_vme_softc *)sc;
if (where != INTR_ENTER)
return (0);
return 0;
/*
* check for parity error
*/
/*
* check for parity error
*/
if (read_iev(vsc, status) & IEVME_PERR) {
aprint_error_dev(sc->sc_dev, "parity error (ctrl 0x%x @ 0x%02x%04x)\n",
read_iev(vsc, pectrl),
read_iev(vsc, pectrl) & IEVME_HADDR,
read_iev(vsc, peaddr));
aprint_error_dev(sc->sc_dev,
"parity error (ctrl 0x%x @ 0x%02x%04x)\n",
read_iev(vsc, pectrl),
read_iev(vsc, pectrl) & IEVME_HADDR,
read_iev(vsc, peaddr));
write_iev(vsc, pectrl, read_iev(vsc, pectrl) | IEVME_PARACK);
}
return (0);
return 0;
}
void ie_memcopyin(struct ie_softc *, void *, int, size_t);
@ -312,9 +314,9 @@ ie_memcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
size_t help;
if ((offset & 1) && ((u_long)p & 1) && size > 0) {
*(u_int8_t *)p = bus_space_read_1(sc->bt, sc->bh, offset);
*(uint8_t *)p = bus_space_read_1(sc->bt, sc->bh, offset);
offset++;
p = (u_int8_t *)p + 1;
p = (uint8_t *)p + 1;
size--;
}
@ -329,8 +331,8 @@ ie_memcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
return;
offset += 2 * help;
p = (u_int16_t *)p + help;
*(u_int8_t *)p = bus_space_read_1(sc->bt, sc->bh, offset);
p = (uint16_t *)p + help;
*(uint8_t *)p = bus_space_read_1(sc->bt, sc->bh, offset);
}
/*
@ -342,9 +344,9 @@ ie_memcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
size_t help;
if ((offset & 1) && ((u_long)p & 1) && size > 0) {
bus_space_write_1(sc->bt, sc->bh, offset, *(const u_int8_t *)p);
bus_space_write_1(sc->bt, sc->bh, offset, *(const uint8_t *)p);
offset++;
p = (const u_int8_t *)p + 1;
p = (const uint8_t *)p + 1;
size--;
}
@ -359,20 +361,20 @@ ie_memcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
return;
offset += 2 * help;
p = (const u_int16_t *)p + help;
bus_space_write_1(sc->bt, sc->bh, offset, *(const u_int8_t *)p);
p = (const uint16_t *)p + help;
bus_space_write_1(sc->bt, sc->bh, offset, *(const uint8_t *)p);
}
/* read a 16-bit value at BH offset */
u_int16_t ie_vme_read16(struct ie_softc *, int offset);
uint16_t ie_vme_read16(struct ie_softc *, int offset);
/* write a 16-bit value at BH offset */
void ie_vme_write16(struct ie_softc *, int offset, u_int16_t value);
void ie_vme_write16(struct ie_softc *, int offset, uint16_t value);
void ie_vme_write24(struct ie_softc *, int offset, int addr);
u_int16_t
uint16_t
ie_vme_read16(struct ie_softc *sc, int offset)
{
u_int16_t v;
uint16_t v;
bus_space_barrier(sc->bt, sc->bh, offset, 2, BUS_SPACE_BARRIER_READ);
v = bus_space_read_2(sc->bt, sc->bh, offset);
@ -380,7 +382,7 @@ ie_vme_read16(struct ie_softc *sc, int offset)
}
void
ie_vme_write16(struct ie_softc *sc, int offset, u_int16_t v)
ie_vme_write16(struct ie_softc *sc, int offset, uint16_t v)
{
int v0 = ((((v)&0xff)<<8) | (((v)>>8)&0xff));
bus_space_write_2(sc->bt, sc->bh, offset, v0);
@ -391,7 +393,7 @@ void
ie_vme_write24(struct ie_softc *sc, int offset, int addr)
{
u_char *f = (u_char *)&addr;
u_int16_t v0, v1;
uint16_t v0, v1;
u_char *t;
t = (u_char *)&v0;
@ -415,38 +417,37 @@ ie_vme_match(device_t parent, cfdata_t cf, void *aux)
if (va->numcfranges < 2) {
printf("ie_vme_match: need 2 ranges\n");
return (0);
return 0;
}
if ((va->r[1].offset & 0xff0fffff) ||
((va->r[0].offset & 0xfff00000)
!= (va->r[1].offset & 0xfff00000))) {
printf("ie_vme_match: base address mismatch\n");
return (0);
return 0;
}
if (va->r[0].size != VMECF_LEN_DEFAULT &&
va->r[0].size != sizeof(struct ievme)) {
printf("ie_vme_match: bad csr size\n");
return (0);
return 0;
}
if (va->r[1].size == VMECF_LEN_DEFAULT) {
printf("ie_vme_match: must specify memory size\n");
return (0);
return 0;
}
mod = 0x3d; /* VME_AM_A24|VME_AM_MBO|VME_AM_SUPER|VME_AM_DATA */
if (va->r[0].am != VMECF_AM_DEFAULT &&
va->r[0].am != mod)
return (0);
return 0;
if (vme_space_alloc(va->va_vct, va->r[0].offset,
sizeof(struct ievme), mod))
return (0);
if (vme_space_alloc(va->va_vct, va->r[1].offset,
va->r[1].size, mod)) {
return 0;
if (vme_space_alloc(va->va_vct, va->r[1].offset, va->r[1].size, mod)) {
vme_space_free(va->va_vct, va->r[0].offset,
sizeof(struct ievme), mod);
return (0);
return 0;
}
error = vme_probe(ct, va->r[0].offset, 2, mod, VME_D16, 0, 0);
vme_space_free(va->va_vct, va->r[0].offset, sizeof(struct ievme), mod);
@ -458,7 +459,7 @@ ie_vme_match(device_t parent, cfdata_t cf, void *aux)
void
ie_vme_attach(device_t parent, device_t self, void *aux)
{
u_int8_t myaddr[ETHER_ADDR_LEN];
uint8_t myaddr[ETHER_ADDR_LEN];
struct ie_vme_softc *vsc = device_private(self);
struct vme_attach_args *va = aux;
vme_chipset_tag_t ct = va->va_vct;
@ -472,9 +473,8 @@ ie_vme_attach(device_t parent, device_t self, void *aux)
vme_am_t mod;
/*
* *note*: we don't detect the difference between a VME3E and
* a multibus/vme card. if you want to use a 3E you'll have
* to fix this.
* *note*: We don't detect the difference between a VME3E and a
* multibus/vme card. If you want to use a 3E you'll have to fix this.
*/
mod = 0x3d; /* VME_AM_A24|VME_AM_MBO|VME_AM_SUPER|VME_AM_DATA */
if (vme_space_alloc(va->va_vct, va->r[0].offset,
@ -501,8 +501,7 @@ ie_vme_attach(device_t parent, device_t self, void *aux)
memsize = va->r[1].size;
if (vme_space_map(ct, va->r[0].offset, sizeof(struct ievme), mod,
VME_D16 | VME_D8, 0,
&vsc->ievt, &vsc->ievh, &resc) != 0)
VME_D16 | VME_D8, 0, &vsc->ievt, &vsc->ievh, &resc) != 0)
panic("if_ie: vme map csr");
rampaddr = va->r[1].offset;
@ -550,9 +549,7 @@ ie_vme_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 = IEVME_PAGESIZE;
sc->buf_area_sz = memsize - IEVME_PAGESIZE;