Misc KNF.
This commit is contained in:
parent
d35d52d37f
commit
5c2e2150a5
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: ne2000.c,v 1.68 2010/03/03 13:39:57 tsutsui Exp $ */
|
/* $NetBSD: ne2000.c,v 1.69 2010/03/13 15:08:24 tsutsui Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
|
||||||
@ -48,7 +48,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: ne2000.c,v 1.68 2010/03/03 13:39:57 tsutsui Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: ne2000.c,v 1.69 2010/03/13 15:08:24 tsutsui Exp $");
|
||||||
|
|
||||||
#include "opt_ipkdb.h"
|
#include "opt_ipkdb.h"
|
||||||
|
|
||||||
@ -98,10 +98,10 @@ void ne2000_read_hdr(struct dp8390_softc *, int, struct dp8390_ring *);
|
|||||||
int ne2000_test_mem(struct dp8390_softc *);
|
int ne2000_test_mem(struct dp8390_softc *);
|
||||||
|
|
||||||
void ne2000_writemem(bus_space_tag_t, bus_space_handle_t,
|
void ne2000_writemem(bus_space_tag_t, bus_space_handle_t,
|
||||||
bus_space_tag_t, bus_space_handle_t, u_int8_t *, int, size_t,
|
bus_space_tag_t, bus_space_handle_t, uint8_t *, int, size_t,
|
||||||
int, int);
|
int, int);
|
||||||
void ne2000_readmem(bus_space_tag_t, bus_space_handle_t,
|
void ne2000_readmem(bus_space_tag_t, bus_space_handle_t,
|
||||||
bus_space_tag_t, bus_space_handle_t, int, u_int8_t *, size_t, int);
|
bus_space_tag_t, bus_space_handle_t, int, uint8_t *, size_t, int);
|
||||||
|
|
||||||
#ifdef NE2000_DETECT_8BIT
|
#ifdef NE2000_DETECT_8BIT
|
||||||
static bool ne2000_detect_8bit(bus_space_tag_t, bus_space_handle_t,
|
static bool ne2000_detect_8bit(bus_space_tag_t, bus_space_handle_t,
|
||||||
@ -113,14 +113,14 @@ static bool ne2000_detect_8bit(bus_space_tag_t, bus_space_handle_t,
|
|||||||
BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
|
BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
|
||||||
|
|
||||||
int
|
int
|
||||||
ne2000_attach(struct ne2000_softc *nsc, u_int8_t *myea)
|
ne2000_attach(struct ne2000_softc *nsc, uint8_t *myea)
|
||||||
{
|
{
|
||||||
struct dp8390_softc *dsc = &nsc->sc_dp8390;
|
struct dp8390_softc *dsc = &nsc->sc_dp8390;
|
||||||
bus_space_tag_t nict = dsc->sc_regt;
|
bus_space_tag_t nict = dsc->sc_regt;
|
||||||
bus_space_handle_t nich = dsc->sc_regh;
|
bus_space_handle_t nich = dsc->sc_regh;
|
||||||
bus_space_tag_t asict = nsc->sc_asict;
|
bus_space_tag_t asict = nsc->sc_asict;
|
||||||
bus_space_handle_t asich = nsc->sc_asich;
|
bus_space_handle_t asich = nsc->sc_asich;
|
||||||
u_int8_t romdata[16];
|
uint8_t romdata[16];
|
||||||
int memstart, memsize, i, useword;
|
int memstart, memsize, i, useword;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -138,7 +138,7 @@ ne2000_attach(struct ne2000_softc *nsc, u_int8_t *myea)
|
|||||||
case NE2000_TYPE_UNKNOWN:
|
case NE2000_TYPE_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
aprint_error_dev(dsc->sc_dev, "where did the card go?\n");
|
aprint_error_dev(dsc->sc_dev, "where did the card go?\n");
|
||||||
return (1);
|
return 1;
|
||||||
case NE2000_TYPE_NE1000:
|
case NE2000_TYPE_NE1000:
|
||||||
memstart = 8192;
|
memstart = 8192;
|
||||||
memsize = 8192;
|
memsize = 8192;
|
||||||
@ -246,8 +246,9 @@ ne2000_attach(struct ne2000_softc *nsc, u_int8_t *myea)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (memstart == 0) {
|
if (memstart == 0) {
|
||||||
aprint_error_dev(&dsc->sc_dev, "cannot find start of RAM\n");
|
aprint_error_dev(&dsc->sc_dev,
|
||||||
return (1);
|
"cannot find start of RAM\n");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search for the end of RAM. */
|
/* Search for the end of RAM. */
|
||||||
@ -319,20 +320,21 @@ ne2000_attach(struct ne2000_softc *nsc, u_int8_t *myea)
|
|||||||
|
|
||||||
if (dp8390_config(dsc)) {
|
if (dp8390_config(dsc)) {
|
||||||
aprint_error_dev(dsc->sc_dev, "setup failed\n");
|
aprint_error_dev(dsc->sc_dev, "setup failed\n");
|
||||||
return (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Detect an NE-2000 or compatible. Returns a model code.
|
* Detect an NE-2000 or compatible. Returns a model code.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ne2000_detect(bus_space_tag_t nict, bus_space_handle_t nich, bus_space_tag_t asict, bus_space_handle_t asich)
|
ne2000_detect(bus_space_tag_t nict, bus_space_handle_t nich,
|
||||||
|
bus_space_tag_t asict, bus_space_handle_t asich)
|
||||||
{
|
{
|
||||||
static u_int8_t test_pattern[32] = "THIS is A memory TEST pattern";
|
static uint8_t test_pattern[32] = "THIS is A memory TEST pattern";
|
||||||
u_int8_t test_buffer[32], tmp;
|
uint8_t test_buffer[32], tmp;
|
||||||
int i, rv = NE2000_TYPE_UNKNOWN;
|
int i, rv = NE2000_TYPE_UNKNOWN;
|
||||||
int useword;
|
int useword;
|
||||||
|
|
||||||
@ -507,7 +509,7 @@ ne2000_detect(bus_space_tag_t nict, bus_space_handle_t nich, bus_space_tag_t asi
|
|||||||
NIC_BARRIER(nict, nich);
|
NIC_BARRIER(nict, nich);
|
||||||
bus_space_write_1(nict, nich, ED_P0_ISR, 0xff);
|
bus_space_write_1(nict, nich, ED_P0_ISR, 0xff);
|
||||||
|
|
||||||
return (rv);
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NE2000_DETECT_8BIT
|
#ifdef NE2000_DETECT_8BIT
|
||||||
@ -594,10 +596,10 @@ ne2000_write_mbuf(struct dp8390_softc *sc, struct mbuf *m, int buf)
|
|||||||
*/
|
*/
|
||||||
if (nsc->sc_useword == 0) {
|
if (nsc->sc_useword == 0) {
|
||||||
/* byte ops are easy. */
|
/* byte ops are easy. */
|
||||||
for (; m != 0; m = m->m_next) {
|
for (; m != NULL; m = m->m_next) {
|
||||||
if (m->m_len) {
|
if (m->m_len) {
|
||||||
bus_space_write_multi_1(asict, asich,
|
bus_space_write_multi_1(asict, asich,
|
||||||
NE2000_ASIC_DATA, mtod(m, u_int8_t *),
|
NE2000_ASIC_DATA, mtod(m, uint8_t *),
|
||||||
m->m_len);
|
m->m_len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -608,20 +610,20 @@ ne2000_write_mbuf(struct dp8390_softc *sc, struct mbuf *m, int buf)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* word ops are a bit trickier. */
|
/* word ops are a bit trickier. */
|
||||||
u_int8_t *data, savebyte[2];
|
uint8_t *data, savebyte[2];
|
||||||
int l, leftover;
|
int l, leftover;
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
u_int8_t *lim;
|
uint8_t *lim;
|
||||||
#endif
|
#endif
|
||||||
/* Start out with no leftover data. */
|
/* Start out with no leftover data. */
|
||||||
leftover = 0;
|
leftover = 0;
|
||||||
savebyte[0] = savebyte[1] = 0;
|
savebyte[0] = savebyte[1] = 0;
|
||||||
|
|
||||||
for (; m != 0; m = m->m_next) {
|
for (; m != NULL; m = m->m_next) {
|
||||||
l = m->m_len;
|
l = m->m_len;
|
||||||
if (l == 0)
|
if (l == 0)
|
||||||
continue;
|
continue;
|
||||||
data = mtod(m, u_int8_t *);
|
data = mtod(m, uint8_t *);
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
lim = data + l;
|
lim = data + l;
|
||||||
#endif
|
#endif
|
||||||
@ -637,10 +639,10 @@ ne2000_write_mbuf(struct dp8390_softc *sc, struct mbuf *m, int buf)
|
|||||||
l--;
|
l--;
|
||||||
bus_space_write_stream_2(asict, asich,
|
bus_space_write_stream_2(asict, asich,
|
||||||
NE2000_ASIC_DATA,
|
NE2000_ASIC_DATA,
|
||||||
*(u_int16_t *)savebyte);
|
*(uint16_t *)savebyte);
|
||||||
leftover = 0;
|
leftover = 0;
|
||||||
} else if (BUS_SPACE_ALIGNED_POINTER(data,
|
} else if (BUS_SPACE_ALIGNED_POINTER(data,
|
||||||
u_int16_t) == 0) {
|
uint16_t) == 0) {
|
||||||
/*
|
/*
|
||||||
* Unaligned data; buffer the next
|
* Unaligned data; buffer the next
|
||||||
* byte.
|
* byte.
|
||||||
@ -658,7 +660,7 @@ ne2000_write_mbuf(struct dp8390_softc *sc, struct mbuf *m, int buf)
|
|||||||
l &= ~1;
|
l &= ~1;
|
||||||
bus_space_write_multi_stream_2(asict,
|
bus_space_write_multi_stream_2(asict,
|
||||||
asich, NE2000_ASIC_DATA,
|
asich, NE2000_ASIC_DATA,
|
||||||
(u_int16_t *)data, l >> 1);
|
(uint16_t *)data, l >> 1);
|
||||||
data += l;
|
data += l;
|
||||||
if (leftover)
|
if (leftover)
|
||||||
savebyte[0] = *data++;
|
savebyte[0] = *data++;
|
||||||
@ -675,7 +677,7 @@ ne2000_write_mbuf(struct dp8390_softc *sc, struct mbuf *m, int buf)
|
|||||||
if (leftover) {
|
if (leftover) {
|
||||||
savebyte[1] = 0;
|
savebyte[1] = 0;
|
||||||
bus_space_write_stream_2(asict, asich, NE2000_ASIC_DATA,
|
bus_space_write_stream_2(asict, asich, NE2000_ASIC_DATA,
|
||||||
*(u_int16_t *)savebyte);
|
*(uint16_t *)savebyte);
|
||||||
}
|
}
|
||||||
if (padlen) {
|
if (padlen) {
|
||||||
for(; padlen > 1; padlen -= 2)
|
for(; padlen > 1; padlen -= 2)
|
||||||
@ -687,7 +689,7 @@ ne2000_write_mbuf(struct dp8390_softc *sc, struct mbuf *m, int buf)
|
|||||||
|
|
||||||
/* AX88796 doesn't seem to have remote DMA complete */
|
/* AX88796 doesn't seem to have remote DMA complete */
|
||||||
if (sc->sc_flags & DP8390_NO_REMOTE_DMA_COMPLETE)
|
if (sc->sc_flags & DP8390_NO_REMOTE_DMA_COMPLETE)
|
||||||
return(savelen);
|
return savelen;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for remote DMA to complete. This is necessary because on the
|
* Wait for remote DMA to complete. This is necessary because on the
|
||||||
@ -711,7 +713,7 @@ ne2000_write_mbuf(struct dp8390_softc *sc, struct mbuf *m, int buf)
|
|||||||
dp8390_reset(sc);
|
dp8390_reset(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (savelen);
|
return savelen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -737,17 +739,17 @@ ne2000_ring_copy(struct dp8390_softc *sc, int src, void *dstv, u_short amount)
|
|||||||
|
|
||||||
/* Copy amount up to end of NIC memory. */
|
/* Copy amount up to end of NIC memory. */
|
||||||
ne2000_readmem(nict, nich, asict, asich, src,
|
ne2000_readmem(nict, nich, asict, asich, src,
|
||||||
(u_int8_t *)dst, tmp_amount, useword);
|
(uint8_t *)dst, tmp_amount, useword);
|
||||||
|
|
||||||
amount -= tmp_amount;
|
amount -= tmp_amount;
|
||||||
src = sc->mem_ring;
|
src = sc->mem_ring;
|
||||||
dst += tmp_amount;
|
dst += tmp_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
ne2000_readmem(nict, nich, asict, asich, src, (u_int8_t *)dst,
|
ne2000_readmem(nict, nich, asict, asich, src, (uint8_t *)dst,
|
||||||
amount, useword);
|
amount, useword);
|
||||||
|
|
||||||
return (src + amount);
|
return src + amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -756,7 +758,7 @@ ne2000_read_hdr(struct dp8390_softc *sc, int buf, struct dp8390_ring *hdr)
|
|||||||
struct ne2000_softc *nsc = (struct ne2000_softc *)sc;
|
struct ne2000_softc *nsc = (struct ne2000_softc *)sc;
|
||||||
|
|
||||||
ne2000_readmem(sc->sc_regt, sc->sc_regh, nsc->sc_asict, nsc->sc_asich,
|
ne2000_readmem(sc->sc_regt, sc->sc_regh, nsc->sc_asict, nsc->sc_asich,
|
||||||
buf, (u_int8_t *)hdr, sizeof(struct dp8390_ring),
|
buf, (uint8_t *)hdr, sizeof(struct dp8390_ring),
|
||||||
nsc->sc_useword);
|
nsc->sc_useword);
|
||||||
#if BYTE_ORDER == BIG_ENDIAN
|
#if BYTE_ORDER == BIG_ENDIAN
|
||||||
hdr->count = bswap16(hdr->count);
|
hdr->count = bswap16(hdr->count);
|
||||||
@ -768,7 +770,7 @@ ne2000_test_mem(struct dp8390_softc *sc)
|
|||||||
{
|
{
|
||||||
|
|
||||||
/* Noop. */
|
/* Noop. */
|
||||||
return (0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -777,7 +779,9 @@ ne2000_test_mem(struct dp8390_softc *sc)
|
|||||||
* rounded up to a word - ok as long as mbufs are word sized.
|
* rounded up to a word - ok as long as mbufs are word sized.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ne2000_readmem(bus_space_tag_t nict, bus_space_handle_t nich, bus_space_tag_t asict, bus_space_handle_t asich, int src, u_int8_t *dst, size_t amount, int useword)
|
ne2000_readmem(bus_space_tag_t nict, bus_space_handle_t nich,
|
||||||
|
bus_space_tag_t asict, bus_space_handle_t asich,
|
||||||
|
int src, uint8_t *dst, size_t amount, int useword)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Select page 0 registers. */
|
/* Select page 0 registers. */
|
||||||
@ -804,7 +808,7 @@ ne2000_readmem(bus_space_tag_t nict, bus_space_handle_t nich, bus_space_tag_t as
|
|||||||
ASIC_BARRIER(asict, asich);
|
ASIC_BARRIER(asict, asich);
|
||||||
if (useword)
|
if (useword)
|
||||||
bus_space_read_multi_stream_2(asict, asich, NE2000_ASIC_DATA,
|
bus_space_read_multi_stream_2(asict, asich, NE2000_ASIC_DATA,
|
||||||
(u_int16_t *)dst, amount >> 1);
|
(uint16_t *)dst, amount >> 1);
|
||||||
else
|
else
|
||||||
bus_space_read_multi_1(asict, asich, NE2000_ASIC_DATA,
|
bus_space_read_multi_1(asict, asich, NE2000_ASIC_DATA,
|
||||||
dst, amount);
|
dst, amount);
|
||||||
@ -815,7 +819,9 @@ ne2000_readmem(bus_space_tag_t nict, bus_space_handle_t nich, bus_space_tag_t as
|
|||||||
* used in the probe routine to test the memory. 'len' must be even.
|
* used in the probe routine to test the memory. 'len' must be even.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ne2000_writemem(bus_space_tag_t nict, bus_space_handle_t nich, bus_space_tag_t asict, bus_space_handle_t asich, u_int8_t *src, int dst, size_t len, int useword, int quiet)
|
ne2000_writemem(bus_space_tag_t nict, bus_space_handle_t nich,
|
||||||
|
bus_space_tag_t asict, bus_space_handle_t asich,
|
||||||
|
uint8_t *src, int dst, size_t len, int useword, int quiet)
|
||||||
{
|
{
|
||||||
int maxwait = 100; /* about 120us */
|
int maxwait = 100; /* about 120us */
|
||||||
|
|
||||||
@ -846,7 +852,7 @@ ne2000_writemem(bus_space_tag_t nict, bus_space_handle_t nich, bus_space_tag_t a
|
|||||||
ASIC_BARRIER(asict, asich);
|
ASIC_BARRIER(asict, asich);
|
||||||
if (useword)
|
if (useword)
|
||||||
bus_space_write_multi_stream_2(asict, asich, NE2000_ASIC_DATA,
|
bus_space_write_multi_stream_2(asict, asich, NE2000_ASIC_DATA,
|
||||||
(u_int16_t *)src, len >> 1);
|
(uint16_t *)src, len >> 1);
|
||||||
else
|
else
|
||||||
bus_space_write_multi_1(asict, asich, NE2000_ASIC_DATA,
|
bus_space_write_multi_1(asict, asich, NE2000_ASIC_DATA,
|
||||||
src, len);
|
src, len);
|
||||||
@ -871,7 +877,7 @@ int
|
|||||||
ne2000_detach(struct ne2000_softc *sc, int flags)
|
ne2000_detach(struct ne2000_softc *sc, int flags)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (dp8390_detach(&sc->sc_dp8390, flags));
|
return dp8390_detach(&sc->sc_dp8390, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IPKDB_NE
|
#ifdef IPKDB_NE
|
||||||
|
Loading…
Reference in New Issue
Block a user