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 /src/proc.asm | |
| 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 'src/proc.asm')
| -rw-r--r-- | src/proc.asm | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/proc.asm b/src/proc.asm index a2b1368..ab1c807 100644 --- a/src/proc.asm +++ b/src/proc.asm @@ -221,7 +221,10 @@ ProcCreate:: ld [hl+], a ; PROC_WRAMB xor a ld [hl+], a ; PROC_PARENT - ld [hl], a ; PROC_EXIT + ld [hl+], a ; PROC_EXIT + ld a, STD_CONSOLE + ld [hl+], a ; PROC_STDIN = console + ld [hl], a ; PROC_STDOUT = console ; build the initial stack frame in the task's RAM bank ld a, [wTmpEntry] @@ -438,7 +441,19 @@ sys_fork:: ld [hl+], a ; PROC_EXIT = 0 xor a - ld [hl], a + ld [hl+], a + ; PROC_STDIN / PROC_STDOUT = inherit from parent + ld a, [wCurProc] + add PROC_STDIN + ld e, a + ld a, [wCurProc+1] + adc 0 + ld d, a + ld a, [de] + ld [hl+], a ; child STDIN = parent STDIN + inc de + ld a, [de] + ld [hl], a ; child STDOUT = parent STDOUT ; ---- return to the parent with child pid ---- ld a, [wForkUserSP] |
