From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47750 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYNxD-0001J2-OK for qemu-devel@nongnu.org; Mon, 12 Jul 2010 14:42:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OYNxC-0006Mi-FE for qemu-devel@nongnu.org; Mon, 12 Jul 2010 14:42:11 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:62569) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OYNxC-0006Mc-8P for qemu-devel@nongnu.org; Mon, 12 Jul 2010 14:42:10 -0400 Received: by pzk10 with SMTP id 10so1295258pzk.4 for ; Mon, 12 Jul 2010 11:42:09 -0700 (PDT) MIME-Version: 1.0 From: Blue Swirl Date: Mon, 12 Jul 2010 18:41:49 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: [Qemu-devel] [PATCH 12/15] rtl8139: convert to pci_bar_map List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel , Anthony Liguori , "Michael S. Tsirkin" Use pci_bar_map() instead of a mapping function. Signed-off-by: Blue Swirl --- hw/rtl8139.c | 42 ++++++++++++++++-------------------------- 1 files changed, 16 insertions(+), 26 deletions(-) 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); -- 1.7.1