Files
SUB-OS/drivers/hwmon/coretemp.c
T

34 lines
1.0 KiB
C

#include <drivers/hwmon.h>
#include <arch/x86_64/pit.h>
#include <lib/string.h>
#include <kernel/printk.h>
static hwmon_data_t hw_data;
void hwmon_init(void) {
memset(&hw_data, 0, sizeof(hw_data));
strcpy(hw_data.chip_name, "coretemp-isa-0000");
hw_data.cpu_temp_celsius = 42;
hw_data.ambient_temp_celsius = 28;
hw_data.fan_rpm = 1850;
hw_data.vcore_millivolts = 1180; // 1.18V
hw_data.v12_millivolts = 12050; // 12.05V
hw_data.v5_millivolts = 5020; // 5.02V
hw_data.initialized = true;
printk(KERN_INFO "HWMON: CoreTemp DTS & Sensor Subsystem online (%s: %d C, Fan: %u RPM)\n",
hw_data.chip_name, hw_data.cpu_temp_celsius, hw_data.fan_rpm);
}
void hwmon_refresh(void) {
uint64_t ticks = pit_get_ticks();
// Simulate realistic dynamic temperature drift based on CPU load and time
hw_data.cpu_temp_celsius = 40 + (int32_t)((ticks / 20) % 8);
hw_data.fan_rpm = 1800 + (uint32_t)((ticks * 7) % 250);
}
const hwmon_data_t* hwmon_get_data(void) {
hwmon_refresh();
return &hw_data;
}