Re: Device driver, PCI, and mmapping

From: James Simmons (jsimmons@acsu.buffalo.edu)
Date: Thu Jun 15 2000 - 10:02:33 EST


> static int
> my_mmap(struct file *filp, struct vm_area_struct *vma) {
> unsigned long paddr = 0, offset = 0, size = 0;
>
> offset = vma->vm_offset;
> if (offset & ~PAGE_MASK)
> return(-ENXIO);
>
> paddr = base0 + offset;
> size = vma->vm_end - vma->vm_start;
> vma->vm_flags |= (VM_SHM | VM_LOCKED | VM_IO);
>
> if (remap_page_range(vma->vm_start, paddr, size, vma->vm_page_prot))
> return(-EAGAIN);
>
> return(0);
> }

This is for mapping real memory to userland. Also you need to to do
page alignment and think about caching. Take a look at
linux/drivers/video/fbmem.c for a example of a mmap. The mmap function in
fbmem.c works for several bus types as well as several different
platforms.

Q: Why did they deprecate a.out support in linux?
A: Because a nasty coff is bad for your elf.

James Simmons [jsimmons@linux-fbdev.org] ____/|
fbdev/console/gfx developer \ o.O|
http://www.linux-fbdev.org =(_)=
http://linuxgfx.sourceforge.net U
http://linuxconsole.sourceforge.net

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jun 15 2000 - 21:00:35 EST