duskos

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

commit 69cb48176197ce11278b5ea241c18a9b662bfb3e
parent 3373039e13f2ed5ef0aa296c9a51866e66d26f43
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sat, 18 Mar 2023 09:36:26 -0400

hal i386: we have prompt!!!

Now, i386 DuskCC...

Diffstat:
Mfs/drv/pc/a20.fs | 4++--
Mfs/drv/pc/ata.fs | 16++++++++--------
Mfs/drv/pc/cmos.fs | 4+---
Mfs/drv/pc/ps28042.fs | 13+++++++------
Mfs/xcomp/bootlo.fs | 6+++---
Mfs/xcomp/i386/kernel.fs | 10+++-------
Mfs/xcomp/i386/pc/build.fs | 2+-
Mfs/xcomp/i386/pc/glue.fs | 1-
Mfs/xcomp/i386/pc/kernel.fs | 10+++++-----
9 files changed, 30 insertions(+), 36 deletions(-)

diff --git a/fs/drv/pc/a20.fs b/fs/drv/pc/a20.fs @@ -8,7 +8,7 @@ code _wait pc al $64 i) in, al 2 i) test, abs>rel jnz, ret, code _wait2 pc al $64 i) in, al 1 i) test, abs>rel jz, ret, : _cmd ( n -- ) ['] _wait abs>rel call, al swap i) mov, al $64 i) out, ; code _unlockThroughPS2 - cli, $ad _cmd $d0 _cmd + ax push, cli, $ad _cmd $d0 _cmd ' _wait2 abs>rel call, al $60 i) in, ax push, $d1 _cmd @@ -16,7 +16,7 @@ code _unlockThroughPS2 ax pop, al 2 i) or, al $60 i) out, $ae _cmd ' _wait abs>rel call, - sti, ret, + sti, ax pop, ret, 32 $400 $400 * * const MEMTOP \ 32 MB ought to be enough for anybody diff --git a/fs/drv/pc/ata.fs b/fs/drv/pc/ata.fs @@ -46,24 +46,24 @@ extends Drive struct[ ATADrive 16 rshift r> _cylhi pc! ; code _ ( dst port -- ) - dx bp 0 d) mov, di bp 4 d) mov, bp CELLSZ << i) add, + dx ax mov, bx si 0 d) mov, cx $100 i) mov, pc ax 16b) dx in, - di 0 d) 16b) ax mov, - di inc, di inc, cx dec, - ( pc ) abs>rel jnz, ret, + bx 0 d) 16b) ax mov, + bx inc, bx inc, cx dec, + ( pc ) abs>rel jnz, nip, drop, ret, : ata@ ( sec dst drv -- ) >r swap r@ _locate $20 ( read sectors ) r@ _cmd pc! r@ _wait ( dst ) r> _data _ ; code _ ( src port -- ) - dx bp 0 d) mov, di bp 4 d) mov, bp CELLSZ << i) add, + dx ax mov, bx si 0 d) mov, cx $100 i) mov, pc - ax 16b) di 0 d) mov, + ax 16b) bx 0 d) mov, ax 16b) dx out, - di inc, di inc, cx dec, - ( pc ) abs>rel jnz, ret, + bx inc, bx inc, cx dec, + ( pc ) abs>rel jnz, nip, drop, ret, : ata! ( sec src drv -- ) >r swap r@ _locate $30 ( write sectors ) r@ _cmd pc! diff --git a/fs/drv/pc/cmos.fs b/fs/drv/pc/cmos.fs @@ -4,9 +4,7 @@ ?f<< /comp/c/cc.fs code cmos@ ( regnum -- val ) - al bp 0 d) mov, cli, - al $70 i) out, al $71 i) in, - sti, bp 0 d) al mov, ret, + cli, al $70 i) out, al $71 i) in, sti, ret, : cmos_read cmos@ ; :c int cmos_read(int reg) ; diff --git a/fs/drv/pc/ps28042.fs b/fs/drv/pc/ps28042.fs @@ -128,18 +128,19 @@ code isrIRQc extends Mouse struct[ PS2Mouse code 8042mouse@ ( -- dx dy btnflags ) - dx dx xor, cli, + ax push, dx dx xor, cli, ax _dx m) mov, _dx m) dx mov, bx _dy m) mov, _dy m) dx mov, \ We keep "pressed" info around to be able to detect "click" events cx _btnflags m) mov, _btnflags m) $ff i) and, sti, \ The PS/2 mouse give a positive dy when going up. We want the opposite. - bx neg, - bp CELLSZ 3 * i) sub, - bp 8 d) ax mov, - bp 4 d) bx mov, - bp 0 d) cx mov, + bx neg, dx pop, + si CELLSZ 3 * i) sub, + si 8 d) dx mov, + si 4 d) ax mov, + si 0 d) bx mov, + ax cx mov, ret, : :new ( -- self ) :newbase ['] 8042mouse@ , ; diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs @@ -6,14 +6,14 @@ code dup dup, exit, code swap PSP) @!, exit, code << 1 <<n, exit, code >> 1 >>n, exit, -: drop, PSP) @, 4 ps+, ; +: nip, 4 ps+, ; +code nip nip, exit, +: drop, PSP) @, nip, ; code drop drop, exit, : 2drop, PSP) 4 +) @, 8 ps+, ; code 2drop 2drop, exit, code rot PSP) @!, PSP) 4 +) @!, exit, code rot> PSP) 4 +) @!, PSP) @!, exit, -: nip, 4 ps+, ; -code nip nip, exit, : over, dup, PSP) 4 +) @, ; code over over, exit, code tuck W>A, PSP) @, dup, W<>A, PSP) 4 +) !, exit, diff --git a/fs/xcomp/i386/kernel.fs b/fs/xcomp/i386/kernel.fs @@ -82,10 +82,6 @@ pc to lblcompiling 0 , xcode compiling xdup, ax lblcompiling m) mov, ret, -xcode bye \ temporary word - dx 42 i) mov, - 0 jmp, - xcode quit cld, lblmod m) 0 i) mov, @@ -400,7 +396,7 @@ xcode pc@ ( port -- n8 ) xcode pc! ( n8 port -- ) dx ax mov, xdrop, - al dx out, + al dx out, xdrop, ret, xcode pw@ ( port -- n16 ) @@ -411,7 +407,7 @@ xcode pw@ ( port -- n16 ) xcode pw! ( n16 port -- ) dx ax mov, xdrop, - ax 16b) dx out, + ax 16b) dx out, xdrop, ret, xcode p@ ( port -- n32 ) @@ -422,7 +418,7 @@ xcode p@ ( port -- n32 ) xcode p! ( n32 port -- ) dx ax mov, xdrop, - ax dx out, + ax dx out, xdrop, ret, \ Interpret loop diff --git a/fs/xcomp/i386/pc/build.fs b/fs/xcomp/i386/pc/build.fs @@ -34,7 +34,7 @@ org value kernel : setupFAT ( drv clustercnt -- fat ) ." creating FAT and copying files\n" - createFAT ( bootfs over copyfs ) ; + createFAT bootfs over copyfs ; : spitfile ( fpath dst -- ) >r curpath :find# Path :open begin ( fc ) diff --git a/fs/xcomp/i386/pc/glue.fs b/fs/xcomp/i386/pc/glue.fs @@ -1,5 +1,4 @@ \ Glue code that goes between the filesystem part and boothi -$2345 bye INT13hDrive FAT :mountvolume ( fs ) to bootfs 0 S" drv" bootfs Filesystem :child S" pc" bootfs Filesystem :child S" int13h.fs" bootfs Filesystem :child floaded, diff --git a/fs/xcomp/i386/pc/kernel.fs b/fs/xcomp/i386/pc/kernel.fs @@ -5,7 +5,7 @@ pc to L1 \ back to protected mode! ax $10 i) mov, ds ax mov, ss ax mov, es ax mov, gs ax mov, fs ax mov, lblidt m) lidt, sti, - ret, + xdrop, ( final xdrop ) ret, pc to L2 $3ff w, 0 , \ real mode IVT @@ -27,7 +27,7 @@ xcode int13h ( drv head cyl sec dst -- ) cl al mov, xdrop, \ sec ch al mov, xdrop, \ cyl dh al mov, xdrop, \ head - dl al mov, xdrop, \ drive + dl al mov, \ drive, the final xdrop, happens after INT13h cli, $18 L4 jmpfar, pc to L1 \ back to protected mode! @@ -36,8 +36,8 @@ pc to L1 \ back to protected mode! cx ax mov, ax pop, al $a1 i) out, al ah mov, al $21 i) out, ax cx mov, - \ we still need to push bx and ax - xgrow, si 0 d) bx mov, ( -- bx ax ) + \ we still need to push bx and ax, PS slot is already reserved + si 0 d) bx mov, ( -- bx ax ) lblidt m) lidt, sti, ret, @@ -63,7 +63,7 @@ xcode int10h ( cx/dx bx ax -- bx ax ) al $ff i) mov, al $21 i) out, al $a1 i) out, ax cx mov, bx si 0 d) mov, xnip, - cx si 0 d) mov, xnip, + cx si 0 d) mov, \ keep this PS slot reserved cli, $18 L4 jmpfar, \ To avoid lockups, we map all PIC IRQs on boot to words that acknowledge those