Re: Mapping virtual addresses to physical | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
>On Wed, Jul 02, 2008 at 11:01:50PM +0100, Alan Casey wrote: >> >On Wed, Jul 02, 2008 at 09:42:26PM +0100, Alan Casey wrote: >> >> I have used code similar to the devmem2.c example at >> >> www.simtec.co.uk/appnotes/AN0014/ to map physical >> >> addresses to virtual addresses (i.e. user space pointers) >> >> but am just wondering how do you do the reverse - i.e. >> >> map virtual addresses to physical addresses in a user >> >> space program without writing a device driver?? >> > >> >What kind of interface to this functionality are you expecting? What >> >use case would such an interface have? >> >> I need to get the virtual address of a file on a Linux filesystem > >Hmm. Not sure how to break this to you, but files on a Linux filesystem >don't have virtual addresses. The only time that they live in memory >is when they're loaded into the page cache. > >At any moment in the future, data in the page cache can be evicted. So, >even if you could work out where a file was, it'd be entirely useless >because you can't guarantee (from userspace) that it'll stay there. > >> or a memory buffer and convert it to a physical address for the >> purposes of programming a custom DMA Controller (on an FPGA) with >> source read (+destination write) addresses. > >It's far better to write a small device driver for your FPGA to do this. > >Essentially, you want the device driver to provide a character special >device. > >Your userspace program opens the device, and then calls mmap() on it to >map some memory into its address space. In response, the device driver's >mmap method allocates the requested memory (using dma_alloc_coherent()) and >maps it into userspace using dma_mmap_coherent(). > >You could then have an ioctl method to say "start DMA" and "stop DMA" >which'd control the DMA operation. Please ensure that you use numbers >defined using the macros in asm-generic/ioctl.h. Thanks for the info - looks like i better start reading the Linux Device Drivers book, but if you have any links to good examples that have the functionality that i need, let me know please. Regards, Alan. ------------------------------------------------------------------- List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
[Site Home] [Linux ARM Kernel] [Fedora ARM] [IETF Annouce] [Security] [Bugtraq] [Linux] [Linux OMAP] [Linux MIPS] [ECOS] [Tools] [DDR & Rambus] [Monitors]