File tree Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -64,19 +64,23 @@ QEMU_ARGS := -machine virt \
6464 -bios $(BOOTLOADER ) \
6565 -device loader,file=$(KERNEL_BIN ) ,addr=$(KERNEL_ENTRY_PA )
6666
67- run-inner : build
67+ QEMU_NAME := qemu-system-riscv64
68+ qemu-version-check :
69+ @sh scripts/qemu-ver-check.sh $(QEMU_NAME )
70+
71+ run-inner : qemu-version-check build
6872 @qemu-system-riscv64 $(QEMU_ARGS )
6973
70- debug : build
74+ debug : qemu-version-check build
7175 @tmux new-session -d \
7276 " qemu-system-riscv64 $( QEMU_ARGS) -s -S" && \
7377 tmux split-window -h " riscv64-unknown-elf-gdb -ex 'file $( KERNEL_ELF) ' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'" && \
7478 tmux -2 attach-session -d
7579
76- gdbserver : build
80+ gdbserver : qemu-version-check build
7781 @qemu-system-riscv64 $(QEMU_ARGS ) -s -S
7882
7983gdbclient :
8084 @riscv64-unknown-elf-gdb -ex ' file $(KERNEL_ELF)' -ex ' set arch riscv:rv64' -ex ' target remote localhost:1234'
8185
82- .PHONY : build env kernel clean disasm disasm-vim run-inner gdbserver gdbclient
86+ .PHONY : build env kernel clean disasm disasm-vim run-inner 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