-
Notifications
You must be signed in to change notification settings - Fork 109
/
qemu.sh
executable file
·145 lines (122 loc) · 4.95 KB
/
qemu.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Helper to run ELKS in QEMU
# Auto-select QEMU system emulator variant
[ -x /usr/bin/qemu-system-i386 ] && QEMU="qemu-system-i386"
[ -x /usr/bin/qemu-system-x86_64 ] && QEMU="qemu-system-x86_64"
[ -x /usr/local/bin/qemu-system-i386 ] && QEMU="qemu-system-i386"
[ -x /usr/local/bin/qemu-system-x86_64 ] && QEMU="qemu-system-x86_64"
[ -x /opt/homebrew/bin/qemu-system-i386 ] && QEMU="qemu-system-i386"
[ -x /opt/homebrew/bin/qemu-system-x86_64 ] && QEMU="qemu-system-x86_64"
[ -z $QEMU ] && { echo 'QEMU system emulator not found!'; exit 1; }
# Select disk image to use
# MINIX or FAT .config build
#IMAGE="-fda image/fd2880.img"
IMAGE="-fda image/fd1440.img"
#IMAGE="-fda image/fd1200.img"
#IMAGE="-fda image/fd720.img"
#IMAGE="-fda image/fd360.img"
#IMAGE="-hda image/hd.img"
#IMAGE="-boot order=a -fda image/fd1440.img -drive file=image/hd32-minix.img,format=raw,if=ide"
# FAT package manager build
#IMAGE="-fda image/fd360-fat.img"
#IMAGE="-fda image/fd720-fat.img"
#IMAGE="-fda image/fd1200-fat.img"
#IMAGE="-fda image/fd1440-fat.img"
#IMAGE="-fda image/fd2880-fat.img"
#IMAGE="-hda image/hd32-fat.img"
#IMAGE="-hda image/hd32-fat.img -fda image/fd1440-minix.img"
# MINIX package manager build
#IMAGE="-fda image/fd360-minix.img"
#IMAGE="-fda image/fd720-minix.img"
#IMAGE="-fda image/fd1200-minix.img"
#IMAGE="-fda image/fd1440-minix.img"
#IMAGE="-fda image/fd2880-minix.img"
#IMAGE="-hda image/hd32-minix.img"
# MBR builds
#IMAGE="-hda image/hd32-minix.img"
#IMAGE="-hda image/hd32mbr-minix.img"
#IMAGE="-hda image/hd32mbr-minix.img -hdb image/hd32-minix.img"
#IMAGE="-hda image/hd32mbr-fat.img"
#IMAGE="-fda image/fd1440.img -drive file=image/hd32mbr-minix.img,if=ide"
#IMAGE="-boot order=a -fda image/fd1440.img -drive file=image/hd32-minix.img,if=ide"
#IMAGE="-boot order=a -fda image/fd1440.img -drive file=image/hd32mbr-minix.img,if=ide"
#IMAGE="-boot order=a -fda image/fd1440.img -drive file=test.img,if=ide"
# Second disk for mount after boot
#DISK2="-fdb image/fd360-fat.img"
#DISK2="-fdb image/fd720-fat.img"
#DISK2="-fdb image/fd1200-fat.img"
#DISK2="-fdb image/fd1440-fat.img"
#DISK2="-fdb image/fd2880-fat.img"
#DISK2="-fdb image/fd360-minix.img"
#DISK2="-fdb image/fd720-minix.img"
#DISK2="-fdb image/fd1200-minix.img"
#DISK2="-fdb image/fd1440-minix.img"
#DISK2="-fdb image/fd2880-minix.img"
#DISK2="-hdb image/hd32-minix.img"
#DISK2="-hdb image/hd32-fat.img"
[ -z "$IMAGE" ] && { echo 'Disk image not found!'; exit 1; }
echo "Using disk image: $IMAGE"
# Select your keyboard mapping here:
# KEYBOARD="-k en-us"
# KEYBOARD="-k fr"
KEYBOARD=
# Select pty serial port or serial mouse driver
#SERIAL="-chardev pty,id=chardev1 -device isa-serial,chardev=chardev1,id=serial1"
#SERIAL="-chardev msmouse,id=chardev1 -device isa-serial,chardev=chardev1,id=serial1"
# Uncomment this to route ELKS /dev/ttyS0 to host terminal
CONSOLE="-serial stdio"
# Hides qemu window also
#CONSOLE="-serial stdio -nographic"
# Host forwarding for networking
# No forwarding: only outgoing from ELKS to host
# HOSTFWD="-net user"
# Incoming telnet forwarding: example: connect to ELKS with telnet localhost 2323
# HOSTFWD="-net user,hostfwd=tcp:127.0.0.1:2323-10.0.2.15:23"
# Incoming http forwarding: example: connect to ELKS httpd with 'http://localhost:8080'
# HOSTFWD="-net user,hostfwd=tcp:127.0.0.1:8080-10.0.2.15:80"
# Simultaneous telnet, http and ftp forwarding
FWD="\
hostfwd=tcp:127.0.0.1:8080-10.0.2.15:80,\
hostfwd=tcp:127.0.0.1:2323-10.0.2.15:23,\
hostfwd=tcp::8020-:20,\
hostfwd=tcp::8021-:21,\
hostfwd=tcp::8041-:49821,\
hostfwd=tcp::8042-:49822,\
hostfwd=tcp::8043-:49823,\
hostfwd=tcp::8044-:49824,\
hostfwd=tcp::8045-:49825,\
hostfwd=tcp::8046-:49826,\
hostfwd=tcp::8047-:49827,\
hostfwd=tcp::8048-:49828,\
hostfwd=tcp::8049-:49829"
# new style
#NET="-net nic,model=ne2k_isa -net user,$FWD"
# old style, with configurable interrupt line
NET="-netdev user,id=mynet,$FWD -device ne2k_isa,irq=12,netdev=mynet"
# Enable network dump here:
# NETDUMP="-net dump"
# Enable PC-Speaker here:
#AUDIO="-audiodev pa,id=speaker -machine pcspk-audiodev=speaker"
UNAME=`uname`
# Determine display type ("Darwin" = OSX)
[ "$UNAME" != 'Darwin' ] && QDISPLAY="-display sdl"
# Configure QEMU as pure ISA system
# For macOS x86, HVF can be used to increase emulation speed
# Otherwise, translation block caching of multiple instructions must be turned off
# Autoselect accelerator
ACCEL_SSTP="-singlestep"
ACCEL_V9="-accel tcg,one-insn-per-tb=on"
ACCEL_HVF="-accel hvf"
ACCEL=$ACCEL_SSTP
if [[ `$QEMU -version` =~ "version 9" ]]; then
ACCEL=$ACCEL_V9
fi
if [[ $QEMU =~ "x86_64" && $UNAME =~ "Darwin" && $UNAME =~ "x86_64" ]]; then
ACCEL=$ACCEL_HVF
fi
#DEBUG="-D logfile -d in_asm,int,unimp,guest_errors"
#DEBUG="-D logfile -d cpu,in_asm,int,unimp,guest_errors"
#DEBUG="-D logfile -d out_asm,in_asm,int,unimp,guest_errors"
echo "Using QEMU: $QEMU $ACCEL"
exec $QEMU $ACCEL $DEBUG $AUDIO $CONSOLE -nodefaults -name ELKS -machine isapc -cpu 486,tsc -m 4M \
$KEYBOARD $QDISPLAY -vga std -rtc base=utc $SERIAL \
$NET $NETDUMP $IMAGE $DISK2 $@