git: bb5b19a12c61 - stable/12 - 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:32:02 UTC
The branch stable/12 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=bb5b19a12c611a8a53b24def420f98ab10c262fe commit bb5b19a12c611a8a53b24def420f98ab10c262fe 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:40:10 +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 e793c435189b..9a49d4ca9783 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -3120,6 +3120,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 b3126ad8dc51..0e1c5e3c8e36 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -705,6 +705,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);