From bf647581fbad727ad22021d345d3955abf44c2f3 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 17 Jul 2026 20:22:34 +0200 Subject: net: SYS_POLLCON + larger console ring for link-injected input Programs that own their main loop (the IRC client) need to poll for typed input without blocking. pollin() only sees the on-screen keyboard; bytes injected over the link (gbhub 'type', for scripted/hub-driven sessions) land in the kernel console ring, previously only drained by the blocking KGetc path. Add SYS_POLLCON: a non-blocking con_pop for userland. Also enlarge that console ring 16 -> 64. One net_pump drains an entire serial burst into the ring at once, so a whole injected command line has to fit or bytes are dropped and lines merge (a 20-char command came out truncated and glued to the next). 64 covers a full line; mask stays a power of two. --- c/gbos.h | 2 ++ c/libc.s | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'c') diff --git a/c/gbos.h b/c/gbos.h index 390fe3a..2350665 100644 --- a/c/gbos.h +++ b/c/gbos.h @@ -17,6 +17,8 @@ void ssend(unsigned char b); /* link-port: transmit one byte */ unsigned char srecv(void); /* link-port: receive one byte (blocks) */ int srecv_nb(void); /* link-port: receive, or -1 if none */ unsigned char pollin(void); /* poll OSK for a typed char, or 0 */ +unsigned char pollcon(void); /* poll console ring (link-injected + input, filled by net pumps), or 0 */ unsigned char sys_net(void *req); /* socket layer trap (see sock.h) */ void gsleep(unsigned char units); /* delay units*(1/64)s (raw trap) */ void msleep(unsigned int ms); /* delay ~ms milliseconds */ diff --git a/c/libc.s b/c/libc.s index b413f3b..5b176d9 100644 --- a/c/libc.s +++ b/c/libc.s @@ -1,6 +1,6 @@ .module libc .globl _writes, _putc, _puts, _nl, _strlen, _readc, _sexit, _getpid, _getargs - .globl _open, _close, _fgetc, _fputc, _flist, _fremove, _pipe, _ssend, _srecv, _srecv_nb, _pollin + .globl _open, _close, _fgetc, _fputc, _flist, _fremove, _pipe, _ssend, _srecv, _srecv_nb, _pollin, _pollcon .globl _sys_net, _gsleep ;; 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 @@ -136,6 +136,12 @@ _pollin: rst #0x30 ret + ;; unsigned char pollcon(void) -> A (queued console byte, or 0) +_pollcon: + ld c, #35 ; SYS_POLLCON + rst #0x30 + ret + ;; unsigned char open(const char *name /*DE*/, unsigned char mode /*A*/) -> A(fd) _open: ld b, a ; B = mode -- cgit v1.3.1-sl0p