#!/bin/sh
#qemu-system-arm -M realview-pb-a8 -kernel Acess2.arm7.bin -serial stdio

QEMU=qemu-system-arm
USE_GDB=

_SYSTEM=realview-pb-a8
_KERNEL=Acess2.armv7-realview_pb.bin

QEMU_PARAMS=""
_NETTYPE="user"
TEE="| tee QemuLog.txt"

while [ $# -ne 0 ]; do
	case $1 in
	-raspberrypi)
		_SYSTEM="versatilepb"
		QEMU_PARAMS=$QEMU_PARAMS" -cpu arm1176 -m 192 -localtime"
		_KERNEL=Acess2.armv6-raspberrypi.bin
		;;
	-tegra2)
		# git://repo.or.cz/qemu/afaerber.git BRANCH tegra
		QEMU=~/apps_exp/bin/qemu-system-arm
		# - Toshiba AC100
		_SYSTEM="ac100"
		_KERNEL=Acess2.armv7-tegra2.bin
		QEMU_PARAMS=$QEMU_PARAMS" -net nic,model=rtl8169"
		QEMU_PARAMS=$QEMU_PARAMS" -drive id=test_usb_image,file=USB_Test_Image.img,if=none"
		QEMU_PARAMS=$QEMU_PARAMS" -device usb-storage,drive=test_usb_image"
		;;
	-gdb)
		QEMU_PARAMS=$QEMU_PARAMS" -s -S"
		;;
	-extramem)
		QEMU_PARAMS=$QEMU_PARAMS" -m 768"
		;;
	-e)
		shift
		QEMU_PARAMS=$QEMU_PARAMS" "$1
		;;
	-bin)
		shift
		QEMU=$1
		;;
	-tuntap)
		_NETTYPE="tap"
		;;
	-notee)
		TEE=""
		;;
	esac
	shift
done
QEMU_PARAMS="-M $_SYSTEM -kernel KernelLand/$_KERNEL -net $_NETTYPE"$QEMU_PARAMS

#	/home/tpg/apps/bin/qemu-system-x86_64 $QEMU_PARAMS -serial stdio -serial file:QemuLog.txt
#	qemu-system-x86_64 $QEMU_PARAMS -serial stdio | tee QemuLog.txt
eval $QEMU $QEMU_PARAMS -serial stdio $TEE
