]> git.proxmox.com Git - qemu.git/commitdiff
add an init function parameter to qemu_chr_open()
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 18 Jan 2009 14:08:04 +0000 (14:08 +0000)
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 18 Jan 2009 14:08:04 +0000 (14:08 +0000)
And use it for the malta emulation. Fix segfault introduced in
revision 6352.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6365 c046a42c-6fe2-441c-8c8c-71466251a162

console.c
gdbstub.c
hw/mips_malta.c
hw/omap1.c
hw/omap2.c
hw/usb-serial.c
qemu-char.c
qemu-char.h
vl.c

index b452bca10267c28b8a3ea9a7a129bce8a92a891c..6f0f1afade44c7989dcded1c83b7e3be19d502ac 100644 (file)
--- a/console.c
+++ b/console.c
@@ -1357,6 +1357,8 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds, const c
     text_console_resize(s);
 
     qemu_chr_reset(chr);
+    if (chr->init)
+        chr->init(chr);
 }
 
 CharDriverState *text_console_init(const char *p)
index 99a4772954959c527df7c12b9ac7e4c718769344..2921a04ed43fa8f1f09f5dba3f0b1b30a7f7f7fe 100644 (file)
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2286,7 +2286,7 @@ int gdbserver_start(const char *port)
         port = gdbstub_port_name;
     }
 
-    chr = qemu_chr_open("gdb", port);
+    chr = qemu_chr_open("gdb", port, NULL);
     if (!chr)
         return -1;
 
index 42f77f1eef9dfcae0a7eed2a4ff3af0d37736105..42169bf3288a8533050ae2c85e92f8a2f7ae3226 100644 (file)
@@ -418,7 +418,24 @@ static void malta_fpga_reset(void *opaque)
 
     s->display_text[8] = '\0';
     snprintf(s->display_text, 9, "        ");
-    malta_fpga_update_display(s);
+}
+
+static void malta_fpga_uart_init(CharDriverState *chr)
+{
+    qemu_chr_printf(chr, "CBUS UART\r\n");
+}
+
+static void malta_fpga_led_init(CharDriverState *chr)
+{
+    qemu_chr_printf(chr, "\e[HMalta LEDBAR\r\n");
+    qemu_chr_printf(chr, "+--------+\r\n");
+    qemu_chr_printf(chr, "+        +\r\n");
+    qemu_chr_printf(chr, "+--------+\r\n");
+    qemu_chr_printf(chr, "\n");
+    qemu_chr_printf(chr, "Malta ASCII\r\n");
+    qemu_chr_printf(chr, "+--------+\r\n");
+    qemu_chr_printf(chr, "+        +\r\n");
+    qemu_chr_printf(chr, "+--------+\r\n");
 }
 
 static MaltaFPGAState *malta_fpga_init(target_phys_addr_t base, CPUState *env)
@@ -436,19 +453,9 @@ static MaltaFPGAState *malta_fpga_init(target_phys_addr_t base, CPUState *env)
     /* 0xa00 is less than a page, so will still get the right offsets.  */
     cpu_register_physical_memory(base + 0xa00, 0x100000 - 0xa00, malta);
 
-    s->display = qemu_chr_open("fpga", "vc:320x200");
-    qemu_chr_printf(s->display, "\e[HMalta LEDBAR\r\n");
-    qemu_chr_printf(s->display, "+--------+\r\n");
-    qemu_chr_printf(s->display, "+        +\r\n");
-    qemu_chr_printf(s->display, "+--------+\r\n");
-    qemu_chr_printf(s->display, "\n");
-    qemu_chr_printf(s->display, "Malta ASCII\r\n");
-    qemu_chr_printf(s->display, "+--------+\r\n");
-    qemu_chr_printf(s->display, "+        +\r\n");
-    qemu_chr_printf(s->display, "+--------+\r\n");
-
-    uart_chr = qemu_chr_open("cbus", "vc:80Cx24C");
-    qemu_chr_printf(uart_chr, "CBUS UART\r\n");
+    s->display = qemu_chr_open("fpga", "vc:320x200", malta_fpga_led_init);
+
+    uart_chr = qemu_chr_open("cbus", "vc:80Cx24C", malta_fpga_uart_init);
     s->uart =
         serial_mm_init(base + 0x900, 3, env->irq[2], 230400, uart_chr, 1);
 
index 4c79028698e01f364681a2359989c124fd23362f..c32d3f7f09108c84c406e1b98ca38cee8b6f3e3e 100644 (file)
@@ -1988,7 +1988,7 @@ struct omap_uart_s *omap_uart_init(target_phys_addr_t base,
     s->fclk = fclk;
     s->irq = irq;
     s->serial = serial_mm_init(base, 2, irq, omap_clk_getrate(fclk)/16,
-                               chr ?: qemu_chr_open("null", "null"), 1);
+                               chr ?: qemu_chr_open("null", "null", NULL), 1);
 
     return s;
 }
@@ -2104,7 +2104,7 @@ void omap_uart_attach(struct omap_uart_s *s, CharDriverState *chr)
     /* TODO: Should reuse or destroy current s->serial */
     s->serial = serial_mm_init(s->base, 2, s->irq,
                     omap_clk_getrate(s->fclk) / 16,
-                    chr ?: qemu_chr_open("null", "null"), 1);
+                    chr ?: qemu_chr_open("null", "null", NULL), 1);
 }
 
 /* MPU Clock/Reset/Power Mode Control */
index b9f7706096ba9911f27c714ec0feecae36e114ef..20b38116ffc402c199189d2b4bc6c6e2e3781e76 100644 (file)
@@ -2161,7 +2161,7 @@ static struct omap_sti_s *omap_sti_init(struct omap_target_agent_s *ta,
     s->irq = irq;
     omap_sti_reset(s);
 
-    s->chr = chr ?: qemu_chr_open("null", "null");
+    s->chr = chr ?: qemu_chr_open("null", "null", NULL);
 
     iomemtype = l4_register_io_memory(0, omap_sti_readfn,
                     omap_sti_writefn, s);
index a6a756d957f1f53ec2da9b1ca3d41c554556628d..9dd2c072d031e4b79d801f33361aa54e86fa62c3 100644 (file)
@@ -558,7 +558,7 @@ USBDevice *usb_serial_init(const char *filename)
         return NULL;
 
     snprintf(label, sizeof(label), "usbserial%d", index++);
-    cdrv = qemu_chr_open(label, filename);
+    cdrv = qemu_chr_open(label, filename, NULL);
     if (!cdrv)
         goto fail;
     s->cs = cdrv;
index 02d4049d0ca97ce141f1df4ff7fb6432af332e84..ac431c7c5c1fa58bc33c768e4e41c9479ff3a0b3 100644 (file)
@@ -2122,7 +2122,7 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,
 static TAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs
 = TAILQ_HEAD_INITIALIZER(chardevs);
 
-CharDriverState *qemu_chr_open(const char *label, const char *filename)
+CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s))
 {
     const char *p;
     CharDriverState *chr;
@@ -2146,7 +2146,7 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename)
         chr = qemu_chr_open_udp(p);
     } else
     if (strstart(filename, "mon:", &p)) {
-        chr = qemu_chr_open(label, p);
+        chr = qemu_chr_open(label, p, NULL);
         if (chr) {
             chr = qemu_chr_open_mux(chr);
             monitor_init(chr, !nographic);
@@ -2207,6 +2207,7 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename)
     if (chr) {
         if (!chr->filename)
             chr->filename = qemu_strdup(filename);
+        chr->init = init;
         chr->label = qemu_strdup(label);
         TAILQ_INSERT_TAIL(&chardevs, chr, next);
     }
index c64fc28c2ed354f07ccd8bd160cb2e04cb2bd9e7..bc0fcf325972432258e570024d55fc37295989a3 100644 (file)
@@ -43,6 +43,7 @@ typedef struct {
 typedef void IOEventHandler(void *opaque, int event);
 
 struct CharDriverState {
+    void (*init)(struct CharDriverState *s);
     int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len);
     void (*chr_update_read_handler)(struct CharDriverState *s);
     int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg);
@@ -61,7 +62,7 @@ struct CharDriverState {
     TAILQ_ENTRY(CharDriverState) next;
 };
 
-CharDriverState *qemu_chr_open(const char *label, const char *filename);
+CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s));
 void qemu_chr_close(CharDriverState *chr);
 void qemu_chr_printf(CharDriverState *s, const char *fmt, ...);
 int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len);
diff --git a/vl.c b/vl.c
index 34ddc072f761b1e850549827ce5d5204bf2b5dcf..bfacdcf04009f82441f3eaed8f5b6c9590a373f3 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -5462,7 +5462,7 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (monitor_device) {
-        monitor_hd = qemu_chr_open("monitor", monitor_device);
+        monitor_hd = qemu_chr_open("monitor", monitor_device, NULL);
         if (!monitor_hd) {
             fprintf(stderr, "qemu: could not open monitor device '%s'\n", monitor_device);
             exit(1);
@@ -5474,7 +5474,7 @@ int main(int argc, char **argv, char **envp)
         if (devname && strcmp(devname, "none")) {
             char label[32];
             snprintf(label, sizeof(label), "serial%d", i);
-            serial_hds[i] = qemu_chr_open(label, devname);
+            serial_hds[i] = qemu_chr_open(label, devname, NULL);
             if (!serial_hds[i]) {
                 fprintf(stderr, "qemu: could not open serial device '%s'\n",
                         devname);
@@ -5488,7 +5488,7 @@ int main(int argc, char **argv, char **envp)
         if (devname && strcmp(devname, "none")) {
             char label[32];
             snprintf(label, sizeof(label), "parallel%d", i);
-            parallel_hds[i] = qemu_chr_open(label, devname);
+            parallel_hds[i] = qemu_chr_open(label, devname, NULL);
             if (!parallel_hds[i]) {
                 fprintf(stderr, "qemu: could not open parallel device '%s'\n",
                         devname);
@@ -5502,7 +5502,7 @@ int main(int argc, char **argv, char **envp)
         if (devname && strcmp(devname, "none")) {
             char label[32];
             snprintf(label, sizeof(label), "virtcon%d", i);
-            virtcon_hds[i] = qemu_chr_open(label, devname);
+            virtcon_hds[i] = qemu_chr_open(label, devname, NULL);
             if (!virtcon_hds[i]) {
                 fprintf(stderr, "qemu: could not open virtio console '%s'\n",
                         devname);