blob: 20817e1939f7a477166385e6f03aaf3b0b9cddd8 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001#!/bin/bash
2
3function HELP {
4 echo "help:"
5 echo "-6 x86-64"
6 echo "-m <memory in MB>"
7 echo "-h for help"
8 echo "all arguments after -- are passed to qemu directly"
9 exit 1
10}
11
12DO_64BIT=0
13MEMSIZE=512
14SUDO=""
15MAKE_VARS=""
16
17while getopts bdhm:cMnt6 FLAG; do
18 case $FLAG in
19 6) DO_64BIT=1;;
20 m) MEMSIZE=$OPTARG;;
21 h) HELP;;
22 \?)
23 echo unrecognized option
24 HELP
25 esac
26done
27
28shift $((OPTIND-1))
29
30if [ $DO_64BIT == 1 ]; then
31 QEMU="qemu-system-x86_64"
32 PROJECT="pc-x86-64-test"
33else
34 QEMU="qemu-system-i386"
35 PROJECT="pc-x86-test"
36fi
37
38ARGS=" -m $MEMSIZE -kernel build-${PROJECT}/lk.elf -nographic"
39
40make $MAKE_VARS $PROJECT -j4 &&
41echo $SUDO $QEMU $ARGS $@ &&
42$SUDO $QEMU $ARGS $@
43