# HG changeset patch # User moel.mich # Date 1265572431 0 # Node ID c4d1fb76a9e1360493d25c2ecdf689b171ccf702 # Parent 420adf5040110ba051f0cfc85b61c74807be9765 Added initial support for W83627HF. Some refactoring for IHardware classes. diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/ATI/ATIGPU.cs --- a/Hardware/ATI/ATIGPU.cs Sun Feb 07 19:48:32 2010 +0000 +++ b/Hardware/ATI/ATIGPU.cs Sun Feb 07 19:53:51 2010 +0000 @@ -41,7 +41,7 @@ using System.Reflection; namespace OpenHardwareMonitor.Hardware.ATI { - public class ATIGPU : IHardware { + public class ATIGPU : Hardware, IHardware { private string name; private Image icon; @@ -55,8 +55,6 @@ private Sensor coreVoltage; private Sensor coreLoad; - private List active = new List(); - public ATIGPU(string name, int adapterIndex, int busNumber, int deviceNumber) { @@ -95,10 +93,6 @@ get { return icon; } } - public ISensor[] Sensors { - get { return active.ToArray(); } - } - public string GetReport() { return null; } @@ -144,24 +138,5 @@ DeactivateSensor(coreLoad); } } - - private void ActivateSensor(Sensor sensor) { - if (!active.Contains(sensor)) { - active.Add(sensor); - if (SensorAdded != null) - SensorAdded(sensor); - } - } - - private void DeactivateSensor(Sensor sensor) { - if (active.Contains(sensor)) { - active.Remove(sensor); - if (SensorRemoved != null) - SensorRemoved(sensor); - } - } - - public event SensorEventHandler SensorAdded; - public event SensorEventHandler SensorRemoved; } } diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/CPU/AMD0FCPU.cs --- a/Hardware/CPU/AMD0FCPU.cs Sun Feb 07 19:48:32 2010 +0000 +++ b/Hardware/CPU/AMD0FCPU.cs Sun Feb 07 19:53:51 2010 +0000 @@ -43,7 +43,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { - public class AMD0FCPU : IHardware { + public class AMD0FCPU : Hardware, IHardware { private string name; private Image icon; @@ -56,8 +56,6 @@ private Sensor totalLoad; private Sensor[] coreLoads; - private List active = new List(); - private CPULoad cpuLoad; private const ushort PCI_AMD_VENDOR_ID = 0x1022; @@ -121,10 +119,6 @@ get { return icon; } } - public ISensor[] Sensors { - get { return active.ToArray(); } - } - public string GetReport() { return null; } @@ -154,26 +148,6 @@ coreLoads[i].Value = cpuLoad.GetCoreLoad(i); totalLoad.Value = cpuLoad.GetTotalLoad(); } - } - - private void ActivateSensor(Sensor sensor) { - if (!active.Contains(sensor)) { - active.Add(sensor); - if (SensorAdded != null) - SensorAdded(sensor); - } - } - - private void DeactivateSensor(Sensor sensor) { - if (active.Contains(sensor)) { - active.Remove(sensor); - if (SensorRemoved != null) - SensorRemoved(sensor); - } - } - - public event SensorEventHandler SensorAdded; - public event SensorEventHandler SensorRemoved; - + } } } diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/CPU/AMD10CPU.cs --- a/Hardware/CPU/AMD10CPU.cs Sun Feb 07 19:48:32 2010 +0000 +++ b/Hardware/CPU/AMD10CPU.cs Sun Feb 07 19:53:51 2010 +0000 @@ -43,7 +43,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { - public class AMD10CPU : IHardware { + public class AMD10CPU : Hardware, IHardware { private string name; private Image icon; @@ -53,8 +53,6 @@ private Sensor totalLoad; private Sensor[] coreLoads; - private List active = new List(); - private CPULoad cpuLoad; private const ushort PCI_AMD_VENDOR_ID = 0x1022; @@ -107,10 +105,6 @@ get { return icon; } } - public ISensor[] Sensors { - get { return active.ToArray(); } - } - public string GetReport() { return null; } @@ -135,25 +129,5 @@ totalLoad.Value = cpuLoad.GetTotalLoad(); } } - - private void ActivateSensor(Sensor sensor) { - if (!active.Contains(sensor)) { - active.Add(sensor); - if (SensorAdded != null) - SensorAdded(sensor); - } - } - - private void DeactivateSensor(Sensor sensor) { - if (active.Contains(sensor)) { - active.Remove(sensor); - if (SensorRemoved != null) - SensorRemoved(sensor); - } - } - - public event SensorEventHandler SensorAdded; - public event SensorEventHandler SensorRemoved; - } } diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/CPU/IntelCPU.cs --- a/Hardware/CPU/IntelCPU.cs Sun Feb 07 19:48:32 2010 +0000 +++ b/Hardware/CPU/IntelCPU.cs Sun Feb 07 19:53:51 2010 +0000 @@ -43,7 +43,7 @@ using System.Text; namespace OpenHardwareMonitor.Hardware.CPU { - public class IntelCPU : IHardware { + public class IntelCPU : Hardware, IHardware { private string name; private Image icon; @@ -52,8 +52,6 @@ private Sensor totalLoad; private Sensor[] coreLoads; - private List active = new List(); - private float tjMax = 0; private uint logicalProcessors; private uint logicalProcessorsPerCore; @@ -165,10 +163,6 @@ get { return icon; } } - public ISensor[] Sensors { - get { return active.ToArray(); } - } - public string GetReport() { StringBuilder r = new StringBuilder(); @@ -210,25 +204,6 @@ coreLoads[i].Value = cpuLoad.GetCoreLoad(i); totalLoad.Value = cpuLoad.GetTotalLoad(); } - } - - private void ActivateSensor(Sensor sensor) { - if (!active.Contains(sensor)) { - active.Add(sensor); - if (SensorAdded != null) - SensorAdded(sensor); - } - } - - private void DeactivateSensor(Sensor sensor) { - if (active.Contains(sensor)) { - active.Remove(sensor); - if (SensorRemoved != null) - SensorRemoved(sensor); - } - } - - public event SensorEventHandler SensorAdded; - public event SensorEventHandler SensorRemoved; + } } } diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/Hardware.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware/Hardware.cs Sun Feb 07 19:53:51 2010 +0000 @@ -0,0 +1,69 @@ +/* + + 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; + +namespace OpenHardwareMonitor.Hardware { + public abstract class Hardware { + + private List active = new List(); + + public ISensor[] Sensors { + get { return active.ToArray(); } + } + + protected void ActivateSensor(Sensor sensor) { + if (!active.Contains(sensor)) { + active.Add(sensor); + if (SensorAdded != null) + SensorAdded(sensor); + } + } + + protected void DeactivateSensor(Sensor sensor) { + if (active.Contains(sensor)) { + active.Remove(sensor); + if (SensorRemoved != null) + SensorRemoved(sensor); + } + } + + public event SensorEventHandler SensorAdded; + public event SensorEventHandler SensorRemoved; + } +} diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/LPC/Chip.cs --- a/Hardware/LPC/Chip.cs Sun Feb 07 19:48:32 2010 +0000 +++ b/Hardware/LPC/Chip.cs Sun Feb 07 19:53:51 2010 +0000 @@ -13,6 +13,7 @@ IT8726F = 0x8726, W83627DHG = 0xA020, W83627DHGP = 0xB070, + W83627HF = 0x5200, F71862 = 0x0601, F71869 = 0x0814, F71882 = 0x0541, diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/LPC/F718XX.cs --- a/Hardware/LPC/F718XX.cs Sun Feb 07 19:48:32 2010 +0000 +++ b/Hardware/LPC/F718XX.cs Sun Feb 07 19:53:51 2010 +0000 @@ -41,16 +41,10 @@ using System.Text; namespace OpenHardwareMonitor.Hardware.LPC { - public class F718XX : IHardware { + public class F718XX : LPCHardware, IHardware { - private string name; - private Image icon; - - private Chip chip; private ushort address; - private List active = new List(); - private Sensor[] temperatures; private Sensor[] fans; private Sensor[] voltages; @@ -71,18 +65,9 @@ return WinRing0.ReadIoPortByte((ushort)(address + DATA_REGISTER_OFFSET)); } - public F718XX(Chip chip, ushort address) { - this.chip = chip; + public F718XX(Chip chip, ushort address) : base(chip) { this.address = address; - switch (chip) { - case Chip.F71862: name = "Fintek F71862"; break; - case Chip.F71869: name = "Fintek F71869"; break; - case Chip.F71882: name = "Fintek F71882"; break; - case Chip.F71889: name = "Fintek F71889"; break; - default: return; - } - temperatures = new Sensor[3]; for (int i = 0; i < temperatures.Length; i++) temperatures[i] = new Sensor("Temperature #" + (i + 1), i, @@ -98,30 +83,12 @@ 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/" + chip.ToString().ToLower(); } - } - - public Image Icon { - get { return icon; } - } - - public ISensor[] Sensors { - get { return active.ToArray(); } } public string GetReport() { StringBuilder r = new StringBuilder(); - r.AppendLine("LPC F718XX"); + r.AppendLine("LPC " + this.GetType().Name); r.AppendLine(); r.Append("Base Adress: 0x"); r.AppendLine(address.ToString("X4")); r.AppendLine(); @@ -175,25 +142,5 @@ } } } - - private void ActivateSensor(Sensor sensor) { - if (!active.Contains(sensor)) { - active.Add(sensor); - if (SensorAdded != null) - SensorAdded(sensor); - } - } - - private void DeactivateSensor(Sensor sensor) { - if (active.Contains(sensor)) { - active.Remove(sensor); - if (SensorRemoved != null) - SensorRemoved(sensor); - } - } - - public event SensorEventHandler SensorAdded; - public event SensorEventHandler SensorRemoved; - } } diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/LPC/IT87XX.cs --- a/Hardware/LPC/IT87XX.cs Sun Feb 07 19:48:32 2010 +0000 +++ b/Hardware/LPC/IT87XX.cs Sun Feb 07 19:53:51 2010 +0000 @@ -41,19 +41,14 @@ using System.Text; namespace OpenHardwareMonitor.Hardware.LPC { - public class IT87XX : IHardware { - - private string name; - private Image icon; + public class IT87XX : LPCHardware, IHardware { private bool available = false; - private Chip chip; private ushort address; private Sensor[] temperatures; private Sensor[] fans; private Sensor[] voltages; - private List active = new List(); private float[] voltageGains; // Consts @@ -80,18 +75,9 @@ return WinRing0.ReadIoPortByte((ushort)(address + DATA_REGISTER_OFFSET)); } - public IT87XX(Chip chip, ushort address) { + public IT87XX(Chip chip, ushort address) : base (chip) { - this.chip = chip; this.address = address; - - switch (chip) { - case Chip.IT8716F: name = "ITE IT8716F"; break; - case Chip.IT8718F: name = "ITE IT8718F"; break; - case Chip.IT8720F: name = "ITE IT8720F"; break; - case Chip.IT8726F: name = "ITE IT8726F"; break; - default: return; - } // Check vendor id byte vendorId = ReadByte(VENDOR_ID_REGISTER); @@ -119,33 +105,16 @@ voltages[1] = new Sensor("Battery", 8, SensorType.Voltage, this); available = true; - icon = Utilities.EmbeddedResources.GetImage("chip.png"); } public bool IsAvailable { get { return available; } } - public string Name { - get { return name; } - } - - public string Identifier { - get { return "/lpc/" + chip.ToString().ToLower(); } - } - - public Image Icon { - get { return icon; } - } - - public ISensor[] Sensors { - get { return active.ToArray(); } - } - public string GetReport() { StringBuilder r = new StringBuilder(); - r.AppendLine("LPC IT87XX"); + r.AppendLine("LPC " + this.GetType().Name); r.AppendLine(); r.Append("Chip ID: 0x"); r.AppendLine(chip.ToString("X")); r.Append("Chip Name: "); r.AppendLine(name); @@ -200,26 +169,6 @@ DeactivateSensor(sensor); } } - } - - private void ActivateSensor(Sensor sensor) { - if (!active.Contains(sensor)) { - active.Add(sensor); - if (SensorAdded != null) - SensorAdded(sensor); - } - } - - private void DeactivateSensor(Sensor sensor) { - if (active.Contains(sensor)) { - active.Remove(sensor); - if (SensorRemoved != null) - SensorRemoved(sensor); - } - } - - public event SensorEventHandler SensorAdded; - public event SensorEventHandler SensorRemoved; - + } } } diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/LPC/LPCGroup.cs --- a/Hardware/LPC/LPCGroup.cs Sun Feb 07 19:48:32 2010 +0000 +++ b/Hardware/LPC/LPCGroup.cs Sun Feb 07 19:53:51 2010 +0000 @@ -93,7 +93,7 @@ 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 W83627_HARDWARE_MONITOR_LDN = 0x0B; private const byte F71858_HARDWARE_MONITOR_LDN = 0x02; private const byte FINTEK_HARDWARE_MONITOR_LDN = 0x04; @@ -165,11 +165,23 @@ logicalDeviceNumber = 0; break; } break; + case 0x52: + switch (revision) { + case 0x17: + case 0x3A: + chip = Chip.W83627HF; + logicalDeviceNumber = W83627_HARDWARE_MONITOR_LDN; + break; + default: + chip = Chip.Unknown; + logicalDeviceNumber = 0; + break; + } break; case 0xA0: switch (revision & 0xF0) { case 0x20: chip = Chip.W83627DHG; - logicalDeviceNumber = W83627DHG_HARDWARE_MONITOR_LDN; + logicalDeviceNumber = W83627_HARDWARE_MONITOR_LDN; break; default: chip = Chip.Unknown; @@ -180,7 +192,7 @@ switch (revision & 0xF0) { case 0x70: chip = Chip.W83627DHGP; - logicalDeviceNumber = W83627DHG_HARDWARE_MONITOR_LDN; + logicalDeviceNumber = W83627_HARDWARE_MONITOR_LDN; break; default: chip = Chip.Unknown; @@ -211,9 +223,10 @@ switch (chip) { case Chip.W83627DHG: case Chip.W83627DHGP: - W83627DHG w83627dhg = new W83627DHG(chip, revision, address); - if (w83627dhg.IsAvailable) - hardware.Add(w83627dhg); + case Chip.W83627HF: + W83627 w83627 = new W83627(chip, revision, address); + if (w83627.IsAvailable) + hardware.Add(w83627); break; case Chip.F71862: case Chip.F71882: diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/LPC/LPCHardware.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware/LPC/LPCHardware.cs Sun Feb 07 19:53:51 2010 +0000 @@ -0,0 +1,80 @@ +/* + + 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; + +namespace OpenHardwareMonitor.Hardware.LPC { + public abstract class LPCHardware : Hardware { + + private Image icon; + protected readonly string name; + protected readonly Chip chip; + + public LPCHardware(Chip chip) { + this.chip = chip; + this.icon = Utilities.EmbeddedResources.GetImage("chip.png"); + + switch (chip) { + case Chip.F71862: name = "Fintek F71862"; break; + case Chip.F71869: name = "Fintek F71869"; break; + case Chip.F71882: name = "Fintek F71882"; break; + case Chip.F71889: name = "Fintek F71889"; break; + case Chip.IT8716F: this.name = "ITE IT8716F"; break; + case Chip.IT8718F: this.name = "ITE IT8718F"; break; + case Chip.IT8720F: this.name = "ITE IT8720F"; break; + case Chip.IT8726F: this.name = "ITE IT8726F"; break; + case Chip.W83627DHG: this.name = "Winbond W83627DHG"; break; + case Chip.W83627DHGP: this.name = "Winbond W83627DHG-P"; break; + case Chip.W83627HF: this.name = "Winbond W83627HF"; break; + } + } + + public string Identifier { + get { return "/lpc/" + chip.ToString().ToLower(); } + } + + public Image Icon { + get { return icon; } + } + + public string Name { + get { return name; } + } + } +} diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/LPC/W83627.cs --- a/Hardware/LPC/W83627.cs Sun Feb 07 19:48:32 2010 +0000 +++ b/Hardware/LPC/W83627.cs Sun Feb 07 19:53:51 2010 +0000 @@ -41,155 +41,63 @@ using System.Text; namespace OpenHardwareMonitor.Hardware.LPC { - public class W83627DHG : IHardware { - - private Chip chip; - private byte revision; - - private string name; - private Image icon; - - private bool available = false; - private ushort address; - - private List active = new List(); - + public class W83627 : Winbond, IHardware { + private Sensor[] temperatures; private Sensor[] fans; private Sensor[] voltages; private float[] voltageGains; - - // Consts - private const ushort WINBOND_VENDOR_ID = 0x5CA3; - private const byte HIGH_BYTE = 0x80; - - // Hardware Monitor - private const byte ADDRESS_REGISTER_OFFSET = 0x05; - private const byte DATA_REGISTER_OFFSET = 0x06; + private string[] fanNames; // Hardware Monitor Registers - private const byte VOLTAGE_BASE_REG = 0x20; - private const byte BANK_SELECT_REGISTER = 0x04E; - private const byte VENDOR_ID_REGISTER = 0x4F; - private const byte FIRST_BANK_REGISTER = 0x50; + private const byte VOLTAGE_BASE_REG = 0x20; private const byte TEMPERATURE_BASE_REG = 0x50; private const byte TEMPERATURE_SYS_REG = 0x27; private byte[] FAN_TACHO_REG = new byte[] { 0x28, 0x29, 0x2A, 0x3F, 0x53 }; - private byte[] FAN_TACHO_BANK = new byte[] { 0, 0, 0, 0, 5 }; - private string[] FAN_NAME = new string[] - { "System", "CPU #1", "Auxiliary #1", "CPU #2", "Auxiliary #2" }; + private byte[] FAN_TACHO_BANK = new byte[] { 0, 0, 0, 0, 5 }; private byte[] FAN_BIT_REG = new byte[] { 0x47, 0x4B, 0x4C, 0x59, 0x5D }; private byte[] FAN_DIV_BIT0 = new byte[] { 36, 38, 30, 8, 10 }; private byte[] FAN_DIV_BIT1 = new byte[] { 37, 39, 31, 9, 11 }; private byte[] FAN_DIV_BIT2 = new byte[] { 5, 6, 7, 23, 15 }; - private byte ReadByte(byte bank, byte register) { - WinRing0.WriteIoPortByte( - (ushort)(address + ADDRESS_REGISTER_OFFSET), BANK_SELECT_REGISTER); - WinRing0.WriteIoPortByte( - (ushort)(address + DATA_REGISTER_OFFSET), bank); - WinRing0.WriteIoPortByte( - (ushort)(address + ADDRESS_REGISTER_OFFSET), register); - return WinRing0.ReadIoPortByte( - (ushort)(address + DATA_REGISTER_OFFSET)); - } - - public W83627DHG(Chip chip, byte revision, ushort address) { - this.chip = chip; - this.revision = revision; - this.address = address; - - // Check vendor id - ushort vendorId = - (ushort)((ReadByte(HIGH_BYTE, VENDOR_ID_REGISTER) << 8) | - ReadByte(0, VENDOR_ID_REGISTER)); - if (vendorId != WINBOND_VENDOR_ID) - return; - - voltageGains = new float[] { 0.008f, 1, 1, 0.016f, 1, 1, 1, 0.016f }; - voltages = new Sensor[3]; - voltages[0] = new Sensor("CPU VCore", 0, SensorType.Voltage, this); - voltages[1] = new Sensor("+3.3V", 3, SensorType.Voltage, this); - voltages[2] = new Sensor("Battery", 7, SensorType.Voltage, this); - + public W83627(Chip chip, byte revision, ushort address) + : base(chip, revision, address) + { + temperatures = new Sensor[3]; temperatures[0] = new Sensor("CPU", 0, SensorType.Temperature, this); temperatures[1] = new Sensor("Auxiliary", 1, SensorType.Temperature, this); temperatures[2] = new Sensor("System", 2, SensorType.Temperature, this); - fans = new Sensor[FAN_NAME.Length]; - for (int i = 0; i < FAN_NAME.Length; i++) - fans[i] = new Sensor(FAN_NAME[i], i, SensorType.Fan, this); - switch (chip) { - case Chip.W83627DHG: name = "Winbond W83627DHG"; break; - case Chip.W83627DHGP: name = "Winbond W83627DHG-P"; break; - default: return; + case Chip.W83627DHG: + case Chip.W83627DHGP: + fanNames = new string[] { "System", "CPU #1", "Auxiliary #1", + "CPU #2", "Auxiliary #2" }; + voltageGains = new float[] { 0.008f, 1, 1, 0.016f, 1, 1, 1, 0.016f }; + voltages = new Sensor[3]; + voltages[0] = new Sensor("CPU VCore", 0, SensorType.Voltage, this); + voltages[1] = new Sensor("+3.3V", 3, SensorType.Voltage, this); + voltages[2] = new Sensor("Battery", 7, SensorType.Voltage, this); + break; + case Chip.W83627HF: + fanNames = new string[] { "Fan #1", "Fan #2", "Fan #3" }; + voltageGains = new float[] { 0.016f, 1, 0.016f, 1, 1, 1, 1, 0.016f }; + voltages = new Sensor[3]; + voltages[0] = new Sensor("CPU VCore", 0, SensorType.Voltage, this); + voltages[1] = new Sensor("+3.3V", 2, SensorType.Voltage, this); + voltages[2] = new Sensor("Battery", 7, SensorType.Voltage, this); + break; + default: fanNames = new string[0]; + break; } - - this.icon = Utilities.EmbeddedResources.GetImage("chip.png"); - available = true; - } - - public bool IsAvailable { - get { return available; } - } - - public string Name { - get { return name; } - } - - public string Identifier { - get { return "/lpc/" + chip.ToString().ToLower(); } - } - - public Image Icon { - get { return icon; } - } - - public ISensor[] Sensors { - get { return active.ToArray(); } - } - - public string GetReport() { - StringBuilder r = new StringBuilder(); - - r.AppendLine("LPC W83627DHG"); - r.AppendLine(); - r.Append("Chip ID: 0x"); r.AppendLine(chip.ToString("X")); - r.Append("Chip revision: 0x"); r.AppendLine(revision.ToString("X")); - 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 < 0x7; i++) { - r.Append(" "); r.Append((i << 4).ToString("X2")); r.Append(" "); - for (int j = 0; j <= 0xF; j++) { - r.Append(" "); - r.Append(ReadByte(0, (byte)((i << 4) | j)).ToString("X2")); - } - r.AppendLine(); - } - for (int k = 1; k <=5; k++) { - r.AppendLine("Bank " + k); - for (int i = 0x5; i < 0x6; i++) { - r.Append(" "); r.Append((i << 4).ToString("X2")); r.Append(" "); - for (int j = 0; j <= 0xF; j++) { - r.Append(" "); - r.Append(ReadByte((byte)(k), - (byte)((i << 4) | j)).ToString("X2")); - } - r.AppendLine(); - } - } - r.AppendLine(); - - return r.ToString(); - } + + fans = new Sensor[fanNames.Length]; + for (int i = 0; i < fanNames.Length; i++) + fans[i] = new Sensor(fanNames[i], i, SensorType.Fan, this); + } public void Update() { foreach (Sensor sensor in voltages) { @@ -243,24 +151,5 @@ ActivateSensor(sensor); } } - - private void ActivateSensor(Sensor sensor) { - if (!active.Contains(sensor)) { - active.Add(sensor); - if (SensorAdded != null) - SensorAdded(sensor); - } - } - - private void DeactivateSensor(Sensor sensor) { - if (active.Contains(sensor)) { - active.Remove(sensor); - if (SensorRemoved != null) - SensorRemoved(sensor); - } - } - - public event SensorEventHandler SensorAdded; - public event SensorEventHandler SensorRemoved; } } diff -r 420adf504011 -r c4d1fb76a9e1 Hardware/LPC/Winbond.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware/LPC/Winbond.cs Sun Feb 07 19:53:51 2010 +0000 @@ -0,0 +1,132 @@ +/* + + 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 abstract class Winbond : LPCHardware { + + private ushort address; + private byte revision; + + private bool available; + + // Consts + private const ushort WINBOND_VENDOR_ID = 0x5CA3; + private const byte HIGH_BYTE = 0x80; + + // Hardware Monitor + private const byte ADDRESS_REGISTER_OFFSET = 0x05; + private const byte DATA_REGISTER_OFFSET = 0x06; + + // Hardware Monitor Registers + private const byte BANK_SELECT_REGISTER = 0x04E; + private const byte VENDOR_ID_REGISTER = 0x4F; + + protected byte ReadByte(byte bank, byte register) { + WinRing0.WriteIoPortByte( + (ushort)(address + ADDRESS_REGISTER_OFFSET), BANK_SELECT_REGISTER); + WinRing0.WriteIoPortByte( + (ushort)(address + DATA_REGISTER_OFFSET), bank); + WinRing0.WriteIoPortByte( + (ushort)(address + ADDRESS_REGISTER_OFFSET), register); + return WinRing0.ReadIoPortByte( + (ushort)(address + DATA_REGISTER_OFFSET)); + } + + private bool IsWinbondVendor() { + ushort vendorId = + (ushort)((ReadByte(HIGH_BYTE, VENDOR_ID_REGISTER) << 8) | + ReadByte(0, VENDOR_ID_REGISTER)); + return vendorId == WINBOND_VENDOR_ID; + } + + public Winbond(Chip chip, byte revision, ushort address) + : base(chip) + { + this.address = address; + this.revision = revision; + + available = IsWinbondVendor(); + } + + public bool IsAvailable { + get { return available; } + } + + public string GetReport() { + StringBuilder r = new StringBuilder(); + + r.AppendLine("LPC " + this.GetType().Name); + r.AppendLine(); + r.Append("Chip ID: 0x"); r.AppendLine(chip.ToString("X")); + r.Append("Chip revision: 0x"); r.AppendLine(revision.ToString("X")); + 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 < 0x7; i++) { + r.Append(" "); r.Append((i << 4).ToString("X2")); r.Append(" "); + for (int j = 0; j <= 0xF; j++) { + r.Append(" "); + r.Append(ReadByte(0, (byte)((i << 4) | j)).ToString("X2")); + } + r.AppendLine(); + } + for (int k = 1; k <= 5; k++) { + r.AppendLine("Bank " + k); + for (int i = 0x5; i < 0x6; i++) { + r.Append(" "); r.Append((i << 4).ToString("X2")); r.Append(" "); + for (int j = 0; j <= 0xF; j++) { + r.Append(" "); + r.Append(ReadByte((byte)(k), + (byte)((i << 4) | j)).ToString("X2")); + } + r.AppendLine(); + } + } + r.AppendLine(); + + return r.ToString(); + } + } +} diff -r 420adf504011 -r c4d1fb76a9e1 OpenHardwareMonitor.csproj --- a/OpenHardwareMonitor.csproj Sun Feb 07 19:48:32 2010 +0000 +++ b/OpenHardwareMonitor.csproj Sun Feb 07 19:53:51 2010 +0000 @@ -62,13 +62,16 @@ + + + - + diff -r 420adf504011 -r c4d1fb76a9e1 Properties/AssemblyInfo.cs --- a/Properties/AssemblyInfo.cs Sun Feb 07 19:48:32 2010 +0000 +++ b/Properties/AssemblyInfo.cs Sun Feb 07 19:53:51 2010 +0000 @@ -69,5 +69,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.13.0")] -[assembly: AssemblyFileVersion("0.1.13.0")] +[assembly: AssemblyVersion("0.1.14.0")] +[assembly: AssemblyFileVersion("0.1.14.0")]