File tree Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -74,20 +74,23 @@ QEMU_ARGS := -machine virt \
7474 -drive file=$(FS_IMG ) ,if=none,format=raw,id=x0 \
7575 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
7676
77- run-inner : build
77+ QEMU_NAME := qemu-system-riscv64
78+ qemu-version-check :
79+ @sh scripts/qemu-ver-check.sh $(QEMU_NAME )
80+
81+ run-inner : qemu-version-check build
7882 @qemu-system-riscv64 $(QEMU_ARGS )
7983
80- debug : build
84+ debug : qemu-version-check build
8185 @tmux new-session -d \
8286 " qemu-system-riscv64 $( QEMU_ARGS) -s -S" && \
8387 tmux split-window -h " riscv64-unknown-elf-gdb -ex 'file $( KERNEL_ELF) ' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'" && \
8488 tmux -2 attach-session -d
8589
86-
87- gdbserver : build
90+ gdbserver : qemu-version-check build
8891 @qemu-system-riscv64 $(QEMU_ARGS ) -s -S
8992
9093gdbclient :
9194 @riscv64-unknown-elf-gdb -ex ' file $(KERNEL_ELF)' -ex ' set arch riscv:rv64' -ex ' target remote localhost:1234'
9295
93- .PHONY : build env kernel clean disasm disasm-vim run-inner fs-img gdbserver gdbclient
96+ .PHONY : build env kernel clean disasm disasm-vim run-inner fs-img gdbserver gdbclient qemu-version-check
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # Argument1: The filename of qemu executable, e.g. qemu-system-riscv64
4+ QEMU_PATH=$( which $1 )
5+ RET=$?
6+ MINIMUM_MAJOR_VERSION=7
7+ RED=' \033[0;31m'
8+ GREEN=' \033[0;32m'
9+ NC=' \033[0m'
10+ if [ $RET != 0 ]
11+ then
12+ echo " $1 not found"
13+ exit 1
14+ else
15+ QEMU_VERSION=$( $1 --version| head -n 1| awk ' {print $4}' )
16+ MAJOR_VERSION=$( echo $QEMU_VERSION | cut -c1-1)
17+ if [ $MAJOR_VERSION -lt $MINIMUM_MAJOR_VERSION ]
18+ then
19+ echo " ${RED} Error: Required major version of QEMU is ${MINIMUM_MAJOR_VERSION} , " \
20+ " but current is ${QEMU_VERSION} .${NC} "
21+ exit 1
22+ else
23+ echo " ${GREEN} QEMU version is ${QEMU_VERSION} (>=${MINIMUM_MAJOR_VERSION} ), OK!${NC} "
24+ exit 0
25+ fi
26+ fi
You can’t perform that action at this time.
0 commit comments