All of lore.kernel.org
 help / color / mirror / Atom feed
* how to list pci devices from userpace?  anything better than /proc/bus/pci/devices?
@ 2002-11-27 21:24 Chris Friesen
  2002-11-27 21:41 ` Richard B. Johnson
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Chris Friesen @ 2002-11-27 21:24 UTC (permalink / raw)
  To: linux-kernel


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: cfriesen@nortelnetworks.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to list pci devices from userpace?  anything better than /proc/bus/pci/devices?
  2002-11-27 21:24 how to list pci devices from userpace? anything better than /proc/bus/pci/devices? Chris Friesen
@ 2002-11-27 21:41 ` Richard B. Johnson
  2002-11-27 21:49   ` Jan-Benedict Glaw
                     ` (2 more replies)
  2002-11-27 21:47 ` Dave Jones
  2002-11-28  9:18 ` Thierry Vignaud
  2 siblings, 3 replies; 7+ messages in thread
From: Richard B. Johnson @ 2002-11-27 21:41 UTC (permalink / raw)
  To: Chris Friesen; +Cc: linux-kernel

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to list pci devices from userpace?  anything better than /proc/bus/pci/devices?
  2002-11-27 21:24 how to list pci devices from userpace? anything better than /proc/bus/pci/devices? Chris Friesen
  2002-11-27 21:41 ` Richard B. Johnson
@ 2002-11-27 21:47 ` Dave Jones
  2002-11-28  9:18 ` Thierry Vignaud
  2 siblings, 0 replies; 7+ messages in thread
From: Dave Jones @ 2002-11-27 21:47 UTC (permalink / raw)
  To: Chris Friesen; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to list pci devices from userpace?  anything better than /proc/bus/pci/devices?
  2002-11-27 21:41 ` Richard B. Johnson
@ 2002-11-27 21:49   ` Jan-Benedict Glaw
  2002-11-27 21:54   ` Martin Mares
  2002-11-28 16:37   ` Alan Cox
  2 siblings, 0 replies; 7+ messages in thread
From: Jan-Benedict Glaw @ 2002-11-27 21:49 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 750 bytes --]

On Wed, 2002-11-27 16:41:18 -0500, Richard B. Johnson <root@chaos.analogic.com>
wrote in message <Pine.LNX.3.95.1021127163510.4690A-100000@chaos.analogic.com>:
> 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       jbglaw@lug-owl.de    . +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/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to list pci devices from userpace?  anything better than /proc/bus/pci/devices?
  2002-11-27 21:41 ` Richard B. Johnson
  2002-11-27 21:49   ` Jan-Benedict Glaw
@ 2002-11-27 21:54   ` Martin Mares
  2002-11-28 16:37   ` Alan Cox
  2 siblings, 0 replies; 7+ messages in thread
From: Martin Mares @ 2002-11-27 21:54 UTC (permalink / raw)
  To: Richard B. Johnson; +Cc: Chris Friesen, linux-kernel

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   <mj@ucw.cz>   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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to list pci devices from userpace?  anything better than /proc/bus/pci/devices?
  2002-11-27 21:24 how to list pci devices from userpace? anything better than /proc/bus/pci/devices? Chris Friesen
  2002-11-27 21:41 ` Richard B. Johnson
  2002-11-27 21:47 ` Dave Jones
@ 2002-11-28  9:18 ` Thierry Vignaud
  2 siblings, 0 replies; 7+ messages in thread
From: Thierry Vignaud @ 2002-11-28  9:18 UTC (permalink / raw)
  To: Chris Friesen; +Cc: linux-kernel

Chris Friesen <cfriesen@nortelnetworks.com> 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/


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: how to list pci devices from userpace?  anything better than /proc/bus/pci/devices?
  2002-11-27 21:41 ` Richard B. Johnson
  2002-11-27 21:49   ` Jan-Benedict Glaw
  2002-11-27 21:54   ` Martin Mares
@ 2002-11-28 16:37   ` Alan Cox
  2 siblings, 0 replies; 7+ messages in thread
From: Alan Cox @ 2002-11-28 16:37 UTC (permalink / raw)
  To: root; +Cc: Chris Friesen, Linux Kernel Mailing List

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-11-28 16:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-27 21:24 how to list pci devices from userpace? anything better than /proc/bus/pci/devices? Chris Friesen
2002-11-27 21:41 ` Richard B. Johnson
2002-11-27 21:49   ` Jan-Benedict Glaw
2002-11-27 21:54   ` Martin Mares
2002-11-28 16:37   ` Alan Cox
2002-11-27 21:47 ` Dave Jones
2002-11-28  9:18 ` Thierry Vignaud

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.