From patchwork Sun Jul 17 11:14:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 105045 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3AFF8B6F7A for ; Sun, 17 Jul 2011 23:24:12 +1000 (EST) Received: from localhost ([::1]:46042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QiRKK-0007rs-CS for incoming@patchwork.ozlabs.org; Sun, 17 Jul 2011 09:24:08 -0400 Received: from eggs.gnu.org ([140.186.70.92]:42890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QiPJ5-0005Zx-U2 for qemu-devel@nongnu.org; Sun, 17 Jul 2011 07:14:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QiPIv-0007kC-Tj for qemu-devel@nongnu.org; Sun, 17 Jul 2011 07:14:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23204) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QiPIu-0007h1-Mx for qemu-devel@nongnu.org; Sun, 17 Jul 2011 07:14:32 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6HBEWuY002317 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 17 Jul 2011 07:14:32 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6HBEUNh006963; Sun, 17 Jul 2011 07:14:31 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 70FEBB0660; Sun, 17 Jul 2011 14:14:27 +0300 (IDT) From: Avi Kivity To: qemu-devel@nongnu.org Date: Sun, 17 Jul 2011 14:14:17 +0300 Message-Id: <1310901265-32051-51-git-send-email-avi@redhat.com> In-Reply-To: <1310901265-32051-1-git-send-email-avi@redhat.com> References: <1310901265-32051-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kvm@vger.kernel.org Subject: [Qemu-devel] [RFC v4 50/58] ehci: convert to memory API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Avi Kivity --- hw/usb-ehci.c | 36 +++++++++--------------------------- 1 files changed, 9 insertions(+), 27 deletions(-) diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index 91fb7de..076c0b2 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -371,8 +371,7 @@ struct EHCIState { PCIDevice dev; USBBus bus; qemu_irq irq; - target_phys_addr_t mem_base; - int mem; + MemoryRegion mem; int num_ports; /* properties */ @@ -2094,29 +2093,15 @@ static void ehci_frame_timer(void *opaque) qemu_mod_timer(ehci->frame_timer, expire_time); } -static CPUReadMemoryFunc *ehci_readfn[3]={ - ehci_mem_readb, - ehci_mem_readw, - ehci_mem_readl -}; -static CPUWriteMemoryFunc *ehci_writefn[3]={ - ehci_mem_writeb, - ehci_mem_writew, - ehci_mem_writel +static MemoryRegionOps ehci_mem_ops = { + .old_mmio = { + .read = { ehci_mem_readb, ehci_mem_readw, ehci_mem_readl }, + .write = { ehci_mem_writeb, ehci_mem_writew, ehci_mem_writel }, + }, + .endianness = DEVICE_LITTLE_ENDIAN, }; -static void ehci_map(PCIDevice *pci_dev, int region_num, - pcibus_t addr, pcibus_t size, int type) -{ - EHCIState *s =(EHCIState *)pci_dev; - - DPRINTF("ehci_map: region %d, addr %08" PRIx64 ", size %" PRId64 ", s->mem %08X\n", - region_num, addr, size, s->mem); - s->mem_base = addr; - cpu_register_physical_memory(addr, size, s->mem); -} - static void ehci_device_destroy(USBBus *bus, USBDevice *dev) { EHCIState *s = container_of(bus, EHCIState, bus); @@ -2215,11 +2200,8 @@ static int usb_ehci_initfn(PCIDevice *dev) qemu_register_reset(ehci_reset, s); - s->mem = cpu_register_io_memory(ehci_readfn, ehci_writefn, s, - DEVICE_LITTLE_ENDIAN); - - pci_register_bar(&s->dev, 0, MMIO_SIZE, PCI_BASE_ADDRESS_SPACE_MEMORY, - ehci_map); + memory_region_init_io(&s->mem, &ehci_mem_ops, s, "ehci", MMIO_SIZE); + pci_register_bar_region(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mem); fprintf(stderr, "*** EHCI support is under development ***\n");