Re: [Hampshire] Sys fs, PCI & mmap

Top Page

Reply to this message
Author: James Courtier-Dutton
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] Sys fs, PCI & mmap
On 11/10/2007, Bond, Peter <PBond@???> wrote:
> Hi all -
>
> I've been racking my brains over this one, and I'll have to give in and beg for help.
>
> I have a PCI device. Sysfs happily shows it, along with the resources derived from the BARS. I'd like to mmap the resource0 file that is offered up so that I can access the memory from userspace. Googling around suggests that this functionality is available without having a driver loaded (assuming I've understood that correctly). Only problem is, that whilst a copy of devmem2 modified to use resource0 rather than /dev/mem for the mmap appears to work, it doesn't result in any PCI activity.
>
> Rubini doesn't quite cover this scenario - or if it does, I'm not reading the right pages.
>
> Help?
>


Just write a small kernel module that does a mmio mapping the physical
memory on the card into the virtual memory of the userspace
application.
You do need a kernel module driver loaded to do this task though.
There would simply be a few IOCTL calls so that userspace can request
a pointer to the virtual memory location, and also to release the
memory.

Take a look at some of the PCI passthru code in qemu. qemu is a
userspace app and can be used to passthru mmio from the hardware into
the qemu vm.

James