summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-07-31 02:18:30 +0200
committersalmonik <salmonik@tuta.io>2026-07-31 02:18:30 +0200
commit76103215711d268b4b02f62e900f2be3032cf295 (patch)
treedcd86b5b02ae99c99ca833668055f4f53211be6b /Makefile
downloadrs-dos-76103215711d268b4b02f62e900f2be3032cf295.tar.gz
rs-dos-76103215711d268b4b02f62e900f2be3032cf295.zip
Initial commit: raisernics toy kernel
- Bare-metal x86_64 UEFI kernel (PE32+, no libc) - GOP framebuffer + 8x16 bitmap font - PS/2 keyboard (polling, scancode set 1) - UART 16550 serial driver (COM1, 115200 8N1) - Bump allocator as #[global_allocator] (alloc::String, Vec, format!) - UEFI memory map capture (static buffer, ADR 0001) - Shell with 7 commands (help, echo, clear, hello, info, mem, halt) - Dual output: GOP framebuffer + serial console - Makefile: run, run-gui, debug, release, image targets - tools/: qemu.sh, boot-image.sh, debug-kernel.py
Diffstat (limited to '')
-rw-r--r--Makefile124
1 files changed, 124 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9f03f93
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,124 @@
1# shellcheck shell=sh disable=SC2046,SC2091,SC2086,SC2155
2# NOTE: $(VAR) in this file is MAKE syntax, not shell substitution.
3export TARGET=x86_64-unknown-uefi
4export PROFILE=debug
5export OUT_DIR=target/$(TARGET)/$(PROFILE)
6export ESP_DIR=esp
7export KERNEL=$(OUT_DIR)/raisernics.efi
8export BZIMAGE=$(ESP_DIR)/bzImage
9export INITRD=$(ESP_DIR)/initramfs.cpio.gz
10export BOOTLOADER=../rng/rsbl/../build/bootloader/BOOTX64.EFI
11export OVMF=/usr/share/edk2/x64/OVMF.4m.fd
12export BOOT_EFI=$(ESP_DIR)/EFI/BOOT/BOOTX64.EFI
13
14.PHONY: all run run-gui clean image debug release fmt
15
16# ---- Build ---------------------------------------------------------------
17
18all: $(BZIMAGE) $(INITRD) $(BOOT_EFI)
19
20release: PROFILE=release
21release: export PROFILE=release
22release: export OUT_DIR=target/$(TARGET)/release
23release: CARGO_FLAGS=--release
24release: all
25
26# shellcheck disable=SC2034
27CARGO_FLAGS=
28
29$(OUT_DIR)/raisernics.efi: $(shell find src -name '*.rs') Cargo.toml build.rs
30 cargo build --target $(TARGET) $(CARGO_FLAGS)
31
32$(BZIMAGE): $(KERNEL) | $(ESP_DIR)
33 cp "$<" "$@"
34
35$(BOOT_EFI): $(BOOTLOADER) | $(ESP_DIR)
36 mkdir -p $(ESP_DIR)/EFI/BOOT
37 cp "$<" "$@"
38
39$(ESP_DIR):
40 mkdir -p $(ESP_DIR)
41
42$(INITRD): | $(ESP_DIR)
43 printf '' | gzip > "$@"
44
45# ---- QEMU runners --------------------------------------------------------
46
47run: all
48 qemu-system-x86_64 \
49 -bios $(OVMF) \
50 -drive file=fat:rw:$(ESP_DIR),format=raw \
51 -serial stdio \
52 -m 256M \
53 -machine q35 \
54 -cpu qemu64 \
55 -no-reboot \
56 -display none
57
58run-gui: all
59 qemu-system-x86_64 \
60 -bios $(OVMF) \
61 -drive file=fat:rw:$(ESP_DIR),format=raw \
62 -serial stdio \
63 -m 256M \
64 -machine q35 \
65 -cpu qemu64 \
66 -no-reboot \
67 -vga std
68
69# GDB stub on :1234
70debug: all
71 qemu-system-x86_64 \
72 -bios $(OVMF) \
73 -drive file=fat:rw:$(ESP_DIR),format=raw \
74 -serial stdio \
75 -m 256M \
76 -machine q35 \
77 -cpu qemu64 \
78 -no-reboot \
79 -display none \
80 -s -S
81
82# Boot from a raw disk image (created by tools/boot-image.sh)
83run-image: all
84 qemu-system-x86_64 \
85 -bios $(OVMF) \
86 -drive file=$(IMG),format=raw,if=none,id=hd \
87 -device ide-hd,drive=hd \
88 -serial stdio \
89 -m 256M \
90 -machine q35 \
91 -cpu qemu64 \
92 -no-reboot \
93 -display none
94
95# ---- Disk image ----------------------------------------------------------
96
97image: all
98 ./tools/boot-image.sh raisernics.img
99
100# ---- Utilities -----------------------------------------------------------
101
102fmt:
103 cargo fmt
104
105clean:
106 cargo clean
107 rm -rf $(ESP_DIR) raisernics.img
108
109help:
110 @echo "raisernics — Make targets"
111 @echo ""
112 @echo " make build kernel + ESP (default)"
113 @echo " make release build with --release (smaller binary)"
114 @echo " make image create bootable USB image (raisernics.img)"
115 @echo " make run QEMU serial console (no graphics)"
116 @echo " make run-gui QEMU with graphical window (GOP/PS2)"
117 @echo " make debug QEMU + GDB stub on :1234"
118 @echo " make clean remove build artifacts"
119 @echo " make fmt format Rust source"
120 @echo ""
121 @echo "Scripts:"
122 @echo " ./tools/qemu.sh flexible QEMU launcher"
123 @echo " ./tools/boot-image.sh create bootable disk image"
124 @echo " ./tools/debug-kernel.py GDB plugin (attach after 'make debug')"