Makefile.src 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # disable kvm to debug triple faults
  2. QEMU_BIN=##PLACEHOLDER_1##
  3. GDB_BIN=##PLACEHOLDER_2##
  4. QEMU_ACCELERATION_FLAG=##PLACEHOLDER_3##
  5. QEMU_DEBUG_FLAG=#-d cpu_reset,int
  6. QEMU_ARGS=-machine q35 -drive id=disk,file=build/boot.img,format=raw,if=none \
  7. -device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0 -smp 4 \
  8. -no-reboot -no-shutdown $(QEMU_ACCELERATION_FLAG) $(QEMU_DEBUG_FLAG)
  9. CROSS_COMPILE=##PLACEHOLDER_4##
  10. .PHONY: run
  11. run: build
  12. $(QEMU_BIN) $(QEMU_ARGS) -display curses -S -s
  13. .PHONY: srun
  14. srun: build
  15. $(QEMU_BIN) $(QEMU_ARGS) -display none -S -s -serial mon:stdio
  16. .PHONY: nativerun
  17. nativerun: build
  18. $(QEMU_BIN) $(QEMU_ARGS) -display none -serial mon:stdio
  19. .PHONY: prepare
  20. prepare:
  21. cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug $(CROSS_COMPILE)
  22. cp build/compile_commands.json .
  23. .PHONY: reprepare
  24. reprepare: clean prepare
  25. true
  26. .PHONY: build
  27. build:
  28. cmake --build build -j 6 --target boot.img
  29. .PHONY: clean
  30. clean:
  31. -rm -rf build
  32. -rm compile_commands.json
  33. .PHONY: clean-all
  34. clean-all: clean
  35. -rm Makefile
  36. .PHONY: debug
  37. debug:
  38. -$(GDB_BIN) --symbols=build/kernel.out \
  39. -iex 'source pretty-print.py' \
  40. -iex 'set pagination off' \
  41. -iex 'set output-radix 16' \
  42. -iex 'set print asm-demangle on' \
  43. -iex 'set print pretty on' \
  44. -iex 'target remote:1234'
  45. -killall $(QEMU_BIN)
  46. .PHONY: tmux-debug
  47. tmux-debug:
  48. tmux new-session -s gbos-debug -d
  49. -tmux split-window -t gbos-debug -hf
  50. -tmux send-keys -t gbos-debug:1.1 'make srun' C-m
  51. -tmux send-keys -t gbos-debug:1.2 'make debug' C-m C-m
  52. -tmux attach -t gbos-debug
  53. tmux kill-session -t gbos-debug
  54. build/boot.vdi: build/boot.img
  55. -rm build/boot.vdi
  56. VBoxManage convertfromraw $< $@ --format VDI