From d7053ddba00bddda9ea8c67a9f8dedd7a2fe91f6 Mon Sep 17 00:00:00 2001 From: malc Date: Sat, 1 Aug 2009 00:23:53 +0400 Subject: [PATCH] Wrapper for idlestat that takes care of module loading/device creation --- idlestat.run | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 idlestat.run diff --git a/idlestat.run b/idlestat.run new file mode 100755 index 0000000..4328746 --- /dev/null +++ b/idlestat.run @@ -0,0 +1,60 @@ +#!/bin/sh + +set -e + +dev="/dev/itc" + +function suX() { # remove X to enjoy sudo + shift + sudo $* +} + +! test `uname -s` = "Linux" && { + echo `uname -s` is not Linux + exit 1 +} + +case `uname -r | cut -d. -f1,2` in + 2.6) kms=ko; syms=/proc/kallsyms;; + 2.4) kms=o; syms=/proc/ksyms;; + *) echo "unknown kernel version"; exit 1;; +esac + + +test -e "build/itc.$kms" && kmod=build/itc.$kms +test -z "$kmod" && test -e "mod/itc.$kms" && kmod=mod/itc.$kms + +test -z "$kmod" && { + echo "Kernel module does not exist" + exit 1 +} + +idlestat=./idlestat +test -e "$idlestat" || idlestat="build/idlestat" +test -e "$idlestat" || { + echo "idlestat is not found in usual places" + exit 1 +} + +case `uname -m` in + i[3456]86) + func=$(awk '/default_idle$/ {print "0x" $1}' $syms) + args="idle_func=$func" + ;; + + *) + args= + ;; +esac + +if ! test -c $dev; then + echo "ITC kernel module is not running. Will try to load $kmod." + su -c "insmod $kmod $args" +fi + +if ! test -r $dev; then + echo "ITC is not readable. Will try to change mode." + su -c "chmod +r $dev" +fi + +$idlestat -- 2.11.4.GIT