vga_mem_writel,
};
-static void vga_save(QEMUFile *f, void *opaque)
+void vga_common_save(QEMUFile *f, void *opaque)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
int i;
- if (s->pci_dev)
- pci_device_save(s->pci_dev, f);
-
qemu_put_be32s(f, &s->latch);
qemu_put_8s(f, &s->sr_index);
qemu_put_buffer(f, s->sr, 8);
#endif
}
-static int vga_load(QEMUFile *f, void *opaque, int version_id)
+int vga_common_load(QEMUFile *f, void *opaque, int version_id)
{
- VGAState *s = opaque;
- int is_vbe, i, ret;
+ VGACommonState *s = opaque;
+ int is_vbe, i;
if (version_id > 2)
return -EINVAL;
- if (s->pci_dev && version_id >= 2) {
- ret = pci_device_load(s->pci_dev, f);
- if (ret < 0)
- return ret;
- }
-
qemu_get_be32s(f, &s->latch);
qemu_get_8s(f, &s->sr_index);
qemu_get_buffer(f, s->sr, 8);
typedef struct PCIVGAState {
PCIDevice dev;
- VGAState vga;
+ VGACommonState vga;
} PCIVGAState;
+static void pci_vga_save(QEMUFile *f, void *opaque)
+{
+ PCIVGAState *s = opaque;
+
+ pci_device_save(&s->dev, f);
+ vga_common_save(f, &s->vga);
+}
+
+static int pci_vga_load(QEMUFile *f, void *opaque, int version_id)
+{
+ PCIVGAState *s = opaque;
+ int ret;
+
+ if (version_id > 2)
+ return -EINVAL;
+
+ if (version_id >= 2) {
+ ret = pci_device_load(&s->dev, f);
+ if (ret < 0)
+ return ret;
+ }
+ return vga_common_load(f, &s->vga, version_id);
+}
+
void vga_dirty_log_start(VGAState *s)
{
if (kvm_enabled() && s->map_addr)
int vga_io_memory;
qemu_register_reset(vga_reset, s);
- register_savevm("vga", 0, 2, vga_save, vga_load, s);
register_ioport_write(0x3c0, 16, 1, vga_ioport_write, s);
s_ioport_ctrl = cpu_register_io_memory(vga_mm_read_ctrl, vga_mm_write_ctrl, s);
vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s);
- register_savevm("vga", 0, 2, vga_save, vga_load, s);
+ register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s);
cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl);
s->bank_offset = 0;
vga_common_init(s, VGA_RAM_SIZE);
vga_init(s);
+ register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s);
s->ds = graphic_console_init(s->update, s->invalidate,
s->screen_dump, s->text_update, s);
// vga + console init
vga_common_init(s, VGA_RAM_SIZE);
vga_init(s);
- s->pci_dev = &d->dev;
+ register_savevm("vga", 0, 2, pci_vga_save, pci_vga_load, d);
+
s->ds = graphic_console_init(s->update, s->invalidate,
s->screen_dump, s->text_update, s);