Received: from [140.186.70.92] (port=47908 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYNxc-0001aV-Li for qemu-devel@nongnu.org; Mon, 12 Jul 2010 14:42:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OYNxb-0006Rp-E1 for qemu-devel@nongnu.org; Mon, 12 Jul 2010 14:42:36 -0400 Received: from mail-pv0-f173.google.com ([74.125.83.173]:51784) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OYNxb-0006Rh-9b for qemu-devel@nongnu.org; Mon, 12 Jul 2010 14:42:35 -0400 Received: by pvg7 with SMTP id 7so1958616pvg.4 for ; Mon, 12 Jul 2010 11:42:34 -0700 (PDT) MIME-Version: 1.0 From: Blue Swirl Date: Mon, 12 Jul 2010 18:42:14 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: [Qemu-devel] [PATCH 14/15] usb-uhci: 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/usb-uhci.c | 31 +++++++++++++++---------------- 1 files changed, 15 insertions(+), 16 deletions(-) diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index 1d83400..2e1f5ee 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -1088,23 +1088,22 @@ static void uhci_frame_timer(void *opaque) qemu_mod_timer(s->frame_timer, s->expire_time); } -static void uhci_map(PCIDevice *pci_dev, int region_num, - pcibus_t addr, pcibus_t size, int type) -{ - UHCIState *s = (UHCIState *)pci_dev; - - register_ioport_write(addr, 32, 2, uhci_ioport_writew, s); - register_ioport_read(addr, 32, 2, uhci_ioport_readw, s); - register_ioport_write(addr, 32, 4, uhci_ioport_writel, s); - register_ioport_read(addr, 32, 4, uhci_ioport_readl, s); - register_ioport_write(addr, 32, 1, uhci_ioport_writeb, s); - register_ioport_read(addr, 32, 1, uhci_ioport_readb, s); -} +static IOPortWriteFunc * const uhci_io_writes[] = { + uhci_ioport_writeb, + uhci_ioport_writew, + uhci_ioport_writel, +}; + +static IOPortReadFunc * const uhci_io_reads[] = { + uhci_ioport_readb, + uhci_ioport_readw, + uhci_ioport_readl, +}; static int usb_uhci_common_initfn(UHCIState *s) { uint8_t *pci_conf = s->dev.config; - int i; + int i, io_index; pci_conf[PCI_REVISION_ID] = 0x01; // revision number pci_conf[PCI_CLASS_PROG] = 0x00; @@ -1126,9 +1125,9 @@ static int usb_uhci_common_initfn(UHCIState *s) /* Use region 4 for consistency with real hardware. BSD guests seem to rely on this. */ - pci_register_bar(&s->dev, 4, 0x20, - PCI_BASE_ADDRESS_SPACE_IO, uhci_map); - + pci_register_bar(&s->dev, 4, 0x20, PCI_BASE_ADDRESS_SPACE_IO, NULL); + io_index = cpu_register_io(uhci_io_reads, uhci_io_writes, 32, s); + pci_bar_map(&s->dev, 4, 0, 0, 32, io_index); return 0; } -- 1.7.1