From edf05935c0783c195d36c23c6a6356794203a35b Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Sat, 2 Mar 2024 13:18:31 +0100 Subject: [PATCH] Use constants instead of hardcoding the MSR index. --- app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs b/app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs index e7bacc1d..03706ff5 100644 --- a/app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs +++ b/app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs @@ -2,8 +2,12 @@ namespace GHelper.AutoTDP.PowerLimiter { + internal class IntelMSRPowerLimiter : IPowerLimiter { + public static readonly uint MSR_PKG_POWER_LIMIT = 0x610; + public static readonly uint MSR_RAPL_POWER_UNIT = 0x606; + private Ols ols; private uint DefaultEax = 0; // Set on first reading @@ -28,7 +32,7 @@ namespace GHelper.AutoTDP.PowerLimiter uint eax = 0; uint edx = 0; - ols.Rdmsr(0x606, ref eax, ref edx); + ols.Rdmsr(MSR_RAPL_POWER_UNIT, ref eax, ref edx); uint pwr = eax & 0x03; @@ -42,7 +46,7 @@ namespace GHelper.AutoTDP.PowerLimiter uint edx = 0; - ols.Rdmsr(0x610, ref eax, ref edx); + ols.Rdmsr(MSR_PKG_POWER_LIMIT, ref eax, ref edx); uint watsRapl = (uint)(watts / PowerUnit); @@ -66,7 +70,7 @@ namespace GHelper.AutoTDP.PowerLimiter uint eax = 0; uint edx = 0; - ols.Rdmsr(0x610, ref eax, ref edx); + ols.Rdmsr(MSR_PKG_POWER_LIMIT, ref eax, ref edx); if (DefaultEax == 0) { @@ -88,7 +92,7 @@ namespace GHelper.AutoTDP.PowerLimiter { return; } - ols.Wrmsr(0x610, DefaultEax, DefaultEdx); + ols.Wrmsr(MSR_PKG_POWER_LIMIT, DefaultEax, DefaultEdx); } public void Dispose()