2 * UDI Ne2000 NIC Driver
3 * By John Hodge (thePowersGang)
10 #include "ne2000_common.h"
13 udi_buf_write_call_t ne2k_rx__buf_allocated;
14 udi_pio_trans_call_t ne2k_rx__complete;
17 void ne2k_nd_rx_channel_event_ind(udi_channel_event_cb_t *cb)
20 void ne2k_nd_rx_rx_rdy(udi_nic_rx_cb_t *cb)
22 udi_cb_t *gcb = UDI_GCB(cb);
23 ne2k_rdata_t *rdata = gcb->context;
25 // Add cb(s) to avaliable list
26 if( rdata->rx_next_cb ) {
27 rdata->rx_last_cb->chain = cb;
30 rdata->rx_next_cb = cb;
32 rdata->rx_last_cb = cb;
34 while( rdata->rx_last_cb->chain ) {
35 rdata->rx_last_cb = rdata->rx_last_cb->chain;
39 void ne2k_intr__rx_ok(udi_cb_t *gcb)
41 ne2k_rdata_t *rdata = gcb->context;
42 if( rdata->rx_next_cb )
44 udi_nic_rx_cb_t *rx_cb = rdata->rx_next_cb;
45 rdata->rx_next_cb = rx_cb->chain;
47 udi_debug_printf("ne2k_intr__rx_ok: Initialising buffer\n");
48 udi_buf_write(ne2k_rx__buf_allocated, UDI_GCB(rx_cb), NULL, 1520, rx_cb->rx_buf, 0, 0, NULL);
52 // Drop packet due to no free cbs
53 udi_debug_printf("ne2k_intr__rx_ok: Dropped due to no free rx cbs\n");
54 // TODO: Tell hardware to drop packet
58 void ne2k_rx__buf_allocated(udi_cb_t *gcb, udi_buf_t *new_buf)
60 ne2k_rdata_t *rdata = gcb->context;
61 udi_nic_rx_cb_t *rx_cb = UDI_MCB(gcb, udi_nic_rx_cb_t);
63 udi_debug_printf("ne2k_rx__buf_allocated: Buffer ready, cb=%p\n", rx_cb);
64 udi_pio_trans(ne2k_rx__complete, gcb,
65 rdata->pio_handles[NE2K_PIO_RX], 0, rx_cb->rx_buf, &rdata->rx_next_page);
68 void ne2k_rx__complete(udi_cb_t *gcb, udi_buf_t *new_buf, udi_status_t status, udi_ubit16_t result)
70 udi_nic_rx_cb_t *rx_cb = UDI_MCB(gcb, udi_nic_rx_cb_t);
71 rx_cb->rx_buf->buf_size = result;
73 udi_nsr_rx_ind( rx_cb );