Target and makefile cleanup

This commit is contained in:
--global
2025-02-18 21:32:18 +00:00
parent e84df2364f
commit e89ac58bec
3 changed files with 20 additions and 12 deletions

View File

@ -52,16 +52,14 @@ $(BUILD)/tetros.elf: $(BUILD)/tetros.lib $(BIOS_LD)
# Wrap tetros in three-stage BIOS loader
# Parameters:
# - BIOS_SRC: source directory of bios assembly
# - STAGE3: path to linked stage 3 binary
# - STAGE2_SECTOR: the index of the first sector of the stage 2 binary on the disk
BIOS_SRC = ./bios
STAGE2_SECTOR = 5
STAGE3 = $(BUILD)/tetros.elf
$(BUILD)/bios.bin: $(wildcard $(BIOS_SRC)/*.asm) $(STAGE3)
STAGE2_SECTOR = 1
$(BUILD)/bios.bin: $(wildcard $(BIOS_SRC)/*.asm) $(BUILD)/tetros.elf
@mkdir -p "$(BUILD)"
nasm \
-f bin \
-D STAGE3=$(STAGE3) \
-D STAGE3=$(BUILD)/tetros.elf \
-D STAGE2_SECTOR=$(STAGE2_SECTOR) \
-o "$@" \
-l "$@.lst" \
@ -92,8 +90,9 @@ $(BUILD)/disk.img: $(BUILD)/mbr.bin $(BUILD)/stage2.bin
@echo ""
dd if=/dev/zero of=$@ bs=512 count=32
dd if="$(BUILD)/mbr.bin" of=$@ conv=notrunc bs=512
dd if="$(BUILD)/stage2.bin" of=$@ conv=notrunc seek=5 bs=512
dd if="$(BUILD)/stage2.bin" of=$@ conv=notrunc seek=$(STAGE2_SECTOR) bs=512
.PHONY: qemu
qemu: $(BUILD)/disk.img
qemu-system-i386 \
-d cpu_reset \
@ -103,6 +102,20 @@ qemu: $(BUILD)/disk.img
-net none \
-serial stdio \
-fda "$<"
# Same as qemu, but with no dependency.
# Used for remote dev, where build box != run box.
.PHONY: qemu-remote
qemu-remote:
qemu-system-i386 \
-d cpu_reset \
-no-reboot \
-smp 1 -m 2048 \
-machine q35 \
-net none \
-serial stdio \
-fda "$(BUILD)/disk.img"
# -gdb tcp::26000 \
# -S
# -enable-kvm \