Fix hdd booting using bpb struc
This commit is contained in:
parent
1d64c2364d
commit
8ed9fe7465
19
Makefile
19
Makefile
@ -6,6 +6,7 @@ QEMU = qemu-system-i386
|
|||||||
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
|
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
|
||||||
|
|
||||||
VERSION = $(shell git log -1 --format=%cd --date=format:%Y%m%d)
|
VERSION = $(shell git log -1 --format=%cd --date=format:%Y%m%d)
|
||||||
|
LABEL = RDOS $(VERSION)
|
||||||
|
|
||||||
NASM = nasm
|
NASM = nasm
|
||||||
NASM_ARGS = -s -Ilib -DVERSION=$(VERSION)
|
NASM_ARGS = -s -Ilib -DVERSION=$(VERSION)
|
||||||
@ -59,22 +60,12 @@ fat6.bs: boot/fat.asm
|
|||||||
$(NASM) $(NASM_ARGS) -o $@ $< && utils/fix-rom $@
|
$(NASM) $(NASM_ARGS) -o $@ $< && utils/fix-rom $@
|
||||||
|
|
||||||
fd%.img: kernel.bs $(DISTFILES)
|
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=$@
|
dd if=kernel.bs conv=notrunc bs=512 skip=1 seek=1 of=$@
|
||||||
mcopy -i $@ $(DISTFILES) ::
|
mcopy -i $@ $(DISTFILES) ::
|
||||||
|
|
||||||
hdimage.img: mbr.bs fd1440.img
|
hdimage.img: mbr.bs fd1440.img
|
||||||
cat mbr.bs fd1440 >$@
|
cat mbr.bs fd1440.img >$@
|
||||||
|
|
||||||
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 > $@
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.com *.bs *.0 *.lst *.img *.bin *.rom
|
rm -f *.com *.bs *.0 *.lst *.img *.bin *.rom
|
||||||
@ -83,8 +74,8 @@ clean:
|
|||||||
qemu-floppy: fd1440.img $(ROMS)
|
qemu-floppy: fd1440.img $(ROMS)
|
||||||
$(QEMU) $(QEMU_ARGS) -boot a -fda fd1440.img
|
$(QEMU) $(QEMU_ARGS) -boot a -fda fd1440.img
|
||||||
|
|
||||||
qemu-hdd: hdd.img $(ROMS)
|
qemu-hdd: hdimage.img $(ROMS)
|
||||||
$(QEMU) $(QEMU_ARGS) -boot c -hda hdd.img
|
$(QEMU) $(QEMU_ARGS) -boot c -hda hdimage.img
|
||||||
|
|
||||||
qemu-pxe: pxeboot.0 $(ROMS)
|
qemu-pxe: pxeboot.0 $(ROMS)
|
||||||
$(QEMU) $(QEMU_ARGS) -boot n \
|
$(QEMU) $(QEMU_ARGS) -boot n \
|
||||||
|
12
boot/mbr.asm
12
boot/mbr.asm
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
%include "inc/bpb.asm"
|
%include "inc/bpb.asm"
|
||||||
|
|
||||||
%define bpb bs+0x0B
|
%define params bs+0x0B
|
||||||
|
|
||||||
cpu 8086
|
cpu 8086
|
||||||
org 0x0600
|
org 0x0600
|
||||||
@ -72,11 +72,11 @@ main: ; find active partition
|
|||||||
|
|
||||||
; FAT bpb has "bytes per sector" at this place
|
; FAT bpb has "bytes per sector" at this place
|
||||||
; we support only 512 byte sectors anyways
|
; we support only 512 byte sectors anyways
|
||||||
cmp word [bpb+bpb_ss], 512
|
cmp word [params+bpb.sectorsize], 512
|
||||||
jne chain
|
jne chain
|
||||||
|
|
||||||
; Media descriptor byte is never smaller than 0xF0
|
; Media descriptor byte is never smaller than 0xF0
|
||||||
cmp byte [bpb+bpb_md], 0xF0
|
cmp byte [params+bpb.mediadesc], 0xF0
|
||||||
jc chain
|
jc chain
|
||||||
|
|
||||||
; ask BIOS what our disk geometry is
|
; ask BIOS what our disk geometry is
|
||||||
@ -92,17 +92,17 @@ main: ; find active partition
|
|||||||
; update sectors per track
|
; update sectors per track
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
mov al, cl
|
mov al, cl
|
||||||
mov [bpb+bpb_spt], ax
|
mov [params+bpb.tracksectors], ax
|
||||||
|
|
||||||
; update number of sides
|
; update number of sides
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
mov al, dh
|
mov al, dh
|
||||||
mov [bpb+bpb_nos], ax
|
mov [params+bpb.heads], ax
|
||||||
|
|
||||||
; update partition offset
|
; update partition offset
|
||||||
push si
|
push si
|
||||||
add si, 0x08
|
add si, 0x08
|
||||||
mov di, bpb+bpb_po
|
mov di, params+bpb.sectoroffset
|
||||||
movsw
|
movsw
|
||||||
movsw
|
movsw
|
||||||
pop si
|
pop si
|
||||||
|
Loading…
Reference in New Issue
Block a user