Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

/opentcp/include/inet/ethernet.h File Reference


Detailed Description

Author:
Version:
1.0
Date:
23.6.2002
OpenTCP Ethernet driver and protocol function declarations, constants, etc.

Definition in file ethernet.h.

Go to the source code of this file.

Data Structures

struct  ethernet_frame
 Ethernet packet header fields. More...


Defines

#define PROTOCOL_IP   0x0800
#define PROTOCOL_ARP   0x0806
#define CR   0x00
#define PSTART   0x01
#define PSTOP   0x02
#define BOUNDARY   0x03
#define TPSR   0x04
#define TSR   0x04
#define TBCR0   0x05
#define TBCR1   0x06
#define ISR   0x07
#define RSAR0   0x08
#define RBCR0   0x0A
#define RCR   0x0C
#define TCR   0x0D
#define DCR   0x0E
#define IMR   0x0F
#define PAR0   0x01
#define CURR   0x07
#define MAR0   0x08
#define IOPORT   0x10
#define RXBUF_START   0x40
#define RXBUF_END   0x4D
#define ARP_BUFFER   0x5F
#define ICMP_BUF   0x4D
#define TCP_BUF   0x53
#define UDP_BUF   0x59

Functions

void outNE2000 (UINT8, UINT8)
 Write data to NE2000 register.

void outNE2000again (UINT8)
 Write data to the same NE2000 register as before.

UINT8 inNE2000 (UINT8)
 Read byte from NE2000 register.

UINT8 inNE2000again (void)
 Continue reading byte(s) from NE2000.

UINT8 NE2000CheckRxFrame (void)
 Check to see if new frame has been received.

void NE2000DumpRxFrame (void)
 Discard current received frame.

void NE2000Init (UINT8 *)
 Initialize and configure RTL8019AS.

void NE2000CheckOverFlow (void)
 Check if receive-buffer overflow occured.

UINT8 NE2000ReceiveFrame (void)
 Checks if new Ethernet frame exists and initializes variables accordingly.

void InitTransmission (UINT8)
 Initialize transmission of new packet.

void NE2000WriteEthernetHeader (struct ethernet_frame *)
 Write Ethernet Header to transmission buffer.

void NE2000DMAInit (UINT8)
 Initialize NE2000 in preparation for remote DMA.

void NE2000DMAInit_position (UINT16)
 Initialize reading from NE2000.

void NE2000SendFrame (UINT16)
 Instruct NIC to send the Ethernet frame.

void NE2000EnterSleep (void)
 Put NE2000 to sleep mode.

void NE2000ExitSleep (void)
 Restore NE2000 from sleep mode.


Define Documentation

#define PROTOCOL_IP   0x0800
 

IP over Ethernet

Definition at line 80 of file ethernet.h.

Referenced by process_ip_in(), and process_ip_out().

#define PROTOCOL_ARP   0x0806
 

ARP over Ethernet

Definition at line 81 of file ethernet.h.

Referenced by arp_send_req(), and arp_send_response().

#define CR   0x00
 

Command register, R/W

Definition at line 85 of file ethernet.h.

Referenced by InitTransmission(), NE2000CheckOverFlow(), NE2000CheckRxFrame(), NE2000DMAInit(), NE2000DMAInit_position(), NE2000DumpRxFrame(), NE2000EnterSleep(), NE2000ExitSleep(), NE2000Init(), NE2000ReceiveFrame(), and NE2000SendFrame().

#define PSTART   0x01
 

Rx buffer start page, W

Definition at line 86 of file ethernet.h.

Referenced by NE2000Init().

#define PSTOP   0x02
 

Rx buffer stop page

Definition at line 87 of file ethernet.h.

Referenced by NE2000Init().

#define BOUNDARY   0x03
 

Address of last byte that host has read from RxBuf, R/W

Definition at line 88 of file ethernet.h.

Referenced by NE2000CheckOverFlow(), NE2000CheckRxFrame(), NE2000DumpRxFrame(), NE2000Init(), and NE2000ReceiveFrame().

#define TPSR   0x04
 

Tx Buf start page, W

Definition at line 91 of file ethernet.h.

Referenced by InitTransmission().

#define TSR   0x04
 

Status of Tx, R

Definition at line 92 of file ethernet.h.

#define TBCR0   0x05
 

Length of transmittet packet

Definition at line 93 of file ethernet.h.

Referenced by NE2000SendFrame().

#define TBCR1   0x06
 

W

Definition at line 94 of file ethernet.h.

Referenced by NE2000SendFrame().

#define ISR   0x07
 

Interrupt status req, R/W

Definition at line 95 of file ethernet.h.

Referenced by NE2000CheckOverFlow(), and NE2000Init().

#define RSAR0   0x08
 

RemoteDMA start address, W

Definition at line 96 of file ethernet.h.

Referenced by InitTransmission(), NE2000DMAInit(), NE2000DMAInit_position(), and NE2000ReceiveFrame().

#define RBCR0   0x0A
 

RemoteDMA bytecount ,W

Definition at line 98 of file ethernet.h.

Referenced by InitTransmission(), NE2000CheckOverFlow(), NE2000DMAInit(), NE2000DMAInit_position(), and NE2000ReceiveFrame().

#define RCR   0x0C
 

Rx Conf reg, W

Definition at line 100 of file ethernet.h.

Referenced by NE2000CheckRxFrame(), and NE2000Init().

#define TCR   0x0D
 

Tx Conf req, W

Definition at line 101 of file ethernet.h.

Referenced by NE2000CheckOverFlow(), and NE2000Init().

#define DCR   0x0E
 

ISA bus configuration, W

Definition at line 102 of file ethernet.h.

Referenced by NE2000Init().

#define IMR   0x0F
 

Interrupt mask register, W

Definition at line 103 of file ethernet.h.

#define PAR0   0x01
 

Physical address ,R/W

Definition at line 107 of file ethernet.h.

Referenced by NE2000Init().

#define CURR   0x07
 

Current local DMA receivereg

Definition at line 113 of file ethernet.h.

Referenced by NE2000CheckOverFlow(), NE2000CheckRxFrame(), and NE2000Init().

#define MAR0   0x08
 

Multicast address register, R/W

Definition at line 114 of file ethernet.h.

#define IOPORT   0x10
 

DMA dataregister

Definition at line 118 of file ethernet.h.

Referenced by InitTransmission(), NE2000DMAInit_position(), and NE2000ReceiveFrame().

#define RXBUF_START   0x40
 

3328 byte Rx Buffer

Definition at line 123 of file ethernet.h.

Referenced by NE2000DMAInit_position(), and NE2000Init().

#define RXBUF_END   0x4D
 

(2 max packets

Definition at line 124 of file ethernet.h.

Referenced by NE2000DMAInit_position(), and NE2000Init().

#define ARP_BUFFER   0x5F
 

256 byte Tx for ARP

Definition at line 125 of file ethernet.h.

Referenced by arp_send_req(), and arp_send_response().

#define ICMP_BUF   0x4D
 

1536 byte Tx for ICMP

Definition at line 126 of file ethernet.h.

Referenced by process_ip_out().

#define TCP_BUF   0x53
 

1536 byte Tx for TCP

Definition at line 127 of file ethernet.h.

Referenced by process_ip_out().

#define UDP_BUF   0x59
 

1536 byte Tx for UDP

Definition at line 128 of file ethernet.h.

Referenced by process_ip_out().


Function Documentation

void outNE2000 UINT8    reg,
UINT8    dat
 

Author:
Date:
19.02.2002
Parameters:
reg  NE2000 register address
dat  new register content
Write data to NE2000 register.

Definition at line 118 of file ethernet.c.

References ADRBUS, DATABUS, DATADIR, DDR_OUT, IOCHRDY, and IOW.

Referenced by InitTransmission(), NE2000CheckOverFlow(), NE2000CheckRxFrame(), NE2000DMAInit(), NE2000DMAInit_position(), NE2000DumpRxFrame(), NE2000EnterSleep(), NE2000ExitSleep(), NE2000Init(), NE2000ReceiveFrame(), and NE2000SendFrame().

void outNE2000again UINT8    dat
 

Author:
Date:
19.02.2002
Parameters:
dat  new register content
Invoke this function to write data to the same register as in previously invoked outNE2000(). Saves some cycles because data direction registers and address are set up.

Use SEND_NETWORK_B() macro instead of invoking this function directly.

Definition at line 148 of file ethernet.c.

References DATABUS, IOCHRDY, and IOW.

Referenced by NE2000SendFrame(), and NE2000WriteEthernetHeader().

UINT8 inNE2000 UINT8    reg
 

Author:
Date:
19.02.2002
Parameters:
reg  NE2000 register address
Returns:
Register content
Invoke this function to read contents of a NE2000 register.

Definition at line 198 of file ethernet.c.

References ADRBUS, DATABUS, DATADIR, DDR_IN, IOCHRDY, and IOR.

Referenced by InitTransmission(), NE2000CheckOverFlow(), NE2000CheckRxFrame(), and NE2000ReceiveFrame().

UINT8 inNE2000again void   
 

Author:
Date:
19.02.2002
Returns:
Register content
Invoke this function to continue reading contents of a NE2000 register, usefull when reading a sequence of bytes from Ethernet controller.

Use RECEIVE_NETWORK_B() macro instead of directly invoking this function for easier driver change.

Definition at line 226 of file ethernet.c.

References DATABUS, IOCHRDY, and IOR.

Referenced by NE2000ReceiveFrame().

UINT8 NE2000CheckRxFrame void   
 

Author:
Date:
19.02.2002
Returns:
  • TRUE - if there is a new packet waiting
  • FALSE - if there is no new packet waiting
Invoke this function to check if there is a new Ethernet frame in the NIC's buffer waiting to be processed.

Definition at line 274 of file ethernet.c.

References BOUNDARY, CR, CURR, inNE2000(), outNE2000(), and RCR.

Referenced by NE2000ReceiveFrame().

void NE2000DumpRxFrame void   
 

Author:
Date:
19.02.2002
Discard the current received frame by advancing the receive circular buffer tail pointer.

Definition at line 304 of file ethernet.c.

References BOUNDARY, CR, NE2000NextPktPtr, and outNE2000().

void NE2000Init UINT8 *    mac
 

Author:
Date:
19.02.2002
Parameters:
mac  Pointer to NIC's hardware address
Invoke this function at startup to properly initialize NIC's registers, HW address and operation.

Definition at line 327 of file ethernet.c.

References BOUNDARY, CR, CURR, DCR, ISR, NE2000CurrPktPtr, NE2000NextPktPtr, outNE2000(), PAR0, PSTART, PSTOP, RCR, RESETPIN_NE2000, RXBUF_END, RXBUF_START, and TCR.

void NE2000CheckOverFlow void   
 

Author:
Date:
19.02.2002
This function checks if receive-buffer overflow has happened. If it did, NIC is reinitialized to ensure proper operation.

Invoke this function periodically to ensure proper operation under heavy load.

Definition at line 393 of file ethernet.c.

References BOUNDARY, CR, CURR, inNE2000(), ISR, NE2000CurrPktPtr, NE2000NextPktPtr, outNE2000(), RBCR0, and TCR.

UINT8 NE2000ReceiveFrame void   
 

Author:
Date:
19.02.2002
Returns:
  • TRUE - new frame exists, variables initialized so further processing may start
  • FALSE - no new Ethernet frame detected
Invoke this function periodically (better not directly but by invoking NETWORK_CHECK_IF_RECEIVED() macro) to test for newly-arrived Ethernet packets.

Once this function detects a new Etherent packet, internal variables are initialized (NE2000CurrPktPtr, NE2000NextPktPtr and received_frame structure) and TRUE is returned, indicating that processing of newly-arrived frame may begin.

Definition at line 482 of file ethernet.c.

References BOUNDARY, ethernet_frame::buf_index, CR, ethernet_frame::destination, FALSE, ethernet_frame::frame_size, inNE2000(), inNE2000again(), IOPORT, NE2000CheckRxFrame(), NE2000CurrPktPtr, NE2000NextPktPtr, outNE2000(), ethernet_frame::protocol, RBCR0, RSAR0, and ethernet_frame::source.

void InitTransmission UINT8    page
 

Author:
Date:
19.02.2002
Parameters:
page  Address in Ethernet controller where outgoing packet buffered
This function is used to initialize transmission of an Ethernet packet. Packet is created starting from page address.

Do not invoke this function directly, but instead use NETWORK_SEND_INITIALIZE() macro.

Definition at line 570 of file ethernet.c.

References ADRBUS, CR, DATADIR, DDR_OUT, inNE2000(), IOPORT, outNE2000(), RBCR0, RSAR0, and TPSR.

void NE2000WriteEthernetHeader struct ethernet_frame   frame
 

Author:
Date:
19.02.2002
Parameters:
frame  Pointer to ethernet_frame structure containing information about the new Ethernet frame
Invoke this function (through NETWORK_ADD_DATALINK() macro) to create an Ethernet header in the NIC's transmit buffer. Do this only after invoking NETWORK_SEND_INITIALIZE() macro.

Definition at line 608 of file ethernet.c.

References ethernet_frame::destination, outNE2000again(), ethernet_frame::protocol, and ethernet_frame::source.

void NE2000DMAInit UINT8    page
 

Author:
Date:
19.02.2002
Parameters:
page  Address for the DMA

Definition at line 639 of file ethernet.c.

References CR, outNE2000(), RBCR0, and RSAR0.

void NE2000DMAInit_position UINT16    pos
 

Author:
Date:
19.02.2002
Parameters:
pos  Position from the start of current frame from which DMA is initialized.
Invoke this function (through NETWORK_RECEIVE_INITIALIZE() macro) to prepair NIC for reading from the specified position.

Definition at line 665 of file ethernet.c.

References ADRBUS, CR, DATADIR, DDR_IN, IOPORT, NE2000CurrPktPtr, outNE2000(), RBCR0, RSAR0, RXBUF_END, and RXBUF_START.

void NE2000SendFrame UINT16    len
 

Author:
Date:
19.02.2002
Parameters:
len  Length of packet stored in the NIC's buffer
Warning:
  • Minimum Ethernet packet size is 64 bytes
Invoke this function (through NETWORK_COMPLETE_SEND() macro) when the whole packet is formed inside NIC's memory and is ready to be sent. Proper length of the packet must be supplied so that NIC knows how much data to put on the line.

Definition at line 725 of file ethernet.c.

References CR, outNE2000(), outNE2000again(), TBCR0, and TBCR1.

void NE2000EnterSleep void   
 

Author:
Date:
19.02.2002
Invoke this function to put Ethernet controller to sleep mode.

Definition at line 760 of file ethernet.c.

References CR, EtherSleep, and outNE2000().

void NE2000ExitSleep void   
 

Author:
Date:
19.02.2002
Invoke this function to instruct NE2000 to exit sleep mode and continue normal operation.

Definition at line 779 of file ethernet.c.

References CR, EtherSleep, and outNE2000().


Generated on Sun Aug 3 20:33:00 2003 for OpenTCP by doxygen1.2.18