[SeaBIOS] [PATCH 10/14] ohci: Convert to new PCI BAR helper functions

Kevin O'Connor kevin at koconnor.net
Wed Feb 3 05:18:53 CET 2016


Use the pci_enable_x() functions.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 src/hw/usb-ohci.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/hw/usb-ohci.c b/src/hw/usb-ohci.c
index 0c0bf60..3d55d48 100644
--- a/src/hw/usb-ohci.c
+++ b/src/hw/usb-ohci.c
@@ -268,6 +268,10 @@ free:
 static void
 ohci_controller_setup(struct pci_device *pci)
 {
+    struct ohci_regs *regs = pci_enable_membar(pci, PCI_BASE_ADDRESS_0);
+    if (!regs)
+        return;
+
     struct usb_ohci_s *cntl = malloc_tmphigh(sizeof(*cntl));
     if (!cntl) {
         warn_noalloc();
@@ -276,18 +280,13 @@ ohci_controller_setup(struct pci_device *pci)
     memset(cntl, 0, sizeof(*cntl));
     cntl->usb.pci = pci;
     cntl->usb.type = USB_TYPE_OHCI;
-
-    u16 bdf = pci->bdf;
-    u32 baseaddr = pci_config_readl(bdf, PCI_BASE_ADDRESS_0);
-    cntl->regs = (void*)(baseaddr & PCI_BASE_ADDRESS_MEM_MASK);
+    cntl->regs = regs;
 
     dprintf(1, "OHCI init on dev %02x:%02x.%x (regs=%p)\n"
-            , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)
-            , pci_bdf_to_fn(bdf), cntl->regs);
+            , pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf)
+            , pci_bdf_to_fn(pci->bdf), cntl->regs);
 
-    // Enable bus mastering and memory access.
-    pci_config_maskw(bdf, PCI_COMMAND
-                     , 0, PCI_COMMAND_MASTER|PCI_COMMAND_MEMORY);
+    pci_enable_busmaster(pci);
 
     // XXX - check for and disable SMM control?
 
-- 
2.5.0




More information about the SeaBIOS mailing list