commit 1660c3e57ff4df0783fd58b85222f181d1d9a1c5
parent 6e30417c3d2292e337439137e1cb4577ba95c78e
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Fri, 1 Jul 2022 15:07:25 -0400
Add namespaces to FS words and a "glue" part fo boot.fs
Diffstat:
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,5 +1,5 @@
TARGETS = dusk
-BOOTFS_SRC = fs/xcomp/bootlo.fs fs/fs/linux.fs fs/xcomp/boothi.fs
+BOOTFS_SRC = fs/xcomp/bootlo.fs fs/fs/linux.fs bootglue.fs fs/xcomp/boothi.fs
all: $(TARGETS)
dusk: dusk.asm boot.fs fatfs
diff --git a/fs/fs/boot.fs b/fs/fs/boot.fs
@@ -135,6 +135,8 @@ create fcursors( FCursorSize FCURSORCNT * allot0
( dirent cluster ) dup r@ w! r@ FCUR_cluster! ( dirent )
0 r@ 4 + ! DIR_FileSize r@ 8 + ! ( ) r> ;
+: fat16open ( path -- fcursor ) findpath openfile ;
+
: fat16getc ( fcursor -- c-or-0 )
dup FCUR_pos over FCUR_size = if drop 0 exit then
dup FCUR_pos+ ClusterSize mod over FCUR_buf( + c@ ( fc c )
diff --git a/fs/fs/linux.fs b/fs/fs/linux.fs
@@ -1,15 +1,15 @@
\ Filesystem implemented as Linux system calls
\ Requires a "lnxcall" word in the kernel
-: fclose ( fd -- ) 6 ( close ) swap 0 0 ( close fd 0 0 ) lnxcall drop ;
+: lnxclose ( fd -- ) 6 ( close ) swap 0 0 ( close fd 0 0 ) lnxcall drop ;
create _buf $100 allot
: _tozstr ( s -- zs )
c@+ >r _buf r@ move 0 _buf r> + c! _buf ;
create _ 'C' c, 'a' c, 'n' c, ''' c, 't' c, $20 c, 'o' c, 'p' c, 'e' c, 'n' c,
-: fopen ( fname -- fd )
+: lnxopen ( fname -- fd )
_tozstr 5 ( open ) swap 0 0 ( open cstr noflag O_RDONLY ) lnxcall
dup 0< if _ 10 rtype abort then ;
create _ 1 allot
-: fread ( fd -- c-or-0 ) 3 ( read ) swap _ 1 lnxcall 1 = if _ c@ else 0 then ;
+: lnxgetc ( fd -- c-or-0 ) 3 ( read ) swap _ 1 lnxcall 1 = if _ c@ else 0 then ;