diff options
| author | user <user@clank> | 2026-09-24 12:48:37 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-24 12:48:37 +0200 |
| commit | dc9dffb9069e32a1a0cf14883176544b234fc3e5 (patch) | |
| tree | 4877daa5f01e98ac5d7e64d98c4144c94fa94a91 /include | |
| parent | term: write the palette attribute for every re-rendered tile, not just the cu... (diff) | |
| download | gbos-dc9dffb9069e32a1a0cf14883176544b234fc3e5.tar.gz gbos-dc9dffb9069e32a1a0cf14883176544b234fc3e5.tar.xz gbos-dc9dffb9069e32a1a0cf14883176544b234fc3e5.zip | |
kernel: stat/fsstat/isatty syscalls, and O_APPEND
Four things userland had no way to ask for:
- SYS_STAT: type, link count, size and inode for a path. The trap needs HL
for its dispatch table, so a call taking both a path and an output buffer
passes a request block - the shape SYS_NET already established. usr/stat.h
wraps it, header-only like sock.h, because the block must live in the
caller's RAM.
- SYS_FSSTAT: blocks/inodes, total and free. The bitmaps are already cached
write-through in fs_bmbuf, so this is the popcount boot_fs already prints.
- SYS_ISATTY: is this process's stdin the console? The shell needs it to tell
an interactive session from a script.
- O_APPEND: open a file positioned at EOF. There is no seek syscall, so this
is the only way to add to a file - without it nothing running ON the Game
Boy can build a multi-line file, shell scripts included.
Together these back ls -l, df, and `>>`.
Diffstat (limited to 'include')
| -rw-r--r-- | include/gbos.inc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/include/gbos.inc b/include/gbos.inc index eabdcec..76981da 100644 --- a/include/gbos.inc +++ b/include/gbos.inc @@ -123,6 +123,9 @@ DEF PROC_SIZE RB 0 DEF KILL_CODE EQU 137 ; exit status of a killed process (128 + SIGKILL) +DEF O_READ EQU 0 +DEF O_WRITE EQU 1 +DEF O_APPEND EQU 2 ; write, keeping what is there (pos starts at EOF) DEF STD_CONSOLE EQU $FF ; ----------------------------------------------------------------------------- @@ -165,7 +168,20 @@ DEF SYS_NET EQU 33 ; socket layer (DE=&netreq -> A=resu DEF SYS_SLEEP EQU 34 ; cooperative delay (B = 1/64-second units) DEF SYS_POLLCON EQU 35 ; poll console ring (link-injected -> A=byte or 0) DEF SYS_UPTIME EQU 36 ; copy the 64 Hz tick counter (4B LE) to [DE] -DEF SYS_MAX EQU 37 +DEF SYS_STAT EQU 37 ; stat a path (DE=&statreq -> A=0/$FF) +DEF SYS_FSSTAT EQU 38 ; filesystem totals (DE=buf[4] -> A=0) +DEF SYS_ISATTY EQU 39 ; is stdin the console? (-> A=1/0) +DEF SYS_MAX EQU 40 + +; ---- SYS_STAT request block (see fs.asm sys_stat) --------------------------- +; The syscall trap needs HL for its dispatch table, so a call that takes both a +; path and an output buffer passes a request block, like SYS_NET does. +DEF SR_PATH EQU 0 ; 2: pointer to the path (in) +DEF SR_TYPE EQU 2 ; 1: IT_FILE / IT_DIR (out) +DEF SR_NLINK EQU 3 ; 1 (out) +DEF SR_SIZE EQU 4 ; 2: bytes, little-endian(out) +DEF SR_INO EQU 6 ; 1: inode number (out) +DEF SR_SIZE_ EQU 7 ; sizeof(statreq) ; ---- socket layer (SYS_NET) -------------------------------------------------- ; netreq struct (in caller RAM; DE points to it): @@ -307,5 +323,12 @@ DEF PROG_CP EQU 35 DEF PROG_NC EQU 36 DEF PROG_HTTPD EQU 37 DEF PROG_IRCD EQU 38 +DEF PROG_DF EQU 39 +DEF PROG_MV EQU 40 +DEF PROG_SLEEP EQU 41 +DEF PROG_TEE EQU 42 +DEF PROG_TAIL EQU 43 +DEF PROG_HELP EQU 44 +DEF PROG_POWEROFF EQU 45 ENDC |
