Subject: looking for devices on PCI bus
To: None <tech-kern@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-kern
Date: 05/01/2001 19:33:21
Hi,
there is at last 2 situations where we want to look for PCI devices of a
given type in the system. The first one is for LKM device driver (we
need to find the devices we can drive at lkm load time), the second is for
pciide (where I need to find which pcib we have to know the exact type of
VIA IDE controller). For now the only way to do this would be to duplicate
part of pci.c in various drivers which need it, so I think it's time to come
with a generic way of doing this.

The interface I'm thinking of could be something like:

void
pci_find_device_by_id(bus, vendor, id, rev, callback(struct pci_attach_args *))

This would scan PCI busses in the system. "bus" would be the pci bus number,
"vendor", "id", "rev" the PCI vendor, device, and revision ID.
Each of theses could be set to '-1' meaning wildcard.
For each device matching found "callback()" would be invoked.
In a similar way we could have a pci_find_device_by_class to
find devices of a specific call/subclass:

void
pci_find_device_by_id(bus, class, subclass, callback(struct pci_attach_args *))

The code needed for this would be quite small, most of it is already there
for autoconf stuff.

Comments ?
If nobody object to adding these functions, I'll propose an implementation
soon.

--
Manuel Bouyer <bouyer@antioche.eu.org>
--