2 * (C) 2003 - 2004 Dominik Brodowski <linux@dominikbrodowski.de>
4 * Licensed under the terms of the GNU GPL License version 2.
6 * Based on code found in
7 * linux/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
8 * and originally developed by Jeremy Fitzhardinge.
10 * USAGE: simply run it to decode the current settings on CPU 0,
11 * or pass the CPU number as argument, or pass the MSR content
22 #include <sys/types.h>
27 #define MSR_IA32_PERF_STATUS 0x198
29 static int rdmsr(unsigned int cpu
, unsigned int msr
,
30 unsigned int *lo
, unsigned int *hi
)
34 unsigned long long val
;
42 sprintf(file
, "/dev/cpu/%d/msr", cpu
);
43 fd
= open(file
, O_RDONLY
);
48 if (lseek(fd
, msr
, SEEK_CUR
) == -1)
51 if (read(fd
, &val
, 8) != 8)
54 *lo
= (uint32_t )(val
& 0xffffffffull
);
55 *hi
= (uint32_t )(val
>>32 & 0xffffffffull
);
64 static void decode (unsigned int msr
)
66 unsigned int multiplier
;
69 multiplier
= ((msr
>> 8) & 0xFF);
71 mv
= (((msr
& 0xFF) * 16) + 700);
73 printf("0x%x means multiplier %d @ %d mV\n", msr
, multiplier
, mv
);
76 static int decode_live(unsigned int cpu
)
81 err
= rdmsr(cpu
, MSR_IA32_PERF_STATUS
, &lo
, &hi
);
84 printf("can't get MSR_IA32_PERF_STATUS for cpu %d\n", cpu
);
85 printf("Possible trouble: you don't run an Enhanced SpeedStep capable cpu\n");
86 printf("or you are not root, or the msr driver is not present\n");
95 int main (int argc
, char **argv
)
97 unsigned int cpu
, mode
= 0;
102 cpu
= strtoul(argv
[1], NULL
, 0);