-
Notifications
You must be signed in to change notification settings - Fork 98
/
funcs.sh
executable file
·147 lines (138 loc) · 2.04 KB
/
funcs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#useful functions
OS=`cat os`
CPU=`cat cpu`
ABI=`cat abi`
function zero_pad
{
if [ $1 -lt 100 ]
then
zp="0$1"
else
zp=$1
fi
if [ $zp -lt 10 ]
then
zp="0$zp"
fi
}
function add_link
{
zero_pad $(($1 + $base_cpu))
l1=$zp
zero_pad $(($2 + $base_cpu))
l2=$zp
if [ $l1 != $l2 ]
then
if [ $l1 -lt $l2 ]
then
nl=$l1-$l2
else
nl=$l2-$l1
fi
if [[ "$links" != *"$nl"* ]]
then
links+="-l $nl "
fi
fi
}
function wrap
{
wp=$(($1 % $num_cpu))
if [ $wp -lt 0 ]
then
wp=$(($wp + $num_cpu))
fi
}
function boot_cpu_gui
{
if [ $1 -lt 1 ]
then
if [ "$front" == "" ]
then
./obj/$CPU/$ABI/$OS/main_gui obj/$CPU/$ABI/sys/boot_image $2 $emu -run gui/gui/gui.lisp &
else
./obj/$CPU/$ABI/$OS/main_gui obj/$CPU/$ABI/sys/boot_image $2 $emu -run gui/gui/gui.lisp
if [ $? -eq 0 ]
then
{
./stop.sh
} &> /dev/null
clear
fi
fi
else
./obj/$CPU/$ABI/$OS/main_gui obj/$CPU/$ABI/sys/boot_image $2 $emu &
fi
}
function boot_cpu_tui
{
if [ $1 -lt 1 ]
then
if [ "$front" == "" ]
then
./obj/$CPU/$ABI/$OS/main_tui obj/$CPU/$ABI/sys/boot_image $2 $emu -run $script
else
./obj/$CPU/$ABI/$OS/main_tui obj/$CPU/$ABI/sys/boot_image $2 $emu -run $script
if [ $? -eq 0 ]
then
{
./stop.sh
} &> /dev/null
fi
fi
else
./obj/$CPU/$ABI/$OS/main_tui obj/$CPU/$ABI/sys/boot_image $2 $emu &
fi
}
function main
{
num_cpu=$1
max_cpu=$2
shift 2
base_cpu=0
emu=""
front=""
script="apps/tui/tui.lisp"
while [ "$#" -gt 0 ]; do
case $1 in
-i)
script="apps/tui/install.lisp";
shift
;;
-e)
emu=$1;
shift
;;
-f)
front=$1;
shift
;;
-n)
num_cpu=$2
shift 2
;;
-b)
base_cpu=$2
shift 2
;;
*) echo "[-n cnt] number of nodes"
echo "[-b base] base offset"
echo "[-e] emulator mode"
echo "[-f] foreground mode"
echo "[-h] help"
num_cpu=0
break
;;
esac
done
#not greater than $max_cpu
if [ $num_cpu -gt $max_cpu ]
then
num_cpu=$max_cpu
fi
#shutdown all nodes if base is 0
if [ $base_cpu -eq 0 ]
then
./stop.sh
fi
}