I have a situation where the userspace app needs to be able to deal with
two different models of hardware, each of which uses a slightly
different api.
Is there any way that I can query the pci vendor/device numbers without
having to parse ascii files in /proc?
Thanks,
Chris
--
Chris Friesen | MailStop: 043/33/F10
Nortel Networks | work: (613) 765-0557
3500 Carling Avenue | fax: (613) 765-2986
Nepean, ON K2H 8E9 Canada | email: [email protected]
On Wed, 27 Nov 2002, Chris Friesen wrote:
>
> I have a situation where the userspace app needs to be able to deal with
> two different models of hardware, each of which uses a slightly
> different api.
>
> Is there any way that I can query the pci vendor/device numbers without
> having to parse ascii files in /proc?
>
> Thanks,
>
> Chris
Red Hat distributions after 7.0 provide `lspci`. You still have
to parse ASCII. FYI, it's not hard to write a 'C' program
that directly accessed the PCI bus from its ports at 0xCF8 (index)
and 0xCFC (data). You need to do 32-bit port accesses and you
can set iopl(3) from user-space.
If you want to 'roll-your-own', I can send you some code to
use as a template.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Bush : The Fourth Reich of America
On Wed, Nov 27, 2002 at 04:24:12PM -0500, Chris Friesen wrote:
>
> I have a situation where the userspace app needs to be able to deal with
> two different models of hardware, each of which uses a slightly
> different api.
>
> Is there any way that I can query the pci vendor/device numbers without
> having to parse ascii files in /proc?
See pcilib. Part of pciutils. (Its on freshmeat)
Dave
--
| Dave Jones. http://www.codemonkey.org.uk
| SuSE Labs
On Wed, 2002-11-27 16:41:18 -0500, Richard B. Johnson <[email protected]>
wrote in message <[email protected]>:
> On Wed, 27 Nov 2002, Chris Friesen wrote:
[Doing PCI config stuff from userland]
> If you want to 'roll-your-own', I can send you some code to
> use as a template.
It would be nice if you'd post an URI. I think that many people could
make use of it, and this would be nice for the archive:-)
MfG, JBG
--
Jan-Benedict Glaw [email protected] . +49-172-7608481
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur
fuer einen Freien Staat voll Freier B?rger" | im Internet!
Shell Script APT-Proxy: http://lug-owl.de/~jbglaw/software/ap2/
Hi!
> Red Hat distributions after 7.0 provide `lspci`. You still have
> to parse ASCII. FYI, it's not hard to write a 'C' program
> that directly accessed the PCI bus from its ports at 0xCF8 (index)
> and 0xCFC (data). You need to do 32-bit port accesses and you
> can set iopl(3) from user-space.
Please DON'T do that -- not all machines support this access mechanism
and even on them directly poking the I/O ports would lead to races with
other programs and as well with the kernel.
Either use lspci (which has a nice machine-parseable output mode) or
parse /proc/bus/pci/devices or use the libpci library (part of the
pciutils package).
Have a nice fortnight
--
Martin `MJ' Mares <[email protected]> http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
A LISP programmer knows value of everything, but cost of nothing.
Chris Friesen <[email protected]> writes:
> I have a situation where the userspace app needs to be able to deal
> with two different models of hardware, each of which uses a slightly
> different api.
>
> Is there any way that I can query the pci vendor/device numbers
> without having to parse ascii files in /proc?
look at libldetect from ldetect package.
http://cvs.mandrakesoft.com/cgi-bin/cvsweb.cgi/soft/ldetect/
On Wed, 2002-11-27 at 21:41, Richard B. Johnson wrote:
> Red Hat distributions after 7.0 provide `lspci`. You still have
> to parse ASCII. FYI, it's not hard to write a 'C' program
> that directly accessed the PCI bus from its ports at 0xCF8 (index)
> and 0xCFC (data). You need to do 32-bit port accesses and you
> can set iopl(3) from user-space.
That wont work portably. lspci comes with a pci access library that uses
the kernel interfaces and does the job correctly