FreeBSD/aarch64 in Gem5 simulator
The gem5 simulator is a modular platform for computer system architecture research, encompassing system-level architecture as well as processor microarchitecture.
Build instructions
0. Preparation
$ export WORKDIR=~/gem5-test $ mkdir $WORKDIR $ cd $WORKDIR $ git clone https://github.com/bukinr/aarch64-tools.git $ git clone https://gem5.googlesource.com/public/gem5 $ svnlite co http://svn.freebsd.org/base/head
1. Build Gem5 Simulator System
$ cd $WORKDIR/gem5 $ export SWIG=/usr/local/bin/swig2.0 $ export CXX=c++ # use -j <n> as appropriate for your machine $ scons -j 16 build/ARM/gem5.opt $ gmake -C util/term
2. Build FreeBSD
$ cd $WORKDIR/head $ cat $WORKDIR/aarch64-tools/gem5/freebsd_gem5.patch | patch -p0 $ sh $WORKDIR/aarch64-tools/arm64_build.sh $WORKDIR/head
3. Make symlinks
$ mkdir $WORKDIR/gem5/binaries $WORKDIR/gem5/disks $ ln -s $WORKDIR/aarch64-tools/gem5/aarch64_gem5.dtb $WORKDIR/gem5/binaries/ $ ln -s $WORKDIR/aarch64-tools/gem5/boot_emm.arm64 $WORKDIR/gem5/binaries/ $ ln -s ~/arm64-workspace/obj/arm64.aarch64/usr/home/$USER/gem5-test/head/sys/GENERIC/kernel $WORKDIR/gem5/binaries/ $ ln -s ~/arm64-workspace/rootfs/disk.img $WORKDIR/gem5/disks/
Running in Full System mode
$ cd $WORKDIR/gem5 $ export M5_PATH=$WORKDIR/gem5 $ ./build/ARM/gem5.opt --debug-flags=-Exec configs/example/fs.py --kernel=kernel --machine-type=VExpress_EMM64 --dtb-file=aarch64_gem5.dtb --disk-image=disk.img --mem-size=256MB $ (from another console) ./util/term/m5term 3456
Running in Syscall Emulation mode
$ cd $WORKDIR/gem5 $ export M5_PATH=$WORKDIR/gem5 $ ./build/ARM/gem5.opt --debug-flags=-Loader,-Exec,-Faults,-SyscallVerbose,-TLBVerbose configs/example/se.py -c your_app
Known problems
- Simulation speed is slow. It takes ~1 hour to boot freebsd in FS mode
- UART driver needs to be fixed