@@ -2,6 +2,7 @@
#define __PCI_H
#include "types.h" // u32
+#include "pci_regs.h" // PCI_CAPABILITY_LIST et al.
static inline u8 pci_bdf_to_bus(u16 bdf) {
return bdf >> 8;
@@ -52,6 +53,10 @@ int pci_next(int bdf, int *pmax);
for (MAX=0x0100, BDF=pci_next(0, &MAX) \
; BDF >= 0 \
; BDF=pci_next(BDF+1, &MAX))
+#define foreachcap(BDF, PTR, CAP) \
+ for (PTR = PCI_CAPABILITY_LIST, CAP = pci_config_readb(BDF, PTR); \
+ CAP; \
+ PTR = CAP + PCI_CAP_LIST_NEXT, CAP = pci_config_readb(BDF, PTR))
#define foreachpci_in_bus(BDF, MAX, BUS) \
for (MAX = pci_bus_devfn_to_bdf(BUS, 0) + 0x0100, \