#include <NE2000.h>
Data Structures | |
struct | net_device_stats |
Network device statistics. Akin to the 2.0 ether stats but with byte counters. More... | |
struct | e8390_pkt_hdr |
The per-packet-header format.This header is present on the first 4 bytes on the NIC buffer. More... | |
Some generic ethernet register configurations. | |
#define | E8390_TX_IRQ_MASK 0xa |
#define | E8390_RX_IRQ_MASK 0x5 |
#define | E8390_RXCONFIG 0x4 |
#define | E8390_RXOFF 0x20 |
#define | E8390_TXCONFIG 0x00 |
#define | E8390_TXOFF 0x02 |
Register accessed at EN_CMD, the 8390 base addr. | |
#define | E8390_STOP 0x01 |
#define | E8390_START 0x02 |
#define | E8390_TRANS 0x04 |
#define | E8390_RREAD 0x08 |
#define | E8390_RWRITE 0x10 |
#define | E8390_NODMA 0x20 |
#define | E8390_PAGE0 0x00 |
#define | E8390_PAGE1 0x40 |
#define | E8390_PAGE2 0x80 |
Page 0 register offsets. | |
#define | EN0_CLDALO 0x01 |
#define | EN0_STARTPG 0x01 |
#define | EN0_CLDAHI 0x02 |
#define | EN0_STOPPG 0x02 |
#define | EN0_BOUNDARY 0x03 |
#define | EN0_TSR 0x04 |
#define | EN0_TPSR 0x04 |
#define | EN0_NCR 0x05 |
#define | EN0_TCNTLO 0x05 |
#define | EN0_FIFO 0x06 |
#define | EN0_TCNTHI 0x06 |
#define | EN0_ISR 0x07 |
#define | EN0_CRDALO 0x08 |
#define | EN0_RSARLO 0x08 |
#define | EN0_CRDAHI 0x09 |
#define | EN0_RSARHI 0x09 |
#define | EN0_RCNTLO 0x0a |
#define | EN0_RCNTHI 0x0b |
#define | EN0_RSR 0x0c |
#define | EN0_RXCR 0x0c |
#define | EN0_TXCR 0x0d |
#define | EN0_COUNTER0 0x0d |
#define | EN0_DCFG 0x0e |
#define | EN0_COUNTER1 0x0e |
#define | EN0_IMR 0x0f |
#define | EN0_COUNTER2 0x0f |
Page 1 register offsets | |
#define | EN1_PHYS 0x01 |
#define | EN1_CURPAG 0x07 |
#define | EN1_MULT 0x08 |
Bits in EN0_ISR - Interrupt status register | |
#define | ENISR_RX 0x01 |
#define | ENISR_TX 0x02 |
#define | ENISR_RX_ERR 0x04 |
#define | ENISR_TX_ERR 0x08 |
#define | ENISR_OVER 0x10 |
#define | ENISR_COUNTERS 0x20 |
#define | ENISR_RDC 0x40 |
#define | ENISR_RESET 0x80 |
#define | ENISR_ALL 0x3f |
Bits in EN0_DCFG - Data config register | |
#define | ENDCFG_WTS 0x01 |
Bits in received packet status byte and EN0_RSR | |
#define | ENRSR_RXOK 0x01 |
#define | ENRSR_CRC 0x02 |
#define | ENRSR_FAE 0x04 |
#define | ENRSR_FO 0x08 |
#define | ENRSR_MPA 0x10 |
#define | ENRSR_PHY 0x20 |
#define | ENRSR_DIS 0x40 |
#define | ENRSR_DEF 0x80 |
Transmitted packet status, EN0_TSR. | |
#define | ENTSR_PTX 0x01 |
#define | ENTSR_ND 0x02 |
#define | ENTSR_COL 0x04 |
#define | ENTSR_ABT 0x08 |
#define | ENTSR_CRS 0x10 |
#define | ENTSR_FU 0x20 |
#define | ENTSR_CDH 0x40 |
#define | ENTSR_OWC 0x80 |
Device Driver API | |
void | NICReset (void) |
Reset NIC by software. | |
void | ei_init (void) |
Init Procedure to set-up NE2000 base board. We configure the board to accept broadcast frames, witch can raise ring buffer overflow's if you can't remove the frames from the buffer. | |
void | ei_transmit (unsigned char *buf, unsigned int send_length) |
Transmit frame on the network. | |
unsigned int | ei_poll (void) |
Poll NIC for received frames. It also check if occured ring buffer overflow and updated statistics. | |
Defines | |
#define | ETHER_ADDR_LEN 6 |
#define | ETH_ZLEN 60 |
#define | E8390_CMD 0x00 |
#define | UPDSTATS(_STAT_) |
Functions | |
void | ei_tx_intr (void) |
We have finished a transmit: check for errors and update statistics. | |
void | ei_tx_err (void) |
Handle transmitter error. A transmitter error has happened. Most likely excess collisions (which is a fairly normal condition). | |
unsigned int | ei_receive (void) |
Read from NIC, ONE FRAME received. The frame readed is puted on uip_buf. | |
void | ei_rx_overrun (void) |
Handle receiver overrun, i.e. overwrite the ring buffer because the frames were not readed. We have a receiver overrun: we have to kick the 8390 to get it started again. Problem is that you have to kick it exactly as NS prescribes in the updated datasheets, or "the NIC may act in an unpredictable manner." This includes causing "the NIC to defer indefinitely when it is stopped on a busy network." Ugh. Called with lock held. Don't call this with the interrupts off or your computer will hate you - it takes 10ms or so. | |
void | ei_nic_write (unsigned char *buf, unsigned int count, unsigned int start_page) |
Transfer a packet from the NIC buffer to the PC Ram. This function is based on Donald Becker driver and on AN874 -"Writing Drivers for the DP8390".. | |
void | ei_nic_read (unsigned char *buf, unsigned int count, unsigned int ring_offset) |
Read a packet from the NIC local RAM. This function is based on Donald Becker driver and on AN874 -"Writing Drivers for the DP8390".. | |
unsigned char | ne_probe (void) |
Test if NIC present and dump configuration. | |
void | nic_mem_test (void) |
Test various positions of NIC local memory. This function is very usefull for locating the correct range of NIC ring buffer! | |
unsigned char | loopback_test (void) |
Test NIC on loopback, using only MODE1. | |
unsigned char | pktTransmit (void) |
Loops until the Packet Transmitted bit is set in the Interrupt Status Register or exceds 10 "pool's". |
|
The command register (for all pages) Definition at line 199 of file NE2000.h. Referenced by ei_init(), ei_poll(), ei_receive(), ei_rx_overrun(), and ei_transmit(). |
|
Remote DMA Definition at line 193 of file NE2000.h. Referenced by ei_init(), ei_nic_read(), ei_nic_write(), ei_poll(), ei_receive(), ei_rx_overrun(), and ei_transmit(). |
|
Select page chip registers using the two high-order bits Definition at line 194 of file NE2000.h. Referenced by ei_init(), ei_nic_read(), ei_nic_write(), ei_poll(), ei_receive(), and ei_rx_overrun(). |
|
Definition at line 195 of file NE2000.h. Referenced by ei_init(), and ei_receive(). |
|
Page 3 is invalid. |
|
Remote read Definition at line 191 of file NE2000.h. Referenced by ei_nic_read(), and ei_nic_write(). |
|
Remote write Definition at line 192 of file NE2000.h. Referenced by ei_nic_write(). |
|
|
|
EN0_RXCR: broadcasts, no multicast,errors Definition at line 180 of file NE2000.h. Referenced by ei_init(). |
|
EN0_RXCR: Accept no packets Definition at line 181 of file NE2000.h. Referenced by ei_init(). |
|
Start the chip, clear reset Definition at line 189 of file NE2000.h. Referenced by ei_init(), ei_nic_read(), ei_nic_write(), ei_poll(), ei_rx_overrun(), and ei_transmit(). |
|
Stop and reset the chip Definition at line 188 of file NE2000.h. Referenced by ei_init(), and ei_rx_overrun(). |
|
Transmit a frame Definition at line 190 of file NE2000.h. Referenced by ei_rx_overrun(), and ei_transmit(). |
|
For register EN0_ISR |
|
EN0_TXCR: Normal transmit mode Definition at line 182 of file NE2000.h. Referenced by ei_init(), and ei_rx_overrun(). |
|
EN0_TXCR: Transmitter off Definition at line 183 of file NE2000.h. Referenced by ei_init(), and ei_rx_overrun(). |
|
Boundary page of ring bfr RD WR Definition at line 207 of file NE2000.h. Referenced by ei_init(), ei_poll(), and ei_receive(). |
|
High byte of current local dma addr RD |
|
Low byte of current local dma addr RD |
|
Rcv alignment error counter RD Definition at line 224 of file NE2000.h. Referenced by ei_poll(). |
|
Rcv CRC error counter RD Definition at line 226 of file NE2000.h. Referenced by ei_poll(). |
|
Rcv missed frame error counter RD Definition at line 228 of file NE2000.h. Referenced by ei_poll(). |
|
high byte, current remote dma address RD |
|
low byte of current remote dma address RD |
|
Data configuration reg WR Definition at line 225 of file NE2000.h. Referenced by ei_init(). |
|
FIFO RD |
|
Interrupt mask reg WR Definition at line 227 of file NE2000.h. Referenced by ei_init(). |
|
Interrupt status reg RD WR Definition at line 214 of file NE2000.h. Referenced by ei_init(), ei_nic_write(), ei_poll(), ei_rx_overrun(), ei_transmit(), ei_tx_err(), ei_tx_intr(), and NICReset(). |
|
Number of collision reg RD |
|
Remote byte count reg WR Definition at line 220 of file NE2000.h. Referenced by ei_init(), ei_nic_read(), ei_nic_write(), and ei_rx_overrun(). |
|
Remote byte count reg WR Definition at line 219 of file NE2000.h. Referenced by ei_init(), ei_nic_read(), ei_nic_write(), and ei_rx_overrun(). |
|
Remote start address reg 1 Definition at line 218 of file NE2000.h. Referenced by ei_nic_read(), and ei_nic_write(). |
|
Remote start address reg 0 Definition at line 216 of file NE2000.h. Referenced by ei_nic_read(), and ei_nic_write(). |
|
rx status reg RD |
|
RX configuration reg WR Definition at line 222 of file NE2000.h. Referenced by ei_init(). |
|
Starting page of ring bfr WR Definition at line 204 of file NE2000.h. Referenced by ei_init(). |
|
Ending page +1 of ring bfr WR Definition at line 206 of file NE2000.h. Referenced by ei_init(). |
|
High byte of tx byte count WR Definition at line 213 of file NE2000.h. Referenced by ei_transmit(). |
|
Low byte of tx byte count WR Definition at line 211 of file NE2000.h. Referenced by ei_transmit(). |
|
Transmit starting page WR Definition at line 209 of file NE2000.h. Referenced by ei_init(), and ei_transmit(). |
|
Transmit status reg RD Definition at line 208 of file NE2000.h. Referenced by ei_tx_err(), and ei_tx_intr(). |
|
TX configuration reg WR Definition at line 223 of file NE2000.h. Referenced by ei_init(), and ei_rx_overrun(). |
|
Current memory page RD WR Definition at line 234 of file NE2000.h. Referenced by ei_init(), and ei_receive(). |
|
Multicast filter mask array (8 bytes) RD WR |
|
This board's physical enet addr RD WR Definition at line 233 of file NE2000.h. Referenced by ei_init(). |
|
word transfer mode selection |
|
Interrupts we will enable |
|
Counters need emptying Definition at line 245 of file NE2000.h. Referenced by ei_poll(). |
|
Receiver overwrote the ring Definition at line 244 of file NE2000.h. Referenced by ei_poll(), and ei_rx_overrun(). |
|
remote dma complete Definition at line 246 of file NE2000.h. Referenced by ei_nic_write(), and ei_poll(). |
|
Reset completed Definition at line 247 of file NE2000.h. Referenced by NICReset(). |
|
Receiver, no error Definition at line 240 of file NE2000.h. Referenced by ei_poll(). |
|
Receiver, with error Definition at line 242 of file NE2000.h. Referenced by ei_poll(). |
|
Transmitter, no error Definition at line 241 of file NE2000.h. Referenced by ei_rx_overrun(), ei_transmit(), and ei_tx_intr(). |
|
Transmitter, with error Definition at line 243 of file NE2000.h. Referenced by ei_rx_overrun(), ei_transmit(), and ei_tx_err(). |
|
CRC error |
|
deferring |
|
receiver disable. set in monitor mode |
|
frame alignment error |
|
FIFO overrun |
|
missed pkt |
|
physical/multicase address |
|
Received a good packet |
|
The transmit collided 16 times, and was deferred. Definition at line 273 of file NE2000.h. Referenced by ei_tx_err(), and ei_tx_intr(). |
|
The collision detect "heartbeat" signal was lost. Definition at line 276 of file NE2000.h. Referenced by ei_tx_err(), and ei_tx_intr(). |
|
The transmit collided at least once. Definition at line 272 of file NE2000.h. Referenced by ei_tx_intr(). |
|
The carrier sense was lost. Definition at line 274 of file NE2000.h. Referenced by ei_tx_err(), and ei_tx_intr(). |
|
A "FIFO underrun" occured during transmit. Definition at line 275 of file NE2000.h. Referenced by ei_tx_err(), and ei_tx_intr(). |
|
The transmit wasn't deferred. Definition at line 271 of file NE2000.h. Referenced by ei_tx_err(). |
|
There was an out-of-window collision. Definition at line 277 of file NE2000.h. Referenced by ei_tx_err(), and ei_tx_intr(). |
|
Packet transmitted without error Definition at line 270 of file NE2000.h. Referenced by ei_tx_intr(). |
|
Min. octets in frame sans FCS Definition at line 174 of file NE2000.h. Referenced by ei_transmit(). |
|
Length of Ethernet Address |
|
Definition at line 404 of file NE2000.h. Referenced by ei_poll(), ei_receive(), ei_rx_overrun(), ei_transmit(), ei_tx_err(), and ei_tx_intr(). |
|
Init Procedure to set-up NE2000 base board. We configure the board to accept broadcast frames, witch can raise ring buffer overflow's if you can't remove the frames from the buffer.
Definition at line 76 of file NE2000.c. References current_page, E8390_CMD, E8390_NODMA, E8390_PAGE0, E8390_PAGE1, E8390_RXCONFIG, E8390_RXOFF, E8390_START, E8390_STOP, E8390_TXCONFIG, E8390_TXOFF, EN0_BOUNDARY, EN0_DCFG, EN0_IMR, EN0_ISR, EN0_RCNTHI, EN0_RCNTLO, EN0_RXCR, EN0_STARTPG, EN0_STOPPG, EN0_TPSR, EN0_TXCR, EN1_CURPAG, EN1_PHYS, ioaddr, MAC1, MAC2, MAC3, MAC4, MAC5, MAC6, NICReset(), RX_START_PAGE, RX_STOP_PAGE, TX_START_PAGE, TxChar(), TxEol(), TxHex(), and TxStr_P. Referenced by main(). |
|
Read a packet from the NIC local RAM.
Definition at line 854 of file NE2000.c. References E8390_NODMA, E8390_PAGE0, E8390_RREAD, E8390_START, EN0_RCNTHI, EN0_RCNTLO, EN0_RSARHI, EN0_RSARLO, ioaddr, NE_CMD, and NE_DATAPORT. Referenced by ei_receive(), and nic_mem_test(). |
|
Transfer a packet from the NIC buffer to the PC Ram.
Definition at line 796 of file NE2000.c. References E8390_NODMA, E8390_PAGE0, E8390_RREAD, E8390_RWRITE, E8390_START, EN0_ISR, EN0_RCNTHI, EN0_RCNTLO, EN0_RSARHI, EN0_RSARLO, ENISR_RDC, ioaddr, NE_CMD, and NE_DATAPORT. Referenced by ei_transmit(), and nic_mem_test(). |
|
Poll NIC for received frames. It also check if occured ring buffer overflow and updated statistics.
Definition at line 563 of file NE2000.c. References E8390_CMD, E8390_NODMA, E8390_PAGE0, E8390_START, ei_receive(), ei_rx_overrun(), EN0_BOUNDARY, EN0_COUNTER0, EN0_COUNTER1, EN0_COUNTER2, EN0_ISR, ENISR_COUNTERS, ENISR_OVER, ENISR_RDC, ENISR_RX, ENISR_RX_ERR, ioaddr, MAX_SERVICE, net_device_stats::rx_crc_errors, net_device_stats::rx_frame_errors, net_device_stats::rx_missed_errors, RX_START_PAGE, RX_STOP_PAGE, rxing_page, and UPDSTATS. Referenced by main(). |
|
Read from NIC, ONE FRAME received. The frame readed is puted on uip_buf.
Definition at line 154 of file NE2000.c. References e8390_pkt_hdr::count, current_page, E8390_CMD, E8390_NODMA, E8390_PAGE0, E8390_PAGE1, ei_nic_read(), EN0_BOUNDARY, EN1_CURPAG, ioaddr, NELOG, NELOG_EOL, NELOG_UINT, e8390_pkt_hdr::next, net_device_stats::rx_errors, net_device_stats::rx_length_errors, RX_START_PAGE, RX_STOP_PAGE, rxing_page, e8390_pkt_hdr::status, TxChark, TxEolk, TxHexk, TxStrk_P, TxUintk, uip_buf, UIP_BUFSIZE, UPDSTATS, and VERBOSE_RX_PKT_HDR. Referenced by ei_poll(), and ei_rx_overrun(). |
|
Handle receiver overrun, i.e. overwrite the ring buffer because the frames were not readed. We have a receiver overrun: we have to kick the 8390 to get it started again. Problem is that you have to kick it exactly as NS prescribes in the updated datasheets, or "the NIC may act in an unpredictable manner." This includes causing "the NIC to defer indefinitely when it is stopped on a busy network." Ugh. Called with lock held. Don't call this with the interrupts off or your computer will hate you - it takes 10ms or so.
Definition at line 338 of file NE2000.c. References E8390_CMD, E8390_NODMA, E8390_PAGE0, E8390_START, E8390_STOP, E8390_TRANS, E8390_TXCONFIG, E8390_TXOFF, ei_receive(), EN0_ISR, EN0_RCNTHI, EN0_RCNTLO, EN0_TXCR, ENISR_OVER, ENISR_TX, ENISR_TX_ERR, ioaddr, NELOG, NELOG_EOL, net_device_stats::rx_over_errors, and UPDSTATS. Referenced by ei_poll(). |
|
Transmit frame on the network.
Definition at line 499 of file NE2000.c. References E8390_CMD, E8390_NODMA, E8390_START, E8390_TRANS, ei_nic_write(), ei_tx_err(), ei_tx_intr(), EN0_ISR, EN0_TCNTHI, EN0_TCNTLO, EN0_TPSR, ENISR_TX, ENISR_TX_ERR, ETH_ZLEN, ioaddr, net_device_stats::tx_bytes, TX_START_PAGE, TxChark, TxEolk, TxStrk_P, and UPDSTATS. Referenced by main(). |
|
Handle transmitter error. A transmitter error has happened. Most likely excess collisions (which is a fairly normal condition).
Definition at line 408 of file NE2000.c. References EN0_ISR, EN0_TSR, ENISR_TX_ERR, ENTSR_ABT, ENTSR_CDH, ENTSR_CRS, ENTSR_FU, ENTSR_ND, ENTSR_OWC, ioaddr, net_device_stats::tx_carrier_errors, net_device_stats::tx_errors, net_device_stats::tx_heartbeat_errors, net_device_stats::tx_window_errors, TxEolk, TxHexk, TxStrk_P, and UPDSTATS. Referenced by ei_transmit(). |
|
We have finished a transmit: check for errors and update statistics.
Definition at line 449 of file NE2000.c. References net_device_stats::collisions, EN0_ISR, EN0_TSR, ENISR_TX, ENTSR_ABT, ENTSR_CDH, ENTSR_COL, ENTSR_CRS, ENTSR_FU, ENTSR_OWC, ENTSR_PTX, ioaddr, e8390_pkt_hdr::status, net_device_stats::tx_aborted_errors, net_device_stats::tx_carrier_errors, net_device_stats::tx_errors, net_device_stats::tx_fifo_errors, net_device_stats::tx_heartbeat_errors, net_device_stats::tx_packets, net_device_stats::tx_window_errors, TxEolk, TxStrk_P, and UPDSTATS. Referenced by ei_transmit(). |
|
Test NIC on loopback, using only MODE1.
Referenced by main(). |
|
Test if NIC present and dump configuration.
Referenced by main(). |
|
Test various positions of NIC local memory. This function is very usefull for locating the correct range of NIC ring buffer!
Definition at line 1006 of file NE2000.c. References ei_nic_read(), ei_nic_write(), TxChar(), TxEol(), TxHex(), TxStr(), and uip_buf. Referenced by main(). |
|
Reset NIC by software.
Definition at line 631 of file NE2000.c. References EN0_ISR, ENISR_RESET, ioaddr, NE_RESET, NELOG, and NELOG_EOL. Referenced by ei_init(). |
|
Loops until the Packet Transmitted bit is set in the Interrupt Status Register or exceds 10 "pool's".
|