Hi, the current CVS version of QEMU supports a character device 'vc' which can be used for monitor, serial und parallel text consoles.
Each text console window has an initial size of 80 x 25 characters or 640 x 400 pixels. When the user switches from graphical console to a text console, this size changes to the size of the graphical console. I did not expect this behaviour, and for terminal applications running in a serial text console, this change of window size is clearly unwanted. On the other part, I always wanted a text console larger than 80 x 25, especially for Linux kernel boot messages. On TFT displays, text consoles look best in full screen mode when they use the physical display resolution. The new patch is an extension of the 'vc' device which allows specifying a fixed size in pixels or characters like 'vc:800x600' or 'vc:80Cx40C'. When no size is given, you get the old behaviour. It was tested with SDL and VNC consoles. The new syntax for 'vc' can be extended with specifications for text font and terminal emulation like 'vc:800x600:font12x6:vt100'. This is work left for the future. Patch details: console.c: * now 3 types of consoles: graphic, text and fixed size text * text_console_init() has new parameter with console attributes qemu-doc.texi: * added description for new vc syntax vl.h: * changed prototype for text_console_init() vl.c: * support new vc syntax The default settings are not changed by this patch. You can try the new features with command line options: qemu --serial vc:1024x768 --monitor vc:800x600 ... If you like the new feature, the default settings of "vc" can be changed in vl.c, mips_malta.c and other files. Examples: Monitor device: "vc:800x600" - large enough to show all help text :-) Serial device: "vc:800x600" or "vc:1024x768" MIPS Malta LED: "vc:320x200" ... Suggestions for the best size of the different text consoles are welcome! Regards Stefan Weil
Index: console.c =================================================================== RCS file: /sources/qemu/qemu/console.c,v retrieving revision 1.12 diff -u -b -B -r1.12 console.c --- console.c 10 Feb 2007 22:37:56 -0000 1.12 +++ console.c 7 Jul 2007 16:15:26 -0000 @@ -104,10 +104,16 @@ return len1; } +typedef enum { + GRAPHIC_CONSOLE, + TEXT_CONSOLE, + TEXT_CONSOLE_FIXED_SIZE +} console_type_t; + /* ??? This is mis-named. It is used for both text and graphical consoles. */ struct TextConsole { - int text_console; /* true if text console */ + console_type_t console_type; DisplayState *ds; /* Graphic console state. */ vga_hw_update_ptr hw_update; @@ -587,7 +593,7 @@ int i, y1; s = active_console; - if (!s || !s->text_console) + if (!s || (s->console_type == GRAPHIC_CONSOLE)) return; if (ydelta > 0) { @@ -990,13 +996,17 @@ s = consoles[index]; if (s) { active_console = s; - if (s->text_console) { + if (s->console_type != GRAPHIC_CONSOLE) { if (s->g_width != s->ds->width || s->g_height != s->ds->height) { + if (s->console_type == TEXT_CONSOLE_FIXED_SIZE) { + dpy_resize(s->ds, s->g_width, s->g_height); + } else { s->g_width = s->ds->width; s->g_height = s->ds->height; text_console_resize(s); } + } console_refresh(s); } else { vga_hw_invalidate(); @@ -1062,7 +1072,7 @@ int c; s = active_console; - if (!s || !s->text_console) + if (!s || (s->console_type == GRAPHIC_CONSOLE)) return; switch(keysym) { @@ -1104,7 +1114,7 @@ } } -static TextConsole *new_console(DisplayState *ds, int text) +static TextConsole *new_console(DisplayState *ds, console_type_t console_type) { TextConsole *s; int i; @@ -1115,16 +1125,18 @@ if (!s) { return NULL; } - if (!active_console || (active_console->text_console && !text)) + if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) && + (console_type == GRAPHIC_CONSOLE))) { active_console = s; + } s->ds = ds; - s->text_console = text; - if (text) { + s->console_type = console_type; + if (console_type != GRAPHIC_CONSOLE) { consoles[nb_consoles++] = s; } else { /* HACK: Put graphical consoles before text consoles. */ for (i = nb_consoles; i > 0; i--) { - if (!consoles[i - 1]->text_console) + if (consoles[i - 1]->console_type == GRAPHIC_CONSOLE) break; consoles[i] = consoles[i - 1]; } @@ -1152,20 +1164,22 @@ int is_graphic_console(void) { - return !active_console->text_console; + return active_console->console_type == GRAPHIC_CONSOLE; } -CharDriverState *text_console_init(DisplayState *ds) +CharDriverState *text_console_init(DisplayState *ds, const char *p) { CharDriverState *chr; TextConsole *s; int i,j; + unsigned width; + unsigned height; static int color_inited; chr = qemu_mallocz(sizeof(CharDriverState)); if (!chr) return NULL; - s = new_console(ds, 1); + s = new_console(ds, (p == 0) ? 1 : 2); if (!s) { free(chr); return NULL; @@ -1193,8 +1207,25 @@ s->total_height = DEFAULT_BACKSCROLL; s->x = 0; s->y = 0; - s->g_width = s->ds->width; - s->g_height = s->ds->height; + width = s->ds->width; + height = s->ds->height; + if (p != 0) { + width = strtoul(p, (char **)&p, 10); + if (*p == 'C') { + p++; + width *= FONT_WIDTH; + } + if (*p == 'x') { + p++; + height = strtoul(p, (char **)&p, 10); + if (*p == 'C') { + p++; + height *= FONT_HEIGHT; + } + } + } + s->g_width = width; + s->g_height = height; /* Set text attribute defaults */ s->t_attrib_default.bold = 0; Index: qemu-doc.texi =================================================================== RCS file: /sources/qemu/qemu/qemu-doc.texi,v retrieving revision 1.151 diff -u -b -B -r1.151 qemu-doc.texi --- qemu-doc.texi 22 Jun 2007 08:15:58 -0000 1.151 +++ qemu-doc.texi 7 Jul 2007 16:15:28 -0000 @@ -555,8 +555,15 @@ Available character devices are: @table @code [EMAIL PROTECTED] vc -Virtual console [EMAIL PROTECTED] vc[:WxH] +Virtual console. Optionally, a width and height can be given in pixel with [EMAIL PROTECTED] +vc:800x600 [EMAIL PROTECTED] example +It is also possible to specify width or height in characters: [EMAIL PROTECTED] +vc:80Cx24C [EMAIL PROTECTED] example @item pty [Linux only] Pseudo TTY (a new PTY is automatically allocated) @item none Index: vl.c =================================================================== RCS file: /sources/qemu/qemu/vl.c,v retrieving revision 1.320 diff -u -b -B -r1.320 vl.c --- vl.c 2 Jul 2007 15:03:13 -0000 1.320 +++ vl.c 7 Jul 2007 16:15:32 -0000 @@ -2923,7 +2923,9 @@ const char *p; if (!strcmp(filename, "vc")) { - return text_console_init(&display_state); + return text_console_init(&display_state, 0); + } else if (strstart(filename, "vc:", &p)) { + return text_console_init(&display_state, p); } else if (!strcmp(filename, "null")) { return qemu_chr_open_null(); } else @@ -7970,7 +7972,7 @@ devname); exit(1); } - if (!strcmp(devname, "vc")) + if (strstart(devname, "vc", 0)) qemu_chr_printf(serial_hds[i], "serial%d console\r\n", i); } } @@ -7984,7 +7986,7 @@ devname); exit(1); } - if (!strcmp(devname, "vc")) + if (strstart(devname, "vc", 0)) qemu_chr_printf(parallel_hds[i], "parallel%d console\r\n", i); } } Index: vl.h =================================================================== RCS file: /sources/qemu/qemu/vl.h,v retrieving revision 1.255 diff -u -b -B -r1.255 vl.h --- vl.h 30 Jun 2007 17:32:17 -0000 1.255 +++ vl.h 7 Jul 2007 16:15:34 -0000 @@ -351,7 +351,7 @@ void vga_hw_screen_dump(const char *filename); int is_graphic_console(void); -CharDriverState *text_console_init(DisplayState *ds); +CharDriverState *text_console_init(DisplayState *ds, const char *p); void console_select(unsigned int index); /* serial ports */