aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoruser <user@clank>2026-07-17 20:22:34 +0200
committeruser <user@clank>2026-07-17 20:22:34 +0200
commitbf647581fbad727ad22021d345d3955abf44c2f3 (patch)
tree59e77e48c1e07dd181e2c0d693016847c441c662 /src
parentnet: fix truncated TCP field offsets corrupting multi-segment recv (diff)
downloadgbos-bf647581fbad727ad22021d345d3955abf44c2f3.tar.gz
gbos-bf647581fbad727ad22021d345d3955abf44c2f3.tar.xz
gbos-bf647581fbad727ad22021d345d3955abf44c2f3.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/net.asm10
-rw-r--r--src/socket.asm11
-rw-r--r--src/syscall.asm1
3 files changed, 19 insertions, 3 deletions
diff --git a/src/net.asm b/src/net.asm
index f2c4279..8309242 100644
--- a/src/net.asm
+++ b/src/net.asm
@@ -54,6 +54,16 @@ sys_srecv_nb::
and a ; CF = 0 (got a byte)
ret
+; sys_pollcon() -> A = a queued console-ring byte (link-injected input,
+; e.g. gbhub 'type'), or 0 if none. Non-blocking twin of KGetc's con_pop
+; path: programs that own their main loop (irc) poll this alongside the OSK.
+; The ring fills during net pumps, which such programs do constantly.
+sys_pollcon::
+ call con_pop
+ ret nc ; got a byte
+ xor a
+ ret
+
; sys_pollin() -> A = char typed on the OSK this poll, or 0 if none.
sys_pollin::
call pad_poll
diff --git a/src/socket.asm b/src/socket.asm
index 0720b0a..51179b4 100644
--- a/src/socket.asm
+++ b/src/socket.asm
@@ -64,7 +64,12 @@ wNetRxBuf:: DS 320 ; rx frame assembly / parse
wNetRxLen:: DS 2 ; 16-bit: frames can exceed 255 bytes (DHCP/BOOTP)
wNetRxEsc:: DS 1
wNetInFrame:: DS 1 ; net_pump: currently inside a SLIP frame?
-wConRing:: DS 16 ; console-input ring: non-framed bytes from the link
+wConRing:: DS 64 ; console-input ring: non-framed bytes from the link
+ ; (link-injected console input, e.g. gbhub 'type').
+ ; One net_pump drains a whole serial burst into here
+ ; at once, so it must hold a full injected command
+ ; line - 16 was too small (dropped bytes, merged
+ ; lines). Size MUST stay a power of two (mask below).
wConHead:: DS 1
wConTail:: DS 1
wNetUdpPort:: DS 2 ; scratch: UDP dst port being demuxed
@@ -112,7 +117,7 @@ con_push::
ld b, a
ld a, [wConTail]
inc a
- and 15
+ and 63
ld c, a
ld a, [wConHead]
cp c
@@ -145,7 +150,7 @@ con_pop::
ld c, [hl]
ld a, b
inc a
- and 15
+ and 63
ld [wConHead], a
ld a, c
and a ; CF = 0
diff --git a/src/syscall.asm b/src/syscall.asm
index 2adf5bf..bd58cc2 100644
--- a/src/syscall.asm
+++ b/src/syscall.asm
@@ -69,6 +69,7 @@ SyscallTable:
dw sys_pollin ; 32 POLLIN
dw sys_net ; 33 NET
dw sys_sleep ; 34 SLEEP
+ dw sys_pollcon ; 35 POLLCON
; -----------------------------------------------------------------------------
sys_nosys: