Poll function, Interruptvector function, Upper layer functions – Comtrol eCos User Manual

Page 608: Interrupt-vector function

Advertising
background image

Chapter 46. Generic Ethernet Device Driver

has been called itself from your deliver function when it knows that a packet of data is available on the interface.
The

(sc->funs->eth_drv->recv)()

function then arranges network buffers and structures for the data and then

calls

HRDWR_recv()

to actually move the data from the interface.

A scatter-gather list (struct eth_drv_sg) is used once more, just like in the send case.

Poll function

static void

HRDWR_poll(struct eth_drv_sc *sc)

This function is used when in a non-interrupt driven system, e.g. when interrupts are completely disabled. This
allows the driver time to check whether anything needs doing either for transmission, or to check if anything has
been received, or if any other processing needs doing.

It is perfectly correct and acceptable for the poll function to look like this:

static void

HRDWR_poll(struct eth_drv_sc *sc)

{

my_interrupt_ISR(sc);

HRDWR_deliver(struct eth_drv_sc *sc);

}

provided that both the ISR and the deliver functions are idempotent and harmless if called when there is no attention
needed by the hardware. Some devices might not need a call to the ISR here if the deliver function contains all the
“intelligence.”

Interrupt-vector function

static int

HRDWR_int_vector(struct eth_drv_sc *sc)

This function returns the interrupt vector number used for receive interrupts. This is so that the common GDB
stubs can detect when to check for incoming “CTRL-C” packets (used to asynchronously halt the application)
when debugging over ethernet. The GDB stubs need to know which interrupt the ethernet device uses so that they
can mask or unmask that interrupt as required.

Upper Layer Functions

Upper layer functions are called by drivers to deliver received packets or transmission completion status back up
into the network stack.

These functions are defined by the hardware independent upper layers of the networking driver support. They are
present to hide the interfaces to the actual networking stack so that the hardware drivers may be used by different
network stack implementations without change.

504

Advertising