~vdupras/duskos

2dd86b072efe14654dc4106859e6f08aa47abffb — Virgil Dupras a month ago 1660c3e
Runs on FAT16!
5 files changed, 21 insertions(+), 9 deletions(-)

M Makefile
M fs/fs/boot.fs
M fs/init.fs
A fs/xcomp/glue1.fs
A fs/xcomp/glue2.fs
M Makefile => Makefile +6 -1
@@ 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

M fs/fs/boot.fs => fs/fs/boot.fs +4 -6
@@ 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@ ;

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

A fs/xcomp/glue1.fs => fs/xcomp/glue1.fs +4 -0
@@ 0,0 1,4 @@
\ Glue code between the storage driver and the FS handler
fatfs( to ramdrv(
RAMDRVSECSZ const drvblksz
alias ramdrv@ (drv@)

A fs/xcomp/glue2.fs => fs/xcomp/glue2.fs +5 -0
@@ 0,0 1,5 @@
\ Glue code that goes between the filesystem part and boothi
readFAT
alias fat16open fopen
alias fat16getc fread
alias fat16close fclose