2 * QEMU graphical console
4 * Copyright (c) 2004 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 #include "qemu-common.h"
25 #include "ui/console.h"
26 #include "qemu/timer.h"
27 #include "qmp-commands.h"
28 #include "sysemu/char.h"
30 //#define DEBUG_CONSOLE
31 #define DEFAULT_BACKSCROLL 512
32 #define MAX_CONSOLES 12
33 #define CONSOLE_CURSOR_PERIOD 500
35 typedef struct TextAttributes
{
45 typedef struct TextCell
{
47 TextAttributes t_attrib
;
50 #define MAX_ESC_PARAMS 3
58 typedef struct QEMUFIFO
{
61 int count
, wptr
, rptr
;
64 static int qemu_fifo_write(QEMUFIFO
*f
, const uint8_t *buf
, int len1
)
68 l
= f
->buf_size
- f
->count
;
73 l
= f
->buf_size
- f
->wptr
;
76 memcpy(f
->buf
+ f
->wptr
, buf
, l
);
78 if (f
->wptr
>= f
->buf_size
)
87 static int qemu_fifo_read(QEMUFIFO
*f
, uint8_t *buf
, int len1
)
95 l
= f
->buf_size
- f
->rptr
;
98 memcpy(buf
, f
->buf
+ f
->rptr
, l
);
100 if (f
->rptr
>= f
->buf_size
)
112 TEXT_CONSOLE_FIXED_SIZE
117 console_type_t console_type
;
119 DisplaySurface
*surface
;
121 /* Graphic console state. */
122 const GraphicHwOps
*hw_ops
;
125 /* Text console state */
129 int backscroll_height
;
131 int x_saved
, y_saved
;
134 TextAttributes t_attrib_default
; /* default text attributes */
135 TextAttributes t_attrib
; /* currently active text attributes */
137 int text_x
[2], text_y
[2], cursor_invalidate
;
139 bool cursor_visible_phase
;
140 QEMUTimer
*cursor_timer
;
148 int esc_params
[MAX_ESC_PARAMS
];
151 CharDriverState
*chr
;
152 /* fifo for key pressed */
154 uint8_t out_fifo_buf
[16];
155 QEMUTimer
*kbd_timer
;
158 struct DisplayState
{
159 struct QEMUTimer
*gui_timer
;
160 uint64_t last_update
;
161 uint64_t update_interval
;
166 QLIST_HEAD(, DisplayChangeListener
) listeners
;
169 static DisplayState
*display_state
;
170 static QemuConsole
*active_console
;
171 static QemuConsole
*consoles
[MAX_CONSOLES
];
172 static int nb_consoles
= 0;
174 static void text_console_do_init(CharDriverState
*chr
, DisplayState
*ds
);
175 static void dpy_gfx_switch_surface(DisplayState
*ds
,
176 DisplaySurface
*surface
);
177 static void dpy_refresh(DisplayState
*s
);
179 static void gui_update(void *opaque
)
181 uint64_t interval
= GUI_REFRESH_INTERVAL_IDLE
;
182 uint64_t dcl_interval
;
183 DisplayState
*ds
= opaque
;
184 DisplayChangeListener
*dcl
;
187 ds
->refreshing
= true;
189 ds
->refreshing
= false;
191 QLIST_FOREACH(dcl
, &ds
->listeners
, next
) {
192 dcl_interval
= dcl
->update_interval
?
193 dcl
->update_interval
: GUI_REFRESH_INTERVAL_DEFAULT
;
194 if (interval
> dcl_interval
) {
195 interval
= dcl_interval
;
198 if (ds
->update_interval
!= interval
) {
199 ds
->update_interval
= interval
;
200 for (i
= 0; i
< nb_consoles
; i
++) {
201 if (consoles
[i
]->hw_ops
->update_interval
) {
202 consoles
[i
]->hw_ops
->update_interval(consoles
[i
]->hw
, interval
);
205 trace_console_refresh(interval
);
207 ds
->last_update
= qemu_get_clock_ms(rt_clock
);
208 qemu_mod_timer(ds
->gui_timer
, ds
->last_update
+ interval
);
211 static void gui_setup_refresh(DisplayState
*ds
)
213 DisplayChangeListener
*dcl
;
214 bool need_timer
= false;
215 bool have_gfx
= false;
216 bool have_text
= false;
218 QLIST_FOREACH(dcl
, &ds
->listeners
, next
) {
219 if (dcl
->ops
->dpy_refresh
!= NULL
) {
222 if (dcl
->ops
->dpy_gfx_update
!= NULL
) {
225 if (dcl
->ops
->dpy_text_update
!= NULL
) {
230 if (need_timer
&& ds
->gui_timer
== NULL
) {
231 ds
->gui_timer
= qemu_new_timer_ms(rt_clock
, gui_update
, ds
);
232 qemu_mod_timer(ds
->gui_timer
, qemu_get_clock_ms(rt_clock
));
234 if (!need_timer
&& ds
->gui_timer
!= NULL
) {
235 qemu_del_timer(ds
->gui_timer
);
236 qemu_free_timer(ds
->gui_timer
);
237 ds
->gui_timer
= NULL
;
240 ds
->have_gfx
= have_gfx
;
241 ds
->have_text
= have_text
;
244 void graphic_hw_update(QemuConsole
*con
)
247 con
= active_console
;
249 if (con
&& con
->hw_ops
->gfx_update
) {
250 con
->hw_ops
->gfx_update(con
->hw
);
254 void graphic_hw_invalidate(QemuConsole
*con
)
257 con
= active_console
;
259 if (con
&& con
->hw_ops
->invalidate
) {
260 con
->hw_ops
->invalidate(con
->hw
);
264 static void ppm_save(const char *filename
, struct DisplaySurface
*ds
,
267 int width
= pixman_image_get_width(ds
->image
);
268 int height
= pixman_image_get_height(ds
->image
);
272 pixman_image_t
*linebuf
;
274 trace_ppm_save(filename
, ds
);
275 f
= fopen(filename
, "wb");
277 error_setg(errp
, "failed to open file '%s': %s", filename
,
281 ret
= fprintf(f
, "P6\n%d %d\n%d\n", width
, height
, 255);
286 linebuf
= qemu_pixman_linebuf_create(PIXMAN_BE_r8g8b8
, width
);
287 for (y
= 0; y
< height
; y
++) {
288 qemu_pixman_linebuf_fill(linebuf
, ds
->image
, width
, 0, y
);
290 ret
= fwrite(pixman_image_get_data(linebuf
), 1,
291 pixman_image_get_stride(linebuf
), f
);
299 qemu_pixman_image_unref(linebuf
);
304 error_setg(errp
, "failed to write to file '%s': %s", filename
,
310 void qmp_screendump(const char *filename
, Error
**errp
)
312 QemuConsole
*con
= consoles
[0];
313 DisplaySurface
*surface
;
316 error_setg(errp
, "There is no QemuConsole I can screendump from.");
320 graphic_hw_update(con
);
321 surface
= qemu_console_surface(con
);
322 ppm_save(filename
, surface
, errp
);
325 void graphic_hw_text_update(QemuConsole
*con
, console_ch_t
*chardata
)
328 con
= active_console
;
330 if (con
&& con
->hw_ops
->text_update
) {
331 con
->hw_ops
->text_update(con
->hw
, chardata
);
335 static void vga_fill_rect(QemuConsole
*con
,
336 int posx
, int posy
, int width
, int height
,
337 pixman_color_t color
)
339 DisplaySurface
*surface
= qemu_console_surface(con
);
340 pixman_rectangle16_t rect
= {
341 .x
= posx
, .y
= posy
, .width
= width
, .height
= height
344 pixman_image_fill_rectangles(PIXMAN_OP_SRC
, surface
->image
,
348 /* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */
349 static void vga_bitblt(QemuConsole
*con
,
350 int xs
, int ys
, int xd
, int yd
, int w
, int h
)
352 DisplaySurface
*surface
= qemu_console_surface(con
);
354 pixman_image_composite(PIXMAN_OP_SRC
,
355 surface
->image
, NULL
, surface
->image
,
356 xs
, ys
, 0, 0, xd
, yd
, w
, h
);
359 /***********************************************************/
360 /* basic char display */
362 #define FONT_HEIGHT 16
367 #ifndef CONFIG_CURSES
380 #define QEMU_RGB(r, g, b) \
381 { .red = r << 8, .green = g << 8, .blue = b << 8, .alpha = 0xffff }
383 static const pixman_color_t color_table_rgb
[2][8] = {
385 QEMU_RGB(0x00, 0x00, 0x00), /* black */
386 QEMU_RGB(0xaa, 0x00, 0x00), /* red */
387 QEMU_RGB(0x00, 0xaa, 0x00), /* green */
388 QEMU_RGB(0xaa, 0xaa, 0x00), /* yellow */
389 QEMU_RGB(0x00, 0x00, 0xaa), /* blue */
390 QEMU_RGB(0xaa, 0x00, 0xaa), /* magenta */
391 QEMU_RGB(0x00, 0xaa, 0xaa), /* cyan */
392 QEMU_RGB(0xaa, 0xaa, 0xaa), /* white */
395 QEMU_RGB(0x00, 0x00, 0x00), /* black */
396 QEMU_RGB(0xff, 0x00, 0x00), /* red */
397 QEMU_RGB(0x00, 0xff, 0x00), /* green */
398 QEMU_RGB(0xff, 0xff, 0x00), /* yellow */
399 QEMU_RGB(0x00, 0x00, 0xff), /* blue */
400 QEMU_RGB(0xff, 0x00, 0xff), /* magenta */
401 QEMU_RGB(0x00, 0xff, 0xff), /* cyan */
402 QEMU_RGB(0xff, 0xff, 0xff), /* white */
407 static void console_print_text_attributes(TextAttributes
*t_attrib
, char ch
)
409 if (t_attrib
->bold
) {
414 if (t_attrib
->uline
) {
419 if (t_attrib
->blink
) {
424 if (t_attrib
->invers
) {
429 if (t_attrib
->unvisible
) {
435 printf(" fg: %d bg: %d ch:'%2X' '%c'\n", t_attrib
->fgcol
, t_attrib
->bgcol
, ch
, ch
);
439 static void vga_putcharxy(QemuConsole
*s
, int x
, int y
, int ch
,
440 TextAttributes
*t_attrib
)
442 static pixman_image_t
*glyphs
[256];
443 DisplaySurface
*surface
= qemu_console_surface(s
);
444 pixman_color_t fgcol
, bgcol
;
446 if (t_attrib
->invers
) {
447 bgcol
= color_table_rgb
[t_attrib
->bold
][t_attrib
->fgcol
];
448 fgcol
= color_table_rgb
[t_attrib
->bold
][t_attrib
->bgcol
];
450 fgcol
= color_table_rgb
[t_attrib
->bold
][t_attrib
->fgcol
];
451 bgcol
= color_table_rgb
[t_attrib
->bold
][t_attrib
->bgcol
];
455 glyphs
[ch
] = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT
, vgafont16
, ch
);
457 qemu_pixman_glyph_render(glyphs
[ch
], surface
->image
,
458 &fgcol
, &bgcol
, x
, y
, FONT_WIDTH
, FONT_HEIGHT
);
461 static void text_console_resize(QemuConsole
*s
)
463 TextCell
*cells
, *c
, *c1
;
464 int w1
, x
, y
, last_width
;
466 last_width
= s
->width
;
467 s
->width
= surface_width(s
->surface
) / FONT_WIDTH
;
468 s
->height
= surface_height(s
->surface
) / FONT_HEIGHT
;
474 cells
= g_malloc(s
->width
* s
->total_height
* sizeof(TextCell
));
475 for(y
= 0; y
< s
->total_height
; y
++) {
476 c
= &cells
[y
* s
->width
];
478 c1
= &s
->cells
[y
* last_width
];
479 for(x
= 0; x
< w1
; x
++) {
483 for(x
= w1
; x
< s
->width
; x
++) {
485 c
->t_attrib
= s
->t_attrib_default
;
493 static inline void text_update_xy(QemuConsole
*s
, int x
, int y
)
495 s
->text_x
[0] = MIN(s
->text_x
[0], x
);
496 s
->text_x
[1] = MAX(s
->text_x
[1], x
);
497 s
->text_y
[0] = MIN(s
->text_y
[0], y
);
498 s
->text_y
[1] = MAX(s
->text_y
[1], y
);
501 static void invalidate_xy(QemuConsole
*s
, int x
, int y
)
503 if (s
->update_x0
> x
* FONT_WIDTH
)
504 s
->update_x0
= x
* FONT_WIDTH
;
505 if (s
->update_y0
> y
* FONT_HEIGHT
)
506 s
->update_y0
= y
* FONT_HEIGHT
;
507 if (s
->update_x1
< (x
+ 1) * FONT_WIDTH
)
508 s
->update_x1
= (x
+ 1) * FONT_WIDTH
;
509 if (s
->update_y1
< (y
+ 1) * FONT_HEIGHT
)
510 s
->update_y1
= (y
+ 1) * FONT_HEIGHT
;
513 static void update_xy(QemuConsole
*s
, int x
, int y
)
518 if (s
!= active_console
) {
522 if (s
->ds
->have_text
) {
523 text_update_xy(s
, x
, y
);
526 if (s
->ds
->have_gfx
) {
527 y1
= (s
->y_base
+ y
) % s
->total_height
;
528 y2
= y1
- s
->y_displayed
;
530 y2
+= s
->total_height
;
531 if (y2
< s
->height
) {
532 c
= &s
->cells
[y1
* s
->width
+ x
];
533 vga_putcharxy(s
, x
, y2
, c
->ch
,
535 invalidate_xy(s
, x
, y2
);
540 static void console_show_cursor(QemuConsole
*s
, int show
)
546 if (s
!= active_console
) {
550 if (s
->ds
->have_text
) {
551 s
->cursor_invalidate
= 1;
554 if (s
->ds
->have_gfx
) {
558 y1
= (s
->y_base
+ s
->y
) % s
->total_height
;
559 y
= y1
- s
->y_displayed
;
561 y
+= s
->total_height
;
563 c
= &s
->cells
[y1
* s
->width
+ x
];
564 if (show
&& s
->cursor_visible_phase
) {
565 TextAttributes t_attrib
= s
->t_attrib_default
;
566 t_attrib
.invers
= !(t_attrib
.invers
); /* invert fg and bg */
567 vga_putcharxy(s
, x
, y
, c
->ch
, &t_attrib
);
569 vga_putcharxy(s
, x
, y
, c
->ch
, &(c
->t_attrib
));
571 invalidate_xy(s
, x
, y
);
576 static void console_refresh(QemuConsole
*s
)
578 DisplaySurface
*surface
= qemu_console_surface(s
);
582 if (s
!= active_console
)
585 if (s
->ds
->have_text
) {
588 s
->text_x
[1] = s
->width
- 1;
589 s
->text_y
[1] = s
->height
- 1;
590 s
->cursor_invalidate
= 1;
593 if (s
->ds
->have_gfx
) {
594 vga_fill_rect(s
, 0, 0, surface_width(surface
), surface_height(surface
),
595 color_table_rgb
[0][COLOR_BLACK
]);
597 for (y
= 0; y
< s
->height
; y
++) {
598 c
= s
->cells
+ y1
* s
->width
;
599 for (x
= 0; x
< s
->width
; x
++) {
600 vga_putcharxy(s
, x
, y
, c
->ch
,
604 if (++y1
== s
->total_height
) {
608 console_show_cursor(s
, 1);
609 dpy_gfx_update(s
, 0, 0,
610 surface_width(surface
), surface_height(surface
));
614 static void console_scroll(int ydelta
)
620 if (!s
|| (s
->console_type
== GRAPHIC_CONSOLE
))
624 for(i
= 0; i
< ydelta
; i
++) {
625 if (s
->y_displayed
== s
->y_base
)
627 if (++s
->y_displayed
== s
->total_height
)
632 i
= s
->backscroll_height
;
633 if (i
> s
->total_height
- s
->height
)
634 i
= s
->total_height
- s
->height
;
637 y1
+= s
->total_height
;
638 for(i
= 0; i
< ydelta
; i
++) {
639 if (s
->y_displayed
== y1
)
641 if (--s
->y_displayed
< 0)
642 s
->y_displayed
= s
->total_height
- 1;
648 static void console_put_lf(QemuConsole
*s
)
654 if (s
->y
>= s
->height
) {
655 s
->y
= s
->height
- 1;
657 if (s
->y_displayed
== s
->y_base
) {
658 if (++s
->y_displayed
== s
->total_height
)
661 if (++s
->y_base
== s
->total_height
)
663 if (s
->backscroll_height
< s
->total_height
)
664 s
->backscroll_height
++;
665 y1
= (s
->y_base
+ s
->height
- 1) % s
->total_height
;
666 c
= &s
->cells
[y1
* s
->width
];
667 for(x
= 0; x
< s
->width
; x
++) {
669 c
->t_attrib
= s
->t_attrib_default
;
672 if (s
== active_console
&& s
->y_displayed
== s
->y_base
) {
673 if (s
->ds
->have_text
) {
676 s
->text_x
[1] = s
->width
- 1;
677 s
->text_y
[1] = s
->height
- 1;
680 if (s
->ds
->have_gfx
) {
681 vga_bitblt(s
, 0, FONT_HEIGHT
, 0, 0,
682 s
->width
* FONT_WIDTH
,
683 (s
->height
- 1) * FONT_HEIGHT
);
684 vga_fill_rect(s
, 0, (s
->height
- 1) * FONT_HEIGHT
,
685 s
->width
* FONT_WIDTH
, FONT_HEIGHT
,
686 color_table_rgb
[0][s
->t_attrib_default
.bgcol
]);
689 s
->update_x1
= s
->width
* FONT_WIDTH
;
690 s
->update_y1
= s
->height
* FONT_HEIGHT
;
696 /* Set console attributes depending on the current escape codes.
697 * NOTE: I know this code is not very efficient (checking every color for it
698 * self) but it is more readable and better maintainable.
700 static void console_handle_escape(QemuConsole
*s
)
704 for (i
=0; i
<s
->nb_esc_params
; i
++) {
705 switch (s
->esc_params
[i
]) {
706 case 0: /* reset all console attributes to default */
707 s
->t_attrib
= s
->t_attrib_default
;
710 s
->t_attrib
.bold
= 1;
713 s
->t_attrib
.uline
= 1;
716 s
->t_attrib
.blink
= 1;
719 s
->t_attrib
.invers
= 1;
722 s
->t_attrib
.unvisible
= 1;
725 s
->t_attrib
.bold
= 0;
728 s
->t_attrib
.uline
= 0;
731 s
->t_attrib
.blink
= 0;
734 s
->t_attrib
.invers
= 0;
737 s
->t_attrib
.unvisible
= 0;
739 /* set foreground color */
741 s
->t_attrib
.fgcol
=COLOR_BLACK
;
744 s
->t_attrib
.fgcol
=COLOR_RED
;
747 s
->t_attrib
.fgcol
=COLOR_GREEN
;
750 s
->t_attrib
.fgcol
=COLOR_YELLOW
;
753 s
->t_attrib
.fgcol
=COLOR_BLUE
;
756 s
->t_attrib
.fgcol
=COLOR_MAGENTA
;
759 s
->t_attrib
.fgcol
=COLOR_CYAN
;
762 s
->t_attrib
.fgcol
=COLOR_WHITE
;
764 /* set background color */
766 s
->t_attrib
.bgcol
=COLOR_BLACK
;
769 s
->t_attrib
.bgcol
=COLOR_RED
;
772 s
->t_attrib
.bgcol
=COLOR_GREEN
;
775 s
->t_attrib
.bgcol
=COLOR_YELLOW
;
778 s
->t_attrib
.bgcol
=COLOR_BLUE
;
781 s
->t_attrib
.bgcol
=COLOR_MAGENTA
;
784 s
->t_attrib
.bgcol
=COLOR_CYAN
;
787 s
->t_attrib
.bgcol
=COLOR_WHITE
;
793 static void console_clear_xy(QemuConsole
*s
, int x
, int y
)
795 int y1
= (s
->y_base
+ y
) % s
->total_height
;
796 TextCell
*c
= &s
->cells
[y1
* s
->width
+ x
];
798 c
->t_attrib
= s
->t_attrib_default
;
802 /* set cursor, checking bounds */
803 static void set_cursor(QemuConsole
*s
, int x
, int y
)
811 if (y
>= s
->height
) {
822 static void console_putchar(QemuConsole
*s
, int ch
)
831 case '\r': /* carriage return */
834 case '\n': /* newline */
837 case '\b': /* backspace */
841 case '\t': /* tabspace */
842 if (s
->x
+ (8 - (s
->x
% 8)) > s
->width
) {
846 s
->x
= s
->x
+ (8 - (s
->x
% 8));
849 case '\a': /* alert aka. bell */
850 /* TODO: has to be implemented */
853 /* SI (shift in), character set 0 (ignored) */
856 /* SO (shift out), character set 1 (ignored) */
858 case 27: /* esc (introducing an escape sequence) */
859 s
->state
= TTY_STATE_ESC
;
862 if (s
->x
>= s
->width
) {
867 y1
= (s
->y_base
+ s
->y
) % s
->total_height
;
868 c
= &s
->cells
[y1
* s
->width
+ s
->x
];
870 c
->t_attrib
= s
->t_attrib
;
871 update_xy(s
, s
->x
, s
->y
);
876 case TTY_STATE_ESC
: /* check if it is a terminal escape sequence */
878 for(i
=0;i
<MAX_ESC_PARAMS
;i
++)
879 s
->esc_params
[i
] = 0;
880 s
->nb_esc_params
= 0;
881 s
->state
= TTY_STATE_CSI
;
883 s
->state
= TTY_STATE_NORM
;
886 case TTY_STATE_CSI
: /* handle escape sequence parameters */
887 if (ch
>= '0' && ch
<= '9') {
888 if (s
->nb_esc_params
< MAX_ESC_PARAMS
) {
889 int *param
= &s
->esc_params
[s
->nb_esc_params
];
890 int digit
= (ch
- '0');
892 *param
= (*param
<= (INT_MAX
- digit
) / 10) ?
893 *param
* 10 + digit
: INT_MAX
;
896 if (s
->nb_esc_params
< MAX_ESC_PARAMS
)
901 fprintf(stderr
, "escape sequence CSI%d;%d%c, %d parameters\n",
902 s
->esc_params
[0], s
->esc_params
[1], ch
, s
->nb_esc_params
);
904 s
->state
= TTY_STATE_NORM
;
908 if (s
->esc_params
[0] == 0) {
909 s
->esc_params
[0] = 1;
911 set_cursor(s
, s
->x
, s
->y
- s
->esc_params
[0]);
914 /* move cursor down */
915 if (s
->esc_params
[0] == 0) {
916 s
->esc_params
[0] = 1;
918 set_cursor(s
, s
->x
, s
->y
+ s
->esc_params
[0]);
921 /* move cursor right */
922 if (s
->esc_params
[0] == 0) {
923 s
->esc_params
[0] = 1;
925 set_cursor(s
, s
->x
+ s
->esc_params
[0], s
->y
);
928 /* move cursor left */
929 if (s
->esc_params
[0] == 0) {
930 s
->esc_params
[0] = 1;
932 set_cursor(s
, s
->x
- s
->esc_params
[0], s
->y
);
935 /* move cursor to column */
936 set_cursor(s
, s
->esc_params
[0] - 1, s
->y
);
940 /* move cursor to row, column */
941 set_cursor(s
, s
->esc_params
[1] - 1, s
->esc_params
[0] - 1);
944 switch (s
->esc_params
[0]) {
946 /* clear to end of screen */
947 for (y
= s
->y
; y
< s
->height
; y
++) {
948 for (x
= 0; x
< s
->width
; x
++) {
949 if (y
== s
->y
&& x
< s
->x
) {
952 console_clear_xy(s
, x
, y
);
957 /* clear from beginning of screen */
958 for (y
= 0; y
<= s
->y
; y
++) {
959 for (x
= 0; x
< s
->width
; x
++) {
960 if (y
== s
->y
&& x
> s
->x
) {
963 console_clear_xy(s
, x
, y
);
968 /* clear entire screen */
969 for (y
= 0; y
<= s
->height
; y
++) {
970 for (x
= 0; x
< s
->width
; x
++) {
971 console_clear_xy(s
, x
, y
);
978 switch (s
->esc_params
[0]) {
981 for(x
= s
->x
; x
< s
->width
; x
++) {
982 console_clear_xy(s
, x
, s
->y
);
986 /* clear from beginning of line */
987 for (x
= 0; x
<= s
->x
; x
++) {
988 console_clear_xy(s
, x
, s
->y
);
992 /* clear entire line */
993 for(x
= 0; x
< s
->width
; x
++) {
994 console_clear_xy(s
, x
, s
->y
);
1000 console_handle_escape(s
);
1003 /* report cursor position */
1004 /* TODO: send ESC[row;colR */
1007 /* save cursor position */
1012 /* restore cursor position */
1017 #ifdef DEBUG_CONSOLE
1018 fprintf(stderr
, "unhandled escape character '%c'\n", ch
);
1027 void console_select(unsigned int index
)
1031 if (index
>= MAX_CONSOLES
)
1034 trace_console_select(index
);
1035 s
= consoles
[index
];
1037 DisplayState
*ds
= s
->ds
;
1039 if (active_console
&& active_console
->cursor_timer
) {
1040 qemu_del_timer(active_console
->cursor_timer
);
1044 dpy_gfx_switch_surface(ds
, s
->surface
);
1045 dpy_gfx_update(s
, 0, 0, surface_width(s
->surface
),
1046 surface_height(s
->surface
));
1048 if (ds
->have_text
) {
1049 dpy_text_resize(s
, s
->width
, s
->height
);
1051 if (s
->cursor_timer
) {
1052 qemu_mod_timer(s
->cursor_timer
,
1053 qemu_get_clock_ms(rt_clock
) + CONSOLE_CURSOR_PERIOD
/ 2);
1058 static int console_puts(CharDriverState
*chr
, const uint8_t *buf
, int len
)
1060 QemuConsole
*s
= chr
->opaque
;
1063 s
->update_x0
= s
->width
* FONT_WIDTH
;
1064 s
->update_y0
= s
->height
* FONT_HEIGHT
;
1067 console_show_cursor(s
, 0);
1068 for(i
= 0; i
< len
; i
++) {
1069 console_putchar(s
, buf
[i
]);
1071 console_show_cursor(s
, 1);
1072 if (s
->ds
->have_gfx
&& s
->update_x0
< s
->update_x1
) {
1073 dpy_gfx_update(s
, s
->update_x0
, s
->update_y0
,
1074 s
->update_x1
- s
->update_x0
,
1075 s
->update_y1
- s
->update_y0
);
1080 static void kbd_send_chars(void *opaque
)
1082 QemuConsole
*s
= opaque
;
1086 len
= qemu_chr_be_can_write(s
->chr
);
1087 if (len
> s
->out_fifo
.count
)
1088 len
= s
->out_fifo
.count
;
1090 if (len
> sizeof(buf
))
1092 qemu_fifo_read(&s
->out_fifo
, buf
, len
);
1093 qemu_chr_be_write(s
->chr
, buf
, len
);
1095 /* characters are pending: we send them a bit later (XXX:
1096 horrible, should change char device API) */
1097 if (s
->out_fifo
.count
> 0) {
1098 qemu_mod_timer(s
->kbd_timer
, qemu_get_clock_ms(rt_clock
) + 1);
1102 /* called when an ascii key is pressed */
1103 void kbd_put_keysym(int keysym
)
1106 uint8_t buf
[16], *q
;
1110 if (!s
|| (s
->console_type
== GRAPHIC_CONSOLE
))
1114 case QEMU_KEY_CTRL_UP
:
1117 case QEMU_KEY_CTRL_DOWN
:
1120 case QEMU_KEY_CTRL_PAGEUP
:
1121 console_scroll(-10);
1123 case QEMU_KEY_CTRL_PAGEDOWN
:
1127 /* convert the QEMU keysym to VT100 key string */
1129 if (keysym
>= 0xe100 && keysym
<= 0xe11f) {
1132 c
= keysym
- 0xe100;
1134 *q
++ = '0' + (c
/ 10);
1135 *q
++ = '0' + (c
% 10);
1137 } else if (keysym
>= 0xe120 && keysym
<= 0xe17f) {
1140 *q
++ = keysym
& 0xff;
1141 } else if (s
->echo
&& (keysym
== '\r' || keysym
== '\n')) {
1142 console_puts(s
->chr
, (const uint8_t *) "\r", 1);
1148 console_puts(s
->chr
, buf
, q
- buf
);
1150 if (s
->chr
->chr_read
) {
1151 qemu_fifo_write(&s
->out_fifo
, buf
, q
- buf
);
1158 static void text_console_invalidate(void *opaque
)
1160 QemuConsole
*s
= (QemuConsole
*) opaque
;
1162 if (s
->ds
->have_text
&& s
->console_type
== TEXT_CONSOLE
) {
1163 text_console_resize(s
);
1168 static void text_console_update(void *opaque
, console_ch_t
*chardata
)
1170 QemuConsole
*s
= (QemuConsole
*) opaque
;
1173 if (s
->text_x
[0] <= s
->text_x
[1]) {
1174 src
= (s
->y_base
+ s
->text_y
[0]) * s
->width
;
1175 chardata
+= s
->text_y
[0] * s
->width
;
1176 for (i
= s
->text_y
[0]; i
<= s
->text_y
[1]; i
++)
1177 for (j
= 0; j
< s
->width
; j
++, src
++)
1178 console_write_ch(chardata
++, s
->cells
[src
].ch
|
1179 (s
->cells
[src
].t_attrib
.fgcol
<< 12) |
1180 (s
->cells
[src
].t_attrib
.bgcol
<< 8) |
1181 (s
->cells
[src
].t_attrib
.bold
<< 21));
1182 dpy_text_update(s
, s
->text_x
[0], s
->text_y
[0],
1183 s
->text_x
[1] - s
->text_x
[0], i
- s
->text_y
[0]);
1184 s
->text_x
[0] = s
->width
;
1185 s
->text_y
[0] = s
->height
;
1189 if (s
->cursor_invalidate
) {
1190 dpy_text_cursor(s
, s
->x
, s
->y
);
1191 s
->cursor_invalidate
= 0;
1195 static QemuConsole
*new_console(DisplayState
*ds
, console_type_t console_type
)
1200 if (nb_consoles
>= MAX_CONSOLES
)
1202 s
= g_malloc0(sizeof(QemuConsole
));
1203 if (!active_console
|| ((active_console
->console_type
!= GRAPHIC_CONSOLE
) &&
1204 (console_type
== GRAPHIC_CONSOLE
))) {
1208 s
->console_type
= console_type
;
1209 if (console_type
!= GRAPHIC_CONSOLE
) {
1210 s
->index
= nb_consoles
;
1211 consoles
[nb_consoles
++] = s
;
1213 /* HACK: Put graphical consoles before text consoles. */
1214 for (i
= nb_consoles
; i
> 0; i
--) {
1215 if (consoles
[i
- 1]->console_type
== GRAPHIC_CONSOLE
)
1217 consoles
[i
] = consoles
[i
- 1];
1218 consoles
[i
]->index
= i
;
1227 static void qemu_alloc_display(DisplaySurface
*surface
, int width
, int height
,
1228 int linesize
, PixelFormat pf
, int newflags
)
1232 qemu_pixman_image_unref(surface
->image
);
1233 surface
->image
= NULL
;
1235 surface
->format
= qemu_pixman_get_format(&pf
);
1236 assert(surface
->format
!= 0);
1237 surface
->image
= pixman_image_create_bits(surface
->format
,
1240 assert(surface
->image
!= NULL
);
1242 surface
->flags
= newflags
| QEMU_ALLOCATED_FLAG
;
1243 #ifdef HOST_WORDS_BIGENDIAN
1244 surface
->flags
|= QEMU_BIG_ENDIAN_FLAG
;
1248 DisplaySurface
*qemu_create_displaysurface(int width
, int height
)
1250 DisplaySurface
*surface
= g_new0(DisplaySurface
, 1);
1251 int linesize
= width
* 4;
1253 trace_displaysurface_create(surface
, width
, height
);
1254 qemu_alloc_display(surface
, width
, height
, linesize
,
1255 qemu_default_pixelformat(32), 0);
1259 DisplaySurface
*qemu_create_displaysurface_from(int width
, int height
, int bpp
,
1260 int linesize
, uint8_t *data
,
1263 DisplaySurface
*surface
= g_new0(DisplaySurface
, 1);
1265 trace_displaysurface_create_from(surface
, width
, height
, bpp
, byteswap
);
1267 surface
->pf
= qemu_different_endianness_pixelformat(bpp
);
1269 surface
->pf
= qemu_default_pixelformat(bpp
);
1272 surface
->format
= qemu_pixman_get_format(&surface
->pf
);
1273 assert(surface
->format
!= 0);
1274 surface
->image
= pixman_image_create_bits(surface
->format
,
1276 (void *)data
, linesize
);
1277 assert(surface
->image
!= NULL
);
1279 #ifdef HOST_WORDS_BIGENDIAN
1280 surface
->flags
= QEMU_BIG_ENDIAN_FLAG
;
1286 void qemu_free_displaysurface(DisplaySurface
*surface
)
1288 if (surface
== NULL
) {
1291 trace_displaysurface_free(surface
);
1292 qemu_pixman_image_unref(surface
->image
);
1296 void register_displaychangelistener(DisplayState
*ds
,
1297 DisplayChangeListener
*dcl
)
1299 trace_displaychangelistener_register(dcl
, dcl
->ops
->dpy_name
);
1301 QLIST_INSERT_HEAD(&ds
->listeners
, dcl
, next
);
1302 gui_setup_refresh(ds
);
1303 if (dcl
->ops
->dpy_gfx_switch
&& active_console
) {
1304 dcl
->ops
->dpy_gfx_switch(dcl
, active_console
->surface
);
1308 void update_displaychangelistener(DisplayChangeListener
*dcl
,
1311 DisplayState
*ds
= dcl
->ds
;
1313 dcl
->update_interval
= interval
;
1314 if (!ds
->refreshing
&& ds
->update_interval
> interval
) {
1315 qemu_mod_timer(ds
->gui_timer
, ds
->last_update
+ interval
);
1319 void unregister_displaychangelistener(DisplayChangeListener
*dcl
)
1321 DisplayState
*ds
= dcl
->ds
;
1322 trace_displaychangelistener_unregister(dcl
, dcl
->ops
->dpy_name
);
1323 QLIST_REMOVE(dcl
, next
);
1324 gui_setup_refresh(ds
);
1327 void dpy_gfx_update(QemuConsole
*con
, int x
, int y
, int w
, int h
)
1329 DisplayState
*s
= con
->ds
;
1330 struct DisplayChangeListener
*dcl
;
1331 int width
= surface_width(con
->surface
);
1332 int height
= surface_height(con
->surface
);
1338 w
= MIN(w
, width
- x
);
1339 h
= MIN(h
, height
- y
);
1341 if (con
!= active_console
) {
1344 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1345 if (dcl
->ops
->dpy_gfx_update
) {
1346 dcl
->ops
->dpy_gfx_update(dcl
, x
, y
, w
, h
);
1351 static void dpy_gfx_switch_surface(DisplayState
*ds
,
1352 DisplaySurface
*surface
)
1354 struct DisplayChangeListener
*dcl
;
1356 QLIST_FOREACH(dcl
, &ds
->listeners
, next
) {
1357 if (dcl
->ops
->dpy_gfx_switch
) {
1358 dcl
->ops
->dpy_gfx_switch(dcl
, surface
);
1363 void dpy_gfx_replace_surface(QemuConsole
*con
,
1364 DisplaySurface
*surface
)
1366 DisplayState
*s
= con
->ds
;
1367 DisplaySurface
*old_surface
= con
->surface
;
1369 con
->surface
= surface
;
1370 if (con
== active_console
) {
1371 dpy_gfx_switch_surface(s
, surface
);
1373 qemu_free_displaysurface(old_surface
);
1376 void dpy_refresh(DisplayState
*s
)
1378 struct DisplayChangeListener
*dcl
;
1379 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1380 if (dcl
->ops
->dpy_refresh
) {
1381 dcl
->ops
->dpy_refresh(dcl
);
1386 void dpy_gfx_copy(QemuConsole
*con
, int src_x
, int src_y
,
1387 int dst_x
, int dst_y
, int w
, int h
)
1389 DisplayState
*s
= con
->ds
;
1390 struct DisplayChangeListener
*dcl
;
1392 if (con
!= active_console
) {
1395 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1396 if (dcl
->ops
->dpy_gfx_copy
) {
1397 dcl
->ops
->dpy_gfx_copy(dcl
, src_x
, src_y
, dst_x
, dst_y
, w
, h
);
1399 dcl
->ops
->dpy_gfx_update(dcl
, dst_x
, dst_y
, w
, h
);
1404 void dpy_text_cursor(QemuConsole
*con
, int x
, int y
)
1406 DisplayState
*s
= con
->ds
;
1407 struct DisplayChangeListener
*dcl
;
1409 if (con
!= active_console
) {
1412 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1413 if (dcl
->ops
->dpy_text_cursor
) {
1414 dcl
->ops
->dpy_text_cursor(dcl
, x
, y
);
1419 void dpy_text_update(QemuConsole
*con
, int x
, int y
, int w
, int h
)
1421 DisplayState
*s
= con
->ds
;
1422 struct DisplayChangeListener
*dcl
;
1424 if (con
!= active_console
) {
1427 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1428 if (dcl
->ops
->dpy_text_update
) {
1429 dcl
->ops
->dpy_text_update(dcl
, x
, y
, w
, h
);
1434 void dpy_text_resize(QemuConsole
*con
, int w
, int h
)
1436 DisplayState
*s
= con
->ds
;
1437 struct DisplayChangeListener
*dcl
;
1439 if (con
!= active_console
) {
1442 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1443 if (dcl
->ops
->dpy_text_resize
) {
1444 dcl
->ops
->dpy_text_resize(dcl
, w
, h
);
1449 void dpy_mouse_set(QemuConsole
*con
, int x
, int y
, int on
)
1451 DisplayState
*s
= con
->ds
;
1452 struct DisplayChangeListener
*dcl
;
1454 if (con
!= active_console
) {
1457 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1458 if (dcl
->ops
->dpy_mouse_set
) {
1459 dcl
->ops
->dpy_mouse_set(dcl
, x
, y
, on
);
1464 void dpy_cursor_define(QemuConsole
*con
, QEMUCursor
*cursor
)
1466 DisplayState
*s
= con
->ds
;
1467 struct DisplayChangeListener
*dcl
;
1469 if (con
!= active_console
) {
1472 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1473 if (dcl
->ops
->dpy_cursor_define
) {
1474 dcl
->ops
->dpy_cursor_define(dcl
, cursor
);
1479 bool dpy_cursor_define_supported(QemuConsole
*con
)
1481 DisplayState
*s
= con
->ds
;
1482 struct DisplayChangeListener
*dcl
;
1483 QLIST_FOREACH(dcl
, &s
->listeners
, next
) {
1484 if (dcl
->ops
->dpy_cursor_define
) {
1491 /***********************************************************/
1492 /* register display */
1494 /* console.c internal use only */
1495 static DisplayState
*get_alloc_displaystate(void)
1497 if (!display_state
) {
1498 display_state
= g_new0(DisplayState
, 1);
1500 return display_state
;
1504 * Called by main(), after creating QemuConsoles
1505 * and before initializing ui (sdl/vnc/...).
1507 DisplayState
*init_displaystate(void)
1511 if (!display_state
) {
1512 display_state
= g_new0(DisplayState
, 1);
1515 for (i
= 0; i
< nb_consoles
; i
++) {
1516 if (consoles
[i
]->console_type
!= GRAPHIC_CONSOLE
&&
1517 consoles
[i
]->ds
== NULL
) {
1518 text_console_do_init(consoles
[i
]->chr
, display_state
);
1522 return display_state
;
1525 QemuConsole
*graphic_console_init(const GraphicHwOps
*hw_ops
,
1533 ds
= get_alloc_displaystate();
1534 trace_console_gfx_new();
1535 s
= new_console(ds
, GRAPHIC_CONSOLE
);
1539 s
->surface
= qemu_create_displaysurface(width
, height
);
1543 int is_graphic_console(void)
1545 return active_console
&& active_console
->console_type
== GRAPHIC_CONSOLE
;
1548 int is_fixedsize_console(void)
1550 return active_console
&& active_console
->console_type
!= TEXT_CONSOLE
;
1553 static void text_console_set_echo(CharDriverState
*chr
, bool echo
)
1555 QemuConsole
*s
= chr
->opaque
;
1560 static void text_console_update_cursor(void *opaque
)
1562 QemuConsole
*s
= opaque
;
1564 s
->cursor_visible_phase
= !s
->cursor_visible_phase
;
1565 graphic_hw_invalidate(s
);
1566 qemu_mod_timer(s
->cursor_timer
,
1567 qemu_get_clock_ms(rt_clock
) + CONSOLE_CURSOR_PERIOD
/ 2);
1570 static const GraphicHwOps text_console_ops
= {
1571 .invalidate
= text_console_invalidate
,
1572 .text_update
= text_console_update
,
1575 static void text_console_do_init(CharDriverState
*chr
, DisplayState
*ds
)
1578 int g_width
= 80 * FONT_WIDTH
;
1579 int g_height
= 24 * FONT_HEIGHT
;
1583 chr
->chr_write
= console_puts
;
1585 s
->out_fifo
.buf
= s
->out_fifo_buf
;
1586 s
->out_fifo
.buf_size
= sizeof(s
->out_fifo_buf
);
1587 s
->kbd_timer
= qemu_new_timer_ms(rt_clock
, kbd_send_chars
, s
);
1592 s
->total_height
= DEFAULT_BACKSCROLL
;
1596 if (active_console
&& active_console
->surface
) {
1597 g_width
= surface_width(active_console
->surface
);
1598 g_height
= surface_height(active_console
->surface
);
1600 s
->surface
= qemu_create_displaysurface(g_width
, g_height
);
1604 qemu_new_timer_ms(rt_clock
, text_console_update_cursor
, s
);
1606 s
->hw_ops
= &text_console_ops
;
1609 /* Set text attribute defaults */
1610 s
->t_attrib_default
.bold
= 0;
1611 s
->t_attrib_default
.uline
= 0;
1612 s
->t_attrib_default
.blink
= 0;
1613 s
->t_attrib_default
.invers
= 0;
1614 s
->t_attrib_default
.unvisible
= 0;
1615 s
->t_attrib_default
.fgcol
= COLOR_WHITE
;
1616 s
->t_attrib_default
.bgcol
= COLOR_BLACK
;
1617 /* set current text attributes to default */
1618 s
->t_attrib
= s
->t_attrib_default
;
1619 text_console_resize(s
);
1625 s
->t_attrib
.bgcol
= COLOR_BLUE
;
1626 len
= snprintf(msg
, sizeof(msg
), "%s console\r\n", chr
->label
);
1627 console_puts(chr
, (uint8_t*)msg
, len
);
1628 s
->t_attrib
= s
->t_attrib_default
;
1631 qemu_chr_be_generic_open(chr
);
1636 static CharDriverState
*text_console_init(ChardevVC
*vc
)
1638 CharDriverState
*chr
;
1641 unsigned height
= 0;
1643 chr
= g_malloc0(sizeof(CharDriverState
));
1645 if (vc
->has_width
) {
1647 } else if (vc
->has_cols
) {
1648 width
= vc
->cols
* FONT_WIDTH
;
1651 if (vc
->has_height
) {
1652 height
= vc
->height
;
1653 } else if (vc
->has_rows
) {
1654 height
= vc
->rows
* FONT_HEIGHT
;
1657 trace_console_txt_new(width
, height
);
1658 if (width
== 0 || height
== 0) {
1659 s
= new_console(NULL
, TEXT_CONSOLE
);
1661 s
= new_console(NULL
, TEXT_CONSOLE_FIXED_SIZE
);
1662 s
->surface
= qemu_create_displaysurface(width
, height
);
1672 chr
->chr_set_echo
= text_console_set_echo
;
1674 if (display_state
) {
1675 text_console_do_init(chr
, display_state
);
1680 static VcHandler
*vc_handler
= text_console_init
;
1682 CharDriverState
*vc_init(ChardevVC
*vc
)
1684 return vc_handler(vc
);
1687 void register_vc_handler(VcHandler
*handler
)
1689 vc_handler
= handler
;
1692 void qemu_console_resize(QemuConsole
*s
, int width
, int height
)
1694 DisplaySurface
*surface
;
1696 assert(s
->console_type
== GRAPHIC_CONSOLE
);
1697 surface
= qemu_create_displaysurface(width
, height
);
1698 dpy_gfx_replace_surface(s
, surface
);
1701 void qemu_console_copy(QemuConsole
*con
, int src_x
, int src_y
,
1702 int dst_x
, int dst_y
, int w
, int h
)
1704 assert(con
->console_type
== GRAPHIC_CONSOLE
);
1705 dpy_gfx_copy(con
, src_x
, src_y
, dst_x
, dst_y
, w
, h
);
1708 DisplaySurface
*qemu_console_surface(QemuConsole
*console
)
1710 return console
->surface
;
1713 DisplayState
*qemu_console_displaystate(QemuConsole
*console
)
1718 PixelFormat
qemu_different_endianness_pixelformat(int bpp
)
1722 memset(&pf
, 0x00, sizeof(PixelFormat
));
1724 pf
.bits_per_pixel
= bpp
;
1725 pf
.bytes_per_pixel
= DIV_ROUND_UP(bpp
, 8);
1726 pf
.depth
= bpp
== 32 ? 24 : bpp
;
1730 pf
.rmask
= 0x000000FF;
1731 pf
.gmask
= 0x0000FF00;
1732 pf
.bmask
= 0x00FF0000;
1744 pf
.rmask
= 0x0000FF00;
1745 pf
.gmask
= 0x00FF0000;
1746 pf
.bmask
= 0xFF000000;
1747 pf
.amask
= 0x00000000;
1767 PixelFormat
qemu_default_pixelformat(int bpp
)
1771 memset(&pf
, 0x00, sizeof(PixelFormat
));
1773 pf
.bits_per_pixel
= bpp
;
1774 pf
.bytes_per_pixel
= DIV_ROUND_UP(bpp
, 8);
1775 pf
.depth
= bpp
== 32 ? 24 : bpp
;
1779 pf
.bits_per_pixel
= 16;
1780 pf
.rmask
= 0x00007c00;
1781 pf
.gmask
= 0x000003E0;
1782 pf
.bmask
= 0x0000001F;
1794 pf
.rmask
= 0x0000F800;
1795 pf
.gmask
= 0x000007E0;
1796 pf
.bmask
= 0x0000001F;
1808 pf
.rmask
= 0x00FF0000;
1809 pf
.gmask
= 0x0000FF00;
1810 pf
.bmask
= 0x000000FF;
1822 pf
.rmask
= 0x00FF0000;
1823 pf
.gmask
= 0x0000FF00;
1824 pf
.bmask
= 0x000000FF;
1841 static void qemu_chr_parse_vc(QemuOpts
*opts
, ChardevBackend
*backend
,
1846 backend
->vc
= g_new0(ChardevVC
, 1);
1848 val
= qemu_opt_get_number(opts
, "width", 0);
1850 backend
->vc
->has_width
= true;
1851 backend
->vc
->width
= val
;
1854 val
= qemu_opt_get_number(opts
, "height", 0);
1856 backend
->vc
->has_height
= true;
1857 backend
->vc
->height
= val
;
1860 val
= qemu_opt_get_number(opts
, "cols", 0);
1862 backend
->vc
->has_cols
= true;
1863 backend
->vc
->cols
= val
;
1866 val
= qemu_opt_get_number(opts
, "rows", 0);
1868 backend
->vc
->has_rows
= true;
1869 backend
->vc
->rows
= val
;
1873 static void register_types(void)
1875 register_char_driver_qapi("vc", CHARDEV_BACKEND_KIND_VC
,
1879 type_init(register_types
);