run_qemu.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. # This script starts a bootable image in QEMU using legacy BIOS boot.
  3. # http://redsymbol.net/articles/unofficial-bash-strict-mode/
  4. set -euo pipefail
  5. IFS=$'\n\t'
  6. DIR=$(dirname "$(realpath "$0")")
  7. cd "$DIR" || exit
  8. BINS_DIR="../../bins/target/x86-unknown-none/release"
  9. CHAINLOADER="$BINS_DIR/multiboot2_chainloader"
  10. PAYLOAD="$BINS_DIR/multiboot2_payload"
  11. # add "-d int \" to debug CPU exceptions
  12. # "-display none" is necessary for the CI but locally the display and the
  13. # combat monitor are really helpful
  14. set +e
  15. qemu-system-x86_64 \
  16. -kernel "$CHAINLOADER" \
  17. -append "chainloader" \
  18. -initrd "$PAYLOAD multiboot2 payload" \
  19. -m 24m \
  20. -debugcon stdio \
  21. -no-reboot \
  22. -device isa-debug-exit,iobase=0xf4,iosize=0x04 \
  23. -display none `# relevant for the CI`
  24. EXIT_CODE=$?
  25. # Custom exit code used by the integration test to report success.
  26. QEMU_EXIT_SUCCESS=73
  27. echo "#######################################"
  28. if [[ $EXIT_CODE -eq $QEMU_EXIT_SUCCESS ]]; then
  29. echo "SUCCESS - Integration Test 'multiboot2-header'"
  30. exit 0
  31. else
  32. echo "FAILED - Integration Test 'multiboot2-header'"
  33. exit "$EXIT_CODE"
  34. fi