Revision 151b2986 hw/eepro100.c
b/hw/eepro100.c | ||
---|---|---|
220 | 220 |
|
221 | 221 |
/* Data in mem is always in the byte order of the controller (le). */ |
222 | 222 |
uint8_t mem[PCI_MEM_SIZE]; |
223 |
/* vmstate for each particular nic */ |
|
224 |
VMStateDescription *vmstate; |
|
223 | 225 |
} EEPRO100State; |
224 | 226 |
|
225 | 227 |
/* Default values for MDI (PHY) registers */ |
... | ... | |
1597 | 1599 |
return size; |
1598 | 1600 |
} |
1599 | 1601 |
|
1600 |
static int nic_load(QEMUFile * f, void *opaque, int version_id) |
|
1601 |
{ |
|
1602 |
EEPRO100State *s = opaque; |
|
1603 |
int i; |
|
1604 |
int ret; |
|
1605 |
|
|
1606 |
if (version_id > 3) |
|
1607 |
return -EINVAL; |
|
1608 |
|
|
1609 |
ret = pci_device_load(&s->dev, f); |
|
1610 |
if (ret < 0) { |
|
1611 |
return ret; |
|
1612 |
} |
|
1613 |
|
|
1614 |
/* Skip unused entries. */ |
|
1615 |
qemu_fseek(f, 32, SEEK_CUR); |
|
1616 |
|
|
1617 |
qemu_get_buffer(f, s->mult, 8); |
|
1618 |
qemu_get_buffer(f, s->mem, sizeof(s->mem)); |
|
1619 |
|
|
1620 |
/* Restore all members of struct between scb_stat and mem. */ |
|
1621 |
qemu_get_8s(f, &s->scb_stat); |
|
1622 |
qemu_get_8s(f, &s->int_stat); |
|
1623 |
/* Skip unused entries. */ |
|
1624 |
qemu_fseek(f, 3 * 4, SEEK_CUR); |
|
1625 |
qemu_get_buffer(f, s->conf.macaddr.a, 6); |
|
1626 |
/* Skip unused entries. */ |
|
1627 |
qemu_fseek(f, 19 * 4, SEEK_CUR); |
|
1628 |
for (i = 0; i < 32; i++) { |
|
1629 |
qemu_get_be16s(f, &s->mdimem[i]); |
|
1630 |
} |
|
1631 |
/* The eeprom should be saved and restored by its own routines. */ |
|
1632 |
qemu_get_be32s(f, &s->device); |
|
1633 |
// TODO check device. |
|
1634 |
qemu_get_be32s(f, &s->pointer); |
|
1635 |
qemu_get_be32s(f, &s->cu_base); |
|
1636 |
qemu_get_be32s(f, &s->cu_offset); |
|
1637 |
qemu_get_be32s(f, &s->ru_base); |
|
1638 |
qemu_get_be32s(f, &s->ru_offset); |
|
1639 |
qemu_get_be32s(f, &s->statsaddr); |
|
1640 |
/* Restore epro100_stats_t statistics. */ |
|
1641 |
qemu_get_be32s(f, &s->statistics.tx_good_frames); |
|
1642 |
qemu_get_be32s(f, &s->statistics.tx_max_collisions); |
|
1643 |
qemu_get_be32s(f, &s->statistics.tx_late_collisions); |
|
1644 |
qemu_get_be32s(f, &s->statistics.tx_underruns); |
|
1645 |
qemu_get_be32s(f, &s->statistics.tx_lost_crs); |
|
1646 |
qemu_get_be32s(f, &s->statistics.tx_deferred); |
|
1647 |
qemu_get_be32s(f, &s->statistics.tx_single_collisions); |
|
1648 |
qemu_get_be32s(f, &s->statistics.tx_multiple_collisions); |
|
1649 |
qemu_get_be32s(f, &s->statistics.tx_total_collisions); |
|
1650 |
qemu_get_be32s(f, &s->statistics.rx_good_frames); |
|
1651 |
qemu_get_be32s(f, &s->statistics.rx_crc_errors); |
|
1652 |
qemu_get_be32s(f, &s->statistics.rx_alignment_errors); |
|
1653 |
qemu_get_be32s(f, &s->statistics.rx_resource_errors); |
|
1654 |
qemu_get_be32s(f, &s->statistics.rx_overrun_errors); |
|
1655 |
qemu_get_be32s(f, &s->statistics.rx_cdt_errors); |
|
1656 |
qemu_get_be32s(f, &s->statistics.rx_short_frame_errors); |
|
1657 |
qemu_get_be32s(f, &s->statistics.fc_xmt_pause); |
|
1658 |
qemu_get_be32s(f, &s->statistics.fc_rcv_pause); |
|
1659 |
qemu_get_be32s(f, &s->statistics.fc_rcv_unsupported); |
|
1660 |
qemu_get_be16s(f, &s->statistics.xmt_tco_frames); |
|
1661 |
qemu_get_be16s(f, &s->statistics.rcv_tco_frames); |
|
1662 |
qemu_get_be32s(f, &s->statistics.complete); |
|
1602 |
static const VMStateDescription vmstate_eepro100 = { |
|
1603 |
.version_id = 3, |
|
1604 |
.minimum_version_id = 2, |
|
1605 |
.minimum_version_id_old = 2, |
|
1606 |
.fields = (VMStateField []) { |
|
1607 |
VMSTATE_PCI_DEVICE(dev, EEPRO100State), |
|
1608 |
VMSTATE_UNUSED(32), |
|
1609 |
VMSTATE_BUFFER(mult, EEPRO100State), |
|
1610 |
VMSTATE_BUFFER(mem, EEPRO100State), |
|
1611 |
/* Save all members of struct between scb_stat and mem. */ |
|
1612 |
VMSTATE_UINT8(scb_stat, EEPRO100State), |
|
1613 |
VMSTATE_UINT8(int_stat, EEPRO100State), |
|
1614 |
VMSTATE_UNUSED(3*4), |
|
1615 |
VMSTATE_MACADDR(conf.macaddr, EEPRO100State), |
|
1616 |
VMSTATE_UNUSED(19*4), |
|
1617 |
VMSTATE_UINT16_ARRAY(mdimem, EEPRO100State, 32), |
|
1618 |
/* The eeprom should be saved and restored by its own routines. */ |
|
1619 |
VMSTATE_UINT32(device, EEPRO100State), |
|
1620 |
/* TODO check device. */ |
|
1621 |
VMSTATE_UINT32(pointer, EEPRO100State), |
|
1622 |
VMSTATE_UINT32(cu_base, EEPRO100State), |
|
1623 |
VMSTATE_UINT32(cu_offset, EEPRO100State), |
|
1624 |
VMSTATE_UINT32(ru_base, EEPRO100State), |
|
1625 |
VMSTATE_UINT32(ru_offset, EEPRO100State), |
|
1626 |
VMSTATE_UINT32(statsaddr, EEPRO100State), |
|
1627 |
/* Save epro100_stats_t statistics. */ |
|
1628 |
VMSTATE_UINT32(statistics.tx_good_frames, EEPRO100State), |
|
1629 |
VMSTATE_UINT32(statistics.tx_max_collisions, EEPRO100State), |
|
1630 |
VMSTATE_UINT32(statistics.tx_late_collisions, EEPRO100State), |
|
1631 |
VMSTATE_UINT32(statistics.tx_underruns, EEPRO100State), |
|
1632 |
VMSTATE_UINT32(statistics.tx_lost_crs, EEPRO100State), |
|
1633 |
VMSTATE_UINT32(statistics.tx_deferred, EEPRO100State), |
|
1634 |
VMSTATE_UINT32(statistics.tx_single_collisions, EEPRO100State), |
|
1635 |
VMSTATE_UINT32(statistics.tx_multiple_collisions, EEPRO100State), |
|
1636 |
VMSTATE_UINT32(statistics.tx_total_collisions, EEPRO100State), |
|
1637 |
VMSTATE_UINT32(statistics.rx_good_frames, EEPRO100State), |
|
1638 |
VMSTATE_UINT32(statistics.rx_crc_errors, EEPRO100State), |
|
1639 |
VMSTATE_UINT32(statistics.rx_alignment_errors, EEPRO100State), |
|
1640 |
VMSTATE_UINT32(statistics.rx_resource_errors, EEPRO100State), |
|
1641 |
VMSTATE_UINT32(statistics.rx_overrun_errors, EEPRO100State), |
|
1642 |
VMSTATE_UINT32(statistics.rx_cdt_errors, EEPRO100State), |
|
1643 |
VMSTATE_UINT32(statistics.rx_short_frame_errors, EEPRO100State), |
|
1644 |
VMSTATE_UINT32(statistics.fc_xmt_pause, EEPRO100State), |
|
1645 |
VMSTATE_UINT32(statistics.fc_rcv_pause, EEPRO100State), |
|
1646 |
VMSTATE_UINT32(statistics.fc_rcv_unsupported, EEPRO100State), |
|
1647 |
VMSTATE_UINT16(statistics.xmt_tco_frames, EEPRO100State), |
|
1648 |
VMSTATE_UINT16(statistics.rcv_tco_frames, EEPRO100State), |
|
1649 |
VMSTATE_UINT32(statistics.complete, EEPRO100State), |
|
1663 | 1650 |
#if 0 |
1664 |
qemu_get_be16s(f, &s->status);
|
|
1651 |
VMSTATE_UINT16(status, EEPRO100State),
|
|
1665 | 1652 |
#endif |
1666 |
|
|
1667 |
/* Configuration bytes. */ |
|
1668 |
qemu_get_buffer(f, s->configuration, sizeof(s->configuration)); |
|
1669 |
|
|
1670 |
return 0; |
|
1671 |
} |
|
1672 |
|
|
1673 |
static void nic_save(QEMUFile * f, void *opaque) |
|
1674 |
{ |
|
1675 |
EEPRO100State *s = opaque; |
|
1676 |
int i; |
|
1677 |
|
|
1678 |
pci_device_save(&s->dev, f); |
|
1679 |
|
|
1680 |
/* Skip unused entries. */ |
|
1681 |
qemu_fseek(f, 32, SEEK_CUR); |
|
1682 |
|
|
1683 |
qemu_put_buffer(f, s->mult, 8); |
|
1684 |
qemu_put_buffer(f, s->mem, sizeof(s->mem)); |
|
1685 |
|
|
1686 |
/* Save all members of struct between scb_stat and mem. */ |
|
1687 |
qemu_put_8s(f, &s->scb_stat); |
|
1688 |
qemu_put_8s(f, &s->int_stat); |
|
1689 |
/* Skip unused entries. */ |
|
1690 |
qemu_fseek(f, 3 * 4, SEEK_CUR); |
|
1691 |
qemu_put_buffer(f, s->conf.macaddr.a, 6); |
|
1692 |
/* Skip unused entries. */ |
|
1693 |
qemu_fseek(f, 19 * 4, SEEK_CUR); |
|
1694 |
for (i = 0; i < 32; i++) { |
|
1695 |
qemu_put_be16s(f, &s->mdimem[i]); |
|
1653 |
/* Configuration bytes. */ |
|
1654 |
VMSTATE_BUFFER(configuration, EEPRO100State), |
|
1655 |
VMSTATE_END_OF_LIST() |
|
1696 | 1656 |
} |
1697 |
/* The eeprom should be saved and restored by its own routines. */ |
|
1698 |
qemu_put_be32s(f, &s->device); |
|
1699 |
qemu_put_be32s(f, &s->pointer); |
|
1700 |
qemu_put_be32s(f, &s->cu_base); |
|
1701 |
qemu_put_be32s(f, &s->cu_offset); |
|
1702 |
qemu_put_be32s(f, &s->ru_base); |
|
1703 |
qemu_put_be32s(f, &s->ru_offset); |
|
1704 |
qemu_put_be32s(f, &s->statsaddr); |
|
1705 |
/* Save epro100_stats_t statistics. */ |
|
1706 |
qemu_put_be32s(f, &s->statistics.tx_good_frames); |
|
1707 |
qemu_put_be32s(f, &s->statistics.tx_max_collisions); |
|
1708 |
qemu_put_be32s(f, &s->statistics.tx_late_collisions); |
|
1709 |
qemu_put_be32s(f, &s->statistics.tx_underruns); |
|
1710 |
qemu_put_be32s(f, &s->statistics.tx_lost_crs); |
|
1711 |
qemu_put_be32s(f, &s->statistics.tx_deferred); |
|
1712 |
qemu_put_be32s(f, &s->statistics.tx_single_collisions); |
|
1713 |
qemu_put_be32s(f, &s->statistics.tx_multiple_collisions); |
|
1714 |
qemu_put_be32s(f, &s->statistics.tx_total_collisions); |
|
1715 |
qemu_put_be32s(f, &s->statistics.rx_good_frames); |
|
1716 |
qemu_put_be32s(f, &s->statistics.rx_crc_errors); |
|
1717 |
qemu_put_be32s(f, &s->statistics.rx_alignment_errors); |
|
1718 |
qemu_put_be32s(f, &s->statistics.rx_resource_errors); |
|
1719 |
qemu_put_be32s(f, &s->statistics.rx_overrun_errors); |
|
1720 |
qemu_put_be32s(f, &s->statistics.rx_cdt_errors); |
|
1721 |
qemu_put_be32s(f, &s->statistics.rx_short_frame_errors); |
|
1722 |
qemu_put_be32s(f, &s->statistics.fc_xmt_pause); |
|
1723 |
qemu_put_be32s(f, &s->statistics.fc_rcv_pause); |
|
1724 |
qemu_put_be32s(f, &s->statistics.fc_rcv_unsupported); |
|
1725 |
qemu_put_be16s(f, &s->statistics.xmt_tco_frames); |
|
1726 |
qemu_put_be16s(f, &s->statistics.rcv_tco_frames); |
|
1727 |
qemu_put_be32s(f, &s->statistics.complete); |
|
1728 |
#if 0 |
|
1729 |
qemu_put_be16s(f, &s->status); |
|
1730 |
#endif |
|
1731 |
|
|
1732 |
/* Configuration bytes. */ |
|
1733 |
qemu_put_buffer(f, s->configuration, sizeof(s->configuration)); |
|
1734 |
} |
|
1657 |
}; |
|
1735 | 1658 |
|
1736 | 1659 |
static void nic_cleanup(VLANClientState *vc) |
1737 | 1660 |
{ |
... | ... | |
1745 | 1668 |
EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); |
1746 | 1669 |
|
1747 | 1670 |
cpu_unregister_io_memory(s->mmio_index); |
1748 |
unregister_savevm(s->vc->model, s);
|
|
1671 |
vmstate_unregister(s->vmstate, s);
|
|
1749 | 1672 |
eeprom93xx_free(s->eeprom); |
1750 | 1673 |
qemu_del_vlan_client(s->vc); |
1751 | 1674 |
return 0; |
... | ... | |
1794 | 1717 |
|
1795 | 1718 |
qemu_register_reset(nic_reset, s); |
1796 | 1719 |
|
1797 |
register_savevm(s->vc->model, -1, 3, nic_save, nic_load, s); |
|
1720 |
s->vmstate = qemu_malloc(sizeof(vmstate_eepro100)); |
|
1721 |
memcpy(s->vmstate, &vmstate_eepro100, sizeof(vmstate_eepro100)); |
|
1722 |
s->vmstate->name = s->vc->model; |
|
1723 |
vmstate_register(-1, s->vmstate, s); |
|
1798 | 1724 |
return 0; |
1799 | 1725 |
} |
1800 | 1726 |
|
Also available in: Unified diff