From: Stefan Weil <weil@mail.berlios.de>
To: QEMU Developers <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] New features for QEMU text console
Date: Sat, 07 Jul 2007 18:51:38 +0200 [thread overview]
Message-ID: <468FC49A.5070905@mail.berlios.de> (raw)
[-- 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 */
next reply other threads:[~2007-07-07 16:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-07 16:51 Stefan Weil [this message]
2008-04-18 22:18 ` [Qemu-devel] [PATCH] New features for QEMU text console Stefan Weil
2008-04-28 19:56 ` Stefan Weil
2008-04-28 20:18 ` Aurelien Jarno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=468FC49A.5070905@mail.berlios.de \
--to=weil@mail.berlios.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).