From e89ac58beca3195e0694f2b90518741019a70bbd Mon Sep 17 00:00:00 2001 From: --global <--global> Date: Tue, 18 Feb 2025 21:32:18 +0000 Subject: [PATCH] Target and makefile cleanup --- Makefile | 25 +++++++++++++++++++------ tetros/Cargo.toml | 2 +- tetros/src/{main.rs => lib.rs} | 5 ----- 3 files changed, 20 insertions(+), 12 deletions(-) rename tetros/src/{main.rs => lib.rs} (93%) diff --git a/Makefile b/Makefile index 4a162f2..d0a8377 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/tetros/Cargo.toml b/tetros/Cargo.toml index 5c30c23..6970936 100644 --- a/tetros/Cargo.toml +++ b/tetros/Cargo.toml @@ -6,7 +6,7 @@ publish = false [lib] name = "tetros" -path = "src/main.rs" +path = "src/lib.rs" crate-type = ["staticlib"] diff --git a/tetros/src/main.rs b/tetros/src/lib.rs similarity index 93% rename from tetros/src/main.rs rename to tetros/src/lib.rs index 252d5fd..3793d65 100644 --- a/tetros/src/main.rs +++ b/tetros/src/lib.rs @@ -18,11 +18,6 @@ mod tetrisboard; #[macro_use] mod drivers; -// We don't need `main()` -// It's only here to keep rust-analyzer happy. -#[allow(dead_code)] -fn main() {} - #[global_allocator] static ALLOCATOR: LockedHeap = LockedHeap::empty();