duskos

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

commit 4b65df05e17e1cce8d70a96e272fce9094989754
parent 8508adafee4c3aa2bff622b58d3d7a7ebda4acde
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sat,  5 Nov 2022 17:30:22 -0400

i386: add BIOS poking tool

I'm trying to get Dusk to run on a old Pentium 75Mhz laptop and it's not quite
the SeaBIOS we have in QEMU...

Diffstat:
MMakefile | 4++++
Abuildpcdbg.fs | 4++++
Afs/xcomp/i386/pc/bootdbg.fs | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 88 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -21,6 +21,10 @@ pc.img: dusk $(ALLSRCS) dd if=/dev/zero of=$@ bs=512 count=2880 ./dusk < buildpc.fs +pcdbg.img: dusk $(ALLSRCS) + cp README.md $@ # we want to have some dummy contents to read during diag + ./dusk < buildpcdbg.fs + .PHONY: pcrun pcrun: pc.img qemu-system-i386 $(QEMU_FLAGS) -drive file=pc.img,$(QEMU_DRVOPTS) diff --git a/buildpcdbg.fs b/buildpcdbg.fs @@ -0,0 +1,4 @@ +f<< /xcomp/i386/pc/bootdbg.fs + +S" pcdbg.img" mountImage ( drv ) 0 org rot Drive :sec! +bye diff --git a/fs/xcomp/i386/pc/bootdbg.fs b/fs/xcomp/i386/pc/bootdbg.fs @@ -0,0 +1,80 @@ +\ Tools to debug a PC at boot time. +\ This boot from the MBR and pokes around. +?f<< /asm/i386.fs +1 to realmode + +$7c00 to binstart +0 value lblstart +0 value lblmsg +0 value lblprinthex +0 value lblstop +0 value lblloop + +here to org $aa55 here $1fe + w! +forward8 jmp, to lblstart +pc \ list of messages, 4 chars each +," DL StopGeo SectErr " + +pc to lblmsg \ si=idx + si 2 i) shl, ( x4 ) si ( pc ) i) add, cl 4 i) mov, + ah $0e i) mov, bx $0007 i) mov, + pc al si 0 d) mov, $10 int, si inc, cl dec, ( pc ) abs>rel jnz, ret, + +pc to lblprinthex \ al=num + ah $0e i) mov, bx $0007 i) mov, + ax push, al 4 i) shr, + al '0' i) add, al ':' i) cmp, forward8 jc, al 7 i) add, forward! $10 int, + ax pop, al $0f i) and, + al '0' i) add, al ':' i) cmp, forward8 jc, al 7 i) add, forward! $10 int, + ret, + +pc to lblstop si 1 i) mov, lblmsg abs>rel call, 0 jmp, +lblstart forward! +cli, cld, ax ax xor, es ax mov, ds ax mov, ss ax mov, sp $7c00 i) mov, sti, +ax $0003 i) mov, $10 int, \ video mode 80x25 +si 0 i) mov, lblmsg abs>rel call, +al dl mov, lblprinthex abs>rel call, + +\ If you want a hardcoded drive parameters, uncomment code below +\ dl $80 i) mov, + +si 2 i) mov, lblmsg abs>rel call, +dx push, ah 8 i) mov, $13 int, \ dh=numheads-1 cl&3f=sec per trk +al dh mov, lblprinthex abs>rel call, +al cl mov, lblprinthex abs>rel call, +dx pop, +\ Enough for the generic info. Now, what we'll do is read sectors into $8000, +\ one sector at a time, and print the first 8 bytes of it. Then, we wait for a +\ a key press and try to read the next sector,and again, and again. +\ When we encounter an error, we reset the sector, inc the head, try again. If +\ we have another error, we reset the head, inc the cylinder, try again. If we +\ have an error, we stop. + +\ We begin at cylinder 0, head 0, sector 1 +cx $0001 i) mov, \ ch=cyl cl=sec +dh dh xor, \ dh=head +pc to lblloop + cx push, si 3 i) mov, lblmsg abs>rel call, cx pop, + al ch mov, lblprinthex abs>rel call, + al cl mov, lblprinthex abs>rel call, + al dh mov, lblprinthex abs>rel call, + al dl mov, lblprinthex abs>rel call, + bx $8000 i) mov, + ax $0201 i) mov, \ ah=read cmd al=read 1 sector + $13 int, forward8 jnc, + \ error + cx push, si 4 i) mov, lblmsg abs>rel call, cx pop, + cl 1 i) cmp, forward8 jz, + \ cl != 1, we need to reset cl and inc head + cl 1 i) mov, dh inc, lblloop abs>rel jmp, + forward! + \ cl=1, we need to reset head and inc cylinder + dh dh or, lblstop abs>rel jz, \ dh=0? we have a terminating error! + dh dh xor, ch inc, lblloop abs>rel jmp, + forward! + \ no error, inc sector and print + cl inc, + di 8 i) mov, si $8000 i) mov, + pc al si 0 d) mov, lblprinthex abs>rel call, si inc, di dec, abs>rel jnz, + ah ah xor, $16 int, \ read key press +lblloop abs>rel jmp,