From patchwork Tue Nov 22 16:32:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Benoit Canet X-Patchwork-Id: 127129 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 3419B1007D1 for ; Wed, 23 Nov 2011 03:48:16 +1100 (EST) Received: from localhost ([::1]:33834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RStHj-0005iy-3s for incoming@patchwork.ozlabs.org; Tue, 22 Nov 2011 11:33:27 -0500 Received: from eggs.gnu.org ([140.186.70.92]:53848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RStGe-0002O8-Ci for qemu-devel@nongnu.org; Tue, 22 Nov 2011 11:32:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RStGd-0003xi-7B for qemu-devel@nongnu.org; Tue, 22 Nov 2011 11:32:20 -0500 Received: from mail-ww0-f53.google.com ([74.125.82.53]:64312) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RStGc-0003vt-T9 for qemu-devel@nongnu.org; Tue, 22 Nov 2011 11:32:19 -0500 Received: by mail-ww0-f53.google.com with SMTP id 27so556451wwf.10 for ; Tue, 22 Nov 2011 08:32:18 -0800 (PST) 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 :mime-version:content-type:content-transfer-encoding; bh=N1eIA8QcBF5rXl1I21S2Za4R8pxZAGcp9+YRUwoK/dY=; b=ejGO8zBlmIteO0vX8+vPZloVgh8m5jd7nf40cnNcCO9QlZ2pehJpl3bpVMMyG11V9D MhdFWN9/jBkvSqDh5IWVwJ3uELfYuDk0zYytC+0a3JJopW+5PFANUIC0I2UjXCefElE5 jPXbTM6uiEFivFuQRhGnbURkg1PYWOzgZC344= Received: by 10.216.29.81 with SMTP id h59mr1758494wea.100.1321979538531; Tue, 22 Nov 2011 08:32:18 -0800 (PST) Received: from Laure.box.in.chocolate-blue.net ([109.190.18.76]) by mx.google.com with ESMTPS id z3sm5677843wid.11.2011.11.22.08.32.17 (version=SSLv3 cipher=OTHER); Tue, 22 Nov 2011 08:32:17 -0800 (PST) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Tue, 22 Nov 2011 17:32:02 +0100 Message-Id: <1321979527-23921-7-git-send-email-benoit.canet@gmail.com> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1321979527-23921-1-git-send-email-benoit.canet@gmail.com> References: <1321979527-23921-1-git-send-email-benoit.canet@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.53 Cc: =?UTF-8?q?Beno=C3=AEt=20Canet?= , avi@redhat.com Subject: [Qemu-devel] [PATCH v2 06/11] lm32_sys: 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: BenoƮt Canet --- hw/lm32_sys.c | 23 +++++++++-------------- 1 files changed, 9 insertions(+), 14 deletions(-) diff --git a/hw/lm32_sys.c b/hw/lm32_sys.c index e5ff962..6aa8b2e 100644 --- a/hw/lm32_sys.c +++ b/hw/lm32_sys.c @@ -47,6 +47,7 @@ enum { struct LM32SysState { SysBusDevice busdev; + MemoryRegion iomem; uint32_t base; uint32_t regs[R_MAX]; uint8_t testname[MAX_TESTNAME_LEN]; @@ -89,16 +90,12 @@ static void sys_write(void *opaque, target_phys_addr_t addr, uint32_t value) } } -static CPUReadMemoryFunc * const sys_read_fn[] = { - NULL, - NULL, - NULL, -}; - -static CPUWriteMemoryFunc * const sys_write_fn[] = { - NULL, - NULL, - &sys_write, +static const MemoryRegionOps sys_ops = { + .old_mmio = { + .read = { NULL, NULL, NULL, }, + .write = { NULL, NULL, sys_write, }, + }, + .endianness = DEVICE_NATIVE_ENDIAN, }; static void sys_reset(DeviceState *d) @@ -115,11 +112,9 @@ static void sys_reset(DeviceState *d) static int lm32_sys_init(SysBusDevice *dev) { LM32SysState *s = FROM_SYSBUS(typeof(*s), dev); - int sys_regs; - sys_regs = cpu_register_io_memory(sys_read_fn, sys_write_fn, s, - DEVICE_NATIVE_ENDIAN); - sysbus_init_mmio(dev, R_MAX * 4, sys_regs); + memory_region_init_io(&s->iomem, &sys_ops , s, "sys", R_MAX * 4); + sysbus_init_mmio_region(dev, &s->iomem); /* Note: This device is not created in the board initialization, * instead it has to be added with the -device parameter. Therefore,