From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MGyee-0005L1-0U for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MGyeW-0005DP-0z for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:27 -0400 Received: from [199.232.76.173] (port=54826 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MGyeU-0005Bk-C0 for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:22 -0400 Received: from mx2.redhat.com ([66.187.237.31]:35952) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MGyeS-0007y5-JS for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:21 -0400 From: Glauber Costa Date: Wed, 17 Jun 2009 13:09:57 -0400 Message-Id: <1245258604-2843-9-git-send-email-glommer@redhat.com> In-Reply-To: <1245258604-2843-8-git-send-email-glommer@redhat.com> References: <1245258604-2843-1-git-send-email-glommer@redhat.com> <1245258604-2843-2-git-send-email-glommer@redhat.com> <1245258604-2843-3-git-send-email-glommer@redhat.com> <1245258604-2843-4-git-send-email-glommer@redhat.com> <1245258604-2843-5-git-send-email-glommer@redhat.com> <1245258604-2843-6-git-send-email-glommer@redhat.com> <1245258604-2843-7-git-send-email-glommer@redhat.com> <1245258604-2843-8-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH 08/15] BACKPORT: Register reset functions for e1000 and rtl8139 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl , aliguori@us.ibm.com From: Blue Swirl Signed-off-by: Blue Swirl Signed-off-by: Glauber Costa --- hw/e1000.c | 21 ++++++++++++++------- hw/rtl8139.c | 4 +++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index 8c1741f..ba766e0 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -1058,6 +1058,18 @@ pci_e1000_uninit(PCIDevice *dev) return 0; } +static void e1000_reset(void *opaque) +{ + E1000State *d = opaque; + + memset(d->phy_reg, 0, sizeof d->phy_reg); + memmove(d->phy_reg, phy_reg_init, sizeof phy_reg_init); + memset(d->mac_reg, 0, sizeof d->mac_reg); + memmove(d->mac_reg, mac_reg_init, sizeof mac_reg_init); + d->rxbuf_min_shift = 1; + memset(&d->tx, 0, sizeof d->tx); +} + PCIDevice * pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) { @@ -1103,13 +1115,6 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) checksum = (uint16_t) EEPROM_SUM - checksum; d->eeprom_data[EEPROM_CHECKSUM_REG] = checksum; - memset(d->phy_reg, 0, sizeof d->phy_reg); - memmove(d->phy_reg, phy_reg_init, sizeof phy_reg_init); - memset(d->mac_reg, 0, sizeof d->mac_reg); - memmove(d->mac_reg, mac_reg_init, sizeof mac_reg_init); - d->rxbuf_min_shift = 1; - memset(&d->tx, 0, sizeof d->tx); - d->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, e1000_receive, e1000_can_receive, e1000_cleanup, d); @@ -1119,6 +1124,8 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) register_savevm(info_str, -1, 2, nic_save, nic_load, d); d->dev.unregister = pci_e1000_uninit; + qemu_register_reset(e1000_reset, d); + e1000_reset(d); return (PCIDevice *)d; } diff --git a/hw/rtl8139.c b/hw/rtl8139.c index 19c7623..42899a5 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -1170,8 +1170,9 @@ static void rtl8139_reset_rxring(RTL8139State *s, uint32_t bufferSize) s->RxBufAddr = 0; } -static void rtl8139_reset(RTL8139State *s) +static void rtl8139_reset(void *opaque) { + RTL8139State *s = opaque; int i; /* restore MAC address */ @@ -3480,6 +3481,7 @@ PCIDevice *pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn) s->pci_dev = (PCIDevice *)d; memcpy(s->macaddr, nd->macaddr, 6); + qemu_register_reset(rtl8139_reset, s); rtl8139_reset(s); s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, rtl8139_receive, rtl8139_can_receive, -- 1.6.2.2