diff options
| author | Michael Brown | 2005-05-03 14:14:29 +0200 |
|---|---|---|
| committer | Michael Brown | 2005-05-03 14:14:29 +0200 |
| commit | 303ff86c758554941e3e016b64f2a35bc8811b78 (patch) | |
| tree | 2e7a2e4a5eee51500eeef76f9e51f5c50e54dfc7 | |
| parent | #if 0 out the whole file for now; it cannot be linked because the base (diff) | |
| download | ipxe-303ff86c758554941e3e016b64f2a35bc8811b78.tar.gz ipxe-303ff86c758554941e3e016b64f2a35bc8811b78.tar.xz ipxe-303ff86c758554941e3e016b64f2a35bc8811b78.zip | |
Added example of how to use __shared.
Moved transmit before poll, since typically transmit will be implemented first.
| -rw-r--r-- | src/drivers/net/skel.c | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/src/drivers/net/skel.c b/src/drivers/net/skel.c index a96a78b21..5f5fd0ba8 100644 --- a/src/drivers/net/skel.c +++ b/src/drivers/net/skel.c @@ -21,12 +21,34 @@ Skeleton NIC driver for Etherboot #include "isapnp.h" #include "mca.h" -/* NIC specific static variables go here. Try to avoid using static +/* + * NIC specific static variables go here. Try to avoid using static * variables wherever possible. In particular, the I/O address can * always be accessed via nic->ioaddr. */ /* + * If you have large static variables (e.g. transmit and receive + * buffers), you should place them together in a single structure and + * mark the structure as "shared". This enables this space to be + * shared between drivers in multi-driver images, which can easily + * reduce the runtime size by 50%. + * + */ +#define SKEL_RX_BUFS 1 +#define SKEL_TX_BUFS 1 +#define SKEL_RX_BUFSIZE 0 +#define SKEL_TX_BUFSIZE 0 +struct skel_rx_desc {}; +struct skel_tx_desc {}; +struct { + struct skel_rx_desc rxd[SKEL_RX_BUFS]; + unsigned char rxb[SKEL_RX_BUFS][SKEL_RX_BUFSIZE]; + struct skel_tx_desc txd[SKEL_TX_BUFS]; + unsigned char txb[SKEL_TX_BUFS][SKEL_TX_BUFSIZE]; +} skel_bufs __shared; + +/* * Don't forget to remove "__unused" from all the function parameters! * */ @@ -49,6 +71,29 @@ static int skel_connect ( struct nic *nic __unused ) { } /************************************************************************** + * TRANSMIT - Transmit a frame + ************************************************************************** +*/ +static void skel_transmit ( struct nic *nic __unused, + const char *dest __unused, + unsigned int type __unused, + unsigned int size __unused, + const char *packet __unused ) { + /* Transmit packet to dest MAC address. You will need to + * construct the link-layer header (dest MAC, source MAC, + * type). + */ + /* + unsigned int nstype = htons ( type ); + memcpy ( <tx_buffer>, dest, ETH_ALEN ); + memcpy ( <tx_buffer> + ETH_ALEN, nic->node_addr, ETH_ALEN ); + memcpy ( <tx_buffer> + 2 * ETH_ALEN, &nstype, 2 ); + memcpy ( <tx_buffer> + ETH_HLEN, data, size ); + <transmit_data> ( <tx_buffer>, size + ETH_HLEN ); + */ +} + +/************************************************************************** * POLL - Wait for a frame ************************************************************************** */ @@ -82,29 +127,6 @@ static int skel_poll ( struct nic *nic __unused, int retrieve __unused ) { } /************************************************************************** - * TRANSMIT - Transmit a frame - ************************************************************************** -*/ -static void skel_transmit ( struct nic *nic __unused, - const char *dest __unused, - unsigned int type __unused, - unsigned int size __unused, - const char *packet __unused ) { - /* Transmit packet to dest MAC address. You will need to - * construct the link-layer header (dest MAC, source MAC, - * type). - */ - /* - unsigned int nstype = htons ( type ); - memcpy ( <tx_buffer>, dest, ETH_ALEN ); - memcpy ( <tx_buffer> + ETH_ALEN, nic->node_addr, ETH_ALEN ); - memcpy ( <tx_buffer> + 2 * ETH_ALEN, &nstype, 2 ); - memcpy ( <tx_buffer> + ETH_HLEN, data, size ); - <transmit_data> ( <tx_buffer>, size + ETH_HLEN ); - */ -} - -/************************************************************************** * IRQ - handle interrupts ************************************************************************** */ @@ -143,8 +165,8 @@ static void skel_irq ( struct nic *nic __unused, irq_action_t action ) { */ static struct nic_operations skel_operations = { .connect = skel_connect, - .poll = skel_poll, .transmit = skel_transmit, + .poll = skel_poll, .irq = skel_irq, }; |
