duskos

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

commit a85ebfff270dc517c0a2e852c0a0cc754b31961e
parent fa998933262e43cfc3c585b8090892cd21927bb5
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun,  5 Jun 2022 07:09:28 -0400

Extract /lib/core/fs from boot.fs

Diffstat:
Mboot.fs | 15+--------------
Mdusk.asm | 1-
Mfs/doc/arch.txt | 4++--
Afs/doc/dirstruct.txt | 7+++++++
Mfs/init.fs | 1+
Afs/lib/core.fs | 16++++++++++++++++
6 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/boot.fs b/boot.fs @@ -31,21 +31,8 @@ current to (wnf) : _ S" stack underflow" stype abort ; current to (psufl) -: <> ( n n -- l h ) 2dup > if swap then ; -: min <> drop ; : max <> nip ; : fill ( a u b -- *A* ) rot> >r >A begin dup Ac!+ next drop ; : allot0 ( n -- ) here over 0 fill allot ; -: .xh $f and tbl-0-f + c@ emit ; -: .x1 dup 4 rshift .xh .xh ; -: .x2 dup 8 rshift .x1 .x1 ; -: .x dup 16 rshift .x2 .x2 ; -: nl> CR emit LF emit ; : spc> SPC emit ; -: psdump scnt not if exit then - scnt >A begin dup .x spc> >r scnt not until - begin r> scnt A> = until ; -: .S ( -- ) - S" SP " stype scnt .x1 spc> S" RS " stype rcnt .x1 spc> - S" -- " stype stack? psdump ; : code word entry ; : create code compile (cell) ; : value code compile (val) , ; @@ -56,7 +43,7 @@ create _ $100 allot : fclose ( fd -- ) 6 ( close ) swap 0 0 ( close fd 0 0 ) lnxcall drop ; : fopen ( sa sl -- fd ) tocstr 5 ( open ) swap 0 0 ( open cstr noflag O_RDONLY ) lnxcall - dup 0< if S" Can't open" stype abort then ; + dup 0< if abort" Can't open" then ; create _ 1 allot : fread ( fd -- c-or-0 ) 3 ( read ) swap _ 1 lnxcall 1 = if _ c@ else 0 then ; diff --git a/dusk.asm b/dusk.asm @@ -110,7 +110,6 @@ iinrd: resd 1 ; iin< inrd: resd 1 ; in< wnf: resd 1 ; (wnf) psufl: resd 1 ; (psufl) -scratchpad: resd 0x100 resd PS_SZ ps_top: resd RS_SZ diff --git a/fs/doc/arch.txt b/fs/doc/arch.txt @@ -73,8 +73,8 @@ The contents of /boot.fs has been embedded to the Dusk OS binary and is being 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. + and loops, string literals, create/value/alias. +2. Give access to the root filesystem (f<<). 3. Load /init.fs and run it. # Initialization layer (init) diff --git a/fs/doc/dirstruct.txt b/fs/doc/dirstruct.txt @@ -0,0 +1,7 @@ +# Directory structure + +/lib: collections of words to be used in multiple apps/subsystems + +/sys: subsystems. self-contained set of words that provide a "background" + service. Readline interface, Grid interface, etc. They're similar to + libraries, but only a handful of words in them are externally usable. diff --git a/fs/init.fs b/fs/init.fs @@ -1,4 +1,5 @@ \ Initialization layer. Called at the end of boot.fs +f<< lib/core.fs f<< sys/rdln.fs : init S" Dusk OS" stype rdln$ ; init diff --git a/fs/lib/core.fs b/fs/lib/core.fs @@ -0,0 +1,16 @@ +\ Core forth words that are hard to live without +\ pretty much every Forth source in the system use those words +: <> ( n n -- l h ) 2dup > if swap then ; +: min <> drop ; : max <> nip ; + +: .xh $f and tbl-0-f + c@ emit ; +: .x1 dup 4 rshift .xh .xh ; +: .x2 dup 8 rshift .x1 .x1 ; +: .x dup 16 rshift .x2 .x2 ; +: nl> CR emit LF emit ; : spc> SPC emit ; +: psdump scnt not if exit then + scnt >A begin dup .x spc> >r scnt not until + begin r> scnt A> = until ; +: .S ( -- ) + S" SP " stype scnt .x1 spc> S" RS " stype rcnt .x1 spc> + S" -- " stype stack? psdump ;