Skip to content

Commit a3fe5e6

Browse files
committed
Added AMD family 15h model 60h and 70h CPU support.
1 parent 65c0d3e commit a3fe5e6

2 files changed

Lines changed: 35 additions & 29 deletions

File tree

Hardware/CPU/AMD10CPU.cs

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This Source Code Form is subject to the terms of the Mozilla Public
44
License, v. 2.0. If a copy of the MPL was not distributed with this
55
file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
7-
Copyright (C) 2009-2013 Michael Möller <mmoeller@openhardwaremonitor.org>
7+
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
88
99
*/
1010

@@ -39,12 +39,15 @@ internal sealed class AMD10CPU : AMDCPU {
3939
private const ushort FAMILY_15H_MODEL_10_MISC_CONTROL_DEVICE_ID = 0x1403;
4040
private const ushort FAMILY_15H_MODEL_30_MISC_CONTROL_DEVICE_ID = 0x141D;
4141
private const ushort FAMILY_15H_MODEL_60_MISC_CONTROL_DEVICE_ID = 0x1573;
42+
private const ushort FAMILY_15H_MODEL_70_MISC_CONTROL_DEVICE_ID = 0x15B3;
4243
private const ushort FAMILY_16H_MODEL_00_MISC_CONTROL_DEVICE_ID = 0x1533;
4344
private const ushort FAMILY_16H_MODEL_30_MISC_CONTROL_DEVICE_ID = 0x1583;
4445

4546
private const uint REPORTED_TEMPERATURE_CONTROL_REGISTER = 0xA4;
4647
private const uint CLOCK_POWER_TIMING_CONTROL_0_REGISTER = 0xD4;
47-
private const uint F15H_M60H_REPORTED_TEMP_CTRL_OFFSET = 0xD8200CA4;
48+
private const uint SMU_REPORTED_TEMP_CONTROL_REGISTER = 0xD8200CA4;
49+
50+
private readonly bool hasSmuTemperatureRegister = false;
4851

4952
private readonly uint miscellaneousControlAddress;
5053
private readonly ushort miscellaneousControlDeviceId;
@@ -82,7 +85,13 @@ public AMD10CPU(int processorIndex, CPUID[][] cpuid, ISettings settings)
8285
case 0x30: miscellaneousControlDeviceId =
8386
FAMILY_15H_MODEL_30_MISC_CONTROL_DEVICE_ID; break;
8487
case 0x60: miscellaneousControlDeviceId =
85-
FAMILY_15H_MODEL_60_MISC_CONTROL_DEVICE_ID; break;
88+
FAMILY_15H_MODEL_60_MISC_CONTROL_DEVICE_ID;
89+
hasSmuTemperatureRegister = true;
90+
break;
91+
case 0x70: miscellaneousControlDeviceId =
92+
FAMILY_15H_MODEL_70_MISC_CONTROL_DEVICE_ID;
93+
hasSmuTemperatureRegister = true;
94+
break;
8695
default: miscellaneousControlDeviceId = 0; break;
8796
} break;
8897
case 0x16:
@@ -301,37 +310,34 @@ private string ReadFirstLine(Stream stream) {
301310
return sb.ToString();
302311
}
303312

313+
private bool ReadSmuRegister(uint address, out uint value) {
314+
if (!Ring0.WritePciConfig(0, 0xB8, address)) {
315+
value = 0;
316+
return false;
317+
}
318+
return Ring0.ReadPciConfig(0, 0xBC, out value);
319+
}
320+
304321
public override void Update() {
305322
base.Update();
306323

307324
if (temperatureStream == null) {
308325
if (miscellaneousControlAddress != Ring0.InvalidPciAddress) {
309326
uint value;
310-
if (miscellaneousControlAddress == FAMILY_15H_MODEL_60_MISC_CONTROL_DEVICE_ID) {
311-
value = F15H_M60H_REPORTED_TEMP_CTRL_OFFSET;
312-
Ring0.WritePciConfig(Ring0.GetPciAddress(0, 0, 0), 0xB8, value);
313-
Ring0.ReadPciConfig(Ring0.GetPciAddress(0, 0, 0), 0xBC, out value);
314-
coreTemperature.Value = ((value >> 21) & 0x7FF) * 0.125f +
315-
coreTemperature.Parameters[0].Value;
316-
ActivateSensor(coreTemperature);
317-
return;
318-
}
319-
if (Ring0.ReadPciConfig(miscellaneousControlAddress,
320-
REPORTED_TEMPERATURE_CONTROL_REGISTER, out value)) {
321-
if (family == 0x15 && (value & 0x30000) == 0x30000) {
322-
if ((model & 0xF0) == 0x00) {
323-
coreTemperature.Value = ((value >> 21) & 0x7FC) / 8.0f +
324-
coreTemperature.Parameters[0].Value - 49;
325-
} else {
326-
coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f +
327-
coreTemperature.Parameters[0].Value - 49;
328-
}
329-
} else if (family == 0x16 &&
330-
((value & 0x30000) == 0x30000 || (value & 0x80000) == 0x80000)) {
331-
coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f +
332-
coreTemperature.Parameters[0].Value - 49;
327+
bool valueValid;
328+
if (hasSmuTemperatureRegister) {
329+
valueValid =
330+
ReadSmuRegister(SMU_REPORTED_TEMP_CONTROL_REGISTER, out value);
331+
} else {
332+
valueValid = Ring0.ReadPciConfig(miscellaneousControlAddress,
333+
REPORTED_TEMPERATURE_CONTROL_REGISTER, out value);
334+
}
335+
if (valueValid) {
336+
if ((family == 0x15 || family == 0x16) && (value & 0x30000) == 0x30000) {
337+
coreTemperature.Value = ((value >> 21) & 0x7FF) * 0.125f +
338+
coreTemperature.Parameters[0].Value - 49;
333339
} else {
334-
coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f +
340+
coreTemperature.Value = ((value >> 21) & 0x7FF) * 0.125f +
335341
coreTemperature.Parameters[0].Value;
336342
}
337343
ActivateSensor(coreTemperature);

Properties/AssemblyVersion.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ This Source Code Form is subject to the terms of the Mozilla Public
1010

1111
using System.Reflection;
1212

13-
[assembly: AssemblyVersion("0.9.3.0")]
14-
[assembly: AssemblyInformationalVersion("0.9.3")]
13+
[assembly: AssemblyVersion("0.9.3.1")]
14+
[assembly: AssemblyInformationalVersion("0.9.3.1 Alpha")]

0 commit comments

Comments
 (0)