All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Hervé Poussineau" <hpoussin@reactos.org>
To: qemu-devel@nongnu.org
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Subject: [Qemu-devel] [PATCH 3/8] [MIPS] qdev: convert jazz-led to sysbus device
Date: Wed,  8 Sep 2010 22:39:47 +0200	[thread overview]
Message-ID: <1283978392-6313-4-git-send-email-hpoussin@reactos.org> (raw)
In-Reply-To: <1283978392-6313-1-git-send-email-hpoussin@reactos.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 <hpoussin@reactos.org>
---
 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
-- 
1.7.1.GIT

  parent reply	other threads:[~2010-09-08 20:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-08 20:39 [Qemu-devel] [PATCH v2 0/8] Convert some MIPS Jazz devices to qdev Hervé Poussineau
2010-09-08 20:39 ` [Qemu-devel] [PATCH 1/8] [MIPS] qdev: convert i8042 to sysbus device Hervé Poussineau
2010-09-25  9:47   ` Markus Armbruster
2010-09-08 20:39 ` [Qemu-devel] [PATCH 2/8] [MIPS] qdev: convert ds1225y nvram " Hervé Poussineau
2010-09-09 14:21   ` Blue Swirl
2010-09-25  9:52   ` Markus Armbruster
2010-09-08 20:39 ` Hervé Poussineau [this message]
2010-09-25  9:55   ` [Qemu-devel] [PATCH 3/8] [MIPS] qdev: convert jazz-led " Markus Armbruster
2010-09-08 20:39 ` [Qemu-devel] [PATCH 4/8] [MIPS] qdev: Use qdev floppy disk controller in Jazz emulation Hervé Poussineau
2010-09-08 20:39 ` [Qemu-devel] [PATCH 5/8] [MIPS] qdev: convert ISA VGA MM to sysbus device Hervé Poussineau
2010-09-09 14:28   ` Blue Swirl
2010-09-08 20:39 ` [Qemu-devel] [PATCH 6/8] [MIPS] qdev: convert g364fb " Hervé Poussineau
2010-09-09 14:32   ` Blue Swirl
2010-09-08 20:39 ` [Qemu-devel] [PATCH 7/8] [MIPS] qdev: convert jazz irq controller " Hervé Poussineau
2010-09-08 20:39 ` [Qemu-devel] [PATCH 8/8] [MIPS] qdev: convert rc4030 " Hervé Poussineau
2010-09-09 14:37   ` Blue Swirl
2010-09-25  9:59     ` Markus Armbruster
2010-09-25 10:43       ` Blue Swirl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1283978392-6313-4-git-send-email-hpoussin@reactos.org \
    --to=hpoussin@reactos.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.