simple_bootscript.rcS revision 11291:9d2364203316
1#!/bin/bash
2
3
4#
5# Copyright (c) 2015 ARM Limited
6# All rights reserved
7#
8# The license below extends only to copyright in the software and shall
9# not be construed as granting a license to any other intellectual
10# property including but not limited to intellectual property relating
11# to a hardware implementation of the functionality of the software
12# licensed hereunder.  You may use the software subject to the license
13# terms below provided that you ensure that this notice is replicated
14# unmodified and in its entirety in all distributions of the software,
15# modified or unmodified, in source code or in binary form.
16#
17# Redistribution and use in source and binary forms, with or without
18# modification, are permitted provided that the following conditions are
19# met: redistributions of source code must retain the above copyright
20# notice, this list of conditions and the following disclaimer;
21# redistributions in binary form must reproduce the above copyright
22# notice, this list of conditions and the following disclaimer in the
23# documentation and/or other materials provided with the distribution;
24# neither the name of the copyright holders nor the names of its
25# contributors may be used to endorse or promote products derived from
26# this software without specific prior written permission.
27#
28# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39#
40# Authors: Gabor Dozsa
41#
42#
43# This is an example boot script to use for dist-gem5 runs. The important
44# task here is to extract the rank and size information through the m5
45# initparam utility and use those to configure MAC/IP addresses and hostname.
46#
47# You are expected to customize this scipt for your needs (e.g. change
48# the command at the end of the scipt to run your tests/workloads.
49
50source /root/.bashrc
51echo "bootscript.rcS is running"
52
53# Retrieve dist-gem5 rank and size parameters using the 'm5' utility
54MY_RANK=$(/sbin/m5 initparam dist-rank)
55[ $? = 0 ] || { echo "m5 initparam failed"; exit -1; }
56MY_SIZE=$(/sbin/m5 initparam dist-size)
57[ $? = 0 ] || { echo "m5 initparam failed"; exit -1; }
58
59/bin/hostname node${MY_RANK}
60
61# Keep MAC address assignment simple for now ...
62(($MY_RANK > 97)) && { echo "(E) Rank must be less than 98"; /sbin/m5 abort; }
63((MY_ADDR = MY_RANK + 2))
64if (($MY_ADDR < 10))
65then
66    MY_ADDR_PADDED=0${MY_ADDR}
67else
68    MY_ADDR_PADDED=${MY_ADDR}
69fi
70
71/sbin/ifconfig eth0 hw ether 00:90:00:00:00:${MY_ADDR_PADDED}
72/sbin/ifconfig eth0 192.168.0.${MY_ADDR} netmask 255.255.255.0 up
73
74/sbin/ifconfig -a
75
76echo "Hello from $MY_RANK of $MY_SIZE"
77
78# Now that our network interface is configured we can use the usual commands to
79# contact the other systems, e.g. let's try to ping a "neighbour" system
80if ((MY_RANK < MY_SIZE - 1))
81then
82    ping -c 1 192.168.0.$((MY_ADDR + 1))
83else
84    ping -c 1 192.168.0.2
85fi
86
87
88if [ "$MY_RANK" == "0" ]
89then
90    # Trigger an immediate checkpoint at the next sync (by passing a non-zero
91    # delay param to m5 ckpt)
92    /sbin/m5 checkpoint 1
93    echo "A real multi node workload might start here ..."
94    # Trigger an immediate exit at the next sync (by passing a non-zero delay
95    # param to m5 exit)
96    /sbin/m5 exit 1
97else
98    # This is to avoid other (rank!=0) gem5 processes exiting
99    # before the test (started by rank 0) completes. When rank 0 completes the
100    # test it will exit and that will trigger a notification to all the peer
101    # gem5 processes to stop the simulation.
102    echo "sleep forever..."
103    while /bin/true
104    do
105	sleep 5
106    done
107fi
108