ia64/xen-unstable

changeset 14653:8f5a947c0ea6

[HVM] Save/restore: backport pcnet save/restore from qemu tip.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Thu Mar 29 15:29:15 2007 +0000 (2007-03-29)
parents 19f33f5ba96b
children f06535a8ae9f
files tools/ioemu/hw/pcnet.c
line diff
     1.1 --- a/tools/ioemu/hw/pcnet.c	Thu Mar 29 15:28:27 2007 +0000
     1.2 +++ b/tools/ioemu/hw/pcnet.c	Thu Mar 29 15:29:15 2007 +0000
     1.3 @@ -1727,6 +1727,58 @@ static void pcnet_mmio_map(PCIDevice *pc
     1.4      cpu_register_physical_memory(addr, PCNET_PNPMMIO_SIZE, d->mmio_io_addr);
     1.5  }
     1.6  
     1.7 +
     1.8 +static void pcnet_save(QEMUFile *f, void *opaque)
     1.9 +{
    1.10 +    PCNetState *s = opaque;
    1.11 +    unsigned int i;
    1.12 +
    1.13 +    qemu_put_be32s(f, &s->rap);
    1.14 +    qemu_put_be32s(f, &s->isr);
    1.15 +    qemu_put_be32s(f, &s->lnkst);
    1.16 +    qemu_put_be32s(f, &s->rdra);
    1.17 +    qemu_put_be32s(f, &s->tdra);
    1.18 +    qemu_put_buffer(f, s->prom, 16);
    1.19 +    for (i = 0; i < 128; i++)
    1.20 +        qemu_put_be16s(f, &s->csr[i]);
    1.21 +    for (i = 0; i < 32; i++)
    1.22 +        qemu_put_be16s(f, &s->bcr[i]);
    1.23 +    qemu_put_be64s(f, &s->timer);
    1.24 +    qemu_put_be32s(f, &s->xmit_pos);
    1.25 +    qemu_put_be32s(f, &s->recv_pos);
    1.26 +    qemu_put_buffer(f, s->buffer, 4096);
    1.27 +    qemu_put_be32s(f, &s->tx_busy);
    1.28 +    qemu_put_timer(f, s->poll_timer);
    1.29 +}
    1.30 +
    1.31 +static int pcnet_load(QEMUFile *f, void *opaque, int version_id)
    1.32 +{
    1.33 +    PCNetState *s = opaque;
    1.34 +    int i, ret;
    1.35 +
    1.36 +    if (version_id != 1)
    1.37 +        return -EINVAL;
    1.38 +
    1.39 +    qemu_get_be32s(f, &s->rap);
    1.40 +    qemu_get_be32s(f, &s->isr);
    1.41 +    qemu_get_be32s(f, &s->lnkst);
    1.42 +    qemu_get_be32s(f, &s->rdra);
    1.43 +    qemu_get_be32s(f, &s->tdra);
    1.44 +    qemu_get_buffer(f, s->prom, 16);
    1.45 +    for (i = 0; i < 128; i++)
    1.46 +        qemu_get_be16s(f, &s->csr[i]);
    1.47 +    for (i = 0; i < 32; i++)
    1.48 +        qemu_get_be16s(f, &s->bcr[i]);
    1.49 +    qemu_get_be64s(f, &s->timer);
    1.50 +    qemu_get_be32s(f, &s->xmit_pos);
    1.51 +    qemu_get_be32s(f, &s->recv_pos);
    1.52 +    qemu_get_buffer(f, s->buffer, 4096);
    1.53 +    qemu_get_be32s(f, &s->tx_busy);
    1.54 +    qemu_get_timer(f, s->poll_timer);
    1.55 +
    1.56 +    return 0;
    1.57 +}
    1.58 +
    1.59  void pci_pcnet_init(PCIBus *bus, NICInfo *nd)
    1.60  {
    1.61      PCNetState *d;
    1.62 @@ -1775,6 +1827,10 @@ void pci_pcnet_init(PCIBus *bus, NICInfo
    1.63  
    1.64      d->vc = qemu_new_vlan_client(nd->vlan, pcnet_receive, 
    1.65                                   pcnet_can_receive, d);
    1.66 +
    1.67 +    register_savevm("pcnet", 0, 1, pcnet_save, pcnet_load, d);
    1.68 +    register_savevm("pcnet_pci", 0, 1, generic_pci_save, generic_pci_load, 
    1.69 +                    &d->dev);
    1.70      
    1.71      snprintf(d->vc->info_str, sizeof(d->vc->info_str),
    1.72               "pcnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x",