Re: /proc/pci

Stephen Williams (steve@icarus.icarus.com)
Sun, 21 Sep 1997 10:20:34 +0800


teunis@usa.net said:
> Okay fine. How _SHOULD_ a userspace program find a PCI card? (I'm
> probably missing something here - I haven't really paid all that much
> attention to this thread 'till now)

Currently, there is no practical alternative. I think /proc/pci is incorrect,
but I don't believe that there have been better alternatives. ... yet.

I have submitted a patch that removed /proc/pci and replaces it
with /proc/pcibus. This directory contains machine-readable images of
the configuration spaces of all the PCI devices.

ftp://ftp.picturel.com/put/source/pcistat.tgz

David Howells is also working on a configuration management subsystem for
Linux that may well also be able to provide this sort of information.

There are also a few people suggesting replacing /proc/pci with a machine
readable but ASCII dumped version. Perhaps maybe ascii hex? This suggestion
from Martin Mares:

mj@atrey.karlin.mff.cuni.cz said:
> - Add the pci config space access syscalls to _all_ architectures
> supporting PCI.

> - Replace /proc/pci contents by a simple list of all found PCI
> devices (userland programs should _not_ scan the bus) in the
> following format (one line per device): [...etc...]

This is also a good idea. It will probably mess up with non-type0 headers
like bridges, but a variant that doesn't interpret past the first few
words will be easy and reliable.

rth@dot.cygnus.com said:
> Note that that comment describes an old version of XF86_TGA. Current
> versions use the pciconfig_read system call.

This system call doesn't exist on all Linux platforms. Personally, I think
that a new sytem call is inappropriate and that the proper thing to do is
to choose/devise a good /proc based mechinism, or add a sysctl.

-- 
Steve Williams
steve@icarus.com
steve@picturel.com

"The woods are lovely, dark and deep. But I have promises to keep, And lines to code before I sleep, And lines to code before I sleep."