More documentation on mmap_single

Hi,

I am trying to memory-map I/O-physical memory to a user process which does a mmap call.(It is my small custom driver.) However, I am not able to find sufficient documentation on memory mapping physical memory to vm_object inside mmap_single.

I have implemented d_mmap and it works without any issues. But I don't want mmap to be called for every page two times. So, I am trying to explore mmap_single. Can someone direct me to some documentation?

Thanks.
 
Hey thanks,

I used the given reference and modified it for the device allocated memory. However, one thing I realized is I still need mmap along with mmap_single; mmap method as a handle to specify the physical address of the device allocated memory. That mmap handle gets called once for every page and then once for the whole range when a user actually tries to access the memory. When the handler gets called for each offset, I do get context of the file_prev(application context). But when a user tries to access it I don't get any context. :(

My pseudo code looks like:

Code:
cdev method{
	.mmap = my_mmap;
	.mmap_single = my_mmap_single;

}

my_mmap(offset, *paddr)
{
     *paddr = actual_phy_addr_to_be_assigned; //based on offset.  
}
my_mmap_single(offset,**vm_object,nprot) {
    vm_object = vm_pager_allocator();
}

Am I doing something wrong or what is the rationale behind calling the mmap method once again when user space accesses the memory?
 
Hi,

I went through some other drivers and found the required implementation. Now I set a page fault handler, ctor and dtor in mmap_single calls and works well. However, when I was going through the BSD code, one of the thing I failed to understand was: why BSD chose not to provide the context when page faults happen on mmap'ed areas (when the mmap call is used and not mmap_single).
 
Back
Top