Linux 4.19.133
[linux/fpc-iii.git] / samples / mic / mpssd / micctrl
blob8f2629b41c5f5167be37fd3e7dee74dc9b67d2a6
1 #!/bin/bash
2 # Intel MIC Platform Software Stack (MPSS)
4 # Copyright(c) 2013 Intel Corporation.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License, version 2, as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # The full GNU General Public License is included in this distribution in
16 # the file called "COPYING".
18 # Intel MIC User Space Tools.
20 # micctrl - Controls MIC boot/start/stop.
22 # chkconfig: 2345 95 05
23 # description: start MPSS stack processing.
25 ### BEGIN INIT INFO
26 # Provides: micctrl
27 ### END INIT INFO
29 # Source function library.
30 . /etc/init.d/functions
32 sysfs="/sys/class/mic"
34 _status()
36 f=$sysfs/$1
37 echo -e $1 state: "`cat $f/state`" shutdown_status: "`cat $f/shutdown_status`"
40 status()
42 if [ "`echo $1 | head -c3`" == "mic" ]; then
43 _status $1
44 return $?
46 for f in $sysfs/*
48 _status `basename $f`
49 RETVAL=$?
50 [ $RETVAL -ne 0 ] && return $RETVAL
51 done
52 return 0
55 _reset()
57 f=$sysfs/$1
58 echo reset > $f/state
61 reset()
63 if [ "`echo $1 | head -c3`" == "mic" ]; then
64 _reset $1
65 return $?
67 for f in $sysfs/*
69 _reset `basename $f`
70 RETVAL=$?
71 [ $RETVAL -ne 0 ] && return $RETVAL
72 done
73 return 0
76 _boot()
78 f=$sysfs/$1
79 echo "linux" > $f/bootmode
80 echo "mic/uos.img" > $f/firmware
81 echo "mic/$1.image" > $f/ramdisk
82 echo "boot" > $f/state
85 boot()
87 if [ "`echo $1 | head -c3`" == "mic" ]; then
88 _boot $1
89 return $?
91 for f in $sysfs/*
93 _boot `basename $f`
94 RETVAL=$?
95 [ $RETVAL -ne 0 ] && return $RETVAL
96 done
97 return 0
100 _shutdown()
102 f=$sysfs/$1
103 echo shutdown > $f/state
106 shutdown()
108 if [ "`echo $1 | head -c3`" == "mic" ]; then
109 _shutdown $1
110 return $?
112 for f in $sysfs/*
114 _shutdown `basename $f`
115 RETVAL=$?
116 [ $RETVAL -ne 0 ] && return $RETVAL
117 done
118 return 0
121 _wait()
123 f=$sysfs/$1
124 while [ "`cat $f/state`" != "offline" -a "`cat $f/state`" != "online" ]
126 sleep 1
127 echo -e "Waiting for $1 to go offline"
128 done
131 wait()
133 if [ "`echo $1 | head -c3`" == "mic" ]; then
134 _wait $1
135 return $?
137 # Wait for the cards to go offline
138 for f in $sysfs/*
140 _wait `basename $f`
141 RETVAL=$?
142 [ $RETVAL -ne 0 ] && return $RETVAL
143 done
144 return 0
147 if [ ! -d "$sysfs" ]; then
148 echo -e $"Module unloaded "
149 exit 3
152 case $1 in
154 status $2
157 reset $2
160 boot $2
163 shutdown $2
166 wait $2
169 echo $"Usage: $0 {-s (status) |-r (reset) |-b (boot) |-S (shutdown) |-w (wait)}"
170 exit 2
171 esac
173 exit $?