x86: helper for PCI bus mastering
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 28 Oct 2013 00:16:10 +0000 (17:16 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Jan 2014 19:18:11 +0000 (11:18 -0800)
Probably every PCI device that needs to DMA will need to set this.

kern/arch/x86/pci.c
kern/arch/x86/pci.h

index 5f68878..898c58f 100644 (file)
@@ -324,3 +324,10 @@ void pcidev_print_info(struct pci_device *pcidev, int verbosity)
                }
        }
 }
+
+void pci_set_bus_master(struct pci_device *pcidev)
+{
+       pcidev_write32(pcidev, PCI_STAT_CMD_REG,
+                      pcidev_read32(pcidev, PCI_STAT_CMD_REG) |
+                      PCI_CMD_BUS_MAS);
+}
index 18c28e4..07da58f 100644 (file)
@@ -190,4 +190,7 @@ bool pci_is_membar64(uint32_t bar);
 uint32_t pci_getmembar32(uint32_t bar);
 uint32_t pci_getiobar32(uint32_t bar);
 
+/* Other common PCI functions */
+void pci_set_bus_master(struct pci_device *pcidev);
+
 #endif /* ROS_ARCH_PCI_H */