PCI save/restore changes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2115 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
89b6b50892
commit
1941d19c65
25
hw/ne2000.c
25
hw/ne2000.c
@ -648,6 +648,9 @@ static void ne2000_save(QEMUFile* f,void* opaque)
|
||||
{
|
||||
NE2000State* s=(NE2000State*)opaque;
|
||||
|
||||
if (s->pci_dev)
|
||||
pci_device_save(s->pci_dev, f);
|
||||
|
||||
qemu_put_8s(f, &s->rxcr);
|
||||
|
||||
qemu_put_8s(f, &s->cmd);
|
||||
@ -673,13 +676,21 @@ static void ne2000_save(QEMUFile* f,void* opaque)
|
||||
static int ne2000_load(QEMUFile* f,void* opaque,int version_id)
|
||||
{
|
||||
NE2000State* s=(NE2000State*)opaque;
|
||||
int ret;
|
||||
|
||||
if (version_id == 2) {
|
||||
qemu_get_8s(f, &s->rxcr);
|
||||
} else if (version_id == 1) {
|
||||
s->rxcr = 0x0c;
|
||||
} else {
|
||||
if (version_id > 3)
|
||||
return -EINVAL;
|
||||
|
||||
if (s->pci_dev && version_id >= 3) {
|
||||
ret = pci_device_load(s->pci_dev, f);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (version_id >= 2) {
|
||||
qemu_get_8s(f, &s->rxcr);
|
||||
} else {
|
||||
s->rxcr = 0x0c;
|
||||
}
|
||||
|
||||
qemu_get_8s(f, &s->cmd);
|
||||
@ -810,7 +821,5 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd)
|
||||
s->macaddr[5]);
|
||||
|
||||
/* XXX: instance number ? */
|
||||
register_savevm("ne2000", 0, 2, ne2000_save, ne2000_load, s);
|
||||
register_savevm("ne2000_pci", 0, 1, generic_pci_save, generic_pci_load,
|
||||
&d->dev);
|
||||
register_savevm("ne2000", 0, 3, ne2000_save, ne2000_load, s);
|
||||
}
|
||||
|
15
hw/pci.c
15
hw/pci.c
@ -36,6 +36,8 @@ struct PCIBus {
|
||||
PCIDevice *devices[256];
|
||||
};
|
||||
|
||||
static void pci_update_mappings(PCIDevice *d);
|
||||
|
||||
target_phys_addr_t pci_mem_base;
|
||||
static int pci_irq_index;
|
||||
static PCIBus *first_bus;
|
||||
@ -56,21 +58,20 @@ int pci_bus_num(PCIBus *s)
|
||||
return s->bus_num;
|
||||
}
|
||||
|
||||
void generic_pci_save(QEMUFile* f, void *opaque)
|
||||
void pci_device_save(PCIDevice *s, QEMUFile *f)
|
||||
{
|
||||
PCIDevice* s=(PCIDevice*)opaque;
|
||||
|
||||
qemu_put_be32(f, 1); /* PCI device version */
|
||||
qemu_put_buffer(f, s->config, 256);
|
||||
}
|
||||
|
||||
int generic_pci_load(QEMUFile* f, void *opaque, int version_id)
|
||||
int pci_device_load(PCIDevice *s, QEMUFile *f)
|
||||
{
|
||||
PCIDevice* s=(PCIDevice*)opaque;
|
||||
|
||||
uint32_t version_id;
|
||||
version_id = qemu_get_be32(f);
|
||||
if (version_id != 1)
|
||||
return -EINVAL;
|
||||
|
||||
qemu_get_buffer(f, s->config, 256);
|
||||
pci_update_mappings(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -181,6 +181,20 @@ static void piix3_reset(PCIDevice *d)
|
||||
pci_conf[0xae] = 0x00;
|
||||
}
|
||||
|
||||
static void piix_save(QEMUFile* f, void *opaque)
|
||||
{
|
||||
PCIDevice *d = opaque;
|
||||
pci_device_save(d, f);
|
||||
}
|
||||
|
||||
static int piix_load(QEMUFile* f, void *opaque, int version_id)
|
||||
{
|
||||
PCIDevice *d = opaque;
|
||||
if (version_id != 2)
|
||||
return -EINVAL;
|
||||
return pci_device_load(d, f);
|
||||
}
|
||||
|
||||
int piix3_init(PCIBus *bus)
|
||||
{
|
||||
PCIDevice *d;
|
||||
@ -188,7 +202,7 @@ int piix3_init(PCIBus *bus)
|
||||
|
||||
d = pci_register_device(bus, "PIIX3", sizeof(PCIDevice),
|
||||
-1, NULL, NULL);
|
||||
register_savevm("PIIX3", 0, 1, generic_pci_save, generic_pci_load, d);
|
||||
register_savevm("PIIX3", 0, 2, piix_save, piix_load, d);
|
||||
|
||||
piix3_dev = d;
|
||||
pci_conf = d->config;
|
||||
|
16
hw/rtl8139.c
16
hw/rtl8139.c
@ -3122,6 +3122,8 @@ static void rtl8139_save(QEMUFile* f,void* opaque)
|
||||
RTL8139State* s=(RTL8139State*)opaque;
|
||||
int i;
|
||||
|
||||
pci_device_save(s->pci_dev, f);
|
||||
|
||||
qemu_put_buffer(f, s->phys, 6);
|
||||
qemu_put_buffer(f, s->mult, 8);
|
||||
|
||||
@ -3203,12 +3205,18 @@ static void rtl8139_save(QEMUFile* f,void* opaque)
|
||||
static int rtl8139_load(QEMUFile* f,void* opaque,int version_id)
|
||||
{
|
||||
RTL8139State* s=(RTL8139State*)opaque;
|
||||
int i;
|
||||
int i, ret;
|
||||
|
||||
/* just 2 versions for now */
|
||||
if (version_id > 2)
|
||||
if (version_id > 3)
|
||||
return -EINVAL;
|
||||
|
||||
if (version_id >= 3) {
|
||||
ret = pci_device_load(s->pci_dev, f);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* saved since version 1 */
|
||||
qemu_get_buffer(f, s->phys, 6);
|
||||
qemu_get_buffer(f, s->mult, 8);
|
||||
@ -3457,9 +3465,7 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd)
|
||||
s->cplus_txbuffer_offset = 0;
|
||||
|
||||
/* XXX: instance number ? */
|
||||
register_savevm("rtl8139", 0, 2, rtl8139_save, rtl8139_load, s);
|
||||
register_savevm("rtl8139_pci", 0, 1, generic_pci_save, generic_pci_load,
|
||||
&d->dev);
|
||||
register_savevm("rtl8139", 0, 3, rtl8139_save, rtl8139_load, s);
|
||||
|
||||
#if RTL8139_ONBOARD_TIMER
|
||||
s->timer = qemu_new_timer(vm_clock, rtl8139_timer, s);
|
||||
|
Loading…
Reference in New Issue
Block a user