From 7165448a913bd8f757f588e8f1581c170d8b1775 Mon Sep 17 00:00:00 2001 From: William Dauchy Date: Sun, 6 Mar 2011 22:27:18 +0100 Subject: moving eeprom initialization The initialization should not be only on reset but also when initializing the device. It resolves a bug when hot plugging a pci network device: the mac address was always null. Signed-off-by: William Dauchy Signed-off-by: Wen Congyang Signed-off-by: Blue Swirl --- hw/rtl8139.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'hw/rtl8139.c') diff --git a/hw/rtl8139.c b/hw/rtl8139.c index a22530cf89..7a8752239e 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -1189,18 +1189,6 @@ static void rtl8139_reset(DeviceState *d) rtl8139_update_irq(s); - /* prepare eeprom */ - s->eeprom.contents[0] = 0x8129; -#if 1 - // PCI vendor and device ID should be mirrored here - s->eeprom.contents[1] = PCI_VENDOR_ID_REALTEK; - s->eeprom.contents[2] = PCI_DEVICE_ID_REALTEK_8139; -#endif - - s->eeprom.contents[7] = s->conf.macaddr.a[0] | s->conf.macaddr.a[1] << 8; - s->eeprom.contents[8] = s->conf.macaddr.a[2] | s->conf.macaddr.a[3] << 8; - s->eeprom.contents[9] = s->conf.macaddr.a[4] | s->conf.macaddr.a[5] << 8; - /* mark all status registers as owned by host */ for (i = 0; i < 4; ++i) { @@ -3392,6 +3380,17 @@ static int pci_rtl8139_init(PCIDevice *dev) qemu_macaddr_default_if_unset(&s->conf.macaddr); + /* prepare eeprom */ + s->eeprom.contents[0] = 0x8129; +#if 1 + /* PCI vendor and device ID should be mirrored here */ + s->eeprom.contents[1] = PCI_VENDOR_ID_REALTEK; + s->eeprom.contents[2] = PCI_DEVICE_ID_REALTEK_8139; +#endif + s->eeprom.contents[7] = s->conf.macaddr.a[0] | s->conf.macaddr.a[1] << 8; + s->eeprom.contents[8] = s->conf.macaddr.a[2] | s->conf.macaddr.a[3] << 8; + s->eeprom.contents[9] = s->conf.macaddr.a[4] | s->conf.macaddr.a[5] << 8; + s->nic = qemu_new_nic(&net_rtl8139_info, &s->conf, dev->qdev.info->name, dev->qdev.id, s); qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a); -- cgit v1.2.1