duskos

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

commit ee0beaf1bbed9779c107ea59d4ca605400dd4e56
parent f29541dacb9cc2aec81fd403a66d11c6b835dd1a
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Thu, 21 Jul 2022 15:20:02 -0400

pc: separate bootloader and payload

Diffstat:
Mbuildpc.fs | 4+++-
Mfs/asm/i386.fs | 2+-
Afs/xcomp/pc/boot.fs | 6++++++
Mfs/xcomp/pc/mbr.fs | 11++++++-----
4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/buildpc.fs b/buildpc.fs @@ -1,4 +1,6 @@ : spit ( a u -- ) >r begin c@+ stderr next ; +f<< /asm/i386.fs f<< /xcomp/pc/mbr.fs +f<< /xcomp/pc/boot.fs -ORG $200 spit bye +ORG $400 spit bye diff --git a/fs/asm/i386.fs b/fs/asm/i386.fs @@ -130,7 +130,7 @@ AL _ al BL _ bl CL _ cl DL _ dl AH _ ah BH _ bh CH _ ch DH _ dh \ Inherent : op ( opcode -- ) doer c, does> ( a -- ) c@ c, asm$ ; -$c3 op ret, +$c3 op ret, $fa op cli, $fc op cld, \ Jumps and relative addresses \ i386 jumps and calls in their immediate modes are relative. We keep it that diff --git a/fs/xcomp/pc/boot.fs b/fs/xcomp/pc/boot.fs @@ -0,0 +1,6 @@ +\ This part is called when the bootloader has finished loading the kernel as +\ well as the Forth boot code following it in memory. We're still in real mode, +\ SS is uninitialized. This code lives at $8000 +ax $0e59 i) mov, +$10 int, +0 jmp, \ infinite loop diff --git a/fs/xcomp/pc/mbr.fs b/fs/xcomp/pc/mbr.fs @@ -1,11 +1,12 @@ \ x86 bootloader -?f<< /asm/i386.fs +\ Bootsector is loaded at address $7c00 1 to realmode create ORG here $200 0 fill $26 jmp, \ bypass BPB $23 allot -ax $0e58 i) mov, -$10 int, -0 jmp, \ infinite loop -$55 ORG $1fe + c!+ $aa swap c! +cli, cld, +\ read sector 2 from boot floppy in memory at address $8000 +ax $0201 i) mov, bx $8000 i) mov, cx $0002 i) mov, dx $0000 i) mov, $13 int, +ax $8000 i) mov, ax jmp, +ORG $1fe + to here $55 c, $aa c,