commit d064f7275de8516f9b0e588e1d98759138dd43d2
parent 70ce001154b16aea1caf70b304b07636f6112879
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Fri, 12 Aug 2022 19:57:54 -0400
fs/fat: untangle things a bit
Diffstat:
6 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/buildpc.fs b/buildpc.fs
@@ -11,8 +11,7 @@ xbindict orgifydict
org here org - spit
spitfile<< /xcomp/bootlo.fs
spitfile<< /drv/pc/int13h.fs
-spitfile<< /xcomp/pc/glue1.fs
spitfile<< /fs/fatlo.fs
-spitfile<< /xcomp/pc/glue2.fs
+spitfile<< /xcomp/pc/glue.fs
spitfile<< /xcomp/boothi.fs
bye
diff --git a/fs/fs/fatlo.fs b/fs/fs/fatlo.fs
@@ -10,9 +10,6 @@
\ of logic from this unit in fs/fat. All in all, "read and core stucture" is
\ here, "write" is in fs/fat.
-\ Before loading this unit, you need to define a "fatdrv" value that is a
-\ pointer to a Drive (doc/drive) structure.
-
\ See fs/fat.fs for complete implementation details.
struct[ DirEntry
@@ -88,7 +85,7 @@ r@ :buf( r> Filesystem drv Drive :sec@ ;
dup >> + ( cl offset ) r@ secsz /mod ( cl secoff sec )
r@ reservedseccnt +
over 1+ r@ secsz = if \ end-of-sector cross-over!
- dup 1 + r@ :buf( fatdrv Drive :sec@ r@ :buf( c@ r@ :)buf c! then
+ dup 1 + r@ :buf( r@ Filesystem drv Drive :sec@ r@ :buf( c@ r@ :)buf c! then
0 r@ :readsector ( cl secoff )
r> :buf( + ;
: :FAT12@ ( cluster self -- entry )
@@ -151,7 +148,7 @@ current value :child'
\ read multiple sectors in buf
: :readsectors ( sec u buf self -- ) to _self
A>r swap >r swap >A begin ( buf )
- A> over fatdrv Drive :sec@
+ A> over _self Filesystem drv Drive :sec@
A+ _self secsz + next ( buf ) drop r>A ;
: :readcluster ( cluster dst self -- ) >r
@@ -166,22 +163,18 @@ $1000 const FATMAXSECSZ
\ TODO: support more than one FAT FS at once
align4
create _FATFS
- fatdrv , FAT :child' , 0 , ' abort , 0 , 0 , 0 ,
+ 0 , FAT :child' , 0 , ' abort , 0 , 0 , 0 ,
FAT HDRSZ allot
\ Allocate buffer
FATMAXSECSZ 1+ allot
\ 1+ is for the extra byte for FAT12 cross-sector exception
_FATFS structbind FAT FATFS
-: fatbuf( FATFS :buf( ;
-: )fatbuf FATFS :)buf ;
-
-: readFATvolume ( -- )
- 0 fatbuf( fatdrv Drive :sec@
- fatbuf( FATFS :hdr( FAT HDRSZ move
- FATFS secsz fatdrv Drive secsz = not if
+: readFATvolume ( drv -- ) dup >r _FATFS !
+ 0 FATFS :buf( r@ Drive :sec@
+ FATFS :buf( FATFS :hdr( FAT HDRSZ move
+ FATFS secsz r> Drive secsz = not if
abort" Drive sector size not matching drive!" then ;
-readFATvolume
\ File cursor
extends File struct[ FATFile
@@ -267,6 +260,6 @@ create _EmptyCursor
drop FATFS :getdirentry _EmptyCursor cursors :findfreecursor dup >r
( dirent 'empty hdl ) FATFile SZ move ( dirent )
\ write the rest
- dup fatbuf( - FATFS bufsec FATFS secsz * + ( dirent doffset ) r@ to FATFile entryoff
+ dup FATFS :buf( - FATFS bufsec FATFS secsz * + ( dirent doffset ) r@ to FATFile entryoff
DirEntry filesize r@ to FATFile size ( ) r> ;
current _FATFS 8 + !
diff --git a/fs/xcomp/pc/glue.fs b/fs/xcomp/pc/glue.fs
@@ -0,0 +1,6 @@
+\ Glue code that goes between the filesystem part and boothi
+INT13hDrive readFATvolume
+' FATFS to activefs
+0 S" drv" activefs :child S" pc" activefs :child
+ S" int13h.fs" activefs :child floaded,
+0 S" fs" activefs :child S" fatlo.fs" activefs :child floaded,
diff --git a/fs/xcomp/pc/glue1.fs b/fs/xcomp/pc/glue1.fs
@@ -1 +0,0 @@
-INT13hDrive value fatdrv
diff --git a/fs/xcomp/pc/glue2.fs b/fs/xcomp/pc/glue2.fs
@@ -1,5 +0,0 @@
-\ Glue code that goes between the filesystem part and boothi
-' FATFS to activefs
-0 S" drv" activefs :child S" pc" activefs :child
- S" int13h.fs" activefs :child floaded,
-0 S" fs" activefs :child S" fatlo.fs" activefs :child floaded,
diff --git a/fs/xcomp/pc/init.fs b/fs/xcomp/pc/init.fs
@@ -10,7 +10,7 @@ f<< /sys/grid.fs
' (emit) to emit
f<< /drv/pc/ata.fs
-ataidentify $c0 and $40 = [if] atareset drop ATADrive to fatdrv [then]
+ataidentify $c0 and $40 = [if] atareset drop ATADrive to FATFS drv [then]
f<< /drv/pc/pci.fs
f<< /drv/pc/ps28042.fs