浏览代码

Ne2k Driver Fixes to Support Running in Windows! (#378)

ne2k fixes to support network card in Windows (compared to qemu implementation)
- fix clearing of initial buffer (this appears to be the main fix!)
- additional fixes for write logic
Ilya Kreymer 3 年之前
父节点
当前提交
1bebfe68bb
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      src/ne2k.js

+ 6 - 2
src/ne2k.js

@@ -131,7 +131,10 @@ function Ne2k(cpu, bus, preserve_mac_from_state_image)
         this.memory[i << 1] = this.memory[i << 1 | 1] = this.mac[i];
     }
 
-    this.memory[14] = this.memory[15] = 0x57;
+    // the PROM signature of 0x57, 0x57 is also doubled
+    // resulting in setting the 4 bytes at the end, 28, 29, 30 and 31 to 0x57
+    this.memory[14 << 1] = this.memory[14 << 1 | 1] = 0x57;
+    this.memory[15 << 1] = this.memory[15 << 1 | 1] = 0x57;
 
     dbg_log("Mac: " + h(this.mac[0], 2) + ":" +
                       h(this.mac[1], 2) + ":" +
@@ -158,7 +161,7 @@ function Ne2k(cpu, bus, preserve_mac_from_state_image)
 
     io.register_write(this.port | E8390_CMD, this, function(data_byte)
     {
-        this.cr = data_byte & ~4;
+        this.cr = data_byte;
         dbg_log("Write command: " + h(data_byte, 2) + " newpg=" + (this.cr >> 6) + " txcr=" + h(this.txcr, 2), LOG_NET);
 
         if(this.cr & 1)
@@ -177,6 +180,7 @@ function Ne2k(cpu, bus, preserve_mac_from_state_image)
             var data = this.memory.subarray(start, start + this.tcnt);
             this.bus.send("net0-send", data);
             this.bus.send("eth-transmit-end", [data.length]);
+            this.cr &= ~4;
             this.do_interrupt(ENISR_TX);
 
             dbg_log("Command: Transfer. length=" + h(data.byteLength), LOG_NET);