DMA in C

K

kid joe

Hi all,

I'm wondering if it's possible to request a data transfer from one device
(given its device name and its offset and the transfer length) to another
file w/o reading in the data. I could do a fread() followed by a fwrite()
but I would love to have some sort of DMA-like function to do this job.

Thanks.
 
V

viza

Hi

I'm wondering if it's possible to request a data transfer from one
device (given its device name and its offset and the transfer length) to
another file w/o reading in the data. I could do a fread() followed by
a fwrite() but I would love to have some sort of DMA-like function to do
this job.

That is quite a low level operation. The generic C FILE functions do not
let you do anything like that.

Most operating systems will not allow you direct control of DMA devices,
but if you are in a *nix environment, you can sometimes make reading and
writing to block devices more efficient by using the O_DIRECT flag to
open().

Alternatively you might be able to make certain file to file operations
on pipes or sockets quicker by using system calls like sendfile() or
splice().

HTH
viza
 
S

santosh

kid said:
Hi all,

I'm wondering if it's possible to request a data transfer from one
device (given its device name and its offset and the transfer length)
to another file w/o reading in the data. I could do a fread()
followed by a fwrite() but I would love to have some sort of DMA-like
function to do this job.

This is absolutely beyond the scope of standard C. You should normally
let your operating system take care using DMA wherever possible. It
almost certainly knows more than you do about the capabilities (or lack
thereof) of the devices in your system.
 
K

kid joe

OK, thanks for all the info.


There's quite possibly a call to DMA engines. It depends on your OS and is,
of course, non-standard.
However the problem for conventional C is that DMA is usually carried out in
parallel to the main processor. So you need to ensure that the DMA has
completed before trying to use the buffer, which can get tricky.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,228
Latest member
MikeMichal

Latest Threads

Top