From 606c2579e5ce9d62ed940fd1fd93e83a728c3bad Mon Sep 17 00:00:00 2001 From: Dylan Bautista Date: Wed, 19 Feb 2025 12:57:47 +0100 Subject: [PATCH] Updated parameter handling and added functionality. --- boot.sh | 62 +++++++++++++++++---------------------------------------- 1 file changed, 18 insertions(+), 44 deletions(-) diff --git a/boot.sh b/boot.sh index 370691a..283703e 100755 --- a/boot.sh +++ b/boot.sh @@ -1,40 +1,8 @@ #!/usr/bin/env bash -set -e +set -ex -show_help () { - echo "Usage: $0 [QEMU options]" - echo "Options:" - echo " -h Show this help message." - echo " --kernelp {bench2|debug2} Kernel parameter:" - echo " bench2: to execute benchmark suite at boot stage 2." - echo " debug2: to get an interactive shell at boot stage 2." -} - -QEMU_KERNEL_PARAMS="" -OPTIONS=$(getopt -o h -l help,kernelp: -n "$0" -- "$@") - -eval set -- "$OPTIONS" - -while true -do - case "$1" in - --kernelp) - QEMU_KERNEL_PARAMS="$2" - shift 2 - ;; - -h|--help) - show_help - exit 0 - ;; - --) - shift - break - ;; - esac -done - -set -x +QEMU_KERNEL_PARAMS="$@" #export PATH=/nix/store/c5xwy0rllg4lcw61mh20glairjz7ibv4-qemu-8.0.4/bin/:$PATH @@ -81,8 +49,9 @@ cd "$TMPDIR" #DEBUG_CPU="-d cpu_reset" #DEBUG_CPU="-d in_asm,cpu,cpu_reset" -run_qemu () { - qemu-system-riscv64 \ +run_qemu () { + + CMD='qemu-system-riscv64 \ $DEBUG_GDB \ $DEBUG_CPU \ -name nixos-riscv \ @@ -104,13 +73,19 @@ run_qemu () { -device vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=123 \ -serial mon:stdio \ -append "$(cat $system/kernel-params) init=$system/init console=ttyS0 loglevel=7 $QEMU_KERNEL_PARAMS" \ - $QEMU_OPTS - "$@" 2>&1 + $QEMU_OPTS \ + "$@"' + + if [[ "$QEMU_KERNEL_PARAMS" =~ bench2 ]]; then + eval "$CMD &" + echo "$!" > qemu.pid + else + eval "$CMD" + fi } -if [ $QEMU_KERNEL_PARAMS == "bench2" ]; then - run_qemu | awk -f $CDIR/verify_rvb.awk - echo "The exit status value is $?" +if [[ "$QEMU_KERNEL_PARAMS" =~ bench2 ]]; then + run_qemu | awk -f $CDIR/verify-bench2.awk else run_qemu fi @@ -131,8 +106,7 @@ fi # -net nic,netdev=user.0,model=virtio -netdev user,id=user.0,"$QEMU_NET_OPTS" \ #console=tty0 #console=ttyS0,115200n8 -# -# -fsdev local,id=fsdev1,path=/nix/store,security_model=none \ + # -device virtio-9p-pci,fsdev=fsdev1,mount_tag=store,bus=pcie.1 \ # -# -drive cache=writeback,file="$NIX_DISK_IMAGE",id=drive1,if=none,index=1,werror=report -device virtio-blk-pci,drive=drive1 \ \ No newline at end of file +# -drive cache=writeback,file="$NIX_DISK_IMAGE",id=drive1,if=none,index=1,werror=report -device virtio-blk-pci,drive=drive1 \