Helper function to set/clear specific bit in PCI_COMMAND register. Signed-off-by: Peter Xu <peterx@xxxxxxxxxx> --- lib/pci.c | 12 ++++++++++++ lib/pci.h | 1 + 2 files changed, 13 insertions(+) diff --git a/lib/pci.c b/lib/pci.c index c063d53..fd17ea5 100644 --- a/lib/pci.c +++ b/lib/pci.c @@ -7,6 +7,18 @@ #include "pci.h" #include "asm/pci.h" +void pci_cmd_set_clr(struct pci_dev *dev, uint16_t set, uint16_t clr) +{ + uint16_t val = pci_config_readw(dev->bdf, PCI_COMMAND); + + /* No overlap is allowed */ + assert((set & clr) == 0); + val |= set; + val &= ~clr; + + pci_config_writew(dev->bdf, PCI_COMMAND, val); +} + bool pci_dev_exists(pcidevaddr_t dev) { return (pci_config_readw(dev, PCI_VENDOR_ID) != 0xffff && diff --git a/lib/pci.h b/lib/pci.h index e452819..de15086 100644 --- a/lib/pci.h +++ b/lib/pci.h @@ -25,6 +25,7 @@ struct pci_dev { void pci_dev_init(struct pci_dev *dev, pcidevaddr_t bdf); void pci_scan_bars(struct pci_dev *dev); +void pci_cmd_set_clr(struct pci_dev *dev, uint16_t set, uint16_t clr); extern bool pci_probe(void); extern void pci_print(void); -- 2.7.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