From patchwork Thu Jan 3 14:09:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 209256 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 480A02C0089 for ; Fri, 4 Jan 2013 01:10:00 +1100 (EST) Received: from localhost ([::1]:47302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqlUc-0005Ih-Bg for incoming@patchwork.ozlabs.org; Thu, 03 Jan 2013 09:09:58 -0500 Received: from eggs.gnu.org ([208.118.235.92]:44155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqlUT-0005Ia-1l for qemu-devel@nongnu.org; Thu, 03 Jan 2013 09:09:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TqlUO-00029a-1U for qemu-devel@nongnu.org; Thu, 03 Jan 2013 09:09:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqlUN-00029V-PA for qemu-devel@nongnu.org; Thu, 03 Jan 2013 09:09:43 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r03E9gTX009932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Jan 2013 09:09:43 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-25.ams2.redhat.com [10.36.116.25]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r03E9dro013107; Thu, 3 Jan 2013 09:09:40 -0500 Message-ID: <50E59122.3010101@redhat.com> Date: Thu, 03 Jan 2013 15:09:38 +0100 From: Gerd Hoffmann User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121116 Thunderbird/10.0.11 MIME-Version: 1.0 To: =?UTF-8?B?SGVydsOpIFBvdXNzaW5lYXU=?= References: <1356276769-7357-1-git-send-email-hpoussin@reactos.org> <1356276769-7357-4-git-send-email-hpoussin@reactos.org> In-Reply-To: <1356276769-7357-4-git-send-email-hpoussin@reactos.org> X-Enigmail-Version: 1.4 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [RFC 3/8] uhci: do not use old_portio-style callbacks 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 On 12/23/12 16:32, Hervé Poussineau wrote: > -static const MemoryRegionPortio uhci_portio[] = { > - { 0, 32, 2, .write = uhci_ioport_writew, }, > - { 0, 32, 2, .read = uhci_ioport_readw, }, > - { 0, 32, 4, .write = uhci_ioport_writel, }, > - { 0, 32, 4, .read = uhci_ioport_readl, }, > - { 0, 32, 1, .write = uhci_ioport_writeb, }, > - { 0, 32, 1, .read = uhci_ioport_readb, }, > - PORTIO_END_OF_LIST() > -}; > +static uint64_t uhci_ioport_read(void *opaque, hwaddr addr, unsigned int size) > +{ > + switch (size) { > + case 1: > + return uhci_ioport_readb(opaque, (uint32_t)addr); > + case 2: > + return uhci_ioport_readw(opaque, (uint32_t)addr); > + case 4: > + return uhci_ioport_readl(opaque, (uint32_t)addr); > + default: > + return ~0UL; > + } > +} Aaaargh. Please don't. Offloading the size handling to the memory api is better. See attached patch. cheers, Gerd From 3f5810004dad2ef67cf067d96cf0b983166a454f Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 3 Jan 2013 12:29:41 +0100 Subject: [PATCH] uhci: stop using portio lists Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-uhci.c | 106 +++++++++++++++-------------------------------------- trace-events | 2 - 2 files changed, 30 insertions(+), 78 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 0cd68cf..60645aa 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -461,40 +461,11 @@ static const VMStateDescription vmstate_uhci = { } }; -static void uhci_ioport_writeb(void *opaque, uint32_t addr, uint32_t val) +static void uhci_port_write(void *opaque, hwaddr addr, + uint64_t val, unsigned size) { UHCIState *s = opaque; - addr &= 0x1f; - switch(addr) { - case 0x0c: - s->sof_timing = val; - break; - } -} - -static uint32_t uhci_ioport_readb(void *opaque, uint32_t addr) -{ - UHCIState *s = opaque; - uint32_t val; - - addr &= 0x1f; - switch(addr) { - case 0x0c: - val = s->sof_timing; - break; - default: - val = 0xff; - break; - } - return val; -} - -static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val) -{ - UHCIState *s = opaque; - - addr &= 0x1f; trace_usb_uhci_mmio_writew(addr, val); switch(addr) { @@ -543,6 +514,17 @@ static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val) if (s->status & UHCI_STS_HCHALTED) s->frnum = val & 0x7ff; break; + case 0x08: + s->fl_base_addr &= 0xffff0000; + s->fl_base_addr |= val & ~0xfff; + break; + case 0x0a: + s->fl_base_addr &= 0x0000ffff; + s->fl_base_addr |= (val << 16); + break; + case 0x0c: + s->sof_timing = val & 0xff; + break; case 0x10 ... 0x1f: { UHCIPort *port; @@ -574,12 +556,11 @@ static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val) } } -static uint32_t uhci_ioport_readw(void *opaque, uint32_t addr) +static uint64_t uhci_port_read(void *opaque, hwaddr addr, unsigned size) { UHCIState *s = opaque; uint32_t val; - addr &= 0x1f; switch(addr) { case 0x00: val = s->cmd; @@ -593,6 +574,15 @@ static uint32_t uhci_ioport_readw(void *opaque, uint32_t addr) case 0x06: val = s->frnum; break; + case 0x08: + val = s->fl_base_addr & 0xffff; + break; + case 0x0a: + val = (s->fl_base_addr >> 16) & 0xffff; + break; + case 0x0c: + val = s->sof_timing; + break; case 0x10 ... 0x1f: { UHCIPort *port; @@ -615,38 +605,6 @@ static uint32_t uhci_ioport_readw(void *opaque, uint32_t addr) return val; } -static void uhci_ioport_writel(void *opaque, uint32_t addr, uint32_t val) -{ - UHCIState *s = opaque; - - addr &= 0x1f; - trace_usb_uhci_mmio_writel(addr, val); - - switch(addr) { - case 0x08: - s->fl_base_addr = val & ~0xfff; - break; - } -} - -static uint32_t uhci_ioport_readl(void *opaque, uint32_t addr) -{ - UHCIState *s = opaque; - uint32_t val; - - addr &= 0x1f; - switch(addr) { - case 0x08: - val = s->fl_base_addr; - break; - default: - val = 0xffffffff; - break; - } - trace_usb_uhci_mmio_readl(addr, val); - return val; -} - /* signal resume if controller suspended */ static void uhci_resume (void *opaque) { @@ -1236,18 +1194,14 @@ static void uhci_frame_timer(void *opaque) qemu_mod_timer(s->frame_timer, t_now + frame_t); } -static const MemoryRegionPortio uhci_portio[] = { - { 0, 32, 2, .write = uhci_ioport_writew, }, - { 0, 32, 2, .read = uhci_ioport_readw, }, - { 0, 32, 4, .write = uhci_ioport_writel, }, - { 0, 32, 4, .read = uhci_ioport_readl, }, - { 0, 32, 1, .write = uhci_ioport_writeb, }, - { 0, 32, 1, .read = uhci_ioport_readb, }, - PORTIO_END_OF_LIST() -}; - static const MemoryRegionOps uhci_ioport_ops = { - .old_portio = uhci_portio, + .read = uhci_port_read, + .write = uhci_port_write, + .valid.min_access_size = 1, + .valid.max_access_size = 4, + .impl.min_access_size = 2, + .impl.max_access_size = 2, + .endianness = DEVICE_LITTLE_ENDIAN, }; static USBPortOps uhci_port_ops = { diff --git a/trace-events b/trace-events index 4b061c6..f68e03b 100644 --- a/trace-events +++ b/trace-events @@ -307,8 +307,6 @@ usb_uhci_frame_loop_stop_idle(void) "" usb_uhci_frame_loop_continue(void) "" usb_uhci_mmio_readw(uint32_t addr, uint32_t val) "addr 0x%04x, ret 0x%04x" usb_uhci_mmio_writew(uint32_t addr, uint32_t val) "addr 0x%04x, val 0x%04x" -usb_uhci_mmio_readl(uint32_t addr, uint32_t val) "addr 0x%04x, ret 0x%08x" -usb_uhci_mmio_writel(uint32_t addr, uint32_t val) "addr 0x%04x, val 0x%08x" usb_uhci_queue_add(uint32_t token) "token 0x%x" usb_uhci_queue_del(uint32_t token, const char *reason) "token 0x%x: %s" usb_uhci_packet_add(uint32_t token, uint32_t addr) "token 0x%x, td 0x%x"