git: 9a647d96eb3c - stable/13 - pci: Add helper routines to iterate over a device's BARs.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 25 Aug 2022 17:31:42 UTC
The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=9a647d96eb3c35b52ca2ff2c041132a32b94c1dd commit 9a647d96eb3c35b52ca2ff2c041132a32b94c1dd Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2022-08-19 21:59:06 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2022-08-25 16:38:49 +0000 pci: Add helper routines to iterate over a device's BARs. Reviewed by: imp, markj, emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36237 (cherry picked from commit 16bedf532c022f2380b0bb2970a3a3ebc7ca0f36) --- sys/dev/pci/pci.c | 15 +++++++++++++++ sys/dev/pci/pcivar.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 6e9ac44577b4..59fced7b14c4 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -3171,6 +3171,21 @@ pci_find_bar(device_t dev, int reg) return (NULL); } +struct pci_map * +pci_first_bar(device_t dev) +{ + struct pci_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (STAILQ_FIRST(&dinfo->cfg.maps)); +} + +struct pci_map * +pci_next_bar(struct pci_map *pm) +{ + return (STAILQ_NEXT(pm, pm_link)); +} + int pci_bar_enabled(device_t dev, struct pci_map *pm) { diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 74aa704635f7..3a444114027d 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -712,6 +712,8 @@ extern struct devlist pci_devq; extern uint32_t pci_generation; struct pci_map *pci_find_bar(device_t dev, int reg); +struct pci_map *pci_first_bar(device_t dev); +struct pci_map *pci_next_bar(struct pci_map *pm); int pci_bar_enabled(device_t dev, struct pci_map *pm); struct pcicfg_vpd *pci_fetch_vpd_list(device_t dev);