2 * UDI Ne2000 NIC Driver
3 * By John Hodge (thePowersGang)
8 #define UDI_VERSION 0x101
9 #define UDI_NIC_VERSION 0x101
12 #include "ne2000_common.h"
15 udi_buf_write_call_t ne2k_rx__buf_allocated;
16 udi_pio_trans_call_t ne2k_rx__complete;
19 void ne2k_nd_rx_channel_event_ind(udi_channel_event_cb_t *cb)
22 void ne2k_nd_rx_rx_rdy(udi_nic_rx_cb_t *cb)
24 udi_cb_t *gcb = UDI_GCB(cb);
25 ne2k_rdata_t *rdata = gcb->context;
27 // Add cb(s) to avaliable list
28 if( rdata->rx_next_cb ) {
29 rdata->rx_last_cb->chain = cb;
32 rdata->rx_next_cb = cb;
34 rdata->rx_last_cb = cb;
36 while( rdata->rx_last_cb->chain ) {
37 rdata->rx_last_cb = rdata->rx_last_cb->chain;
41 void ne2k_intr__rx_ok(udi_cb_t *gcb)
43 ne2k_rdata_t *rdata = gcb->context;
44 if( rdata->rx_next_cb )
46 udi_nic_rx_cb_t *rx_cb = rdata->rx_next_cb;
47 rdata->rx_next_cb = rx_cb->chain;
49 udi_debug_printf("ne2k_intr__rx_ok: Initialising buffer\n");
50 udi_buf_write(ne2k_rx__buf_allocated, UDI_GCB(rx_cb), NULL, 1520, rx_cb->rx_buf, 0, 0, UDI_NULL_BUF_PATH);
54 // Drop packet due to no free cbs
55 udi_debug_printf("ne2k_intr__rx_ok: Dropped due to no free rx cbs\n");
56 // TODO: Tell hardware to drop packet
60 void ne2k_rx__buf_allocated(udi_cb_t *gcb, udi_buf_t *new_buf)
62 ne2k_rdata_t *rdata = gcb->context;
63 udi_nic_rx_cb_t *rx_cb = UDI_MCB(gcb, udi_nic_rx_cb_t);
65 udi_debug_printf("ne2k_rx__buf_allocated: Buffer ready, cb=%p\n", rx_cb);
66 udi_pio_trans(ne2k_rx__complete, gcb,
67 rdata->pio_handles[NE2K_PIO_RX], 0, rx_cb->rx_buf, &rdata->rx_next_page);
70 void ne2k_rx__complete(udi_cb_t *gcb, udi_buf_t *new_buf, udi_status_t status, udi_ubit16_t result)
72 udi_nic_rx_cb_t *rx_cb = UDI_MCB(gcb, udi_nic_rx_cb_t);
73 rx_cb->rx_buf->buf_size = result;
75 udi_nsr_rx_ind( rx_cb );