2020-03-01 17:43:23 +01:00
|
|
|
FLOPPY = 360
|
2019-09-04 15:38:32 +02:00
|
|
|
|
2020-03-02 13:10:21 +01:00
|
|
|
PROGRAMS = hello.com
|
2020-03-25 22:19:40 +01:00
|
|
|
DISTFILES = $(PROGRAMS) kernel.bs
|
2020-03-01 17:43:23 +01:00
|
|
|
ROMS =
|
2019-04-21 12:14:06 +02:00
|
|
|
|
2020-03-01 17:43:23 +01:00
|
|
|
QEMU_ARCH = $(shell uname -m)
|
|
|
|
QEMU = qemu-system-$(QEMU_ARCH)
|
|
|
|
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
|
2019-03-24 19:30:49 +01:00
|
|
|
|
2020-03-01 17:43:23 +01:00
|
|
|
NASM = nasm
|
2020-04-04 23:04:36 +02:00
|
|
|
NASM_ARGS = -s -Ilib -DFLOPPY=$(FLOPPY)
|
2020-03-01 13:03:35 +01:00
|
|
|
|
2020-03-01 17:43:23 +01:00
|
|
|
EMUL = utils/emul
|
|
|
|
|
|
|
|
ifdef KVM
|
|
|
|
QEMU_ARGS += --enable-kvm
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef DEBUG
|
2020-04-04 23:04:36 +02:00
|
|
|
ROMS += debug.rom
|
2020-03-01 17:43:23 +01:00
|
|
|
NASM_ARGS += -l $(basename $@).lst
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef DISPLAY
|
|
|
|
QEMU_ARGS += --display curses
|
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: default bootstrap clean qemu-rom qemu-floppy qemu-pxe
|
|
|
|
|
|
|
|
default: fdimage.img
|
|
|
|
|
|
|
|
# Host utils
|
2020-03-01 18:08:25 +01:00
|
|
|
utils/%: %.c
|
2020-03-01 17:43:23 +01:00
|
|
|
mkdir -p utils
|
|
|
|
$(CC) -o $@ $<
|
|
|
|
|
2020-03-01 18:08:25 +01:00
|
|
|
cp437.bin: cp437.bmp utils/bmp2font
|
2020-03-01 17:43:23 +01:00
|
|
|
utils/bmp2font $< $@
|
|
|
|
|
2020-03-01 18:08:25 +01:00
|
|
|
vga11.com: cp437.bin
|
2020-03-01 17:43:23 +01:00
|
|
|
|
|
|
|
# COM programs
|
2020-03-30 14:13:21 +02:00
|
|
|
%.com: com/%.asm
|
2020-03-31 21:46:59 +02:00
|
|
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
2020-03-01 17:43:23 +01:00
|
|
|
|
|
|
|
# Bootloaders, first sector on partition
|
2020-03-30 14:13:21 +02:00
|
|
|
%.bs: boot/%.asm
|
2020-03-31 21:46:59 +02:00
|
|
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
2020-03-01 18:08:25 +01:00
|
|
|
|
2020-04-27 15:56:41 +02:00
|
|
|
kernel.bs: kernel/*.asm
|
|
|
|
|
2020-04-06 21:20:15 +02:00
|
|
|
# Special case: variations of FAT vbr
|
|
|
|
fat1.bs: boot/fat.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -DFAT12 -DCHS -o $@ $<
|
|
|
|
|
|
|
|
fat4.bs: boot/fat.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -DFAT16 -DCHS -o $@ $<
|
|
|
|
|
|
|
|
fat6.bs: boot/fat.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -DFAT16 -DCHS -DLARGE -o $@ $<
|
|
|
|
|
|
|
|
fatb.bs: boot/fat.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -DFAT32 -DCHS -DLARGE -o $@ $<
|
|
|
|
|
|
|
|
fatc.bs: boot/fat.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -DFAT32 -DLBA -DLARGE -o $@ $<
|
|
|
|
|
|
|
|
fate.bs: boot/fat.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -DFAT16 -DLBA -DLARGE -o $@ $<
|
|
|
|
|
2020-03-01 18:08:25 +01:00
|
|
|
# BIOS option roms
|
2020-03-02 13:10:21 +01:00
|
|
|
%.rom: rom/%.asm utils/fix-rom
|
2020-03-31 21:46:59 +02:00
|
|
|
$(NASM) $(NASM_ARGS) -o $@ $< && utils/fix-rom $@
|
2020-03-01 17:43:23 +01:00
|
|
|
|
2020-05-11 22:48:46 +02:00
|
|
|
# rdos drivers
|
|
|
|
%.drv: driver/%.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
|
|
|
|
2020-04-06 21:20:15 +02:00
|
|
|
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
|
2020-03-01 17:43:23 +01:00
|
|
|
|
2020-03-16 18:24:39 +01:00
|
|
|
hdimage.img: mbr.bs fdimage.img
|
|
|
|
cat mbr.bs fdimage.img >$@
|
|
|
|
|
2020-04-06 21:20:15 +02:00
|
|
|
part.img: fatc.bs $(DISTFILES)
|
2020-03-16 18:24:39 +01:00
|
|
|
dd if=/dev/zero bs=1024 count=33k of=$@
|
2020-04-06 21:20:15 +02:00
|
|
|
mformat -i $@ -F -B fatc.bs ::
|
2020-03-25 21:56:00 +01:00
|
|
|
mmd -i $@ ::rdos
|
|
|
|
mcopy -i $@ $(DISTFILES) ::rdos
|
2020-03-30 14:35:59 +02:00
|
|
|
mattrib -i $@ +s ::rdos ::rdos/kernel.bs
|
2019-09-18 00:41:39 +02:00
|
|
|
|
2020-04-21 20:22:32 +02:00
|
|
|
hdd.img: part.img mbr.bs
|
2020-04-22 21:44:43 +02:00
|
|
|
cat mbr.bs part.img > $@
|
2020-04-21 20:22:32 +02:00
|
|
|
|
2019-03-24 19:30:49 +01:00
|
|
|
clean:
|
2020-03-01 17:43:23 +01:00
|
|
|
rm -f *.com *.bs *.0 *.lst *.img *.bin *.rom
|
2020-03-01 18:08:25 +01:00
|
|
|
rm -rf utils
|
2020-03-01 17:43:23 +01:00
|
|
|
|
|
|
|
qemu-floppy: fdimage.img $(ROMS)
|
|
|
|
$(QEMU) $(QEMU_ARGS) -boot a -fda fdimage.img
|
|
|
|
|
2020-04-21 20:22:32 +02:00
|
|
|
qemu-hdd: hdd.img $(ROMS)
|
|
|
|
$(QEMU) $(QEMU_ARGS) -boot c -hda hdd.img
|
2020-03-01 17:43:23 +01:00
|
|
|
|
2020-03-16 18:24:39 +01:00
|
|
|
qemu-pxe: pxeboot.0 $(ROMS)
|
2020-03-01 17:43:23 +01:00
|
|
|
$(QEMU) $(QEMU_ARGS) -boot n \
|
|
|
|
-option-rom /usr/share/qemu/pxe-rtl8139.rom \
|
|
|
|
-device e1000,netdev=mynet0,mac=52:54:00:12:34:56 \
|
2020-03-16 18:24:39 +01:00
|
|
|
-netdev user,id=mynet0,net=192.168.76.0/24,dhcpstart=192.168.76.9,tftp=$(CURDIR),bootfile=pxeboot.0
|