Partially addresses #200
This commit is contained in:
@@ -42,60 +42,90 @@ namespace LibreHardwareMonitor.Hardware.CPU
|
||||
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 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 0x70:
|
||||
case 0x60:
|
||||
{
|
||||
miscellaneousControlDeviceId = FAMILY_15H_MODEL_60_MISC_CONTROL_DEVICE_ID;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
miscellaneousControlDeviceId = 0;
|
||||
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;
|
||||
}
|
||||
default:
|
||||
{
|
||||
miscellaneousControlDeviceId = 0;
|
||||
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
|
||||
@@ -334,23 +364,24 @@ namespace LibreHardwareMonitor.Hardware.CPU
|
||||
}
|
||||
}
|
||||
|
||||
private string ReadFirstLine(Stream stream)
|
||||
private static string ReadFirstLine(Stream stream)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
try
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
int b = stream.ReadByte();
|
||||
while (b != -1 && b != 10)
|
||||
{
|
||||
sb.Append((char)b);
|
||||
stringBuilder.Append((char)b);
|
||||
b = stream.ReadByte();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
return sb.ToString();
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
|
||||
@@ -158,27 +158,31 @@ namespace LibreHardwareMonitor.Hardware.CPU
|
||||
uint sviPlane0Offset;
|
||||
uint sviPlane1Offset;
|
||||
|
||||
bool isZen2 = false;
|
||||
|
||||
// TODO: find a better way because these will probably keep changing in the future.
|
||||
switch (cpu.Model)
|
||||
{
|
||||
case 0x31: // Threadripper 3000.
|
||||
{
|
||||
sviPlane0Offset = F17H_M01H_SVI + 0x14;
|
||||
sviPlane1Offset = F17H_M01H_SVI + 0x10;
|
||||
break;
|
||||
}
|
||||
{
|
||||
sviPlane0Offset = F17H_M01H_SVI + 0x14;
|
||||
sviPlane1Offset = F17H_M01H_SVI + 0x10;
|
||||
isZen2 = true;
|
||||
break;
|
||||
}
|
||||
case 0x71: // Zen 2.
|
||||
{
|
||||
sviPlane0Offset = F17H_M01H_SVI + 0x10;
|
||||
sviPlane1Offset = F17H_M01H_SVI + 0xC;
|
||||
break;
|
||||
}
|
||||
{
|
||||
sviPlane0Offset = F17H_M01H_SVI + 0x10;
|
||||
sviPlane1Offset = F17H_M01H_SVI + 0xC;
|
||||
isZen2 = true;
|
||||
break;
|
||||
}
|
||||
default: // Zen and Zen+.
|
||||
{
|
||||
sviPlane0Offset = F17H_M01H_SVI + 0xC;
|
||||
sviPlane1Offset = F17H_M01H_SVI + 0x10;
|
||||
break;
|
||||
}
|
||||
{
|
||||
sviPlane0Offset = F17H_M01H_SVI + 0xC;
|
||||
sviPlane1Offset = F17H_M01H_SVI + 0x10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// SVI0_PLANE0_VDDCOR [24:16]
|
||||
@@ -257,55 +261,55 @@ namespace LibreHardwareMonitor.Hardware.CPU
|
||||
}
|
||||
|
||||
// Tested only on R5 3600 & Threadripper 3960X.
|
||||
for (uint i = 0; i < _ccdTemperatures.Length; i++)
|
||||
if (isZen2)
|
||||
{
|
||||
Ring0.WritePciConfig(0x00, FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M70H_CCD1_TEMP + (i * 0x4));
|
||||
Ring0.ReadPciConfig(0x00, FAMILY_17H_PCI_CONTROL_REGISTER + 4, out uint ccdTempData);
|
||||
|
||||
uint ccdTemp = ccdTempData & 0xFFF;
|
||||
if (ccdTemp == 0)
|
||||
continue;
|
||||
|
||||
if (_ccdTemperatures[i] == null)
|
||||
for (uint i = 0; i < _ccdTemperatures.Length; i++)
|
||||
{
|
||||
_hw.ActivateSensor(_ccdTemperatures[i] = new Sensor(
|
||||
$"Core CCD{i + 1} (Tdie)",
|
||||
_hw._sensorTemperatures++,
|
||||
SensorType.Temperature,
|
||||
_hw,
|
||||
_hw._settings));
|
||||
Ring0.WritePciConfig(0x00, FAMILY_17H_PCI_CONTROL_REGISTER, F17H_M70H_CCD1_TEMP + (i * 0x4));
|
||||
Ring0.ReadPciConfig(0x00, FAMILY_17H_PCI_CONTROL_REGISTER + 4, out uint ccdTempData);
|
||||
|
||||
uint ccdTemp = ccdTempData & 0xFFF;
|
||||
if (ccdTemp == 0)
|
||||
continue;
|
||||
|
||||
if (_ccdTemperatures[i] == null)
|
||||
{
|
||||
_hw.ActivateSensor(_ccdTemperatures[i] = new Sensor($"Core CCD{i + 1} (Tdie)",
|
||||
_hw._sensorTemperatures++,
|
||||
SensorType.Temperature,
|
||||
_hw,
|
||||
_hw._settings));
|
||||
}
|
||||
|
||||
_ccdTemperatures[i].Value = ((ccdTemp * 125) - 305000) * 0.001f;
|
||||
}
|
||||
|
||||
_ccdTemperatures[i].Value = ((ccdTemp * 125) - 305000) * 0.001f;
|
||||
}
|
||||
|
||||
Sensor[] activeCcds = _ccdTemperatures.Where(x => x != null).ToArray();
|
||||
if (activeCcds.Length > 1)
|
||||
{
|
||||
// No need to get the max / average ccds temp if there is only one CCD.
|
||||
|
||||
if (_ccdsMaxTemperature == null)
|
||||
Sensor[] activeCcds = _ccdTemperatures.Where(x => x != null).ToArray();
|
||||
if (activeCcds.Length > 1)
|
||||
{
|
||||
_hw.ActivateSensor(_ccdsMaxTemperature = new Sensor(
|
||||
"Core CCDs Max (Tdie)",
|
||||
_hw._sensorTemperatures++,
|
||||
SensorType.Temperature,
|
||||
_hw,
|
||||
_hw._settings));
|
||||
}
|
||||
// No need to get the max / average ccds temp if there is only one CCD.
|
||||
|
||||
if (_ccdsAverageTemperature == null)
|
||||
{
|
||||
_hw.ActivateSensor(_ccdsAverageTemperature = new Sensor(
|
||||
"Core CCDs Average (Tdie)",
|
||||
_hw._sensorTemperatures++,
|
||||
SensorType.Temperature,
|
||||
_hw,
|
||||
_hw._settings));
|
||||
}
|
||||
if (_ccdsMaxTemperature == null)
|
||||
{
|
||||
_hw.ActivateSensor(_ccdsMaxTemperature = new Sensor("Core CCDs Max (Tdie)",
|
||||
_hw._sensorTemperatures++,
|
||||
SensorType.Temperature,
|
||||
_hw,
|
||||
_hw._settings));
|
||||
}
|
||||
|
||||
_ccdsMaxTemperature.Value = activeCcds.Max(x => x.Value);
|
||||
_ccdsAverageTemperature.Value = activeCcds.Average(x => x.Value);
|
||||
if (_ccdsAverageTemperature == null)
|
||||
{
|
||||
_hw.ActivateSensor(_ccdsAverageTemperature = new Sensor("Core CCDs Average (Tdie)",
|
||||
_hw._sensorTemperatures++,
|
||||
SensorType.Temperature,
|
||||
_hw,
|
||||
_hw._settings));
|
||||
}
|
||||
|
||||
_ccdsMaxTemperature.Value = activeCcds.Max(x => x.Value);
|
||||
_ccdsAverageTemperature.Value = activeCcds.Average(x => x.Value);
|
||||
}
|
||||
}
|
||||
|
||||
// voltage
|
||||
@@ -524,7 +528,6 @@ namespace LibreHardwareMonitor.Hardware.CPU
|
||||
private const uint MSR_PSTATE_0 = 0xC0010064;
|
||||
private const uint MSR_PWR_UNIT = 0xC0010299;
|
||||
private const uint PERF_CTL_0 = 0xC0010000;
|
||||
|
||||
private const uint PERF_CTR_0 = 0xC0010004;
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
|
||||
@@ -195,9 +195,12 @@ namespace LibreHardwareMonitor.Hardware.Gpu
|
||||
|
||||
if (_currentOverdriveApiLevel >= 7)
|
||||
{
|
||||
// If a sensor isn't available, some cards report 54000 degrees C. 110C is expected for Navi, so 100 more than that should be enough to use as a maximum.
|
||||
const int maxTemperature = 210;
|
||||
|
||||
int temp = 0;
|
||||
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.EDGE, ref temp) == AtiAdlxx.ADL_OK)
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.EDGE, ref temp) == AtiAdlxx.ADL_OK && temp < maxTemperature)
|
||||
{
|
||||
_temperatureCore.Value = 0.001f * temp;
|
||||
ActivateSensor(_temperatureCore);
|
||||
@@ -207,7 +210,7 @@ namespace LibreHardwareMonitor.Hardware.Gpu
|
||||
_temperatureCore.Value = null;
|
||||
}
|
||||
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.MEM, ref temp) == AtiAdlxx.ADL_OK)
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.MEM, ref temp) == AtiAdlxx.ADL_OK && temp < maxTemperature)
|
||||
{
|
||||
_temperatureMemory.Value = temp;
|
||||
ActivateSensor(_temperatureMemory);
|
||||
@@ -217,7 +220,7 @@ namespace LibreHardwareMonitor.Hardware.Gpu
|
||||
_temperatureMemory.Value = null;
|
||||
}
|
||||
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRVDDC, ref temp) == AtiAdlxx.ADL_OK)
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRVDDC, ref temp) == AtiAdlxx.ADL_OK && temp < maxTemperature)
|
||||
{
|
||||
_temperatureVddc.Value = temp;
|
||||
ActivateSensor(_temperatureVddc);
|
||||
@@ -227,7 +230,7 @@ namespace LibreHardwareMonitor.Hardware.Gpu
|
||||
_temperatureVddc.Value = null;
|
||||
}
|
||||
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRMVDD, ref temp) == AtiAdlxx.ADL_OK)
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRMVDD, ref temp) == AtiAdlxx.ADL_OK && temp < maxTemperature)
|
||||
{
|
||||
_temperatureMvdd.Value = temp;
|
||||
ActivateSensor(_temperatureMvdd);
|
||||
@@ -238,26 +241,20 @@ namespace LibreHardwareMonitor.Hardware.Gpu
|
||||
}
|
||||
|
||||
_temperatureLiquid.Value = null;
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.LIQUID, ref temp) == AtiAdlxx.ADL_OK)
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.LIQUID, ref temp) == AtiAdlxx.ADL_OK && temp > 0 && temp < maxTemperature)
|
||||
{
|
||||
if (temp > 0)
|
||||
{
|
||||
_temperatureLiquid.Value = temp;
|
||||
ActivateSensor(_temperatureLiquid);
|
||||
}
|
||||
_temperatureLiquid.Value = temp;
|
||||
ActivateSensor(_temperatureLiquid);
|
||||
}
|
||||
|
||||
_temperaturePlx.Value = null;
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.PLX, ref temp) == AtiAdlxx.ADL_OK)
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.PLX, ref temp) == AtiAdlxx.ADL_OK && temp > 0 && temp < maxTemperature)
|
||||
{
|
||||
if (temp > 0)
|
||||
{
|
||||
_temperaturePlx.Value = temp;
|
||||
ActivateSensor(_temperaturePlx);
|
||||
}
|
||||
_temperaturePlx.Value = temp;
|
||||
ActivateSensor(_temperaturePlx);
|
||||
}
|
||||
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.HOTSPOT, ref temp) == AtiAdlxx.ADL_OK)
|
||||
if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.HOTSPOT, ref temp) == AtiAdlxx.ADL_OK && temp < maxTemperature)
|
||||
{
|
||||
_temperatureHotSpot.Value = temp;
|
||||
ActivateSensor(_temperatureHotSpot);
|
||||
|
||||
Reference in New Issue
Block a user