diff mbox

[12/15] rtl8139: convert to pci_bar_map

Message ID AANLkTikpzFRktoB3CySnnQ0E3JO_c05amuMg-sTGN2f1@mail.gmail.com
State New
Headers show

Commit Message

Blue Swirl July 12, 2010, 6:41 p.m. UTC
Use pci_bar_map() instead of a mapping function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 hw/rtl8139.c |   42 ++++++++++++++++--------------------------
 1 files changed, 16 insertions(+), 26 deletions(-)
diff mbox

Patch

diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 441f0a9..18721dd 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -3269,28 +3269,17 @@  static const VMStateDescription vmstate_rtl8139 = {
 /***********************************************************/
 /* PCI RTL8139 definitions */

-static void rtl8139_mmio_map(PCIDevice *pci_dev, int region_num,
-                       pcibus_t addr, pcibus_t size, int type)
-{
-    RTL8139State *s = DO_UPCAST(RTL8139State, dev, pci_dev);
-
-    cpu_register_physical_memory(addr + 0, 0x100, s->rtl8139_mmio_io_addr);
-}
-
-static void rtl8139_ioport_map(PCIDevice *pci_dev, int region_num,
-                       pcibus_t addr, pcibus_t size, int type)
-{
-    RTL8139State *s = DO_UPCAST(RTL8139State, dev, pci_dev);
-
-    register_ioport_write(addr, 0x100, 1, rtl8139_ioport_writeb, s);
-    register_ioport_read( addr, 0x100, 1, rtl8139_ioport_readb,  s);
-
-    register_ioport_write(addr, 0x100, 2, rtl8139_ioport_writew, s);
-    register_ioport_read( addr, 0x100, 2, rtl8139_ioport_readw,  s);
+static IOPortWriteFunc * const rtl8139_io_writes[] = {
+    rtl8139_ioport_writeb,
+    rtl8139_ioport_writew,
+    rtl8139_ioport_writel,
+};

-    register_ioport_write(addr, 0x100, 4, rtl8139_ioport_writel, s);
-    register_ioport_read( addr, 0x100, 4, rtl8139_ioport_readl,  s);
-}
+static IOPortReadFunc * const rtl8139_io_reads[] = {
+    rtl8139_ioport_readb,
+    rtl8139_ioport_readw,
+    rtl8139_ioport_readl,
+};

 static CPUReadMemoryFunc * const rtl8139_mmio_read[3] = {
     rtl8139_mmio_readb,
@@ -3353,6 +3342,7 @@  static int pci_rtl8139_init(PCIDevice *dev)
 {
     RTL8139State * s = DO_UPCAST(RTL8139State, dev, dev);
     uint8_t *pci_conf;
+    int io_index;

     pci_conf = s->dev.config;
     pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_REALTEK);
@@ -3371,11 +3361,11 @@  static int pci_rtl8139_init(PCIDevice *dev)
     s->rtl8139_mmio_io_addr =
         cpu_register_io_memory(rtl8139_mmio_read, rtl8139_mmio_write, s);

-    pci_register_bar(&s->dev, 0, 0x100,
-                           PCI_BASE_ADDRESS_SPACE_IO,  rtl8139_ioport_map);
-
-    pci_register_bar(&s->dev, 1, 0x100,
-                           PCI_BASE_ADDRESS_SPACE_MEMORY, rtl8139_mmio_map);
+    pci_register_bar(&s->dev, 0, 0x100, PCI_BASE_ADDRESS_SPACE_IO, NULL);
+    io_index = cpu_register_io(rtl8139_io_reads, rtl8139_io_writes, 0x100, s);
+    pci_bar_map(&s->dev, 0, 0, 0, 0x100, io_index);
+    pci_register_bar(&s->dev, 1, 0x100, PCI_BASE_ADDRESS_SPACE_MEMORY, NULL);
+    pci_bar_map(&s->dev, 1, 0, 0, 0x100, s->rtl8139_mmio_io_addr);

     qemu_macaddr_default_if_unset(&s->conf.macaddr);