commit bc53f7a749ddd60dac914bd5cdf5b22ba46ae2e7
parent 9e3a277f42e75d4ff2c029bce38a665bc73611b7
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sat, 13 Aug 2022 07:16:05 -0400
Make "activefs" into a structbind instead of an alias
This allows us to remove the global "FATFS" structbind and rename the "_FATFS"
data structure to "FATFS".
Diffstat:
6 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/fs/fs/fatlo.fs b/fs/fs/fatlo.fs
@@ -232,15 +232,14 @@ $1000 const FATMAXSECSZ
\ TODO: support more than one FAT FS at once
align4
-create _FATFS
+create FATFS
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
-create _FATCursors _FATFS , 0 ,
+create _FATCursors FATFS , 0 ,
_FATCursors structbind FATCursors cursors
create _EmptyCursor
@@ -249,7 +248,7 @@ create _EmptyCursor
\ File handle methods :seek :close
FATFile :fatseek' , FATFile :fatclose' ,
\ FAT fields
- _FATFS , 1 ( flags ) , 0 ( cluster ) , -1 ( clusteridx ) , 0 ( pos ) ,
+ FATFS , 1 ( flags ) , 0 ( cluster ) , -1 ( clusteridx ) , 0 ( pos ) ,
0 ( size ) , 0 ( entryoff ) ,
0 value _self
@@ -260,11 +259,11 @@ create _EmptyCursor
\ write the rest
dup _self FAT :buf( - _self FAT bufsec _self FAT secsz * + ( dirent doffset )
r@ to FATFile entryoff DirEntry filesize r@ to FATFile size ( ) r> ;
-current _FATFS 8 + !
+current FATFS 8 + !
-: readFATvolume ( drv -- ) dup >r _FATFS !
- 0 _FATFS FAT :buf( r@ Drive :sec@
- _FATFS FAT :buf( _FATFS FAT :hdr( FAT HDRSZ move
- _FATFS FAT secsz r> Drive secsz = not if
+: readFATvolume ( drv -- ) dup >r FATFS !
+ 0 FATFS FAT :buf( r@ Drive :sec@
+ FATFS FAT :buf( FATFS FAT :hdr( FAT HDRSZ move
+ FATFS FAT secsz r> Drive secsz = not if
abort" Drive sector size not matching drive!" then ;
diff --git a/fs/sys/file.fs b/fs/sys/file.fs
@@ -3,7 +3,7 @@
26 const MAXFSCNT
create filesystems MAXFSCNT CELLSZ * allot0
-to@ activefs filesystems ! \ record our boot FS in the list
+' activefs structbind' filesystems ! \ record our boot FS in the list
0 value curdir
create _buf $100 allot
diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs
@@ -205,7 +205,8 @@ does> ( 'struct )
: structbind ( 'data -- ) ' doer , , immediate does> ( 'bind -- *to* )
dup @ swap CELLSZ + ( 'struct ''data )
compiling if litn compile @ else @ swap then execute ;
-: rebind ( 'data 'bind -- ) does' CELLSZ + ! ;
+: structbind' ( 'bind -- ) does' CELLSZ + ;
+: rebind ( 'data 'bind -- ) structbind' ! ;
\ Drive API
\ Anticipating lib/drive
@@ -231,7 +232,7 @@ struct[ Filesystem
smethod :open
smethod :newfile
]struct
-alias abort activefs immediate
+0 structbind Filesystem activefs \ has to be rebinded before first use
extends IO struct[ File
smethod :seek
smethod :close
diff --git a/fs/xcomp/pc/glue.fs b/fs/xcomp/pc/glue.fs
@@ -1,6 +1,6 @@
\ Glue code that goes between the filesystem part and boothi
INT13hDrive readFATvolume
-' FATFS to activefs
+FATFS ' activefs rebind
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 FATFS drv [then]
+ataidentify $c0 and $40 = [if] atareset drop ATADrive to activefs drv [then]
f<< /drv/pc/pci.fs
f<< /drv/pc/ps28042.fs
diff --git a/posix/glue.fs b/posix/glue.fs
@@ -6,5 +6,4 @@ create _POSIXFS
' _:open ,
' abort ,
-_POSIXFS structbind Filesystem POSIXFS
-current to activefs
+_POSIXFS ' activefs rebind