Fix hdd booting using bpb struc

This commit is contained in:
Nero 2020-09-19 08:22:50 +00:00
parent 1d64c2364d
commit 8ed9fe7465
2 changed files with 11 additions and 20 deletions

View File

@ -6,6 +6,7 @@ QEMU = qemu-system-i386
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
VERSION = $(shell git log -1 --format=%cd --date=format:%Y%m%d)
LABEL = RDOS $(VERSION)
NASM = nasm
NASM_ARGS = -s -Ilib -DVERSION=$(VERSION)
@ -59,22 +60,12 @@ fat6.bs: boot/fat.asm
$(NASM) $(NASM_ARGS) -o $@ $< && utils/fix-rom $@
fd%.img: kernel.bs $(DISTFILES)
mformat -C -i $@ -f $* -R 8 -B kernel.bs ::
mformat -C -i $@ -f $* -R 8 -v "$(LABEL)" -B kernel.bs ::
dd if=kernel.bs conv=notrunc bs=512 skip=1 seek=1 of=$@
mcopy -i $@ $(DISTFILES) ::
hdimage.img: mbr.bs fd1440.img
cat mbr.bs fd1440 >$@
part.img: fatc.bs $(DISTFILES)
dd if=/dev/zero bs=1024 count=33k of=$@
mformat -i $@ -F -B fatc.bs ::
mmd -i $@ ::rdos
mcopy -i $@ $(DISTFILES) ::rdos
mattrib -i $@ +s ::rdos ::rdos/kernel.bs
hdd.img: part.img mbr.bs
cat mbr.bs part.img > $@
cat mbr.bs fd1440.img >$@
clean:
rm -f *.com *.bs *.0 *.lst *.img *.bin *.rom
@ -83,8 +74,8 @@ clean:
qemu-floppy: fd1440.img $(ROMS)
$(QEMU) $(QEMU_ARGS) -boot a -fda fd1440.img
qemu-hdd: hdd.img $(ROMS)
$(QEMU) $(QEMU_ARGS) -boot c -hda hdd.img
qemu-hdd: hdimage.img $(ROMS)
$(QEMU) $(QEMU_ARGS) -boot c -hda hdimage.img
qemu-pxe: pxeboot.0 $(ROMS)
$(QEMU) $(QEMU_ARGS) -boot n \

View File

@ -10,7 +10,7 @@
%include "inc/bpb.asm"
%define bpb bs+0x0B
%define params bs+0x0B
cpu 8086
org 0x0600
@ -72,11 +72,11 @@ main: ; find active partition
; FAT bpb has "bytes per sector" at this place
; we support only 512 byte sectors anyways
cmp word [bpb+bpb_ss], 512
cmp word [params+bpb.sectorsize], 512
jne chain
; Media descriptor byte is never smaller than 0xF0
cmp byte [bpb+bpb_md], 0xF0
cmp byte [params+bpb.mediadesc], 0xF0
jc chain
; ask BIOS what our disk geometry is
@ -92,17 +92,17 @@ main: ; find active partition
; update sectors per track
xor ax, ax
mov al, cl
mov [bpb+bpb_spt], ax
mov [params+bpb.tracksectors], ax
; update number of sides
xor ax, ax
mov al, dh
mov [bpb+bpb_nos], ax
mov [params+bpb.heads], ax
; update partition offset
push si
add si, 0x08
mov di, bpb+bpb_po
mov di, params+bpb.sectoroffset
movsw
movsw
pop si