commit 2dd86b072efe14654dc4106859e6f08aa47abffb
parent 1660c3e57ff4df0783fd58b85222f181d1d9a1c5
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Fri, 1 Jul 2022 15:37:44 -0400
Runs on FAT16!
Diffstat:
5 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,5 +1,10 @@
TARGETS = dusk
-BOOTFS_SRC = fs/xcomp/bootlo.fs fs/fs/linux.fs bootglue.fs fs/xcomp/boothi.fs
+BOOTFS_SRC = fs/xcomp/bootlo.fs \
+ fs/drv/ramdrive.fs \
+ fs/xcomp/glue1.fs \
+ fs/fs/boot.fs \
+ fs/xcomp/glue2.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
@@ -9,10 +9,8 @@
\ This unit has access to a very small set of words, that it, words implemented
\ by boot.fs as well as the "drive" protocol, which is implemented by a driver
\ that is inserted between boot.fs and this unit.
-
-$18 const BPBSZ \ we only care about a part of the BPB
-create bpb BPBSZ allot
-0 drv@ drvbuf( bpb BPBSZ move
+create bpb drvblksz allot
+0 bpb (drv@)
: BPB_BytsPerSec bpb $0b + w@ ;
: BPB_SecPerClus bpb $0d + c@ ;
@@ -94,7 +92,7 @@ here const )fnbuf
: findpath ( path -- direntry )
A>r fnbufclr fnbuf( >A c@+ >r readroot begin ( a )
- c@+ dup emit case
+ c@+ case
'.' of = fnbuf( 8 + >A endof
'/' of = _findindir readdir fnbufclr fnbuf( >A endof
r@ upcase Ac!+ A> )fnbuf = if abort" filename too long!" then
@@ -109,7 +107,7 @@ here const )fnbuf
\ 4b cur pos (offset from beginning of file)
\ 4b file size
\ Xb current cluster X=ClusterSize
-4 const FCURSORCNT \ maximum number of opened files
+10 const FCURSORCNT \ maximum number of opened files
: FCursorSize ClusterSize 12 + ;
: FCUR_cluster0 ( fcur -- n ) w@ ;
: FCUR_cluster ( fcur -- n ) 2 + w@ ;
diff --git a/fs/init.fs b/fs/init.fs
@@ -5,9 +5,9 @@ f<< sys/doc.fs
f<< lib/io.fs
f<< sys/scratch.fs
f<< sys/drive.fs
-f<< drv/ramdrive.fs
-fatfs( to ramdrv(
+\ we don't load drv/ramdrive.fs because it's already in boot.fs
RAMDRVSECSZ to drvblksz
+fatfs( to ramdrv(
' ramdrv@ to (drv@)
' ramdrv! to (drv!)
f<< lib/file.fs
diff --git a/fs/xcomp/glue1.fs b/fs/xcomp/glue1.fs
@@ -0,0 +1,4 @@
+\ Glue code between the storage driver and the FS handler
+fatfs( to ramdrv(
+RAMDRVSECSZ const drvblksz
+alias ramdrv@ (drv@)
diff --git a/fs/xcomp/glue2.fs b/fs/xcomp/glue2.fs
@@ -0,0 +1,5 @@
+\ Glue code that goes between the filesystem part and boothi
+readFAT
+alias fat16open fopen
+alias fat16getc fread
+alias fat16close fclose