aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-10-22 12:52:45 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2016-10-24 15:27:20 +0200
commit9850b05d216b3a835f92100fed64ffad77e5cf3b (patch)
treeb3ae9d00bdbe5cc8103f64949c0774d1032f1dae
parent4496dc49ec9a6e24e9eeb2da970ed0ec0051968e (diff)
downloadqemu-9850b05d216b3a835f92100fed64ffad77e5cf3b.zip
qemu-9850b05d216b3a835f92100fed64ffad77e5cf3b.tar.gz
qemu-9850b05d216b3a835f92100fed64ffad77e5cf3b.tar.bz2
malta: replace chr init by CHR_EVENT_OPENED handler
The CharDriverState.init() callback was introduced in commit ceecf1d158. It is only called from text_console_do_init(), but it is no longer set since commit a61ae7f88 (init assignment has been removed by accident). It seems correct to use an event callback instead and print the console text on CHR_EVENT_OPENED. That way we can remove the single user of CharDriverState init(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20161022095318.17775-6-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--hw/mips/mips_malta.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index bae60be..3aec6d8 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -88,6 +88,7 @@ typedef struct {
CharDriverState *display;
char display_text[9];
SerialState *uart;
+ bool display_inited;
} MaltaFPGAState;
#define TYPE_MIPS_MALTA "mips-malta"
@@ -530,17 +531,22 @@ static void malta_fpga_reset(void *opaque)
snprintf(s->display_text, 9, " ");
}
-static void malta_fpga_led_init(CharDriverState *chr)
+static void malta_fgpa_display_event(void *opaque, int event)
{
- qemu_chr_fe_printf(chr, "\e[HMalta LEDBAR\r\n");
- qemu_chr_fe_printf(chr, "+--------+\r\n");
- qemu_chr_fe_printf(chr, "+ +\r\n");
- qemu_chr_fe_printf(chr, "+--------+\r\n");
- qemu_chr_fe_printf(chr, "\n");
- qemu_chr_fe_printf(chr, "Malta ASCII\r\n");
- qemu_chr_fe_printf(chr, "+--------+\r\n");
- qemu_chr_fe_printf(chr, "+ +\r\n");
- qemu_chr_fe_printf(chr, "+--------+\r\n");
+ MaltaFPGAState *s = opaque;
+
+ if (event == CHR_EVENT_OPENED && !s->display_inited) {
+ qemu_chr_fe_printf(s->display, "\e[HMalta LEDBAR\r\n");
+ qemu_chr_fe_printf(s->display, "+--------+\r\n");
+ qemu_chr_fe_printf(s->display, "+ +\r\n");
+ qemu_chr_fe_printf(s->display, "+--------+\r\n");
+ qemu_chr_fe_printf(s->display, "\n");
+ qemu_chr_fe_printf(s->display, "Malta ASCII\r\n");
+ qemu_chr_fe_printf(s->display, "+--------+\r\n");
+ qemu_chr_fe_printf(s->display, "+ +\r\n");
+ qemu_chr_fe_printf(s->display, "+--------+\r\n");
+ s->display_inited = true;
+ }
}
static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space,
@@ -560,7 +566,9 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space,
memory_region_add_subregion(address_space, base, &s->iomem_lo);
memory_region_add_subregion(address_space, base + 0xa00, &s->iomem_hi);
- s->display = qemu_chr_new("fpga", "vc:320x200", malta_fpga_led_init);
+ s->display = qemu_chr_new("fpga", "vc:320x200", NULL);
+ qemu_chr_add_handlers(s->display, NULL, NULL,
+ malta_fgpa_display_event, s);
s->uart = serial_mm_init(address_space, base + 0x900, 3, uart_irq,
230400, uart_chr, DEVICE_NATIVE_ENDIAN);