diff --git a/boot.json b/boot.json index 787672b..63c70f1 100644 --- a/boot.json +++ b/boot.json @@ -1,5 +1,5 @@ { - "cdrom": "arch/linux.iso", + "cdrom": "arch/blockless.iso", "bios_file": "arch/seabios.bin", "vga_bios_file": "arch/vgabios.bin", "wasm_file": "target/v86.wasm", @@ -8,7 +8,7 @@ "cmdline": ["tsc=reliable mitigations=off random.trust_cpu=on"], "logger": { "log_file": "debug.log", - "log_module": ["PS2"] + "log_module": ["NET"] }, "tun": { "address": "192.168.0.1", diff --git a/crates/wasi/src/ne2k.rs b/crates/wasi/src/ne2k.rs index f9957a8..97ff644 100644 --- a/crates/wasi/src/ne2k.rs +++ b/crates/wasi/src/ne2k.rs @@ -1,7 +1,7 @@ #![allow(unused)] -use crate::{StoreT, pci::{PCIDevice, GenericPCIDevice, PCIBar}, log::LOG, ContextTrait, Dev, bus::BusData}; +use crate::{bus::BusData, io::IO, log::LOG, pci::{GenericPCIDevice, PCIBar, PCIDevice}, ContextTrait, Dev, StoreT}; -const NE2K_LOG_VERBOSE: bool = false; +const NE2K_LOG_VERBOSE: bool = true; const E8390_CMD: u16 = 0x00; /* The command register (for all pages) */ @@ -167,31 +167,57 @@ impl Ne2k { (self.port | EN0_COUNTER0) as u32, Dev::Emulator(self.store.clone()), |dev: &Dev, _addr: u32| { - dev.ne2k().map_or(0, |_ne2k| { - dbg_log!(LOG::NET, "Read counter0"); - 0 + dev.ne2k().map_or(0, |ne2k| { + let pg = ne2k.get_page(); + if pg == 1 { + dbg_log!(LOG::NET, "Read mar5"); + return ne2k.mar[5]; + } else { + dbg_log!(LOG::NET, "Read counter0 pg={pg}"); + return 0; + } }) } ); - io.register_read8( + io.register_read( (self.port | EN0_COUNTER1) as u32, Dev::Emulator(self.store.clone()), |dev: &Dev, _addr: u32| { - dev.ne2k().map_or(0, |_ne2k| { - dbg_log!(LOG::NET, "Read counter1"); - 0 + dev.ne2k().map_or(0, |ne2k| { + let pg = ne2k.get_page(); + if pg == 1 { + dbg_log!(LOG::NET, "Read mar6"); + return ne2k.mar[6]; + } else { + dbg_log!(LOG::NET, "Read8 counter1 pg={pg}"); + return 0; + } }) - } + }, + |dev: &Dev, _addr: u32| { + dev.ne2k().map_or(0, |ne2k| { + let pg = ne2k.get_page(); + dbg_log!(LOG::NET, "Read16 counter1 pg={pg}"); + return 0; + }) + }, + IO::empty_read32 ); io.register_read8( (self.port | EN0_COUNTER2) as u32, Dev::Emulator(self.store.clone()), |dev: &Dev, _addr: u32| { - dev.ne2k().map_or(0, |_ne2k| { - dbg_log!(LOG::NET, "Read counter2"); - 0 + dev.ne2k().map_or(0, |ne2k| { + let pg = ne2k.get_page(); + if pg == 1 { + dbg_log!(LOG::NET, "Read mar7"); + return ne2k.mar[7]; + } else { + dbg_log!(LOG::NET, "Read counter2 pg={pg}"); + return 0; + } }) } ); @@ -201,14 +227,9 @@ impl Ne2k { Dev::Emulator(self.store.clone()), |dev: &Dev, _addr: u32| { dev.ne2k_mut().map_or(0, |ne2k| { - let pg = ne2k.get_page(); - if pg == 0{ - dbg_log!(LOG::NET, "Read reset"); - ne2k.do_interrupt(ENISR_RESET); - } else { - dbg_log!(LOG::NET, "Read pg{}/1f", pg); - assert!(false); - } + let _pg = ne2k.get_page(); + dbg_log!(LOG::NET, "Read reset"); + ne2k.do_interrupt(ENISR_RESET); return 0; }) } @@ -220,13 +241,8 @@ impl Ne2k { |dev: &Dev, _addr: u32, data_byte: u8| { dev.ne2k_mut().map(|ne2k| { let pg = ne2k.get_page(); - if pg == 0 { - dbg_log!(LOG::NET, "Write reset: {:#X}", data_byte); - //this.isr &= ~ENISR_RESET; - } else { - dbg_log!(LOG::NET, "Write pg{}/1f: {:#X}", pg, data_byte); - assert!(false); - } + dbg_log!(LOG::NET, "Write reset: {data_byte:#X}"); + //this.isr &= ~ENISR_RESET; }); } ); @@ -245,7 +261,7 @@ impl Ne2k { } else if pg == 2 { return ne2k.pstart; } else { - dbg_log!(LOG::NET, "Read pg{}/01", pg); + dbg_log!(LOG::NET, "Read pg{pg}/01"); assert!(false); return 0; } @@ -260,10 +276,10 @@ impl Ne2k { dev.ne2k_mut().map(|ne2k| { let pg = ne2k.get_page(); if pg == 0 { - dbg_log!(LOG::NET, "start page: {:#X}", data_byte); + dbg_log!(LOG::NET, "start page: {data_byte:#X}"); ne2k.pstart = data_byte; } else if pg == 1 { - dbg_log!(LOG::NET, "mac[0] = {:#X}", data_byte); + dbg_log!(LOG::NET, "mac[0] = {data_byte:#X}"); ne2k.mac[0] = data_byte; } else if pg == 3 { dbg_log!(LOG::NET, "Unimplemented: Write pg3/01 (9346CR): {:#X}", data_byte); @@ -404,6 +420,9 @@ impl Ne2k { if pg == 0 { dbg_log!(LOG::NET, "Read pg0/0a"); 0x50 + } else if pg == 1 { + dbg_log!(LOG::NET, "Read mar2"); + return ne2k.mar[2]; } else { assert!(false, "TODO"); 0 @@ -420,7 +439,7 @@ impl Ne2k { let pg = ne2k.get_page(); if pg == 0 { dbg_log!(LOG::NET, "Write remote byte count low: {:#2X}", data_byte); - ne2k.rcnt = ne2k.rcnt & 0xFF00 | data_byte as u16 & 0xFF; + ne2k.rcnt = ne2k.rcnt & 0xFF00 | (data_byte & 0xFF) as u16; } else { dbg_log!(LOG::NET, "Unimplemented: Write pg{}/0a {:#X}", pg, data_byte); } @@ -437,6 +456,9 @@ impl Ne2k { if pg == 0 { dbg_log!(LOG::NET, "Read pg0/0b"); return 0x43; + } else if pg == 1 { + dbg_log!(LOG::NET, "Read mar3"); + return ne2k.mar[3]; } else { assert!(false, "TODO"); return 0; @@ -470,6 +492,9 @@ impl Ne2k { if pg == 0 { dbg_log!(LOG::NET, "Read remote start address low"); return (ne2k.rsar & 0xFF) as u8; + } else if pg == 1 { + dbg_log!(LOG::NET, "Read mar0"); + return ne2k.mar[0]; } else { dbg_log!(LOG::NET, "Unimplemented: Read pg{}/08", pg); assert!(false); @@ -504,6 +529,9 @@ impl Ne2k { if pg == 0 { dbg_log!(LOG::NET, "Read remote start address high"); return (ne2k.rsar >> 8 & 0xFF) as u8; + } else if pg == 1 { + dbg_log!(LOG::NET, "Read mar1"); + return ne2k.mar[1]; } else { dbg_log!(LOG::NET, "Unimplemented: Read pg{}/09", pg); assert!(false); @@ -910,7 +938,7 @@ impl Ne2k { let data_start = offset + 4; let mut next = self.curpg as usize + 1 + (total_length >> 8); - let end = offset as usize + total_length; + let end = offset + total_length; let needed = 1 + (total_length >> 8);