From patchwork Mon Oct 24 21:03:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Canet X-Patchwork-Id: 121449 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 DA6751007D7 for ; Tue, 25 Oct 2011 09:47:30 +1100 (EST) Received: from localhost ([::1]:55168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIRfb-0004K1-41 for incoming@patchwork.ozlabs.org; Mon, 24 Oct 2011 17:02:55 -0400 Received: from eggs.gnu.org ([140.186.70.92]:48795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIRei-0002cn-Ec for qemu-devel@nongnu.org; Mon, 24 Oct 2011 17:02:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RIReg-0001Hk-RC for qemu-devel@nongnu.org; Mon, 24 Oct 2011 17:02:00 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:60680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIReg-0001G0-6w for qemu-devel@nongnu.org; Mon, 24 Oct 2011 17:01:58 -0400 Received: by mail-wy0-f173.google.com with SMTP id 15so7513712wyh.4 for ; Mon, 24 Oct 2011 14:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=z/xL4OHmEsTXNcH/clwImMj/BHtuPZU+5bDKV1LjZPA=; b=T2kCrJnPf8/COAyrWa3xdLtWC4ZtEa3MBBZU4aj0qq0/0RatLOAHdSSE9Ibod0zUL6 4ze4cFDgviWyT/b3lQudpDeBo3x69BT5BM7+t/H/XV9tguAY2bFrUmgYbzSqgLE072i8 aYZH5UXP819EwfOYwBNlxc2nBq9Kp7p9WWPl8= Received: by 10.227.36.229 with SMTP id u37mr4317212wbd.21.1319490117424; Mon, 24 Oct 2011 14:01:57 -0700 (PDT) Received: from localhost.localdomain ([78.250.84.36]) by mx.google.com with ESMTPS id x40sm34963853wbn.19.2011.10.24.14.01.54 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Oct 2011 14:01:56 -0700 (PDT) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Mon, 24 Oct 2011 23:03:32 +0200 Message-Id: <1319490221-5854-8-git-send-email-benoit.canet@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1319490221-5854-1-git-send-email-benoit.canet@gmail.com> References: <1319490221-5854-1-git-send-email-benoit.canet@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.173 Cc: peter.maydell@linaro.org, =?UTF-8?q?Beno=C3=AEt=20Canet?= Subject: [Qemu-devel] [PATCH 06/15] syborg_pointer: 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: Benoit Canet --- hw/syborg_pointer.c | 28 +++++++++++----------------- 1 files changed, 11 insertions(+), 17 deletions(-) diff --git a/hw/syborg_pointer.c b/hw/syborg_pointer.c index b91214d..a0f8b32 100644 --- a/hw/syborg_pointer.c +++ b/hw/syborg_pointer.c @@ -44,6 +44,7 @@ typedef struct { typedef struct { SysBusDevice busdev; + MemoryRegion iomem; int int_enabled; uint32_t fifo_size; event_data *event_fifo; @@ -57,7 +58,8 @@ static void syborg_pointer_update(SyborgPointerState *s) qemu_set_irq(s->irq, s->read_count && s->int_enabled); } -static uint32_t syborg_pointer_read(void *opaque, target_phys_addr_t offset) +static uint64_t syborg_pointer_read(void *opaque, target_phys_addr_t offset, + unsigned size) { SyborgPointerState *s = (SyborgPointerState *)opaque; @@ -87,7 +89,7 @@ static uint32_t syborg_pointer_read(void *opaque, target_phys_addr_t offset) } static void syborg_pointer_write(void *opaque, target_phys_addr_t offset, - uint32_t value) + uint64_t value, unsigned size) { SyborgPointerState *s = (SyborgPointerState *)opaque; @@ -110,16 +112,10 @@ static void syborg_pointer_write(void *opaque, target_phys_addr_t offset, syborg_pointer_update(s); } -static CPUReadMemoryFunc * const syborg_pointer_readfn[] = { - syborg_pointer_read, - syborg_pointer_read, - syborg_pointer_read -}; - -static CPUWriteMemoryFunc * const syborg_pointer_writefn[] = { - syborg_pointer_write, - syborg_pointer_write, - syborg_pointer_write +static const MemoryRegionOps syborg_pointer_ops = { + .read = syborg_pointer_read, + .write = syborg_pointer_write, + .endianness = DEVICE_NATIVE_ENDIAN, }; static void syborg_pointer_event(void *opaque, int dx, int dy, int dz, @@ -186,13 +182,11 @@ static const VMStateDescription vmstate_syborg_pointer = { static int syborg_pointer_init(SysBusDevice *dev) { SyborgPointerState *s = FROM_SYSBUS(SyborgPointerState, dev); - int iomemtype; sysbus_init_irq(dev, &s->irq); - iomemtype = cpu_register_io_memory(syborg_pointer_readfn, - syborg_pointer_writefn, s, - DEVICE_NATIVE_ENDIAN); - sysbus_init_mmio(dev, 0x1000, iomemtype); + memory_region_init_io(&s->iomem, &syborg_pointer_ops, s, + "pointer", 0x1000); + sysbus_init_mmio_region(dev, &s->iomem); if (s->fifo_size <= 0) { fprintf(stderr, "syborg_pointer: fifo too small\n");