Skip to content
Snippets Groups Projects
Commit d5bfbaca authored by Mark Cave-Ayland's avatar Mark Cave-Ayland Committed by Philippe Mathieu-Daudé
Browse files

g364fb: use RAM memory region for framebuffer


Since the migration stream is already broken, we can use this opportunity to
change the framebuffer so that it is migrated as a RAM memory region rather
than as an array of bytes.

In particular this helps the output of the analyze-migration.py tool which
no longer contains a huge array representing the framebuffer contents.

Signed-off-by: default avatarMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210625163554.14879-2-mark.cave-ayland@ilande.co.uk>
Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
parent 11984b18
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "hw/hw.h" #include "hw/hw.h"
#include "hw/irq.h" #include "hw/irq.h"
#include "hw/qdev-properties.h" #include "hw/qdev-properties.h"
#include "qapi/error.h"
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "qemu/module.h" #include "qemu/module.h"
#include "ui/console.h" #include "ui/console.h"
...@@ -33,7 +34,6 @@ ...@@ -33,7 +34,6 @@
typedef struct G364State { typedef struct G364State {
/* hardware */ /* hardware */
uint8_t *vram;
uint32_t vram_size; uint32_t vram_size;
qemu_irq irq; qemu_irq irq;
MemoryRegion mem_vram; MemoryRegion mem_vram;
...@@ -125,7 +125,7 @@ static void g364fb_draw_graphic8(G364State *s) ...@@ -125,7 +125,7 @@ static void g364fb_draw_graphic8(G364State *s)
xcursor = ycursor = -65; xcursor = ycursor = -65;
} }
vram = s->vram + s->top_of_screen; vram = memory_region_get_ram_ptr(&s->mem_vram) + s->top_of_screen;
/* XXX: out of range in vram? */ /* XXX: out of range in vram? */
data_display = dd = surface_data(surface); data_display = dd = surface_data(surface);
snap = memory_region_snapshot_and_clear_dirty(&s->mem_vram, 0, s->vram_size, snap = memory_region_snapshot_and_clear_dirty(&s->mem_vram, 0, s->vram_size,
...@@ -274,6 +274,8 @@ static inline void g364fb_invalidate_display(void *opaque) ...@@ -274,6 +274,8 @@ static inline void g364fb_invalidate_display(void *opaque)
static void g364fb_reset(G364State *s) static void g364fb_reset(G364State *s)
{ {
uint8_t *vram = memory_region_get_ram_ptr(&s->mem_vram);
qemu_irq_lower(s->irq); qemu_irq_lower(s->irq);
memset(s->color_palette, 0, sizeof(s->color_palette)); memset(s->color_palette, 0, sizeof(s->color_palette));
...@@ -283,7 +285,7 @@ static void g364fb_reset(G364State *s) ...@@ -283,7 +285,7 @@ static void g364fb_reset(G364State *s)
s->ctla = 0; s->ctla = 0;
s->top_of_screen = 0; s->top_of_screen = 0;
s->width = s->height = 0; s->width = s->height = 0;
memset(s->vram, 0, s->vram_size); memset(vram, 0, s->vram_size);
g364fb_invalidate_display(s); g364fb_invalidate_display(s);
} }
...@@ -450,11 +452,10 @@ static int g364fb_post_load(void *opaque, int version_id) ...@@ -450,11 +452,10 @@ static int g364fb_post_load(void *opaque, int version_id)
static const VMStateDescription vmstate_g364fb = { static const VMStateDescription vmstate_g364fb = {
.name = "g364fb", .name = "g364fb",
.version_id = 1, .version_id = 2,
.minimum_version_id = 1, .minimum_version_id = 2,
.post_load = g364fb_post_load, .post_load = g364fb_post_load,
.fields = (VMStateField[]) { .fields = (VMStateField[]) {
VMSTATE_VBUFFER_UINT32(vram, G364State, 1, NULL, vram_size),
VMSTATE_BUFFER_UNSAFE(color_palette, G364State, 0, 256 * 3), VMSTATE_BUFFER_UNSAFE(color_palette, G364State, 0, 256 * 3),
VMSTATE_BUFFER_UNSAFE(cursor_palette, G364State, 0, 9), VMSTATE_BUFFER_UNSAFE(cursor_palette, G364State, 0, 9),
VMSTATE_UINT16_ARRAY(cursor, G364State, 512), VMSTATE_UINT16_ARRAY(cursor, G364State, 512),
...@@ -474,15 +475,12 @@ static const GraphicHwOps g364fb_ops = { ...@@ -474,15 +475,12 @@ static const GraphicHwOps g364fb_ops = {
static void g364fb_init(DeviceState *dev, G364State *s) static void g364fb_init(DeviceState *dev, G364State *s)
{ {
s->vram = g_malloc0(s->vram_size);
s->con = graphic_console_init(dev, 0, &g364fb_ops, s); s->con = graphic_console_init(dev, 0, &g364fb_ops, s);
memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &g364fb_ctrl_ops, s, memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &g364fb_ctrl_ops, s,
"ctrl", 0x180000); "ctrl", 0x180000);
memory_region_init_ram_ptr(&s->mem_vram, NULL, "vram", memory_region_init_ram(&s->mem_vram, NULL, "g364fb.vram", s->vram_size,
s->vram_size, s->vram); &error_fatal);
vmstate_register_ram(&s->mem_vram, dev);
memory_region_set_log(&s->mem_vram, true, DIRTY_MEMORY_VGA); memory_region_set_log(&s->mem_vram, true, DIRTY_MEMORY_VGA);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment