From patchwork Sun Oct 2 14:26:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 117306 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]) by ozlabs.org (Postfix) with ESMTP id E1696B6F77 for ; Mon, 3 Oct 2011 01:34:08 +1100 (EST) Received: from localhost ([::1]:56666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAN2O-0002uN-K6 for incoming@patchwork.ozlabs.org; Sun, 02 Oct 2011 10:29:04 -0400 Received: from eggs.gnu.org ([140.186.70.92]:51281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAN0r-0007Db-KA for qemu-devel@nongnu.org; Sun, 02 Oct 2011 10:27:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RAN0h-0008DV-2F for qemu-devel@nongnu.org; Sun, 02 Oct 2011 10:27:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55797) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAN0e-0008Br-NF for qemu-devel@nongnu.org; Sun, 02 Oct 2011 10:27:17 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p92EREvH030657 (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-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p92ERBq8004349; Sun, 2 Oct 2011 10:27:14 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 1D5B0250B75; 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:51 +0200 Message-Id: <1317565616-12997-21-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.23 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 20/25] milkymist-pfpu: 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-pfpu.c | 33 ++++++++++++++++----------------- 1 files changed, 16 insertions(+), 17 deletions(-) diff --git a/hw/milkymist-pfpu.c b/hw/milkymist-pfpu.c index 306d1ce..672f6e4 100644 --- a/hw/milkymist-pfpu.c +++ b/hw/milkymist-pfpu.c @@ -118,6 +118,7 @@ enum { struct MilkymistPFPUState { SysBusDevice busdev; + MemoryRegion regs_region; CharDriverState *chr; qemu_irq irq; @@ -379,7 +380,8 @@ static inline int get_microcode_address(MilkymistPFPUState *s, uint32_t addr) return (512 * s->regs[R_CODEPAGE]) + addr - MICROCODE_BEGIN; } -static uint32_t pfpu_read(void *opaque, target_phys_addr_t addr) +static uint64_t pfpu_read(void *opaque, target_phys_addr_t addr, + unsigned size) { MilkymistPFPUState *s = opaque; uint32_t r = 0; @@ -418,8 +420,8 @@ static uint32_t pfpu_read(void *opaque, target_phys_addr_t addr) return r; } -static void -pfpu_write(void *opaque, target_phys_addr_t addr, uint32_t value) +static void pfpu_write(void *opaque, target_phys_addr_t addr, uint64_t value, + unsigned size) { MilkymistPFPUState *s = opaque; @@ -459,16 +461,14 @@ static uint32_t pfpu_read(void *opaque, target_phys_addr_t addr) } } -static CPUReadMemoryFunc * const pfpu_read_fn[] = { - NULL, - NULL, - &pfpu_read, -}; - -static CPUWriteMemoryFunc * const pfpu_write_fn[] = { - NULL, - NULL, - &pfpu_write, +static const MemoryRegionOps pfpu_mmio_ops = { + .read = pfpu_read, + .write = pfpu_write, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, + .endianness = DEVICE_NATIVE_ENDIAN, }; static void milkymist_pfpu_reset(DeviceState *d) @@ -494,13 +494,12 @@ static void milkymist_pfpu_reset(DeviceState *d) static int milkymist_pfpu_init(SysBusDevice *dev) { MilkymistPFPUState *s = FROM_SYSBUS(typeof(*s), dev); - int pfpu_regs; sysbus_init_irq(dev, &s->irq); - pfpu_regs = cpu_register_io_memory(pfpu_read_fn, pfpu_write_fn, s, - DEVICE_NATIVE_ENDIAN); - sysbus_init_mmio(dev, MICROCODE_END * 4, pfpu_regs); + memory_region_init_io(&s->regs_region, &pfpu_mmio_ops, s, + "milkymist-pfpu", MICROCODE_END * 4); + sysbus_init_mmio_region(dev, &s->regs_region); return 0; }