Need to program the DMA engine on a PC
I have a Tyan Thunder K8S PRO motherboard with dual AMD-64 Opterons on it. Its running Linux 2.6.11 gentoo. I have written the applications and drivers for the system I need but the one thing I have not been successful is in using DMA to transfer data from one of the cards to user space. To just memory map it and the to use memcpy() is not fast enough. I need burst mode to be used in transferring the data.
I have looked through the book "Linux Device Drivers" 3rd edition and in it is some of the required driver routines for setting up the DMA to a point. However, it would appear to only have one side of the DMA transfer described.
I need to transfer from RAM on my card to RAM in my user space. I created the driver entry point adc_read() so that a call to read() on my driver would take it as the entry point. The following code is what I have so far...
flags = claim_dma_lock();
disable_dma(ADC_DMA_CHANNEL);
clear_dma_ff(ADC_DMA_CHANNEL);
set_dma_mode(ADC_DMA_CHANNEL,DMA_MODE_READ);
set_dma_addr(ADC_DMA_CHANNEL,adcDmaBusAddr);
set_dma_count(ADC_DMA_CHANNEL,count);
enable_dma(ADC_DMA_CHANNEL);
while(get_dma_residue(ADC_DMA_CHANNEL) != 0);
release_dma_lock(flags);
this is essentially copied from the book I mentioned above. My problem is, I'm only giving the DMA one address. How can this possibly work and where would I set the address of the destination? Also, that while loop is potentially a disaster since this resides in the driver code. I need a done bit or some such but I could code around this by having an ioctl call to block until this transfer was complete.
I would like to hear from anyone who has done this in the past or who knows a good url to check out for examples.
Cheers!!
|