diff options
| author | user <user@clank> | 2026-07-16 08:25:35 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-07-16 08:25:35 +0200 |
| commit | 6c64d97e70984c77be3cd8d4e03e9adf717e02fb (patch) | |
| tree | fd55f0ef943fef12a833ab526ebfe6bc5740f728 /include/gbos.inc | |
| parent | filesystem: a RAM FS (WRAMX) + ls/cat/save/rm; wc/head read files (diff) | |
| download | gbos-6c64d97e70984c77be3cd8d4e03e9adf717e02fb.tar.gz gbos-6c64d97e70984c77be3cd8d4e03e9adf717e02fb.tar.xz gbos-6c64d97e70984c77be3cd8d4e03e9adf717e02fb.zip | |
shell: I/O redirection (>/<) and pipes (|); rewrite shell in C
- kernel I/O routing: PCB gains PROC_STDIN/PROC_STDOUT (default console $FF),
inherited across fork. KGetc/KPutc route read/write/putc to the console or a
file fd. New syscalls: putc(16), setin(17), setout(18), lookup(19).
read/write now go through the routing; putc/puts/nl use SYS_PUTC.
- sys_lookup + NameTable move command-name resolution into the kernel.
- shell rewritten in C (c/sh.c): tokenizes a line, parses > / < / |, and drives
fork+setin/setout+exec+wait. Pipes run as 'a > __pipe ; b < __pipe' (temp
file). asm shell + cmdtab removed; StrEqual/SkipName kept for sys_lookup.
- libc: fork/exec/wait/setin/setout/lookup wrappers.
- verified: echo>file, cat file, wc<file, cat readme|wc -l, echo ...|wc.
Diffstat (limited to '')
| -rw-r--r-- | include/gbos.inc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/include/gbos.inc b/include/gbos.inc index 7c3f325..6aaaf73 100644 --- a/include/gbos.inc +++ b/include/gbos.inc @@ -67,8 +67,12 @@ DEF PROC_RAMB RB 1 ; data/stack cart-RAM bank DEF PROC_WRAMB RB 1 ; u-area SVBK bank (1..7) DEF PROC_PARENT RB 1 DEF PROC_EXIT RB 1 ; exit code (valid when PS_ZOMBIE) +DEF PROC_STDIN RB 1 ; $FF = console, else an open-file fd +DEF PROC_STDOUT RB 1 ; $FF = console, else an open-file fd DEF PROC_SIZE RB 0 +DEF STD_CONSOLE EQU $FF + ; ----------------------------------------------------------------------------- ; Syscall numbers (passed in C; args in DE/HL/B per call, ret in A) ; ----------------------------------------------------------------------------- @@ -88,7 +92,11 @@ DEF SYS_GETB EQU 12 ; read a byte from an open file (B=fd -> A, CF=EOF) DEF SYS_PUTB EQU 13 ; append a byte to an open file (B=fd, E=byte) DEF SYS_LIST EQU 14 ; list a directory slot (B=slot, DE=namebuf) DEF SYS_REMOVE EQU 15 ; delete a file (DE=name) -DEF SYS_MAX EQU 16 +DEF SYS_PUTC EQU 16 ; write a byte to stdout (E=byte) +DEF SYS_SETIN EQU 17 ; set current stdin fd (B=fd, $FF=console) +DEF SYS_SETOUT EQU 18 ; set current stdout fd (B=fd, $FF=console) +DEF SYS_LOOKUP EQU 19 ; program id for a command name (DE=name -> A=id/$FF) +DEF SYS_MAX EQU 20 ; (SYS_OPEN=4 / SYS_CLOSE=5 are now implemented by the filesystem) ; ----------------------------------------------------------------------------- |
