[TOOLCHAIN] Setup for emulation
This commit is contained in:
parent
94999611d4
commit
1f8d5b3482
4
.gitignore
vendored
4
.gitignore
vendored
@ -1 +1,5 @@
|
||||
toolchain/
|
||||
sysroot/
|
||||
*.iso
|
||||
*.img
|
||||
*.log
|
||||
|
7
Makefile
7
Makefile
@ -4,7 +4,12 @@ ifeq ($(MITTOS64),)
|
||||
$(error Build environment is not activated. Please source activate)
|
||||
endif
|
||||
|
||||
.PHONY: all
|
||||
.PHONY: all clean
|
||||
SHELL := bash
|
||||
|
||||
all:
|
||||
|
||||
clean:
|
||||
@(. util/helpers.sh; print_info "Cleaning up")
|
||||
rm -f mittos64.iso
|
||||
rm -f qemu-error.log
|
||||
|
24
README.md
24
README.md
@ -19,3 +19,27 @@ automatically if you install homebrew. The rest of the packages can be
|
||||
installed with homebrew. You'll also want homebrews ctags.
|
||||
|
||||
homebrew install gmp mpfr libmpc ctags
|
||||
|
||||
In order to build the boot disk and run the emulator you'll need xorriso and
|
||||
qemu - also installable by homebrew.
|
||||
|
||||
homebrew install xorriso qemu
|
||||
|
||||
|
||||
A note on qemu and compatibility
|
||||
--------------------------------
|
||||
I have had great trouble with qemu, gdb and the x86_64 structure in cobination.
|
||||
For now, everything seem to work in the setup I'm using if the installed
|
||||
version of qemu is commit: a470b33259bf82ef2336bfcd5d07640562d3f63b built with
|
||||
--enable-curses.
|
||||
You may need to remove the check for wide character support in the qemu
|
||||
./configure file if building under OSX with homebrew (e.g. by deleting lines:
|
||||
2953, 2954, 2956, 2957, 2958)
|
||||
|
||||
This is tested for GDB 7.12.
|
||||
|
||||
Among the problems that may arise if wrong versions are used are:
|
||||
|
||||
- g-packet something something too large in gdb
|
||||
- gdb thinking sizeof(void *) == 4 even in 64 bit mode, meaning no variables can be viewed, because their addresses are truncated to 32 bits
|
||||
- qemu crashing when a keyboard irq is received
|
||||
|
1
activate
1
activate
@ -7,6 +7,7 @@ export MITTOS64=mittos64
|
||||
. util/helpers.sh
|
||||
|
||||
export BUILDROOT=`pwd`
|
||||
export SYSROOT=${BUILDROOT}/sysroot
|
||||
export TOOLCHAIN=${BUILDROOT}/toolchain
|
||||
export PATH=${TOOLCHAIN}/bin:${PATH}
|
||||
export TARGET=x86_64-elf
|
||||
|
93
emul
Executable file
93
emul
Executable file
@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -z ${TOOLCHAIN+x} ]]; then
|
||||
echo TOOLCHAIN is not set. Please source activate
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function print_help() {
|
||||
cat << EOF
|
||||
emul [-gvdh]
|
||||
|
||||
Runs emulator
|
||||
|
||||
-g
|
||||
Run with graphics window
|
||||
Can also be invoked by setting EMULGFX
|
||||
-v
|
||||
Run in vnc mode
|
||||
Can also be invoked by setting EMULVNC
|
||||
Open a listening client to port 5909 to connect
|
||||
-d
|
||||
DON'T run gdb debugger
|
||||
Can also be invoked by setting EMULNDEBUG
|
||||
-h
|
||||
Display help message
|
||||
EOF
|
||||
}
|
||||
|
||||
function main() {
|
||||
|
||||
EMULGFX="${EMULGFX+x}"
|
||||
EMULVNC="${EMULVNC+x}"
|
||||
EMULNDEBUG="${EMULNDEBUG+x}"
|
||||
|
||||
local monitorwin=""
|
||||
|
||||
while getopts "gvdh" OPTION; do
|
||||
case ${OPTION} in
|
||||
g)
|
||||
readonly EMULGFX=1
|
||||
;;
|
||||
v)
|
||||
readonly EMULVNC=1
|
||||
;;
|
||||
d)
|
||||
readonly EMULNDEBUG=1
|
||||
;;
|
||||
h)
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ $1 = "--" ]] && shift
|
||||
EMULPARAM=("$@")
|
||||
|
||||
make all || exit 1
|
||||
util/build_iso.sh || exit 1
|
||||
emulator="qemu-system-x86_64 -cdrom mittos64.iso ${EMULPARAM[@]}"
|
||||
debugger=$(which x86_64-elf-linux-gdb)
|
||||
|
||||
if [[ (-n ${EMULVNC}) ]]; then
|
||||
# A bug in qemu means the reverse port does not work as written in the man pages
|
||||
# :X,reverse will open a reverse connection on DISPLAY X, not PORT X
|
||||
# i.e. PORT 5900+X
|
||||
emulator="${emulator} -vnc :9,reverse"
|
||||
fi
|
||||
|
||||
if [[ (-n ${EMULVNC}) || (-n ${EMULGFX}) ]]; then
|
||||
emulator="${emulator} -monitor stdio"
|
||||
fi
|
||||
|
||||
if [[ (-z ${EMULNDEBUG}) ]]; then
|
||||
emulator="${emulator} -s -S"
|
||||
fi
|
||||
|
||||
if [[ (-z ${EMULVNC}) && (-z ${EMULGFX}) && (-n "${TMUX+x}") ]]; then
|
||||
emulator="${emulator} -curses"
|
||||
fi
|
||||
|
||||
if [[ -n "${TMUX}" ]]; then
|
||||
emulwindow=`tmux new-window -P -n "osdevemul" "${emulator} 2>qemu-error.log; tmux kill-window -t osdevemul"`
|
||||
if [[ -z ${EMULDEBUG} ]]; then
|
||||
debugpane=`tmux split-window -P -h -t ${emulwindow} "sleep 1; ${debugger}"`
|
||||
fi
|
||||
else
|
||||
${emulator}
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
main "${@}"
|
30
util/build_iso.sh
Executable file
30
util/build_iso.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
. util/helpers.sh
|
||||
|
||||
function fail() {
|
||||
print_error "Something went wrong"
|
||||
die "Building boot iso failed"
|
||||
}
|
||||
|
||||
SYSROOT=${SYSROOT-${BUILDROOT}/sysroot}
|
||||
|
||||
function collect() {
|
||||
print_info "Collecting sysroot"
|
||||
|
||||
mkdir -p ${SYSROOT}
|
||||
|
||||
# Grub menu configuration
|
||||
mkdir -p ${SYSROOT}/boot/grub
|
||||
cp ${BUILDROOT}/util/grub.cfg ${SYSROOT}/boot/grub/grub.cfg
|
||||
}
|
||||
|
||||
function mkimage() {
|
||||
print_info "Making boot disk"
|
||||
grub-mkrescue -o ${BUILDROOT}/mittos64.iso ${SYSROOT}
|
||||
}
|
||||
|
||||
collect
|
||||
mkimage
|
6
util/grub.cfg
Normal file
6
util/grub.cfg
Normal file
@ -0,0 +1,6 @@
|
||||
set timeout=0
|
||||
set default=0
|
||||
|
||||
menuentry "mittos64" {
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user