diff --git a/drivers/pci-function.cc b/drivers/pci-function.cc
index 842404b6ad42cc58e24ba8bb19b49481314b869b..29776311af7d1cde15ec06487a2c8dc84d6e2b23 100644
--- a/drivers/pci-function.cc
+++ b/drivers/pci-function.cc
@@ -104,6 +104,60 @@ namespace pci {
         return (_addr_mmio);
     }
 
+    u32 bar::readl(u32 offset)
+    {
+        if (is_pio()) {
+            return (inl(_addr_lo + offset));
+        } else {
+            return mmio_getl(_addr_mmio + offset);
+        }
+    }
+
+    u16 bar::readw(u32 offset)
+    {
+        if (is_pio()) {
+            return (inw(_addr_lo + offset));
+        } else {
+            return mmio_getw(_addr_mmio + offset);
+        }
+    }
+
+    u8 bar::readb(u32 offset)
+    {
+        if (is_pio()) {
+            return (inb(_addr_lo + offset));
+        } else {
+            return mmio_getb(_addr_mmio + offset);
+        }
+    }
+
+    void bar::writel(u32 offset, u32 val)
+    {
+        if (is_pio()) {
+            outl(val, _addr_lo + offset);
+        } else {
+            return mmio_setl(_addr_mmio + offset, val);
+        }
+    }
+
+    void bar::writew(u32 offset, u16 val)
+    {
+        if (is_pio()) {
+            outw(val, _addr_lo + offset);
+        } else {
+            return mmio_setw(_addr_mmio + offset, val);
+        }
+    }
+
+    void bar::writeb(u32 offset, u8 val)
+    {
+        if (is_pio()) {
+            outb(val, _addr_lo + offset);
+        } else {
+            return mmio_setb(_addr_mmio + offset, val);
+        }
+    }
+
     function::function(u8 bus, u8 device, u8 func)
         : _bus(bus), _device(device), _func(func), _have_msix(false), _msix_enabled(false)
     {
diff --git a/drivers/pci-function.hh b/drivers/pci-function.hh
index 5ec216134f87288b69c903a0cf6eea31d15d87d6..d540e2b7034f72c8b7ffbca57ef7c867dff70421 100644
--- a/drivers/pci-function.hh
+++ b/drivers/pci-function.hh
@@ -74,13 +74,13 @@ namespace pci {
         void unmap(void);
         mmioaddr_t get_mmio(void);
 
-        // Access the pio bar
-        u32 read(u32 offset)  { return (inl(_addr_lo + offset)); }
-        u16 readw(u32 offset) { return (inw(_addr_lo + offset)); }
-        u8  readb(u32 offset) { return (inb(_addr_lo + offset)); }
-        void write(u32 offset, u32 val) { outl(val, _addr_lo+offset); }
-        void write(u32 offset, u16 val) { outw(val, _addr_lo+offset); }
-        void write(u32 offset, u8 val)  { outb(val, _addr_lo+offset); }
+        // Access the pio or mmio bar
+        u32 readl(u32 offset);
+        u16 readw(u32 offset);
+        u8 readb(u32 offset);
+        void writel(u32 offset, u32 val);
+        void writew(u32 offset, u16 val);
+        void writeb(u32 offset, u8 val);
 
     private:
 
diff --git a/drivers/virtio.cc b/drivers/virtio.cc
index 98e7ac63be7163500af0e7779272d445e435d20f..2b22d334a374df1e7c654a1ccc5f8cd5fafc2985 100644
--- a/drivers/virtio.cc
+++ b/drivers/virtio.cc
@@ -290,7 +290,7 @@ void virtio_driver::virtio_conf_write(u32 offset, void* buf, int length)
 {
     u8* ptr = reinterpret_cast<u8*>(buf);
     for (int i=0;i<length;i++)
-        _bar1->write(offset+i, ptr[i]);
+        _bar1->writeb(offset+i, ptr[i]);
 }
 
 void virtio_driver::virtio_conf_read(u32 offset, void* buf, int length)
diff --git a/drivers/virtio.hh b/drivers/virtio.hh
index d83c2a7e8ea2396a051c5c6d648b3f48b745d6ac..89c480a1f444d7cb06aec50a16be8e3ef74d412d 100644
--- a/drivers/virtio.hh
+++ b/drivers/virtio.hh
@@ -147,10 +147,10 @@ public:
     void virtio_conf_write(u32 offset, void* buf, int length);
     u8 virtio_conf_readb(u32 offset) { return _bar1->readb(offset);};
     u16 virtio_conf_readw(u32 offset) { return _bar1->readw(offset);};
-    u32 virtio_conf_readl(u32 offset) { return _bar1->read(offset);};
-    void virtio_conf_writeb(u32 offset, u8 val) { _bar1->write(offset, val);};
-    void virtio_conf_writew(u32 offset, u16 val) { _bar1->write(offset, val);};
-    void virtio_conf_writel(u32 offset, u32 val) { _bar1->write(offset, val);};
+    u32 virtio_conf_readl(u32 offset) { return _bar1->readl(offset);};
+    void virtio_conf_writeb(u32 offset, u8 val) { _bar1->writeb(offset, val);};
+    void virtio_conf_writew(u32 offset, u16 val) { _bar1->writew(offset, val);};
+    void virtio_conf_writel(u32 offset, u32 val) { _bar1->writel(offset, val);};
 
     bool kick(int queue);
     void reset_host_side();