mmap a physical address
Hi --
I am trying to map a PCI physical address bar to my user space program. In order to be able to map this physical address to user space I am creating a dummy character driver and capture the bar address in my driver. Later, I send this address to user (using IOCTL) and call mmap on the physical address.
As you can see I am not trying to map a file or something, I am trying to map the real physical memory which I know its address.
I am calling mmap() as follow:
mmap(0 , mem_length , PORT_READ|PROT_WRITE|MAP_SHARED, fd , offset);
1) mem_length = phy_addr_end - phy_addr_start
2) fd = open("/dev/_dummy_char_dev_name", O_WRONLY)
3) offset = phy_addr_start
mmap is returing MAP_FAILED . Could you please give me some hint on this?
also, my kernel mosule map funciton is as follow:
kernel_map(struct file * filp , struct vm_area_struct * vma)
{
remap_pfn_range(vma,vma->vm_Start,
vma->pgoff,
vma->vm_end-vma->vm_Start,
vm->vm_page_prot)
rturn 0
}
any help is much appreciated.
|