pci_find_capability() looks up a given capability and returns its offset. This is needed by AMD IOMMU initialization code. Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@xxxxxxxxxxx> --- src/pci.c | 15 +++++++++++++++ src/pci.h | 1 + 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/src/pci.c b/src/pci.c index 944a393..57caba6 100644 --- a/src/pci.c +++ b/src/pci.c @@ -185,6 +185,21 @@ pci_find_class(u16 classid) return -1; } +int pci_find_capability(int bdf, u8 capid) +{ + int ptr, cap; + + ptr = PCI_CAPABILITY_LIST; + do { + cap = pci_config_readb(bdf, ptr); + if (pci_config_readb(bdf, cap) == capid) + return cap; + ptr = cap + PCI_CAP_LIST_NEXT; + } while (cap); + + return -1; +} + int *PCIpaths; // Build the PCI path designations. diff --git a/src/pci.h b/src/pci.h index 9869a26..bf0d1b8 100644 --- a/src/pci.h +++ b/src/pci.h @@ -46,6 +46,7 @@ void pci_config_maskw(u16 bdf, u32 addr, u16 off, u16 on); int pci_find_vga(void); int pci_find_device(u16 vendid, u16 devid); int pci_find_class(u16 classid); +int pci_find_capability(int bdf, u8 capid); #define PP_ROOT (1<<17) #define PP_PCIBRIDGE (1<<18) -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html