1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- # disable kvm to debug triple faults
- QEMU_BIN=##PLACEHOLDER_1##
- GDB_BIN=##PLACEHOLDER_2##
- QEMU_ACCELERATION_FLAG=##PLACEHOLDER_3##
- QEMU_DEBUG_FLAG=#-d cpu_reset,int
- QEMU_ARGS=-machine q35 -drive id=disk,file=build/boot.img,format=raw,if=none \
- -device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0 -smp 4 \
- -no-reboot -no-shutdown $(QEMU_ACCELERATION_FLAG) $(QEMU_DEBUG_FLAG)
- CROSS_COMPILE=##PLACEHOLDER_4##
- .PHONY: run
- run: build
- $(QEMU_BIN) $(QEMU_ARGS) -display curses -S -s
- .PHONY: srun
- srun: build
- $(QEMU_BIN) $(QEMU_ARGS) -display none -S -s -serial mon:stdio
- .PHONY: nativerun
- nativerun: build
- $(QEMU_BIN) $(QEMU_ARGS) -display none -serial mon:stdio
- .PHONY: prepare
- prepare:
- cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug $(CROSS_COMPILE)
- cp build/compile_commands.json .
- .PHONY: reprepare
- reprepare: clean prepare
- true
- .PHONY: build
- build:
- cmake --build build -j 6 --target boot.img
- .PHONY: clean
- clean:
- -rm -rf build
- -rm compile_commands.json
- .PHONY: clean-all
- clean-all: clean
- -rm Makefile
- .PHONY: debug
- debug:
- -$(GDB_BIN) --symbols=build/kernel.out \
- -iex 'source pretty-print.py' \
- -iex 'set pagination off' \
- -iex 'set output-radix 16' \
- -iex 'set print asm-demangle on' \
- -iex 'set print pretty on' \
- -iex 'target remote:1234'
- -killall $(QEMU_BIN)
- .PHONY: tmux-debug
- tmux-debug:
- tmux new-session -s gbos-debug -d
- -tmux split-window -t gbos-debug -hf
- -tmux send-keys -t gbos-debug:1.1 'make srun' C-m
- -tmux send-keys -t gbos-debug:1.2 'make debug' C-m C-m
- -tmux attach -t gbos-debug
- tmux kill-session -t gbos-debug
- build/boot.vdi: build/boot.img
- -rm build/boot.vdi
- VBoxManage convertfromraw $< $@ --format VDI
|