A small correction for AMD K8 (family 0Fh) core temperature reading, and fan reading on older revision of IT8712F chips. This should fix Issue 42 and Issue 194.

This commit is contained in:
Michael Möller 2011-04-16 14:49:47 +00:00
parent fb451bd475
commit 6872fcbe39
4 changed files with 66 additions and 24 deletions

View File

@ -52,9 +52,9 @@ namespace OpenHardwareMonitor.Hardware.CPU {
private const byte MISCELLANEOUS_CONTROL_FUNCTION = 3;
private const ushort MISCELLANEOUS_CONTROL_DEVICE_ID = 0x1103;
private const uint THERMTRIP_STATUS_REGISTER = 0xE4;
private const byte THERM_SENSE_CORE_SEL_CPU0 = 0x4;
private const byte THERM_SENSE_CORE_SEL_CPU1 = 0x0;
private readonly byte thermSenseCoreSelCPU0;
private readonly byte thermSenseCoreSelCPU1;
private readonly uint miscellaneousControlAddress;
public AMD0FCPU(int processorIndex, CPUID[][] cpuid, ISettings settings)
@ -67,6 +67,16 @@ namespace OpenHardwareMonitor.Hardware.CPU {
if (model >= 0x69 && model != 0xc1 && model != 0x6c && model != 0x7c)
offset += 21;
if (model < 40) {
// AMD Athlon 64 Processors
thermSenseCoreSelCPU0 = 0x0;
thermSenseCoreSelCPU1 = 0x4;
} else {
// AMD NPT Family 0Fh Revision F, G have the core selection swapped
thermSenseCoreSelCPU0 = 0x4;
thermSenseCoreSelCPU1 = 0x0;
}
// check if processor supports a digital thermal sensor
if (cpuid[0][0].ExtData.GetLength(0) > 7 &&
(cpuid[0][0].ExtData[7, 3] & 1) != 0)
@ -122,7 +132,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
for (uint i = 0; i < coreTemperatures.Length; i++) {
if (Ring0.WritePciConfig(
miscellaneousControlAddress, THERMTRIP_STATUS_REGISTER,
i > 0 ? THERM_SENSE_CORE_SEL_CPU1 : THERM_SENSE_CORE_SEL_CPU0)) {
i > 0 ? thermSenseCoreSelCPU1 : thermSenseCoreSelCPU0)) {
uint value;
if (Ring0.ReadPciConfig(
miscellaneousControlAddress, THERMTRIP_STATUS_REGISTER,

View File

@ -48,7 +48,8 @@ namespace OpenHardwareMonitor.Hardware {
foreach (string line in lines) {
string[] array = line.Split(new[] { ' ' },
StringSplitOptions.RemoveEmptyEntries);
if (array.Length == 0)
continue;
if (Convert.ToInt32(array[0], 16) == (address & 0xFFF0))
return Convert.ToByte(array[(address & 0x0F) + 1], 16);
}

View File

@ -56,6 +56,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
private readonly float?[] fans = new float?[0];
private readonly float voltageGain;
private readonly bool has16bitFanCounter;
// Consts
private const byte ITE_VENDOR_ID = 0x90;
@ -68,7 +69,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
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_16_BIT_ENABLE_REGISTER = 0x0c;
private const byte FAN_TACHOMETER_DIVISOR_REGISTER = 0x0B;
private readonly byte[] FAN_TACHOMETER_REG =
new byte[] { 0x0d, 0x0e, 0x0f, 0x80, 0x82 };
private readonly byte[] FAN_TACHOMETER_EXT_REG =
@ -85,8 +86,8 @@ 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) {
if (index >= gpioCount)
@ -103,7 +104,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
}
public IT87XX(Chip chip, ushort address, ushort gpioAddress, byte version) {
this.address = address;
this.chip = chip;
this.version = version;
@ -131,7 +132,14 @@ namespace OpenHardwareMonitor.Hardware.LPC {
if (chip == Chip.IT8721F) {
voltageGain = 0.012f;
} else {
voltageGain = 0.016f;
voltageGain = 0.016f;
}
// older IT8721F revision do not have 16-bit fan counters
if (chip == Chip.IT8712F && version < 8) {
has16bitFanCounter = false;
} else {
has16bitFanCounter = true;
}
// Set the number of GPIO sets
@ -236,19 +244,42 @@ namespace OpenHardwareMonitor.Hardware.LPC {
temperatures[i] = null;
}
for (int i = 0; i < fans.Length; i++) {
bool valid;
int value = ReadByte(FAN_TACHOMETER_REG[i], out valid);
if (!valid)
continue;
value |= ReadByte(FAN_TACHOMETER_EXT_REG[i], out valid) << 8;
if (!valid)
continue;
if (has16bitFanCounter) {
for (int i = 0; i < fans.Length; i++) {
bool valid;
int value = ReadByte(FAN_TACHOMETER_REG[i], out valid);
if (!valid)
continue;
value |= ReadByte(FAN_TACHOMETER_EXT_REG[i], out valid) << 8;
if (!valid)
continue;
if (value > 0x3f) {
fans[i] = (value < 0xffff) ? 1.35e6f / ((value) * 2) : 0;
} else {
fans[i] = null;
if (value > 0x3f) {
fans[i] = (value < 0xffff) ? 1.35e6f / (value * 2) : 0;
} else {
fans[i] = null;
}
}
} else {
for (int i = 0; i < fans.Length; i++) {
bool valid;
int value = ReadByte(FAN_TACHOMETER_REG[i], out valid);
if (!valid)
continue;
int divisor = 2;
if (i < 2) {
int divisors = ReadByte(FAN_TACHOMETER_DIVISOR_REGISTER, out valid);
if (!valid)
continue;
divisor = 1 << ((divisors >> (3 * i)) & 0x7);
}
if (value > 0) {
fans[i] = (value < 0xff) ? 1.35e6f / (value * divisor) : 0;
} else {
fans[i] = null;
}
}
}

View File

@ -37,5 +37,5 @@
using System.Reflection;
[assembly: AssemblyVersion("0.2.1.19")]
[assembly: AssemblyInformationalVersion("0.2.1.19 Alpha")]
[assembly: AssemblyVersion("0.2.1.20")]
[assembly: AssemblyInformationalVersion("0.2.1.20 Alpha")]