Module for 3.x kernels
[apc.git] / idlestat.run
blobca7240cc5a2138f5a08341090bd091ba585a2b7a
1 #!/bin/sh
3 set -e
5 dev="/dev/itc"
7 suX() { # remove X to enjoy sudo
8 shift
9 sudo $*
12 ! test `uname -s` = "Linux" && {
13 echo `uname -s` is not Linux
14 exit 1
17 case `uname -r | cut -d. -f1,2` in
18 2.6) kms=ko; syms=/proc/kallsyms;;
19 2.4) kms=o; syms=/proc/ksyms;;
20 *) echo "unknown kernel version"; exit 1;;
21 esac
24 test -e "build/itc.$kms" && kmod=build/itc.$kms
25 test -z "$kmod" && test -e "mod/itc.$kms" && kmod=mod/itc.$kms
27 test -z "$kmod" && {
28 echo "Kernel module does not exist"
29 exit 1
32 idlestat=./idlestat
33 test -e "$idlestat" || idlestat="build/idlestat"
34 test -e "$idlestat" || {
35 echo "idlestat is not found in usual places"
36 exit 1
39 case `uname -m` in
40 i[3456]86)
41 func=$(awk '/default_idle$/ {print "0x" $1}' $syms)
42 args="idle_func=$func"
46 args=
48 esac
50 if ! test -c $dev; then
51 echo "ITC kernel module is not running. Will try to load $kmod."
52 su -c "insmod $kmod $args"
55 if ! test -r $dev; then
56 echo "ITC is not readable. Will try to change mode."
57 su -c "chmod +r $dev"
60 $idlestat