From patchwork Sun Oct 30 14:33:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 122629 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 150C0B6F84 for ; Mon, 31 Oct 2011 02:20:12 +1100 (EST) Received: from localhost ([::1]:58751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWT8-00073J-Ra for incoming@patchwork.ozlabs.org; Sun, 30 Oct 2011 10:34:38 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWSk-00067i-Mx for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RKWSf-0003sp-0V for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45058) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWSe-0003sB-J5 for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:08 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9UEY7qt010624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 30 Oct 2011 10:34:07 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9UEY5JC028992 for ; Sun, 30 Oct 2011 10:34:07 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 6B778250B9D; Sun, 30 Oct 2011 16:34:01 +0200 (IST) From: Avi Kivity To: qemu-devel@nongnu.org Date: Sun, 30 Oct 2011 16:33:43 +0200 Message-Id: <1319985234-32371-7-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.12 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 06/17] jazz_led: 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/jazz_led.c | 25 ++++++++++--------------- hw/mips.h | 4 +++- hw/mips_jazz.c | 2 +- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/hw/jazz_led.c b/hw/jazz_led.c index eb472a0..6fab334 100644 --- a/hw/jazz_led.c +++ b/hw/jazz_led.c @@ -43,6 +43,7 @@ } screen_state_t; typedef struct LedState { + MemoryRegion iomem; uint8_t segments; DisplayState *ds; screen_state_t state; @@ -140,16 +141,12 @@ static void led_writel(void *opaque, target_phys_addr_t addr, uint32_t val) #endif } -static CPUReadMemoryFunc * const led_read[3] = { - led_readb, - led_readw, - led_readl, -}; - -static CPUWriteMemoryFunc * const led_write[3] = { - led_writeb, - led_writew, - led_writel, +static const MemoryRegionOps led_ops = { + .old_mmio = { + .read = { led_readb, led_readw, led_readl, }, + .write = { led_writeb, led_writew, led_writel, }, + }, + .endianness = DEVICE_NATIVE_ENDIAN, }; /***********************************************************/ @@ -307,18 +304,16 @@ static void jazz_led_text_update(void *opaque, console_ch_t *chardata) dpy_update(s->ds, 0, 0, 2, 1); } -void jazz_led_init(target_phys_addr_t base) +void jazz_led_init(MemoryRegion *address_space, target_phys_addr_t base) { LedState *s; - int io; s = g_malloc0(sizeof(LedState)); s->state = REDRAW_SEGMENTS | REDRAW_BACKGROUND; - io = cpu_register_io_memory(led_read, led_write, s, - DEVICE_NATIVE_ENDIAN); - cpu_register_physical_memory(base, 1, io); + memory_region_init_io(&s->iomem, &led_ops, s, "led", 1); + memory_region_add_subregion(address_space, base, &s->iomem); s->ds = graphic_console_init(jazz_led_update_display, jazz_led_invalidate_display, diff --git a/hw/mips.h b/hw/mips.h index 6fa9a3a..0d4bf25 100644 --- a/hw/mips.h +++ b/hw/mips.h @@ -2,6 +2,8 @@ #define HW_MIPS_H /* Definitions for mips board emulation. */ +#include "memory.h" + /* gt64xxx.c */ PCIBus *gt64120_register(qemu_irq *pic); @@ -9,7 +11,7 @@ PCIBus *gt64120_register(qemu_irq *pic); PCIBus *bonito_init(qemu_irq *pic); /* jazz_led.c */ -void jazz_led_init(target_phys_addr_t base); +void jazz_led_init(MemoryRegion *address_space, target_phys_addr_t base); /* rc4030.c */ typedef struct rc4030DMAState *rc4030_dma; diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index 14beea2..6e657dd 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -287,7 +287,7 @@ static void mips_jazz_init(MemoryRegion *address_space, sysbus_mmio_map(sysbus, 0, 0x80009000); /* LED indicator */ - jazz_led_init(0x8000f000); + jazz_led_init(address_space, 0x8000f000); } static