59 lines
1.2 KiB
Bash
Executable File
59 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
ARGS=""
|
|
KERNEL="-kernel cmake-build-debug/my-kernel.bin"
|
|
NOHUP=0
|
|
|
|
function print_help() {
|
|
cat <<EOF
|
|
Usage: $0 [OPTION]...
|
|
|
|
Options:
|
|
-h, --help Print help info
|
|
-d, --debug Start qemu with halted cpu and GDB port 1234 open. Also print guest errors and interrupts
|
|
-i [disk], --ide [disk] Use [disk] as a hda on an IDE bus
|
|
-n, --nohup Run QEMU using nohup and output to /dev/null
|
|
-m, --max-cpu Run qemu with -m max
|
|
EOF
|
|
}
|
|
|
|
while [[ "$#" -gt 0 ]]; do
|
|
key=$1
|
|
case $key in
|
|
-d | --debug)
|
|
ARGS="${ARGS} -S -s -d guest_errors,int"
|
|
shift
|
|
;;
|
|
-i | --ide)
|
|
ARGS="${ARGS} -hda $2"
|
|
shift 2
|
|
;;
|
|
-s | --sata)
|
|
ARGS="${ARGS} -drive id=disk1,file=$2,if=none -device ahci,id=ahci -device ide-drive,drive=disk1,bus=ahci.0"
|
|
shift 2
|
|
;;
|
|
-m | --max-cpu)
|
|
ARGS="${ARGS} -cpu max"
|
|
shift
|
|
;;
|
|
-n | --nophup)
|
|
NOHUP=1
|
|
shift
|
|
;;
|
|
-h | --help)
|
|
print_help
|
|
exit
|
|
;;
|
|
esac
|
|
done
|
|
|
|
echo "Launching with args ${ARGS} ${KERNEL}"
|
|
|
|
if [ "$NOHUP" -gt 0 ]; then
|
|
# shellcheck disable=SC2086
|
|
nohup qemu-system-i386 ${ARGS} ${KERNEL} >/dev/null &
|
|
disown
|
|
else
|
|
# shellcheck disable=SC2086
|
|
qemu-system-i386 ${ARGS} ${KERNEL}
|
|
fi
|