From patchwork Sun Oct 30 14:33:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 122636 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 B8CEAB6F72 for ; Mon, 31 Oct 2011 02:38:56 +1100 (EST) Received: from localhost ([::1]:59357 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWTY-0007Rl-Ci for incoming@patchwork.ozlabs.org; Sun, 30 Oct 2011 10:35:04 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWSm-0006DL-Ak for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RKWSg-0003uH-Kl for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13020) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWSg-0003tO-Ai for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:10 -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 p9UEY9be019155 (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-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9UEY67f003132 for ; Sun, 30 Oct 2011 10:34:09 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 928C9250BA7; Sun, 30 Oct 2011 16:34:01 +0200 (IST) From: Avi Kivity To: qemu-devel@nongnu.org Date: Sun, 30 Oct 2011 16:33:53 +0200 Message-Id: <1319985234-32371-17-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.11 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 16/17] pl181: 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/pl181.c | 26 ++++++++++---------------- 1 files changed, 10 insertions(+), 16 deletions(-) diff --git a/hw/pl181.c b/hw/pl181.c index 0943c09..e13ea8e 100644 --- a/hw/pl181.c +++ b/hw/pl181.c @@ -24,6 +24,7 @@ typedef struct { SysBusDevice busdev; + MemoryRegion iomem; SDState *card; uint32_t clock; uint32_t power; @@ -259,7 +260,8 @@ static void pl181_fifo_run(pl181_state *s) } } -static uint32_t pl181_read(void *opaque, target_phys_addr_t offset) +static uint64_t pl181_read(void *opaque, target_phys_addr_t offset, + unsigned size) { pl181_state *s = (pl181_state *)opaque; uint32_t tmp; @@ -342,7 +344,7 @@ static uint32_t pl181_read(void *opaque, target_phys_addr_t offset) } static void pl181_write(void *opaque, target_phys_addr_t offset, - uint32_t value) + uint64_t value, unsigned size) { pl181_state *s = (pl181_state *)opaque; @@ -412,16 +414,10 @@ static void pl181_write(void *opaque, target_phys_addr_t offset, pl181_update(s); } -static CPUReadMemoryFunc * const pl181_readfn[] = { - pl181_read, - pl181_read, - pl181_read -}; - -static CPUWriteMemoryFunc * const pl181_writefn[] = { - pl181_write, - pl181_write, - pl181_write +static const MemoryRegionOps pl181_ops = { + .read = pl181_read, + .write = pl181_write, + .endianness = DEVICE_NATIVE_ENDIAN, }; static void pl181_reset(void *opaque) @@ -453,13 +449,11 @@ static void pl181_reset(void *opaque) static int pl181_init(SysBusDevice *dev) { - int iomemtype; pl181_state *s = FROM_SYSBUS(pl181_state, dev); DriveInfo *dinfo; - iomemtype = cpu_register_io_memory(pl181_readfn, pl181_writefn, s, - DEVICE_NATIVE_ENDIAN); - sysbus_init_mmio(dev, 0x1000, iomemtype); + memory_region_init_io(&s->iomem, &pl181_ops, s, "pl181", 0x1000); + sysbus_init_mmio_region(dev, &s->iomem); sysbus_init_irq(dev, &s->irq[0]); sysbus_init_irq(dev, &s->irq[1]); qdev_init_gpio_out(&s->busdev.qdev, s->cardstatus, 2);