summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2016-03-09 18:09:19 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-25 10:29:14 +0000
commitb47c53b70e60990ac83ab488b30fd962e735a4f8 (patch)
tree15f95a97b31ce544a2ab1cc1a081bf7e6216b9b8 /scripts
parentfae732f24e965e80d414b5cd63ff5d33d8dfcd60 (diff)
downloadpoky-b47c53b70e60990ac83ab488b30fd962e735a4f8.tar.gz
runqemu-internal: split the code into functions
Use config_<machine> to split the code into separate functions, so that different machines won't affect each other, and they will have a better structure. (From OE-Core rev: 6098a72e8d21f6321636e727703ca7c29d9af142) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/runqemu-internal180
1 files changed, 89 insertions, 91 deletions
diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index 7ae077766c..ac1c703c53 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -38,49 +38,6 @@ mem_set=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-m[[:space:]] *[0-9]*\)'`
38if [ ! -z "$mem_set" ] ; then 38if [ ! -z "$mem_set" ] ; then
39#Get memory setting size from user input 39#Get memory setting size from user input
40 mem_size=`echo $mem_set | sed 's/-m[[:space:]] *//'` 40 mem_size=`echo $mem_set | sed 's/-m[[:space:]] *//'`
41else
42 case "$MACHINE" in
43 "qemux86")
44 mem_size=256
45 ;;
46 "qemux86-64")
47 mem_size=256
48 ;;
49 "qemuarm")
50 mem_size=128
51 ;;
52 "qemuarm64")
53 mem_size=512
54 ;;
55 "qemumicroblaze")
56 mem_size=256
57 ;;
58 "qemumips"|"qemumips64")
59 mem_size=256
60 ;;
61 "qemuppc")
62 mem_size=256
63 ;;
64 "qemush4")
65 mem_size=1024
66 ;;
67 "qemuzynq")
68 mem_size=1024
69 ;;
70 *)
71 mem_size=64
72 ;;
73 esac
74
75fi
76
77# QEMU_MEMORY has 'M' appended to mem_size
78QEMU_MEMORY="$mem_size"M
79
80# We need to specify -m <mem_size> to overcome a bug in qemu 0.14.0
81# https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/584480
82if [ -z "$mem_set" ] ; then
83 SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT -m $mem_size"
84fi 41fi
85 42
86# This file is created when runqemu-gen-tapdevs creates a bank of tap 43# This file is created when runqemu-gen-tapdevs creates a bank of tap
@@ -267,26 +224,6 @@ else
267 fi 224 fi
268fi 225fi
269 226
270case "$MACHINE" in
271 "qemuarm") ;;
272 "qemuarm64") ;;
273 "qemumicroblaze") ;;
274 "qemumips") ;;
275 "qemumipsel") ;;
276 "qemumips64") ;;
277 "qemush4") ;;
278 "qemuppc") ;;
279 "qemuarmv6") ;;
280 "qemuarmv7") ;;
281 "qemux86") ;;
282 "qemux86-64") ;;
283 "qemuzynq") ;;
284 *)
285 echo "Error: Unsupported machine type $MACHINE"
286 return 1
287 ;;
288esac
289
290if [ ! -f "$KERNEL" -a "$IS_VM" = "false" ]; then 227if [ ! -f "$KERNEL" -a "$IS_VM" = "false" ]; then
291 echo "Error: Kernel image file $KERNEL doesn't exist" 228 echo "Error: Kernel image file $KERNEL doesn't exist"
292 cleanup 229 cleanup
@@ -329,12 +266,25 @@ if [ "$FSTYPE" = "nfs" ]; then
329 NFSRUNNING="true" 266 NFSRUNNING="true"
330fi 267fi
331 268
332if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "qemuarmv6" -o "$MACHINE" = "qemuarmv7" ]; then 269
270set_mem_size() {
271 if [ ! -z "$mem_set" ] ; then
272 #Get memory setting size from user input
273 mem_size=`echo $mem_set | sed 's/-m[[:space:]] *//'`
274 else
275 mem_size=$1
276 fi
277 # QEMU_MEMORY has 'M' appended to mem_size
278 QEMU_MEMORY="$mem_size"M
279
280}
281
282config_qemuarm() {
283 set_mem_size 128
333 QEMU=qemu-system-arm 284 QEMU=qemu-system-arm
334 MACHINE_SUBTYPE=versatilepb 285 MACHINE_SUBTYPE=versatilepb
335 export QEMU_AUDIO_DRV="none" 286 export QEMU_AUDIO_DRV="none"
336 QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS" 287 QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
337 # QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -force-pointer"
338 if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then 288 if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then
339 KERNCMDLINE="root=$DROOT rw console=ttyAMA0,115200 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY highres=off" 289 KERNCMDLINE="root=$DROOT rw console=ttyAMA0,115200 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY highres=off"
340 QEMUOPTIONS="$QEMU_NETWORK_CMD -M ${MACHINE_SUBTYPE} $ROOTFS_OPTIONS -no-reboot $QEMU_UI_OPTIONS" 290 QEMUOPTIONS="$QEMU_NETWORK_CMD -M ${MACHINE_SUBTYPE} $ROOTFS_OPTIONS -no-reboot $QEMU_UI_OPTIONS"
@@ -354,9 +304,10 @@ if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "qemuarmv6" -o "$MACHINE" = "qemuarm
354 if [ "$MACHINE" = "qemuarmv7" ]; then 304 if [ "$MACHINE" = "qemuarmv7" ]; then
355 QEMUOPTIONS="$QEMUOPTIONS -cpu cortex-a8" 305 QEMUOPTIONS="$QEMUOPTIONS -cpu cortex-a8"
356 fi 306 fi
357fi 307}
358 308
359if [ "$MACHINE" = "qemuarm64" ]; then 309config_qemuarm64() {
310 set_mem_size 512
360 QEMU=qemu-system-aarch64 311 QEMU=qemu-system-aarch64
361 312
362 QEMU_NETWORK_CMD="-netdev tap,id=net0,ifname=$TAP,script=no,downscript=no -device virtio-net-device,netdev=net0 " 313 QEMU_NETWORK_CMD="-netdev tap,id=net0,ifname=$TAP,script=no,downscript=no -device virtio-net-device,netdev=net0 "
@@ -383,9 +334,10 @@ if [ "$MACHINE" = "qemuarm64" ]; then
383 KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw console=ttyAMA0,38400 mem=$QEMU_MEMORY highres=off $KERNEL_NETWORK_CMD" 334 KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw console=ttyAMA0,38400 mem=$QEMU_MEMORY highres=off $KERNEL_NETWORK_CMD"
384 QEMUOPTIONS="$QEMU_NETWORK_CMD -machine virt -cpu cortex-a57 $QEMU_UI_OPTIONS" 335 QEMUOPTIONS="$QEMU_NETWORK_CMD -machine virt -cpu cortex-a57 $QEMU_UI_OPTIONS"
385 fi 336 fi
386fi 337}
387 338
388if [ "$MACHINE" = "qemux86" ]; then 339config_qemux86() {
340 set_mem_size 256
389 QEMU=qemu-system-i386 341 QEMU=qemu-system-i386
390 if [ "$KVM_ACTIVE" = "yes" ]; then 342 if [ "$KVM_ACTIVE" = "yes" ]; then
391 CPU_SUBTYPE=kvm32 343 CPU_SUBTYPE=kvm32
@@ -421,9 +373,10 @@ if [ "$MACHINE" = "qemux86" ]; then
421 # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in 373 # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in
422 # qemux86 and qemux86-64. We can use timer interrupt mode for now. 374 # qemux86 and qemux86-64. We can use timer interrupt mode for now.
423 KERNCMDLINE="$KERNCMDLINE oprofile.timer=1" 375 KERNCMDLINE="$KERNCMDLINE oprofile.timer=1"
424fi 376}
425 377
426if [ "$MACHINE" = "qemux86-64" ]; then 378config_qemux86_64() {
379 set_mem_size 256
427 QEMU=qemu-system-x86_64 380 QEMU=qemu-system-x86_64
428 if [ "$KVM_ACTIVE" = "yes" ]; then 381 if [ "$KVM_ACTIVE" = "yes" ]; then
429 CPU_SUBTYPE=kvm64 382 CPU_SUBTYPE=kvm64
@@ -457,9 +410,10 @@ if [ "$MACHINE" = "qemux86-64" ]; then
457 # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in 410 # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in
458 # qemux86 and qemux86-64. We can use timer interrupt mode for now. 411 # qemux86 and qemux86-64. We can use timer interrupt mode for now.
459 KERNCMDLINE="$KERNCMDLINE oprofile.timer=1" 412 KERNCMDLINE="$KERNCMDLINE oprofile.timer=1"
460fi 413}
461 414
462if [ "$MACHINE" = "qemumips" -o "$MACHINE" = "qemumipsel" -o "$MACHINE" = "qemumips64" ]; then 415config_qemumips() {
416 set_mem_size 256
463 case "$MACHINE" in 417 case "$MACHINE" in
464 qemumips) QEMU=qemu-system-mips ;; 418 qemumips) QEMU=qemu-system-mips ;;
465 qemumipsel) QEMU=qemu-system-mipsel ;; 419 qemumipsel) QEMU=qemu-system-mipsel ;;
@@ -481,9 +435,10 @@ if [ "$MACHINE" = "qemumips" -o "$MACHINE" = "qemumipsel" -o "$MACHINE" = "qemum
481 KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" 435 KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
482 QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS" 436 QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS"
483 fi 437 fi
484fi 438}
485 439
486if [ "$MACHINE" = "qemuppc" ]; then 440config_qemuppc() {
441 set_mem_size 256
487 QEMU=qemu-system-ppc 442 QEMU=qemu-system-ppc
488 MACHINE_SUBTYPE=mac99 443 MACHINE_SUBTYPE=mac99
489 CPU_SUBTYPE=G4 444 CPU_SUBTYPE=G4
@@ -506,9 +461,10 @@ if [ "$MACHINE" = "qemuppc" ]; then
506 KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" 461 KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
507 QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS" 462 QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS"
508 fi 463 fi
509fi 464}
510 465
511if [ "$MACHINE" = "qemush4" ]; then 466config_qemush4() {
467 set_mem_size 1024
512 QEMU=qemu-system-sh4 468 QEMU=qemu-system-sh4
513 MACHINE_SUBTYPE=r2d 469 MACHINE_SUBTYPE=r2d
514 QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS" 470 QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
@@ -528,30 +484,72 @@ if [ "$MACHINE" = "qemush4" ]; then
528 QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS -monitor null -serial vc -serial stdio" 484 QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS -monitor null -serial vc -serial stdio"
529 SERIALSTDIO="1" 485 SERIALSTDIO="1"
530 fi 486 fi
531fi 487}
532
533if [ "${FSTYPE:0:3}" = "ext" ]; then
534 KERNCMDLINE="$KERNCMDLINE rootfstype=$FSTYPE"
535fi
536 488
537if [ "$MACHINE" = "qemumicroblaze" ]; then 489config_qemuzynq() {
538 QEMU=qemu-system-microblazeel 490 set_mem_size 1024
539 QEMU_SYSTEM_OPTIONS="$QEMU_NETWORK_CMD -M petalogix-ml605 -serial mon:stdio" 491 QEMU=qemu-system-arm
492 QEMU_SYSTEM_OPTIONS="$QEMU_NETWORK_CMD -M xilinx-zynq-a9 -serial null -serial mon:stdio -dtb $KERNEL-$MACHINE.dtb"
493 # zynq serial ports are named 'ttyPS0' and 'ttyPS1', fixup the default values
494 SCRIPT_KERNEL_OPT=$(echo "$SCRIPT_KERNEL_OPT" | sed 's/console=ttyS/console=ttyPS/g')
540 if [ "${FSTYPE:0:3}" = "ext" -o "${FSTYPE:0:4}" = "cpio" ]; then 495 if [ "${FSTYPE:0:3}" = "ext" -o "${FSTYPE:0:4}" = "cpio" ]; then
541 KERNCMDLINE="earlyprintk root=/dev/ram rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" 496 KERNCMDLINE="earlyprintk root=/dev/ram rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
542 QEMUOPTIONS="$QEMU_SYSTEM_OPTIONS -initrd $ROOTFS" 497 QEMUOPTIONS="$QEMU_SYSTEM_OPTIONS -initrd $ROOTFS"
543 fi 498 fi
544fi 499}
545 500
546if [ "$MACHINE" = "qemuzynq" ]; then 501config_qemumicroblaze() {
547 QEMU=qemu-system-arm 502 set_mem_size 256
548 QEMU_SYSTEM_OPTIONS="$QEMU_NETWORK_CMD -M xilinx-zynq-a9 -serial null -serial mon:stdio -dtb $KERNEL-$MACHINE.dtb" 503 QEMU=qemu-system-microblazeel
549 # zynq serial ports are named 'ttyPS0' and 'ttyPS1', fixup the default values 504 QEMU_SYSTEM_OPTIONS="$QEMU_NETWORK_CMD -M petalogix-ml605 -serial mon:stdio"
550 SCRIPT_KERNEL_OPT=$(echo "$SCRIPT_KERNEL_OPT" | sed 's/console=ttyS/console=ttyPS/g')
551 if [ "${FSTYPE:0:3}" = "ext" -o "${FSTYPE:0:4}" = "cpio" ]; then 505 if [ "${FSTYPE:0:3}" = "ext" -o "${FSTYPE:0:4}" = "cpio" ]; then
552 KERNCMDLINE="earlyprintk root=/dev/ram rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" 506 KERNCMDLINE="earlyprintk root=/dev/ram rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
553 QEMUOPTIONS="$QEMU_SYSTEM_OPTIONS -initrd $ROOTFS" 507 QEMUOPTIONS="$QEMU_SYSTEM_OPTIONS -initrd $ROOTFS"
554 fi 508 fi
509}
510
511case "$MACHINE" in
512 "qemuarm" | "qemuarmv6" | "qemuarmv7")
513 config_qemuarm
514 ;;
515 "qemuarm64")
516 config_qemuarm64
517 ;;
518 "qemux86")
519 config_qemux86
520 ;;
521 "qemux86-64")
522 config_qemux86_64
523 ;;
524 "qemumips" | "qemumipsel" | "qemumips64")
525 config_qemumips
526 ;;
527 "qemuppc")
528 config_qemuppc
529 ;;
530 "qemush4")
531 config_qemush4
532 ;;
533 "qemuzynq")
534 config_qemuzynq
535 ;;
536 "qemumicroblaze")
537 config_qemumicroblaze
538 ;;
539 *)
540 echo "Error: Unsupported machine type $MACHINE"
541 return 1
542 ;;
543esac
544
545# We need to specify -m <mem_size> to overcome a bug in qemu 0.14.0
546# https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/584480
547if [ -z "$mem_set" ] ; then
548 SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT -m $mem_size"
549fi
550
551if [ "${FSTYPE:0:3}" = "ext" ]; then
552 KERNCMDLINE="$KERNCMDLINE rootfstype=$FSTYPE"
555fi 553fi
556 554
557if [ "$FSTYPE" = "cpio.gz" ]; then 555if [ "$FSTYPE" = "cpio.gz" ]; then