Nut/OS  4.10.3
API Reference
nicrtl.c File Reference
#include <cfg/os.h>
#include <cfg/arch/avr.h>
#include <cfg/dev.h>
#include <string.h>
#include <sys/atom.h>
#include <sys/heap.h>
#include <sys/thread.h>
#include <sys/event.h>
#include <sys/timer.h>
#include <sys/confnet.h>
#include <net/ether.h>
#include <net/if_var.h>
#include <dev/irqreg.h>
#include <dev/nicrtl.h>
#include "rtlregs.h"
#include <sys/osdebug.h>
#include <net/netdebug.h>
Include dependency graph for nicrtl.c:

Go to the source code of this file.

Data Structures

struct  nic_pkt_header

Defines

#define NUT_THREAD_NICRXSTACK   640
#define RTL_EE_MEMBUS
#define RTL_EESK_PIN   PINC
#define RTL_EESK_DDR   DDRC
#define RTL_EE_MEMBUS
#define RTL_EEDO_PORT   PORTC
#define RTL_EEDO_DDR   DDRC
#define RTL_EE_MEMBUS
#define RTL_EEMU_PORT   PORTC
#define RTL_EEMU_DDR   DDRC
#define RTL_SIGNAL   sig_INTERRUPT0
 Interrupt used.
#define RTL_RISING_EDGE_MODE()   sbi(EICRA, ISC00); sbi(EICRA, ISC01)
#define NIC_PAGE_SIZE   0x100
 Size of a single ring buffer page.
#define NIC_START_PAGE   0x40
 First ring buffer page address.
#define NIC_STOP_PAGE   0x60
 Last ring buffer page address plus 1.
#define NIC_TX_PAGES   6
 Number of pages in a single transmit buffer.
#define NIC_TX_BUFFERS   1
 Number of transmit buffers.
#define NIC_FIRST_TX_PAGE   NIC_START_PAGE
#define NIC_FIRST_RX_PAGE   (NIC_FIRST_TX_PAGE + NIC_TX_PAGES * NIC_TX_BUFFERS)
#define NIC_CR_PAGE0   (0)
#define NIC_CR_PAGE1   (NIC_CR_PS0)
#define NIC_CR_PAGE2   (NIC_CR_PS1)
#define NIC_CR_PAGE3   (NIC_CR_PS1 | NIC_CR_PS0)
#define NICINB(reg)   (*((volatile uint8_t *)RTL_BASE_ADDR + reg))
#define NICOUTB(reg, val)   (*((volatile uint8_t *)RTL_BASE_ADDR + reg) = val)

Functions

void NicRx (void *arg)
 NIC receiver thread.
int NicOutput (NUTDEVICE *dev, NETBUF *nb)
 Send Ethernet packet.
int NicInit (NUTDEVICE *dev)
 Initialize Ethernet hardware.

Define Documentation

#define NUT_THREAD_NICRXSTACK   640

Definition at line 145 of file nicrtl.c.

Referenced by NicInit().

#define RTL_EE_MEMBUS

Definition at line 202 of file nicrtl.c.

#define RTL_EESK_PIN   PINC

Definition at line 157 of file nicrtl.c.

#define RTL_EESK_DDR   DDRC

Definition at line 158 of file nicrtl.c.

#define RTL_EE_MEMBUS

Definition at line 202 of file nicrtl.c.

#define RTL_EEDO_PORT   PORTC

Definition at line 180 of file nicrtl.c.

#define RTL_EEDO_DDR   DDRC

Definition at line 181 of file nicrtl.c.

#define RTL_EE_MEMBUS

Definition at line 202 of file nicrtl.c.

#define RTL_EEMU_PORT   PORTC

Definition at line 203 of file nicrtl.c.

#define RTL_EEMU_DDR   DDRC

Definition at line 204 of file nicrtl.c.

#define RTL_SIGNAL   sig_INTERRUPT0

Interrupt used.

Definition at line 243 of file nicrtl.c.

Referenced by NicInit().

#define RTL_RISING_EDGE_MODE ( )    sbi(EICRA, ISC00); sbi(EICRA, ISC01)

Definition at line 245 of file nicrtl.c.

Referenced by NicInit().

#define NIC_PAGE_SIZE   0x100

Size of a single ring buffer page.

Definition at line 296 of file nicrtl.c.

#define NIC_START_PAGE   0x40

First ring buffer page address.

Definition at line 301 of file nicrtl.c.

#define NIC_STOP_PAGE   0x60

Last ring buffer page address plus 1.

Definition at line 306 of file nicrtl.c.

#define NIC_TX_PAGES   6

Number of pages in a single transmit buffer.

This should be at least the MTU size.

Definition at line 313 of file nicrtl.c.

#define NIC_TX_BUFFERS   1

Number of transmit buffers.

The initial value had been 2. The idea was to use two alternating buffers. However, this had never been implemented and we took over Bengt Florin's change, defining 1 transmit buffer only and give more buffer space to the receiver.

The controller memory layout is now

  • 0x4000..0x45ff 1.5K bytes transmit buffer
  • 0x4600..0x5fff 6.5K bytes receive buffer

The routines are still not using the buffers in an optimal way, as transmission is limited to 1 packet at a time. In fact several smaller packets would fit into the 1.5 kByte buffer. On the other hand, filling the buffer with more than one transmission packet may result in other bad effects, like pulling the IORDY line more often.

Definition at line 335 of file nicrtl.c.

#define NIC_FIRST_TX_PAGE   NIC_START_PAGE

Definition at line 337 of file nicrtl.c.

#define NIC_FIRST_RX_PAGE   (NIC_FIRST_TX_PAGE + NIC_TX_PAGES * NIC_TX_BUFFERS)

Definition at line 338 of file nicrtl.c.

#define NIC_CR_PAGE0   (0)

Definition at line 340 of file nicrtl.c.

#define NIC_CR_PAGE1   (NIC_CR_PS0)

Definition at line 341 of file nicrtl.c.

#define NIC_CR_PAGE2   (NIC_CR_PS1)

Definition at line 342 of file nicrtl.c.

#define NIC_CR_PAGE3   (NIC_CR_PS1 | NIC_CR_PS0)

Definition at line 343 of file nicrtl.c.