* [newb] mmap pci
@ 2008-04-16 11:23 Neal Becker
2008-04-16 13:52 ` Arjan van de Ven
0 siblings, 1 reply; 3+ messages in thread
From: Neal Becker @ 2008-04-16 11:23 UTC (permalink / raw)
To: linux-kernel
We have a device - an FPGA board on PCI bus. It has a range of internal
memory mapped to PCI. I want to expose this to user via mmap. Is there
some example code someone could point me to?
If this is not the best forum for such questions, what would be a better
choice?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [newb] mmap pci
2008-04-16 11:23 [newb] mmap pci Neal Becker
@ 2008-04-16 13:52 ` Arjan van de Ven
2008-04-17 12:30 ` Neal Becker
0 siblings, 1 reply; 3+ messages in thread
From: Arjan van de Ven @ 2008-04-16 13:52 UTC (permalink / raw)
To: Neal Becker; +Cc: linux-kernel
On Wed, 16 Apr 2008 07:23:29 -0400
Neal Becker <ndbecker2@gmail.com> wrote:
> We have a device - an FPGA board on PCI bus. It has a range of
> internal memory mapped to PCI. I want to expose this to user via
> mmap. Is there some example code someone could point me to?
>
> If this is not the best forum for such questions, what would be a
> better choice?
Hi,
if it's just a PCI bar, you can already memory map it without even writing a driver!
You can just use the sysfs files for this, for example
/sys/devices/pci0000:00/0000:00:02.0/resource1
There's also a way to do this via the /proc representation of the PCI device..
Greetings,
Arjan van de Ven
--
If you want to reach me at my work email, use arjan@linux.intel.com
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [newb] mmap pci
2008-04-16 13:52 ` Arjan van de Ven
@ 2008-04-17 12:30 ` Neal Becker
0 siblings, 0 replies; 3+ messages in thread
From: Neal Becker @ 2008-04-17 12:30 UTC (permalink / raw)
To: linux-kernel
Arjan van de Ven wrote:
> On Wed, 16 Apr 2008 07:23:29 -0400
> Neal Becker <ndbecker2@gmail.com> wrote:
>
>> We have a device - an FPGA board on PCI bus. It has a range of
>> internal memory mapped to PCI. I want to expose this to user via
>> mmap. Is there some example code someone could point me to?
>>
>> If this is not the best forum for such questions, what would be a
>> better choice?
>
> Hi,
>
> if it's just a PCI bar, you can already memory map it without even writing
> a driver! You can just use the sysfs files for this, for example
> /sys/devices/pci0000:00/0000:00:02.0/resource1
>
> There's also a way to do this via the /proc representation of the PCI
> device..
>
> Greetings,
> Arjan van de Ven
>
>
Thanks! Only problem: seems the mapping is read-only?
This python test code works if prot=mmap.PROT_READ, but I get
permission denied if PROT_READ|PROT_WRITE.
import mmap
import struct
f = open ('/sys/bus/pci/devices/0000:05:0f.0/resource0','rw')
m = mmap.mmap(f.fileno(), 1000000, prot=mmap.PROT_READ)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-04-17 12:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-16 11:23 [newb] mmap pci Neal Becker
2008-04-16 13:52 ` Arjan van de Ven
2008-04-17 12:30 ` Neal Becker
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.