libpciaccess question

Adam Jackson ajax at redhat.com
Wed Jul 2 10:41:19 PDT 2008


On Wed, 2008-07-02 at 10:57 -0600, Sebastian Kuzminsky wrote:
> Hi there, sorry to mail you directly but I couldnt find the proper
> mailing list for asking about libpciaccess.

xorg at lists.freedesktop.org is probably the best place.  I've cc'd the
list since this is probably a generally interesting question.

> I'm trying to use libpciaccess to write a userspace utility to work with
> some PCI cards, and I need to peek & poke some IO BARs.  I'm on Ubuntu
> 7.10, which has libpciaccess 0.8.0.
> 
> I can map in memory BARs fine, but the mmap() in
> pci_device_linux_sysfs_map_region() fails with EINVAL when I try to map
> IO BARs.  Is this is a limitation of the sysfs regionX files corresponding
> to IO BARs, that they're not mmappable?

I'm reasonably sure they're not mmapable.  Doing so would essentially
require that the kernel set up a fake map, trap all read or write access
to it, and disassemble the faulting instruction to deduce the i/o cycle
size and address and translate that to an i/o instruction.  (That's my
understanding anyway.)  The PCI config space is not mmap'able for much
the same reason.

The config space is supported through the normal read/write syscalls
though, and the same could reasonably be done for the IO BARs I suspect,
but right now there's no code for that in pciaccess.  Which seems like
failing.

> Does libpciaccess provide some other interface for accessing IO BARs,
> or should i just iopl and inb/outb by hand?

Doing it by hand is certainly the short-term answer, but it would be
pleasant to extend libpciaccess to cover this case.

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg/attachments/20080702/ab94e20a/attachment.pgp>


More information about the xorg mailing list