1 /*
2 * Licensed under the terms of the GNU GPL License version 2.
3 */
4
5 #include <stdio.h>
6 #include <unistd.h>
7 #include <sys/types.h>
8 #include <x86info.h>
9 #include "intel.h"
10
dump_thermal_msrs(struct cpudata * cpu)11 void dump_thermal_msrs(struct cpudata *cpu)
12 {
13 unsigned long long val = 0;
14
15 if (!user_is_root)
16 return;
17
18 if (read_msr(cpu->number, MSR_IA32_MISC_ENABLE, &val) != 1)
19 return;
20
21 // tcc enabled ?
22 if (!(val & (1<<3)))
23 return;
24
25 printf("Thermal msrs:\n");
26 if (read_msr(cpu->number, MSR_PM_THERM2_CTL, &val) == 1) { /* THERM2_CTL */
27 printf(" MSR_PM_THERM2_CTL: 0x%llx [Thermal monitor: %d]\n",
28 val, (val & (1<<16)) ? 2 : 1);
29 }
30 if (read_msr(cpu->number, MSR_IA32_THERM_CONTROL, &val) == 1) {
31 printf(" MSR_IA32_THERM_CONTROL: 0x%llx ", val);
32 if (val & (1<<4)) {
33 printf("[Software-controlled clock: %f%% duty cycle]\n",
34 ((val >> 1) & 7) / 8.);
35 } else
36 printf("[Software-controlled clock disabled (full speed)]\n");
37 }
38 if (read_msr (cpu->number, MSR_IA32_THERM_STATUS, &val) == 1) { /* THERM_STATUS */
39 printf(" MSR_IA32_THERM_STATUS: 0x%llx", val);
40 if (val & (1<<0|1<<1)) {
41 printf(" [");
42 if (val & (1<<0))
43 printf("TooHot ");
44 if (val & (1<<1))
45 printf("WasTooHot ");
46 printf("]");
47 }
48 printf("\n");
49 }
50 printf("\n");
51 }
52