Load kernel from reserved sectors in fatfs

This commit is contained in:
Nero 2020-09-17 05:57:46 +00:00
parent 1ee0637eab
commit 8e87cf0f75
3 changed files with 36 additions and 18 deletions

View file

@ -1,7 +1,5 @@
FLOPPY = 1440
PROGRAMS = hello.com
DISTFILES = $(PROGRAMS) kernel.bs
DISTFILES = $(PROGRAMS)
ROMS =
QEMU_ARCH = $(shell uname -m)
@ -9,7 +7,7 @@ QEMU = qemu-system-$(QEMU_ARCH)
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
NASM = nasm
NASM_ARGS = -s -Ilib -DFLOPPY=$(FLOPPY)
NASM_ARGS = -s -Ilib
EMUL = utils/emul
@ -28,7 +26,7 @@ endif
.PHONY: default bootstrap clean qemu-rom qemu-floppy qemu-pxe
default: fdimage.img
default: fd1440.img
# Host utils
utils/%: %.c
@ -59,14 +57,13 @@ fat6.bs: boot/fat.asm
%.rom: rom/%.asm utils/fix-rom
$(NASM) $(NASM_ARGS) -o $@ $< && utils/fix-rom $@
fdimage.img: fat1.bs $(DISTFILES)
mformat -C -i $@ -f $(FLOPPY) -B fat1.bs ::
mmd -i $@ ::rdos
mcopy -i $@ $(DISTFILES) ::rdos
mattrib -i $@ +s ::rdos ::rdos/kernel.bs
fd%.img: kernel.bs $(DISTFILES)
mformat -C -i $@ -f $* -R 8 -B kernel.bs ::
dd if=kernel.bs conv=notrunc bs=512 skip=1 seek=1 of=$@
mcopy -i $@ $(DISTFILES) ::
hdimage.img: mbr.bs fdimage.img
cat mbr.bs fdimage.img >$@
hdimage.img: mbr.bs fd1440.img
cat mbr.bs fd1440 >$@
part.img: fatc.bs $(DISTFILES)
dd if=/dev/zero bs=1024 count=33k of=$@
@ -82,8 +79,8 @@ clean:
rm -f *.com *.bs *.0 *.lst *.img *.bin *.rom
rm -rf utils
qemu-floppy: fdimage.img $(ROMS)
$(QEMU) $(QEMU_ARGS) -boot a -fda fdimage.img
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