From patchwork Wed Sep 8 20:39:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Herv=C3=A9_Poussineau?= X-Patchwork-Id: 64208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DD88BB6EEC for ; Thu, 9 Sep 2010 06:44:09 +1000 (EST) Received: from localhost ([127.0.0.1]:47462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OtRV1-0005ip-1J for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2010 16:44:07 -0400 Received: from [140.186.70.92] (port=40498 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OtRRN-00041z-OE for qemu-devel@nongnu.org; Wed, 08 Sep 2010 16:40:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OtRRM-0007sk-BH for qemu-devel@nongnu.org; Wed, 08 Sep 2010 16:40:21 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:49308) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OtRRL-0007s1-NM for qemu-devel@nongnu.org; Wed, 08 Sep 2010 16:40:20 -0400 Received: from localhost.localdomain (unknown [88.171.126.33]) by smtp5-g21.free.fr (Postfix) with ESMTP id 4F27FD4814D; Wed, 8 Sep 2010 22:40:14 +0200 (CEST) From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= To: qemu-devel@nongnu.org Date: Wed, 8 Sep 2010 22:39:47 +0200 Message-Id: <1283978392-6313-4-git-send-email-hpoussin@reactos.org> X-Mailer: git-send-email 1.7.1.GIT In-Reply-To: <1283978392-6313-1-git-send-email-hpoussin@reactos.org> References: <1283978392-6313-1-git-send-email-hpoussin@reactos.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [Qemu-devel] [PATCH 3/8] [MIPS] qdev: convert jazz-led to sysbus device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use it in Jazz emulation Remove jazz_led_init() function, which is not used anymore Compile jazz_led.c file only once Signed-off-by: Hervé Poussineau --- Makefile.objs | 1 + Makefile.target | 2 +- default-configs/mips-softmmu.mak | 1 + default-configs/mips64-softmmu.mak | 1 + default-configs/mips64el-softmmu.mak | 1 + default-configs/mipsel-softmmu.mak | 1 + hw/jazz_led.c | 81 ++++++++++++++++++++-------------- hw/mips.h | 3 - hw/mips_jazz.c | 2 +- 9 files changed, 55 insertions(+), 38 deletions(-) diff --git a/Makefile.objs b/Makefile.objs index 4a1eaa1..fb25c66 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -231,6 +231,7 @@ hw-obj-$(CONFIG_RC4030) += rc4030.o hw-obj-$(CONFIG_DP8393X) += dp8393x.o hw-obj-$(CONFIG_DS1225Y) += ds1225y.o hw-obj-$(CONFIG_MIPSNET) += mipsnet.o +hw-obj-$(CONFIG_JAZZ_LED) += jazz_led.o # Sound sound-obj-y = diff --git a/Makefile.target b/Makefile.target index 18826bb..78b37ab 100644 --- a/Makefile.target +++ b/Makefile.target @@ -223,7 +223,7 @@ obj-ppc-$(CONFIG_FDT) += device_tree.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o obj-mips-y += vga.o i8259.o -obj-mips-y += g364fb.o jazz_led.o +obj-mips-y += g364fb.o obj-mips-y += gt64xxx.o mc146818rtc.o obj-mips-y += cirrus_vga.o obj-mips-$(CONFIG_FULONG) += bonito.o vt82c686.o mips_fulong2e.o diff --git a/default-configs/mips-softmmu.mak b/default-configs/mips-softmmu.mak index 3d0af83..69bb235 100644 --- a/default-configs/mips-softmmu.mak +++ b/default-configs/mips-softmmu.mak @@ -30,3 +30,4 @@ CONFIG_DP8393X=y CONFIG_DS1225Y=y CONFIG_MIPSNET=y CONFIG_PFLASH_CFI01=y +CONFIG_JAZZ_LED=y diff --git a/default-configs/mips64-softmmu.mak b/default-configs/mips64-softmmu.mak index 0030de4..0421bb6 100644 --- a/default-configs/mips64-softmmu.mak +++ b/default-configs/mips64-softmmu.mak @@ -30,3 +30,4 @@ CONFIG_DP8393X=y CONFIG_DS1225Y=y CONFIG_MIPSNET=y CONFIG_PFLASH_CFI01=y +CONFIG_JAZZ_LED=y diff --git a/default-configs/mips64el-softmmu.mak b/default-configs/mips64el-softmmu.mak index fa2a3ff..b5d4406 100644 --- a/default-configs/mips64el-softmmu.mak +++ b/default-configs/mips64el-softmmu.mak @@ -32,3 +32,4 @@ CONFIG_DS1225Y=y CONFIG_MIPSNET=y CONFIG_PFLASH_CFI01=y CONFIG_FULONG=y +CONFIG_JAZZ_LED=y diff --git a/default-configs/mipsel-softmmu.mak b/default-configs/mipsel-softmmu.mak index 238b73a..0d9a093 100644 --- a/default-configs/mipsel-softmmu.mak +++ b/default-configs/mipsel-softmmu.mak @@ -30,3 +30,4 @@ CONFIG_DP8393X=y CONFIG_DS1225Y=y CONFIG_MIPSNET=y CONFIG_PFLASH_CFI01=y +CONFIG_JAZZ_LED=y diff --git a/hw/jazz_led.c b/hw/jazz_led.c index 4cb680c..f364301 100644 --- a/hw/jazz_led.c +++ b/hw/jazz_led.c @@ -22,10 +22,9 @@ * THE SOFTWARE. */ -#include "hw.h" -#include "mips.h" #include "console.h" #include "pixel_ops.h" +#include "sysbus.h" //#define DEBUG_LED @@ -43,6 +42,7 @@ typedef enum { } screen_state_t; typedef struct LedState { + DeviceState qdev; uint8_t segments; DisplayState *ds; screen_state_t state; @@ -70,30 +70,18 @@ static uint32_t led_readb(void *opaque, target_phys_addr_t addr) static uint32_t led_readw(void *opaque, target_phys_addr_t addr) { uint32_t v; -#ifdef TARGET_WORDS_BIGENDIAN - v = led_readb(opaque, addr) << 8; - v |= led_readb(opaque, addr + 1); -#else v = led_readb(opaque, addr); v |= led_readb(opaque, addr + 1) << 8; -#endif return v; } static uint32_t led_readl(void *opaque, target_phys_addr_t addr) { uint32_t v; -#ifdef TARGET_WORDS_BIGENDIAN - v = led_readb(opaque, addr) << 24; - v |= led_readb(opaque, addr + 1) << 16; - v |= led_readb(opaque, addr + 2) << 8; - v |= led_readb(opaque, addr + 3); -#else v = led_readb(opaque, addr); v |= led_readb(opaque, addr + 1) << 8; v |= led_readb(opaque, addr + 2) << 16; v |= led_readb(opaque, addr + 3) << 24; -#endif return v; } @@ -116,28 +104,16 @@ static void led_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) static void led_writew(void *opaque, target_phys_addr_t addr, uint32_t val) { -#ifdef TARGET_WORDS_BIGENDIAN - led_writeb(opaque, addr, (val >> 8) & 0xff); - led_writeb(opaque, addr + 1, val & 0xff); -#else led_writeb(opaque, addr, val & 0xff); led_writeb(opaque, addr + 1, (val >> 8) & 0xff); -#endif } static void led_writel(void *opaque, target_phys_addr_t addr, uint32_t val) { -#ifdef TARGET_WORDS_BIGENDIAN - led_writeb(opaque, addr, (val >> 24) & 0xff); - led_writeb(opaque, addr + 1, (val >> 16) & 0xff); - led_writeb(opaque, addr + 2, (val >> 8) & 0xff); - led_writeb(opaque, addr + 3, val & 0xff); -#else led_writeb(opaque, addr, val & 0xff); led_writeb(opaque, addr + 1, (val >> 8) & 0xff); led_writeb(opaque, addr + 2, (val >> 16) & 0xff); led_writeb(opaque, addr + 3, (val >> 24) & 0xff); -#endif } static CPUReadMemoryFunc * const led_read[3] = { @@ -307,21 +283,60 @@ 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) +static int led_post_load(void *opaque, int version_id) { - LedState *s; - int io; + LedState *s = opaque; - s = qemu_mallocz(sizeof(LedState)); + jazz_led_invalidate_display(s); + return 0; +} - s->state = REDRAW_SEGMENTS | REDRAW_BACKGROUND; +static const VMStateDescription vmstate_led = { + .name = "jazz-led", + .version_id = 0, + .minimum_version_id = 0, + .minimum_version_id_old = 0, + .post_load = led_post_load, + .fields = (VMStateField []) { + VMSTATE_UINT8(segments, LedState), + VMSTATE_END_OF_LIST() + } +}; - io = cpu_register_io_memory(led_read, led_write, s); - cpu_register_physical_memory(base, 1, io); +typedef struct { + SysBusDevice busdev; + LedState leds; +} SysBusLedState; + +static int led_sysbus_initfn(SysBusDevice *dev) +{ + LedState *s = &FROM_SYSBUS(SysBusLedState, dev)->leds; + int s_io; + + s_io = cpu_register_io_memory(led_read, led_write, s); + sysbus_init_mmio(dev, 0x1000, s_io); s->ds = graphic_console_init(jazz_led_update_display, jazz_led_invalidate_display, jazz_led_screen_dump, jazz_led_text_update, s); qemu_console_resize(s->ds, 60, 80); + + led_post_load(s, 0); + + return 0; } + +static SysBusDeviceInfo led_sysbus_info = { + .qdev.name = "jazz-led", + .qdev.size = sizeof(SysBusLedState), + .qdev.vmsd = &vmstate_led, + .init = led_sysbus_initfn, +}; + +static void led_register(void) +{ + sysbus_register_withprop(&led_sysbus_info); +} + +device_init(led_register) diff --git a/hw/mips.h b/hw/mips.h index 8f32ba0..285f7dc 100644 --- a/hw/mips.h +++ b/hw/mips.h @@ -16,9 +16,6 @@ int g364fb_mm_init(target_phys_addr_t vram_base, /* mipsnet.c */ void mipsnet_init(int base, qemu_irq irq, NICInfo *nd); -/* jazz_led.c */ -extern void jazz_led_init(target_phys_addr_t base); - /* rc4030.c */ typedef struct rc4030DMAState *rc4030_dma; void rc4030_dma_memory_rw(void *opaque, target_phys_addr_t addr, uint8_t *buf, int len, int is_write); diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index 06968d3..0af4044 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -294,7 +294,7 @@ void mips_jazz_init (ram_addr_t ram_size, sysbus_create_simple("nvram", 0x80009000, NULL); /* LED indicator */ - jazz_led_init(0x8000f000); + sysbus_create_simple("jazz-led", 0x8000f000, NULL); } static