mmap() problem in own driver

Arnd Bergmann arnd at arndb.de
Tue Jul 14 00:30:50 EST 2009


On Monday 13 July 2009, Sauce.Cheng wrote:

> I want to get data from kernel space to user space indirectly using mmap()
> but i dont know how I can do , anyone can give me some advices ?
> 
> firstly, fetch data by DMA to a memory allocated by "kmalloc"
> then i want to mmap it to user space and save the data as a file 

You first need to allocate full pages, e.g. using alloc_pages() instead
of kmalloc, which may not be aligned. To get a streaming mapping on
that memory, use dma_map_single(), which returns a DMA address you 
can pass to the device.
For user space access, the easiest is to have a character device,
which uses an mmap() file operation that calls remap_pfn_range()
on the page_to_pfn(pages).

	Arnd <><


More information about the Linuxppc-dev mailing list