~vdupras/duskos

1660c3e57ff4df0783fd58b85222f181d1d9a1c5 — Virgil Dupras a month ago 6e30417
Add namespaces to FS words and a "glue" part fo boot.fs
3 files changed, 6 insertions(+), 4 deletions(-)

M Makefile
M fs/fs/boot.fs
M fs/fs/linux.fs
M Makefile => Makefile +1 -1
@@ 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

M fs/fs/boot.fs => fs/fs/boot.fs +2 -0
@@ 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 )

M fs/fs/linux.fs => fs/fs/linux.fs +3 -3
@@ 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 ;