commit 6e533b3f21e265b4b08132b67ed128195488a057
parent 2270d5ebe03e413d5eb19995694035f897d339cc
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sat, 4 Jun 2022 15:12:47 -0400
arch: add the "init" layer and move rdln from boot to /sys/rdln.fs
Diffstat:
4 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/boot.fs b/boot.fs
@@ -69,26 +69,4 @@ _fds value 'curfd
: fin< f< ?dup not if ( EOF )
fd~ fd@ not if ['] iin< to in< then SPC then ;
: f<< word fopen >fd ['] fin< to in< ;
-
-64 value LNSZ
-create in( LNSZ allot
-: in) in( 64 + ;
-: bs? BS over = swap $7f = or ;
-\ only emit c if it's within the visible ascii range
-: emitv ( c -- ) dup SPC - $5f < if emit else drop then ;
-: lntype ( ptr c -- ptr+1 f )
- dup bs? if ( ptr c )
- drop dup in( > if 1- BS emit then spc> BS emit 0
- else ( ptr c ) \ non-BS
- dup emitv dup rot c!+ ( c ptr+1 ) dup in) = rot SPC < or ( ptr+1 f )
- then ;
-: rdln
- in( LNSZ SPC fill S" ok" stype nl>
- in( begin key lntype until drop nl> ;
-: rdln<? ( -- c-or-0 )
- in> in) < if in> c@+ swap to in> else 0 then ;
-: rdln< ( -- c ) rdln<? ?dup not if
- rdln in( to in> SPC then ;
-: rdln$ ['] rdln< dup to iin< to in< in) to in> ;
-: init S" Dusk OS" stype rdln$ ;
-init
+f<< init.fs
diff --git a/fs/doc/arch.txt b/fs/doc/arch.txt
@@ -75,9 +75,17 @@ read from memory. The role of the boot layer is to:
1. Implement a minimally convenient set of words, such as comments, conditions
and loops, string literals, number formatting, create/value/alias.
2. Give access to the root filesystem.
-3. Implement a user input system.
+3. Load /init.fs and run it.
-Once it does that, it then spits the "Dusk OS" prompt and then switch in< to
-the user input.
+# Initialization layer (init)
+
+The 3 first layers are machine-dependant and will not change unless something
+fundamental changes with your machine. The "init" layer, however, is
+user-dependant. It does whatever you need it to do.
+
+It will typically load subsystems from /sys/ and then present a prompt. The boot
+layer didn't leave your machine with a way for the user to interact with the
+machine, so before you prompt, you'll have to load a subsystem for user
+interaction, for example /sys/rdln.fs.
The system is yours.
diff --git a/fs/init.fs b/fs/init.fs
@@ -0,0 +1,4 @@
+\ Initialization layer. Called at the end of boot.fs
+f<< sys/rdln.fs
+: init S" Dusk OS" stype rdln$ ;
+init
diff --git a/fs/sys/rdln.fs b/fs/sys/rdln.fs
@@ -0,0 +1,21 @@
+\ Readline interface
+64 value LNSZ
+create in( LNSZ allot
+: in) in( 64 + ;
+: bs? BS over = swap $7f = or ;
+\ only emit c if it's within the visible ascii range
+: emitv ( c -- ) dup SPC - $5f < if emit else drop then ;
+: lntype ( ptr c -- ptr+1 f )
+ dup bs? if ( ptr c )
+ drop dup in( > if 1- BS emit then spc> BS emit 0
+ else ( ptr c ) \ non-BS
+ dup emitv dup rot c!+ ( c ptr+1 ) dup in) = rot SPC < or ( ptr+1 f )
+ then ;
+: rdln
+ in( LNSZ SPC fill S" ok" stype nl>
+ in( begin key lntype until drop nl> ;
+: rdln<? ( -- c-or-0 )
+ in> in) < if in> c@+ swap to in> else 0 then ;
+: rdln< ( -- c ) rdln<? ?dup not if
+ rdln in( to in> SPC then ;
+: rdln$ ['] rdln< dup to iin< to in< in) to in> ;