aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-17 10:46:34 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-17 10:46:34 +0000
commit1941d19c657a8084603e88d7860786baa40c0e80 (patch)
treee40f3b80ebfe96c335e594678218ae8b0eb726bc
parent89b6b508929d63b2a3dda18692fcb724afb43336 (diff)
PCI save/restore changes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2115 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--hw/ne2000.c23
-rw-r--r--hw/pci.c15
-rw-r--r--hw/piix_pci.c16
-rw-r--r--hw/rtl8139.c16
4 files changed, 50 insertions, 20 deletions
diff --git a/hw/ne2000.c b/hw/ne2000.c
index e23c6df069..14d48ee95b 100644
--- a/hw/ne2000.c
+++ b/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 > 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) {
+ if (version_id >= 2) {
qemu_get_8s(f, &s->rxcr);
- } else if (version_id == 1) {
- s->rxcr = 0x0c;
} else {
- return -EINVAL;
+ 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);
}
diff --git a/hw/pci.c b/hw/pci.c
index 85531f72ee..75bd981104 100644
--- a/hw/pci.c
+++ b/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;
}
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 1f7ad94c65..672b736ad0 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -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;
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 9c613a8f93..db6353a7e5 100644
--- a/hw/rtl8139.c
+++ b/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);