qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] New features for QEMU text console
@ 2007-07-07 16:51 Stefan Weil
  2008-04-18 22:18 ` Stefan Weil
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Weil @ 2007-07-07 16:51 UTC (permalink / raw)
  To: QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 1956 bytes --]

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


[-- Attachment #2: textconsole.patch --]
[-- Type: text/x-diff, Size: 6571 bytes --]

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
-@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
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 */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] New features for QEMU text console
  2007-07-07 16:51 [Qemu-devel] [PATCH] New features for QEMU text console Stefan Weil
@ 2008-04-18 22:18 ` Stefan Weil
  2008-04-28 19:56   ` Stefan Weil
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Weil @ 2008-04-18 22:18 UTC (permalink / raw)
  To: QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 2149 bytes --]

Stefan Weil schrieb:
> 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.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!
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



[-- Attachment #2: vc.patch --]
[-- Type: text/x-diff, Size: 1583 bytes --]

Index: vl.c
===================================================================
--- vl.c	(revision 4220)
+++ vl.c	(working copy)
@@ -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;
Index: hw/mips_malta.c
===================================================================
--- hw/mips_malta.c	(revision 4220)
+++ hw/mips_malta.c	(working copy)
@@ -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);
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] New features for QEMU text console
  2008-04-18 22:18 ` Stefan Weil
@ 2008-04-28 19:56   ` Stefan Weil
  2008-04-28 20:18     ` Aurelien Jarno
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Weil @ 2008-04-28 19:56 UTC (permalink / raw)
  To: qemu-devel

Stefan Weil wrote
> 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
>
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] New features for QEMU text console
  2008-04-28 19:56   ` Stefan Weil
@ 2008-04-28 20:18     ` Aurelien Jarno
  0 siblings, 0 replies; 4+ messages in thread
From: Aurelien Jarno @ 2008-04-28 20:18 UTC (permalink / raw)
  To: qemu-devel

Stefan Weil a écrit :
> Stefan Weil wrote
>> 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
>>
> 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.

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-28 20:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-07 16:51 [Qemu-devel] [PATCH] New features for QEMU text console Stefan Weil
2008-04-18 22:18 ` Stefan Weil
2008-04-28 19:56   ` Stefan Weil
2008-04-28 20:18     ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).