duskos

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

commit 0e0c75cda82220d0fbdb5c412cf92ce133b4e4f8
parent 36899e2b919fa5cd53345fddf589b13bd28cb7c1
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sat, 28 Jan 2023 20:19:03 -0500

Make the "floaded" LL go "backwards"

This makes the structure "forkable". I realized that context+floaded is utterly
broken. This commit doesn't fix the problem, but is part of the fix.

Diffstat:
Mfs/doc/arch.txt | 5+++--
Mfs/doc/lib/meta.txt | 13++++++-------
Mfs/xcomp/bootlo.fs | 6+++---
3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/fs/doc/arch.txt b/fs/doc/arch.txt @@ -149,8 +149,9 @@ 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 takes all of this and implements "fload", and then loads -sys/file.fs and then xcomp/i386/pc/init.fs. Then, it executes the word "init". +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 +loop has been installed (rather than interpreting the whole memory contents). This is sourced from xcomp/boothi.fs ### Initialization layer (init) diff --git a/fs/doc/lib/meta.txt b/fs/doc/lib/meta.txt @@ -45,9 +45,7 @@ forget ( "name" -- ) Words related to metadata's linked list: emetatype ( meta -- type ) - Return the type ID of "meta". - -'emetadata ( meta -- a ) + Return the type ID of "meta". 'emetadata ( meta -- a ) Return the address of the data area of "meta". findmeta ( typeid meta -- meta-or-0 ) @@ -78,9 +76,10 @@ facts: 1. The "floaded" node is written to "here" *before* the file is actually loaded. 2. "f<<" does not add a node if the node is already present. +3. The "floaded" LL goes backwards ("floaded" is a value that points to LL's + head) Therefore, you can have a "f<< / forget" loop if you always load the same single -file. If you really need to load multiple files, you'll need to "pre-mark" your -files as loaded with something like 'p" /my/path" Path id floaded,' and then -individually load your files with "f<<" (implicit "?f<<" won't load anything). -Your loaded files will then be "forget-safe". +file. If you really need to load multiple files, save the value of "floaded" +somewhere before you load your multiple paths. Than, right after your forget +(before you load any file), restore "floaded" back to that value. diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs @@ -340,12 +340,12 @@ extends IO struct[ File \ File loading \ TODO: support loading from multiple FSes. -create floaded 0 , \ loaded files LL, *no data* +0 value floaded \ head of the LL : floaded? ( id -- f ) floaded begin ( id ll ) - llnext ?dup while 2dup CELLSZ + @ = not while repeat + ?dup while 2dup CELLSZ + @ <> while llnext repeat 2drop 1 else drop 0 then ; -: floaded, ( id -- ) dup floaded? if drop else floaded lladd drop , then ; +: floaded, ( id -- ) dup floaded? if drop else here to@! floaded , , then ; : \s console readio IO :close ; : fload ( fs id -- ) dup floaded, swap Filesystem :open IO :interpret File :close ;