justfile 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. target := "riscv64imac-unknown-none-elf"
  2. mode := "debug"
  3. build-path := "../../target/" + target + "/" + mode + "/"
  4. rustsbi-elf := build-path + "rustsbi-qemu"
  5. rustsbi-bin := build-path + "rustsbi-qemu.bin"
  6. test-kernel-elf := build-path + "test-kernel"
  7. test-kernel-bin := build-path + "test-kernel.bin"
  8. objdump := "riscv64-unknown-elf-objdump"
  9. objcopy := "rust-objcopy --binary-architecture=riscv64"
  10. gdb := "riscv64-unknown-elf-gdb"
  11. threads := "2"
  12. build: rustsbi test-kernel
  13. @{{objcopy}} {{rustsbi-elf}} --strip-all -O binary {{rustsbi-bin}}
  14. rustsbi:
  15. @cargo build --target={{target}}
  16. test-kernel:
  17. @just -f "../../test-kernel/justfile" build
  18. qemu: build
  19. @qemu-system-riscv64 \
  20. -machine virt \
  21. -nographic \
  22. -bios none \
  23. -device loader,file={{rustsbi-bin}},addr=0x80000000 \
  24. -device loader,file={{test-kernel-bin}},addr=0x80200000 \
  25. -smp threads={{threads}}
  26. run: build qemu
  27. asm: build
  28. @{{objdump}} -D {{rustsbi-elf}} | less
  29. debug: build
  30. @qemu-system-riscv64 \
  31. -machine virt \
  32. -nographic \
  33. -bios none \
  34. -device loader,file={{rustsbi-bin}},addr=0x80000000 \
  35. -device loader,file={{test-kernel-bin}},addr=0x80200000 \
  36. -smp threads={{threads}} \
  37. -gdb tcp::1234 -S
  38. gdb:
  39. @{{gdb}} --eval-command="file {{rustsbi-elf}}" --eval-command="target remote localhost:1234"
  40. gdb-kernel:
  41. @{{gdb}} --eval-command="file {{test-kernel-elf}}" --eval-command="target remote localhost:1234"