Skip to contentSkip to conversation

mmap() problem in own driver

DISCUSSION Sauce.Cheng 2 participants 2 messages Jul 13, 2009

lore
Share & tools
lore
#0 lore raw

Hi everyone
there is a problem of my own driver

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

Cheers everyone~
Martin

Signature · 2 lines
View this message in context: http://www.nabble.com/mmap%28%29-problem-in-own-driver-tp24457031p24457031.html
Sent from the linuxppc-dev mailing list archive at Nabble.com.
#1 lore raw
Quoted 5 lines · Sauce.Cheng

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 <><