summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormycroft <mycroft@NetBSD.org>1995-04-11 04:38:42 +0000
committermycroft <mycroft@NetBSD.org>1995-04-11 04:38:42 +0000
commitb703c76655daa7104657af63c0abe032353f71da (patch)
tree56eff771a54174a090df1be17b640c2cb9d09625 /sys/dev
parent8b77f9cd5f2bab209a769ce73feed5c7f5d85334 (diff)
Update for if.h. Define helper macros for accessing NIC registers. Optimize
edrint() a little more.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/isa/if_ed.c251
1 files changed, 122 insertions, 129 deletions
diff --git a/sys/dev/isa/if_ed.c b/sys/dev/isa/if_ed.c
index 31b970c3346..f7426a2044d 100644
--- a/sys/dev/isa/if_ed.c
+++ b/sys/dev/isa/if_ed.c
@@ -1,10 +1,10 @@
-/* $NetBSD: if_ed.c,v 1.70 1995/04/10 18:21:42 mycroft Exp $ */
+/* $NetBSD: if_ed.c,v 1.71 1995/04/11 04:38:42 mycroft Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
* adapters.
*
- * Copyright (c) 1994 Charles Hannum.
+ * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
*
* Copyright (C) 1993, David Greenman. This software may be used, modified,
* copied, distributed, and sold, in both source and binary form provided that
@@ -84,7 +84,7 @@ struct ed_softc {
* the value back from the card all the time.
*/
u_char wd_msr_proto;
- u_char cr_proto; /* ED_CR_RD2 if not 790; 0 if 790 */
+ u_char cr_proto; /* values always set in CR */
u_char isa16bit; /* width of access to card 0=8 or 1=16 */
u_char is790; /* set by probe if NIC is a 790 */
@@ -123,7 +123,7 @@ void ed_getmcaf __P((struct arpcom *, u_long *));
void ed_get_packet __P((/* struct ed_softc *, caddr_t, u_short */));
static inline void ed_rint __P((struct ed_softc *));
static inline void ed_xmit __P((struct ed_softc *));
-static inline caddr_t ed_ring_copy __P((/* struct ed_Softc *, caddr_t, caddr_t,
+static inline caddr_t ed_ring_copy __P((/* struct ed_softc *, caddr_t, caddr_t,
u_short */));
void ed_pio_readmem __P((/* struct ed_softc *, u_short, caddr_t, u_short */));
@@ -138,6 +138,9 @@ struct cfdriver edcd = {
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
+#define NIC_PUT(sc, off, val) outb(sc->nic_addr + off, val)
+#define NIC_GET(sc, off) inb(sc->nic_addr + off)
+
/*
* Determine if the device is present.
*/
@@ -178,23 +181,23 @@ edprobe(parent, match, aux)
* others would require changing register pages (which would be intrusive if
* this isn't an 8390).
*
- * Return 1 if 8390 was found, 0 if not.
+ * Return 1 if 8390 was found, 0 if not.
*/
int
ed_probe_generic8390(sc)
struct ed_softc *sc;
{
- if ((inb(sc->nic_addr + ED_P0_CR) &
+ if ((NIC_GET(sc, ED_P0_CR) &
(ED_CR_RD2 | ED_CR_TXP | ED_CR_STA | ED_CR_STP)) !=
(ED_CR_RD2 | ED_CR_STP))
return (0);
- if ((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RST) != ED_ISR_RST)
+ if ((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RST) != ED_ISR_RST)
return (0);
return (1);
}
-
+
int ed_wd584_irq[] = { 9, 3, 5, 7, 10, 11, 15, 4 };
int ed_wd790_irq[] = { IRQUNK, 9, 3, 5, 7, 10, 11, 15 };
@@ -531,7 +534,7 @@ ed_probe_WD80x3(sc, cf, ia)
(void) inb(0x84);
return (0);
}
-
+
/*
* Disable 16bit access to shared memory - we leave it disabled
* so that 1) machines reboot properly when the board is set 16
@@ -624,7 +627,7 @@ ed_probe_3Com(sc, cf, ia)
} else
ia->ia_irq = ed_3com_irq[ptr];
#endif
-
+
/*
* Reset NIC and ASIC. Enable on-board transceiver throughout reset
* sequence because it'll lock up if the cable isn't connected if we
@@ -665,7 +668,7 @@ ed_probe_3Com(sc, cf, ia)
outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_EALO | ED_3COM_CR_XSEL);
for (i = 0; i < ETHER_ADDR_LEN; ++i)
- sc->sc_arpcom.ac_enaddr[i] = inb(sc->nic_addr + i);
+ sc->sc_arpcom.ac_enaddr[i] = NIC_GET(sc, i);
/*
* Unmap PROM - select NIC registers. The proper setting of the
@@ -677,25 +680,25 @@ ed_probe_3Com(sc, cf, ia)
/* Determine if this is an 8bit or 16bit board. */
/* Select page 0 registers. */
- outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
/*
* Attempt to clear WTS bit. If it doesn't clear, then this is a
* 16-bit board.
*/
- outb(sc->nic_addr + ED_P0_DCR, 0);
+ NIC_PUT(sc, ED_P0_DCR, 0);
/* Select page 2 registers. */
- outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_2 | ED_CR_STP);
+ NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_2 | ED_CR_STP);
/* The 3c503 forces the WTS bit to a one if this is a 16bit board. */
- if (inb(sc->nic_addr + ED_P2_DCR) & ED_DCR_WTS)
+ if (NIC_GET(sc, ED_P2_DCR) & ED_DCR_WTS)
isa16bit = 1;
else
isa16bit = 0;
/* Select page 0 registers. */
- outb(sc->nic_addr + ED_P2_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(sc, ED_P2_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
sc->mem_start = ISA_HOLE_VADDR(ia->ia_maddr);
sc->mem_size = memsize;
@@ -836,7 +839,7 @@ ed_probe_Novell(sc, cf, ia)
* XXX - this makes the probe invasive! ...Done against my better
* judgement. -DLG
*/
- outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
delay(5000);
@@ -858,13 +861,13 @@ ed_probe_Novell(sc, cf, ia)
* This prevents packets from being stored in the NIC memory when the
* readmem routine turns on the start bit in the CR.
*/
- outb(sc->nic_addr + ED_P0_RCR, ED_RCR_MON);
+ NIC_PUT(sc, ED_P0_RCR, ED_RCR_MON);
/* Temporarily initialize DCR for byte operations. */
- outb(sc->nic_addr + ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
+ NIC_PUT(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
- outb(sc->nic_addr + ED_P0_PSTART, 8192 >> ED_PAGE_SHIFT);
- outb(sc->nic_addr + ED_P0_PSTOP, 16384 >> ED_PAGE_SHIFT);
+ NIC_PUT(sc, ED_P0_PSTART, 8192 >> ED_PAGE_SHIFT);
+ NIC_PUT(sc, ED_P0_PSTOP, 16384 >> ED_PAGE_SHIFT);
sc->isa16bit = 0;
@@ -879,10 +882,10 @@ ed_probe_Novell(sc, cf, ia)
if (bcmp(test_pattern, test_buffer, sizeof(test_pattern))) {
/* not an NE1000 - try NE2000 */
- outb(sc->nic_addr + ED_P0_DCR,
+ NIC_PUT(sc, ED_P0_DCR,
ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
- outb(sc->nic_addr + ED_P0_PSTART, 16384 >> ED_PAGE_SHIFT);
- outb(sc->nic_addr + ED_P0_PSTOP, 32768 >> ED_PAGE_SHIFT);
+ NIC_PUT(sc, ED_P0_PSTART, 16384 >> ED_PAGE_SHIFT);
+ NIC_PUT(sc, ED_P0_PSTOP, 32768 >> ED_PAGE_SHIFT);
sc->isa16bit = 1;
@@ -902,7 +905,7 @@ ed_probe_Novell(sc, cf, ia)
sc->type = ED_TYPE_NE1000;
sc->type_str = "NE1000";
}
-
+
if (ia->ia_irq == IRQUNK) {
printf("%s: %s does not have soft configuration\n",
sc->sc_dev.dv_xname, sc->type_str);
@@ -1007,12 +1010,12 @@ ed_probe_Novell(sc, cf, ia)
#endif /* GWETHER */
/* Clear any pending interrupts that might have occurred above. */
- outb(sc->nic_addr + ED_P0_ISR, 0xff);
+ NIC_PUT(sc, ED_P0_ISR, 0xff);
ia->ia_iosize = ED_NOVELL_IO_PORTS;
return (1);
}
-
+
/*
* Install interface into kernel networking data structures.
*/
@@ -1025,14 +1028,13 @@ edattach(parent, self, aux)
struct isa_attach_args *ia = aux;
struct cfdata *cf = sc->sc_dev.dv_cfdata;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
-
+
/* Set interface to stopped condition (reset). */
ed_stop(sc);
/* Initialize ifnet structure. */
ifp->if_unit = sc->sc_dev.dv_unit;
ifp->if_name = edcd.cd_name;
- ifp->if_output = ether_output;
ifp->if_start = ed_start;
ifp->if_ioctl = ed_ioctl;
ifp->if_watchdog = ed_watchdog;
@@ -1093,7 +1095,7 @@ edattach(parent, self, aux)
sc->sc_ih.ih_level = IPL_NET;
intr_establish(ia->ia_irq, IST_EDGE, &sc->sc_ih);
}
-
+
/*
* Reset interface.
*/
@@ -1108,7 +1110,7 @@ ed_reset(sc)
ed_init(sc);
splx(s);
}
-
+
/*
* Take interface offline.
*/
@@ -1117,16 +1119,16 @@ ed_stop(sc)
struct ed_softc *sc;
{
int n = 5000;
-
+
/* Stop everything on the interface, and select page 0 registers. */
- outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
/*
* Wait for interface to enter stopped state, but limit # of checks to
* 'n' (about 5ms). It shouldn't even take 5us on modern DS8390's, but
* just in case it's an old one.
*/
- while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RST) == 0) && --n);
+ while (((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RST) == 0) && --n);
}
/*
@@ -1146,7 +1148,7 @@ ed_watchdog(unit)
}
/*
- * Initialize device.
+ * Initialize device.
*/
void
ed_init(sc)
@@ -1177,44 +1179,43 @@ ed_init(sc)
sc->txb_next_tx = 0;
/* Set interface for page 0, remote DMA complete, stopped. */
- outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
if (sc->isa16bit) {
/*
* Set FIFO threshold to 8, No auto-init Remote DMA, byte
* order=80x86, word-wide DMA xfers,
*/
- outb(sc->nic_addr + ED_P0_DCR,
- ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
+ NIC_PUT(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
} else {
/* Same as above, but byte-wide DMA xfers. */
- outb(sc->nic_addr + ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
+ NIC_PUT(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
}
/* Clear remote byte count registers. */
- outb(sc->nic_addr + ED_P0_RBCR0, 0);
- outb(sc->nic_addr + ED_P0_RBCR1, 0);
+ NIC_PUT(sc, ED_P0_RBCR0, 0);
+ NIC_PUT(sc, ED_P0_RBCR1, 0);
/* Tell RCR to do nothing for now. */
- outb(sc->nic_addr + ED_P0_RCR, ED_RCR_MON);
+ NIC_PUT(sc, ED_P0_RCR, ED_RCR_MON);
/* Place NIC in internal loopback mode. */
- outb(sc->nic_addr + ED_P0_TCR, ED_TCR_LB0);
+ NIC_PUT(sc, ED_P0_TCR, ED_TCR_LB0);
/* Set lower bits of byte addressable framing to 0. */
if (sc->is790)
- outb(sc->nic_addr + 0x09, 0);
+ NIC_PUT(sc, 0x09, 0);
/* Initialize receive buffer ring. */
- outb(sc->nic_addr + ED_P0_BNRY, sc->rec_page_start);
- outb(sc->nic_addr + ED_P0_PSTART, sc->rec_page_start);
- outb(sc->nic_addr + ED_P0_PSTOP, sc->rec_page_stop);
+ NIC_PUT(sc, ED_P0_BNRY, sc->rec_page_start);
+ NIC_PUT(sc, ED_P0_PSTART, sc->rec_page_start);
+ NIC_PUT(sc, ED_P0_PSTOP, sc->rec_page_stop);
/*
* Clear all interrupts. A '1' in each bit position clears the
* corresponding flag.
*/
- outb(sc->nic_addr + ED_P0_ISR, 0xff);
+ NIC_PUT(sc, ED_P0_ISR, 0xff);
/*
* Enable the following interrupts: receive/transmit complete,
@@ -1222,31 +1223,31 @@ ed_init(sc)
*
* Counter overflow and Remote DMA complete are *not* enabled.
*/
- outb(sc->nic_addr + ED_P0_IMR,
+ NIC_PUT(sc, ED_P0_IMR,
ED_IMR_PRXE | ED_IMR_PTXE | ED_IMR_RXEE | ED_IMR_TXEE |
ED_IMR_OVWE);
/* Program command register for page 1. */
- outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STP);
+ NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STP);
/* Copy out our station address. */
for (i = 0; i < ETHER_ADDR_LEN; ++i)
- outb(sc->nic_addr + ED_P1_PAR0 + i, sc->sc_arpcom.ac_enaddr[i]);
+ NIC_PUT(sc, ED_P1_PAR0 + i, sc->sc_arpcom.ac_enaddr[i]);
/* Set multicast filter on chip. */
ed_getmcaf(&sc->sc_arpcom, mcaf);
for (i = 0; i < 8; i++)
- outb(sc->nic_addr + ED_P1_MAR0 + i, ((u_char *)mcaf)[i]);
+ NIC_PUT(sc, ED_P1_MAR0 + i, ((u_char *)mcaf)[i]);
/*
* Set current page pointer to one page after the boundary pointer, as
* recommended in the National manual.
*/
sc->next_packet = sc->rec_page_start + 1;
- outb(sc->nic_addr + ED_P1_CURR, sc->next_packet);
+ NIC_PUT(sc, ED_P1_CURR, sc->next_packet);
/* Program command register for page 0. */
- outb(sc->nic_addr + ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
+ NIC_PUT(sc, ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
i = ED_RCR_AB | ED_RCR_AM;
if (ifp->if_flags & IFF_PROMISC) {
@@ -1256,10 +1257,10 @@ ed_init(sc)
*/
i |= ED_RCR_PRO | ED_RCR_AR | ED_RCR_SEP;
}
- outb(sc->nic_addr + ED_P0_RCR, i);
+ NIC_PUT(sc, ED_P0_RCR, i);
/* Take interface out of loopback. */
- outb(sc->nic_addr + ED_P0_TCR, 0);
+ NIC_PUT(sc, ED_P0_TCR, 0);
/*
* If this is a 3Com board, the tranceiver must be software enabled
@@ -1286,7 +1287,7 @@ ed_init(sc)
}
/* Fire up the interface. */
- outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
/* Set 'running' flag, and clear output active flag. */
ifp->if_flags |= IFF_RUNNING;
@@ -1295,9 +1296,9 @@ ed_init(sc)
/* ...and attempt to start output. */
ed_start(ifp);
- (void) splx(s);
+ splx(s);
}
-
+
/*
* This routine actually starts the transmission on the interface.
*/
@@ -1311,20 +1312,20 @@ ed_xmit(sc)
len = sc->txb_len[sc->txb_next_tx];
/* Set NIC for page 0 register access. */
- outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
/* Set TX buffer start page. */
- outb(sc->nic_addr + ED_P0_TPSR, sc->tx_page_start +
+ NIC_PUT(sc, ED_P0_TPSR, sc->tx_page_start +
sc->txb_next_tx * ED_TXBUF_SIZE);
/* Set TX length. */
- outb(sc->nic_addr + ED_P0_TBCR0, len);
- outb(sc->nic_addr + ED_P0_TBCR1, len >> 8);
+ NIC_PUT(sc, ED_P0_TBCR0, len);
+ NIC_PUT(sc, ED_P0_TBCR1, len >> 8);
/* Set page 0, remote DMA complete, transmit packet, and *start*. */
- outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_TXP | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_TXP | ED_CR_STA);
sc->xmit_busy = 1;
-
+
/* Point to next transmit buffer slot and wrap if necessary. */
sc->txb_next_tx++;
if (sc->txb_next_tx == sc->txb_cnt)
@@ -1442,7 +1443,7 @@ outloop:
}
} else
len = ed_pio_write_mbufs(sc, m, (u_short)buffer);
-
+
sc->txb_len[sc->txb_new] = max(len, ETHER_MIN_LEN);
sc->txb_inuse++;
@@ -1464,7 +1465,7 @@ outloop:
/* Loop back to the top to possibly buffer more packets. */
goto outloop;
}
-
+
/*
* Ethernet interface receiver interrupt.
*/
@@ -1480,7 +1481,7 @@ ed_rint(sc)
loop:
/* Set NIC to page 1 registers to get 'current' pointer. */
- outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STA);
/*
* 'sc->next_packet' is the logical beginning of the ring-buffer - i.e.
@@ -1490,10 +1491,13 @@ loop:
* until the logical beginning equals the logical end (or in other
* words, until the ring-buffer is empty).
*/
- current = inb(sc->nic_addr + ED_P1_CURR);
+ current = NIC_GET(sc, ED_P1_CURR);
if (sc->next_packet == current)
return;
+ /* Set NIC to page 0 registers to update boundary register. */
+ NIC_PUT(sc, ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
+
do {
/* Get pointer to this buffer's header structure. */
packet_ptr = sc->mem_ring +
@@ -1573,10 +1577,7 @@ loop:
boundary = sc->next_packet - 1;
if (boundary < sc->rec_page_start)
boundary = sc->rec_page_stop - 1;
-
- /* Set NIC to page 0 registers to update boundary register. */
- outb(sc->nic_addr + ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
- outb(sc->nic_addr + ED_P0_BNRY, boundary);
+ NIC_PUT(sc, ED_P0_BNRY, boundary);
} while (sc->next_packet != current);
goto loop;
@@ -1590,9 +1591,9 @@ edintr(sc)
u_char isr;
/* Set NIC to page 0 registers. */
- outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
- isr = inb(sc->nic_addr + ED_P0_ISR);
+ isr = NIC_GET(sc, ED_P0_ISR);
if (!isr)
return (0);
@@ -1603,15 +1604,14 @@ edintr(sc)
* '1' to each bit position that was set.
* (Writing a '1' *clears* the bit.)
*/
- outb(sc->nic_addr + ED_P0_ISR, isr);
+ NIC_PUT(sc, ED_P0_ISR, isr);
/*
* Handle transmitter interrupts. Handle these first because
* the receiver will reset the board under some conditions.
*/
if (isr & (ED_ISR_PTX | ED_ISR_TXE)) {
- u_char collisions =
- inb(sc->nic_addr + ED_P0_NCR) & 0x0f;
+ u_char collisions = NIC_GET(sc, ED_P0_NCR) & 0x0f;
/*
* Check for transmit error. If a TX completed with an
@@ -1622,12 +1622,12 @@ edintr(sc)
* course, with UDP we're screwed, but this is expected
* when a network is heavily loaded.
*/
- (void) inb(sc->nic_addr + ED_P0_TSR);
+ (void) NIC_GET(sc, ED_P0_TSR);
if (isr & ED_ISR_TXE) {
/*
* Excessive collisions (16).
*/
- if ((inb(sc->nic_addr + ED_P0_TSR) & ED_TSR_ABT)
+ if ((NIC_GET(sc, ED_P0_TSR) & ED_TSR_ABT)
&& (collisions == 0)) {
/*
* When collisions total 16, the P0_NCR
@@ -1702,7 +1702,7 @@ edintr(sc)
#ifdef ED_DEBUG
printf("%s: receive error %x\n",
sc->sc_dev.dv_xname,
- inb(sc->nic_addr + ED_P0_RSR));
+ NIC_GET(sc, ED_P0_RSR));
#endif
}
@@ -1757,7 +1757,7 @@ edintr(sc)
* set in the transmit routine, is *okay* - it is 'edge'
* triggered from low to high).
*/
- outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
/*
* If the Network Talley Counters overflow, read them to reset
@@ -1765,17 +1765,17 @@ edintr(sc)
* otherwise - resulting in an infinite loop.
*/
if (isr & ED_ISR_CNT) {
- (void) inb(sc->nic_addr + ED_P0_CNTR0);
- (void) inb(sc->nic_addr + ED_P0_CNTR1);
- (void) inb(sc->nic_addr + ED_P0_CNTR2);
+ (void) NIC_GET(sc, ED_P0_CNTR0);
+ (void) NIC_GET(sc, ED_P0_CNTR1);
+ (void) NIC_GET(sc, ED_P0_CNTR2);
}
- isr = inb(sc->nic_addr + ED_P0_ISR);
+ isr = NIC_GET(sc, ED_P0_ISR);
if (!isr)
return (1);
}
}
-
+
/*
* Process an ioctl request. This code needs some work - it looks pretty ugly.
*/
@@ -1800,15 +1800,8 @@ ed_ioctl(ifp, command, data)
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
case AF_INET:
- ed_init(sc); /* before arpwhohas */
- /*
- * See if another station has *our* IP address.
- * i.e.: There is an address conflict! If a
- * conflict exists, a message is sent to the
- * console.
- */
- sc->sc_arpcom.ac_ipaddr = IA_SIN(ifa)->sin_addr;
- arpwhohas(&sc->sc_arpcom, &IA_SIN(ifa)->sin_addr);
+ ed_init(sc);
+ arp_ifinit(&sc->sc_arpcom, ifa);
break;
#endif
#ifdef NS
@@ -1878,13 +1871,15 @@ ed_ioctl(ifp, command, data)
error = 0;
}
break;
+
default:
error = EINVAL;
}
- (void) splx(s);
+
+ splx(s);
return (error);
}
-
+
/*
* Retreive packet from shared memory and send to the next level up via
* ether_input(). If there is a BPF listener, give a copy to BPF, too.
@@ -1935,7 +1930,7 @@ ed_get_packet(sc, buf, len)
#if NBPFILTER > 0
/*
* Check if there's a BPF listener on this interface. If so, hand off
- * the raw packet to bpf.
+ * the raw packet to bpf.
*/
if (sc->sc_arpcom.ac_if.if_bpf) {
bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m);
@@ -1978,21 +1973,21 @@ ed_pio_readmem(sc, src, dst, amount)
u_short amount;
{
/* Select page 0 registers. */
- outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
/* Round up to a word. */
if (amount & 1)
++amount;
/* Set up DMA byte count. */
- outb(sc->nic_addr + ED_P0_RBCR0, amount);
- outb(sc->nic_addr + ED_P0_RBCR1, amount >> 8);
+ NIC_PUT(sc, ED_P0_RBCR0, amount);
+ NIC_PUT(sc, ED_P0_RBCR1, amount >> 8);
/* Set up source address in NIC mem. */
- outb(sc->nic_addr + ED_P0_RSAR0, src);
- outb(sc->nic_addr + ED_P0_RSAR1, src >> 8);
+ NIC_PUT(sc, ED_P0_RSAR0, src);
+ NIC_PUT(sc, ED_P0_RSAR1, src >> 8);
- outb(sc->nic_addr + ED_P0_CR, ED_CR_RD0 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, ED_CR_RD0 | ED_CR_PAGE_0 | ED_CR_STA);
if (sc->isa16bit)
insw(sc->asic_addr + ED_NOVELL_DATA, dst, amount / 2);
@@ -2014,21 +2009,21 @@ ed_pio_writemem(sc, src, dst, len)
int maxwait = 100; /* about 120us */
/* Select page 0 registers. */
- outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
/* Reset remote DMA complete flag. */
- outb(sc->nic_addr + ED_P0_ISR, ED_ISR_RDC);
+ NIC_PUT(sc, ED_P0_ISR, ED_ISR_RDC);
/* Set up DMA byte count. */
- outb(sc->nic_addr + ED_P0_RBCR0, len);
- outb(sc->nic_addr + ED_P0_RBCR1, len >> 8);
+ NIC_PUT(sc, ED_P0_RBCR0, len);
+ NIC_PUT(sc, ED_P0_RBCR1, len >> 8);
/* Set up destination address in NIC mem. */
- outb(sc->nic_addr + ED_P0_RSAR0, dst);
- outb(sc->nic_addr + ED_P0_RSAR1, dst >> 8);
+ NIC_PUT(sc, ED_P0_RSAR0, dst);
+ NIC_PUT(sc, ED_P0_RSAR1, dst >> 8);
/* Set remote DMA write. */
- outb(sc->nic_addr + ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
if (sc->isa16bit)
outsw(sc->asic_addr + ED_NOVELL_DATA, src, len / 2);
@@ -2042,7 +2037,7 @@ ed_pio_writemem(sc, src, dst, len)
* waiting causes really bad things to happen - like the NIC
* irrecoverably jamming the ISA bus.
*/
- while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
+ while (((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
}
/*
@@ -2062,23 +2057,23 @@ ed_pio_write_mbufs(sc, m, dst)
/* First, count up the total number of bytes to copy. */
for (len = 0, mp = m; mp; mp = mp->m_next)
len += mp->m_len;
-
+
/* Select page 0 registers. */
- outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
/* Reset remote DMA complete flag. */
- outb(sc->nic_addr + ED_P0_ISR, ED_ISR_RDC);
+ NIC_PUT(sc, ED_P0_ISR, ED_ISR_RDC);
/* Set up DMA byte count. */
- outb(sc->nic_addr + ED_P0_RBCR0, len);
- outb(sc->nic_addr + ED_P0_RBCR1, len >> 8);
+ NIC_PUT(sc, ED_P0_RBCR0, len);
+ NIC_PUT(sc, ED_P0_RBCR1, len >> 8);
/* Set up destination address in NIC mem. */
- outb(sc->nic_addr + ED_P0_RSAR0, dst);
- outb(sc->nic_addr + ED_P0_RSAR1, dst >> 8);
+ NIC_PUT(sc, ED_P0_RSAR0, dst);
+ NIC_PUT(sc, ED_P0_RSAR1, dst >> 8);
/* Set remote DMA write. */
- outb(sc->nic_addr + ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
+ NIC_PUT(sc, ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
/*
* Transfer the mbuf chain to the NIC memory.
@@ -2135,7 +2130,7 @@ ed_pio_write_mbufs(sc, m, dst)
*(u_short *)savebyte);
}
}
-
+
/*
* Wait for remote DMA complete. This is necessary because on the
* transmit side, data is handled internally by the NIC in bursts and
@@ -2143,7 +2138,7 @@ ed_pio_write_mbufs(sc, m, dst)
* waiting causes really bad things to happen - like the NIC
* irrecoverably jamming the ISA bus.
*/
- while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
+ while (((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
if (!maxwait) {
log(LOG_WARNING,
@@ -2154,16 +2149,15 @@ ed_pio_write_mbufs(sc, m, dst)
return (len);
}
-
+
/*
* Given a source and destination address, copy 'amount' of a packet from the
* ring buffer into a linear destination buffer. Takes into account ring-wrap.
*/
-static inline char *
+static inline caddr_t
ed_ring_copy(sc, src, dst, amount)
struct ed_softc *sc;
- char *src;
- char *dst;
+ caddr_t src, dst;
u_short amount;
{
u_short tmp_amount;
@@ -2224,7 +2218,7 @@ ed_ring_to_mbuf(sc, src, dst, total_len)
* cluster to. The mbuf that has a cluster extension
* can not be used to contain data - only the cluster
* can contain data.
- */
+ */
dst = m;
MGET(m, M_DONTWAIT, MT_DATA);
if (m == 0)
@@ -2243,7 +2237,6 @@ ed_ring_to_mbuf(sc, src, dst, total_len)
m->m_len += amount;
total_len -= amount;
-
}
return (m);
}