1#!/bin/bash
2##########################################################################
3# Copyright (c) 2016, ETH Zurich.
4# All rights reserved.
5#
6# This file is distributed under the terms in the attached LICENSE file.
7# If you do not find this file, copies can be found by writing to:
8# ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
9##########################################################################
10
11# Rudimentary wrapper script to boot ARM GEM5 with a Barrelfish image.
12
13if [ "$#" -lt 2 ] ; then
14    echo "*** Usage: $0 <machine-type> <boot-image-file> [<m5-path> <port>]"
15    exit 1
16fi
17
18export MACHINE="$1" 
19export KERNEL=$(realpath $2)
20
21PORT=
22
23if [ "$#" -gt 2 ] ; then
24    if [ "$#" -lt 4 ] ; then
25        echo "*** Usage: $0 <machine-type> <boot-image-file> [<m5-path> <port>]"
26        exit 1
27    fi
28
29    export M5_PATH=$(realpath $3)
30    PORT="--dist-server-port=$4"
31fi
32
33if [ -z "$M5_PATH" ]; then
34    echo "*** Error: M5_PATH variable not set."
35    echo "    Please set M5_PATH to be the pathname of the GEM5 build directory"
36    echo "    (i.e. the directory containing LICENSE, build, READ, etc.)"
37    exit 1
38fi
39
40export M5_DIR="$M5_PATH"
41export M5=$M5_DIR/build/ARM/gem5.fast
42
43exec "$M5" "$M5_DIR/configs/example/fs.py" \
44    --bare-metal \
45    --kernel="$KERNEL" \
46    --machine-type="$MACHINE" \
47    --disk-image="$M5_DIR/disks/linux-aarch32-ael.img" \
48    --mem-type=SimpleMemory \
49    --mem-size=512MB \
50    $PORT
51