forked from foxsen/qemu-loongarch-runenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_loongarch.sh
executable file
·78 lines (73 loc) · 1.99 KB
/
run_loongarch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
############################################################
# Help #
############################################################
Help()
{
# Display Help
echo "Run a loongarch virtual machine."
echo
echo "Syntax: run_loongarch.sh [-b|c|d|D|g|h|i|k|m|q]"
echo "options:"
echo "b <bios> use this file as BIOS"
echo "c <NCPU> simulated cpu number"
echo "d use -s to listen on 1234 debug port"
echo "D use -s -S to listen on 1234 debug port and stop waiting for attach"
echo "g Use graphic UI."
echo "h Print this Help."
echo "i <initrd> use this file as initrd"
echo "k <kernel> use this file as kernel"
echo "m <mem> specify simulated memory size"
echo "q <qemu> use this file as qemu"
echo
}
# >= 512M
MEM="4G"
# 1-4
CPUS="1"
#BIOS="./loongarch_bios_0310.bin"
BIOS="./loongarch_bios_0310_debug.bin"
KERNEL="./vmlinux"
INITRD="busybox-rootfs.img"
USE_GRAPHIC="no"
DEBUG=''
QEMU="./qemu-system-loongarch64"
# Get the options
while getopts ":b:c:dDghi:k:m:q:" option; do
case $option in
b)
BIOS=$OPTARG;;
c)
CPUS=$OPTARG;;
d)
DEBUG='-s';;
D)
DEBUG='-s -S';;
g)
USE_GRAPHIC="yes";;
h) # display Help
Help
exit;;
i)
INITRD=$OPTARG;;
k)
KERNEL=$OPTARG;;
q)
QEMU=$OPTARG;;
\?) # invalid option
echo "invalid option"
exit;;
esac
done
if [ $USE_GRAPHIC = "no" ] ; then
# run without graphic
CMDLINE="root=/dev/ram console=ttyS0,115200 rdinit=/init"
GRAPHIC="-vga none -nographic"
else
# run with graphic
CMDLINE="root=/dev/ram console=tty0 rdinit=/init"
# GRAPHIC="-vga virtio -device virtio-keyboard-pci -device virtio-mouse-pci"
GRAPHIC="-vga virtio -device qemu-xhci -device usb-kbd -device usb-mouse"
fi
set -x
$QEMU -m $MEM -smp $CPUS -bios $BIOS -kernel $KERNEL -initrd $INITRD -append "$CMDLINE" $GRAPHIC $DEBUG