feat: HWP scaling, C1E, closed-loop thermal governor for Intel CPUs

This commit is contained in:
2026-07-05 10:51:11 +02:00
parent daa17a325f
commit 70702a21b0
19 changed files with 903 additions and 9 deletions
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once
#define MONTAUK_BUILD_NUMBER 9
#define MONTAUK_BUILD_NUMBER 14
+25
View File
@@ -12,6 +12,8 @@
#include <Graphics/Framebuffer.hpp>
#include <ACPI/AcpiShutdown.hpp>
#include <ACPI/AcpiSleep.hpp>
#include <ACPI/CpuIdle.hpp>
#include <Hal/CpuPower.hpp>
#include "Syscall.hpp"
@@ -71,4 +73,27 @@ namespace montauk::abi {
}
return (int64_t)Hal::AcpiSleep::Suspend();
}
// SYS_POWERINFO. Fills a CPU power/thermal snapshot. Returns -1 when the
// CPU exposes no power management features (e.g. under QEMU).
static int64_t Sys_PowerInfo(PowerInfo* out) {
Hal::CpuPower::Snapshot s{};
if (!Hal::CpuPower::GetSnapshot(s)) {
return -1;
}
out->hwpActive = s.HwpActive ? 1 : 0;
out->throttling = s.Throttling ? 1 : 0;
out->tempC = s.TempC;
out->tjMaxC = s.TjMaxC;
out->highestPerf = s.HighestPerf;
out->lowestPerf = s.LowestPerf;
out->curMaxPerf = s.CurMaxPerf;
out->epp = s.Epp;
out->baseMHz = s.BaseMHz;
out->maxMHz = s.MaxMHz;
out->effMHz = s.EffMHz;
out->apIdleHint = Hal::CpuIdle::GetApIdleHint();
return 0;
}
};
+3
View File
@@ -378,6 +378,9 @@ namespace montauk::abi {
return Sys_SdrSetParam((int)frame->arg1, (int)frame->arg2, frame->arg3);
case SYS_SDR_GETPARAM:
return Sys_SdrGetParam((int)frame->arg1, (int)frame->arg2);
case SYS_POWERINFO:
if (!UserMemory::Writable<PowerInfo>(frame->arg1)) return -1;
return Sys_PowerInfo((PowerInfo*)frame->arg1);
case SYS_THREAD_SPAWN:
return Sys_ThreadSpawn(frame->arg1, frame->arg2, frame->arg3);
case SYS_THREAD_EXIT:
+19
View File
@@ -276,6 +276,9 @@ namespace montauk::abi {
static constexpr uint64_t SYS_SDR_SETPARAM = 147; // (handle, param, value)
static constexpr uint64_t SYS_SDR_GETPARAM = 148; // (handle, param) -> value
/* Power.hpp -- CPU power/thermal status */
static constexpr uint64_t SYS_POWERINFO = 149; // (PowerInfo*) -> 0, -1 unsupported
// Tunable parameters (for SYS_SDR_SETPARAM / SYS_SDR_GETPARAM).
static constexpr int SDR_PARAM_FREQ = 0; // center frequency, Hz
static constexpr int SDR_PARAM_SAMPLE_RATE = 1; // sample rate, Hz
@@ -568,6 +571,22 @@ namespace montauk::abi {
uint32_t _pad;
};
// CPU power/thermal snapshot (returned by SYS_POWERINFO)
struct PowerInfo {
uint8_t hwpActive; // hardware P-state scaling enabled
uint8_t throttling; // thermal governor currently limiting frequency
uint8_t tempC; // package temperature, degrees C (0 = unknown)
uint8_t tjMaxC; // hardware throttle temperature
uint8_t highestPerf; // HWP performance range (ratio units)
uint8_t lowestPerf;
uint8_t curMaxPerf; // thermal governor's current ceiling
uint8_t epp; // energy/perf preference (0=perf, 255=power)
uint32_t baseMHz; // nominal base frequency (0 = unknown)
uint32_t maxMHz; // max turbo frequency
uint32_t effMHz; // measured average active frequency
uint32_t apIdleHint; // MWAIT hint used for AP deep idle
};
// Crash report (filled by kernel on process fault, returned via SYS_CRASH_REPORT)
struct CrashReportInfo {
int pid;