CloverBootloader/Qemu/launch_from_eclipse

117 lines
2.5 KiB
Plaintext
Raw Normal View History

2020-03-09 10:13:38 +01:00
#!/bin/bash
SCRIPT_ABS_FILENAME=`LC_ALL=en_US.ISO8859-1 perl -e 'use Cwd "abs_path";print abs_path(shift)' "${BASH_SOURCE[0]}"`
SCRIPT_DIR=`dirname "$SCRIPT_ABS_FILENAME"`
2020-08-22 15:40:24 +02:00
#SCRIPT_DIR="$(pwd)" # copy in terminal to be able to copy and paste command from this file
2020-03-09 10:13:38 +01:00
OSTYPE=`uname -s`
echo $OSTYPE
#env
#echo "$@"
project_dir="$1"
echo project_dir="$project_dir"
executable="$2"
echo executable="$executable"
executable_name=$(basename "$executable")
echo executable_name="$executable_name"
cd "$SCRIPT_DIR"
if [ "$OSTYPE" = "Linux" ]
then
: # todo
fi
set -x
if [ "$OSTYPE" = "Darwin" ]
then
if pgrep qemu
then
killall qemu-system-x86_64
fi
2020-08-22 15:40:24 +02:00
> ./serial0_qemu_out.log # empty file without erasing it. Useful for editor for refreshing and reloading.
2020-03-09 10:13:38 +01:00
2020-08-22 15:40:24 +02:00
hdiutil attach ./disk_image_gpt.img || exit 1
2020-03-09 13:16:31 +01:00
shopt -s nocasematch
2020-03-09 10:13:38 +01:00
if [[ "$executable_name" == "CloverX64"* ]]
then
echo ditto "$project_dir"/"${executable%.*}".efi /Volumes/QEMU_EFI/EFI/CLOVER/CLOVERX64.efi
ditto "$project_dir"/"${executable%.*}".efi /Volumes/QEMU_EFI/EFI/CLOVER/CLOVERX64.efi || exit 1
echo ditto "$project_dir"/"${executable%.*}".efi /Volumes/QEMU_EFI/EFI/BOOT/BOOTX64.efi
ditto "$project_dir"/"${executable%.*}".efi /Volumes/QEMU_EFI/EFI/BOOT/BOOTX64.efi || exit 1
else
: # if it's a module, has to be copied in Drivers
fi
2020-03-09 13:16:31 +01:00
shopt -u nocasematch
2020-03-09 10:13:38 +01:00
diskutil eject /Volumes/QEMU_EFI || exit 1
2020-03-09 13:16:31 +01:00
2020-08-22 15:40:24 +02:00
./qemu_portable/qemu-system-x86_64 \
-L qemu_portable \
2020-03-09 13:16:31 +01:00
-m 2048 \
-cpu core2duo \
2020-08-22 15:40:24 +02:00
-bios bios.bin-1.13.0 \
2020-03-09 13:16:31 +01:00
-machine q35 \
-device VGA,vgamem_mb=64,edid=on,xres=1024,yres=768 \
-device ahci,id=ahi \
2020-08-22 15:40:24 +02:00
-drive format=raw,id=hda,file=./disk_image_gpt.img \
2020-03-09 13:16:31 +01:00
-usb \
-device usb-mouse,bus=usb-bus.0,port=2 \
-device usb-kbd,bus=usb-bus.0,port=1 \
2020-08-22 15:40:24 +02:00
-serial file:./serial0_qemu_out.log \
-nic none \
2020-03-09 13:16:31 +01:00
-gdb tcp::9000 &
[[ $? -eq 0 ]] || exit 1
2020-03-09 10:13:38 +01:00
count=1
timeout=60
image_base_str="Clover : Image base = "
getImageBase() {
2020-08-22 15:40:24 +02:00
[ -f ./serial0_qemu_out.log ] || return 1
grep "$image_base_str" ./serial0_qemu_out.log
2020-03-09 10:13:38 +01:00
return $?
}
while [ $count -le $timeout ] && ! getImageBase
do
sleep 1
count=$((count+1))
done
if [ $count -ge $timeout ]
then
2020-08-22 15:40:24 +02:00
echo Cannot find "\"Clover : Image base = \"" in ./serial0_qemu_out.log after $timeout seconds
2020-03-09 10:13:38 +01:00
exit 1
fi
2020-08-22 15:40:24 +02:00
adr="$(grep "$image_base_str" ./serial0_qemu_out.log | awk '{printf "0x%x",$8/NR}')"
2020-03-09 10:13:38 +01:00
echo adr="$adr"
echo ovh.knudsen.jf.launch.vmware.efi.adr="$adr"
exit 0
fi
# Windows ???
#if [ "$OSTYPE" = "FreeBSD" ]
#then
#fi