commit 9e2d5e61a728d2ecd9544448e1c4074043c60c63
parent 5678088c8ecdecfe5a9724292ebf140e26bfc5c8
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Fri, 12 Aug 2022 12:51:35 -0400
fs/fat: make FAT headers being copied into the structure as-is
It makes its processing slightly less verbose.
Diffstat:
2 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/fs/fs/fatlo.fs b/fs/fs/fatlo.fs
@@ -38,29 +38,26 @@ create fatbuf( FATMAXSECSZ 1+ allot
to bufseccnt dup to bufsec fatbuf( fatdrv Drive :sec@ ;
extends Filesystem struct[ FATFields
- sfield secsz \ in bytes
- sfield secpercluster
- sfield reservedseccnt \ number of sectors reserved before FAT starts
- sfield FATcnt \ >1 means backup FATs
- sfield rootentcnt \ count of 32b entries
- sfield seccnt
- sfield FATsz \ in bytes
+ ' FATFields structsz const SZ
+ SZ &+ hdr(
+ SZ $0b + &+w@ secsz \ in bytes
+ SZ $0d + &+c@ secpercluster
+ SZ $0e + &+w@ reservedseccnt \ number of sectors reserved before FAT starts
+ SZ $10 + &+c@ FATcnt \ >1 means backup FATs
+ SZ $11 + &+w@ rootentcnt \ count of 32b entries
+ SZ $13 + &+w@ seccnt
+ SZ $16 + &+w@ FATsz \ in bytes
+ $1a const HDRSZ
]struct
\ TODO: support more than one FAT FS at once
create _FATFS
- ' fatdrv , 0 , 0 , ' abort , 7 CELLSZ * allot
+ ' fatdrv , 0 , 0 , ' abort , 7 CELLSZ * allot FATFields HDRSZ allot
_FATFS structbind FATFields FATFS
: readFATvolume ( -- )
0 fatbuf( fatdrv Drive :sec@
- fatbuf( $0b + w@ to FATFS secsz
- fatbuf( $0d + c@ to FATFS secpercluster
- fatbuf( $0e + w@ to FATFS reservedseccnt
- fatbuf( $10 + c@ to FATFS FATcnt
- fatbuf( $11 + w@ to FATFS rootentcnt
- fatbuf( $13 + w@ to FATFS seccnt
- fatbuf( $16 + w@ to FATFS FATsz
+ fatbuf( FATFS hdr( FATFields HDRSZ move
FATFS secsz fatdrv Drive secsz = not if
abort" Drive sector size not matching drive!" then ;
readFATvolume
diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs
@@ -84,6 +84,8 @@
: &w@ ( n -- ) doer , does> @ w@ ;
: &c@ ( n -- ) doer , does> @ c@ ;
: &+@ ( n -- ) doer , does> @ + @ ;
+: &+w@ ( n -- ) doer , does> @ + w@ ;
+: &+c@ ( n -- ) doer , does> @ + c@ ;
: &+! ( n -- ) doer , does> @ + ! ;
\ while..repeat