Index: [thread] [date] [subject] [author]
  From: Andreas Beck <becka@rz.uni-duesseldorf.de>
  To  : ggi-develop@eskimo.com
  Date: Thu, 12 Aug 1999 23:06:58 +0200

Re: [KGI] Detection of PCI device

> > 
> > I have one user for the Cirrus Logic 546x driver which had problems
> > with the PCI device detection the driver does. It seems the way
> > I did it is now rather deprecated (I use the pcibios_find_device(...)
> > function). But this is a guess; could you tell me what is the right
> 
> don't use pcibios_find_device, use pci_find_device instead.
> (include/linux/pci.h:1229 in 2.2.10)
> perhaps he has disabled pci-bios-access and hits the pci-bus directly.

Use neither of them. You are using Linux functionality from with a KGI
driver itself, which is evil. I had to hack that for the ports to other
OSes. We have an abstraction layer to talk to stuff on the PCI bus, but we
do not have one for scanning.

IMHO we should finally write one. I suppose a pci_get_next_device should
suffice, as extracting the required information like vendor/chip ID or
device class is trivial if you know the PCI bus id number of the device.

I'd have to look at the kernel code on how to do the scanning. Can one just
blindly go through the PCI address space (256 buses with 256 devices max and
max 256 functions - right ?) and check if something answers ? 
Or can one query some "enumerator" ?

If doing a full check is required, I suppose it can be shortened by
expecting no missing functions and buses to be numbered consecutively -
right ?

The idea for the driver would be to do something like:

pcidev=PCIDEV(0,0,0)
do {
	if (I_like_that_one()) break;
} while(pci_get_next_device(&pcidev));

While that is not quite as convenient as having prebuilt scan functions, it
is very flexible and requires minimum code in the OS glue layers.

If someone seriously loves the Linux-semantic scanning functions, we can put
them in some common .c module that can be linked to your driver.

I know that this is a little bit less efficient in Linux, as you don't use
the kernel prebuilt PCI devices table, but it is more efficient on other
OSes codesize-wise and PCI scanning is usually done exactly once at driver
startup ...

CU, Andy

-- 
= Andreas Beck                    |  Email :  <andreas.beck@ggi-project.org> =

Index: [thread] [date] [subject] [author]