Makefile.src 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. FDISK_BIN ?= ##PLACEHOLDER_5##
  10. CROSS_COMPILE=##PLACEHOLDER_4##
  11. .PHONY: run
  12. run: build
  13. $(QEMU_BIN) $(QEMU_ARGS) -display curses -S -s
  14. .PHONY: srun
  15. srun: build
  16. $(QEMU_BIN) $(QEMU_ARGS) -display none -S -s -serial mon:stdio
  17. .PHONY: nativerun
  18. nativerun: build
  19. $(QEMU_BIN) $(QEMU_ARGS) -display none -serial mon:stdio
  20. .PHONY: prepare
  21. prepare:
  22. cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug $(CROSS_COMPILE)
  23. cp build/compile_commands.json .
  24. .PHONY: reprepare
  25. reprepare: clean prepare
  26. true
  27. .PHONY: build
  28. build:
  29. cmake --build build -j 6 --target boot.img
  30. .PHONY: clean
  31. clean:
  32. -rm -rf build
  33. -rm compile_commands.json
  34. .PHONY: clean-all
  35. clean-all: clean
  36. -rm Makefile
  37. .PHONY: debug
  38. debug:
  39. -$(GDB_BIN) --symbols=build/kernel.out \
  40. -iex 'source pretty-print.py' \
  41. -iex 'set pagination off' \
  42. -iex 'set output-radix 16' \
  43. -iex 'set print asm-demangle on' \
  44. -iex 'set print pretty on' \
  45. -iex 'target remote:1234'
  46. -killall $(QEMU_BIN)
  47. .PHONY: tmux-debug
  48. tmux-debug:
  49. tmux new-session -s gbos-debug -d
  50. -tmux split-window -t gbos-debug -hf
  51. -tmux send-keys -t gbos-debug:1.1 'make srun' C-m
  52. -tmux send-keys -t gbos-debug:1.2 'make debug' C-m C-m
  53. -tmux attach -t gbos-debug
  54. tmux kill-session -t gbos-debug
  55. build/fs.img: init_script.sh
  56. sh script/build-img.sh
  57. build/boot.img: build/fs.img build/mbr_hole.bin
  58. dd if=build/mbr_hole.bin of=build/boot.img
  59. dd if=build/fs.img of=build/boot.img bs=$(shell expr 4 \* 1024 \* 1024) seek=1 conv=notrunc
  60. sh -c 'echo n; echo; echo; echo 8192; echo; echo a; echo w' | $(FDISK_BIN) build/boot.img
  61. build/boot.vdi: build/boot.img
  62. -rm build/boot.vdi
  63. VBoxManage convertfromraw $< $@ --format VDI
  64. .PHONY: image
  65. image: build/boot.img