duskos

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

commit f67f057eeea25606bccba15e9caf211dcf6e4a6c
parent 698fdbf723d1fc24a13e68f59b76f781653a269f
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sat, 30 Jul 2022 14:09:48 -0400

Make "abort" at boot time halt the machine

Previously, it would call (abort), which would simply reset PS and RS and jump
back to the mainloop, which would continue reading boot<, leading to infinite
breakage, making it hard to read the error message that was the origin of the
boot-time problem.

Now, we spit "boot failure" and halt.

Diffstat:
Mfs/xcomp/i386.fs | 34++++++++++++++++++++++++----------
Mfs/xcomp/init.fs | 3+++
Mfs/xcomp/pc/kernel.fs | 2++
3 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/fs/xcomp/i386.fs b/fs/xcomp/i386.fs @@ -1,10 +1,11 @@ -\ This is (well, will be) the i386 Dusk kernel. It is called when the bootloader -\ has finished loading this binary as well as the Forth boot code following it -\ in memory. We're in protected mode and all segments have been initialized. -\ ESP and EBP are uninitialized. +\ This is the i386 Dusk kernel. It is called when the bootloader has finished +\ loading this binary as well as the Forth boot code following it in memory. +\ We're in protected mode and all segments have been initialized. ESP and EBP +\ are uninitialized. ?f<< /asm/i386.fs ?f<< /xcomp/tools.fs +\ Macros : [ebp] bp 0 d) ; : [ebp]z? [ebp] -1 i) test, ; : [esi] si 0 d) ; @@ -17,6 +18,7 @@ : pspop2, ( r1 r2 -- ) r! bp CELLSZ d) mov, r! [ebp] mov, bp CELLSZ << i) add, ; : wcall, xwordlbl abs>rel call, ; +\ Constants and labels 0 to realmode : values ( n -- ) >r begin 0 value next ; 22 values L1 L2 lblmainalias lbltoptr lbltoexec lblbootptr lblin< lblcurword @@ -27,6 +29,8 @@ $80000 const HEREMAX $8000 to binstart \ This code lives at $8000. $6000 const RSTOP $7c00 const PSTOP + +\ Let's go! align4 here to org forward16 jmp, to L1 @@ -136,9 +140,6 @@ xcode (abort) bp PSTOP i) mov, xwordlbl quit abs>rel jmp, -xcode abort - wcall, (alias) xwordlbl (abort) , - xcode exit ax pop, ret, @@ -491,9 +492,6 @@ xcode r>A xcode emit wcall, (alias) xwordlbl drop , -xcode key - wcall, (alias) xwordlbl abort , - xcode rtype ( a u -- ) CX SI pspop2, pc to lblrtype @@ -508,6 +506,22 @@ pc to lblrtype lblrtype abs>rel jnz, ret, +\ 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" +pc + cx 12 i) mov, + si swap ( msg ) i) mov, + lblrtype abs>rel call, + 0 jmp, + +xcode abort + wcall, (alias) ( pc ) , + +xcode key + wcall, (alias) xwordlbl abort , + align4 pc to lblbootptr 0 , xcode boot< si lblbootptr m) mov, diff --git a/fs/xcomp/init.fs b/fs/xcomp/init.fs @@ -5,6 +5,9 @@ f<< lib/nfmt.fs f<< lib/diag.fs f<< sys/xhere.fs f<< sys/rdln.fs +\ TODO: redesign chaining so that this alias rebind below can happen during +\ rdln$ without breaking the chaining done in btrace. +' (abort) to abort f<< lib/btrace.fs : init S" Dusk OS" stype nl> .free rdln$ ( unwind the boot RS ) quit ; init diff --git a/fs/xcomp/pc/kernel.fs b/fs/xcomp/pc/kernel.fs @@ -26,3 +26,5 @@ xcode int13h ( drv head cyl sec dst -- ) pc lblcurrent pc>addr ! AX pspop, dh al mov, \ head AX pspop, dl al mov, \ drive $18 L1 jmpfar, + +pc lblbootptr pc>addr !