# HG changeset patch # User moel.mich # Date 1264721379 0 # Node ID 9523a3322777c1fe59527196dca82904fe6e670f # Parent 56c9d6c8c08baf17c217166878f1efa685a9b267 Release version 0.1.2. First implementation for Fintek F71882FG chips. Fixed Intel Core i7 temperature reading. Changed Nvidia GPU enumeration. diff -r 56c9d6c8c08b -r 9523a3322777 GUI/AboutBox.Designer.cs --- a/GUI/AboutBox.Designer.cs Thu Jan 28 19:31:10 2010 +0000 +++ b/GUI/AboutBox.Designer.cs Thu Jan 28 23:29:39 2010 +0000 @@ -124,7 +124,7 @@ this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(99, 15); this.label3.TabIndex = 4; - this.label3.Text = "Version 0.1.1 Beta"; + this.label3.Text = "Version " + System.Windows.Forms.Application.ProductVersion + " Beta"; // // label4 // diff -r 56c9d6c8c08b -r 9523a3322777 Hardware/CPU/IntelCPU.cs --- a/Hardware/CPU/IntelCPU.cs Thu Jan 28 19:31:10 2010 +0000 +++ b/Hardware/CPU/IntelCPU.cs Thu Jan 28 23:29:39 2010 +0000 @@ -49,7 +49,8 @@ private Sensor[] coreTemperatures; - private float tjMax = 0; + private float tjMax = 0; + private uint logicalProcessorsPerCore; private const uint IA32_THERM_STATUS_MSR = 0x019C; private const uint IA32_TEMPERATURE_TARGET = 0x01A2; @@ -64,7 +65,7 @@ if (cpuidData.GetLength(0) > 0x04) logicalProcessors = ((cpuidData[4, 0] >> 26) & 0x3F) + 1; - uint logicalProcessorsPerCore = 1; + logicalProcessorsPerCore = 1; if (cpuidData.GetLength(0) > 0x0B) logicalProcessorsPerCore = cpuidData[0x0B, 1] & 0xFF; if (logicalProcessorsPerCore == 0) @@ -159,7 +160,8 @@ uint eax = 0, edx = 0; for (int i = 0; i < coreTemperatures.Length; i++) { if (WinRing0.RdmsrPx( - IA32_THERM_STATUS_MSR, ref eax, ref edx, (UIntPtr)(1 << i))) + IA32_THERM_STATUS_MSR, ref eax, ref edx, + (UIntPtr)(logicalProcessorsPerCore << i))) { // if reading is valid if ((eax & 0x80000000) != 0) { diff -r 56c9d6c8c08b -r 9523a3322777 Hardware/LPC/Chip.cs --- a/Hardware/LPC/Chip.cs Thu Jan 28 19:31:10 2010 +0000 +++ b/Hardware/LPC/Chip.cs Thu Jan 28 23:29:39 2010 +0000 @@ -11,7 +11,8 @@ IT8718F = 0x8718, IT8720F = 0x8720, IT8726F = 0x8726, - W83627DHG = 0xA020 + W83627DHG = 0xA020, + F71882FG = 0x0541 } } diff -r 56c9d6c8c08b -r 9523a3322777 Hardware/LPC/F71882FG.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware/LPC/F71882FG.cs Thu Jan 28 23:29:39 2010 +0000 @@ -0,0 +1,188 @@ +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; + +namespace OpenHardwareMonitor.Hardware.LPC { + public class F71882FG : IHardware { + + private string name; + private Image icon; + + private ushort address; + + private List active = new List(); + + private Sensor[] temperatures; + private Sensor[] fans; + private Sensor[] voltages; + private float[] voltageGains; + + // Hardware Monitor + private const byte ADDRESS_REGISTER_OFFSET = 0x05; + private const byte DATA_REGISTER_OFFSET = 0x06; + + // Hardware Monitor Registers + private const byte VOLTAGE_BASE_REG = 0x20; + private const byte TEMPERATURE_BASE_REG = 0x72; + private byte[] FAN_TACHOMETER_REG = new byte[] { 0xA0, 0xB0, 0xC0, 0xD0 }; + + private byte ReadByte(byte register) { + WinRing0.WriteIoPortByte( + (ushort)(address + ADDRESS_REGISTER_OFFSET), register); + return WinRing0.ReadIoPortByte((ushort)(address + DATA_REGISTER_OFFSET)); + } + + public F71882FG(ushort address) { + this.address = address; + + this.name = "Fintek F71882FG"; + + temperatures = new Sensor[3]; + for (int i = 0; i < temperatures.Length; i++) + temperatures[i] = new Sensor("Temperature #" + (i + 1), i, + SensorType.Temperature, this); + + fans = new Sensor[4]; + for (int i = 0; i < fans.Length; i++) + fans[i] = new Sensor("Fan #" + (i + 1), i, SensorType.Fan, this); + + voltageGains = new float[] { 1, 0.5f, 1, 1, 1, 1, 1, 1, 1 }; + voltages = new Sensor[4]; + voltages[0] = new Sensor("VCC3V", 0, SensorType.Voltage, this); + voltages[1] = new Sensor("CPU VCore", 1, SensorType.Voltage, this); + voltages[2] = new Sensor("VSB3V", 7, SensorType.Voltage, this); + voltages[3] = new Sensor("Battery", 8, SensorType.Voltage, this); + + this.icon = Utilities.EmbeddedResources.GetImage("chip.png"); + } + + public string Name { + get { return name; } + } + + public string Identifier { + get { return "/lpc/f71882fg"; } + } + + public Image Icon { + get { return icon; } + } + + public ISensor[] Sensors { + get { return active.ToArray(); } + } + + public string GetReport() { + StringBuilder r = new StringBuilder(); + + r.AppendLine("LPC F71882FG"); + r.AppendLine(); + r.Append("Base Adress: 0x"); r.AppendLine(address.ToString("X4")); + r.AppendLine(); + r.AppendLine("Hardware Monitor Registers"); + r.AppendLine(); + + 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 <= 0xF; i++) { + r.Append(" "); r.Append((i << 4).ToString("X2")); r.Append(" "); + for (int j = 0; j <= 0xF; j++) { + r.Append(" "); + r.Append(ReadByte((byte)((i << 4) | j)).ToString("X2")); + } + r.AppendLine(); + } + r.AppendLine(); + return r.ToString(); + } + + public void Update() { + + foreach (Sensor sensor in voltages) { + int value = ReadByte((byte)(VOLTAGE_BASE_REG + sensor.Index)); + sensor.Value = voltageGains[sensor.Index] * 0.001f * (value << 4); + if (sensor.Value > 0) + ActivateSensor(sensor); + else + DeactivateSensor(sensor); + } + + foreach (Sensor sensor in temperatures) { + int value = ReadByte((byte)(TEMPERATURE_BASE_REG + 2 * sensor.Index)); + sensor.Value = value; + if (value < 254) + ActivateSensor(sensor); + else + DeactivateSensor(sensor); + } + + foreach (Sensor sensor in fans) { + int value = ReadByte(FAN_TACHOMETER_REG[sensor.Index]) << 8; + value |= ReadByte((byte)(FAN_TACHOMETER_REG[sensor.Index] + 1)); + + if (value > 0) { + sensor.Value = (value < 0x0fff) ? 1.5e6f / value : 0; + ActivateSensor(sensor); + } else { + DeactivateSensor(sensor); + } + } + } + + private void ActivateSensor(Sensor sensor) { + if (!active.Contains(sensor)) { + active.Add(sensor); + SensorAdded(sensor); + } + } + + private void DeactivateSensor(Sensor sensor) { + if (active.Contains(sensor)) { + active.Remove(sensor); + SensorRemoved(sensor); + } + } + + public event SensorEventHandler SensorAdded; + public event SensorEventHandler SensorRemoved; + + } +} diff -r 56c9d6c8c08b -r 9523a3322777 Hardware/LPC/IT87.cs --- a/Hardware/LPC/IT87.cs Thu Jan 28 19:31:10 2010 +0000 +++ b/Hardware/LPC/IT87.cs Thu Jan 28 23:29:39 2010 +0000 @@ -55,7 +55,6 @@ private Sensor[] voltages; private List active = new List(); private float[] voltageGains; - // Consts private const byte ITE_VENDOR_ID = 0x90; @@ -75,7 +74,6 @@ new byte[] { 0x18, 0x19, 0x1a, 0x81, 0x83 }; private const byte VOLTAGE_BASE_REG = 0x20; - private byte ReadByte(byte register) { WinRing0.WriteIoPortByte( (ushort)(address + ADDRESS_REGISTER_OFFSET), register); @@ -151,7 +149,7 @@ r.AppendLine(); r.Append("Chip ID: 0x"); r.AppendLine(chip.ToString("X")); r.Append("Chip Name: "); r.AppendLine(name); - r.Append("Base Address: 0x"); r.AppendLine(address.ToString("X")); + r.Append("Base Address: 0x"); r.AppendLine(address.ToString("X4")); r.AppendLine(); r.AppendLine("Environment Controller Registers"); r.AppendLine(); diff -r 56c9d6c8c08b -r 9523a3322777 Hardware/LPC/LPCGroup.cs --- a/Hardware/LPC/LPCGroup.cs Thu Jan 28 19:31:10 2010 +0000 +++ b/Hardware/LPC/LPCGroup.cs Thu Jan 28 23:29:39 2010 +0000 @@ -47,32 +47,32 @@ private Chip chip = Chip.Unknown; // I/O Ports - private const ushort REGISTER_PORT = 0x2e; - private const ushort VALUE_PORT = 0x2f; + private ushort[] REGISTER_PORTS = new ushort[] { 0x2e, 0x4e }; + private ushort[] VALUE_PORTS = new ushort[] { 0x2f, 0x4f }; + + private ushort registerPort; + private ushort valuePort; // Registers private const byte CONFIGURATION_CONTROL_REGISTER = 0x02; private const byte DEVCIE_SELECT_REGISTER = 0x07; private const byte CHIP_ID_REGISTER = 0x20; private const byte CHIP_REVISION_REGISTER = 0x21; + private const byte BASE_ADDRESS_REGISTER = 0x60; - private static byte ReadByte(byte register) { - WinRing0.WriteIoPortByte(REGISTER_PORT, register); - return WinRing0.ReadIoPortByte(VALUE_PORT); + private byte ReadByte(byte register) { + WinRing0.WriteIoPortByte(registerPort, register); + return WinRing0.ReadIoPortByte(valuePort); } - private static ushort ReadWord(byte register) { - ushort value; - WinRing0.WriteIoPortByte(REGISTER_PORT, register); - value = (ushort)(((ushort)WinRing0.ReadIoPortByte(VALUE_PORT)) << 8); - WinRing0.WriteIoPortByte(REGISTER_PORT, (byte)(register + 1)); - value |= (ushort)WinRing0.ReadIoPortByte(VALUE_PORT); - return value; + private ushort ReadWord(byte register) { + return (ushort)((ReadByte(register) << 8) | + ReadByte((byte)(register + 1))); } - private static void Select(byte logicalDeviceNumber) { - WinRing0.WriteIoPortByte(REGISTER_PORT, DEVCIE_SELECT_REGISTER); - WinRing0.WriteIoPortByte(VALUE_PORT, logicalDeviceNumber); + private void Select(byte logicalDeviceNumber) { + WinRing0.WriteIoPortByte(registerPort, DEVCIE_SELECT_REGISTER); + WinRing0.WriteIoPortByte(valuePort, logicalDeviceNumber); } // IT87 @@ -81,84 +81,137 @@ private const ushort IT8720F_CHIP_ID = 0x8720; private const ushort IT8726F_CHIP_ID = 0x8726; - private const byte IT87_ENVIRONMENT_CONTROLLER_LDN = 0x04; - private const byte IT87_ENVIRONMENT_CONTROLLER_BASE_ADDR_REG = 0x60; + private const byte IT87_ENVIRONMENT_CONTROLLER_LDN = 0x04; - private static void IT87Enter() { - WinRing0.WriteIoPortByte(REGISTER_PORT, 0x87); - WinRing0.WriteIoPortByte(REGISTER_PORT, 0x01); - WinRing0.WriteIoPortByte(REGISTER_PORT, 0x55); - WinRing0.WriteIoPortByte(REGISTER_PORT, 0x55); + private void IT87Enter() { + WinRing0.WriteIoPortByte(registerPort, 0x87); + WinRing0.WriteIoPortByte(registerPort, 0x01); + WinRing0.WriteIoPortByte(registerPort, 0x55); + WinRing0.WriteIoPortByte(registerPort, 0x55); } - internal static void IT87Exit() { - WinRing0.WriteIoPortByte(REGISTER_PORT, CONFIGURATION_CONTROL_REGISTER); - WinRing0.WriteIoPortByte(VALUE_PORT, 0x02); + internal void IT87Exit() { + WinRing0.WriteIoPortByte(registerPort, CONFIGURATION_CONTROL_REGISTER); + WinRing0.WriteIoPortByte(valuePort, 0x02); } - // Winbond - private static void WinbondEnter() { - WinRing0.WriteIoPortByte(REGISTER_PORT, 0x87); - WinRing0.WriteIoPortByte(REGISTER_PORT, 0x87); + // Winbond, Fintek + private const byte FINTEK_VENDOR_ID_REGISTER = 0x23; + private const ushort FINTEK_VENDOR_ID = 0x1934; + + private const byte W83627DHG_HARDWARE_MONITOR_LDN = 0x0B; + private const byte F71882FG_HARDWARE_MONITOR_LDN = 0x04; + + private void WinbondFintekEnter() { + WinRing0.WriteIoPortByte(registerPort, 0x87); + WinRing0.WriteIoPortByte(registerPort, 0x87); } - private static void WinbondExit() { - WinRing0.WriteIoPortByte(REGISTER_PORT, 0xAA); + private void WinbondFintekExit() { + WinRing0.WriteIoPortByte(registerPort, 0xAA); } public LPCGroup() { if (!WinRing0.IsAvailable) return; - WinbondEnter(); + for (int i = 0; i < REGISTER_PORTS.Length; i++) { + registerPort = REGISTER_PORTS[i]; + valuePort = VALUE_PORTS[i]; - byte id = ReadByte(CHIP_ID_REGISTER); - byte revision = ReadByte(CHIP_REVISION_REGISTER); - switch (id) { - case 0xA0: - switch (revision & 0xF0) { - case 0x20: chip = Chip.W83627DHG; break; - default: chip = Chip.Unknown; break; - } break; - default: chip = Chip.Unknown; break; - } - if (chip != Chip.Unknown) { + WinbondFintekEnter(); - WinbondExit(); + byte hardwareMonitorLDN; + byte id = ReadByte(CHIP_ID_REGISTER); + byte revision = ReadByte(CHIP_REVISION_REGISTER); + switch (id) { + case 0xA0: + switch (revision & 0xF0) { + case 0x20: + chip = Chip.W83627DHG; + hardwareMonitorLDN = W83627DHG_HARDWARE_MONITOR_LDN; + break; + default: + chip = Chip.Unknown; + hardwareMonitorLDN = 0; + break; + } break; + case 0x05: + switch (revision) { + case 0x41: + chip = Chip.F71882FG; + hardwareMonitorLDN = F71882FG_HARDWARE_MONITOR_LDN; + break; + default: + chip = Chip.Unknown; + hardwareMonitorLDN = 0; + break; + } break; + default: + chip = Chip.Unknown; + hardwareMonitorLDN = 0; + break; + } + if (chip != Chip.Unknown) { - W83627DHG w83627dhg = new W83627DHG(revision); - if (w83627dhg.IsAvailable) - hardware.Add(w83627dhg); - return; - } + Select(hardwareMonitorLDN); + ushort address = ReadWord(BASE_ADDRESS_REGISTER); + Thread.Sleep(1); + ushort verify = ReadWord(BASE_ADDRESS_REGISTER); - IT87Enter(); + ushort vendorID = 0; + if (chip == Chip.F71882FG) + vendorID = ReadWord(FINTEK_VENDOR_ID_REGISTER); - switch (ReadWord(CHIP_ID_REGISTER)) { - case 0x8716: chip = Chip.IT8716F; break; - case 0x8718: chip = Chip.IT8718F; break; - case 0x8720: chip = Chip.IT8720F; break; - case 0x8726: chip = Chip.IT8726F; break; - default: chip = Chip.Unknown; break; - } + WinbondFintekExit(); - if (chip != Chip.Unknown) { - Select(IT87_ENVIRONMENT_CONTROLLER_LDN); - ushort address = ReadWord(IT87_ENVIRONMENT_CONTROLLER_BASE_ADDR_REG); - Thread.Sleep(1); - ushort verify = ReadWord(IT87_ENVIRONMENT_CONTROLLER_BASE_ADDR_REG); + if (address != verify || address == 0 || (address & 0xF007) != 0) + return; + + switch (chip) { + case Chip.W83627DHG: + W83627DHG w83627dhg = new W83627DHG(revision, address); + if (w83627dhg.IsAvailable) + hardware.Add(w83627dhg); + break; + case Chip.F71882FG: + if (vendorID == FINTEK_VENDOR_ID) + hardware.Add(new F71882FG(address)); + break; + default: break; + } + + return; + } - IT87Exit(); + IT87Enter(); - if (address != verify || address == 0 || (address & 0xF007) != 0) + switch (ReadWord(CHIP_ID_REGISTER)) { + case 0x8716: chip = Chip.IT8716F; break; + case 0x8718: chip = Chip.IT8718F; break; + case 0x8720: chip = Chip.IT8720F; break; + case 0x8726: chip = Chip.IT8726F; break; + default: chip = Chip.Unknown; break; + } + + if (chip != Chip.Unknown) { + Select(IT87_ENVIRONMENT_CONTROLLER_LDN); + ushort address = ReadWord(BASE_ADDRESS_REGISTER); + Thread.Sleep(1); + ushort verify = ReadWord(BASE_ADDRESS_REGISTER); + + IT87Exit(); + + if (address != verify || address == 0 || (address & 0xF007) != 0) + return; + + IT87 it87 = new IT87(chip, address); + if (it87.IsAvailable) + hardware.Add(it87); + return; - - IT87 it87 = new IT87(chip, address); - if (it87.IsAvailable) - hardware.Add(it87); - - return; - } + } + } } public IHardware[] Hardware { diff -r 56c9d6c8c08b -r 9523a3322777 Hardware/LPC/W83627DHG.cs --- a/Hardware/LPC/W83627DHG.cs Thu Jan 28 19:31:10 2010 +0000 +++ b/Hardware/LPC/W83627DHG.cs Thu Jan 28 23:29:39 2010 +0000 @@ -12,9 +12,11 @@ private Image icon; private bool available = false; + private ushort address; - public W83627DHG(byte revision) { + public W83627DHG(byte revision, ushort address) { this.revision = revision; + this.address = address; this.name = "Winbond W83627DHG"; this.icon = Utilities.EmbeddedResources.GetImage("chip.png"); @@ -45,7 +47,9 @@ r.AppendLine("LPC W83627DHG"); r.AppendLine(); - r.Append("Chip revision: 0x"); r.AppendLine(revision.ToString("X")); + r.Append("Chip revision: 0x"); r.AppendLine(revision.ToString("X")); + r.Append("Base Adress: 0x"); r.AppendLine(address.ToString("X4")); + r.AppendLine(); return r.ToString(); } diff -r 56c9d6c8c08b -r 9523a3322777 Hardware/Nvidia/NvidiaGroup.cs --- a/Hardware/Nvidia/NvidiaGroup.cs Thu Jan 28 19:31:10 2010 +0000 +++ b/Hardware/Nvidia/NvidiaGroup.cs Thu Jan 28 23:29:39 2010 +0000 @@ -54,8 +54,12 @@ if (NVAPI.NvAPI_EnumPhysicalGPUs(handles, out count) != NvStatus.OK) return; - for (int i = 0; i < count; i++) - hardware.Add(new NvidiaGPU(i, handles[i])); + for (int i = 0; i < count; i++) { + string gpuName; + NVAPI.NvAPI_GPU_GetFullName(handles[i], out gpuName); + if (gpuName != null && gpuName.Trim() != "") + hardware.Add(new NvidiaGPU(i, handles[i])); + } } public IHardware[] Hardware { diff -r 56c9d6c8c08b -r 9523a3322777 OpenHardwareMonitor.csproj --- a/OpenHardwareMonitor.csproj Thu Jan 28 19:31:10 2010 +0000 +++ b/OpenHardwareMonitor.csproj Thu Jan 28 23:29:39 2010 +0000 @@ -62,6 +62,7 @@ + diff -r 56c9d6c8c08b -r 9523a3322777 Properties/AssemblyInfo.cs --- a/Properties/AssemblyInfo.cs Thu Jan 28 19:31:10 2010 +0000 +++ b/Properties/AssemblyInfo.cs Thu Jan 28 23:29:39 2010 +0000 @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.1.0")] -[assembly: AssemblyFileVersion("0.1.1.0")] +[assembly: AssemblyVersion("0.1.2.0")] +[assembly: AssemblyFileVersion("0.1.2.0")]