From patchwork Sun Oct 30 14:33:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 122632 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 8246BB6F7E for ; Mon, 31 Oct 2011 02:27:01 +1100 (EST) Received: from localhost ([::1]:58786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWTF-00074D-6Q for incoming@patchwork.ozlabs.org; Sun, 30 Oct 2011 10:34:45 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWSm-0006EW-Ms for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RKWSg-0003tv-E0 for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1429) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWSf-0003tI-Vp for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:10 -0400 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 p9UEY9Fj019151 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 30 Oct 2011 10:34:09 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9UEY5JG028992 for ; Sun, 30 Oct 2011 10:34:08 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 8DF94250BA4; Sun, 30 Oct 2011 16:34:01 +0200 (IST) From: Avi Kivity To: qemu-devel@nongnu.org Date: Sun, 30 Oct 2011 16:33:50 +0200 Message-Id: <1319985234-32371-14-git-send-email-avi@redhat.com> In-Reply-To: <1319985234-32371-1-git-send-email-avi@redhat.com> References: <1319985234-32371-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 13/17] pl061: 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/pl061.c | 27 ++++++++++----------------- 1 files changed, 10 insertions(+), 17 deletions(-) diff --git a/hw/pl061.c b/hw/pl061.c index d13746c..ce139cd 100644 --- a/hw/pl061.c +++ b/hw/pl061.c @@ -30,6 +30,7 @@ typedef struct { SysBusDevice busdev; + MemoryRegion iomem; uint32_t locked; uint32_t data; uint32_t old_data; @@ -112,7 +113,8 @@ static void pl061_update(pl061_state *s) /* FIXME: Implement input interrupts. */ } -static uint32_t pl061_read(void *opaque, target_phys_addr_t offset) +static uint64_t pl061_read(void *opaque, target_phys_addr_t offset, + unsigned size) { pl061_state *s = (pl061_state *)opaque; @@ -168,7 +170,7 @@ static uint32_t pl061_read(void *opaque, target_phys_addr_t offset) } static void pl061_write(void *opaque, target_phys_addr_t offset, - uint32_t value) + uint64_t value, unsigned size) { pl061_state *s = (pl061_state *)opaque; uint8_t mask; @@ -262,27 +264,18 @@ static void pl061_set_irq(void * opaque, int irq, int level) } } -static CPUReadMemoryFunc * const pl061_readfn[] = { - pl061_read, - pl061_read, - pl061_read -}; - -static CPUWriteMemoryFunc * const pl061_writefn[] = { - pl061_write, - pl061_write, - pl061_write +static const MemoryRegionOps pl061_ops = { + .read = pl061_read, + .write = pl061_write, + .endianness = DEVICE_NATIVE_ENDIAN, }; static int pl061_init(SysBusDevice *dev, const unsigned char *id) { - int iomemtype; pl061_state *s = FROM_SYSBUS(pl061_state, dev); s->id = id; - iomemtype = cpu_register_io_memory(pl061_readfn, - pl061_writefn, s, - DEVICE_NATIVE_ENDIAN); - sysbus_init_mmio(dev, 0x1000, iomemtype); + memory_region_init_io(&s->iomem, &pl061_ops, s, "pl061", 0x1000); + sysbus_init_mmio_region(dev, &s->iomem); sysbus_init_irq(dev, &s->irq); qdev_init_gpio_in(&dev->qdev, pl061_set_irq, 8); qdev_init_gpio_out(&dev->qdev, s->out, 8);