Subject: Re: looking for devices on PCI bus
To: None <tech-kern@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-kern
Date: 05/02/2001 17:16:26
On Tue, May 01, 2001 at 07:33:21PM +0200, I wrote:
> 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 *))


I just figured out: the callback prototype should probably be like:
callback(void *, struct pci_attach_args *)

The caller of pci_find_device_by_* needs to get a pointer to its own data
in the callback.

--
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
--