commit 3698e00d5b80a5d07e5d19178c584ee71792f260
parent cf9f756395a197cbe3664ff744c0d186c176e44b
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Mon, 12 Jun 2023 15:07:23 -0400
rpi: we have PROMPT!!!11
Diffstat:
4 files changed, 48 insertions(+), 24 deletions(-)
diff --git a/fs/xcomp/arm/rpi/build.fs b/fs/xcomp/arm/rpi/build.fs
@@ -16,4 +16,8 @@ org value kernel
S" /xcomp/bootlo.fs" V1 spitfile
S" /drv/rpi/uart.fs" V1 spitfile
S" /xcomp/arm/rpi/glue.fs" V1 spitfile
+ S" /lib/struct.fs" V1 spitfile
+ S" /sys/io.fs" V1 spitfile
+ S" /sys/rdln.fs" V1 spitfile
+ S" /xcomp/arm/rpi/init.fs" V1 spitfile
r> IO :flush ;
diff --git a/fs/xcomp/arm/rpi/glue.fs b/fs/xcomp/arm/rpi/glue.fs
@@ -1,23 +1,4 @@
-struct[ Foo
- sfield bar
- sfield baz
-]struct
-
-extends Foo struct[ Bar
- sfield zzz
-]struct
-
-: foo ." foo!" ;
-: bar ." bar!" ;
-: prompt ." Hello World!" ;
-
-create data 'A' , 'X' , 'Z' ,
-
-data structbind Bar mybar
-: hey mybar zzz emit ;
-
+: require word drop ; \ no FS for now
+: ?f<< word drop ;
+alias uart@ key
uart$
-' uart! ' emit realias
-prompt
-' uart@ ' in< realias
-
diff --git a/fs/xcomp/arm/rpi/init.fs b/fs/xcomp/arm/rpi/init.fs
@@ -0,0 +1,28 @@
+: _:emit ( c self -- ) drop uart! ;
+' _:emit ByteWriter :new dup to console writeio to stdio writeio
+
+\ A poor man's lib/fmt
+struct+[ IO
+ create _buf 11 allot
+ create _ ," 0123456789abcdef"
+ : _xh ( n -- c ) $f and _ + c@ ;
+ : _xn ( n digits self -- )
+ >r dup >r for ( n ) \ V1=self V2=digits
+ dup _xh _buf i 1- + c! 4 rshift next drop
+ _buf r> r> :write ;
+ : :.x1 2 swap _xn ;
+ : :.x2 4 swap _xn ;
+ : :.x 8 swap _xn ;
+
+ : _ ( n self -- ) >r 10 /mod ( r q ) ?dup if r@ _ then '0' + r> :putc ;
+ : :. ( n self -- ) >r
+ ?dup not if
+ '0' r> :putc else
+ dup 0< if '-' r@ :putc 0 -^ r> _ else r> _ then
+ then ;
+]struct
+
+: .x stdio :.x ;
+: . stdio :. ;
+
+: init ." Dusk OS\n" rdln$ stdio$ quit ; init
diff --git a/fs/xcomp/arm/rpi/kernel.fs b/fs/xcomp/arm/rpi/kernel.fs
@@ -164,11 +164,22 @@ xcode quit
wcall, [
forward b) ,) to lblmain \ never returns
-xcode abort
+xcode (abort)
( coldboot ) forward!
mov) rPSP rd) PSTOP i) ,)
wjmp, quit
+\ During early boot, it's better to halt the machine than to go back to the
+\ mainloop because the mainloop likely sends us to an infinite error loop
+\ through boot<.
+pc ," boot failure"
+xcode abort
+ ( pc ) r0 pc>reg,
+ r0 ppush,
+ mov) rTOP rd) 12 i) ,)
+ pushret, wcall, rtype popret,
+ 0 b) ,)
+
xcode findmeta ( id ll -- ll-or-0 ) \ preserves r6
r0 ppop,
pc to L2 \ r0=id rTOP=ll
@@ -198,7 +209,7 @@ pc to lblerrmsg \ r0=sa r1=sl
r0 ppush,
mov) rTOP rd) r1 rm) ,)
wcall, rtype
- wjmp, abort
+ wjmp, (abort)
pc to lblbootptr 0 le,
xcode boot<