e1000 patch for osx

Submitted by Gabriel L. Somlo on Oct. 31, 2013, 3:06 p.m.

Details

Message ID 20131031150651.GI9423@HEDWIG.INI.CMU.EDU
State New
Headers show

Commit Message

Gabriel L. Somlo Oct. 31, 2013, 3:06 p.m.
On Wed, Oct 30, 2013 at 6:31 PM, jacek burghardt wrote:
> I got this error
> hw/net/e1000.c: In function 'set_phy_ctrl':
> hw/net/e1000.c:209:10: warning: implicit declaration of function 'set_ics'
> [-Wimplicit-function-declaration]

That's because set_ics needs to be declared before being used in
set_phy_ctrl(). A full patch which builds on the current qemu git
master would look like below.

That being said, now it builds, but doesn't actually make osx
(10.6 in my case) start with a working network interface. I still
need to bounce the link (via "set_link foo off; set_link foo on")
from the qemu monitor command line in order to get network access
from osx.

--Gabriel

Comments

jacek burghardt Oct. 31, 2013, 9:38 p.m.
I will test this with 10.8.3

Patch hide | download patch | download mbox

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 70a59fd..7c2dd9f 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -186,6 +186,9 @@  e1000_link_up(E1000State *s)
     s->phy_reg[PHY_STATUS] |= MII_SR_LINK_STATUS;
 }
 
+//FIXME: maybe move set_phy_ctrl *after* set_ics instead ?
+static void set_ics(E1000State *s, int index, uint32_t val);
+
 static void
 set_phy_ctrl(E1000State *s, int index, uint16_t val)
 {
@@ -203,6 +206,12 @@  set_phy_ctrl(E1000State *s, int index, uint16_t val)
         DBGOUT(PHY, "Start link auto negotiation\n");
         timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500);
     }
+
+    if (val & 0x8000) {
+        val &= 0x7fff;
+        set_ics(s, 0, E1000_ICR_LSC);
+    }
+    s->phy_reg[PHY_CTRL] = val;
 }
 
 static void
@@ -445,8 +454,9 @@  set_mdic(E1000State *s, int index, uint32_t val)
         } else {
             if (addr < NPHYWRITEOPS && phyreg_writeops[addr]) {
                 phyreg_writeops[addr](s, index, data);
+            } else {
+                s->phy_reg[addr] = data;
             }
-            s->phy_reg[addr] = data;
         }
     }
     s->mac_reg[MDIC] = val | E1000_MDIC_READY;