]> xenbits.xensource.com Git - qemu-upstream-4.4-testing.git/commitdiff
e1000: pre-initialize RAH/RAL registers
authorGabriel L. Somlo <gsomlo@gmail.com>
Wed, 31 Oct 2012 18:15:39 +0000 (14:15 -0400)
committerStefan Hajnoczi <stefanha@redhat.com>
Thu, 1 Nov 2012 11:02:17 +0000 (12:02 +0100)
Some guest operating systems' drivers (Mac OS X in particular) fail to
properly initialize the Receive Address registers (probably expecting
them to be pre-initialized by an earlier component, such as a specific
proprietary BIOS). This patch pre-initializes the RA registers, allowing
OS X networking to function properly. Other guest operating systems are
not affected, and free to (re)initialize these registers during boot.

[According to the datasheet the Address Valid bits in the RA registers
are cleared on PCI or software reset.  This patch adds the NIC's MAC
address and sets Address Valid on reset.  So we diverge from real
hardware behavior here. -- Stefan]

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
hw/e1000.c

index ec32f591af2702beffc3b2e484c8895e87fcd1ae..cb7e7e83661767a1a34bbb1f65601abbda7ffd61 100644 (file)
@@ -265,6 +265,8 @@ rxbufsize(uint32_t v)
 static void e1000_reset(void *opaque)
 {
     E1000State *d = opaque;
+    uint8_t *macaddr = d->conf.macaddr.a;
+    int i;
 
     qemu_del_timer(d->autoneg_timer);
     memset(d->phy_reg, 0, sizeof d->phy_reg);
@@ -277,6 +279,14 @@ static void e1000_reset(void *opaque)
     if (d->nic->nc.link_down) {
         e1000_link_down(d);
     }
+
+    /* Some guests expect pre-initialized RAH/RAL (AddrValid flag + MACaddr) */
+    d->mac_reg[RA] = 0;
+    d->mac_reg[RA + 1] = E1000_RAH_AV;
+    for (i = 0; i < 4; i++) {
+        d->mac_reg[RA] |= macaddr[i] << (8 * i);
+        d->mac_reg[RA + 1] |= (i < 2) ? macaddr[i + 4] << (8 * i) : 0;
+    }
 }
 
 static void