Files
moss-kernel/scripts/qemu-runner.sh
Matthew Leach a2a37146ff main: init: add arg init option
Add a new option `--init-arg` which allows arguments to be passed to
init when invoked by the kernel. This allows the `-i` parameter to be
passed through to bash such that it will be started in interactive mode.
2026-01-06 16:22:59 -08:00

27 lines
736 B
Bash
Executable File

#!/usr/bin/env bash
set -e
# First argument: the ELF file to run (required)
# Second argument: init script to run (optional, defaults to /bin/bash)
# Parse args:
if [ $# -lt 1 ]; then
echo "Usage: $0 <elf-file>"
exit 1
fi
if [ -n "$2" ]; then
append_args="--init=$2"
else
append_args="--init=/bin/bash --init-arg=-i"
fi
base="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
elf="$1"
bin="${elf%.elf}.bin"
# Convert to binary format
aarch64-none-elf-objcopy -O binary "$elf" "$bin"
qemu-system-aarch64 -M virt,gic-version=3 -initrd moss.img -cpu cortex-a72 -m 2G -smp 4 -nographic -s -kernel "$bin" -append "$append_args --rootfs=ext4fs --automount=/dev,devfs --automount=/tmp,tmpfs --automount=/proc,procfs"