Since commit e2f82e924d05 ("console: purge curses bits from
console.h"), console_ch_t is a plain uint32_t typedef and
console_write_ch() is a trivial assignment (*dest = ch). These
abstractions were originally needed because console_ch_t was the
curses chtype when CONFIG_CURSES was enabled, and console_write_ch()
handled VGA-to-curses character translation. That commit moved the
curses logic into curses_update(), making the typedef and helper
dead abstractions.
Replace console_ch_t with uint32_t and console_write_ch() calls
with direct assignments.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/console.h | 11 ++---------
hw/display/jazz_led.c | 10 +++++-----
hw/display/vga.c | 16 ++++++++--------
hw/display/virtio-gpu-base.c | 2 +-
hw/display/virtio-vga.c | 2 +-
hw/display/vmware_vga.c | 2 +-
ui/console-vc.c | 11 +++++------
ui/console.c | 2 +-
ui/curses.c | 6 +++---
9 files changed, 27 insertions(+), 35 deletions(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 401e5a010fd..152333d60fc 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -350,13 +350,6 @@ int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGLContext ctx);
bool console_has_gl(QemuConsole *con);
-typedef uint32_t console_ch_t;
-
-static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
-{
- *dest = ch;
-}
-
enum {
GRAPHIC_FLAGS_NONE = 0,
/* require a console/display with GL callbacks */
@@ -370,7 +363,7 @@ typedef struct GraphicHwOps {
void (*invalidate)(void *opaque);
void (*gfx_update)(void *opaque);
bool gfx_update_async; /* if true, calls graphic_hw_update_done() */
- void (*text_update)(void *opaque, console_ch_t *text);
+ void (*text_update)(void *opaque, uint32_t *text);
void (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info);
void (*gl_block)(void *opaque, bool block);
} GraphicHwOps;
@@ -386,7 +379,7 @@ void graphic_console_close(QemuConsole *con);
void graphic_hw_update(QemuConsole *con);
void graphic_hw_update_done(QemuConsole *con);
void graphic_hw_invalidate(QemuConsole *con);
-void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
+void graphic_hw_text_update(QemuConsole *con, uint32_t *chardata);
void graphic_hw_gl_block(QemuConsole *con, bool block);
void qemu_console_early_init(void);
diff --git a/hw/display/jazz_led.c b/hw/display/jazz_led.c
index 9d62e51bed9..d5783982950 100644
--- a/hw/display/jazz_led.c
+++ b/hw/display/jazz_led.c
@@ -226,7 +226,7 @@ static void jazz_led_invalidate_display(void *opaque)
s->state |= REDRAW_SEGMENTS | REDRAW_BACKGROUND;
}
-static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
+static void jazz_led_text_update(void *opaque, uint32_t *chardata)
{
LedState *s = opaque;
char buf[3];
@@ -236,10 +236,10 @@ static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
/* TODO: draw the segments */
snprintf(buf, 3, "%02hhx", s->segments);
- console_write_ch(chardata++, ATTR2CHTYPE(buf[0], QEMU_COLOR_BLUE,
- QEMU_COLOR_BLACK, 1));
- console_write_ch(chardata++, ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE,
- QEMU_COLOR_BLACK, 1));
+ *chardata++ = ATTR2CHTYPE(buf[0], QEMU_COLOR_BLUE,
+ QEMU_COLOR_BLACK, 1);
+ *chardata++ = ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE,
+ QEMU_COLOR_BLACK, 1);
dpy_text_update(s->con, 0, 0, 2, 1);
}
diff --git a/hw/display/vga.c b/hw/display/vga.c
index ee7d97b5c21..36cfc59a74e 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -1899,13 +1899,13 @@ static void vga_reset(void *opaque)
((v & 0x00000800) << 10) | ((v & 0x00007000) >> 1))
/* relay text rendering to the display driver
* instead of doing a full vga_update_display() */
-static void vga_update_text(void *opaque, console_ch_t *chardata)
+static void vga_update_text(void *opaque, uint32_t *chardata)
{
VGACommonState *s = opaque;
int graphic_mode, i, cursor_offset, cursor_visible;
int cw, cheight, width, height, size, c_min, c_max;
uint32_t *src;
- console_ch_t *dst, val;
+ uint32_t *dst, val;
char msg_buffer[80];
int full_update = 0;
@@ -2005,14 +2005,14 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
if (full_update) {
for (i = 0; i < size; src ++, dst ++, i ++)
- console_write_ch(dst, VMEM2CHTYPE(le32_to_cpu(*src)));
+ *dst = VMEM2CHTYPE(le32_to_cpu(*src));
dpy_text_update(s->con, 0, 0, width, height);
} else {
c_max = 0;
for (i = 0; i < size; src ++, dst ++, i ++) {
- console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
+ val = VMEM2CHTYPE(le32_to_cpu(*src));
if (*dst != val) {
*dst = val;
c_max = i;
@@ -2021,7 +2021,7 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
}
c_min = i;
for (; i < size; src ++, dst ++, i ++) {
- console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src)));
+ val = VMEM2CHTYPE(le32_to_cpu(*src));
if (*dst != val) {
*dst = val;
c_max = i;
@@ -2059,14 +2059,14 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
dpy_text_resize(s->con, s->last_width, height);
for (dst = chardata, i = 0; i < s->last_width * height; i ++)
- console_write_ch(dst ++, ' ');
+ *dst++ = ' ';
size = strlen(msg_buffer);
width = (s->last_width - size) / 2;
dst = chardata + s->last_width + width;
for (i = 0; i < size; i ++)
- console_write_ch(dst ++, ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLUE,
- QEMU_COLOR_BLACK, 1));
+ *dst++ = ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLUE,
+ QEMU_COLOR_BLACK, 1);
dpy_text_update(s->con, 0, 0, s->last_width, height);
}
diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
index cb76302e2d8..7b107509510 100644
--- a/hw/display/virtio-gpu-base.c
+++ b/hw/display/virtio-gpu-base.c
@@ -87,7 +87,7 @@ static void virtio_gpu_update_display(void *opaque)
{
}
-static void virtio_gpu_text_update(void *opaque, console_ch_t *chardata)
+static void virtio_gpu_text_update(void *opaque, uint32_t *chardata)
{
}
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
index 5e087169f2f..02fb36b31fc 100644
--- a/hw/display/virtio-vga.c
+++ b/hw/display/virtio-vga.c
@@ -31,7 +31,7 @@ static void virtio_vga_base_update_display(void *opaque)
}
}
-static void virtio_vga_base_text_update(void *opaque, console_ch_t *chardata)
+static void virtio_vga_base_text_update(void *opaque, uint32_t *chardata)
{
VirtIOVGABase *vvga = opaque;
VirtIOGPUBase *g = vvga->vgpu;
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index c2c6bc76e90..1e154e7f99e 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -1183,7 +1183,7 @@ static void vmsvga_invalidate_display(void *opaque)
s->invalidated = 1;
}
-static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
+static void vmsvga_text_update(void *opaque, uint32_t *chardata)
{
struct vmsvga_state_s *s = opaque;
diff --git a/ui/console-vc.c b/ui/console-vc.c
index b30adac83ac..ba440c50744 100644
--- a/ui/console-vc.c
+++ b/ui/console-vc.c
@@ -381,7 +381,7 @@ void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym)
vt100_keysym(&s->vt, keysym);
}
-static void text_console_update(void *opaque, console_ch_t *chardata)
+static void text_console_update(void *opaque, uint32_t *chardata)
{
QemuTextConsole *s = QEMU_TEXT_CONSOLE(opaque);
int i, j, src;
@@ -391,11 +391,10 @@ static void text_console_update(void *opaque, console_ch_t *chardata)
chardata += s->vt.text_y[0] * s->vt.width;
for (i = s->vt.text_y[0]; i <= s->vt.text_y[1]; i ++)
for (j = 0; j < s->vt.width; j++, src++) {
- console_write_ch(chardata ++,
- ATTR2CHTYPE(s->vt.cells[src].ch,
- s->vt.cells[src].t_attrib.fgcol,
- s->vt.cells[src].t_attrib.bgcol,
- s->vt.cells[src].t_attrib.bold));
+ *chardata++ = ATTR2CHTYPE(s->vt.cells[src].ch,
+ s->vt.cells[src].t_attrib.fgcol,
+ s->vt.cells[src].t_attrib.bgcol,
+ s->vt.cells[src].t_attrib.bold);
}
dpy_text_update(QEMU_CONSOLE(s), s->vt.text_x[0], s->vt.text_y[0],
s->vt.text_x[1] - s->vt.text_x[0], i - s->vt.text_y[0]);
diff --git a/ui/console.c b/ui/console.c
index 8af1dee0e22..b2b879e8533 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -214,7 +214,7 @@ void graphic_hw_invalidate(QemuConsole *con)
}
}
-void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata)
+void graphic_hw_text_update(QemuConsole *con, uint32_t *chardata)
{
if (con && con->hw_ops->text_update) {
con->hw_ops->text_update(con->hw, chardata);
diff --git a/ui/curses.c b/ui/curses.c
index 161f78c35c3..78f21d940e3 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -57,7 +57,7 @@ enum maybe_keycode {
};
static DisplayChangeListener *dcl;
-static console_ch_t *screen;
+static uint32_t *screen;
static WINDOW *screenpad = NULL;
static int width, height, gwidth, gheight, invalidate;
static int px, py, sminx, sminy, smaxx, smaxy;
@@ -68,7 +68,7 @@ static cchar_t *vga_to_curses;
static void curses_update(DisplayChangeListener *dcl,
int x, int y, int w, int h)
{
- console_ch_t *line;
+ uint32_t *line;
g_autofree cchar_t *curses_line = g_new(cchar_t, width);
wchar_t wch[CCHARW_MAX];
attr_t attrs;
@@ -796,7 +796,7 @@ static void curses_display_init(DisplayState *ds, DisplayOptions *opts)
if (opts->u.curses.charset) {
font_charset = opts->u.curses.charset;
}
- screen = g_new0(console_ch_t, 160 * 100);
+ screen = g_new0(uint32_t, 160 * 100);
vga_to_curses = g_new0(cchar_t, 256);
curses_setup();
curses_keyboard_setup();
--
2.53.0