Go to some lengths to obtain idle_func address
[apc.git] / apc-linux.run
blobd3a8193bda18bf9dfd0d352e84a8f18017b14549
1 #!/bin/sh
3 set -e
5 dev="/dev/itc"
7 ! test `uname -s` = "Linux" && {
8 echo `uname -s` is not Linux
9 exit 1
12 case `uname -r | cut -d. -f1,2` in
13 2.6) kms=ko; syms=/proc/kallsyms;;
14 2.4) kms=o; syms=/proc/ksyms;;
15 *) echo "unknown kernel version"; exit 1;;
16 esac
19 test -e "build/itc.$kms" && kmod=build/itc.$kms
20 test -z "$kmod" && test -e "mod/itc.$kms" && kmod=mod/itc.$kms
22 test -z "$kmod" && {
23 echo "Kernel module does not exist"
24 exit 1
27 case `uname -m` in
28 i[3456]86)
29 func=$(awk '/default_idle$/ {print "0x" $1}' $syms)
30 args="idle_func=$func"
34 args=
36 esac
38 if ! test -c $dev; then
39 echo "ITC kernel module is not running. Will try to load $kmod."
40 su -c "insmod $kmod $args"
43 if ! test -r $dev; then
44 echo "ITC is not readable. Will try to change mode."
45 su -c "chmod +r $dev"
48 ./apc -d $dev & disown
49 echo "apc should be running now"