Reputation: 1129
In my driver, I am trying to map an address returned from ioremap
to a userspace address.
ioremap
?kmalloc
address ?ioremap
?remap_pfn_range
?Upvotes: 6
Views: 5819
Reputation: 14937
You don't need ioremap()
if you're using remap_pfn_range()
. ioremap()
maps a physical address into a kernel virtual address. remap_pfn_range()
maps physical addresses directly to user space. Just pass your physical address (downshifted by PAGE_SHIFT to produce a pfn) directly to remap_pfn_range()
. Your questions in order:
virt_to_phys()
first, to convert kernel virtual address to physical. But skip a step if you don't actually need kernel access to this memory rangeUpvotes: 10
Reputation: 9474
ioremap()
returns the kernel space virtual address. This can't be accessed directly from user space. There is mechanism called mmap(), refer here and Mapping physical addresses to virtual address linux for working sample.
Upvotes: 0