4 if [ "$1" = set ]; then
7 for i
in $
(< /proc
/cmdline
); do
10 for i
in /sys
/devices
/system
/cpu
/cpu
*/cpufreq
/phc_vids
; do
22 if [ -z "$VIDS" ]; then
23 printhl
'Please edit /etc/conf.d/phc-k8'
26 stat_busy
'Setting PHC VIDs'
27 for i
in /sys
/devices
/system
/cpu
/cpu
*/cpufreq
/phc_vids
; do
29 done && stat_done || stat_fail
32 stat_busy
'Resetting default PHC VIDs'
33 for i
in /sys
/devices
/system
/cpu
/cpu
*/cpufreq
; do
34 [ -e "$i/phc_default_vids" -a -e "$i/phc_vids" ] && cat "$i/phc_default_vids" > "$i/phc_vids"
35 done && stat_done || stat_fail
39 for i
in /sys
/devices
/system
/cpu
/cpu
*/cpufreq
; do
40 [ "$(< $i/phc_vids)" = "$(< $i/phc_default_vids)" ] ||
return;
44 for i
in /sys
/devices
/system
/cpu
/cpu
*/cpufreq
/phc_vids
; do
45 [[ "$(< $i)" =~
"$VIDS" ]] ||
return;
48 stat_busy
'PHC status'
49 .
/etc
/conf.d
/phc-intel
59 LOG
='/var/log/phc-k8.log'
62 printhl
"Look at $LOG to find out what went wrong"
65 stat_busy
'Removing old phc-k8 modules'
66 for i
in /lib
/modules
/*; do
67 if [ -f "$i/phc-k8.ko" -a ! -f "$i/version" ]; then
68 rm -f "$i"/{mperf
,phc-k8
}.ko
69 rmdir --ignore-fail-on-non-empty "$i"
70 elif [ -d "$i/updates/kernel/arch/x86/kernel/cpu/cpufreq" -a ! -d "$i/kernel" ]; then
71 rm -f "$i"/updates
/kernel
/arch
/x86
/kernel
/cpu
/cpufreq
/{mperf
,phc-k8
}.ko
72 rmdir -p --ignore-fail-on-non-empty "$i/updates/kernel/arch/x86/kernel/cpu/cpufreq"
76 stat_busy
'Compiling new phc-k8 module'
78 make &>$LOG && stat_done || fail
79 stat_busy
'Installing new phc-k8 module'
80 make install &>>$LOG && stat_done || fail
81 stat_busy
'Cleaning up'
82 make clean
&>>$LOG && stat_done || fail
85 echo "usage: $0 {start|stop|status|setup|set}"