From patchwork Sun Oct 2 14:26:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 117320 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 AAB5EB6F76 for ; Mon, 3 Oct 2011 02:36:40 +1100 (EST) Received: from localhost ([::1]:52999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAN1h-00011A-M7 for incoming@patchwork.ozlabs.org; Sun, 02 Oct 2011 10:28:21 -0400 Received: from eggs.gnu.org ([140.186.70.92]:51217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAN0j-00073y-Tq for qemu-devel@nongnu.org; Sun, 02 Oct 2011 10:27:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RAN0f-0008Co-8H for qemu-devel@nongnu.org; Sun, 02 Oct 2011 10:27:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60935) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAN0e-0008Bl-HJ for qemu-devel@nongnu.org; Sun, 02 Oct 2011 10:27:16 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p92EREj5030653 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 2 Oct 2011 10:27:14 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p92ERAfl021850; Sun, 2 Oct 2011 10:27:13 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 18F96250B73; Sun, 2 Oct 2011 16:27:05 +0200 (IST) From: Avi Kivity To: qemu-devel@nongnu.org, Anthony Liguori Date: Sun, 2 Oct 2011 16:26:49 +0200 Message-Id: <1317565616-12997-19-git-send-email-avi@redhat.com> In-Reply-To: <1317565616-12997-1-git-send-email-avi@redhat.com> References: <1317565616-12997-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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 18/25] milkymist-hpdmc: 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 From: Michael Walle Signed-off-by: Michael Walle Signed-off-by: Avi Kivity --- hw/milkymist-hpdmc.c | 32 ++++++++++++++++---------------- 1 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/milkymist-hpdmc.c b/hw/milkymist-hpdmc.c index c0962fb..17c840f 100644 --- a/hw/milkymist-hpdmc.c +++ b/hw/milkymist-hpdmc.c @@ -42,12 +42,14 @@ enum { struct MilkymistHpdmcState { SysBusDevice busdev; + MemoryRegion regs_region; uint32_t regs[R_MAX]; }; typedef struct MilkymistHpdmcState MilkymistHpdmcState; -static uint32_t hpdmc_read(void *opaque, target_phys_addr_t addr) +static uint64_t hpdmc_read(void *opaque, target_phys_addr_t addr, + unsigned size) { MilkymistHpdmcState *s = opaque; uint32_t r = 0; @@ -72,7 +74,8 @@ static uint32_t hpdmc_read(void *opaque, target_phys_addr_t addr) return r; } -static void hpdmc_write(void *opaque, target_phys_addr_t addr, uint32_t value) +static void hpdmc_write(void *opaque, target_phys_addr_t addr, uint64_t value, + unsigned size) { MilkymistHpdmcState *s = opaque; @@ -96,16 +99,14 @@ static void hpdmc_write(void *opaque, target_phys_addr_t addr, uint32_t value) } } -static CPUReadMemoryFunc * const hpdmc_read_fn[] = { - NULL, - NULL, - &hpdmc_read, -}; - -static CPUWriteMemoryFunc * const hpdmc_write_fn[] = { - NULL, - NULL, - &hpdmc_write, +static const MemoryRegionOps hpdmc_mmio_ops = { + .read = hpdmc_read, + .write = hpdmc_write, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, + .endianness = DEVICE_NATIVE_ENDIAN, }; static void milkymist_hpdmc_reset(DeviceState *d) @@ -125,11 +126,10 @@ static void milkymist_hpdmc_reset(DeviceState *d) static int milkymist_hpdmc_init(SysBusDevice *dev) { MilkymistHpdmcState *s = FROM_SYSBUS(typeof(*s), dev); - int hpdmc_regs; - hpdmc_regs = cpu_register_io_memory(hpdmc_read_fn, hpdmc_write_fn, s, - DEVICE_NATIVE_ENDIAN); - sysbus_init_mmio(dev, R_MAX * 4, hpdmc_regs); + memory_region_init_io(&s->regs_region, &hpdmc_mmio_ops, s, + "milkymist-hpdmc", R_MAX * 4); + sysbus_init_mmio_region(dev, &s->regs_region); return 0; }