From: John Hodge Date: Wed, 2 Oct 2013 14:52:41 +0000 (+0800) Subject: UDI/ne2000 - RX code implemented X-Git-Tag: rel0.15~150 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ba60880472a507ff724595f29830753ec8aad40e;p=tpg%2Facess2.git UDI/ne2000 - RX code implemented --- diff --git a/UDI/drivers/net_ne2000/ne2000_common.h b/UDI/drivers/net_ne2000/ne2000_common.h index 739bafe6..59801fbb 100644 --- a/UDI/drivers/net_ne2000/ne2000_common.h +++ b/UDI/drivers/net_ne2000/ne2000_common.h @@ -16,6 +16,14 @@ #define ARRAY_SIZEOF(arr) (sizeof(arr)/sizeof(arr[0])) +enum { + NE2K_PIO_RESET, + NE2K_PIO_ENABLE, + NE2K_PIO_RX, + NE2K_PIO_IRQACK, + NE2K_PIO_TX, +}; + typedef struct { udi_init_context_t init_context; @@ -36,6 +44,9 @@ typedef struct udi_channel_t rx_channel; udi_channel_t tx_channel; + udi_nic_rx_cb_t *rx_next_cb; + udi_ubit8_t rx_next_page; + udi_ubit8_t macaddr[6]; } ne2k_rdata_t; diff --git a/UDI/drivers/net_ne2000/ne2000_core.c b/UDI/drivers/net_ne2000/ne2000_core.c index acecb498..ea562287 100644 --- a/UDI/drivers/net_ne2000/ne2000_core.c +++ b/UDI/drivers/net_ne2000/ne2000_core.c @@ -242,6 +242,7 @@ void ne2k_bus_irq_intr_event_ind(udi_intr_event_cb_t *cb, udi_ubit8_t flags) { ne2k_intr__rx_ok( UDI_GCB(cb) ); } + // TODO: TX IRQs udi_intr_event_rdy(cb); } diff --git a/UDI/drivers/net_ne2000/ne2000_pio.h b/UDI/drivers/net_ne2000/ne2000_pio.h index b862fe87..71a3d060 100644 --- a/UDI/drivers/net_ne2000/ne2000_pio.h +++ b/UDI/drivers/net_ne2000/ne2000_pio.h @@ -192,21 +192,22 @@ udi_pio_trans_t ne2k_pio_irqack[] = { {UDI_PIO_LABEL, 0, 3}, {UDI_PIO_END_IMM, UDI_PIO_2BYTE, 0}, }; +// +// +// +udi_pio_trans_t ne2k_pio_tx[] = { + +}; struct { udi_pio_trans_t *trans_list; udi_ubit16_t list_length; udi_ubit16_t pio_attributes; } ne2k_pio_ops[] = { - {ne2k_pio_reset, ARRAY_SIZEOF(ne2k_pio_reset), 0}, - {ne2k_pio_enable, ARRAY_SIZEOF(ne2k_pio_enable), 0}, - {ne2k_pio_rx, ARRAY_SIZEOF(ne2k_pio_rx), 0}, - {ne2k_pio_irqack, ARRAY_SIZEOF(ne2k_pio_irqack), 0}, + [NE2K_PIO_RESET] = {ne2k_pio_reset, ARRAY_SIZEOF(ne2k_pio_reset), 0}, + [NE2K_PIO_ENABLE] = {ne2k_pio_enable, ARRAY_SIZEOF(ne2k_pio_enable), 0}, + [NE2K_PIO_RX] = {ne2k_pio_rx, ARRAY_SIZEOF(ne2k_pio_rx), 0}, + [NE2K_PIO_IRQACK] = {ne2k_pio_irqack, ARRAY_SIZEOF(ne2k_pio_irqack), 0}, + [NE2K_PIO_TX] = {ne2k_pio_tx, ARRAY_SIZEOF(ne2k_pio_tx), 0}, }; const int NE2K_NUM_PIO_OPS = ARRAY_SIZEOF(ne2k_pio_ops); -enum { - NE2K_PIO_RESET, - NE2K_PIO_ENABLE, - NE2K_PIO_RX, - NE2K_PIO_IRQACK, -}; diff --git a/UDI/drivers/net_ne2000/ne2000_rx.c b/UDI/drivers/net_ne2000/ne2000_rx.c index cc603902..f38f5107 100644 --- a/UDI/drivers/net_ne2000/ne2000_rx.c +++ b/UDI/drivers/net_ne2000/ne2000_rx.c @@ -9,9 +9,38 @@ #include #include "ne2000_common.h" +// === PROTOTYPES === +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) +{ +} 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_pio_trans(ne2k_rx__complete, UDI_GCB(rx_cb), + rdata->pio_handles[NE2K_PIO_RX], 0, NULL, &rdata->rx_next_page); + } + else + { + // Drop packet due to no free cbs + } } +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); + // TODO: Check result + udi_nsr_rx_ind( rx_cb ); +} + +