From: Neal Becker <ndbecker2@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [newb] mmap pci
Date: Thu, 17 Apr 2008 08:30:29 -0400 [thread overview]
Message-ID: <fu7ft5$4j4$1@ger.gmane.org> (raw)
In-Reply-To: 20080416065217.22691d34@laptopd505.fenrus.org
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)
prev parent reply other threads:[~2008-04-17 12:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='fu7ft5$4j4$1@ger.gmane.org' \
--to=ndbecker2@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.