From 09ae37313a8b6d567a05a3ae886de78e88cd1afe Mon Sep 17 00:00:00 2001 From: user Date: Fri, 17 Jul 2026 12:39:01 +0200 Subject: net: proper socket API in the kernel (SYS_NET) - no more SLIP in userland The network stack moves into the kernel. src/socket.asm owns SLIP framing, IPv4, RFC1071 checksums, and ICMP; programs now speak a socket API through one syscall (SYS_NET, DE=&netreq dispatched by op): net_socket/connect/send/recv/ close/poll (c/sock.h). No program touches SLIP, IP headers, or checksums. - Socket table (4 sockets) + tx/rx buffers in WRAM0; our IP = 10.0.0.2. - net_pump: drains the link, reassembles SLIP frames, demuxes IPv4. Inbound ICMP echo requests are auto-answered in-kernel, so the GB replies to pings whenever any process pumps RX. - ICMP sockets: send() emits an echo request to the connected peer; recv() returns the matching reply (with a spin/yield timeout). ping.c is now a ~15-line socket client; netd.c is just `for(;;){net_poll(); yield();}`. Verified over tunbridge: /# ping 1.1.1.1 -> replies from the real internet (kernel builds it all) host# ping 10.0.0.2 -> 4/4, 0% loss (kernel auto-answers) Gotchas recorded: gbos.inc isn't a make dep (touch asm after editing); this crt0 doesn't copy initializers (fill arrays at runtime); and the arg string at 0xA000 overlaps _DATA, so parse targets must sit past it (big buffer first). UDP and TCP sockets build on this same core next. --- src/boot.asm | 1 + 1 file changed, 1 insertion(+) (limited to 'src/boot.asm') diff --git a/src/boot.asm b/src/boot.asm index 23511c4..c29267d 100644 --- a/src/boot.asm +++ b/src/boot.asm @@ -56,6 +56,7 @@ KernelInit: ld a, HIGH(wKernelPCB) ld [wCurProc+1], a call pipe_init ; mark all pipes free + call net_init ; clear the socket table, set our IP (10.0.0.2) call fs_init ; mount the disk (format on first boot; persists) call term_init ; set up the LCD text terminal call osk_init ; build the on-screen keyboard (window layer) -- cgit v1.3.1-sl0p