Added support for SSDs with a controller from Micron.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
11 using System.Collections.Generic;
12 using System.Globalization;
16 namespace OpenHardwareMonitor.Hardware.LPC {
18 internal class LMSensors {
20 private readonly List<LMChip> lmChips = new List<LMChip>();
23 string[] basePaths = Directory.GetDirectories("/sys/class/hwmon/");
24 foreach (string basePath in basePaths) {
25 foreach (string devicePath in new[] { "/device", "" }) {
26 string path = basePath + devicePath;
30 using (StreamReader reader = new StreamReader(path + "/name"))
31 name = reader.ReadLine();
32 } catch (IOException) { }
36 lmChips.Add(new LMChip(Chip.ATK0110, path)); break;
39 lmChips.Add(new LMChip(Chip.F71858, path)); break;
41 lmChips.Add(new LMChip(Chip.F71862, path)); break;
43 lmChips.Add(new LMChip(Chip.F71882, path)); break;
45 lmChips.Add(new LMChip(Chip.F71889F, path)); break;
48 lmChips.Add(new LMChip(Chip.IT8705F, path)); break;
50 lmChips.Add(new LMChip(Chip.IT8712F, path)); break;
52 lmChips.Add(new LMChip(Chip.IT8716F, path)); break;
54 lmChips.Add(new LMChip(Chip.IT8718F, path)); break;
56 lmChips.Add(new LMChip(Chip.IT8720F, path)); break;
59 lmChips.Add(new LMChip(Chip.W83627EHF, path)); break;
61 lmChips.Add(new LMChip(Chip.W83627DHG, path)); break;
63 lmChips.Add(new LMChip(Chip.W83667HG, path)); break;
65 lmChips.Add(new LMChip(Chip.W83627HF, path)); break;
67 lmChips.Add(new LMChip(Chip.W83627THF, path)); break;
69 lmChips.Add(new LMChip(Chip.W83687THF, path)); break;
76 foreach (LMChip lmChip in lmChips)
80 public ISuperIO[] SuperIO {
82 return lmChips.ToArray();
86 private class LMChip : ISuperIO {
89 private readonly Chip chip;
91 private readonly float?[] voltages;
92 private readonly float?[] temperatures;
93 private readonly float?[] fans;
94 private readonly float?[] controls;
96 private readonly FileStream[] voltageStreams;
97 private readonly FileStream[] temperatureStreams;
98 private readonly FileStream[] fanStreams;
100 public Chip Chip { get { return chip; } }
101 public float?[] Voltages { get { return voltages; } }
102 public float?[] Temperatures { get { return temperatures; } }
103 public float?[] Fans { get { return fans; } }
104 public float?[] Controls { get { return controls; } }
106 public LMChip(Chip chip, string path) {
110 string[] voltagePaths = Directory.GetFiles(path, "in*_input");
111 this.voltages = new float?[voltagePaths.Length];
112 this.voltageStreams = new FileStream[voltagePaths.Length];
113 for (int i = 0; i < voltagePaths.Length; i++)
114 voltageStreams[i] = new FileStream(voltagePaths[i],
115 FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
117 string[] temperaturePaths = Directory.GetFiles(path, "temp*_input");
118 this.temperatures = new float?[temperaturePaths.Length];
119 this.temperatureStreams = new FileStream[temperaturePaths.Length];
120 for (int i = 0; i < temperaturePaths.Length; i++)
121 temperatureStreams[i] = new FileStream(temperaturePaths[i],
122 FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
124 string[] fanPaths = Directory.GetFiles(path, "fan*_input");
125 this.fans = new float?[fanPaths.Length];
126 this.fanStreams = new FileStream[fanPaths.Length];
127 for (int i = 0; i < fanPaths.Length; i++)
128 fanStreams[i] = new FileStream(fanPaths[i],
129 FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
131 this.controls = new float?[0];
134 public byte? ReadGPIO(int index) {
138 public void WriteGPIO(int index, byte value) { }
140 public string GetReport() {
144 public void SetControl(int index, byte? value) { }
146 private string ReadFirstLine(Stream stream) {
147 StringBuilder sb = new StringBuilder();
149 stream.Seek(0, SeekOrigin.Begin);
150 int b = stream.ReadByte();
151 while (b != -1 && b != 10) {
153 b = stream.ReadByte();
156 return sb.ToString();
159 public void Update() {
160 for (int i = 0; i < voltages.Length; i++) {
161 string s = ReadFirstLine(voltageStreams[i]);
163 voltages[i] = 0.001f *
164 long.Parse(s, CultureInfo.InvariantCulture);
170 for (int i = 0; i < temperatures.Length; i++) {
171 string s = ReadFirstLine(temperatureStreams[i]);
173 temperatures[i] = 0.001f *
174 long.Parse(s, CultureInfo.InvariantCulture);
176 temperatures[i] = null;
180 for (int i = 0; i < fans.Length; i++) {
181 string s = ReadFirstLine(fanStreams[i]);
183 fans[i] = long.Parse(s, CultureInfo.InvariantCulture);
190 public void Close() {
191 foreach (FileStream stream in voltageStreams)
193 foreach (FileStream stream in temperatureStreams)
195 foreach (FileStream stream in fanStreams)