void s91_senddata(SMSC smsc, unsigned char *data, int len) { u_long base = smsc->regbase; /* device base address */ #if 0 unshort *word; /* even byte pointer */ #endif void s91_dma_tx_done(void *); int rc; int *send_buf =(int*)alt_uncached_malloc(0x800); /* sanity check */ if ((len < 60) || (((int)data) & 0x1)) { dtrap(); }
/* Send status word first. This seems to be just a required * placeholder in the devices memory. It's filled in by the * device upon TX complete. */ IOWR_ALTERA_AVALON_LAN91C111_DATA_HW(base, 0);
/* Followed by the byte count; count includes the 6 control bytes. */ IOWR_ALTERA_AVALON_LAN91C111_DATA_HW(base, (len & ~0x1) + 6);
#if 0 word = (unshort *)data; while (len >= 2) { IOWR_ALTERA_AVALON_LAN91C111_DATA_HW(base, *word); word++; len -= 2; } #else #ifndef ALTERA_DMA_A_TX if (((u_long)data) & 0x02) { IOWR_ALTERA_AVALON_LAN91C111_DATA_HW(base, *(unshort *)data); data += 2; len -= 2; }
while ((len -= 4) >= 0) { IOWR_ALTERA_AVALON_LAN91C111_DATA_WORD(base, *(unsigned int
*)data); data += 4; }
smsc->snd_odd = len + 4; smsc->snd_data = data; s91_dma_tx_done((void *)smsc); #else /* disable 91C111 interrupts until DMA completes */ IOWR_ALTERA_AVALON_LAN91C111_MSK(base, 0);
/* do the odd half-word at the beginning by PIO */ if (((u_long)data) & 0x02) { IOWR_ALTERA_AVALON_LAN91C111_DATA_HW(base, *(unshort *)data); data += 2; len -= 2; } //printf ("Start dma send\n"); printf(" len = %d\n",len & ~0x3); //len = len & ~0x3; if ((rc = alt_dma_txchan_send(dma_tx, (void *)(((u_long)data) & ~0x80000000), len & ~0x3, s91_dma_tx_done, (void *)smsc)) < 0) { printf ("Failed to post transmit request, reason = %i\n", rc); exit (1); } smsc->snd_odd = len & 0x3; smsc->snd_data = data + (len & ~0x3); #endif /* ALTERA_DMA_TX */
#endif }
Hi$B!$(BI think I have find the problem,when the dma done,it don't call the callback function s91_dma_tx_done,and the lan91c111 buffer is not receive the new data,but I don't know why the dma not send the data,and the rc is correct.