mmap problem
Hi!
I try to write small driver to make access to pci device resource from userland using mmap.
Code below didnt work. :(
Quoted 2 lines · Dmitriy Tochansky
ret = remap_page_range( start,
0x40000000, size,vma->vm_page_prot
); //
Use io_remap_page_range, it has the same parameters, and is designed to work with > 32-bit physical addresses.
Also, you should really use pci_resource_* functions to get information about the pci address, size, etc. Don't hardcode this, even for testing.
-- Dan
Quoted 6 lines · On Tue, 7 Dec 2004 10:57:20 -0500 Dan Malek <[email protected]> wrote:
Quoted 3 lines
ret = remap_page_range( start,
0x40000000, size,vma->vm_page_prot); //
Use
io_remap_page_range, it has the same parameters, and is designed to work with > 32-bit physical addresses.
Well, I test it. On module load - unresolved symbol remap_page_range_high. I looking for some ifdefs
where this function blocked, but seems like everithing is ok. :(
Quoted 4 lines
Also, you should really use pci_resource_* functions to get information about the pci address, size, etc. Don't hardcode this, even for testing.
There is a new variant. If I by hand make io_remap_page_range visible - system hangs. :(
#define MAX_DEV 4
struct pci_dev *devs[MAX_DEV];
struct pci_dev *dev = NULL;
...
static unsigned long *offset;
static int mdrv_mmap(struct file * file, struct vm_area_struct *vma) {
int ret;
struct inode *inode;
inode = file->f_dentry->d_inode;
ret = -EINVAL;
unsigned long start = vma->vm_start; unsigned long size = (vma->vm_end-vma->vm_start);
struct pci_dev *curdev = NULL;
int minor = MINOR(inode->i_rdev);
printk("minor = %d\n",minor);
curdev = (devs[minor]);
offset = (unsigned long *)pci_resource_start(curdev,0);
printk("offset = 0x%X\n", offset );
ret = io_remap_page_range( start, offset, size, vma->vm_page_prot );
return ret;
}