From 1402176289d2c2d70f332ba10a34e1fcc0aaccbc Mon Sep 17 00:00:00 2001 From: Aqua Computer Date: Tue, 9 Jul 2019 13:13:36 +0200 Subject: [PATCH] Bugfixes and new Mainboards (#96) Bug: Reduced exceptions during cpu core init Bug: GetSensorValuesFromSettings, Sensors.cs reduced number of exceptions Bug: HTTP Server Null Reference Exception on StopHTTPListener Bug: in some cases 64 bit process on a 32Bit system detected Intel CPUs: Max Temperature Sensor from all Cores Average temperature from all core sensors dist to tjmax sensor for each core AMD: support new cpus bugfix power sensors Mainboards: Asrock: AB350 PRO4 AB350M PRO4 AB350M Fatal1ty AB350 Gaming K4 AB350M HDV Phantom Gaming 6 A320M-HDV Asrock Z77 Pro4-M Asus: ASUS ROG ZENITH EXTREME (X399) Z170-A Gigabyte: GIGABYTE X399 AOURUS GAMING7 --- Hardware/CPU/AMD10CPU.cs | 220 +++--- Hardware/CPU/AMD17CPU.cs | 948 +++++++++++++------------- Hardware/CPU/CPUGroup.cs | 38 +- Hardware/CPU/IntelCPU.cs | 134 ++-- Hardware/Computer.cs | 26 +- Hardware/LPC/Chip.cs | 12 +- Hardware/LPC/IT87XX.cs | 103 ++- Hardware/Mainboard/Identification.cs | 42 +- Hardware/Mainboard/Model.cs | 31 +- Hardware/Mainboard/SuperIOHardware.cs | 573 +++++++++++----- Hardware/Sensor.cs | 109 +-- Hardware/ThreadAffinity.cs | 88 +-- Software/OperatingSystem.cs | 15 +- Utilities/HttpServer.cs | 33 +- 14 files changed, 1401 insertions(+), 971 deletions(-) diff --git a/Hardware/CPU/AMD10CPU.cs b/Hardware/CPU/AMD10CPU.cs index c5eae3d..9395f46 100644 --- a/Hardware/CPU/AMD10CPU.cs +++ b/Hardware/CPU/AMD10CPU.cs @@ -1,11 +1,11 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2009-2013 Michael Möller - + */ using System; @@ -23,7 +23,10 @@ namespace OpenHardwareMonitor.Hardware.CPU { private readonly Sensor coreTemperature; private readonly Sensor[] coreClocks; private readonly Sensor busClock; - + private readonly Sensor[] cStatesResidency; + private readonly Sensor coreVoltage; + private readonly Sensor northbridgeVoltage; + private const uint PERF_CTL_0 = 0xC0010000; private const uint PERF_CTR_0 = 0xC0010004; private const uint HWCR = 0xC0010015; @@ -51,6 +54,11 @@ namespace OpenHardwareMonitor.Hardware.CPU { private readonly uint miscellaneousControlAddress; private readonly ushort miscellaneousControlDeviceId; + private const uint cStatesIoPort = 0xCD6; + private readonly byte cStatesIoOffset; + + private readonly bool isSVI2; + private readonly FileStream temperatureStream; private readonly double timeStampCounterMultiplier; @@ -58,51 +66,70 @@ namespace OpenHardwareMonitor.Hardware.CPU { public AMD10CPU(int processorIndex, CPUID[][] cpuid, ISettings settings) : base(processorIndex, cpuid, settings) - { + { // AMD family 1Xh processors support only one temperature sensor - coreTemperature = new Sensor( - "Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0, - SensorType.Temperature, this, new [] { + coreTemperature = new Sensor("CPU Cores", 0, SensorType.Temperature, this, new[] { new ParameterDescription("Offset [°C]", "Temperature offset.", 0) }, settings); + coreVoltage = new Sensor("CPU Cores", 0, SensorType.Voltage, this, settings); + ActivateSensor(coreVoltage); + northbridgeVoltage = new Sensor("Northbridge", 0, + SensorType.Voltage, this, settings); + ActivateSensor(northbridgeVoltage); + isSVI2 = (family == 0x15 && model >= 0x10) || family == 0x16; + switch (family) { - case 0x10: miscellaneousControlDeviceId = - FAMILY_10H_MISCELLANEOUS_CONTROL_DEVICE_ID; break; - case 0x11: miscellaneousControlDeviceId = - FAMILY_11H_MISCELLANEOUS_CONTROL_DEVICE_ID; break; - case 0x12: miscellaneousControlDeviceId = - FAMILY_12H_MISCELLANEOUS_CONTROL_DEVICE_ID; break; - case 0x14: miscellaneousControlDeviceId = - FAMILY_14H_MISCELLANEOUS_CONTROL_DEVICE_ID; break; + case 0x10: + miscellaneousControlDeviceId = + FAMILY_10H_MISCELLANEOUS_CONTROL_DEVICE_ID; break; + case 0x11: + miscellaneousControlDeviceId = + FAMILY_11H_MISCELLANEOUS_CONTROL_DEVICE_ID; break; + case 0x12: + miscellaneousControlDeviceId = + FAMILY_12H_MISCELLANEOUS_CONTROL_DEVICE_ID; break; + case 0x14: + miscellaneousControlDeviceId = + FAMILY_14H_MISCELLANEOUS_CONTROL_DEVICE_ID; break; case 0x15: switch (model & 0xF0) { - case 0x00: miscellaneousControlDeviceId = - FAMILY_15H_MODEL_00_MISC_CONTROL_DEVICE_ID; break; - case 0x10: miscellaneousControlDeviceId = - FAMILY_15H_MODEL_10_MISC_CONTROL_DEVICE_ID; break; - case 0x30: miscellaneousControlDeviceId = - FAMILY_15H_MODEL_30_MISC_CONTROL_DEVICE_ID; break; - case 0x60: miscellaneousControlDeviceId = - FAMILY_15H_MODEL_60_MISC_CONTROL_DEVICE_ID; break; + case 0x00: + miscellaneousControlDeviceId = + FAMILY_15H_MODEL_00_MISC_CONTROL_DEVICE_ID; break; + case 0x10: + miscellaneousControlDeviceId = + FAMILY_15H_MODEL_10_MISC_CONTROL_DEVICE_ID; break; + case 0x30: + miscellaneousControlDeviceId = + FAMILY_15H_MODEL_30_MISC_CONTROL_DEVICE_ID; break; + case 0x70: + case 0x60: + miscellaneousControlDeviceId = + FAMILY_15H_MODEL_60_MISC_CONTROL_DEVICE_ID; break; default: miscellaneousControlDeviceId = 0; break; - } break; + } + break; case 0x16: switch (model & 0xF0) { - case 0x00: miscellaneousControlDeviceId = - FAMILY_16H_MODEL_00_MISC_CONTROL_DEVICE_ID; break; - case 0x30: miscellaneousControlDeviceId = - FAMILY_16H_MODEL_30_MISC_CONTROL_DEVICE_ID; break; + case 0x00: + miscellaneousControlDeviceId = + FAMILY_16H_MODEL_00_MISC_CONTROL_DEVICE_ID; break; + case 0x30: + miscellaneousControlDeviceId = + FAMILY_16H_MODEL_30_MISC_CONTROL_DEVICE_ID; break; default: miscellaneousControlDeviceId = 0; break; - } break; - case 0x17: miscellaneousControlDeviceId = - FAMILY_17H_MODEL_00_MISC_CONTROL_DEVICE_ID; break; + } + break; + case 0x17: + miscellaneousControlDeviceId = + FAMILY_17H_MODEL_00_MISC_CONTROL_DEVICE_ID; break; default: miscellaneousControlDeviceId = 0; break; } - // get the pci address for the Miscellaneous Control registers + // get the pci address for the Miscellaneous Control registers miscellaneousControlAddress = GetPciAddress( - MISCELLANEOUS_CONTROL_FUNCTION, miscellaneousControlDeviceId); + MISCELLANEOUS_CONTROL_FUNCTION, miscellaneousControlDeviceId); busClock = new Sensor("Bus Speed", 0, SensorType.Clock, this, settings); coreClocks = new Sensor[coreCount]; @@ -115,13 +142,13 @@ namespace OpenHardwareMonitor.Hardware.CPU { corePerformanceBoostSupport = (cpuid[0][0].ExtData[7, 3] & (1 << 9)) > 0; - // set affinity to the first thread for all frequency estimations + // set affinity to the first thread for all frequency estimations ulong mask = ThreadAffinity.Set(1UL << cpuid[0][0].Thread); - // disable core performance boost + // disable core performance boost uint hwcrEax, hwcrEdx; Ring0.Rdmsr(HWCR, out hwcrEax, out hwcrEdx); - if (corePerformanceBoostSupport) + if (corePerformanceBoostSupport) Ring0.Wrmsr(HWCR, hwcrEax | (1 << 25), hwcrEdx); uint ctlEax, ctlEdx; @@ -136,7 +163,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { Ring0.Wrmsr(PERF_CTR_0, ctrEax, ctrEdx); // restore core performance boost - if (corePerformanceBoostSupport) + if (corePerformanceBoostSupport) Ring0.Wrmsr(HWCR, hwcrEax, hwcrEdx); // restore the thread affinity. @@ -144,7 +171,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { // the file reader for lm-sensors support on Linux temperatureStream = null; - + if (Software.OperatingSystem.IsLinux) { string[] devicePaths = Directory.GetDirectories("/sys/class/hwmon/"); foreach (string path in devicePaths) { @@ -155,14 +182,30 @@ namespace OpenHardwareMonitor.Hardware.CPU { } catch (IOException) { } switch (name) { case "k10temp": - temperatureStream = new FileStream(path + "/device/temp1_input", + temperatureStream = new FileStream(path + "/device/temp1_input", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); break; } } } - Update(); + uint addr = Ring0.GetPciAddress(0, 20, 0); + if (Ring0.ReadPciConfig(addr, 0, out uint dev)) { + Ring0.ReadPciConfig(addr, 8, out uint rev); + + if (dev == 0x43851002) + cStatesIoOffset = (byte)((rev & 0xFF) < 0x40 ? 0xB3 : 0x9C); + else if (dev == 0x780B1022 || dev == 0x790B1022) + cStatesIoOffset = (byte)0x9C; + } + if (cStatesIoOffset != 0) { + cStatesResidency = new Sensor[]{ + new Sensor("CPU Package C2", 0, SensorType.Level, this, settings), + new Sensor("CPU Package C3", 1, SensorType.Level, this, settings) }; + ActivateSensor(cStatesResidency[0]); + ActivateSensor(cStatesResidency[1]); + } + Update(); } private double estimateTimeStampCounterMultiplier() { @@ -180,7 +223,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { private double estimateTimeStampCounterMultiplier(double timeWindow) { uint eax, edx; - + // select event "076h CPU Clocks not Halted" and enable the counter Ring0.Wrmsr(PERF_CTL_0, (1 << 22) | // enable performance counter @@ -192,7 +235,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { Ring0.Wrmsr(PERF_CTR_0, 0, 0); long ticks = (long)(timeWindow * Stopwatch.Frequency); - uint lsbBegin, msbBegin, lsbEnd, msbEnd; + uint lsbBegin, msbBegin, lsbEnd, msbEnd; long timeBegin = Stopwatch.GetTimestamp() + (long)Math.Ceiling(0.001 * ticks); @@ -208,7 +251,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { ulong countBegin = ((ulong)msbBegin << 32) | lsbBegin; ulong countEnd = ((ulong)msbEnd << 32) | lsbEnd; - double coreFrequency = 1e-6 * + double coreFrequency = 1e-6 * (((double)(countEnd - countBegin)) * Stopwatch.Frequency) / (timeEnd - timeBegin); @@ -218,7 +261,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { } protected override uint[] GetMSRs() { - return new uint[] { PERF_CTL_0, PERF_CTR_0, HWCR, P_STATE_0, + return new uint[] { PERF_CTL_0, PERF_CTR_0, HWCR, P_STATE_0, COFVID_STATUS }; } @@ -247,8 +290,8 @@ namespace OpenHardwareMonitor.Hardware.CPU { private double GetCoreMultiplier(uint cofvidEax) { switch (family) { case 0x10: - case 0x11: - case 0x15: + case 0x11: + case 0x15: case 0x16: { // 8:6 CpuDid: current core divisor ID // 5:0 CpuFid: current core frequency ID @@ -312,37 +355,28 @@ namespace OpenHardwareMonitor.Hardware.CPU { if (temperatureStream == null) { if (miscellaneousControlAddress != Ring0.InvalidPciAddress) { uint value; - if (miscellaneousControlAddress == FAMILY_15H_MODEL_60_MISC_CONTROL_DEVICE_ID) { - value = F15H_M60H_REPORTED_TEMP_CTRL_OFFSET; - Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), 0xB8, value); - Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), 0xBC, out value); - coreTemperature.Value = ((value >> 21) & 0x7FF) * 0.125f + - coreTemperature.Parameters[0].Value; - ActivateSensor(coreTemperature); - return; - } - if (Ring0.ReadPciConfig(miscellaneousControlAddress, - REPORTED_TEMPERATURE_CONTROL_REGISTER, out value)) { - if (family == 0x15 && (value & 0x30000) == 0x30000) { - if ((model & 0xF0) == 0x00) { - coreTemperature.Value = ((value >> 21) & 0x7FC) / 8.0f + - coreTemperature.Parameters[0].Value - 49; - } else { - coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f + - coreTemperature.Parameters[0].Value - 49; - } - } else if (family == 0x16 && - ((value & 0x30000) == 0x30000 || (value & 0x80000) == 0x80000)) { - coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f + - coreTemperature.Parameters[0].Value - 49; + if (miscellaneousControlAddress == FAMILY_15H_MODEL_60_MISC_CONTROL_DEVICE_ID) { + Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), 0xB8, F15H_M60H_REPORTED_TEMP_CTRL_OFFSET); + Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), 0xBC, out value); + } else { + Ring0.ReadPciConfig(miscellaneousControlAddress, + REPORTED_TEMPERATURE_CONTROL_REGISTER, out value); + } + if ((family == 0x15 || family == 0x16) && (value & 0x30000) == 0x3000) { + if (family == 0x15 && (model & 0xF0) == 0x00) { + coreTemperature.Value = ((value >> 21) & 0x7FC) / 8.0f + + coreTemperature.Parameters[0].Value - 49; } else { coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f + - coreTemperature.Parameters[0].Value; + coreTemperature.Parameters[0].Value - 49; } - ActivateSensor(coreTemperature); } else { - DeactivateSensor(coreTemperature); + coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f + + coreTemperature.Parameters[0].Value; } + ActivateSensor(coreTemperature); + } else { + DeactivateSensor(coreTemperature); } } else { string s = ReadFirstLine(temperatureStream); @@ -352,40 +386,64 @@ namespace OpenHardwareMonitor.Hardware.CPU { ActivateSensor(coreTemperature); } catch { DeactivateSensor(coreTemperature); - } + } } if (HasTimeStampCounter) { double newBusClock = 0; + float maxCoreVoltage = 0, maxNBVoltage = 0; for (int i = 0; i < coreClocks.Length; i++) { Thread.Sleep(1); uint curEax, curEdx; - if (Ring0.RdmsrTx(COFVID_STATUS, out curEax, out curEdx, - 1UL << cpuid[i][0].Thread)) - { + if (Ring0.RdmsrTx(COFVID_STATUS, out curEax, out curEdx, 1UL << cpuid[i][0].Thread)) { double multiplier; multiplier = GetCoreMultiplier(curEax); - coreClocks[i].Value = - (float)(multiplier * TimeStampCounterFrequency / + coreClocks[i].Value = + (float)(multiplier * TimeStampCounterFrequency / timeStampCounterMultiplier); - newBusClock = + newBusClock = (float)(TimeStampCounterFrequency / timeStampCounterMultiplier); } else { coreClocks[i].Value = (float)TimeStampCounterFrequency; } + + float SVI2Volt(uint vid) => vid < 0b1111_1000 ? 1.5500f - 0.00625f * vid : 0; + float SVI1Volt(uint vid) => vid < 0x7C ? 1.550f - 0.0125f * vid : 0; + float newCoreVoltage, newNBVoltage; + uint coreVid60 = (curEax >> 9) & 0x7F; + if (isSVI2) { + newCoreVoltage = SVI2Volt(curEax >> 13 & 0x80 | coreVid60); + newNBVoltage = SVI2Volt(curEax >> 24); + } else { + newCoreVoltage = SVI1Volt(coreVid60); + newNBVoltage = SVI1Volt(curEax >> 25); + } + if (newCoreVoltage > maxCoreVoltage) + maxCoreVoltage = newCoreVoltage; + if (newNBVoltage > maxNBVoltage) + maxNBVoltage = newNBVoltage; } + coreVoltage.Value = maxCoreVoltage; + northbridgeVoltage.Value = maxNBVoltage; if (newBusClock > 0) { this.busClock.Value = (float)newBusClock; ActivateSensor(this.busClock); } } + + if (cStatesResidency != null) { + for (int i = 0; i < cStatesResidency.Length; i++) { + Ring0.WriteIoPort(cStatesIoPort, (byte)(cStatesIoOffset + i)); + cStatesResidency[i].Value = Ring0.ReadIoPort(cStatesIoPort + 1) / 256f * 100; + } + } } - public override void Close() { + public override void Close() { if (temperatureStream != null) { temperatureStream.Close(); } diff --git a/Hardware/CPU/AMD17CPU.cs b/Hardware/CPU/AMD17CPU.cs index 98e6d6c..f00677b 100644 --- a/Hardware/CPU/AMD17CPU.cs +++ b/Hardware/CPU/AMD17CPU.cs @@ -1,168 +1,169 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) 2016-2017 Sebastian Grams -// Copyright (C) 2016-2017 Aqua Computer - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Text; -using System.Threading; - -namespace OpenHardwareMonitor.Hardware.CPU -{ - internal sealed class AMD17CPU : AMDCPU - { - // counter, to create sensor index values - private int _sensorTemperatures = 0; - private int _sensorPower = 0; - private int _sensorVoltage = 0; - private int _sensorClock = 0; - private int _sensorMulti = 0; - - // register index names for CPUID[] - private const int EAX = 0; - private const int EBX = 1; - private const int ECX = 2; - private const int EDX = 3; - - #region amd zen registers - private const uint PERF_CTL_0 = 0xC0010000; - private const uint PERF_CTR_0 = 0xC0010004; - private const uint HWCR = 0xC0010015; - - private const uint MSR_PSTATE_L = 0xC0010061; - private const uint MSR_PSTATE_C = 0xC0010062; - private const uint MSR_PSTATE_S = 0xC0010063; - private const uint MSR_PSTATE_0 = 0xC0010064; - - private const uint MSR_PWR_UNIT = 0xC0010299; - private const uint MSR_CORE_ENERGY_STAT = 0xC001029A; - private const uint MSR_PKG_ENERGY_STAT = 0xC001029B; - private const uint MSR_HARDWARE_PSTATE_STATUS = 0xC0010293; - private const uint COFVID_STATUS = 0xC0010071; - private const uint FAMILY_17H_PCI_CONTROL_REGISTER = 0x60; - private const uint FAMILY_17H_MODEL_01_MISC_CONTROL_DEVICE_ID = 0x1463; - private const uint F17H_M01H_THM_TCON_CUR_TMP = 0x00059800; - private const uint F17H_M01H_SVI = 0x0005A000; - - public const uint F17H_TEMP_OFFSET_FLAG = 0x80000; - #endregion - - #region Processor - private class Processor - { - private AMD17CPU _hw = null; - private DateTime _lastPwrTime = new DateTime(0); - private uint _lastPwrValue = 0; - private Sensor _packagePower = null; - private Sensor _coreTemperatureTctl = null; - private Sensor _coreTemperatureTdie = null; - private Sensor _coreVoltage = null; - private Sensor _socVoltage = null; - public List Nodes { get; private set; } - - public Processor(Hardware hw) - { - this._hw = (AMD17CPU)hw; - Nodes = new List(); - - _packagePower = new Sensor("Package Power", this._hw._sensorPower++, SensorType.Power, this._hw, this._hw.settings); - _coreTemperatureTctl = new Sensor("Core (Tctl)", this._hw._sensorTemperatures++, SensorType.Temperature, this._hw, this._hw.settings); - _coreTemperatureTdie = new Sensor("Core (Tdie)", this._hw._sensorTemperatures++, SensorType.Temperature, this._hw, this._hw.settings); - _coreVoltage = new Sensor("Core (SVI2)", this._hw._sensorVoltage++, SensorType.Voltage, this._hw, this._hw.settings); +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. +// Copyright (C) 2016-2019 Sebastian Grams +// Copyright (C) 2016-2019 Aqua Computer + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Text; +using System.Threading; + +namespace OpenHardwareMonitor.Hardware.CPU +{ + internal sealed class AMD17CPU : AMDCPU + { + // counter, to create sensor index values + private int _sensorTemperatures = 0; + private int _sensorPower = 0; + private int _sensorVoltage = 0; + private int _sensorClock = 0; + private int _sensorMulti = 0; + + // register index names for CPUID[] + private const int EAX = 0; + private const int EBX = 1; + private const int ECX = 2; + private const int EDX = 3; + + #region amd zen registers + private const uint PERF_CTL_0 = 0xC0010000; + private const uint PERF_CTR_0 = 0xC0010004; + private const uint HWCR = 0xC0010015; + + private const uint MSR_PSTATE_L = 0xC0010061; + private const uint MSR_PSTATE_C = 0xC0010062; + private const uint MSR_PSTATE_S = 0xC0010063; + private const uint MSR_PSTATE_0 = 0xC0010064; + + private const uint MSR_PWR_UNIT = 0xC0010299; + private const uint MSR_CORE_ENERGY_STAT = 0xC001029A; + private const uint MSR_PKG_ENERGY_STAT = 0xC001029B; + private const uint MSR_HARDWARE_PSTATE_STATUS = 0xC0010293; + private const uint COFVID_STATUS = 0xC0010071; + private const uint FAMILY_17H_PCI_CONTROL_REGISTER = 0x60; + private const uint FAMILY_17H_MODEL_01_MISC_CONTROL_DEVICE_ID = 0x1463; + private const uint F17H_M01H_THM_TCON_CUR_TMP = 0x00059800; + private const uint F17H_M01H_SVI = 0x0005A000; + + public const uint F17H_TEMP_OFFSET_FLAG = 0x80000; + #endregion + + #region Processor + private class Processor + { + private AMD17CPU _hw = null; + private DateTime _lastPwrTime = new DateTime(0); + private uint _lastPwrValue = 0; + private Sensor _packagePower = null; + private Sensor _coreTemperatureTctl = null; + private Sensor _coreTemperatureTdie = null; + private Sensor _coreVoltage = null; + private Sensor _socVoltage = null; + public List Nodes { get; private set; } + + public Processor(Hardware hw) + { + this._hw = (AMD17CPU)hw; + Nodes = new List(); + + _packagePower = new Sensor("Package Power", this._hw._sensorPower++, SensorType.Power, this._hw, this._hw.settings); + _coreTemperatureTctl = new Sensor("Core (Tctl)", this._hw._sensorTemperatures++, SensorType.Temperature, this._hw, this._hw.settings); + _coreTemperatureTdie = new Sensor("Core (Tdie)", this._hw._sensorTemperatures++, SensorType.Temperature, this._hw, this._hw.settings); + _coreVoltage = new Sensor("Core (SVI2)", this._hw._sensorVoltage++, SensorType.Voltage, this._hw, this._hw.settings); _socVoltage = new Sensor("SoC (SVI2)", this._hw._sensorVoltage++, SensorType.Voltage, this._hw, this._hw.settings); - _hw.ActivateSensor(_packagePower); - _hw.ActivateSensor(_coreTemperatureTctl); + _hw.ActivateSensor(_packagePower); + _hw.ActivateSensor(_coreTemperatureTctl); _hw.ActivateSensor(_coreTemperatureTdie); _hw.ActivateSensor(_coreVoltage); - } - - #region UpdateSensors - public void UpdateSensors() - { - var node = Nodes[0]; - if (node == null) - return; - Core core = node.Cores[0]; - if (core == null) - return; - CPUID cpu = core.Threads[0]; - if (cpu == null) - return; - uint eax, edx; - - ulong mask = Ring0.ThreadAffinitySet(1UL << cpu.Thread); - - // MSRC001_0299 - // TU [19:16] - // ESU [12:8] -> Unit 15.3 micro Joule per increment - // PU [3:0] - Ring0.Rdmsr(MSR_PWR_UNIT, out eax, out edx); - int tu = (int)((eax >> 16) & 0xf); - int esu = (int)((eax >> 12) & 0xf); - int pu = (int)(eax & 0xf); - - // MSRC001_029B - // total_energy [31:0] - DateTime sample_time = DateTime.Now; - Ring0.Rdmsr(MSR_PKG_ENERGY_STAT, out eax, out edx); - uint total_energy = eax; - - // THM_TCON_CUR_TMP - // CUR_TEMP [31:21] - uint temperature = 0; - Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_THM_TCON_CUR_TMP); - Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out temperature); - - // SVI0_TFN_PLANE0 [0] - // SVI0_TFN_PLANE1 [1] - uint smusvi0_tfn = 0; - Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_SVI + 0x8); - Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out smusvi0_tfn); - - // SVI0_PLANE0_VDDCOR [24:16] - // SVI0_PLANE0_IDDCOR [7:0] - uint smusvi0_tel_plane0 = 0; - Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_SVI + 0xc); - Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out smusvi0_tel_plane0); - - // SVI0_PLANE1_VDDCOR [24:16] - // SVI0_PLANE1_IDDCOR [7:0] - uint smusvi0_tel_plane1 = 0; - Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_SVI + 0x10); - Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out smusvi0_tel_plane1); - - Ring0.ThreadAffinitySet(mask); - - // power consumption - // power.Value = (float) ((double)pu * 0.125); - // esu = 15.3 micro Joule per increment - if (_lastPwrTime.Ticks == 0) - { - _lastPwrTime = sample_time; - _lastPwrValue = total_energy; - } - // ticks diff - TimeSpan time = sample_time - _lastPwrTime; - long pwr; - if (_lastPwrValue <= total_energy) - pwr = total_energy - _lastPwrValue; - else - pwr = (0xffffffff - _lastPwrValue) + total_energy; - - // update for next sample - _lastPwrTime = sample_time; - _lastPwrValue = total_energy; - - double energy = 15.3e-6 * pwr; - energy /= time.TotalSeconds; - - _packagePower.Value = (float)energy; + } + + #region UpdateSensors + public void UpdateSensors() + { + var node = Nodes[0]; + if (node == null) + return; + Core core = node.Cores[0]; + if (core == null) + return; + CPUID cpu = core.Threads[0]; + if (cpu == null) + return; + uint eax, edx; + + ulong mask = Ring0.ThreadAffinitySet(1UL << cpu.Thread); + + // MSRC001_0299 + // TU [19:16] + // ESU [12:8] -> Unit 15.3 micro Joule per increment + // PU [3:0] + Ring0.Rdmsr(MSR_PWR_UNIT, out eax, out edx); + int tu = (int)((eax >> 16) & 0xf); + int esu = (int)((eax >> 12) & 0xf); + int pu = (int)(eax & 0xf); + + // MSRC001_029B + // total_energy [31:0] + DateTime sample_time = DateTime.Now; + Ring0.Rdmsr(MSR_PKG_ENERGY_STAT, out eax, out edx); + uint total_energy = eax; + + // THM_TCON_CUR_TMP + // CUR_TEMP [31:21] + uint temperature = 0; + Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_THM_TCON_CUR_TMP); + Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out temperature); + + // SVI0_TFN_PLANE0 [0] + // SVI0_TFN_PLANE1 [1] + uint smusvi0_tfn = 0; + Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_SVI + 0x8); + Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out smusvi0_tfn); + + // SVI0_PLANE0_VDDCOR [24:16] + // SVI0_PLANE0_IDDCOR [7:0] + uint smusvi0_tel_plane0 = 0; + Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_SVI + 0xc); + Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out smusvi0_tel_plane0); + + // SVI0_PLANE1_VDDCOR [24:16] + // SVI0_PLANE1_IDDCOR [7:0] + uint smusvi0_tel_plane1 = 0; + Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M01H_SVI + 0x10); + Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), FAMILY_17H_PCI_CONTROL_REGISTER + 4, out smusvi0_tel_plane1); + + Ring0.ThreadAffinitySet(mask); + + // power consumption + // power.Value = (float) ((double)pu * 0.125); + // esu = 15.3 micro Joule per increment + if (_lastPwrTime.Ticks == 0) + { + _lastPwrTime = sample_time; + _lastPwrValue = total_energy; + } + // ticks diff + TimeSpan time = sample_time - _lastPwrTime; + long pwr; + if (_lastPwrValue <= total_energy) + pwr = total_energy - _lastPwrValue; + else + pwr = (0xffffffff - _lastPwrValue) + total_energy; + + // update for next sample + _lastPwrTime = sample_time; + _lastPwrValue = total_energy; + + double energy = 15.3e-6 * pwr; + energy /= time.TotalSeconds; + + if (!double.IsNaN(energy)) + _packagePower.Value = (float)energy; // current temp Bit [31:21] //If bit 19 of the Temperature Control register is set, there is an additional offset of 49 degrees C. @@ -172,320 +173,325 @@ namespace OpenHardwareMonitor.Hardware.CPU temperature = (temperature >> 21) * 125; float offset = 0.0f; - if (cpu.Name != null && (cpu.Name.Contains("2600X") || cpu.Name.Contains("2700X"))) - offset = -10.0f; - if (cpu.Name != null && (cpu.Name.Contains("1600X") || cpu.Name.Contains("1700X") || cpu.Name.Contains("1800X"))) + if (string.IsNullOrWhiteSpace(cpu.Name)) + offset = 0; + else if (cpu.Name.Contains("1600X") || cpu.Name.Contains("1700X") || cpu.Name.Contains("1800X")) offset = -20.0f; - else if (cpu.Name != null && (cpu.Name.Contains("1920X") || cpu.Name.Contains("1950X") || cpu.Name.Contains("1900X"))) + else if (cpu.Name.Contains("1920X") || cpu.Name.Contains("1950X") || cpu.Name.Contains("1900X")) offset = -27.0f; - else if (cpu.Name != null && (cpu.Name.Contains("1910") || cpu.Name.Contains("1920") || cpu.Name.Contains("1950"))) + else if (cpu.Name.Contains("2600X") || cpu.Name.Contains("2700X") || cpu.Name.Contains("2800X")) offset = -10.0f; + else if (cpu.Name.Contains("1910") || cpu.Name.Contains("1920") || cpu.Name.Contains("1950")) + offset = -10.0f; + else if (cpu.Name.Contains("2920") || cpu.Name.Contains("2950") || cpu.Name.Contains("2970") || cpu.Name.Contains("2990")) + offset = -27.0f; float t = (temperature * 0.001f); if (temp_offset_flag) - t += -49.0f; - - _coreTemperatureTctl.Value = t; - _coreTemperatureTdie.Value = t + offset; - - // voltage - double VIDStep = 0.00625; - double vcc; - uint svi0_plane_x_vddcor; - uint svi0_plane_x_iddcor; - - //Core - if ((smusvi0_tfn & 0x01) == 0) - { - svi0_plane_x_vddcor = (smusvi0_tel_plane0 >> 16) & 0xff; - svi0_plane_x_iddcor = smusvi0_tel_plane0 & 0xff; - vcc = 1.550 - (double)VIDStep * svi0_plane_x_vddcor; - _coreVoltage.Value = (float)vcc; - } - - // SoC - // not every zen cpu has this voltage - if ((smusvi0_tfn & 0x02) == 0) - { - svi0_plane_x_vddcor = (smusvi0_tel_plane1 >> 16) & 0xff; - svi0_plane_x_iddcor = smusvi0_tel_plane1 & 0xff; - vcc = 1.550 - (double)VIDStep * svi0_plane_x_vddcor; + t += -49.0f; + + _coreTemperatureTctl.Value = t; + _coreTemperatureTdie.Value = t + offset; + + // voltage + double VIDStep = 0.00625; + double vcc; + uint svi0_plane_x_vddcor; + uint svi0_plane_x_iddcor; + + //Core + if ((smusvi0_tfn & 0x01) == 0) + { + svi0_plane_x_vddcor = (smusvi0_tel_plane0 >> 16) & 0xff; + svi0_plane_x_iddcor = smusvi0_tel_plane0 & 0xff; + vcc = 1.550 - (double)VIDStep * svi0_plane_x_vddcor; + _coreVoltage.Value = (float)vcc; + } + + // SoC + // not every zen cpu has this voltage + if ((smusvi0_tfn & 0x02) == 0) + { + svi0_plane_x_vddcor = (smusvi0_tel_plane1 >> 16) & 0xff; + svi0_plane_x_iddcor = smusvi0_tel_plane1 & 0xff; + vcc = 1.550 - (double)VIDStep * svi0_plane_x_vddcor; _socVoltage.Value = (float)vcc; - _hw.ActivateSensor(_socVoltage); - } - - } - #endregion - - public void AppendThread(CPUID thread, int numa_id, int core_id) - { - NumaNode node = null; - foreach (var n in Nodes) - { - if (n.NodeId == numa_id) - node = n; - } - if (node == null) - { - node = new NumaNode(_hw, numa_id); - Nodes.Add(node); - } - if (thread != null) - node.AppendThread(thread, core_id); - } - } - #endregion - - #region NumaNode - private class NumaNode - { - private AMD17CPU _hw = null; - public int NodeId { get; private set; } - public List Cores { get; private set; } - - public NumaNode(Hardware hw, int id) - { - Cores = new List(); - NodeId = id; - _hw = (AMD17CPU)hw; - } - - public void AppendThread(CPUID thread, int core_id) - { - Core core = null; - foreach (var c in Cores) - { - if (c.CoreId == core_id) - core = c; - } - if (core == null) - { - core = new Core(_hw, core_id); - Cores.Add(core); - } - if (thread != null) - core.Threads.Add(thread); - } - - #region UpdateSensors - public void UpdateSensors() - { - } - #endregion - } - #endregion - - #region Core - private class Core - { - private DateTime _lastPwrTime = new DateTime(0); - private uint _lastPwrValue = 0; - private AMD17CPU _hw = null; - private Sensor _clock = null; - private Sensor _vcore = null; - private Sensor _power = null; - private Sensor _multiplier = null; - public int CoreId { get; private set; } - public List Threads { get; private set; } - - public Core(Hardware hw, int id) - { - Threads = new List(); - CoreId = id; - _hw = (AMD17CPU)hw; - _clock = new Sensor("Core #" + CoreId.ToString(), _hw._sensorClock++, SensorType.Clock, _hw, _hw.settings); - _multiplier = new Sensor("Core #" + CoreId.ToString(), _hw._sensorMulti++, SensorType.Factor, _hw, _hw.settings); - _power = new Sensor("Core #" + CoreId.ToString() + " (SMU)", _hw._sensorPower++, SensorType.Power, _hw, _hw.settings); - _vcore = new Sensor("Core #" + CoreId.ToString() + " VID", _hw._sensorVoltage++, SensorType.Voltage, _hw, _hw.settings); - - _hw.ActivateSensor(_clock); - _hw.ActivateSensor(_multiplier); - _hw.ActivateSensor(_power); - _hw.ActivateSensor(_vcore); - } - - #region UpdateSensors - public void UpdateSensors() - { - // CPUID cpu = threads.FirstOrDefault(); - CPUID cpu = Threads[0]; - if (cpu == null) - return; - uint eax, edx; - ulong mask = Ring0.ThreadAffinitySet(1UL << cpu.Thread); - - // MSRC001_0299 - // TU [19:16] - // ESU [12:8] -> Unit 15.3 micro Joule per increment - // PU [3:0] - Ring0.Rdmsr(MSR_PWR_UNIT, out eax, out edx); - int tu = (int)((eax >> 16) & 0xf); - int esu = (int)((eax >> 12) & 0xf); - int pu = (int)(eax & 0xf); - - // MSRC001_029A - // total_energy [31:0] - DateTime sample_time = DateTime.Now; - Ring0.Rdmsr(MSR_CORE_ENERGY_STAT, out eax, out edx); - uint total_energy = eax; - - // MSRC001_0293 - // CurHwPstate [24:22] - // CurCpuVid [21:14] - // CurCpuDfsId [13:8] - // CurCpuFid [7:0] - Ring0.Rdmsr(MSR_HARDWARE_PSTATE_STATUS, out eax, out edx); - int CurHwPstate = (int)((eax >> 22) & 0x3); - int CurCpuVid = (int)((eax >> 14) & 0xff); - int CurCpuDfsId = (int)((eax >> 8) & 0x3f); - int CurCpuFid = (int)(eax & 0xff); - - // MSRC001_0064 + x - // IddDiv [31:30] - // IddValue [29:22] - // CpuVid [21:14] - // CpuDfsId [13:8] - // CpuFid [7:0] - // Ring0.Rdmsr(MSR_PSTATE_0 + (uint)CurHwPstate, out eax, out edx); - // int IddDiv = (int)((eax >> 30) & 0x03); - // int IddValue = (int)((eax >> 22) & 0xff); - // int CpuVid = (int)((eax >> 14) & 0xff); - Ring0.ThreadAffinitySet(mask); - - // clock - // CoreCOF is (Core::X86::Msr::PStateDef[CpuFid[7:0]] / Core::X86::Msr::PStateDef[CpuDfsId]) * 200 - _clock.Value = (float)((double)CurCpuFid / (double)CurCpuDfsId * 200.0); - - // multiplier - _multiplier.Value = (float)((double)CurCpuFid / (double)CurCpuDfsId * 2.0); - - // Voltage - double VIDStep = 0.00625; - double vcc = 1.550 - (double)VIDStep * CurCpuVid; - _vcore.Value = (float)vcc; - - // power consumption - // power.Value = (float) ((double)pu * 0.125); - // esu = 15.3 micro Joule per increment - if (_lastPwrTime.Ticks == 0) - { - _lastPwrTime = sample_time; - _lastPwrValue = total_energy; - } - // ticks diff - TimeSpan time = sample_time - _lastPwrTime; - long pwr; - if (_lastPwrValue <= total_energy) - pwr = total_energy - _lastPwrValue; - else - pwr = (0xffffffff - _lastPwrValue) + total_energy; - - // update for next sample - _lastPwrTime = sample_time; - _lastPwrValue = total_energy; - - double energy = 15.3e-6 * pwr; - energy /= time.TotalSeconds; - - _power.Value = (float)energy; - } - #endregion - } - #endregion - - private Processor _ryzen = null; - - public AMD17CPU(int processorIndex, CPUID[][] cpuid, ISettings settings) - : base(processorIndex, cpuid, settings) - { - // add all numa nodes - // Register ..1E_ECX, [10:8] + 1 - _ryzen = new Processor(this); - int NodesPerProcessor = 1 + (int)((cpuid[0][0].ExtData[0x1e, ECX] >> 8) & 0x7); - - // add all numa nodes - foreach (CPUID[] cpu in cpuid) - { - CPUID thread = cpu[0]; - - // coreID - // Register ..1E_EBX, [7:0] - int core_id = (int)(thread.ExtData[0x1e, EBX] & 0xff); - - // nodeID - // Register ..1E_ECX, [7:0] - int node_id = (int)(thread.ExtData[0x1e, ECX] & 0xff); - - _ryzen.AppendThread(null, node_id, core_id); - } - - // add all threads to numa nodes and specific core - foreach (CPUID[] cpu in cpuid) - { - CPUID thread = cpu[0]; - - // coreID - // Register ..1E_EBX, [7:0] - int core_id = (int)(thread.ExtData[0x1e, EBX] & 0xff); - - // nodeID - // Register ..1E_ECX, [7:0] - int node_id = (int)(thread.ExtData[0x1e, ECX] & 0xff); - - _ryzen.AppendThread(thread, node_id, core_id); - } - Update(); - } - - protected override uint[] GetMSRs() - { - return new uint[] { PERF_CTL_0, PERF_CTR_0, HWCR, MSR_PSTATE_0, COFVID_STATUS }; - } - - public override string GetReport() - { - StringBuilder r = new StringBuilder(); - r.Append(base.GetReport()); - r.Append("Ryzen"); - return r.ToString(); - } - - private string ReadFirstLine(Stream stream) - { - StringBuilder sb = new StringBuilder(); - try - { - stream.Seek(0, SeekOrigin.Begin); - int b = stream.ReadByte(); - while (b != -1 && b != 10) - { - sb.Append((char)b); - b = stream.ReadByte(); - } - } - catch { } - return sb.ToString(); - } - - public override void Update() - { - base.Update(); - - _ryzen.UpdateSensors(); - foreach (NumaNode node in _ryzen.Nodes) - { - node.UpdateSensors(); - - foreach (Core c in node.Cores) - { - c.UpdateSensors(); - } - } - } - - public override void Close() - { - base.Close(); - } - } -} + _hw.ActivateSensor(_socVoltage); + } + + } + #endregion + + public void AppendThread(CPUID thread, int numa_id, int core_id) + { + NumaNode node = null; + foreach (var n in Nodes) + { + if (n.NodeId == numa_id) + node = n; + } + if (node == null) + { + node = new NumaNode(_hw, numa_id); + Nodes.Add(node); + } + if (thread != null) + node.AppendThread(thread, core_id); + } + } + #endregion + + #region NumaNode + private class NumaNode + { + private AMD17CPU _hw = null; + public int NodeId { get; private set; } + public List Cores { get; private set; } + + public NumaNode(Hardware hw, int id) + { + Cores = new List(); + NodeId = id; + _hw = (AMD17CPU)hw; + } + + public void AppendThread(CPUID thread, int core_id) + { + Core core = null; + foreach (var c in Cores) + { + if (c.CoreId == core_id) + core = c; + } + if (core == null) + { + core = new Core(_hw, core_id); + Cores.Add(core); + } + if (thread != null) + core.Threads.Add(thread); + } + + #region UpdateSensors + public void UpdateSensors() + { + } + #endregion + } + #endregion + + #region Core + private class Core + { + private DateTime _lastPwrTime = new DateTime(0); + private uint _lastPwrValue = 0; + private AMD17CPU _hw = null; + private Sensor _clock = null; + private Sensor _vcore = null; + private Sensor _power = null; + private Sensor _multiplier = null; + public int CoreId { get; private set; } + public List Threads { get; private set; } + + public Core(Hardware hw, int id) + { + Threads = new List(); + CoreId = id; + _hw = (AMD17CPU)hw; + _clock = new Sensor("Core #" + CoreId.ToString(), _hw._sensorClock++, SensorType.Clock, _hw, _hw.settings); + _multiplier = new Sensor("Core #" + CoreId.ToString(), _hw._sensorMulti++, SensorType.Factor, _hw, _hw.settings); + _power = new Sensor("Core #" + CoreId.ToString() + " (SMU)", _hw._sensorPower++, SensorType.Power, _hw, _hw.settings); + _vcore = new Sensor("Core #" + CoreId.ToString() + " VID", _hw._sensorVoltage++, SensorType.Voltage, _hw, _hw.settings); + + _hw.ActivateSensor(_clock); + _hw.ActivateSensor(_multiplier); + _hw.ActivateSensor(_power); + _hw.ActivateSensor(_vcore); + } + + #region UpdateSensors + public void UpdateSensors() + { + // CPUID cpu = threads.FirstOrDefault(); + CPUID cpu = Threads[0]; + if (cpu == null) + return; + uint eax, edx; + ulong mask = Ring0.ThreadAffinitySet(1UL << cpu.Thread); + + // MSRC001_0299 + // TU [19:16] + // ESU [12:8] -> Unit 15.3 micro Joule per increment + // PU [3:0] + Ring0.Rdmsr(MSR_PWR_UNIT, out eax, out edx); + int tu = (int)((eax >> 16) & 0xf); + int esu = (int)((eax >> 12) & 0xf); + int pu = (int)(eax & 0xf); + + // MSRC001_029A + // total_energy [31:0] + DateTime sample_time = DateTime.Now; + Ring0.Rdmsr(MSR_CORE_ENERGY_STAT, out eax, out edx); + uint total_energy = eax; + + // MSRC001_0293 + // CurHwPstate [24:22] + // CurCpuVid [21:14] + // CurCpuDfsId [13:8] + // CurCpuFid [7:0] + Ring0.Rdmsr(MSR_HARDWARE_PSTATE_STATUS, out eax, out edx); + int CurHwPstate = (int)((eax >> 22) & 0x3); + int CurCpuVid = (int)((eax >> 14) & 0xff); + int CurCpuDfsId = (int)((eax >> 8) & 0x3f); + int CurCpuFid = (int)(eax & 0xff); + + // MSRC001_0064 + x + // IddDiv [31:30] + // IddValue [29:22] + // CpuVid [21:14] + // CpuDfsId [13:8] + // CpuFid [7:0] + // Ring0.Rdmsr(MSR_PSTATE_0 + (uint)CurHwPstate, out eax, out edx); + // int IddDiv = (int)((eax >> 30) & 0x03); + // int IddValue = (int)((eax >> 22) & 0xff); + // int CpuVid = (int)((eax >> 14) & 0xff); + Ring0.ThreadAffinitySet(mask); + + // clock + // CoreCOF is (Core::X86::Msr::PStateDef[CpuFid[7:0]] / Core::X86::Msr::PStateDef[CpuDfsId]) * 200 + _clock.Value = (float)((double)CurCpuFid / (double)CurCpuDfsId * 200.0); + + // multiplier + _multiplier.Value = (float)((double)CurCpuFid / (double)CurCpuDfsId * 2.0); + + // Voltage + double VIDStep = 0.00625; + double vcc = 1.550 - (double)VIDStep * CurCpuVid; + _vcore.Value = (float)vcc; + + // power consumption + // power.Value = (float) ((double)pu * 0.125); + // esu = 15.3 micro Joule per increment + if (_lastPwrTime.Ticks == 0) + { + _lastPwrTime = sample_time; + _lastPwrValue = total_energy; + } + // ticks diff + TimeSpan time = sample_time - _lastPwrTime; + long pwr; + if (_lastPwrValue <= total_energy) + pwr = total_energy - _lastPwrValue; + else + pwr = (0xffffffff - _lastPwrValue) + total_energy; + + // update for next sample + _lastPwrTime = sample_time; + _lastPwrValue = total_energy; + + double energy = 15.3e-6 * pwr; + energy /= time.TotalSeconds; + + if (!double.IsNaN(energy)) + _power.Value = (float)energy; + } + #endregion + } + #endregion + + private Processor _ryzen = null; + + public AMD17CPU(int processorIndex, CPUID[][] cpuid, ISettings settings) + : base(processorIndex, cpuid, settings) + { + // add all numa nodes + // Register ..1E_ECX, [10:8] + 1 + _ryzen = new Processor(this); + int NodesPerProcessor = 1 + (int)((cpuid[0][0].ExtData[0x1e, ECX] >> 8) & 0x7); + + // add all numa nodes + foreach (CPUID[] cpu in cpuid) + { + CPUID thread = cpu[0]; + + // coreID + // Register ..1E_EBX, [7:0] + int core_id = (int)(thread.ExtData[0x1e, EBX] & 0xff); + + // nodeID + // Register ..1E_ECX, [7:0] + int node_id = (int)(thread.ExtData[0x1e, ECX] & 0xff); + + _ryzen.AppendThread(null, node_id, core_id); + } + + // add all threads to numa nodes and specific core + foreach (CPUID[] cpu in cpuid) + { + CPUID thread = cpu[0]; + + // coreID + // Register ..1E_EBX, [7:0] + int core_id = (int)(thread.ExtData[0x1e, EBX] & 0xff); + + // nodeID + // Register ..1E_ECX, [7:0] + int node_id = (int)(thread.ExtData[0x1e, ECX] & 0xff); + + _ryzen.AppendThread(thread, node_id, core_id); + } + Update(); + } + + protected override uint[] GetMSRs() + { + return new uint[] { PERF_CTL_0, PERF_CTR_0, HWCR, MSR_PSTATE_0, COFVID_STATUS }; + } + + public override string GetReport() + { + StringBuilder r = new StringBuilder(); + r.Append(base.GetReport()); + r.Append("Ryzen"); + return r.ToString(); + } + + private string ReadFirstLine(Stream stream) + { + StringBuilder sb = new StringBuilder(); + try + { + stream.Seek(0, SeekOrigin.Begin); + int b = stream.ReadByte(); + while (b != -1 && b != 10) + { + sb.Append((char)b); + b = stream.ReadByte(); + } + } + catch { } + return sb.ToString(); + } + + public override void Update() + { + base.Update(); + + _ryzen.UpdateSensors(); + foreach (NumaNode node in _ryzen.Nodes) + { + node.UpdateSensors(); + + foreach (Core c in node.Cores) + { + c.UpdateSensors(); + } + } + } + + public override void Close() + { + base.Close(); + } + } +} diff --git a/Hardware/CPU/CPUGroup.cs b/Hardware/CPU/CPUGroup.cs index c72f86e..7d7914e 100644 --- a/Hardware/CPU/CPUGroup.cs +++ b/Hardware/CPU/CPUGroup.cs @@ -1,11 +1,11 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2009-2014 Michael Möller - + */ using System; @@ -24,9 +24,15 @@ namespace OpenHardwareMonitor.Hardware.CPU { List threads = new List(); for (int i = 0; i < 64; i++) { - try { + try + { threads.Add(new CPUID(i)); - } catch (ArgumentOutOfRangeException) { } + } + catch (ArgumentOutOfRangeException) + { + // All cores found. + break; + } } SortedDictionary> processors = @@ -52,7 +58,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { private static CPUID[][] GroupThreadsByCore(IEnumerable threads) { - SortedDictionary> cores = + SortedDictionary> cores = new SortedDictionary>(); foreach (CPUID thread in threads) { List coreList; @@ -82,7 +88,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { foreach (CPUID[] threads in processorThreads) { if (threads.Length == 0) continue; - + CPUID[][] coreThreads = GroupThreadsByCore(threads); this.threads[index] = coreThreads; @@ -122,8 +128,8 @@ namespace OpenHardwareMonitor.Hardware.CPU { public IEnumerable Hardware => hardware; - private static void AppendCpuidData(StringBuilder r, uint[,] data, - uint offset) + private static void AppendCpuidData(StringBuilder r, uint[,] data, + uint offset) { for (int i = 0; i < data.GetLength(0); i++) { r.Append(" "); @@ -139,9 +145,9 @@ namespace OpenHardwareMonitor.Hardware.CPU { public string GetReport() { if (threads == null) return null; - + StringBuilder r = new StringBuilder(); - + r.AppendLine("CPUID"); r.AppendLine(); @@ -153,14 +159,14 @@ namespace OpenHardwareMonitor.Hardware.CPU { Environment.NewLine); r.AppendFormat("Processor Brand: {0}{1}", threads[i][0][0].BrandString, Environment.NewLine); - r.AppendFormat("Family: 0x{0}{1}", - threads[i][0][0].Family.ToString("X", CultureInfo.InvariantCulture), + r.AppendFormat("Family: 0x{0}{1}", + threads[i][0][0].Family.ToString("X", CultureInfo.InvariantCulture), Environment.NewLine); r.AppendFormat("Model: 0x{0}{1}", - threads[i][0][0].Model.ToString("X", CultureInfo.InvariantCulture), + threads[i][0][0].Model.ToString("X", CultureInfo.InvariantCulture), Environment.NewLine); r.AppendFormat("Stepping: 0x{0}{1}", - threads[i][0][0].Stepping.ToString("X", CultureInfo.InvariantCulture), + threads[i][0][0].Stepping.ToString("X", CultureInfo.InvariantCulture), Environment.NewLine); r.AppendLine(); @@ -180,7 +186,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { r.AppendLine(); } } - return r.ToString(); + return r.ToString(); } public void Close() { diff --git a/Hardware/CPU/IntelCPU.cs b/Hardware/CPU/IntelCPU.cs index 190ced7..a27dae9 100644 --- a/Hardware/CPU/IntelCPU.cs +++ b/Hardware/CPU/IntelCPU.cs @@ -1,11 +1,11 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2009-2017 Michael Möller - + */ using System; @@ -38,6 +38,9 @@ namespace OpenHardwareMonitor.Hardware.CPU { private readonly Sensor[] coreClocks; private readonly Sensor busClock; private readonly Sensor[] powerSensors; + private readonly Sensor[] distToTjMaxTemperatures; + private readonly Sensor coreMax; + private readonly Sensor coreAvg; private readonly Microarchitecture microarchitecture; private readonly double timeStampCounterMultiplier; @@ -53,9 +56,9 @@ namespace OpenHardwareMonitor.Hardware.CPU { private const uint MSR_PP0_ENERY_STATUS = 0x639; private const uint MSR_PP1_ENERY_STATUS = 0x641; - private readonly uint[] energyStatusMSRs = { MSR_PKG_ENERY_STATUS, + private readonly uint[] energyStatusMSRs = { MSR_PKG_ENERY_STATUS, MSR_PP0_ENERY_STATUS, MSR_PP1_ENERY_STATUS, MSR_DRAM_ENERGY_STATUS }; - private readonly string[] powerSensorLabels = + private readonly string[] powerSensorLabels = { "CPU Package", "CPU Cores", "CPU Graphics", "CPU DRAM" }; private float energyUnitMultiplier = 0; private DateTime[] lastEnergyTime; @@ -125,7 +128,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { } break; case 0x1A: // Intel Core i7 LGA1366 (45nm) case 0x1E: // Intel Core i5, i7 LGA1156 (45nm) - case 0x1F: // Intel Core i5, i7 + case 0x1F: // Intel Core i5, i7 case 0x25: // Intel Core i3, i5, i7 LGA1156 (32nm) case 0x2C: // Intel Core i7 LGA1366 (32nm) 6 Core case 0x2E: // Intel Xeon Processor 7500 series (45nm) @@ -143,11 +146,11 @@ namespace OpenHardwareMonitor.Hardware.CPU { microarchitecture = Microarchitecture.IvyBridge; tjMax = GetTjMaxFromMSR(); break; - case 0x3C: // Intel Core i5, i7 4xxx LGA1150 (22nm) + case 0x3C: // Intel Core i5, i7 4xxx LGA1150 (22nm) case 0x3F: // Intel Xeon E5-2600/1600 v3, Core i7-59xx // LGA2011-v3, Haswell-E (22nm) case 0x45: // Intel Core i5, i7 4xxxU (22nm) - case 0x46: + case 0x46: microarchitecture = Microarchitecture.Haswell; tjMax = GetTjMaxFromMSR(); break; @@ -180,7 +183,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { microarchitecture = Microarchitecture.Airmont; tjMax = GetTjMaxFromMSR(); break; - case 0x8E: + case 0x8E: case 0x9E: // Intel Core i5, i7 7xxxx (14nm) microarchitecture = Microarchitecture.KabyLake; tjMax = GetTjMaxFromMSR(); @@ -188,7 +191,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { case 0x5C: // Intel ApolloLake microarchitecture = Microarchitecture.ApolloLake; tjMax = GetTjMaxFromMSR(); - break; + break; case 0xAE: // Intel Core i5, i7 8xxxx (14nm++) microarchitecture = Microarchitecture.CoffeeLake; tjMax = GetTjMaxFromMSR(); @@ -236,7 +239,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { case Microarchitecture.Nehalem: case Microarchitecture.SandyBridge: case Microarchitecture.IvyBridge: - case Microarchitecture.Haswell: + case Microarchitecture.Haswell: case Microarchitecture.Broadwell: case Microarchitecture.Silvermont: case Microarchitecture.Skylake: @@ -249,53 +252,86 @@ namespace OpenHardwareMonitor.Hardware.CPU { timeStampCounterMultiplier = (eax >> 8) & 0xff; } } break; - default: + default: timeStampCounterMultiplier = 0; break; } + int coreSensorId = 0; + // check if processor supports a digital thermal sensor at core level - if (cpuid[0][0].Data.GetLength(0) > 6 && - (cpuid[0][0].Data[6, 0] & 1) != 0 && - microarchitecture != Microarchitecture.Unknown) + if (cpuid[0][0].Data.GetLength(0) > 6 && (cpuid[0][0].Data[6, 0] & 1) != 0 && microarchitecture != Microarchitecture.Unknown) { coreTemperatures = new Sensor[coreCount]; - for (int i = 0; i < coreTemperatures.Length; i++) { - coreTemperatures[i] = new Sensor(CoreString(i), i, - SensorType.Temperature, this, new[] { + for (int i = 0; i < coreTemperatures.Length; i++) + { + coreTemperatures[i] = new Sensor(CoreString(i), coreSensorId, SensorType.Temperature, this, new[] { new ParameterDescription( - "TjMax [°C]", "TjMax temperature of the core sensor.\n" + - "Temperature = TjMax - TSlope * Value.", tjMax[i]), - new ParameterDescription("TSlope [°C]", - "Temperature slope of the digital thermal sensor.\n" + + "TjMax [°C]", "TjMax temperature of the core sensor.\n" + + "Temperature = TjMax - TSlope * Value.", tjMax[i]), + new ParameterDescription("TSlope [°C]", + "Temperature slope of the digital thermal sensor.\n" + "Temperature = TjMax - TSlope * Value.", 1)}, settings); ActivateSensor(coreTemperatures[i]); + coreSensorId++; } } else { coreTemperatures = new Sensor[0]; } // check if processor supports a digital thermal sensor at package level - if (cpuid[0][0].Data.GetLength(0) > 6 && - (cpuid[0][0].Data[6, 0] & 0x40) != 0 && - microarchitecture != Microarchitecture.Unknown) + if (cpuid[0][0].Data.GetLength(0) > 6 && (cpuid[0][0].Data[6, 0] & 0x40) != 0 && microarchitecture != Microarchitecture.Unknown) { - packageTemperature = new Sensor("CPU Package", - coreTemperatures.Length, SensorType.Temperature, this, new[] { + packageTemperature = new Sensor("CPU Package", coreSensorId, SensorType.Temperature, this, new[] { new ParameterDescription( - "TjMax [°C]", "TjMax temperature of the package sensor.\n" + - "Temperature = TjMax - TSlope * Value.", tjMax[0]), - new ParameterDescription("TSlope [°C]", - "Temperature slope of the digital thermal sensor.\n" + + "TjMax [°C]", "TjMax temperature of the package sensor.\n" + + "Temperature = TjMax - TSlope * Value.", tjMax[0]), + new ParameterDescription("TSlope [°C]", + "Temperature slope of the digital thermal sensor.\n" + "Temperature = TjMax - TSlope * Value.", 1)}, settings); ActivateSensor(packageTemperature); + coreSensorId++; + } + + // dist to tjmax sensor + if (cpuid[0][0].Data.GetLength(0) > 6 && (cpuid[0][0].Data[6, 0] & 1) != 0 && microarchitecture != Microarchitecture.Unknown) + { + distToTjMaxTemperatures = new Sensor[coreCount]; + for (int i = 0; i < distToTjMaxTemperatures.Length; i++) + { + distToTjMaxTemperatures[i] = new Sensor(CoreString(i) + " Distance to TjMax", coreSensorId, SensorType.Temperature, this, settings); + ActivateSensor(distToTjMaxTemperatures[i]); + coreSensorId++; + } + } + else + { + distToTjMaxTemperatures = new Sensor[0]; + } + + //core temp avg and max value + //is only available when the cpu has more than 1 core + if (cpuid[0][0].Data.GetLength(0) > 6 && (cpuid[0][0].Data[6, 0] & 0x40) != 0 && microarchitecture != Microarchitecture.Unknown && coreCount > 1) + { + coreMax = new Sensor("Core Max", coreSensorId, SensorType.Temperature, this, settings); + ActivateSensor(coreMax); + coreSensorId++; + + coreAvg = new Sensor("Core Average", coreSensorId, SensorType.Temperature, this, settings); + ActivateSensor(coreAvg); + coreSensorId++; + } + else + { + coreMax = null; + coreAvg = null; } busClock = new Sensor("Bus Speed", 0, SensorType.Clock, this, settings); coreClocks = new Sensor[coreCount]; - for (int i = 0; i < coreClocks.Length; i++) { - coreClocks[i] = - new Sensor(CoreString(i), i + 1, SensorType.Clock, this, settings); + for (int i = 0; i < coreClocks.Length; i++) + { + coreClocks[i] = new Sensor(CoreString(i), i + 1, SensorType.Clock, this, settings); if (HasTimeStampCounter && microarchitecture != Microarchitecture.Unknown) ActivateSensor(coreClocks[i]); } @@ -303,12 +339,12 @@ namespace OpenHardwareMonitor.Hardware.CPU { if (microarchitecture == Microarchitecture.SandyBridge || microarchitecture == Microarchitecture.IvyBridge || microarchitecture == Microarchitecture.Haswell || - microarchitecture == Microarchitecture.Broadwell || + microarchitecture == Microarchitecture.Broadwell || microarchitecture == Microarchitecture.Skylake || microarchitecture == Microarchitecture.Silvermont || microarchitecture == Microarchitecture.Airmont || microarchitecture == Microarchitecture.KabyLake || - microarchitecture == Microarchitecture.ApolloLake) + microarchitecture == Microarchitecture.ApolloLake) { powerSensors = new Sensor[energyStatusMSRs.Length]; lastEnergyTime = new DateTime[energyStatusMSRs.Length]; @@ -374,27 +410,45 @@ namespace OpenHardwareMonitor.Hardware.CPU { public override void Update() { base.Update(); + float core_max = float.MinValue; + float core_avg = 0; + for (int i = 0; i < coreTemperatures.Length; i++) { uint eax, edx; // if reading is valid - if (Ring0.RdmsrTx(IA32_THERM_STATUS_MSR, out eax, out edx, - 1UL << cpuid[i][0].Thread) && (eax & 0x80000000) != 0) + if (Ring0.RdmsrTx(IA32_THERM_STATUS_MSR, out eax, out edx, 1UL << cpuid[i][0].Thread) && (eax & 0x80000000) != 0) { // get the dist from tjMax from bits 22:16 float deltaT = ((eax & 0x007F0000) >> 16); float tjMax = coreTemperatures[i].Parameters[0].Value; float tSlope = coreTemperatures[i].Parameters[1].Value; coreTemperatures[i].Value = tjMax - tSlope * deltaT; + + core_avg += (float)coreTemperatures[i].Value; + if (core_max < coreTemperatures[i].Value) + core_max = (float)coreTemperatures[i].Value; + + distToTjMaxTemperatures[i].Value = deltaT; + } else { coreTemperatures[i].Value = null; + distToTjMaxTemperatures[i].Value = null; } } + //calculate average cpu temperature over all cores + if (coreMax != null && core_max != float.MinValue) + { + coreMax.Value = core_max; + core_avg /= coreTemperatures.Length; + coreAvg.Value = core_avg; + } + if (packageTemperature != null) { uint eax, edx; // if reading is valid if (Ring0.RdmsrTx(IA32_PACKAGE_THERM_STATUS, out eax, out edx, - 1UL << cpuid[0][0].Thread) && (eax & 0x80000000) != 0) + 1UL << cpuid[0][0].Thread) && (eax & 0x80000000) != 0) { // get the dist from tjMax from bits 22:16 float deltaT = ((eax & 0x007F0000) >> 16); @@ -422,7 +476,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { } break; case Microarchitecture.SandyBridge: case Microarchitecture.IvyBridge: - case Microarchitecture.Haswell: + case Microarchitecture.Haswell: case Microarchitecture.Broadwell: case Microarchitecture.Silvermont: case Microarchitecture.Skylake: diff --git a/Hardware/Computer.cs b/Hardware/Computer.cs index 2947909..c1946b1 100644 --- a/Hardware/Computer.cs +++ b/Hardware/Computer.cs @@ -1,11 +1,11 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2009-2012 Michael Möller - + */ using System; @@ -32,7 +32,7 @@ namespace OpenHardwareMonitor.Hardware { private bool ramEnabled; private bool gpuEnabled; private bool fanControllerEnabled; - private bool hddEnabled; + private bool hddEnabled; private bool nicEnabled; private int nicCount; @@ -89,7 +89,7 @@ namespace OpenHardwareMonitor.Hardware { if (mainboardEnabled) Add(new Mainboard.MainboardGroup(smbios, settings)); - + if (cpuEnabled) Add(new CPU.CPUGroup(settings)); @@ -162,7 +162,7 @@ namespace OpenHardwareMonitor.Hardware { } ramEnabled = value; } - } + } public bool GPUEnabled { get { return gpuEnabled; } @@ -258,7 +258,7 @@ namespace OpenHardwareMonitor.Hardware { } private static void ReportHardwareSensorTree( - IHardware hardware, TextWriter w, string space) + IHardware hardware, TextWriter w, string space) { w.WriteLine("{0}|", space); w.WriteLine("{0}+- {1} ({2})", @@ -266,8 +266,8 @@ namespace OpenHardwareMonitor.Hardware { ISensor[] sensors = hardware.Sensors; Array.Sort(sensors, CompareSensor); foreach (ISensor sensor in sensors) { - w.WriteLine("{0}| +- {1,-14} : {2,8:G6} {3,8:G6} {4,8:G6} ({5})", - space, sensor.Name, sensor.Value, sensor.Min, sensor.Max, + w.WriteLine("{0}| +- {1,-14} : {2,8:G6} {3,8:G6} {4,8:G6} ({5})", + space, sensor.Name, sensor.Value, sensor.Min, sensor.Max, sensor.Identifier); } foreach (IHardware subHardware in hardware.SubHardware) @@ -374,14 +374,14 @@ namespace OpenHardwareMonitor.Hardware { } } - public void Close() { + public void Close() { if (!open) return; while (groups.Count > 0) { IGroup group = groups[groups.Count - 1]; - Remove(group); - } + Remove(group); + } Opcode.Close(); Ring0.Close(); @@ -421,4 +421,4 @@ namespace OpenHardwareMonitor.Hardware { public void Remove(string name) { } } } -} +} \ No newline at end of file diff --git a/Hardware/LPC/Chip.cs b/Hardware/LPC/Chip.cs index 4106215..89bd226 100644 --- a/Hardware/LPC/Chip.cs +++ b/Hardware/LPC/Chip.cs @@ -1,11 +1,11 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2009-2015 Michael Möller - + */ namespace OpenHardwareMonitor.Hardware.LPC { @@ -16,7 +16,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { ATK0110 = 0x0110, F71858 = 0x0507, - F71862 = 0x0601, + F71862 = 0x0601, F71869 = 0x0814, F71869A = 0x1007, F71878AD = 0x1106, @@ -56,7 +56,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { W83627DHG = 0xA020, W83627DHGP = 0xB070, - W83627EHF = 0x8800, + W83627EHF = 0x8800, W83627HF = 0x5200, W83627THF = 0x8280, W83667HG = 0xA510, @@ -91,7 +91,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { case Chip.IT8705F: return "ITE IT8705F"; case Chip.IT8712F: return "ITE IT8712F"; case Chip.IT8716F: return "ITE IT8716F"; - case Chip.IT8718F: return "ITE IT8718F"; + case Chip.IT8718F: return "ITE IT8718F"; case Chip.IT8720F: return "ITE IT8720F"; case Chip.IT8721F: return "ITE IT8721F"; case Chip.IT8726F: return "ITE IT8726F"; diff --git a/Hardware/LPC/IT87XX.cs b/Hardware/LPC/IT87XX.cs index 81eb9a1..035bbe2 100644 --- a/Hardware/LPC/IT87XX.cs +++ b/Hardware/LPC/IT87XX.cs @@ -1,11 +1,11 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2009-2015 Michael Möller - + */ using System.Globalization; @@ -14,7 +14,7 @@ using System; namespace OpenHardwareMonitor.Hardware.LPC { internal class IT87XX : ISuperIO { - + private readonly ushort address; private readonly Chip chip; private readonly byte version; @@ -37,18 +37,18 @@ namespace OpenHardwareMonitor.Hardware.LPC { // Consts private const byte ITE_VENDOR_ID = 0x90; - + // Environment Controller private const byte ADDRESS_REGISTER_OFFSET = 0x05; private const byte DATA_REGISTER_OFFSET = 0x06; - // Environment Controller Registers + // Environment Controller Registers private const byte CONFIGURATION_REGISTER = 0x00; private const byte TEMPERATURE_BASE_REG = 0x29; private const byte VENDOR_ID_REGISTER = 0x58; private const byte FAN_TACHOMETER_DIVISOR_REGISTER = 0x0B; private const byte FAN_TACHOMETER_16BIT_REGISTER = 0x0C; - private readonly byte[] FAN_TACHOMETER_REG = + private readonly byte[] FAN_TACHOMETER_REG = { 0x0d, 0x0e, 0x0f, 0x80, 0x82, 0x4c }; private readonly byte[] FAN_TACHOMETER_EXT_REG = { 0x18, 0x19, 0x1a, 0x81, 0x83, 0x4c }; @@ -56,7 +56,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { private readonly byte[] FAN_PWM_CTRL_REG = { 0x15, 0x16, 0x17 }; private readonly byte[] FAN_PWM_DUTY_REG = { 0x63, 0x6b, 0x73 }; - private bool[] restoreDefaultFanPwmControlRequired = new bool[3]; + private bool[] restoreDefaultFanPwmControlRequired = new bool[3]; private byte[] initialFanPwmControl = new byte[3]; private byte[] initialFanPwmControlMode = new byte[3]; @@ -64,7 +64,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { Ring0.WriteIoPort(addressReg, register); byte value = Ring0.ReadIoPort(dataReg); valid = register == Ring0.ReadIoPort(addressReg); - // IT8688E doesn't return the value we wrote to + // IT8688E doesn't return the value we wrote to // addressReg when we read it back. if (this.chip == Chip.IT8688E) valid = true; @@ -74,7 +74,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { private bool WriteByte(byte register, byte value) { Ring0.WriteIoPort(addressReg, register); Ring0.WriteIoPort(dataReg, value); - return register == Ring0.ReadIoPort(addressReg); + return register == Ring0.ReadIoPort(addressReg); } public byte? ReadGPIO(int index) { @@ -89,7 +89,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { return; Ring0.WriteIoPort((ushort)(gpioAddress + index), value); - } + } private void SaveDefaultFanPwmControl(int index) { bool valid; @@ -101,8 +101,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { initialFanPwmControl[index] = ReadByte(FAN_PWM_DUTY_REG[index], out valid); } - } - else { + } else { if (!restoreDefaultFanPwmControlRequired[index]) { initialFanPwmControl[index] = ReadByte(FAN_PWM_CTRL_REG[index], out valid); @@ -119,8 +118,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { WriteByte(FAN_PWM_DUTY_REG[index], initialFanPwmControl[index]); restoreDefaultFanPwmControlRequired[index] = false; } - } - else { + } else { if (restoreDefaultFanPwmControlRequired[index]) { WriteByte(FAN_PWM_CTRL_REG[index], initialFanPwmControl[index]); restoreDefaultFanPwmControlRequired[index] = false; @@ -153,13 +151,11 @@ namespace OpenHardwareMonitor.Hardware.LPC { // set speed WriteByte(FAN_PWM_DUTY_REG[index], value.Value); - } - else { + } else { // set output value WriteByte(FAN_PWM_CTRL_REG[index], (byte)((value.Value >> 1))); } - } - else { + } else { RestoreDefaultFanPwmControl(index); } @@ -177,20 +173,19 @@ namespace OpenHardwareMonitor.Hardware.LPC { // Check vendor id bool valid; - byte vendorId = ReadByte(VENDOR_ID_REGISTER, out valid); + byte vendorId = ReadByte(VENDOR_ID_REGISTER, out valid); if (!valid || vendorId != ITE_VENDOR_ID) return; // Bit 0x10 of the configuration register should always be 1 byte config = ReadByte(CONFIGURATION_REGISTER, out valid); - if ((config & 0x10) == 0 && chip != Chip.IT8665E) + if ((config & 0x10) == 0 && chip != Chip.IT8665E) return; if (!valid) return; // IT8686E has more sensors - if(chip == Chip.IT8686E) - { + if (chip == Chip.IT8686E) { voltages = new float?[10]; temperatures = new float?[5]; fans = new float?[5]; @@ -208,7 +203,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { fans = new float?[5]; fansDisabled = new bool[5]; controls = new float?[3]; - } else { + } else { voltages = new float?[9]; temperatures = new float?[3]; fans = new float?[chip == Chip.IT8705F ? 3 : 5]; @@ -216,49 +211,42 @@ namespace OpenHardwareMonitor.Hardware.LPC { controls = new float?[3]; } - // IT8620E, IT8628E, IT8721F, IT8728F, IT8772E and IT8686E use a 12mV resultion + // IT8620E, IT8628E, IT8721F, IT8728F, IT8772E and IT8686E use a 12mV resultion // ADC, all others 16mV - if (chip == Chip.IT8620E || chip == Chip.IT8628E || chip == Chip.IT8721F + if (chip == Chip.IT8620E || chip == Chip.IT8628E || chip == Chip.IT8721F || chip == Chip.IT8728F || chip == Chip.IT8771E || chip == Chip.IT8772E - || chip == Chip.IT8686E || chip == Chip.IT8688E) - { + || chip == Chip.IT8686E || chip == Chip.IT8688E) { voltageGain = 0.012f; - } - else if (chip == Chip.IT8665E) - { + } else if (chip == Chip.IT8665E) { voltageGain = 0.0109f; } else { - voltageGain = 0.016f; + voltageGain = 0.016f; } // older IT8705F and IT8721F revisions do not have 16-bit fan counters - if ((chip == Chip.IT8705F && version < 3) || - (chip == Chip.IT8712F && version < 8)) - { + if ((chip == Chip.IT8705F && version < 3) || + (chip == Chip.IT8712F && version < 8)) { has16bitFanCounter = false; } else { has16bitFanCounter = true; } - if(chip == Chip.IT8620E) { + if (chip == Chip.IT8620E) { hasNewerAutopwm = true; } // Disable any fans that aren't set with 16-bit fan counters - if (has16bitFanCounter) - { + if (has16bitFanCounter) { int modes = ReadByte(FAN_TACHOMETER_16BIT_REGISTER, out valid); if (!valid) return; - if (fans.Length >= 5) - { + if (fans.Length >= 5) { fansDisabled[3] = (modes & (1 << 4)) == 0; fansDisabled[4] = (modes & (1 << 5)) == 0; } - if (fans.Length >= 6) - { + if (fans.Length >= 6) { fansDisabled[5] = (modes & (1 << 2)) == 0; } } @@ -278,7 +266,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { case Chip.IT8620E: case Chip.IT8628E: case Chip.IT8688E: - case Chip.IT8705F: + case Chip.IT8705F: case Chip.IT8728F: case Chip.IT8771E: case Chip.IT8772E: @@ -315,8 +303,8 @@ namespace OpenHardwareMonitor.Hardware.LPC { r.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); r.AppendLine(); for (int i = 0; i <= 0xA; i++) { - r.Append(" "); - r.Append((i << 4).ToString("X2", CultureInfo.InvariantCulture)); + r.Append(" "); + r.Append((i << 4).ToString("X2", CultureInfo.InvariantCulture)); r.Append(" "); for (int j = 0; j <= 0xF; j++) { r.Append(" "); @@ -350,14 +338,14 @@ namespace OpenHardwareMonitor.Hardware.LPC { for (int i = 0; i < voltages.Length; i++) { bool valid; - - float value = - voltageGain * ReadByte((byte)(VOLTAGE_BASE_REG + i), out valid); + + float value = + voltageGain * ReadByte((byte)(VOLTAGE_BASE_REG + i), out valid); if (!valid) continue; if (value > 0) - voltages[i] = value; + voltages[i] = value; else voltages[i] = null; } @@ -372,13 +360,13 @@ namespace OpenHardwareMonitor.Hardware.LPC { if (value < sbyte.MaxValue && value > 0) temperatures[i] = value; else - temperatures[i] = null; + temperatures[i] = null; } if (has16bitFanCounter) { for (int i = 0; i < fans.Length; i++) { if (fansDisabled[i]) - continue; + continue; bool valid; int value = ReadByte(FAN_TACHOMETER_REG[i], out valid); if (!valid) @@ -430,12 +418,10 @@ namespace OpenHardwareMonitor.Hardware.LPC { if ((ctrlValue & 0x80) > 0) { // automatic operation (value can't be read) controls[i] = null; - } - else { + } else { controls[i] = (float)Math.Round((value) * 100.0f / 0xFF); } - } - else { + } else { bool valid; byte value = ReadByte(FAN_PWM_CTRL_REG[i], out valid); if (!valid) @@ -444,8 +430,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { if ((value & 0x80) > 0) { // automatic operation (value can't be read) controls[i] = null; - } - else { + } else { // software operation controls[i] = (float)Math.Round((value & 0x7F) * 100.0f / 0x7F); } @@ -454,5 +439,5 @@ namespace OpenHardwareMonitor.Hardware.LPC { Ring0.ReleaseIsaBusMutex(); } - } -} + } +} \ No newline at end of file diff --git a/Hardware/Mainboard/Identification.cs b/Hardware/Mainboard/Identification.cs index a034d0e..a8aaa40 100644 --- a/Hardware/Mainboard/Identification.cs +++ b/Hardware/Mainboard/Identification.cs @@ -1,11 +1,11 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2012 Michael Möller - + */ namespace OpenHardwareMonitor.Hardware.Mainboard { @@ -53,6 +53,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { case "LENOVO": return Manufacturer.Lenovo; case "Micro-Star International": + case "Micro-Star International Co., Ltd": case "MICRO-STAR INTERNATIONAL CO., LTD": case "MICRO-STAR INTERNATIONAL CO.,LTD": case "MSI": @@ -80,6 +81,21 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { return Model.B85M_DGS; case "ASRock AOD790GX/128M": return Model.AOD790GX_128M; + case "AB350 Pro4": + return Model.ASROCK_AB350_PRO4; + case "AB350M Pro4": + return Model.ASROCK_AB350M_PRO4; + case "AB350M": + return Model.ASROCK_AB350M; + case "Fatal1ty AB350 Gaming K4": + return Model.ASROCK_Fatal1ty_AB350_Gaming_K4; + case "AB350M-HDV": + return Model.ASROCK_AB350M_HDV; + case "X399 Phantom Gaming 6": + return Model.ASROCK_PHANTOM_GAMING_6; + case "A320M-HDV": + return Model.ASROCK_A320M_HDV; + case "P55 Deluxe": return Model.P55_Deluxe; case "Crosshair III Formula": @@ -184,6 +200,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { case "X58A-UD3R": return Model.X58A_UD3R; case "Z270 PC MATE": + case "Z270 PC MATE (MS-7A72)": return Model.Z270_PC_MATE; case "X79-UD3": return Model.X79_UD3; @@ -209,6 +226,23 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { return Model.PRIME_X370_PRO; case "ROG MAXIMUS X APEX": return Model.ROG_MAXIMUS_APEX; + case "AB350-Gaming 3-CF": + return Model.AB350_Gaming_3_CF; + case "X399 AORUS Gaming 7": + return Model.GIGABYTE_X399_AOURUS_GAMING7; + case "ROG ZENITH EXTREME": + return Model.ROG_ZENITH_EXTREME; + case "Z170-A": + return Model.ASUS_Z170_A; + case "Z77 Pro4-M": + return Model.ASROCK_Z77PRO4M; + case "AX370-Gaming 5": + return Model.AX370_Gaming_5; + case "TUF X470-PLUS GAMING": + return Model.TUF_X470_PLUS_GAMING; + case "B360M PRO-VDH (MS-7B24)": + return Model.B360M_PRO_VDH; + case "Base Board Product Name": case "To be filled by O.E.M.": return Model.Unknown; @@ -217,4 +251,4 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { } } } -} +} \ No newline at end of file diff --git a/Hardware/Mainboard/Model.cs b/Hardware/Mainboard/Model.cs index 1603939..7270ef2 100644 --- a/Hardware/Mainboard/Model.cs +++ b/Hardware/Mainboard/Model.cs @@ -1,11 +1,11 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2009-2012 Michael Möller - + */ namespace OpenHardwareMonitor.Hardware.Mainboard { @@ -16,14 +16,22 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { AOD790GX_128M, P55_Deluxe, B85M_DGS, + ASROCK_Z77PRO4M, + ASROCK_AB350M_PRO4, + ASROCK_AB350_PRO4, + ASROCK_AB350M, + ASROCK_Fatal1ty_AB350_Gaming_K4, + ASROCK_AB350M_HDV, + ASROCK_PHANTOM_GAMING_6, + ASROCK_A320M_HDV, // ASUS Crosshair_III_Formula, M2N_SLI_DELUXE, M4A79XTD_EVO, - P5W_DH_Deluxe, + P5W_DH_Deluxe, P6T, - P6X58D_E, + P6X58D_E, P8P67, P8P67_EVO, P8P67_PRO, @@ -34,6 +42,9 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { Rampage_II_GENE, PRIME_X370_PRO, ROG_MAXIMUS_APEX, + ROG_ZENITH_EXTREME, + ASUS_Z170_A, + TUF_X470_PLUS_GAMING, // DFI LP_BI_P45_T2RS_Elite, @@ -44,6 +55,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { // MSI Z270_PC_MATE, + B360M_PRO_VDH, // EVGA X58_SLI_Classified, @@ -61,8 +73,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { GA_MA770T_UD3, GA_MA770T_UD3P, GA_MA785GM_US2H, - GA_MA785GMT_UD2H, - GA_MA78LM_S2H, + GA_MA785GMT_UD2H, + GA_MA78LM_S2H, GA_MA790X_UD3P, H55_USB3, H55N_USB3, @@ -71,7 +83,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { H67A_UD3H_B3, H67A_USB3_B3, P35_DS3, - P35_DS3L, + P35_DS3L, P55_UD4, P55A_UD3, P55M_UD4, @@ -90,6 +102,9 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { Z390_M_GAMING, Z390_AORUS_ULTRA, Z390_UD, + AB350_Gaming_3_CF, + GIGABYTE_X399_AOURUS_GAMING7, + AX370_Gaming_5, // Shuttle FH67, diff --git a/Hardware/Mainboard/SuperIOHardware.cs b/Hardware/Mainboard/SuperIOHardware.cs index 8f8fcbf..8098b19 100644 --- a/Hardware/Mainboard/SuperIOHardware.cs +++ b/Hardware/Mainboard/SuperIOHardware.cs @@ -1,11 +1,11 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2009-2015 Michael Möller - + */ using System; @@ -39,9 +39,9 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { // mainboard specific mutex private readonly Mutex mutex; - public SuperIOHardware(Mainboard mainboard, ISuperIO superIO, - Manufacturer manufacturer, Model model, ISettings settings) - : base(ChipName.GetName(superIO.Chip), new Identifier("lpc", + public SuperIOHardware(Mainboard mainboard, ISuperIO superIO, + Manufacturer manufacturer, Model model, ISettings settings) + : base(ChipName.GetName(superIO.Chip), new Identifier("lpc", superIO.Chip.ToString().ToLowerInvariant()), settings) { this.mainboard = mainboard; @@ -62,8 +62,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { CreateControlSensors(superIO, settings, c); } - private void CreateControlSensors(ISuperIO superIO, ISettings settings, - IList c) + private void CreateControlSensors(ISuperIO superIO, ISettings settings, + IList c) { foreach (Ctrl ctrl in c) { int index = ctrl.Index; @@ -101,7 +101,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { break; default: break; - } + } sensor.Control = control; controls.Add(sensor); @@ -110,8 +110,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { } } - private void CreateFanSensors(ISuperIO superIO, ISettings settings, - IList f) + private void CreateFanSensors(ISuperIO superIO, ISettings settings, + IList f) { foreach (Fan fan in f) { if (fan.Index < superIO.Fans.Length) { @@ -122,8 +122,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { } } - private void CreateTemperatureSensors(ISuperIO superIO, ISettings settings, - IList t) + private void CreateTemperatureSensors(ISuperIO superIO, ISettings settings, + IList t) { foreach (Temperature temperature in t) if (temperature.Index < superIO.Temperatures.Length) { @@ -135,19 +135,19 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { } } - private void CreateVoltageSensors(ISuperIO superIO, ISettings settings, - IList v) + private void CreateVoltageSensors(ISuperIO superIO, ISettings settings, + IList v) { const string formula = "Voltage = value + (value - Vf) * Ri / Rf."; foreach (Voltage voltage in v) if (voltage.Index < superIO.Voltages.Length) { Sensor sensor = new Sensor(voltage.Name, voltage.Index, voltage.Hidden, SensorType.Voltage, this, new[] { - new ParameterDescription("Ri [kΩ]", "Input resistance.\n" + + new ParameterDescription("Ri [kΩ]", "Input resistance.\n" + formula, voltage.Ri), - new ParameterDescription("Rf [kΩ]", "Reference resistance.\n" + + new ParameterDescription("Rf [kΩ]", "Reference resistance.\n" + formula, voltage.Rf), - new ParameterDescription("Vf [V]", "Reference voltage.\n" + + new ParameterDescription("Vf [V]", "Reference voltage.\n" + formula, voltage.Vf) }, settings); voltages.Add(sensor); @@ -236,7 +236,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("AVCC", 3, 34, 51)); v.Add(new Voltage("Voltage #5", 4, true)); v.Add(new Voltage("5VSB", 5, 34, 51)); - v.Add(new Voltage("VBAT", 6)); + v.Add(new Voltage("VBat", 6)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Auxiliary", 1)); t.Add(new Temperature("System", 2)); @@ -257,7 +257,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #2", 5, true)); v.Add(new Voltage("Reserved", 6, true)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); v.Add(new Voltage("Voltage #10", 9, true)); t.Add(new Temperature("SYS", 1)); t.Add(new Temperature("CPU Core", 2)); @@ -283,8 +283,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { } } - private static void GetDefaultConfiguration(ISuperIO superIO, - IList v, IList t, IList f, IList c) + private static void GetDefaultConfiguration(ISuperIO superIO, + IList v, IList t, IList f, IList c) { for (int i = 0; i < superIO.Voltages.Length; i++) v.Add(new Voltage("Voltage #" + (i + 1), i, true)); @@ -296,11 +296,11 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { c.Add(new Ctrl("Fan Control #" + (i + 1), i)); } - private static void GetITEConfigurationsA(ISuperIO superIO, - Manufacturer manufacturer, Model model, - IList v, IList t, IList f, IList c, - ref ReadValueDelegate readFan, ref UpdateDelegate postUpdate, - ref Mutex mutex) + private static void GetITEConfigurationsA(ISuperIO superIO, + Manufacturer manufacturer, Model model, + IList v, IList t, IList f, IList c, + ref ReadValueDelegate readFan, ref UpdateDelegate postUpdate, + ref Mutex mutex) { switch (manufacturer) { case Manufacturer.ASUS: @@ -324,7 +324,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { f.Add(new Fan("Chassis Fan #1", 1)); f.Add(new Fan("Power Fan", 2)); break; - case Model.M4A79XTD_EVO: // IT8720F + case Model.M4A79XTD_EVO: // IT8720F v.Add(new Voltage("+5V", 3, 6.8f, 10)); v.Add(new Voltage("VBat", 8)); t.Add(new Temperature("CPU", 0)); @@ -334,6 +334,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { f.Add(new Fan("Chassis Fan #2", 2)); break; case Model.PRIME_X370_PRO: // IT8665E + case Model.TUF_X470_PLUS_GAMING: v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("SB 2.5V", 1)); v.Add(new Voltage("+12V", 2, 5, 1)); @@ -353,6 +354,37 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { for (int i = 1; i < superIO.Fans.Length; i++) f.Add(new Fan("Fan #" + (i + 1), i)); break; + + case Model.ROG_ZENITH_EXTREME: // IT8665E + v.Add(new Voltage("CPU VCore", 0, 10, 10, 0, false)); + v.Add(new Voltage("DRAM AB", 1, 10, 10, 0, false)); + v.Add(new Voltage("+12V", 2, 5, 1,0, false)); + v.Add(new Voltage("+5V", 3, 1.5f, 1, 0, false)); + v.Add(new Voltage("SB 1.05V", 4, 10, 10, 0, false)); + v.Add(new Voltage("DRAM CD", 5, 10, 10, 0, false)); + v.Add(new Voltage("1.8V PLL", 6, 10, 10, 0, false)); + v.Add(new Voltage("+3.3V", 7, 10, 10, 0, false)); + v.Add(new Voltage("VBat", 8, 10, 10, 0, false)); + + t.Add(new Temperature("CPU", 0)); + t.Add(new Temperature("Mainboard", 1)); + t.Add(new Temperature("CPU Socket", 2)); + t.Add(new Temperature("Temperature #4", 3)); + t.Add(new Temperature("Temperature #5", 4)); + t.Add(new Temperature("VRM", 5)); + + int x = superIO.Fans.Length; + f.Add(new Fan("CPU Fan", 0)); + f.Add(new Fan("Chassis Fan 1", 1)); + f.Add(new Fan("Chassis Fan 2", 2)); + f.Add(new Fan("High Amp Fan", 3)); + f.Add(new Fan("Fan 5", 4)); + f.Add(new Fan("Fan 6", 5)); + + for (int i = 0; i < superIO.Controls.Length; i++) + c.Add(new Ctrl("Fan Control #" + (i + 1), i)); + break; + default: v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("Voltage #2", 1, true)); @@ -376,7 +408,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { case Manufacturer.ASRock: switch (model) { case Model.P55_Deluxe: // IT8720F - GetASRockConfiguration(superIO, v, t, f, + GetASRockConfiguration(superIO, v, t, f, ref readFan, ref postUpdate, ref mutex); break; default: @@ -483,7 +515,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { f.Add(new Fan("Power Fan", 2)); f.Add(new Fan("System Fan #1", 3)); break; - case Model.EX58_EXTREME: // IT8720F + case Model.EX58_EXTREME: // IT8720F v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("+5V", 3, 6.8f, 10)); @@ -496,7 +528,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { f.Add(new Fan("Power Fan", 2)); f.Add(new Fan("System Fan #1", 3)); break; - case Model.P35_DS3: // IT8718F + case Model.P35_DS3: // IT8718F case Model.P35_DS3L: // IT8718F v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("DRAM", 1)); @@ -513,9 +545,9 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { break; case Model.P55_UD4: // IT8720F case Model.P55A_UD3: // IT8720F - case Model.P55M_UD4: // IT8720F + case Model.P55M_UD4: // IT8720F case Model.H55_USB3: // IT8720F - case Model.EX58_UD3R: // IT8720F + case Model.EX58_UD3R: // IT8720F v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("+3.3V", 2)); @@ -572,7 +604,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { c.Add(new Ctrl("PWM 3", 2)); break; case Model.GA_MA770T_UD3: // IT8720F - case Model.GA_MA770T_UD3P: // IT8720F + case Model.GA_MA770T_UD3P: // IT8720F case Model.GA_MA790X_UD3P: // IT8720F v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("DRAM", 1)); @@ -616,7 +648,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { f.Add(new Fan("System Fan", 1)); f.Add(new Fan("NB Fan", 2)); break; - case Model.X58A_UD3R: // IT8720F + case Model.X58A_UD3R: // IT8720F v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("+3.3V", 2)); @@ -632,6 +664,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { f.Add(new Fan("System Fan #1", 3)); break; case Model.AX370_K7: // IT8686E + case Model.AX370_Gaming_5: + case Model.AB350_Gaming_3_CF: // IT8686E // Note: v3.3, v12, v5, and AVCC3 might be slightly off. v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("+3.3V", 1, 0.65f, 1)); @@ -641,7 +675,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("VDDP", 5)); v.Add(new Voltage("VDRAM", 6)); v.Add(new Voltage("3VSB", 7, 10, 10)); - v.Add(new Voltage("VBAT", 8, 10, 10)); + v.Add(new Voltage("VBat", 8, 10, 10)); v.Add(new Voltage("AVCC3", 9, 7.53f, 1)); t.Add(new Temperature("System", 0)); t.Add(new Temperature("Chipset", 1)); @@ -650,7 +684,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { t.Add(new Temperature("VRM MOS", 4)); for (int i = 0; i < superIO.Fans.Length; i++) f.Add(new Fan("Fan #" + (i + 1), i)); - break; + break; case Model.Z390_M_GAMING: // IT8688E case Model.Z390_AORUS_ULTRA: case Model.Z390_UD: @@ -660,7 +694,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("+5V", 3, 1.5f, 1)); v.Add(new Voltage("CPU VCCGT", 4)); v.Add(new Voltage("CPU VCCSA", 5)); - v.Add(new Voltage("VDDQ", 6)); + v.Add(new Voltage("VDDQ", 6)); v.Add(new Voltage("DDRVTT", 7)); v.Add(new Voltage("PCHCore", 8)); v.Add(new Voltage("CPU VCCIO", 9)); @@ -675,6 +709,30 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { f.Add(new Fan("System Fan #1", 1)); f.Add(new Fan("System Fan #2", 2)); f.Add(new Fan("System Fan #3", 3)); + break; + case Model.GIGABYTE_X399_AOURUS_GAMING7: //ITE IT8686E + v.Add(new Voltage("CPU VCore", 0, 0, 1, 0, false)); + v.Add(new Voltage("+3.3V", 1, 6.5F, 10, 0, false)); + v.Add(new Voltage("+12V", 2, 5, 1, 0, false)); + v.Add(new Voltage("+5V", 3, 1.5F, 1, 0, false)); + v.Add(new Voltage("DRAM CD", 4, 0, 1, 0, false)); + v.Add(new Voltage("SOC Vcore", 5, 0, 1, 0, false)); + v.Add(new Voltage("DRAM AB", 6, 0, 1, 0, false)); + v.Add(new Voltage("3VSB", 7, 10, 10, 0, false)); + v.Add(new Voltage("VBat", 8, 10, 10, 0, false)); + v.Add(new Voltage("AVCC3", 9, 54, 10, 0, false)); + + t.Add(new Temperature("System 1", 0)); + t.Add(new Temperature("Chipset", 1)); + t.Add(new Temperature("CPU", 2)); + t.Add(new Temperature("PCIE_X16", 3)); + t.Add(new Temperature("VRM", 4)); + + for (int i = 0; i < superIO.Fans.Length; i++) + f.Add(new Fan("Fan #" + (i + 1), i)); + for (int i = 0; i < superIO.Controls.Length; i++) + c.Add(new Ctrl("Fan Control #" + (i + 1), i)); + break; default: v.Add(new Voltage("CPU VCore", 0)); @@ -716,10 +774,10 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { } } - private static void GetASRockConfiguration(ISuperIO superIO, - IList v, IList t, IList f, - ref ReadValueDelegate readFan, ref UpdateDelegate postUpdate, - ref Mutex mutex) + private static void GetASRockConfiguration(ISuperIO superIO, + IList v, IList t, IList f, + ref ReadValueDelegate readFan, ref UpdateDelegate postUpdate, + ref Mutex mutex) { v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("+3.3V", 2)); @@ -737,7 +795,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { bool exclusiveAccess = false; try { exclusiveAccess = mutex.WaitOne(10, false); - } catch (AbandonedMutexException) { } + } catch (AbandonedMutexException) { } catch (InvalidOperationException) { } // only read additional fans if we get exclusive access @@ -781,7 +839,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { private static void GetITEConfigurationsB(ISuperIO superIO, Manufacturer manufacturer, Model model, - IList v, IList t, IList f, IList c) + IList v, IList t, IList f, IList c) { switch (manufacturer) { case Manufacturer.ECS: @@ -836,7 +894,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { f.Add(new Fan("System Fan", 1)); break; case Model.H67A_UD3H_B3: // IT8728F - case Model.H67A_USB3_B3: // IT8728F + case Model.H67A_USB3_B3: // IT8728F v.Add(new Voltage("VTT", 0)); v.Add(new Voltage("+5V", 1, 15, 10)); v.Add(new Voltage("+12V", 2, 30.9f, 10)); @@ -869,9 +927,9 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { break; case Model.P67A_UD3_B3: // IT8728F case Model.P67A_UD3R_B3: // IT8728F - case Model.P67A_UD4_B3: // IT8728F + case Model.P67A_UD4_B3: // IT8728F case Model.Z68AP_D3: // IT8728F - case Model.Z68X_UD3H_B3: // IT8728F + case Model.Z68X_UD3H_B3: // IT8728F v.Add(new Voltage("VTT", 0)); v.Add(new Voltage("+3.3V", 1, 6.49f, 10)); v.Add(new Voltage("+12V", 2, 30.9f, 10)); @@ -944,7 +1002,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { break; case Manufacturer.Shuttle: switch (model) { - case Model.FH67: // IT8772E + case Model.FH67: // IT8772E v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("PCH VCCIO", 2)); @@ -998,12 +1056,12 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { private static void GetFintekConfiguration(ISuperIO superIO, Manufacturer manufacturer, Model model, - IList v, IList t, IList f, IList c) + IList v, IList t, IList f, IList c) { switch (manufacturer) { case Manufacturer.EVGA: switch (model) { - case Model.X58_SLI_Classified: // F71882 + case Model.X58_SLI_Classified: // F71882 v.Add(new Voltage("VCC3V", 0, 150, 150)); v.Add(new Voltage("CPU VCore", 1, 47, 100)); v.Add(new Voltage("DIMM", 2, 47, 100)); @@ -1059,9 +1117,9 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { } } - private static void GetNuvotonConfigurationF(ISuperIO superIO, - Manufacturer manufacturer, Model model, - IList v, IList t, IList f, IList c) + private static void GetNuvotonConfigurationF(ISuperIO superIO, + Manufacturer manufacturer, Model model, + IList v, IList t, IList f, IList c) { switch (manufacturer) { case Manufacturer.ASUS: @@ -1075,7 +1133,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("+3.3V", 3, 34, 34)); v.Add(new Voltage("+5V", 4, 12, 3)); v.Add(new Voltage("Standby +3.3V", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Auxiliary", 2)); t.Add(new Temperature("Motherboard", 3)); @@ -1096,7 +1154,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("Standby +3.3V", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Motherboard", 3)); f.Add(new Fan("Chassis Fan #1", 0)); @@ -1112,7 +1170,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("+3.3V", 3, 34, 34)); v.Add(new Voltage("+5V", 4, 12, 3)); v.Add(new Voltage("Standby +3.3V", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Auxiliary", 2)); t.Add(new Temperature("Motherboard", 3)); @@ -1128,7 +1186,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("+3.3V", 3, 34, 34)); v.Add(new Voltage("+5V", 4, 12, 3)); v.Add(new Voltage("Standby +3.3V", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Motherboard", 3)); for (int i = 0; i < superIO.Fans.Length; i++) @@ -1145,7 +1203,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU Core", 0)); t.Add(new Temperature("Temperature #1", 1)); t.Add(new Temperature("Temperature #2", 2)); @@ -1158,80 +1216,229 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { } break; case Manufacturer.ASRock: - { - switch (model) - { - case Model.B85M_DGS: - { - v.Add(new Voltage("CPU VCCIN", 0, 1, 1)); - v.Add(new Voltage("+12V", 1, 56, 10)); - v.Add(new Voltage("Analog +3.3V", 2, 34, 34)); - v.Add(new Voltage("+3.3V", 3, 34, 34)); - v.Add(new Voltage("VIN1", 4, true)); - v.Add(new Voltage("+5V", 5, 12, 3)); - v.Add(new Voltage("VIN3", 6, true)); - v.Add(new Voltage("Standby +3.3V", 7, 34, 34)); - t.Add(new Temperature("CPU", 0)); - t.Add(new Temperature("Auxiliary", 2)); - t.Add(new Temperature("Motherboard", 3)); - f.Add(new Fan("Chassis Fan #1", 0)); - f.Add(new Fan("CPU Fan", 1)); - f.Add(new Fan("Power Fan", 2)); - f.Add(new Fan("Chassis Fan #2", 3)); - c.Add(new Ctrl("Chassis Fan #2", 0)); - c.Add(new Ctrl("CPU Fan", 1)); - c.Add(new Ctrl("Chassis Fan #1", 2)); - } - break; - default: - v.Add(new Voltage("CPU VCore", 0)); - v.Add(new Voltage("Voltage #2", 1, true)); - v.Add(new Voltage("AVCC", 2, 34, 34)); - v.Add(new Voltage("3VCC", 3, 34, 34)); - v.Add(new Voltage("Voltage #5", 4, true)); - v.Add(new Voltage("Voltage #6", 5, true)); - v.Add(new Voltage("Voltage #7", 6, true)); - v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); - t.Add(new Temperature("CPU Core", 0)); - t.Add(new Temperature("Temperature #1", 1)); - t.Add(new Temperature("Temperature #2", 2)); - t.Add(new Temperature("Temperature #3", 3)); - for (int i = 0; i < superIO.Fans.Length; i++) - f.Add(new Fan("Fan #" + (i + 1), i)); - for (int i = 0; i < superIO.Controls.Length; i++) - c.Add(new Ctrl("Fan Control #" + (i + 1), i)); - break; - } - } - break; - default: - v.Add(new Voltage("CPU VCore", 0)); - v.Add(new Voltage("Voltage #2", 1, true)); - v.Add(new Voltage("AVCC", 2, 34, 34)); - v.Add(new Voltage("3VCC", 3, 34, 34)); - v.Add(new Voltage("Voltage #5", 4, true)); - v.Add(new Voltage("Voltage #6", 5, true)); - v.Add(new Voltage("Voltage #7", 6, true)); - v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); - t.Add(new Temperature("CPU Core", 0)); - t.Add(new Temperature("Temperature #1", 1)); - t.Add(new Temperature("Temperature #2", 2)); - t.Add(new Temperature("Temperature #3", 3)); - for (int i = 0; i < superIO.Fans.Length; i++) - f.Add(new Fan("Fan #" + (i + 1), i)); - for (int i = 0; i < superIO.Controls.Length; i++) - c.Add(new Ctrl("Fan Control #" + (i + 1), i)); - break; + { + switch (model) + { + case Model.B85M_DGS: + { + v.Add(new Voltage("CPU VCCIN", 0, 1, 1)); + v.Add(new Voltage("+12V", 1, 56, 10)); + v.Add(new Voltage("Analog +3.3V", 2, 34, 34)); + v.Add(new Voltage("+3.3V", 3, 34, 34)); + v.Add(new Voltage("VIN1", 4, true)); + v.Add(new Voltage("+5V", 5, 12, 3)); + v.Add(new Voltage("VIN3", 6, true)); + v.Add(new Voltage("Standby +3.3V", 7, 34, 34)); + t.Add(new Temperature("CPU", 0)); + t.Add(new Temperature("Auxiliary", 2)); + t.Add(new Temperature("Motherboard", 3)); + f.Add(new Fan("Chassis Fan #1", 0)); + f.Add(new Fan("CPU Fan", 1)); + f.Add(new Fan("Power Fan", 2)); + f.Add(new Fan("Chassis Fan #2", 3)); + c.Add(new Ctrl("Chassis Fan #2", 0)); + c.Add(new Ctrl("CPU Fan", 1)); + c.Add(new Ctrl("Chassis Fan #1", 2)); + } + break; + case Model.ASROCK_Z77PRO4M: //NCT6776F + v.Add(new Voltage("CPU VCore", 0, 0, 1, 0, false)); + v.Add(new Voltage("+12V", 1, 56, 10, 0, false)); + v.Add(new Voltage("AVCC", 2, 10, 10, 0, false)); + v.Add(new Voltage("3VCC", 3, 10, 10, 0, false)); + //v.Add(new Voltage("#Unused 4", 4, 0, 1, 0, true)); + v.Add(new Voltage("+5V", 5, 20, 10, 0, false)); + //v.Add(new Voltage("#Unused 6", 6, 0, 1, 0, true)); + v.Add(new Voltage("3VSB", 7, 10, 10, 0, false)); + v.Add(new Voltage("VBat", 8, 10, 10, 0, false)); + + t.Add(new Temperature("CPU Core", 0)); + t.Add(new Temperature("CPU", 1)); + t.Add(new Temperature("AUX", 2)); + t.Add(new Temperature("Mainboard", 3)); + + for (int i = 0; i < superIO.Fans.Length; i++) + f.Add(new Fan("Fan #" + (i + 1), i)); + for (int i = 0; i < superIO.Controls.Length; i++) + c.Add(new Ctrl("Fan Control #" + (i + 1), i)); + break; + default: + v.Add(new Voltage("CPU VCore", 0)); + v.Add(new Voltage("Voltage #2", 1, true)); + v.Add(new Voltage("AVCC", 2, 34, 34)); + v.Add(new Voltage("3VCC", 3, 34, 34)); + v.Add(new Voltage("Voltage #5", 4, true)); + v.Add(new Voltage("Voltage #6", 5, true)); + v.Add(new Voltage("Voltage #7", 6, true)); + v.Add(new Voltage("3VSB", 7, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); + t.Add(new Temperature("CPU Core", 0)); + t.Add(new Temperature("Temperature #1", 1)); + t.Add(new Temperature("Temperature #2", 2)); + t.Add(new Temperature("Temperature #3", 3)); + for (int i = 0; i < superIO.Fans.Length; i++) + f.Add(new Fan("Fan #" + (i + 1), i)); + for (int i = 0; i < superIO.Controls.Length; i++) + c.Add(new Ctrl("Fan Control #" + (i + 1), i)); + break; + } + } + break; + default: + v.Add(new Voltage("CPU VCore", 0)); + v.Add(new Voltage("Voltage #2", 1, true)); + v.Add(new Voltage("AVCC", 2, 34, 34)); + v.Add(new Voltage("3VCC", 3, 34, 34)); + v.Add(new Voltage("Voltage #5", 4, true)); + v.Add(new Voltage("Voltage #6", 5, true)); + v.Add(new Voltage("Voltage #7", 6, true)); + v.Add(new Voltage("3VSB", 7, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); + t.Add(new Temperature("CPU Core", 0)); + t.Add(new Temperature("Temperature #1", 1)); + t.Add(new Temperature("Temperature #2", 2)); + t.Add(new Temperature("Temperature #3", 3)); + for (int i = 0; i < superIO.Fans.Length; i++) + f.Add(new Fan("Fan #" + (i + 1), i)); + for (int i = 0; i < superIO.Controls.Length; i++) + c.Add(new Ctrl("Fan Control #" + (i + 1), i)); + break; } } private static void GetNuvotonConfigurationD(ISuperIO superIO, Manufacturer manufacturer, Model model, - IList v, IList t, IList f, IList c) + IList v, IList t, IList f, IList c) { switch (manufacturer) { + case Manufacturer.ASRock: + switch (model) + { + case Model.ASROCK_A320M_HDV: //NCT6779D + v.Add(new Voltage("CPU VCore", 0, 10, 10, 0, false)); + v.Add(new Voltage("Chipset 1.05V", 1, 0, 1, 0, false)); + v.Add(new Voltage("AVCC", 2, 10, 10, 0, false)); + v.Add(new Voltage("3VCC", 3, 10, 10, 0, false)); + v.Add(new Voltage("+12V", 4, 56, 10, 0, false)); + v.Add(new Voltage("VcoreRef", 5, 0, 1, 0, false)); + v.Add(new Voltage("DRAM", 6, 0, 1, 0, false)); + v.Add(new Voltage("3VSB", 7, 10, 10, 0, false)); + v.Add(new Voltage("VBat", 8, 10, 10, 0, false)); + //v.Add(new Voltage("#Unused 9", 9, 0, 1, 0, true)); + //v.Add(new Voltage("#Unused 10", 10, 0, 1, 0, true)); + //v.Add(new Voltage("#Unused 11", 11, 34, 34, 0, true)); + v.Add(new Voltage("+5V", 12, 20, 10, 0, false)); + //v.Add(new Voltage("#Unused 13", 13, 10, 10, 0, true)); + //v.Add(new Voltage("#Unused 14", 14, 0, 1, 0, true)); + + //t.Add(new Temperature("#Unused 0", 0)); + //t.Add(new Temperature("#Unused 1", 1)); + t.Add(new Temperature("Mainboard", 2)); + //t.Add(new Temperature("#Unused 3", 3)); + //t.Add(new Temperature("#Unused 4", 4)); + t.Add(new Temperature("AUX", 5)); + + for (int i = 0; i < superIO.Fans.Length; i++) + f.Add(new Fan("Fan #" + (i + 1), i)); + for (int i = 0; i < superIO.Controls.Length; i++) + c.Add(new Ctrl("Fan Control #" + (i + 1), i)); + break; + + case Model.ASROCK_AB350_PRO4: //NCT6779D + case Model.ASROCK_AB350M_PRO4: + case Model.ASROCK_AB350M: + case Model.ASROCK_Fatal1ty_AB350_Gaming_K4: + case Model.ASROCK_AB350M_HDV: + v.Add(new Voltage("1 CPU VCore", 0, 10, 10, 0, false)); + //v.Add(new Voltage("#Unused", 1, 0, 1, 0, true)); + v.Add(new Voltage("3 AVCC", 2, 10, 10, 0, false)); + v.Add(new Voltage("4 3VCC", 3, 10, 10, 0, false)); + v.Add(new Voltage("5 +12V", 4, 28, 5, 0, false)); + //v.Add(new Voltage("#Unused 5", 5, 0, 1, 0, true)); + //v.Add(new Voltage("#Unused 6", 6, 0, 1, 0, true)); + v.Add(new Voltage("3VSB", 7, 10, 10, 0, false)); + v.Add(new Voltage("9 VBat", 8, 34, 34)); + //v.Add(new Voltage("#Unused 9", 9, 0, 1, 0, true)); + //v.Add(new Voltage("#Unused 10", 10, 0, 1, 0, true)); + v.Add(new Voltage("Chipset 1.05V", 11, 0, 1, 0, false)); + v.Add(new Voltage("+5V", 12, 20, 10, 0, false)); + //v.Add(new Voltage("#Unused 13", 13, 0, 1, 0, true)); + v.Add(new Voltage("+1.8V", 14, 0, 1, 0, false)); + + t.Add(new Temperature("CPU Core", 0)); + t.Add(new Temperature("CPU", 1)); + t.Add(new Temperature("Mainboard", 2)); + t.Add(new Temperature("AUX", 3)); + t.Add(new Temperature("VRM", 4)); + t.Add(new Temperature("AUXTIN2", 5)); + t.Add(new Temperature("Temperature #6", 6)); + + for (int i = 0; i < superIO.Fans.Length; i++) + f.Add(new Fan("Fan #" + (i + 1), i)); + for (int i = 0; i < superIO.Controls.Length; i++) + c.Add(new Ctrl("Fan Control #" + (i + 1), i)); + break; + + case Model.ASROCK_PHANTOM_GAMING_6: //NCT6779D + v.Add(new Voltage("CPU VCore", 0, 10, 10, 0, false)); + v.Add(new Voltage("Chipset 1.05V", 1, 0, 1, 0, false)); + v.Add(new Voltage("AVCC", 2, 10, 10, 0, false)); + v.Add(new Voltage("3VCC", 3, 10, 10, 0, false)); + v.Add(new Voltage("+12V", 4, 56, 10, 0, false)); + v.Add(new Voltage("VDDCR_SOC", 5, 0, 1, 0, false)); + v.Add(new Voltage("DRAM", 6, 0, 1, 0, false)); + v.Add(new Voltage("3VSB", 7, 10, 10, 0, false)); + v.Add(new Voltage("VBat", 8, 10, 10, 0, false)); + //v.Add(new Voltage("#Unused", 9, 0, 1, 0, true)); + //v.Add(new Voltage("#Unused", 10, 0, 1, 0, true)); + //v.Add(new Voltage("#Unused", 11, 0, 1, 0, true)); + v.Add(new Voltage("+5V", 12, 20, 10, 0, false)); + v.Add(new Voltage("+1.8V", 13, 10, 10, 0, false)); + //v.Add(new Voltage("unused", 14, 34, 34, 0, true)); + + t.Add(new Temperature("CPU Core", 0)); + t.Add(new Temperature("Mainboard", 1)); + t.Add(new Temperature("AUX", 2)); + t.Add(new Temperature("Chipset", 3)); + t.Add(new Temperature("Core VRM", 4)); + t.Add(new Temperature("Core SOC", 5)); + + for (int i = 0; i < superIO.Fans.Length; i++) + f.Add(new Fan("Fan #" + (i + 1), i)); + for (int i = 0; i < superIO.Controls.Length; i++) + c.Add(new Ctrl("Fan Control #" + (i + 1), i)); + break; + + default: + v.Add(new Voltage("CPU VCore", 0, 10,10, 0, false)); + v.Add(new Voltage("Voltage #2", 1, true)); + v.Add(new Voltage("AVCC", 2, 34, 34)); + v.Add(new Voltage("3VCC", 3, 34, 34)); + v.Add(new Voltage("Voltage #5", 4, true)); + v.Add(new Voltage("Voltage #6", 5, true)); + v.Add(new Voltage("Voltage #7", 6, true)); + v.Add(new Voltage("3VSB", 7, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); + v.Add(new Voltage("VTT", 9)); + v.Add(new Voltage("Voltage #11", 10, true)); + v.Add(new Voltage("Voltage #12", 11, true)); + v.Add(new Voltage("Voltage #13", 12, true)); + v.Add(new Voltage("Voltage #14", 13, true)); + v.Add(new Voltage("Voltage #15", 14, true)); + t.Add(new Temperature("CPU Core", 0)); + t.Add(new Temperature("Temperature #1", 1)); + t.Add(new Temperature("Temperature #2", 2)); + t.Add(new Temperature("Temperature #3", 3)); + t.Add(new Temperature("Temperature #4", 4)); + t.Add(new Temperature("Temperature #5", 5)); + t.Add(new Temperature("Temperature #6", 6)); + for (int i = 0; i < superIO.Fans.Length; i++) + f.Add(new Fan("Fan #" + (i + 1), i)); + for (int i = 0; i < superIO.Controls.Length; i++) + c.Add(new Ctrl("Fan Control #" + (i + 1), i)); + break; + } + break; case Manufacturer.ASUS: switch (model) { case Model.P8Z77_V: // NCT6779D @@ -1243,7 +1450,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); v.Add(new Voltage("VTT", 9)); v.Add(new Voltage("Voltage #11", 10, true)); v.Add(new Voltage("Voltage #12", 11, true)); @@ -1271,7 +1478,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("CPU GFX", 6, 2, 2)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); v.Add(new Voltage("VTT", 9)); v.Add(new Voltage("DRAM", 10, 1, 1)); v.Add(new Voltage("VCCSA", 11)); @@ -1283,8 +1490,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { t.Add(new Temperature("T1", 2)); t.Add(new Temperature("CPU", 3)); t.Add(new Temperature("PCH", 4)); - t.Add(new Temperature("Temp #4", 5)); - t.Add(new Temperature("Temp #5", 6)); + t.Add(new Temperature("Temperature #4", 5)); + t.Add(new Temperature("Temperature #5", 6)); f.Add(new Fan("Chassis Fan #1", 0)); f.Add(new Fan("CPU Fan", 1)); f.Add(new Fan("Chassis Fan #2", 2)); @@ -1296,6 +1503,36 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { c.Add(new Ctrl("Chassis Fan #3", 3)); c.Add(new Ctrl("AIO Pump", 4)); break; + case Model.ASUS_Z170_A: //NCT6793D + v.Add(new Voltage("CPU VCore", 0, 2, 2)); + v.Add(new Voltage("+5V", 1, 4, 1)); + v.Add(new Voltage("AVSB", 2, 34, 34)); + v.Add(new Voltage("3VCC", 3, 34, 34)); + v.Add(new Voltage("+12V", 4, 11, 1)); + v.Add(new Voltage("Voltage #6", 5, 0, 1, 0, true)); + v.Add(new Voltage("CPU GFX", 6, 2, 2)); + v.Add(new Voltage("3VSB_ATX", 7, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); + v.Add(new Voltage("VTT", 9)); + v.Add(new Voltage("DRAM", 10, 1, 1)); + v.Add(new Voltage("VCCSA", 11)); + v.Add(new Voltage("PCH Core", 12)); + v.Add(new Voltage("CPU PLLs", 13)); + v.Add(new Voltage("CPU VCCIO/IMC", 14)); + + t.Add(new Temperature("CPU (PECI)", 0)); + t.Add(new Temperature("CPU", 1)); + t.Add(new Temperature("Mainboard", 2)); + t.Add(new Temperature("CPU", 3)); + t.Add(new Temperature("PCH", 4)); + t.Add(new Temperature("Temperature #4", 5)); + t.Add(new Temperature("Temperature #5", 6)); + + for (int i = 0; i < superIO.Fans.Length; i++) + f.Add(new Fan("Fan #" + (i + 1), i)); + for (int i = 0; i < superIO.Controls.Length; i++) + c.Add(new Ctrl("Fan Control #" + (i + 1), i)); + break; default: v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("Voltage #2", 1, true)); @@ -1305,7 +1542,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); v.Add(new Voltage("VTT", 9)); v.Add(new Voltage("Voltage #11", 10, true)); v.Add(new Voltage("Voltage #12", 11, true)); @@ -1328,6 +1565,32 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { break; case Manufacturer.MSI: switch (model) { + case Model.B360M_PRO_VDH: // NCT6797D + v.Add(new Voltage("CPU VCore", 0)); + v.Add(new Voltage("+5V", 1, 4, 1)); + v.Add(new Voltage("AVCC", 2, 34, 34)); + v.Add(new Voltage("3VCC", 3, 34, 34)); + v.Add(new Voltage("+12V", 4, 11, 1)); + v.Add(new Voltage("Voltage #6", 5, true)); + v.Add(new Voltage("CPU I/O", 6)); + v.Add(new Voltage("3VSB", 7, 34, 34)); + v.Add(new Voltage("VTT", 9)); + v.Add(new Voltage("CPU SA", 10)); + v.Add(new Voltage("Voltage #12", 11, true)); + v.Add(new Voltage("PCH", 12)); + v.Add(new Voltage("DRAM", 13, 1, 1)); + v.Add(new Voltage("Voltage #15", 14, true)); + t.Add(new Temperature("CPU", 0)); + t.Add(new Temperature("Auxiliary", 1)); + t.Add(new Temperature("Motherboard", 2)); + t.Add(new Temperature("Temperature #1", 5)); + f.Add(new Fan("CPU Fan", 1)); + f.Add(new Fan("System Fan #1", 2)); + f.Add(new Fan("System Fan #2", 3)); + c.Add(new Ctrl("CPU Fan", 1)); + c.Add(new Ctrl("System Fan #1", 2)); + c.Add(new Ctrl("System Fan #2", 3)); + break; case Model.Z270_PC_MATE: // NCT6795D v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("+5V", 1, 4, 1)); @@ -1368,7 +1631,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); v.Add(new Voltage("VTT", 9)); v.Add(new Voltage("Voltage #11", 10, true)); v.Add(new Voltage("Voltage #12", 11, true)); @@ -1398,7 +1661,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); v.Add(new Voltage("VTT", 9)); v.Add(new Voltage("Voltage #11", 10, true)); v.Add(new Voltage("Voltage #12", 11, true)); @@ -1421,7 +1684,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { } private static void GetWinbondConfigurationEHF(Manufacturer manufacturer, - Model model, IList v, IList t, IList f) + Model model, IList v, IList t, IList f) { switch (manufacturer) { case Manufacturer.ASRock: @@ -1433,7 +1696,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("+5V", 5, 20, 10)); v.Add(new Voltage("+12V", 6, 28, 5)); v.Add(new Voltage("Standby +3.3V", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Motherboard", 2)); f.Add(new Fan("CPU Fan", 0)); @@ -1448,7 +1711,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); v.Add(new Voltage("Voltage #10", 9, true)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Auxiliary", 1)); @@ -1469,7 +1732,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); v.Add(new Voltage("Voltage #10", 9, true)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Auxiliary", 1)); @@ -1481,10 +1744,10 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { f.Add(new Fan("Auxiliary Fan #2", 4)); break; } - } + } private static void GetWinbondConfigurationHG(Manufacturer manufacturer, - Model model, IList v, IList t, IList f) + Model model, IList v, IList t, IList f) { switch (manufacturer) { case Manufacturer.ASRock: @@ -1495,7 +1758,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("+5V", 5, 15, 7.5f)); v.Add(new Voltage("+12V", 6, 56, 10)); v.Add(new Voltage("Standby +3.3V", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Motherboard", 2)); f.Add(new Fan("Chassis Fan", 0)); @@ -1511,7 +1774,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Auxiliary", 1)); t.Add(new Temperature("System", 2)); @@ -1526,15 +1789,15 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { case Manufacturer.ASUS: switch (model) { case Model.P6T: // W83667HG - case Model.P6X58D_E: // W83667HG - case Model.Rampage_II_GENE: // W83667HG + case Model.P6X58D_E: // W83667HG + case Model.Rampage_II_GENE: // W83667HG v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("+12V", 1, 11.5f, 1.91f)); v.Add(new Voltage("Analog +3.3V", 2, 34, 34)); v.Add(new Voltage("+3.3V", 3, 34, 34)); v.Add(new Voltage("+5V", 4, 15, 7.5f)); v.Add(new Voltage("Standby +3.3V", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Motherboard", 2)); f.Add(new Fan("Chassis Fan #1", 0)); @@ -1543,14 +1806,14 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { f.Add(new Fan("Chassis Fan #2", 3)); f.Add(new Fan("Chassis Fan #3", 4)); break; - case Model.Rampage_Extreme: // W83667HG + case Model.Rampage_Extreme: // W83667HG v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("+12V", 1, 12, 2)); v.Add(new Voltage("Analog +3.3V", 2, 34, 34)); v.Add(new Voltage("+3.3V", 3, 34, 34)); v.Add(new Voltage("+5V", 4, 15, 7.5f)); v.Add(new Voltage("Standby +3.3V", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Motherboard", 2)); f.Add(new Fan("Chassis Fan #1", 0)); @@ -1568,7 +1831,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Auxiliary", 1)); t.Add(new Temperature("System", 2)); @@ -1589,7 +1852,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("3VSB", 7, 34, 34)); - v.Add(new Voltage("VBAT", 8, 34, 34)); + v.Add(new Voltage("VBat", 8, 34, 34)); t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("Auxiliary", 1)); t.Add(new Temperature("System", 2)); @@ -1646,7 +1909,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { foreach (Sensor sensor in controls) { float? value = readControl(sensor.Index); - sensor.Value = value; + sensor.Value = value; } postUpdate(); @@ -1670,17 +1933,17 @@ namespace OpenHardwareMonitor.Hardware.Mainboard { public Voltage(string name, int index) : this(name, index, false) { } - + public Voltage(string name, int index, bool hidden) : this(name, index, 0, 1, 0, hidden) { } - + public Voltage(string name, int index, float ri, float rf) : this(name, index, ri, rf, 0, false) { } - - // float ri = 0, float rf = 1, float vf = 0, bool hidden = false) - - public Voltage(string name, int index, - float ri, float rf, float vf, bool hidden) + + // float ri = 0, float rf = 1, float vf = 0, bool hidden = false) + + public Voltage(string name, int index, + float ri, float rf, float vf, bool hidden) { this.Name = name; this.Index = index; diff --git a/Hardware/Sensor.cs b/Hardware/Sensor.cs index e149c89..73f5df6 100644 --- a/Hardware/Sensor.cs +++ b/Hardware/Sensor.cs @@ -1,11 +1,11 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2009-2012 Michael Möller - + */ using System; @@ -32,40 +32,40 @@ namespace OpenHardwareMonitor.Hardware { private TimeSpan valuesTimeWindow = TimeSpan.FromDays(1.0); private readonly ISettings settings; private IControl control; - + private float sum; private int count; - + public Sensor(string name, int index, SensorType sensorType, - Hardware hardware, ISettings settings) : + Hardware hardware, ISettings settings) : this(name, index, sensorType, hardware, null, settings) { } public Sensor(string name, int index, SensorType sensorType, - Hardware hardware, ParameterDescription[] parameterDescriptions, + Hardware hardware, ParameterDescription[] parameterDescriptions, ISettings settings) : this(name, index, false, sensorType, hardware, parameterDescriptions, settings) { } - public Sensor(string name, int index, bool defaultHidden, - SensorType sensorType, Hardware hardware, - ParameterDescription[] parameterDescriptions, ISettings settings) - { + public Sensor(string name, int index, bool defaultHidden, + SensorType sensorType, Hardware hardware, + ParameterDescription[] parameterDescriptions, ISettings settings) + { this.index = index; this.defaultHidden = defaultHidden; this.sensorType = sensorType; this.hardware = hardware; Parameter[] parameters = new Parameter[parameterDescriptions == null ? 0 : parameterDescriptions.Length]; - for (int i = 0; i < parameters.Length; i++ ) + for (int i = 0; i < parameters.Length; i++ ) parameters[i] = new Parameter(parameterDescriptions[i], this, settings); this.parameters = parameters; this.settings = settings; - this.defaultName = name; + this.defaultName = name; this.name = settings.GetValue( new Identifier(Identifier, "name").ToString(), name); - GetSensorValuesFromSettings(); + GetSensorValuesFromSettings(); hardware.Closing += delegate(IHardware h) { SetSensorValuesToSettings(); @@ -95,39 +95,60 @@ namespace OpenHardwareMonitor.Hardware { string name = new Identifier(Identifier, "values").ToString(); string s = settings.GetValue(name, null); - try { - byte[] array = Convert.FromBase64String(s); - s = null; - DateTime now = DateTime.UtcNow; - using (MemoryStream m = new MemoryStream(array)) - using (GZipStream c = new GZipStream(m, CompressionMode.Decompress)) - using (BinaryReader reader = new BinaryReader(c)) { - try { - long t = 0; - while (true) { - t += reader.ReadInt64(); - DateTime time = DateTime.FromBinary(t); - if (time > now) - break; - float value = reader.ReadSingle(); - AppendValue(value, time); + if (!string.IsNullOrEmpty(s)) + { + try + { + byte[] array = Convert.FromBase64String(s); + s = null; + DateTime now = DateTime.UtcNow; + using (MemoryStream m = new MemoryStream(array)) + using (GZipStream c = new GZipStream(m, CompressionMode.Decompress)) + { + using (MemoryStream unzip = new MemoryStream()) + { + c.CopyTo(unzip); + unzip.Seek(0, SeekOrigin.Begin); + using (BinaryReader reader = new BinaryReader(unzip)) + { + try + { + long t = 0; + long readLen = reader.BaseStream.Length - reader.BaseStream.Position; + while (true && readLen > 0) + { + t += reader.ReadInt64(); + DateTime time = DateTime.FromBinary(t); + if (time > now) + break; + float value = reader.ReadSingle(); + AppendValue(value, time); + + readLen = reader.BaseStream.Length - reader.BaseStream.Position; + } + } + catch (EndOfStreamException e) + { } + } } - } catch (EndOfStreamException) { } + } } - } catch { } + catch { } + } + if (values.Count > 0) AppendValue(float.NaN, DateTime.UtcNow); - // remove the value string from the settings to reduce memory usage + //remove the value string from the settings to reduce memory usage settings.Remove(name); } private void AppendValue(float value, DateTime time) { - if (values.Count >= 2 && values[values.Count - 1].Value == value && + if (values.Count >= 2 && values[values.Count - 1].Value == value && values[values.Count - 2].Value == value) { values[values.Count - 1] = new SensorValue(value, time); return; - } + } values.Add(new SensorValue(value, time)); } @@ -149,13 +170,13 @@ namespace OpenHardwareMonitor.Hardware { } public string Name { - get { - return name; + get { + return name; } set { - if (!string.IsNullOrEmpty(value)) - name = value; - else + if (!string.IsNullOrEmpty(value)) + name = value; + else name = defaultName; settings.SetValue(new Identifier(Identifier, "name").ToString(), name); } @@ -174,8 +195,8 @@ namespace OpenHardwareMonitor.Hardware { } public float? Value { - get { - return currentValue; + get { + return currentValue; } set { if (valuesTimeWindow != TimeSpan.Zero) { @@ -215,7 +236,7 @@ namespace OpenHardwareMonitor.Hardware { public IEnumerable Values { get { return values; } - } + } public TimeSpan ValuesTimeWindow { get { @@ -223,7 +244,7 @@ namespace OpenHardwareMonitor.Hardware { } set { this.valuesTimeWindow = value; - + if (value == TimeSpan.Zero) values.Clear(); } diff --git a/Hardware/ThreadAffinity.cs b/Hardware/ThreadAffinity.cs index 58bed84..6324450 100755 --- a/Hardware/ThreadAffinity.cs +++ b/Hardware/ThreadAffinity.cs @@ -1,31 +1,31 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2010-2014 Michael Möller - -*/ - -using System; -using System.Runtime.InteropServices; - -namespace OpenHardwareMonitor.Hardware { - - internal static class ThreadAffinity { - - public static ulong Set(ulong mask) { - if (mask == 0) - return 0; - + +*/ + +using System; +using System.Runtime.InteropServices; + +namespace OpenHardwareMonitor.Hardware { + + internal static class ThreadAffinity { + + public static ulong Set(ulong mask) { + if (mask == 0) + return 0; + if (Software.OperatingSystem.IsLinux) { // Unix ulong result = 0; - if (NativeMethods.sched_getaffinity(0, (IntPtr)Marshal.SizeOf(result), - ref result) != 0) + if (NativeMethods.sched_getaffinity(0, (IntPtr)Marshal.SizeOf(result), + ref result) != 0) return 0; - if (NativeMethods.sched_setaffinity(0, (IntPtr)Marshal.SizeOf(mask), + if (NativeMethods.sched_setaffinity(0, (IntPtr)Marshal.SizeOf(mask), ref mask) != 0) return 0; return result; @@ -38,28 +38,28 @@ namespace OpenHardwareMonitor.Hardware { } return (ulong)NativeMethods.SetThreadAffinityMask( NativeMethods.GetCurrentThread(), uIntPtrMask); - } - - private static class NativeMethods { - private const string KERNEL = "kernel32.dll"; - - [DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)] - public static extern UIntPtr - SetThreadAffinityMask(IntPtr handle, UIntPtr mask); - - [DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)] - public static extern IntPtr GetCurrentThread(); - - private const string LIBC = "libc"; - - [DllImport(LIBC)] - public static extern int sched_getaffinity(int pid, IntPtr maskSize, - ref ulong mask); - - [DllImport(LIBC)] - public static extern int sched_setaffinity(int pid, IntPtr maskSize, - ref ulong mask); - } - } -} - + } + + private static class NativeMethods { + private const string KERNEL = "kernel32.dll"; + + [DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)] + public static extern UIntPtr + SetThreadAffinityMask(IntPtr handle, UIntPtr mask); + + [DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)] + public static extern IntPtr GetCurrentThread(); + + private const string LIBC = "libc"; + + [DllImport(LIBC)] + public static extern int sched_getaffinity(int pid, IntPtr maskSize, + ref ulong mask); + + [DllImport(LIBC)] + public static extern int sched_setaffinity(int pid, IntPtr maskSize, + ref ulong mask); + } + } +} + diff --git a/Software/OperatingSystem.cs b/Software/OperatingSystem.cs index 1fa66ac..87104c3 100644 --- a/Software/OperatingSystem.cs +++ b/Software/OperatingSystem.cs @@ -9,21 +9,8 @@ namespace OpenHardwareMonitor.Software { var platform = Environment.OSVersion.Platform; IsLinux = platform == PlatformID.Unix || platform == PlatformID.MacOSX; - - if (IntPtr.Size == 8) { + if (System.Environment.Is64BitProcess) Is64Bit = true; - } else if (!IsLinux) { - try { - var result = IsWow64Process(Process.GetCurrentProcess().Handle, out bool wow64Process); - // If we are still here, this is a 64bit windows; 32bit windows does - // not provide IsWow64Process. - Is64Bit = true; - } - catch (EntryPointNotFoundException) { - // IsWow64Process is not present on 32 bit: - Is64Bit = false; - } - } } public static bool Is64Bit { get; } diff --git a/Utilities/HttpServer.cs b/Utilities/HttpServer.cs index 90c35d9..1eaa47f 100644 --- a/Utilities/HttpServer.cs +++ b/Utilities/HttpServer.cs @@ -1,9 +1,9 @@ /* - + This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - + Copyright (C) 2012 Prince Samuel Copyright (C) 2012-2013 Michael Möller @@ -80,7 +80,8 @@ namespace OpenHardwareMonitor.Utilities { return false; try { - listenerThread.Abort(); + if (listenerThread != null) + listenerThread.Abort(); listener.Stop(); listenerThread = null; } catch (HttpListenerException) { @@ -144,7 +145,7 @@ namespace OpenHardwareMonitor.Utilities { * {"result":"fail","message":"Some error message"} * or: * {"result":"ok","value":42.0, "format":"{0:F2} RPM"} - * + * * Set: * http://localhost:8085/Sensor?action=Set&id=/some/node/path/0&value=42.0 * http://localhost:8085/Sensor?action=Set&id=/some/node/path/0&value=null @@ -228,7 +229,7 @@ namespace OpenHardwareMonitor.Utilities { // Call EndGetContext to complete the asynchronous operation. HttpListenerContext context; try { - context = listener.EndGetContext(result); + context = listener.EndGetContext(result); } catch (Exception) { return; } @@ -257,7 +258,7 @@ namespace OpenHardwareMonitor.Utilities { } if (requestedFile.Contains("images_icon")) { - ServeResourceImage(context.Response, + ServeResourceImage(context.Response, requestedFile.Replace("images_icon/", "")); return; } @@ -276,11 +277,11 @@ namespace OpenHardwareMonitor.Utilities { } } - private void ServeResourceFile(HttpListenerResponse response, string name, - string ext) + private void ServeResourceFile(HttpListenerResponse response, string name, + string ext) { // resource names do not support the hyphen - name = "OpenHardwareMonitor.Resources." + + name = "OpenHardwareMonitor.Resources." + name.Replace("custom-theme", "custom_theme"); string[] names = @@ -299,13 +300,13 @@ namespace OpenHardwareMonitor.Utilities { output.Write(buffer, 0, len); } output.Flush(); - output.Close(); + output.Close(); response.Close(); - } catch (HttpListenerException) { - } catch (InvalidOperationException) { + } catch (HttpListenerException) { + } catch (InvalidOperationException) { } return; - } + } } } @@ -332,7 +333,7 @@ namespace OpenHardwareMonitor.Utilities { ms.WriteTo(output); } output.Close(); - } catch (HttpListenerException) { + } catch (HttpListenerException) { } image.Dispose(); response.Close(); @@ -416,9 +417,9 @@ namespace OpenHardwareMonitor.Utilities { return jsonNode; } - private static void ReturnFile(HttpListenerContext context, string filePath) + private static void ReturnFile(HttpListenerContext context, string filePath) { - context.Response.ContentType = + context.Response.ContentType = GetContentType(Path.GetExtension(filePath)); const int bufferSize = 1024 * 512; //512KB var buffer = new byte[bufferSize];