#include "hw/hw.h"
#include "hw/irq.h"
#include "hw/qdev-properties.h"
+#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/module.h"
#include "ui/console.h"
typedef struct G364State {
/* hardware */
- uint8_t *vram;
uint32_t vram_size;
qemu_irq irq;
MemoryRegion mem_vram;
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? */
data_display = dd = surface_data(surface);
snap = memory_region_snapshot_and_clear_dirty(&s->mem_vram, 0, s->vram_size,
static void g364fb_reset(G364State *s)
{
+ uint8_t *vram = memory_region_get_ram_ptr(&s->mem_vram);
+
qemu_irq_lower(s->irq);
memset(s->color_palette, 0, sizeof(s->color_palette));
s->ctla = 0;
s->top_of_screen = 0;
s->width = s->height = 0;
- memset(s->vram, 0, s->vram_size);
+ memset(vram, 0, s->vram_size);
g364fb_invalidate_display(s);
}
static const VMStateDescription vmstate_g364fb = {
.name = "g364fb",
- .version_id = 1,
- .minimum_version_id = 1,
+ .version_id = 2,
+ .minimum_version_id = 2,
.post_load = g364fb_post_load,
.fields = (VMStateField[]) {
- VMSTATE_VBUFFER_UINT32(vram, G364State, 1, NULL, vram_size),
VMSTATE_BUFFER_UNSAFE(color_palette, G364State, 0, 256 * 3),
VMSTATE_BUFFER_UNSAFE(cursor_palette, G364State, 0, 9),
VMSTATE_UINT16_ARRAY(cursor, G364State, 512),
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);
memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &g364fb_ctrl_ops, s,
"ctrl", 0x180000);
- memory_region_init_ram_ptr(&s->mem_vram, NULL, "vram",
- s->vram_size, s->vram);
- vmstate_register_ram(&s->mem_vram, dev);
+ memory_region_init_ram(&s->mem_vram, NULL, "g364fb.vram", s->vram_size,
+ &error_fatal);
memory_region_set_log(&s->mem_vram, true, DIRTY_MEMORY_VGA);
}