New features for QEMU text console
PATCH 1/1 New features for QEMU text console
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
console.c +45 -14
@@ -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
qemu-doc.texi +9 -2
@@ -555,8 +555,15 @@ Available character devices are: @table @code -@item vc -Virtual console +@item vc[:WxH] +Virtual console. Optionally, a width and height can be given in pixel with +@example +vc:800x600 +@end example +It is also possible to specify width or height in characters: +@example +vc:80Cx24C +@end 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
vl.c +5 -3
@@ -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
vl.h +1 -1
@@ -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 */
Quoted 34 lines · Stefan Weil
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.
... 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.cand other files. Examples:
Quoted 6 lines
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!
Up to now, I did not see suggestions for the best size.
So I provide here a patch which is my suggestion to improve the current QEMU trunk.
The patch sets these default console sizes:
* monitor 800 x 600 (so help can display all commands)
* serial 80 chars x 24 lines ("best" size for Linux text console)
* parallel 640 x 480
* Malta UART same as serial console
* Malta LED display 320 x 200
Regards
Stefan
Regards
Stefan
vl.c +3 -3
@@ -8290,14 +8290,14 @@ kernel_cmdline ="" ; cyls = heads = secs =0 ; translation =BIOS_ATA_TRANSLATION_AUTO ; - monitor_device ="vc" ; + monitor_device ="vc:800x600" ; - serial_devices[0 ] ="vc" ; + serial_devices[0 ] ="vc:80Cx24C" ;for (i =1 ; i <MAX_SERIAL_PORTS ; i++) serial_devices[i] =NULL ; serial_device_index =0 ; - parallel_devices[0 ] ="vc" ; + parallel_devices[0 ] ="vc:640x480" ;for (i =1 ; i <MAX_PARALLEL_PORTS ; i++) parallel_devices[i] =NULL ; parallel_device_index =0 ;
mips_malta.c +2 -2
@@ -436,7 +436,7 @@cpu_register_physical_memory (base,0x900 , malta);cpu_register_physical_memory (base +0xa00 ,0x100000 -0xa00 , malta); - s->display =qemu_chr_open ("vc" ); + s->display =qemu_chr_open ("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" );
@@ -447,7 +447,7 @@qemu_chr_printf (s->display,"+ +\r\n" );qemu_chr_printf (s->display,"+--------+\r\n" ); - uart_chr =qemu_chr_open ("vc" ); + uart_chr =qemu_chr_open ("vc:80Cx24C" );qemu_chr_printf (uart_chr,"CBUS UART\r\n" ); s->uart =serial_mm_init (base +0x900 ,3 , env->irq[2 ], uart_chr,1 );
Stefan Weil wrote
Quoted 5 lines
Up to now, I did not see suggestions for the best size.
So I provide here a patch which is my suggestion to improve the current QEMU trunk.
Quoted 7 lines
The patch sets these default console sizes:
* monitor 800 x 600 (so help can display all commands)
* serial 80 chars x 24 lines ("best" size for Linux text console)
* parallel 640 x 480
* Malta UART same as serial console
* Malta LED display 320 x 200
What is wrong with my mail or my patch? There were no answers, nor was the patch included in qemu/trunk.
Are you all satisfied with the current QEMU behaviour where consoles start with "wrong" default sizes and change their sizes when VGA switches to a new video mode?
Or should I provide more explanations?
Stefan
Quoted 13 lines · Stefan Weil
Stefan Weil wrote
Quoted 5 lines
Up to now, I did not see suggestions for the best size.
So I provide here a patch which is my suggestion to improve the current QEMU trunk.
Quoted 7 lines
The patch sets these default console sizes:
* monitor 800 x 600 (so help can display all commands)
* serial 80 chars x 24 lines ("best" size for Linux text console)
* parallel 640 x 480
* Malta UART same as serial console
* Malta LED display 320 x 200
Quoted 2 lines
What is wrong with my mail or my patch? There were no answers, nor was the patch included in qemu/trunk.
Probably nothing, -ENOTIME as for other patches.
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net