On Thu, Oct 20, 2016 at 03:30:32PM +0200, Andrew Jones wrote: [...] > > +static void pci_cap_walk(pci_dev *dev) > > +{ > > + uint8_t cap_offset; > > + uint8_t cap_id; > > + > > + cap_offset = pci_config_readb(dev->pci_addr, PCI_CAPABILITY_LIST); > > + while (cap_offset) { > > + cap_id = pci_config_readb(dev->pci_addr, cap_offset); > > + printf("PCI detected cap 0x%x\n", cap_id); > > + if (cap_handlers[cap_id]) { > > + cap_handlers[cap_id](dev, cap_offset); > > + } > > nit: no need for {} Will fix. [...] > > @@ -49,6 +107,7 @@ int pci_dev_init(pci_dev *dev, uint16_t vendor_id, uint16_t device_id) > > dev->inited = true; > > > > pci_set_master(dev, 1); > > + pci_cap_walk(dev); > > again, not sure we want this in the one and only init function I'll put it into the new pci_enable_defaults(). > > > > > return 0; > > } > > diff --git a/lib/pci.h b/lib/pci.h > > index 6a1c3c9..5581446 100644 > > --- a/lib/pci.h > > +++ b/lib/pci.h > > @@ -27,6 +27,7 @@ enum { > > struct pci_dev { > > bool inited; > > uint16_t pci_addr; > > + uint16_t msi_offset; > > phys_addr_t pci_bar[PCI_BAR_NUM]; > > }; > > typedef struct pci_dev pci_dev; > > @@ -35,6 +36,7 @@ int pci_dev_init(pci_dev *dev, uint16_t vendor_id, uint16_t device_id); > > phys_addr_t pci_bar_addr(pci_dev *dev, int bar_num); > > bool pci_bar_is_memory(pci_dev *dev, int bar_num); > > bool pci_bar_is_valid(pci_dev *dev, int bar_num); > > +void pci_setup_msi(pci_dev *dev, uint64_t msi_addr, uint32_t msi_data); > > > > /* > > * pci-testdev is a driver for the pci-testdev qemu pci device. The > > -- > > 2.7.4 > > > > Looks good from my not knowing much about PCI perspective. Thanks for review! -- peterx -- 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