X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=UDI%2Fdrivers%2Fnet_ne2000%2Fne2000_rx.c;h=9b4b3c32370195dd8c62dd15049beb268517c408;hb=c150d2bd6ee7c18c1b5f042ebfbd20d86cb34fe2;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=729aa1c3613994659bce0394f3548d351eafea2a;p=tpg%2Facess2.git diff --git a/UDI/drivers/net_ne2000/ne2000_rx.c b/UDI/drivers/net_ne2000/ne2000_rx.c index e69de29b..9b4b3c32 100644 --- a/UDI/drivers/net_ne2000/ne2000_rx.c +++ b/UDI/drivers/net_ne2000/ne2000_rx.c @@ -0,0 +1,78 @@ +/* + * UDI Ne2000 NIC Driver + * By John Hodge (thePowersGang) + * + * ne2000_rx.c + * - Receive Code + */ +#define UDI_VERSION 0x101 +#define UDI_NIC_VERSION 0x101 +#include +#include +#include "ne2000_common.h" + +// === PROTOTYPES === +udi_buf_write_call_t ne2k_rx__buf_allocated; +udi_pio_trans_call_t ne2k_rx__complete; + +// === CODE === +void ne2k_nd_rx_channel_event_ind(udi_channel_event_cb_t *cb) +{ +} +void ne2k_nd_rx_rx_rdy(udi_nic_rx_cb_t *cb) +{ + udi_cb_t *gcb = UDI_GCB(cb); + ne2k_rdata_t *rdata = gcb->context; + + // Add cb(s) to avaliable list + if( rdata->rx_next_cb ) { + rdata->rx_last_cb->chain = cb; + } + else { + rdata->rx_next_cb = cb; + } + rdata->rx_last_cb = cb; + // Follow new chain + while( rdata->rx_last_cb->chain ) { + rdata->rx_last_cb = rdata->rx_last_cb->chain; + } + +} +void ne2k_intr__rx_ok(udi_cb_t *gcb) +{ + ne2k_rdata_t *rdata = gcb->context; + if( rdata->rx_next_cb ) + { + udi_nic_rx_cb_t *rx_cb = rdata->rx_next_cb; + rdata->rx_next_cb = rx_cb->chain; + rx_cb->chain = NULL; + udi_debug_printf("ne2k_intr__rx_ok: Initialising buffer\n"); + udi_buf_write(ne2k_rx__buf_allocated, UDI_GCB(rx_cb), NULL, 1520, rx_cb->rx_buf, 0, 0, UDI_NULL_BUF_PATH); + } + else + { + // Drop packet due to no free cbs + udi_debug_printf("ne2k_intr__rx_ok: Dropped due to no free rx cbs\n"); + // TODO: Tell hardware to drop packet + } +} + +void ne2k_rx__buf_allocated(udi_cb_t *gcb, udi_buf_t *new_buf) +{ + ne2k_rdata_t *rdata = gcb->context; + udi_nic_rx_cb_t *rx_cb = UDI_MCB(gcb, udi_nic_rx_cb_t); + + udi_debug_printf("ne2k_rx__buf_allocated: Buffer ready, cb=%p\n", rx_cb); + udi_pio_trans(ne2k_rx__complete, gcb, + rdata->pio_handles[NE2K_PIO_RX], 0, rx_cb->rx_buf, &rdata->rx_next_page); +} + +void ne2k_rx__complete(udi_cb_t *gcb, udi_buf_t *new_buf, udi_status_t status, udi_ubit16_t result) +{ + udi_nic_rx_cb_t *rx_cb = UDI_MCB(gcb, udi_nic_rx_cb_t); + rx_cb->rx_buf->buf_size = result; + // TODO: Check result + udi_nsr_rx_ind( rx_cb ); +} + +