New features for QEMU text console, by Stefan Weil.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3068 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
ths 2007-07-11 23:14:59 +00:00
parent 37a4c5392d
commit af3a903106
4 changed files with 61 additions and 21 deletions

View File

@ -104,10 +104,16 @@ int qemu_fifo_read(QEMUFIFO *f, uint8_t *buf, int len1)
return len1; return len1;
} }
typedef enum {
GRAPHIC_CONSOLE,
TEXT_CONSOLE,
TEXT_CONSOLE_FIXED_SIZE
} console_type_t;
/* ??? This is mis-named. /* ??? This is mis-named.
It is used for both text and graphical consoles. */ It is used for both text and graphical consoles. */
struct TextConsole { struct TextConsole {
int text_console; /* true if text console */ console_type_t console_type;
DisplayState *ds; DisplayState *ds;
/* Graphic console state. */ /* Graphic console state. */
vga_hw_update_ptr hw_update; vga_hw_update_ptr hw_update;
@ -587,7 +593,7 @@ static void console_scroll(int ydelta)
int i, y1; int i, y1;
s = active_console; s = active_console;
if (!s || !s->text_console) if (!s || (s->console_type == GRAPHIC_CONSOLE))
return; return;
if (ydelta > 0) { if (ydelta > 0) {
@ -990,13 +996,17 @@ void console_select(unsigned int index)
s = consoles[index]; s = consoles[index];
if (s) { if (s) {
active_console = s; active_console = s;
if (s->text_console) { if (s->console_type != GRAPHIC_CONSOLE) {
if (s->g_width != s->ds->width || if (s->g_width != s->ds->width ||
s->g_height != s->ds->height) { 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_width = s->ds->width;
s->g_height = s->ds->height; s->g_height = s->ds->height;
text_console_resize(s); text_console_resize(s);
} }
}
console_refresh(s); console_refresh(s);
} else { } else {
vga_hw_invalidate(); vga_hw_invalidate();
@ -1062,7 +1072,7 @@ void kbd_put_keysym(int keysym)
int c; int c;
s = active_console; s = active_console;
if (!s || !s->text_console) if (!s || (s->console_type == GRAPHIC_CONSOLE))
return; return;
switch(keysym) { switch(keysym) {
@ -1104,7 +1114,7 @@ void kbd_put_keysym(int keysym)
} }
} }
static TextConsole *new_console(DisplayState *ds, int text) static TextConsole *new_console(DisplayState *ds, console_type_t console_type)
{ {
TextConsole *s; TextConsole *s;
int i; int i;
@ -1115,16 +1125,18 @@ static TextConsole *new_console(DisplayState *ds, int text)
if (!s) { if (!s) {
return NULL; 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; active_console = s;
}
s->ds = ds; s->ds = ds;
s->text_console = text; s->console_type = console_type;
if (text) { if (console_type != GRAPHIC_CONSOLE) {
consoles[nb_consoles++] = s; consoles[nb_consoles++] = s;
} else { } else {
/* HACK: Put graphical consoles before text consoles. */ /* HACK: Put graphical consoles before text consoles. */
for (i = nb_consoles; i > 0; i--) { for (i = nb_consoles; i > 0; i--) {
if (!consoles[i - 1]->text_console) if (consoles[i - 1]->console_type == GRAPHIC_CONSOLE)
break; break;
consoles[i] = consoles[i - 1]; consoles[i] = consoles[i - 1];
} }
@ -1140,7 +1152,7 @@ TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
{ {
TextConsole *s; TextConsole *s;
s = new_console(ds, 0); s = new_console(ds, GRAPHIC_CONSOLE);
if (!s) if (!s)
return NULL; return NULL;
s->hw_update = update; s->hw_update = update;
@ -1152,20 +1164,22 @@ TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
int is_graphic_console(void) 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; CharDriverState *chr;
TextConsole *s; TextConsole *s;
int i,j; int i,j;
unsigned width;
unsigned height;
static int color_inited; static int color_inited;
chr = qemu_mallocz(sizeof(CharDriverState)); chr = qemu_mallocz(sizeof(CharDriverState));
if (!chr) if (!chr)
return NULL; return NULL;
s = new_console(ds, 1); s = new_console(ds, (p == 0) ? TEXT_CONSOLE : TEXT_CONSOLE_FIXED_SIZE);
if (!s) { if (!s) {
free(chr); free(chr);
return NULL; return NULL;
@ -1193,8 +1207,25 @@ CharDriverState *text_console_init(DisplayState *ds)
s->total_height = DEFAULT_BACKSCROLL; s->total_height = DEFAULT_BACKSCROLL;
s->x = 0; s->x = 0;
s->y = 0; s->y = 0;
s->g_width = s->ds->width; width = s->ds->width;
s->g_height = s->ds->height; 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 */ /* Set text attribute defaults */
s->t_attrib_default.bold = 0; s->t_attrib_default.bold = 0;

View File

@ -555,8 +555,15 @@ Use @code{-serial none} to disable all serial ports.
Available character devices are: Available character devices are:
@table @code @table @code
@item vc @item vc[:WxH]
Virtual console 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 @item pty
[Linux only] Pseudo TTY (a new PTY is automatically allocated) [Linux only] Pseudo TTY (a new PTY is automatically allocated)
@item none @item none

8
vl.c
View File

@ -2923,7 +2923,9 @@ CharDriverState *qemu_chr_open(const char *filename)
const char *p; const char *p;
if (!strcmp(filename, "vc")) { 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")) { } else if (!strcmp(filename, "null")) {
return qemu_chr_open_null(); return qemu_chr_open_null();
} else } else
@ -7970,7 +7972,7 @@ int main(int argc, char **argv)
devname); devname);
exit(1); exit(1);
} }
if (!strcmp(devname, "vc")) if (strstart(devname, "vc", 0))
qemu_chr_printf(serial_hds[i], "serial%d console\r\n", i); qemu_chr_printf(serial_hds[i], "serial%d console\r\n", i);
} }
} }
@ -7984,7 +7986,7 @@ int main(int argc, char **argv)
devname); devname);
exit(1); exit(1);
} }
if (!strcmp(devname, "vc")) if (strstart(devname, "vc", 0))
qemu_chr_printf(parallel_hds[i], "parallel%d console\r\n", i); qemu_chr_printf(parallel_hds[i], "parallel%d console\r\n", i);
} }
} }

2
vl.h
View File

@ -351,7 +351,7 @@ void vga_hw_invalidate(void);
void vga_hw_screen_dump(const char *filename); void vga_hw_screen_dump(const char *filename);
int is_graphic_console(void); 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); void console_select(unsigned int index);
/* serial ports */ /* serial ports */