graphical_console_init change
PATCH 1/1 graphical_console_init change
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.
Signed-off-by Stefano Stabellini <[email protected]>
---
console.c +42 -19
@@ -1190,6 +1190,17 @@ } } +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,38 @@ 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_createDisplaySurface (640 ,480 ,32 ,640 *4 ); + s =new_console (ds,GRAPHIC_CONSOLE ); -if (!s) -return NULL ; +if (s ==NULL ) { +qemu_freeDisplaySurface (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; + +return ds; }int is_graphic_console (void )
@@ -1285,6 +1307,7 @@ 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 +1360,22 @@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_resizeDisplaySurface (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); } }
console.h +13 -8
@@ -122,8 +122,12 @@void (*mouse_set)(int x,int y,int on);void (*cursor_define)(int width,int height,int bpp,int hot_x,int hot_y,uint8_t *image,uint8_t *mask); + +struct DisplayState *next; }; +void register_displaystate (DisplayState *ds); +DisplayState *get_displaystate (void );DisplaySurface *qemu_createDisplaySurface (int width,int height,int bpp,int linesize);DisplaySurface *qemu_resizeDisplaySurface (DisplaySurface *surface,int width,int height,int bpp,int linesize);
@@ -248,11 +252,12 @@typedef void (*vga_hw_screen_dump_ptr )(void *,const char *);typedef void (*vga_hw_text_update_ptr )(void *,console_ch_t *); -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); +void vga_hw_update (void );void vga_hw_invalidate (void );void vga_hw_screen_dump (const char *filename);
@@ -263,9 +268,9 @@CharDriverState *text_console_init (DisplayState *ds,const char *p);void console_select (unsigned int index);void console_color_init (DisplayState *ds); -void qemu_console_resize (QEMUConsole *console,int width,int height); -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_resize (DisplayState *ds,int width,int height); +void qemu_console_copy (DisplayState *ds,int src_x,int src_y, +int dst_x,int dst_y,int w,int h);/* sdl.c */ void sdl_display_init (DisplayState *ds,int full_screen,int no_frame);
qemu-char.c +2 -2
@@ -2129,10 +2129,10 @@CharDriverState *chr;if (!strcmp (filename,"vc" )) { - chr =text_console_init (&display_state,0 ); + chr =text_console_init (get_displaystate (),0 ); }else if (strstart (filename,"vc:" , &p)) { - chr =text_console_init (&display_state, p); + chr =text_console_init (get_displaystate (), p); }else if (!strcmp (filename,"null" )) { chr =qemu_chr_open_null ();
sysemu.h +0 -1
@@ -98,7 +98,6 @@extern int semihosting_enabled;extern int old_param;extern const char *bootp_filename; -extern DisplayState display_state;#ifdef USE_KQEMU extern int kqemu_allowed;
vl.c +79 -60
179 lines not on this page · raw message