DMA

Jan 06, 2005 4 Replies

Hello,



I am trying to figure out how to make a program from user land that can use the DMA controller. I would like it to read values, returned from the SPI port, and store the values in the SDRAM. Can this be done?



I have figured out that I need to use a physical address when programming the DMA controller, not a virtual address such as is used in application programs. Is there a way to find the physical address from the virtual address?



Thanks in advance to anyone who can help.



BJ


You're question is rather vauge, but I think what you need to do is write a device driver that does the DMA to/from a buffer. That device driver can then allow the user-program to mmap() the DMA buffers into user-space.

Grant Edwards grante Yow! AIEEEEE! I am having at an UNDULATING EXPERIENCE! visi.com

Thank you for the reply.

That sounds like what I had anticipated I would have to do but I don't know how to go about it.

Does anyone have a sample program that I could follow?

BJ

Here's a demo I did many years ago that sort of does that:

ftp://ftp.visi.com/users/grante/stuff/demomm.tar.gz

It supports mmapping a PCI card's memory region into user space, as well as a "scratch" buffer that can be used for DMA. It's 5 years old, and hasn't been touched since kernel 2.2. I suspect that the kernal API has changed so much it's worthless.

Grant Edwards grante Yow! -- In 1962, you could at buy a pair of SHARKSKIN visi.com SLACKS, with a "Continental Belt," for $10.99!!

Bus master DMA (e.g. by a PCI card) or using a DMA utility in the Motherboard or processor.

If (2) you need to find out a free controller and reserve same for your driver.

Generally it's not a good idea at all to try to do any DMA related work in userland. You should do a device driver and call that from you program, providing userland addresses for the buffer and then ave the driver do the work.

-Michael

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required