aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authoruser <user@clank>2026-07-16 07:53:19 +0200
committeruser <user@clank>2026-07-16 07:53:19 +0200
commit7b5c532625a864a3fbaf76f44df6aa99b0d6861e (patch)
tree6a6d67644993ccaea4b71bdc0881798887a6d1aa /include
parentlibc: option parsing (hasflag/optval); wc -l/-w/-c, head -n N (diff)
downloadgbos-7b5c532625a864a3fbaf76f44df6aa99b0d6861e.tar.gz
gbos-7b5c532625a864a3fbaf76f44df6aa99b0d6861e.tar.xz
gbos-7b5c532625a864a3fbaf76f44df6aa99b0d6861e.zip
filesystem: a RAM FS (WRAMX) + ls/cat/save/rm; wc/head read files
- fs.asm: 8-slot RAM filesystem in WRAMX ($D000-$DFFF), name[8]+len[2]+data[502]; syscalls open/close/getb/putb/list/remove, seeded with a 'readme' at boot. - libc: open/close/fgetc/fputc/flist/fremove wrappers + O_READ/O_WRITE/NOFD. - tools: ls, save (stdin->file, one line), rm; cat/wc/head now take a file arg. - fix: syscall dispatch clobbers A, so putb takes its byte in E (was reading the handler's low address byte, 0xDC); ls NUL-terminates 8-char names. - verified: save/cat/ls/rm cycle; wc readme -> '2 7 38'; head -n 1 readme. - README: document the filesystem + the A-clobber ABI note.
Diffstat (limited to 'include')
-rw-r--r--include/gbos.inc30
1 files changed, 29 insertions, 1 deletions
diff --git a/include/gbos.inc b/include/gbos.inc
index 156876b..7c3f325 100644
--- a/include/gbos.inc
+++ b/include/gbos.inc
@@ -84,7 +84,32 @@ DEF SYS_GETPID EQU 8
DEF SYS_KILL EQU 9
DEF SYS_BRK EQU 10
DEF SYS_YIELD EQU 11
-DEF SYS_MAX EQU 12
+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
+; (SYS_OPEN=4 / SYS_CLOSE=5 are now implemented by the filesystem)
+
+; -----------------------------------------------------------------------------
+; RAM filesystem (lives in WRAMX $D000-$DFFF, 4 KiB; fixed in DMG mode).
+; 8 files x 512 bytes: name[8] (first byte 0 = free) + len[2] + data[502].
+; -----------------------------------------------------------------------------
+DEF FS_BASE EQU $D000
+DEF FS_MAX_FILES EQU 8
+DEF FS_FILE_SIZE EQU 512
+DEF FS_NAME EQU 0
+DEF FS_LEN EQU 8
+DEF FS_DATA EQU 10
+DEF FS_MAX_DATA EQU 502
+
+; open-file table (kernel WRAM0): inuse, slot, mode, pos(2)
+DEF OF_MAX EQU 4
+DEF OF_INUSE EQU 0
+DEF OF_SLOT EQU 1
+DEF OF_MODE EQU 2
+DEF OF_POS EQU 3
+DEF OF_SIZE EQU 5
; -----------------------------------------------------------------------------
; Program table indices (see programs.asm). exec() takes one of these in B.
@@ -102,5 +127,8 @@ DEF PROG_CAT EQU 9
DEF PROG_WC EQU 10
DEF PROG_HEAD EQU 11
DEF PROG_ARGS EQU 12
+DEF PROG_LS EQU 13
+DEF PROG_SAVE EQU 14
+DEF PROG_RM EQU 15
ENDC