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
This commit is contained in:
John Baldwin 2022-08-19 14:59:06 -07:00
parent baf753cc19
commit 16bedf532c
2 changed files with 17 additions and 0 deletions

View File

@ -3170,6 +3170,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)
{

View File

@ -717,6 +717,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);