duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit f68551c3cb332536d1558a03cc0a79ac0d8c5978
parent c2626f885900d93ecf82330dad4b1cd2c7495748
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Fri, 12 Aug 2022 07:18:40 -0400

fs/fat: fix indirection level for fatdrv

Indirection has to be made at the data level, not the structbind level.
Otherwise, compiled methods get stuck to the initial value.

Diffstat:
Mfs/drv/pc/ata.fs | 3+--
Mfs/drv/pc/int13h.fs | 3+--
Mfs/fs/fatlo.fs | 14+++++++-------
Mfs/tests/kernel.fs | 4++++
Mfs/xcomp/pc/glue1.fs | 2+-
Mfs/xcomp/pc/init.fs | 15+--------------
6 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/fs/drv/pc/ata.fs b/fs/drv/pc/ata.fs @@ -55,8 +55,7 @@ $ec const IDENTIFY 1 to atabus 0 to atadrive .ata nl> 1 to atadrive .ata nl> to atabus to atadrive ; -create _ATADrive +create ATADrive ATASECSZ , ' ata@ , ' ata! , -_ATADrive structbind Drive ATADrive diff --git a/fs/drv/pc/int13h.fs b/fs/drv/pc/int13h.fs @@ -13,8 +13,7 @@ $7c24 c@ const DRVNO : biossec! abort" int13h driver doesn't support writing" ; -create _INT13hDrive +create INT13hDrive BIOSSECSZ , ' biossec@ , ' biossec! , -_INT13hDrive structbind Drive INT13hDrive diff --git a/fs/fs/fatlo.fs b/fs/fs/fatlo.fs @@ -27,15 +27,15 @@ align4 create fatbuf( FATMAXSECSZ 1+ allot \ 1+ is for the extra byte for FAT12 cross-sector exception -alias fatdrv bufdrv immediate \ drive from which this sector was read 0 value bufsec \ sector number of current buf 0 value bufseccnt \ number of sectors ahead for sequential read 0 value bufcluster \ cluster number of current buf -: )fatbuf fatbuf( bufdrv secsz + ; +: )fatbuf fatbuf( fatdrv Drive secsz + ; \ "cnt" is the number of sectors ahead of "sec" that are available for a \ seqential read. -: readsector ( sec cnt -- ) to bufseccnt dup to bufsec fatbuf( bufdrv :sec@ ; +: readsector ( sec cnt -- ) + to bufseccnt dup to bufsec fatbuf( fatdrv Drive :sec@ ; extends Filesystem 7 struct FATFields secsz secpercluster reservedseccnt FATcnt rootentcnt seccnt FATsz @@ -51,7 +51,7 @@ create _FATFS _FATFS structbind FATFields FATFS : readFATvolume ( -- ) - 0 fatbuf( fatdrv :sec@ + 0 fatbuf( fatdrv Drive :sec@ fatbuf( $0b + w@ to FATFS secsz fatbuf( $0d + c@ to FATFS secpercluster fatbuf( $0e + w@ to FATFS reservedseccnt @@ -59,7 +59,7 @@ _FATFS structbind FATFields FATFS fatbuf( $11 + w@ to FATFS rootentcnt fatbuf( $13 + w@ to FATFS seccnt fatbuf( $16 + w@ to FATFS FATsz - FATFS secsz fatdrv secsz = not if + FATFS secsz fatdrv Drive secsz = not if abort" Drive sector size not matching drive!" then ; readFATvolume @@ -82,7 +82,7 @@ readFATvolume dup >> + ( cl offset ) FATFS secsz /mod ( cl secoff sec ) FATFS reservedseccnt + over 1+ FATFS secsz = if \ end-of-sector cross-over! - dup 1 + fatbuf( bufdrv :sec@ fatbuf( c@ )fatbuf c! then + dup 1 + fatbuf( fatdrv Drive :sec@ fatbuf( c@ )fatbuf c! then 0 readsector ( cl secoff ) fatbuf( + ; : FAT12@ ( cluster -- entry ) @@ -208,7 +208,7 @@ extends File 12 struct FATFile \ read multiple sectors in buf : readsectors ( sec u buf -- ) A>r swap >r swap >A begin ( buf ) - A> over bufdrv :sec@ A+ FATFS secsz + next ( buf ) drop r>A ; + A> over fatdrv Drive :sec@ A+ FATFS secsz + next ( buf ) drop r>A ; : readcluster ( cluster dst -- ) over 2 - $fff6 > if abort" cluster out of range!" then diff --git a/fs/tests/kernel.fs b/fs/tests/kernel.fs @@ -119,6 +119,10 @@ data1 structbind Foo MyData1 MyData1 bar 1 #eq : myword MyData1 :bleh ; myword 45 #eq +: bleh2 dup Foo bar swap Foo baz + 1+ ; +' bleh2 data1 8 + ! +data1 Foo :bleh 46 #eq +myword 46 #eq extends Foo 1 struct Bazooka bling create data3 7 , 9 , ' mybleh , 999 , diff --git a/fs/xcomp/pc/glue1.fs b/fs/xcomp/pc/glue1.fs @@ -1 +1 @@ -alias INT13hDrive fatdrv immediate +INT13hDrive value fatdrv diff --git a/fs/xcomp/pc/init.fs b/fs/xcomp/pc/init.fs @@ -1,19 +1,6 @@ \ Initialization for PC : ARCH S" i386" ; -\ TODO: the ATADrive assignment below actually isn't working so well, so if we -\ don't create our cursor before hitting the $10000 mark, all hell breaks loose -\ with INT13h that is still in use. -\ Fix this and remove those ugly cursor pre-assignments -createcursor drop -createcursor drop -createcursor drop -createcursor drop -createcursor drop -createcursor drop -createcursor drop -createcursor drop - 0 S" sys" activefs :child S" file.fs" activefs :child fload \ We now have f<< f<< /drv/pc/acpi.fs @@ -23,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 fatdrv [then] f<< /drv/pc/pci.fs f<< /drv/pc/ps28042.fs