[platform][riscv-virt] added support for QEMU's riscv 'virt' machine

The virt machine is a generic target, much like the arm virt machine.
Intended to be simple to use and a good target to run large systems like
linux on. At the moment simply support booting and simple uart and timer
support.
This commit is contained in:
Travis Geiselbrecht
2019-03-30 21:31:47 -07:00
parent dbe86c89be
commit ae5200595c
18 changed files with 536 additions and 13 deletions

View File

@@ -103,9 +103,9 @@ fi
MAKE_VARS=""
if [ $DO_CMPCTMALLOC == 1 ]; then
MAKE_VARS=LK_HEAP_IMPLEMENTATION=cmpctmalloc
MAKE_VARS=LK_HEAP_IMPLEMENTATION=cmpctmalloc
elif [ $DO_MINIHEAP == 1 ]; then
MAKE_VARS=LK_HEAP_IMPLEMENTATION=miniheap
MAKE_VARS=LK_HEAP_IMPLEMENTATION=miniheap
fi
$DIR/make-parallel $MAKE_VARS $PROJECT &&

View File

@@ -2,8 +2,118 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
set -e
set -x
function HELP {
echo "help:"
echo "-b a virtio block device"
echo "-c cmpctmalloc instead of dlmalloc"
echo "-M miniheap instead of dlmalloc"
echo "-n a virtio network device"
echo "-t a virtio tap network device"
echo "-d a virtio display"
echo "-e embeded platform"
echo "-6 64bit"
echo "-m <memory in MB>"
echo "-s <number of cpus>"
echo "-h for help"
echo "all arguments after -- are passed to qemu directly"
exit 1
}
$DIR/make-parallel sifive-e-test
qemu-system-riscv32 -machine sifive_e -kernel build-sifive-e-test/lk.elf -nographic $@
DO_NET=0
DO_NET_TAP=0
DO_BLOCK=0
DO_64BIT=0
DO_EMBEDDED=0
DO_DISPLAY=0
DO_CMPCTMALLOC=0
DO_MINIHEAP=0
SMP=1
MEMSIZE=512
SUDO=""
PROJECT=""
while getopts bdhm:cMnte6p:s: FLAG; do
case $FLAG in
b) DO_BLOCK=1;;
c) DO_CMPCTMALLOC=1;;
d) DO_DISPLAY=1;;
M) DO_MINIHEAP=1;;
n) DO_NET=1;;
t) DO_NET_TAP=1;;
e) DO_EMBEDDED=1;;
6) DO_64BIT=1;;
m) MEMSIZE=$OPTARG;;
s) SMP=$OPTARG;;
p) PROJECT=$OPTARG;;
h) HELP;;
\?)
echo unrecognized option
HELP
esac
done
shift $((OPTIND-1))
if (( $DO_64BIT )); then
echo unsupported now
exit 1
QEMU="qemu-system-riscv64"
#CPU="cortex-a53"
MACHINE="virt"
_PROJECT="qemu-virt-arm64-test"
elif (( $DO_EMBEDDED == 1 )); then
QEMU="qemu-system-riscv32"
MACHINE="sifive_e"
_PROJECT="sifive-e-test"
else
QEMU="qemu-system-riscv32"
CPU="any"
MACHINE="virt"
_PROJECT="qemu-virt-riscv32-test"
fi
if [ "$PROJECT" == "" ]; then
PROJECT=$_PROJECT
fi
BLOCK_ARGS=" -drive if=none,file=blk.bin,id=blk,format=raw -device virtio-blk-device,drive=blk"
NET_ARGS=" -netdev user,id=vmnic,hostname=qemu -device virtio-net-device,netdev=vmnic"
NET_TAP_ARGS=" -netdev tap,id=vmnic -device virtio-net-device,netdev=vmnic"
NO_DISPLAY_ARGS=" -nographic"
DISPLAY_ARGS=" -device virtio-gpu-device -serial stdio"
# the following args only really make sense on non embedded versions
if (( ! $DO_EMBEDDED )); then
ARGS=" -cpu $CPU -m $MEMSIZE -smp $SMP -machine $MACHINE -kernel build-${PROJECT}/lk.elf"
ARGS+=" -bios none"
if (( $DO_BLOCK )); then
ARGS+=$BLOCK_ARGS
fi
if (( $DO_NET )); then
ARGS+=$NET_ARGS
fi
if (( $DO_NET_TAP )); then
ARGS+=$NET_TAP_ARGS
SUDO="sudo "
fi
if (( $DO_DISPLAY )); then
ARGS+=$DISPLAY_ARGS
else
ARGS+=$NO_DISPLAY_ARGS
fi
else
# embedded machine is more fixed and only gets these options
ARGS="-machine $MACHINE -kernel build-${PROJECT}/lk.elf"
ARGS+=$NO_DISPLAY_ARGS
fi
MAKE_VARS=""
if (( $DO_CMPCTMALLOC )); then
MAKE_VARS=LK_HEAP_IMPLEMENTATION=cmpctmalloc
elif (( $DO_MINIHEAP )); then
MAKE_VARS=LK_HEAP_IMPLEMENTATION=miniheap
fi
$DIR/make-parallel $MAKE_VARS $PROJECT &&
echo $SUDO $QEMU $ARGS $@ &&
$SUDO $QEMU $ARGS $@