2 #include "sys/cpuinfo.h"
8 size_t cputemp_calibrate_value = 0;
15 bool is_temperature_module_present() {
16 if(cpu_get_id() ==
INTEL_MAGIC && get_max_cpuid_count() >= 6) {
17 uint32_t info[4] = {0};
26 return (
bool)(info[0] & 1);
36 void cputemp_calibrate() {
40 if(is_temperature_module_present()) {
41 rdmsr(INTEL_TEMPERATURE_TARGET, a, b);
42 cputemp_calibrate_value = (a >> 16) & 0x7F;
46 if (cputemp_calibrate_value < 50 || cputemp_calibrate_value > 125) {
47 cputemp_calibrate_value = 100;
57 size_t get_cpu_temperature() {
58 if(is_temperature_module_present()) {
62 rdmsr(INTEL_THERMAL_STATUS, a, b);
64 uint32_t absolute = (a >> 16) & 0x7F;
66 return cputemp_calibrate_value - absolute;
Основные определения ядра
#define INTEL_MAGIC
Ключ процессора Intel.