rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | function 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 | |
| 12 | DO_64BIT=0 |
| 13 | MEMSIZE=512 |
| 14 | SUDO="" |
| 15 | MAKE_VARS="" |
| 16 | |
| 17 | while 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 |
| 26 | done |
| 27 | |
| 28 | shift $((OPTIND-1)) |
| 29 | |
| 30 | if [ $DO_64BIT == 1 ]; then |
| 31 | QEMU="qemu-system-x86_64" |
| 32 | PROJECT="pc-x86-64-test" |
| 33 | else |
| 34 | QEMU="qemu-system-i386" |
| 35 | PROJECT="pc-x86-test" |
| 36 | fi |
| 37 | |
| 38 | ARGS=" -m $MEMSIZE -kernel build-${PROJECT}/lk.elf -nographic" |
| 39 | |
| 40 | make $MAKE_VARS $PROJECT -j4 && |
| 41 | echo $SUDO $QEMU $ARGS $@ && |
| 42 | $SUDO $QEMU $ARGS $@ |
| 43 | |