Add pci_cirrus_vga_{save/load} functions, then remove vga.pci_dev use

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Juan Quintela 2009-08-24 18:42:56 +02:00 committed by Anthony Liguori
parent f3566bf92d
commit 4f335febba

View File

@ -3021,9 +3021,6 @@ static void cirrus_vga_save(QEMUFile *f, void *opaque)
{
CirrusVGAState *s = opaque;
if (s->vga.pci_dev)
pci_device_save(s->vga.pci_dev, f);
qemu_put_be32s(f, &s->vga.latch);
qemu_put_8s(f, &s->vga.sr_index);
qemu_put_buffer(f, s->vga.sr, 256);
@ -3062,17 +3059,10 @@ static void cirrus_vga_save(QEMUFile *f, void *opaque)
static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)
{
CirrusVGAState *s = opaque;
int ret;
if (version_id > 2)
return -EINVAL;
if (s->vga.pci_dev && version_id >= 2) {
ret = pci_device_load(s->vga.pci_dev, f);
if (ret < 0)
return ret;
}
qemu_get_be32s(f, &s->vga.latch);
qemu_get_8s(f, &s->vga.sr_index);
qemu_get_buffer(f, s->vga.sr, 256);
@ -3115,6 +3105,31 @@ static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
static void pci_cirrus_vga_save(QEMUFile *f, void *opaque)
{
PCICirrusVGAState *s = opaque;
pci_device_save(&s->dev, f);
cirrus_vga_save(f, &s->cirrus_vga);
}
static int pci_cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)
{
PCICirrusVGAState *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 cirrus_vga_load(f, &s->cirrus_vga, version_id);
}
/***************************************
*
* initialize
@ -3231,7 +3246,6 @@ static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci)
qemu_register_reset(cirrus_reset, s);
cirrus_reset(s);
register_savevm("cirrus_vga", 0, 2, cirrus_vga_save, cirrus_vga_load, s);
}
/***************************************
@ -3251,6 +3265,7 @@ void isa_cirrus_vga_init(void)
s->vga.ds = graphic_console_init(s->vga.update, s->vga.invalidate,
s->vga.screen_dump, s->vga.text_update,
&s->vga);
register_savevm("cirrus_vga", 0, 2, cirrus_vga_save, cirrus_vga_load, s);
/* XXX ISA-LFB support */
}
@ -3312,7 +3327,6 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
/* setup VGA */
vga_common_init(&s->vga, VGA_RAM_SIZE);
cirrus_init_common(s, device_id, 1);
s->vga.pci_dev = dev;
s->vga.ds = graphic_console_init(s->vga.update, s->vga.invalidate,
s->vga.screen_dump, s->vga.text_update,
&s->vga);
@ -3334,6 +3348,7 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
pci_register_bar((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,
PCI_ADDRESS_SPACE_MEM, cirrus_pci_mmio_map);
}
register_savevm("cirrus_vga", 0, 2, pci_cirrus_vga_save, pci_cirrus_vga_load, d);
/* XXX: ROM BIOS */
return 0;
}