# HG changeset patch # User moel.mich # Date 1302380202 0 # Node ID 2687ac753d905e1ff3bac7aca7ad64c61e5c2029 # Parent 961c07a3bd7861f88e0b8da63f0896b92369a5a4 Added support for AMD 10h core temperature sensors and Asus ATK0110 devices on Linux. diff -r 961c07a3bd78 -r 2687ac753d90 Hardware/CPU/AMD10CPU.cs --- a/Hardware/CPU/AMD10CPU.cs Sat Mar 19 22:55:05 2011 +0000 +++ b/Hardware/CPU/AMD10CPU.cs Sat Apr 09 20:16:42 2011 +0000 @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2010 + Portions created by the Initial Developer are Copyright (C) 2009-2011 the Initial Developer. All Rights Reserved. Contributor(s): @@ -42,6 +42,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading; +using System.IO; namespace OpenHardwareMonitor.Hardware.CPU { @@ -64,6 +65,8 @@ private readonly uint miscellaneousControlAddress; private readonly ushort miscellaneousControlDeviceId; + private readonly StreamReader temperatureReader; + private double timeStampCounterMultiplier; public AMD10CPU(int processorIndex, CPUID[][] cpuid, ISettings settings) @@ -114,6 +117,25 @@ // restore the thread affinity. ThreadAffinity.Set(mask); + // the file reader for lm-sensors support on Linux + temperatureReader = null; + int p = (int)Environment.OSVersion.Platform; + if ((p == 4) || (p == 128)) { + string[] devicePaths = Directory.GetDirectories("/sys/class/hwmon/"); + foreach (string path in devicePaths) { + string name = null; + try { + using (StreamReader reader = new StreamReader(path + "/device/name")) + name = reader.ReadLine(); + } catch (IOException) { } + switch (name) { + case "k10temp": + temperatureReader = new StreamReader(path + "/device/temp1_input"); + break; + } + } + } + Update(); } @@ -196,16 +218,28 @@ public override void Update() { base.Update(); - if (miscellaneousControlAddress != Ring0.InvalidPciAddress) { - uint value; - if (Ring0.ReadPciConfig(miscellaneousControlAddress, - REPORTED_TEMPERATURE_CONTROL_REGISTER, out value)) { - coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f + - coreTemperature.Parameters[0].Value; + if (temperatureReader == null) { + if (miscellaneousControlAddress != Ring0.InvalidPciAddress) { + uint value; + if (Ring0.ReadPciConfig(miscellaneousControlAddress, + REPORTED_TEMPERATURE_CONTROL_REGISTER, out value)) { + coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f + + coreTemperature.Parameters[0].Value; + ActivateSensor(coreTemperature); + } else { + DeactivateSensor(coreTemperature); + } + } + } else { + temperatureReader.BaseStream.Seek(0, SeekOrigin.Begin); + string s = temperatureReader.ReadLine(); + try { + coreTemperature.Value = 0.001f * + long.Parse(s, CultureInfo.InvariantCulture); ActivateSensor(coreTemperature); - } else { + } catch { DeactivateSensor(coreTemperature); - } + } } if (HasTimeStampCounter) { @@ -240,5 +274,11 @@ } } } + + public override void Close() { + if (temperatureReader != null) { + temperatureReader.Close(); + } + } } } diff -r 961c07a3bd78 -r 2687ac753d90 Hardware/CPU/CPUGroup.cs --- a/Hardware/CPU/CPUGroup.cs Sat Mar 19 22:55:05 2011 +0000 +++ b/Hardware/CPU/CPUGroup.cs Sat Apr 09 20:16:42 2011 +0000 @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2010 + Portions created by the Initial Developer are Copyright (C) 2009-2011 the Initial Developer. All Rights Reserved. Contributor(s): @@ -42,8 +42,8 @@ namespace OpenHardwareMonitor.Hardware.CPU { - internal class CPUGroup : IGroup { - private readonly List hardware = new List(); + internal class CPUGroup : IGroup { + private readonly List hardware = new List(); private readonly CPUID[][][] threads; @@ -207,6 +207,10 @@ return r.ToString(); } - public void Close() { } + public void Close() { + foreach (GenericCPU cpu in hardware) { + cpu.Close(); + } + } } } diff -r 961c07a3bd78 -r 2687ac753d90 Hardware/CPU/GenericCPU.cs --- a/Hardware/CPU/GenericCPU.cs Sat Mar 19 22:55:05 2011 +0000 +++ b/Hardware/CPU/GenericCPU.cs Sat Apr 09 20:16:42 2011 +0000 @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2010 + Portions created by the Initial Developer are Copyright (C) 2010-2011 the Initial Developer. All Rights Reserved. Contributor(s): @@ -305,5 +305,9 @@ totalLoad.Value = cpuLoad.GetTotalLoad(); } } + + public virtual void Close() { + + } } } diff -r 961c07a3bd78 -r 2687ac753d90 Hardware/LPC/Chip.cs --- a/Hardware/LPC/Chip.cs Sat Mar 19 22:55:05 2011 +0000 +++ b/Hardware/LPC/Chip.cs Sat Apr 09 20:16:42 2011 +0000 @@ -39,12 +39,26 @@ internal enum Chip : ushort { Unknown = 0, + + ATK0110 = 0x0110, + + F71858 = 0x0507, + F71862 = 0x0601, + F71869 = 0x0814, + F71882 = 0x0541, + F71889ED = 0x0909, + F71889F = 0x0723, + IT8712F = 0x8712, IT8716F = 0x8716, IT8718F = 0x8718, IT8720F = 0x8720, IT8721F = 0x8721, IT8726F = 0x8726, + + NCT6771F = 0xB470, + NCT6776F = 0xC330, + W83627DHG = 0xA020, W83627DHGP = 0xB070, W83627EHF = 0x8800, @@ -52,15 +66,7 @@ W83627THF = 0x8280, W83667HG = 0xA510, W83667HGB = 0xB350, - W83687THF = 0x8541, - NCT6771F = 0xB470, - NCT6776F = 0xC330, - F71858 = 0x0507, - F71862 = 0x0601, - F71869 = 0x0814, - F71882 = 0x0541, - F71889ED = 0x0909, - F71889F = 0x0723 + W83687THF = 0x8541 } internal class ChipName { @@ -69,18 +75,25 @@ public static string GetName(Chip chip) { switch (chip) { + case Chip.ATK0110: return "Asus ATK0110"; + case Chip.F71858: return "Fintek F71858"; case Chip.F71862: return "Fintek F71862"; case Chip.F71869: return "Fintek F71869"; case Chip.F71882: return "Fintek F71882"; case Chip.F71889ED: return "Fintek F71889ED"; case Chip.F71889F: return "Fintek F71889F"; + case Chip.IT8712F: return "ITE IT8712F"; case Chip.IT8716F: return "ITE IT8716F"; case Chip.IT8718F: return "ITE IT8718F"; case Chip.IT8721F: return "ITE IT8721F"; case Chip.IT8720F: return "ITE IT8720F"; case Chip.IT8726F: return "ITE IT8726F"; + + case Chip.NCT6771F: return "Nuvoton NCT6771F"; + case Chip.NCT6776F: return "Nuvoton NCT6776F"; + case Chip.W83627DHG: return "Winbond W83627DHG"; case Chip.W83627DHGP: return "Winbond W83627DHG-P"; case Chip.W83627EHF: return "Winbond W83627EHF"; @@ -89,8 +102,7 @@ case Chip.W83667HG: return "Winbond W83667HG"; case Chip.W83667HGB: return "Winbond W83667HG-B"; case Chip.W83687THF: return "Winbond W83687THF"; - case Chip.NCT6771F: return "Nuvoton NCT6771F"; - case Chip.NCT6776F: return "Nuvoton NCT6776F"; + case Chip.Unknown: return "Unkown"; default: return "Unknown"; } diff -r 961c07a3bd78 -r 2687ac753d90 Hardware/LPC/LMSensors.cs --- a/Hardware/LPC/LMSensors.cs Sat Mar 19 22:55:05 2011 +0000 +++ b/Hardware/LPC/LMSensors.cs Sat Apr 09 20:16:42 2011 +0000 @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2010 + Portions created by the Initial Developer are Copyright (C) 2009-2011 the Initial Developer. All Rights Reserved. Contributor(s): @@ -46,44 +46,52 @@ private readonly List lmChips = new List(); public LMSensors() { - string[] devicePaths = Directory.GetDirectories("/sys/class/hwmon/"); - foreach (string path in devicePaths) { - string name = null; - try { - using (StreamReader reader = new StreamReader(path + "/device/name")) - name = reader.ReadLine(); - } catch (IOException) { } - switch (name) { - case "f71858fg": - lmChips.Add(new LMChip(Chip.F71858, path + "/device")); break; - case "f71862fg": - lmChips.Add(new LMChip(Chip.F71862, path + "/device")); break; - case "f71882fg": - lmChips.Add(new LMChip(Chip.F71882, path + "/device")); break; - case "f71889fg": - lmChips.Add(new LMChip(Chip.F71889F, path + "/device")); break; + string[] basePaths = Directory.GetDirectories("/sys/class/hwmon/"); + foreach (string basePath in basePaths) { + foreach (string devicePath in new[] { "/device", "" }) { + string path = basePath + devicePath; - case "it8712": - lmChips.Add(new LMChip(Chip.IT8712F, path + "/device")); break; - case "it8716": - lmChips.Add(new LMChip(Chip.IT8716F, path + "/device")); break; - case "it8718": - lmChips.Add(new LMChip(Chip.IT8718F, path + "/device")); break; - case "it8720": - lmChips.Add(new LMChip(Chip.IT8720F, path + "/device")); break; + string name = null; + try { + using (StreamReader reader = new StreamReader(path + "/name")) + name = reader.ReadLine(); + } catch (IOException) { } - case "w83627ehf": - lmChips.Add(new LMChip(Chip.W83627EHF, path + "/device")); break; - case "w83627dhg": - lmChips.Add(new LMChip(Chip.W83627DHG, path + "/device")); break; - case "w83667hg": - lmChips.Add(new LMChip(Chip.W83667HG, path + "/device")); break; - case "w83627hf": - lmChips.Add(new LMChip(Chip.W83627HF, path + "/device")); break; - case "w83627thf": - lmChips.Add(new LMChip(Chip.W83627THF, path + "/device")); break; - case "w83687thf": - lmChips.Add(new LMChip(Chip.W83687THF, path + "/device")); break; + switch (name) { + case "atk0110": + lmChips.Add(new LMChip(Chip.ATK0110, path)); break; + + case "f71858fg": + lmChips.Add(new LMChip(Chip.F71858, path)); break; + case "f71862fg": + lmChips.Add(new LMChip(Chip.F71862, path)); break; + case "f71882fg": + lmChips.Add(new LMChip(Chip.F71882, path)); break; + case "f71889fg": + lmChips.Add(new LMChip(Chip.F71889F, path)); break; + + case "it8712": + lmChips.Add(new LMChip(Chip.IT8712F, path)); break; + case "it8716": + lmChips.Add(new LMChip(Chip.IT8716F, path)); break; + case "it8718": + lmChips.Add(new LMChip(Chip.IT8718F, path)); break; + case "it8720": + lmChips.Add(new LMChip(Chip.IT8720F, path)); break; + + case "w83627ehf": + lmChips.Add(new LMChip(Chip.W83627EHF, path)); break; + case "w83627dhg": + lmChips.Add(new LMChip(Chip.W83627DHG, path)); break; + case "w83667hg": + lmChips.Add(new LMChip(Chip.W83667HG, path)); break; + case "w83627hf": + lmChips.Add(new LMChip(Chip.W83627HF, path)); break; + case "w83627thf": + lmChips.Add(new LMChip(Chip.W83627THF, path)); break; + case "w83687thf": + lmChips.Add(new LMChip(Chip.W83687THF, path)); break; + } } } } diff -r 961c07a3bd78 -r 2687ac753d90 Properties/AssemblyVersion.cs --- a/Properties/AssemblyVersion.cs Sat Mar 19 22:55:05 2011 +0000 +++ b/Properties/AssemblyVersion.cs Sat Apr 09 20:16:42 2011 +0000 @@ -37,5 +37,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.2.1.14")] -[assembly: AssemblyInformationalVersion("0.2.1.14 Alpha")] \ No newline at end of file +[assembly: AssemblyVersion("0.2.1.16")] +[assembly: AssemblyInformationalVersion("0.2.1.16 Alpha")] \ No newline at end of file