summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-16 19:04:14 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-16 19:04:14 +0000
commit3023f3329d87a6203d03a0e9ccb948772940da96 (patch)
tree2e1bea1fcce30aa15940275277f52022d7325341 /console.c
parentFix false positive for AIO on OpenBSD (diff)
downloadqemu-kvm-3023f3329d87a6203d03a0e9ccb948772940da96.tar.gz
qemu-kvm-3023f3329d87a6203d03a0e9ccb948772940da96.tar.bz2
qemu-kvm-3023f3329d87a6203d03a0e9ccb948772940da96.zip
graphical_console_init change (Stefano Stabellini)
Patch 5/7 This patch changes the graphical_console_init function to return an allocated DisplayState instead of a QEMUConsole. This patch contains just the graphical_console_init change and few other modifications mainly in console.c and vl.c. It was necessary to move the display frontends (e.g. sdl and vnc) initialization after machine->init in vl.c. This patch does *not* include any required changes to any device, these changes come with the following patches. Patch 6/7 This patch changes the QEMUMachine init functions not to take a DisplayState as an argument because is not needed any more; In few places the graphic hardware initialization function was called only if DisplayState was not NULL, now they are always called. Apart from these cases, the rest are all mechanical substitutions. Patch 7/7 This patch updates the graphic device code to use the new graphical_console_init function. As for the previous patch, in few places graphical_console_init was called only if DisplayState was not NULL, now it is always called. Apart from these cases, the rest are all mechanical substitutions. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6344 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'console.c')
-rw-r--r--console.c60
1 files changed, 42 insertions, 18 deletions
diff --git a/console.c b/console.c
index efd07ce31..a37edf707 100644
--- a/console.c
+++ b/console.c
@@ -1190,6 +1190,17 @@ static void text_console_update(void *opaque, console_ch_t *chardata)
}
}
+static TextConsole *get_graphic_console() {
+ int i;
+ TextConsole *s;
+ for (i = 0; i < nb_consoles; i++) {
+ s = consoles[i];
+ if (s->console_type == GRAPHIC_CONSOLE)
+ return s;
+ }
+ return NULL;
+}
+
static TextConsole *new_console(DisplayState *ds, console_type_t console_type)
{
TextConsole *s;
@@ -1217,27 +1228,39 @@ static TextConsole *new_console(DisplayState *ds, console_type_t console_type)
consoles[i] = consoles[i - 1];
}
consoles[i] = s;
+ nb_consoles++;
}
return s;
}
-TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
- vga_hw_invalidate_ptr invalidate,
- vga_hw_screen_dump_ptr screen_dump,
- vga_hw_text_update_ptr text_update,
- void *opaque)
+DisplayState *graphic_console_init(vga_hw_update_ptr update,
+ vga_hw_invalidate_ptr invalidate,
+ vga_hw_screen_dump_ptr screen_dump,
+ vga_hw_text_update_ptr text_update,
+ void *opaque)
{
TextConsole *s;
+ DisplayState *ds;
+
+ ds = (DisplayState *) qemu_mallocz(sizeof(DisplayState));
+ if (ds == NULL)
+ return NULL;
+ ds->surface = qemu_create_displaysurface(640, 480, 32, 640 * 4);
s = new_console(ds, GRAPHIC_CONSOLE);
- if (!s)
- return NULL;
+ if (s == NULL) {
+ qemu_free_displaysurface(ds->surface);
+ qemu_free(ds);
+ return NULL;
+ }
s->hw_update = update;
s->hw_invalidate = invalidate;
s->hw_screen_dump = screen_dump;
s->hw_text_update = text_update;
s->hw = opaque;
- return s;
+
+ register_displaystate(ds);
+ return ds;
}
int is_graphic_console(void)
@@ -1285,6 +1308,7 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p)
s->out_fifo.buf = s->out_fifo_buf;
s->out_fifo.buf_size = sizeof(s->out_fifo_buf);
s->kbd_timer = qemu_new_timer(rt_clock, kbd_send_chars, s);
+ s->ds = ds;
if (!color_inited) {
color_inited = 1;
@@ -1337,22 +1361,22 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p)
return chr;
}
-void qemu_console_resize(QEMUConsole *console, int width, int height)
+void qemu_console_resize(DisplayState *ds, int width, int height)
{
- console->g_width = width;
- console->g_height = height;
- if (active_console == console) {
- DisplayState *ds = console->ds;
+ TextConsole *s = get_graphic_console();
+ s->g_width = width;
+ s->g_height = height;
+ if (is_graphic_console()) {
ds->surface = qemu_resize_displaysurface(ds->surface, width, height, 32, 4 * width);
- dpy_resize(console->ds);
+ dpy_resize(ds);
}
}
-void qemu_console_copy(QEMUConsole *console, int src_x, int src_y,
- int dst_x, int dst_y, int w, int h)
+void qemu_console_copy(DisplayState *ds, int src_x, int src_y,
+ int dst_x, int dst_y, int w, int h)
{
- if (active_console == console) {
- dpy_copy(console->ds, src_x, src_y, dst_x, dst_y, w, h);
+ if (is_graphic_console()) {
+ dpy_copy(ds, src_x, src_y, dst_x, dst_y, w, h);
}
}