diff options
| author | user <user@clank> | 2026-07-17 01:28:23 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-07-17 01:28:23 +0200 |
| commit | b5544e84232b80351e7c58501c1632080a354d12 (patch) | |
| tree | a4087d5c9df0589b613bcb6696962825099ce8b7 /c/libc.s | |
| parent | pipe: PIPE_MAX 2->4 (5-stage pipelines) + fix cross-yield byte corruption (diff) | |
| download | gbos-b5544e84232b80351e7c58501c1632080a354d12.tar.gz gbos-b5544e84232b80351e7c58501c1632080a354d12.tar.xz gbos-b5544e84232b80351e7c58501c1632080a354d12.zip | |
net: SLIP framing over the link port + a host gateway (echo round-trip)
First step of link-port networking. The LCD terminal + OSK freed the serial
port from console duty, so it can be the network link.
Kernel (src/net.asm): raw link-port serial that bypasses the console/
terminal - sys_ssend (transmit, GB drives the clock) and sys_srecv (receive,
GB slave, blocks by yielding). Syscalls 29/30.
Userland: libc ssend()/srecv(); c/necho.c does SLIP (RFC 1055) framing over
them - send a packet, receive the reply, print it.
Host: tools/gateway.py wraps the emulator, owns its link serial, speaks SLIP,
and (for now) echoes every frame back - the "link cable adapter". Console
(ASCII) bytes on the same channel are printed for visibility.
Verified: `necho` sends a SLIP frame, the gateway decodes+echoes it, and gbos
prints the reply - a real framed round-trip over the Game Boy link port.
Next: swap the echo for actual network ops (DNS/HTTP or IRC/chat).
Diffstat (limited to '')
| -rw-r--r-- | c/libc.s | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -1,6 +1,6 @@ .module libc .globl _writes, _putc, _puts, _nl, _strlen, _readc, _sexit, _getpid, _getargs - .globl _open, _close, _fgetc, _fputc, _flist, _fremove, _pipe + .globl _open, _close, _fgetc, _fputc, _flist, _fremove, _pipe, _ssend, _srecv ;; SDCC sm83 sdcccall(1): 1st arg -> A (byte) or DE (pointer); ret A / BC. ;; rst $30 (the trap) clobbers BC/DE/HL; SDCC treats them caller-saved, so ;; wrappers need not preserve them - but we compute cleanly regardless. @@ -92,6 +92,19 @@ _pipe: rst #0x30 ret + ;; void ssend(unsigned char b /*A*/) -- link-port transmit +_ssend: + ld e, a + ld c, #29 ; SYS_SSEND + rst #0x30 + ret + + ;; unsigned char srecv(void) -> A -- link-port receive (blocks) +_srecv: + ld c, #30 ; SYS_SRECV + rst #0x30 + ret + ;; unsigned char open(const char *name /*DE*/, unsigned char mode /*A*/) -> A(fd) _open: ld b, a ; B = mode |
