Release version 0.1.2. First implementation for Fintek F71882FG chips. Fixed Intel Core i7 temperature reading. Changed Nvidia GPU enumeration.

This commit is contained in:
Michael Möller
2010-01-28 23:29:39 +00:00
parent d7f2ebd4ba
commit 8fc7a41776
10 changed files with 337 additions and 86 deletions

View File

@@ -124,7 +124,7 @@ namespace OpenHardwareMonitor.GUI {
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(99, 15); this.label3.Size = new System.Drawing.Size(99, 15);
this.label3.TabIndex = 4; this.label3.TabIndex = 4;
this.label3.Text = "Version 0.1.1 Beta"; this.label3.Text = "Version " + System.Windows.Forms.Application.ProductVersion + " Beta";
// //
// label4 // label4
// //

View File

@@ -49,7 +49,8 @@ namespace OpenHardwareMonitor.Hardware.CPU {
private Sensor[] coreTemperatures; 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_THERM_STATUS_MSR = 0x019C;
private const uint IA32_TEMPERATURE_TARGET = 0x01A2; private const uint IA32_TEMPERATURE_TARGET = 0x01A2;
@@ -64,7 +65,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
if (cpuidData.GetLength(0) > 0x04) if (cpuidData.GetLength(0) > 0x04)
logicalProcessors = ((cpuidData[4, 0] >> 26) & 0x3F) + 1; logicalProcessors = ((cpuidData[4, 0] >> 26) & 0x3F) + 1;
uint logicalProcessorsPerCore = 1; logicalProcessorsPerCore = 1;
if (cpuidData.GetLength(0) > 0x0B) if (cpuidData.GetLength(0) > 0x0B)
logicalProcessorsPerCore = cpuidData[0x0B, 1] & 0xFF; logicalProcessorsPerCore = cpuidData[0x0B, 1] & 0xFF;
if (logicalProcessorsPerCore == 0) if (logicalProcessorsPerCore == 0)
@@ -159,7 +160,8 @@ namespace OpenHardwareMonitor.Hardware.CPU {
uint eax = 0, edx = 0; uint eax = 0, edx = 0;
for (int i = 0; i < coreTemperatures.Length; i++) { for (int i = 0; i < coreTemperatures.Length; i++) {
if (WinRing0.RdmsrPx( 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 reading is valid
if ((eax & 0x80000000) != 0) { if ((eax & 0x80000000) != 0) {

View File

@@ -11,7 +11,8 @@ namespace OpenHardwareMonitor.Hardware.LPC {
IT8718F = 0x8718, IT8718F = 0x8718,
IT8720F = 0x8720, IT8720F = 0x8720,
IT8726F = 0x8726, IT8726F = 0x8726,
W83627DHG = 0xA020 W83627DHG = 0xA020,
F71882FG = 0x0541
} }
} }

188
Hardware/LPC/F71882FG.cs Normal file
View File

@@ -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 <m.moeller@gmx.ch>.
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<ISensor> active = new List<ISensor>();
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;
}
}

View File

@@ -55,7 +55,6 @@ namespace OpenHardwareMonitor.Hardware.LPC {
private Sensor[] voltages; private Sensor[] voltages;
private List<ISensor> active = new List<ISensor>(); private List<ISensor> active = new List<ISensor>();
private float[] voltageGains; private float[] voltageGains;
// Consts // Consts
private const byte ITE_VENDOR_ID = 0x90; private const byte ITE_VENDOR_ID = 0x90;
@@ -75,7 +74,6 @@ namespace OpenHardwareMonitor.Hardware.LPC {
new byte[] { 0x18, 0x19, 0x1a, 0x81, 0x83 }; new byte[] { 0x18, 0x19, 0x1a, 0x81, 0x83 };
private const byte VOLTAGE_BASE_REG = 0x20; private const byte VOLTAGE_BASE_REG = 0x20;
private byte ReadByte(byte register) { private byte ReadByte(byte register) {
WinRing0.WriteIoPortByte( WinRing0.WriteIoPortByte(
(ushort)(address + ADDRESS_REGISTER_OFFSET), register); (ushort)(address + ADDRESS_REGISTER_OFFSET), register);
@@ -151,7 +149,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
r.AppendLine(); r.AppendLine();
r.Append("Chip ID: 0x"); r.AppendLine(chip.ToString("X")); r.Append("Chip ID: 0x"); r.AppendLine(chip.ToString("X"));
r.Append("Chip Name: "); r.AppendLine(name); 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();
r.AppendLine("Environment Controller Registers"); r.AppendLine("Environment Controller Registers");
r.AppendLine(); r.AppendLine();

View File

@@ -47,32 +47,32 @@ namespace OpenHardwareMonitor.Hardware.LPC {
private Chip chip = Chip.Unknown; private Chip chip = Chip.Unknown;
// I/O Ports // I/O Ports
private const ushort REGISTER_PORT = 0x2e; private ushort[] REGISTER_PORTS = new ushort[] { 0x2e, 0x4e };
private const ushort VALUE_PORT = 0x2f; private ushort[] VALUE_PORTS = new ushort[] { 0x2f, 0x4f };
private ushort registerPort;
private ushort valuePort;
// Registers // Registers
private const byte CONFIGURATION_CONTROL_REGISTER = 0x02; private const byte CONFIGURATION_CONTROL_REGISTER = 0x02;
private const byte DEVCIE_SELECT_REGISTER = 0x07; private const byte DEVCIE_SELECT_REGISTER = 0x07;
private const byte CHIP_ID_REGISTER = 0x20; private const byte CHIP_ID_REGISTER = 0x20;
private const byte CHIP_REVISION_REGISTER = 0x21; private const byte CHIP_REVISION_REGISTER = 0x21;
private const byte BASE_ADDRESS_REGISTER = 0x60;
private static byte ReadByte(byte register) { private byte ReadByte(byte register) {
WinRing0.WriteIoPortByte(REGISTER_PORT, register); WinRing0.WriteIoPortByte(registerPort, register);
return WinRing0.ReadIoPortByte(VALUE_PORT); return WinRing0.ReadIoPortByte(valuePort);
} }
private static ushort ReadWord(byte register) { private ushort ReadWord(byte register) {
ushort value; return (ushort)((ReadByte(register) << 8) |
WinRing0.WriteIoPortByte(REGISTER_PORT, register); ReadByte((byte)(register + 1)));
value = (ushort)(((ushort)WinRing0.ReadIoPortByte(VALUE_PORT)) << 8);
WinRing0.WriteIoPortByte(REGISTER_PORT, (byte)(register + 1));
value |= (ushort)WinRing0.ReadIoPortByte(VALUE_PORT);
return value;
} }
private static void Select(byte logicalDeviceNumber) { private void Select(byte logicalDeviceNumber) {
WinRing0.WriteIoPortByte(REGISTER_PORT, DEVCIE_SELECT_REGISTER); WinRing0.WriteIoPortByte(registerPort, DEVCIE_SELECT_REGISTER);
WinRing0.WriteIoPortByte(VALUE_PORT, logicalDeviceNumber); WinRing0.WriteIoPortByte(valuePort, logicalDeviceNumber);
} }
// IT87 // IT87
@@ -81,84 +81,137 @@ namespace OpenHardwareMonitor.Hardware.LPC {
private const ushort IT8720F_CHIP_ID = 0x8720; private const ushort IT8720F_CHIP_ID = 0x8720;
private const ushort IT8726F_CHIP_ID = 0x8726; private const ushort IT8726F_CHIP_ID = 0x8726;
private const byte IT87_ENVIRONMENT_CONTROLLER_LDN = 0x04; private const byte IT87_ENVIRONMENT_CONTROLLER_LDN = 0x04;
private const byte IT87_ENVIRONMENT_CONTROLLER_BASE_ADDR_REG = 0x60;
private static void IT87Enter() { private void IT87Enter() {
WinRing0.WriteIoPortByte(REGISTER_PORT, 0x87); WinRing0.WriteIoPortByte(registerPort, 0x87);
WinRing0.WriteIoPortByte(REGISTER_PORT, 0x01); WinRing0.WriteIoPortByte(registerPort, 0x01);
WinRing0.WriteIoPortByte(REGISTER_PORT, 0x55); WinRing0.WriteIoPortByte(registerPort, 0x55);
WinRing0.WriteIoPortByte(REGISTER_PORT, 0x55); WinRing0.WriteIoPortByte(registerPort, 0x55);
} }
internal static void IT87Exit() { internal void IT87Exit() {
WinRing0.WriteIoPortByte(REGISTER_PORT, CONFIGURATION_CONTROL_REGISTER); WinRing0.WriteIoPortByte(registerPort, CONFIGURATION_CONTROL_REGISTER);
WinRing0.WriteIoPortByte(VALUE_PORT, 0x02); WinRing0.WriteIoPortByte(valuePort, 0x02);
} }
// Winbond // Winbond, Fintek
private static void WinbondEnter() { private const byte FINTEK_VENDOR_ID_REGISTER = 0x23;
WinRing0.WriteIoPortByte(REGISTER_PORT, 0x87); private const ushort FINTEK_VENDOR_ID = 0x1934;
WinRing0.WriteIoPortByte(REGISTER_PORT, 0x87);
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() { private void WinbondFintekExit() {
WinRing0.WriteIoPortByte(REGISTER_PORT, 0xAA); WinRing0.WriteIoPortByte(registerPort, 0xAA);
} }
public LPCGroup() { public LPCGroup() {
if (!WinRing0.IsAvailable) if (!WinRing0.IsAvailable)
return; 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); WinbondFintekEnter();
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) {
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); Select(hardwareMonitorLDN);
if (w83627dhg.IsAvailable) ushort address = ReadWord(BASE_ADDRESS_REGISTER);
hardware.Add(w83627dhg); Thread.Sleep(1);
return; 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)) { WinbondFintekExit();
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) { if (address != verify || address == 0 || (address & 0xF007) != 0)
Select(IT87_ENVIRONMENT_CONTROLLER_LDN); return;
ushort address = ReadWord(IT87_ENVIRONMENT_CONTROLLER_BASE_ADDR_REG);
Thread.Sleep(1); switch (chip) {
ushort verify = ReadWord(IT87_ENVIRONMENT_CONTROLLER_BASE_ADDR_REG); case Chip.W83627DHG:
W83627DHG w83627dhg = new W83627DHG(revision, address);
IT87Exit(); if (w83627dhg.IsAvailable)
hardware.Add(w83627dhg);
if (address != verify || address == 0 || (address & 0xF007) != 0) break;
case Chip.F71882FG:
if (vendorID == FINTEK_VENDOR_ID)
hardware.Add(new F71882FG(address));
break;
default: break;
}
return; return;
}
IT87 it87 = new IT87(chip, address); IT87Enter();
if (it87.IsAvailable)
hardware.Add(it87); switch (ReadWord(CHIP_ID_REGISTER)) {
case 0x8716: chip = Chip.IT8716F; break;
return; 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;
}
}
} }
public IHardware[] Hardware { public IHardware[] Hardware {

View File

@@ -12,9 +12,11 @@ namespace OpenHardwareMonitor.Hardware.LPC {
private Image icon; private Image icon;
private bool available = false; private bool available = false;
private ushort address;
public W83627DHG(byte revision) { public W83627DHG(byte revision, ushort address) {
this.revision = revision; this.revision = revision;
this.address = address;
this.name = "Winbond W83627DHG"; this.name = "Winbond W83627DHG";
this.icon = Utilities.EmbeddedResources.GetImage("chip.png"); this.icon = Utilities.EmbeddedResources.GetImage("chip.png");
@@ -45,7 +47,9 @@ namespace OpenHardwareMonitor.Hardware.LPC {
r.AppendLine("LPC W83627DHG"); r.AppendLine("LPC W83627DHG");
r.AppendLine(); 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(); return r.ToString();
} }

View File

@@ -54,8 +54,12 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
if (NVAPI.NvAPI_EnumPhysicalGPUs(handles, out count) != NvStatus.OK) if (NVAPI.NvAPI_EnumPhysicalGPUs(handles, out count) != NvStatus.OK)
return; return;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++) {
hardware.Add(new NvidiaGPU(i, handles[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 { public IHardware[] Hardware {

View File

@@ -62,6 +62,7 @@
<Compile Include="Hardware\HDD\HDDGroup.cs" /> <Compile Include="Hardware\HDD\HDDGroup.cs" />
<Compile Include="Hardware\HDD\SMART.cs" /> <Compile Include="Hardware\HDD\SMART.cs" />
<Compile Include="Hardware\LPC\Chip.cs" /> <Compile Include="Hardware\LPC\Chip.cs" />
<Compile Include="Hardware\LPC\F71882FG.cs" />
<Compile Include="Hardware\SMBIOS\SMBIOSGroup.cs" /> <Compile Include="Hardware\SMBIOS\SMBIOSGroup.cs" />
<Compile Include="Hardware\LPC\W83627DHG.cs" /> <Compile Include="Hardware\LPC\W83627DHG.cs" />
<Compile Include="Hardware\ReportWriter.cs" /> <Compile Include="Hardware\ReportWriter.cs" />

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.1.0")] [assembly: AssemblyVersion("0.1.2.0")]
[assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyFileVersion("0.1.2.0")]