summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile66
1 files changed, 30 insertions, 36 deletions
diff --git a/Makefile b/Makefile
index 4c57ac2..6f7f545 100644
--- a/Makefile
+++ b/Makefile
@@ -10,15 +10,14 @@ export INITRD=$(ESP_DIR)/initramfs.cpio.gz
10export BOOTLOADER=rsboot/rsboot.efi 10export BOOTLOADER=rsboot/rsboot.efi
11export OVMF=/usr/share/edk2/x64/OVMF.4m.fd 11export OVMF=/usr/share/edk2/x64/OVMF.4m.fd
12export BOOT_EFI=$(ESP_DIR)/EFI/BOOT/BOOTX64.EFI 12export BOOT_EFI=$(ESP_DIR)/EFI/BOOT/BOOTX64.EFI
13# Attach a raw disk image as the SATA drive (disk.img -> ide.0, ESP -> ide.1). 13# Attach the single dd-able system image as the SATA drive (ide.0).
14# Create one with: make disk (or: ./scripts/mkdisk.sh) 14# Create/re-create with: make system-fresh (or: ./scripts/mksystem.sh --force)
15export DISK_IMG ?= /tmp/disk.img 15export SYSTEM_IMG ?= /tmp/system.img
16 16
17.PHONY: all run run-gui clean image debug release fmt bootloader boot-image disk disk-fresh inspect test-disk test-mouse test-gfx test-fault test-msg
18 17
19# ---- Build --------------------------------------------------------------- 18# ---- Build ---------------------------------------------------------------
20 19
21all: $(BZIMAGE) $(INITRD) 20.PHONY: all run run-gui clean image debug release fmt bootloader boot-image system system-fresh inspect test-disk test-mouse test-gfx test-fault test-msg
22 21
23release: PROFILE=release 22release: PROFILE=release
24release: export PROFILE=release 23release: export PROFILE=release
@@ -43,13 +42,11 @@ $(INITRD): | $(ESP_DIR)
43 42
44# ---- QEMU runners -------------------------------------------------------- 43# ---- QEMU runners --------------------------------------------------------
45 44
46run: all disk 45run: all system
47 qemu-system-x86_64 \ 46 qemu-system-x86_64 \
48 -bios $(OVMF) \ 47 -bios $(OVMF) \
49 -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ 48 -drive file=$(SYSTEM_IMG),format=raw,if=none,id=disk \
50 -device ide-hd,drive=disk,bus=ide.0 \ 49 -device ide-hd,drive=disk,bus=ide.0 \
51 -drive file=fat:rw:$(ESP_DIR),format=raw,if=none,id=esp \
52 -device ide-hd,drive=esp,bus=ide.1 \
53 -serial stdio \ 50 -serial stdio \
54 -m 256M \ 51 -m 256M \
55 -machine q35 \ 52 -machine q35 \
@@ -57,13 +54,11 @@ run: all disk
57 -no-reboot \ 54 -no-reboot \
58 -display none 55 -display none
59 56
60run-gui: all disk 57run-gui: all system
61 qemu-system-x86_64 \ 58 qemu-system-x86_64 \
62 -bios $(OVMF) \ 59 -bios $(OVMF) \
63 -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ 60 -drive file=$(SYSTEM_IMG),format=raw,if=none,id=disk \
64 -device ide-hd,drive=disk,bus=ide.0 \ 61 -device ide-hd,drive=disk,bus=ide.0 \
65 -drive file=fat:rw:$(ESP_DIR),format=raw,if=none,id=esp \
66 -device ide-hd,drive=esp,bus=ide.1 \
67 -serial stdio \ 62 -serial stdio \
68 -m 256M \ 63 -m 256M \
69 -machine q35 \ 64 -machine q35 \
@@ -72,13 +67,11 @@ run-gui: all disk
72 -vga std 67 -vga std
73 68
74# GDB stub on :1234 69# GDB stub on :1234
75debug: all disk 70debug: all system
76 qemu-system-x86_64 \ 71 qemu-system-x86_64 \
77 -bios $(OVMF) \ 72 -bios $(OVMF) \
78 -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ 73 -drive file=$(SYSTEM_IMG),format=raw,if=none,id=disk \
79 -device ide-hd,drive=disk,bus=ide.0 \ 74 -device ide-hd,drive=disk,bus=ide.0 \
80 -drive file=fat:rw:$(ESP_DIR),format=raw,if=none,id=esp \
81 -device ide-hd,drive=esp,bus=ide.1 \
82 -serial stdio \ 75 -serial stdio \
83 -m 256M \ 76 -m 256M \
84 -machine q35 \ 77 -machine q35 \
@@ -90,23 +83,27 @@ debug: all disk
90# Boot from a raw disk image (delegates to boot-image.sh which builds the 83# Boot from a raw disk image (delegates to boot-image.sh which builds the
91# full chain if the image doesn't exist yet) 84# full chain if the image doesn't exist yet)
92run-image: all 85run-image: all
93 ./scripts/boot-image.sh rs-dos.img
94 86
95# ---- Data disk ----------------------------------------------------------- 87# ---- System image --------------------------------------------------------
96 88
97# Create the FAT32 data disk if it doesn't exist. Uses mkfs.fat -C (the 89# One dd-able FAT32 image: kernel + ESP + /etc + /bin + seed data.
98# flag that actually creates the file) and seeds it from seed/. 90# Stamp rule: rebuilt only when the kernel or this script changes — an
99disk: 91# up-to-date image is NEVER touched, so files written at runtime survive.
100 ./scripts/mkdisk.sh "$(DISK_IMG)" 92system:
93 @if [ ! -f "$(SYSTEM_IMG)" ] || [ "$$(stat -c %Y $(BZIMAGE) 2>/dev/null || echo 0)" -gt "$$(stat -c %Y $(SYSTEM_IMG) 2>/dev/null || echo 0)" ]; then \
94 ./scripts/mksystem.sh --force "$(SYSTEM_IMG)"; \
95 else \
96 echo "system image up to date: $(SYSTEM_IMG)"; \
97 fi
101 98
102# Re-format the data disk from scratch (wipes it, then re-seeds). 99# Re-create the system image from scratch (wipes runtime data).
103disk-fresh: 100system-fresh:
104 ./scripts/mkdisk.sh --fresh "$(DISK_IMG)" 101 ./scripts/mksystem.sh --force "$(SYSTEM_IMG)"
105 102
106# List the data disk contents with mtools (requires mtools). 103# List the system image contents with mtools (requires mtools).
107inspect: 104inspect:
108 @command -v mdir >/dev/null 2>&1 || (echo "inspect needs mtools: sudo apt install mtools"; exit 1) 105 @command -v mdir >/dev/null 2>&1 || (echo "inspect needs mtools: sudo apt install mtools"; exit 1)
109 @mdir -i "$(DISK_IMG)" 106 @mdir -i "$(SYSTEM_IMG)" ::
110 107
111# Full automated round trip: build -> boot -> shell commands -> poweroff 108# Full automated round trip: build -> boot -> shell commands -> poweroff
112# -> fsck + mtools verification. 109# -> fsck + mtools verification.
@@ -152,7 +149,7 @@ fmt:
152 149
153clean: 150clean:
154 cargo clean 151 cargo clean
155 rm -rf $(ESP_DIR) rs-dos.img 152 rm -rf $(ESP_DIR)
156 153
157help: 154help:
158 @echo "rs-dos — Make targets" 155 @echo "rs-dos — Make targets"
@@ -163,16 +160,13 @@ help:
163 @echo " make image build full chain disk image (bootloader + kernel)" 160 @echo " make image build full chain disk image (bootloader + kernel)"
164 @echo " make boot-image build + boot full chain via QEMU" 161 @echo " make boot-image build + boot full chain via QEMU"
165 @echo " make run QEMU serial console (direct boot, no bootloader)" 162 @echo " make run QEMU serial console (direct boot, no bootloader)"
166 @echo " make run-gui QEMU with graphical window (GOP/PS2)" 163 @echo " make system create the system image if stale/missing (/tmp/system.img)"
167 @echo " make debug QEMU + GDB stub on :1234" 164 @echo " make system-fresh re-create the system image (wipes runtime data)"
168 @echo " make disk create the data disk if missing (default /tmp/disk.img)" 165 @echo " make inspect list system image contents (mtools)"
169 @echo " make disk-fresh re-format the data disk (wipes it)"
170 @echo " make inspect list data disk contents (mtools)"
171 @echo " make test-disk automated disk round trip (build->boot->fsck)" 166 @echo " make test-disk automated disk round trip (build->boot->fsck)"
172 @echo " make clean remove build artifacts" 167 @echo " make clean remove build artifacts"
173 @echo " make fmt format Rust source" 168 @echo " make fmt format Rust source"
174 @echo "" 169 @echo " ./scripts/mksystem.sh build the dd-able system image"
175 @echo "Scripts:"
176 @echo " ./scripts/boot.sh quick direct boot (dev loop)" 170 @echo " ./scripts/boot.sh quick direct boot (dev loop)"
177 @echo " ./scripts/mkdisk.sh create/re-format the data disk" 171 @echo " ./scripts/mkdisk.sh create/re-format the data disk"
178 @echo " ./scripts/test-disk.sh automated disk round trip" 172 @echo " ./scripts/test-disk.sh automated disk round trip"