diff options
author | mdodd <mdodd@FreeBSD.org> | 2002-01-10 00:56:02 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 2002-01-10 00:56:02 +0000 |
commit | 2fc9c4563aec4d68e1438f96a23fe9e3ce39a42b (patch) | |
tree | c616ef2c952addbd30c94db9a417e370378a3729 /sys/dev/pci | |
parent | caa458225bdcfc1a2ca4b7b7ce49ce458677a30f (diff) | |
download | FreeBSD-src-2fc9c4563aec4d68e1438f96a23fe9e3ce39a42b.zip FreeBSD-src-2fc9c4563aec4d68e1438f96a23fe9e3ce39a42b.tar.gz |
Implement 2 small helper functions:
pci_find_bsf() - Find a device_t by bus/slot/function.
pci_find_device() - Find a device_t by vendor/device ID.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/pci.c | 35 | ||||
-rw-r--r-- | sys/dev/pci/pcivar.h | 2 |
2 files changed, 37 insertions, 0 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 2897f22..a9f37ba5 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -190,6 +190,41 @@ struct devlist pci_devq; u_int32_t pci_generation; u_int32_t pci_numdevs = 0; +/* Find a device_t by bus/slot/function */ + +device_t +pci_find_bsf (u_int8_t bus, u_int8_t slot, u_int8_t func) +{ + struct pci_devinfo *dinfo; + + STAILQ_FOREACH(dinfo, &pci_devq, pci_links) { + if ((dinfo->cfg.bus == bus) && + (dinfo->cfg.slot == slot) && + (dinfo->cfg.func == func)) { + return (dinfo->cfg.dev); + } + } + + return (NULL); +} + +/* Find a device_t by vendor/device ID */ + +device_t +pci_find_device (u_int16_t vendor, u_int16_t device) +{ + struct pci_devinfo *dinfo; + + STAILQ_FOREACH(dinfo, &pci_devq, pci_links) { + if ((dinfo->cfg.vendor == vendor) && + (dinfo->cfg.device == device)) { + return (dinfo->cfg.dev); + } + } + + return (NULL); +} + /* return base address of memory or port map */ static u_int32_t diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 3fc06c7..432f885 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -308,6 +308,8 @@ pci_get_powerstate(device_t dev) return PCI_GET_POWERSTATE(device_get_parent(dev), dev); } +device_t pci_find_bsf(u_int8_t, u_int8_t, u_int8_t); +device_t pci_find_device(u_int16_t, u_int16_t); #endif /* _SYS_BUS_H_ */ /* |