aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorMatthew N. Dodd <mdodd@FreeBSD.org>2002-01-10 00:56:02 +0000
committerMatthew N. Dodd <mdodd@FreeBSD.org>2002-01-10 00:56:02 +0000
commitced8202c20f01f6cad37c7903cb713442b2709aa (patch)
treec616ef2c952addbd30c94db9a417e370378a3729 /sys/dev/pci
parent5390e1bc8fe871d8ca5ddcd288d918b1c538b4b5 (diff)
Notes
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/pci.c35
-rw-r--r--sys/dev/pci/pcivar.h2
2 files changed, 37 insertions, 0 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 2897f221ffb2..a9f37ba500e5 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 3fc06c774759..432f885d9caa 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_ */
/*