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

commit 6a091fb48d5b9e58f35c15536d4eaae564cd6fb9
parent f440785490b4da379d7d4ea3b6bf704834d64d06
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Mon, 15 May 2023 21:42:42 -0400

Make bootfs into a structbind

Mfs/doc/arch.txt | 8++++----
Mfs/doc/deploy.txt | 4++--
Mfs/doc/lib/file.txt | 10++++++----
Mfs/doc/sys/file.txt | 2+-
Mfs/lib/file.fs | 1+
Mfs/sys/file.fs | 7+++----
Mfs/xcomp/boothi.fs | 8+++-----
Mfs/xcomp/bootlo.fs | 3---
Mfs/xcomp/i386/pc/build.fs | 6+++---
Mfs/xcomp/i386/pc/glue.fs | 11+++++------
Mfs/xcomp/i386/pc/init.fs | 8++++----
Mposix/glue.fs | 2+-
12 files changed, 33 insertions(+), 37 deletions(-)

diff --git a/fs/doc/arch.txt b/fs/doc/arch.txt @@ -138,10 +138,10 @@ For now, Dusk can only boot from a FAT12 volume. To do so, it needs the "fatlo" code, a read-only subset of its FAT implementation, to be embedded in the boot code. This piece of code lives in fs/fatlo.fs -The glue file plugs the Filesystem structure into the "bootfs" pointer. It also -has the responsibility of adding references to embedded files in "floaded" so -that they aren't loaded twice in memory. In the PC target, this is sourced from -xcomp/pc/glue.fs +The glue file creates a "bootfs" structbind from the Filesystem structure. It +also has the responsibility of adding references to embedded files in "floaded" +so that they aren't loaded twice in memory. In the PC target, this is sourced +from xcomp/pc/glue.fs The "boothi" part does very little: it loads /sys/file.fs and then /init.fs, and then calls init. It ends with a failsafe to ensure that an interactive interpret diff --git a/fs/doc/deploy.txt b/fs/doc/deploy.txt @@ -87,8 +87,8 @@ other sectors too? Well, that sounds good, it looks like you can plug fatlo in. For this, I recommend looking at how the PC platform does it. It should look the same for all targets: we stream bootlo in, then the storage driver, then fatlo, -then the "glue" file, which create an instance of Filesystem and place it in the -"bootfs" value. +then the "glue" file, which create an instance of Filesystem as well as a +"bootfs" structbind to it. If you look at PC's glue.fs, you'll also see something about "floaded," the goal of that is to "register" files in the boot stream as "loaded" so that "?f<<" diff --git a/fs/doc/lib/file.txt b/fs/doc/lib/file.txt @@ -15,16 +15,18 @@ capabilities to a memory buffer. It extends File with those words: ## DriveFile DriveFile is a structure allowing direct access to a Drive through the -convenience of a File API. It's buffer size is the drive's sector size. +convenience of a File API. Its buffer size is the drive's sector size. It lives +on top of a SectorWindow (lib/drive) and by defaults targets the whole drive, +although the :move word can be used to reduce the scope of the file. Fields: -drv The Drive being interfaced. -sec Sector number currently in buffer, -1 if none. -dirty? Whether the buffer has changed since it was loaded from the drive. +secwin The target SectorWindow. Words: :new ( drv -- hdl ) Create a new DriveFile interfacing Drive "drv". +:move ( fsec cnt self -- ) + Calls secwin's :move and seek pos 0. diff --git a/fs/doc/sys/file.txt b/fs/doc/sys/file.txt @@ -168,7 +168,7 @@ on to a Path reference a little longer, you should copy it elsewhere. The File subsystem has 2 important global variables: -bootfs is a pointer to the Filesystem structure from which the system was +bootfs is a structbind to the Filesystem structure from which the system was booted. It's used only until the File subsystem is initialized. curpath is a Path bind that points to the "current directory". It is initialized diff --git a/fs/lib/file.fs b/fs/lib/file.fs @@ -19,6 +19,7 @@ extends File struct[ MemFile extends File struct[ DriveFile sfield secwin : :secwin [compile] secwin [compile] SectorWindow ; immediate + : :move dup :secwin :move 0 :seek ; : flush :secwin :flush ; : seek ( pos self -- ) to pos ; : readbuf ( n self -- a? read-n ) diff --git a/fs/sys/file.fs b/fs/sys/file.fs @@ -1,5 +1,4 @@ -0 S" sys" bootfs Filesystem :child S" io.fs" bootfs Filesystem :child - bootfs swap fload +bootfs :self 0 S" sys" bootfs :child S" io.fs" bootfs :child fload struct[ FSInfo sfield name @@ -9,7 +8,7 @@ struct[ FSInfo 26 const MAXFSCNT create filesystems MAXFSCNT CELLSZ * allot0 -bootfs filesystems ! \ record our boot FS in the list +bootfs :self filesystems ! \ record our boot FS in the list struct+[ Filesystem : :?newfile ( dirid name fs -- id ) @@ -22,7 +21,7 @@ struct[ Path sfield fs sfield id - create _curpath bootfs , 0 , + create _curpath bootfs :self , 0 , $400 const BUFSZ create _paths BUFSZ SZ * allot diff --git a/fs/xcomp/boothi.fs b/fs/xcomp/boothi.fs @@ -1,5 +1,3 @@ -0 S" sys" bootfs Filesystem :child S" file.fs" bootfs Filesystem :child - bootfs swap fload -0 S" init.fs" bootfs Filesystem :child bootfs swap fload -init -." Still on BootIn after init? shutting down." bye +bootfs :self 0 S" sys" bootfs :child S" file.fs" bootfs :child fload +bootfs :self 0 S" init.fs" bootfs :child fload +init ." Booting error" bye diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs @@ -450,9 +450,6 @@ struct[ Filesystem '" child" , '" info" , '" open" , '" iter" , '" newfile" , '" newdir" , '" remove" , ; ]struct -\ bootfs holds a reference to boot FS. This is used until the full sys/file -\ subsystem takes over with Path mechanics. -0 value bootfs extends IO struct[ File sfield pos sfield size diff --git a/fs/xcomp/i386/pc/build.fs b/fs/xcomp/i386/pc/build.fs @@ -34,7 +34,7 @@ org value kernel : setupFAT ( drv clustercnt -- fat ) ." creating FAT and copying files\n" - createFAT bootfs over copyfs ; + createFAT bootfs :self over copyfs ; : spitfile ( fpath dst -- ) >r curpath :find# Path :open begin ( fc ) @@ -44,8 +44,8 @@ org value kernel : combineInit ( fname1 fname2 fat -- ) >r swap >r >r \ V1=fat V2=f1 V3=f2 0 S" init.fs" V1 Filesystem :?newfile V1 swap Path :new - V2 bootfs 0 Path :new Path :find# Path :copyfile - V3 bootfs 0 Path :new Path :find# + V2 bootfs :self 0 Path :new Path :find# Path :copyfile + V3 bootfs :self 0 Path :new Path :find# S" /init.fs" V1 0 Path :new Path :find# Path :appendfile 2rdrop rdrop ; diff --git a/fs/xcomp/i386/pc/glue.fs b/fs/xcomp/i386/pc/glue.fs @@ -1,7 +1,6 @@ \ Glue code that goes between the filesystem part and boothi -INT13hDrive FAT :mountvolume ( fs ) to bootfs -0 S" drv" bootfs Filesystem :child S" pc" bootfs Filesystem :child - S" int13h.fs" bootfs Filesystem :child floaded, -0 S" lib" bootfs Filesystem :child - S" drivelo.fs" bootfs Filesystem :child floaded, -0 S" fs" bootfs Filesystem :child S" fatlo.fs" bootfs Filesystem :child floaded, +INT13hDrive FAT :mountvolume ( fs ) structbind FAT bootfs +0 S" drv" bootfs :child S" pc" bootfs :child + S" int13h.fs" bootfs :child floaded, +0 S" lib" bootfs :child S" drivelo.fs" bootfs :child floaded, +0 S" fs" bootfs :child S" fatlo.fs" bootfs :child floaded, diff --git a/fs/xcomp/i386/pc/init.fs b/fs/xcomp/i386/pc/init.fs @@ -14,16 +14,16 @@ grid :self dup to console writeio to stdio writeio \ Floppy boot drive \ f<< /drv/pc/fdc.fs \ floppy :init -\ floppy :self bootfs to Filesystem drv +\ floppy :self to bootfs drv f<< /drv/pc/pci.fs \ IDE boot drive f<< /drv/pc/ata.fs -ATA0:0 ATADrive :reset drop ATA0:0 bootfs to Filesystem drv +ATA0:0 ATADrive :reset drop ATA0:0 to bootfs drv \ AHCI boot drive \ f<< /drv/pc/ahci.fs -\ 0 AHCIDrive :new dup bootfs to Filesystem drv ( drv ) +\ 0 AHCIDrive :new dup to bootfs drv ( drv ) \ AHCIDrive :enable \ Now that int13h won't be used anymore, it's safe to configure the PIC @@ -31,7 +31,7 @@ f<< /drv/pc/pic.fs pic$ idt$ f<< /fs/fat.fs -bootfs FAT :patchlo +bootfs :patchlo f<< /sys/kbd.fs f<< /sys/mouse.fs diff --git a/posix/glue.fs b/posix/glue.fs @@ -9,7 +9,7 @@ extends Filesystem struct[ POSIXFS alias abort remove : :new 0 Filesystem :new S[ :[methods] ]S c@+ -move, ; ]struct -POSIXFS :new to bootfs +POSIXFS :new structbind POSIXFS bootfs : mountImage ( imgname -- drv ) _mountdrv here 512 , -1 , ['] _drv@ , ['] _drv! , ;