简体   繁体   中英

Implementing mmap in file_operations - mapping array of pages to virtual space

Let's say the memory I want to give user access to memory that is fragmented into several pages. I have two arrays of the same size: one for logical addresses and one dma_ptrs. I would like to map these consecutive fragments into one contiguous virtual address for the user so he can use it.

I really can't understand the specification of remap_pfn_range which is probably what I'm looking for.

Documentation: http://www.makelinux.net/ldd3/chp-15-sect-2

Page array contains page frame numbers - simply the physical address right-shifted by PAGE_SHIFT bits.

for(i = vm_pgoff; i < no; i++){
    remap_pfn_range(vma, virt_addr + (i - vm_pgoff) * PAGE_SIZE, page[i], PAGE_SIZE, prot);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM