moel@324
|
1 |
/*
|
moel@324
|
2 |
|
moel@344
|
3 |
This Source Code Form is subject to the terms of the Mozilla Public
|
moel@344
|
4 |
License, v. 2.0. If a copy of the MPL was not distributed with this
|
moel@344
|
5 |
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
moel@324
|
6 |
|
moel@344
|
7 |
Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
|
moel@344
|
8 |
Copyright (C) 2010 Paul Werelds
|
moel@344
|
9 |
|
moel@324
|
10 |
*/
|
moel@324
|
11 |
|
moel@324
|
12 |
namespace OpenHardwareMonitor.Hardware.HDD {
|
moel@324
|
13 |
using System.Collections.Generic;
|
moel@324
|
14 |
|
moel@338
|
15 |
[NamePrefix(""), RequireSmart(0xAB), RequireSmart(0xB1)]
|
moel@324
|
16 |
internal class SSDSandforce : AbstractHarddrive {
|
moel@324
|
17 |
|
moel@324
|
18 |
private static readonly IEnumerable<SmartAttribute> smartAttributes =
|
moel@324
|
19 |
new List<SmartAttribute> {
|
moel@339
|
20 |
new SmartAttribute(0x01, SmartNames.RawReadErrorRate),
|
moel@339
|
21 |
new SmartAttribute(0x05, SmartNames.RetiredBlockCount, RawToInt),
|
moel@328
|
22 |
new SmartAttribute(0x09, SmartNames.PowerOnHours, RawToInt),
|
moel@328
|
23 |
new SmartAttribute(0x0C, SmartNames.PowerCycleCount, RawToInt),
|
moel@339
|
24 |
new SmartAttribute(0xAB, SmartNames.ProgramFailCount, RawToInt),
|
moel@339
|
25 |
new SmartAttribute(0xAC, SmartNames.EraseFailCount, RawToInt),
|
moel@339
|
26 |
new SmartAttribute(0xAE, SmartNames.UnexpectedPowerLossCount, RawToInt),
|
moel@339
|
27 |
new SmartAttribute(0xB1, SmartNames.WearRangeDelta, RawToInt),
|
moel@339
|
28 |
new SmartAttribute(0xB5, SmartNames.AlternativeProgramFailCount, RawToInt),
|
moel@339
|
29 |
new SmartAttribute(0xB6, SmartNames.AlternativeEraseFailCount, RawToInt),
|
moel@339
|
30 |
new SmartAttribute(0xBB, SmartNames.UncorrectableErrorCount, RawToInt),
|
moel@340
|
31 |
new SmartAttribute(0xC2, SmartNames.Temperature, (byte[] raw, byte value)
|
moel@340
|
32 |
=> { return value; }, SensorType.Temperature, 0, true),
|
moel@328
|
33 |
new SmartAttribute(0xC3, SmartNames.UnrecoverableEcc),
|
moel@339
|
34 |
new SmartAttribute(0xC4, SmartNames.ReallocationEventCount, RawToInt),
|
moel@339
|
35 |
new SmartAttribute(0xE7, SmartNames.RemainingLife, null,
|
moel@339
|
36 |
SensorType.Level, 0),
|
moel@339
|
37 |
new SmartAttribute(0xE9, SmartNames.ControllerWritesToNAND, RawToInt,
|
moel@324
|
38 |
SensorType.Data, 0),
|
moel@339
|
39 |
new SmartAttribute(0xEA, SmartNames.HostWritesToController, RawToInt,
|
moel@339
|
40 |
SensorType.Data, 1),
|
moel@339
|
41 |
new SmartAttribute(0xF1, SmartNames.HostWrites, RawToInt,
|
moel@339
|
42 |
SensorType.Data, 1),
|
moel@339
|
43 |
new SmartAttribute(0xF2, SmartNames.HostReads, RawToInt,
|
moel@339
|
44 |
SensorType.Data, 2)
|
moel@324
|
45 |
};
|
moel@324
|
46 |
|
moel@339
|
47 |
private Sensor writeAmplification;
|
moel@339
|
48 |
|
moel@325
|
49 |
public SSDSandforce(ISmart smart, string name, string firmwareRevision,
|
moel@325
|
50 |
int index, ISettings settings)
|
moel@325
|
51 |
: base(smart, name, firmwareRevision, index, smartAttributes, settings)
|
moel@339
|
52 |
{
|
moel@339
|
53 |
this.writeAmplification = new Sensor("Write Amplification", 1,
|
moel@340
|
54 |
SensorType.Factor, this, settings);
|
moel@339
|
55 |
}
|
moel@339
|
56 |
|
moel@339
|
57 |
public override void UpdateAdditionalSensors(DriveAttributeValue[] values) {
|
moel@339
|
58 |
float? controllerWritesToNAND = null;
|
moel@339
|
59 |
float? hostWritesToController = null;
|
moel@339
|
60 |
foreach (DriveAttributeValue value in values) {
|
moel@339
|
61 |
if (value.Identifier == 0xE9)
|
moel@339
|
62 |
controllerWritesToNAND = RawToInt(value.RawValue, value.AttrValue);
|
moel@339
|
63 |
|
moel@339
|
64 |
if (value.Identifier == 0xEA)
|
moel@339
|
65 |
hostWritesToController = RawToInt(value.RawValue, value.AttrValue);
|
moel@339
|
66 |
}
|
moel@339
|
67 |
if (controllerWritesToNAND.HasValue && hostWritesToController.HasValue) {
|
moel@343
|
68 |
if (hostWritesToController.Value > 0)
|
moel@343
|
69 |
writeAmplification.Value =
|
moel@343
|
70 |
controllerWritesToNAND.Value / hostWritesToController.Value;
|
moel@343
|
71 |
else
|
moel@343
|
72 |
writeAmplification.Value = 0;
|
moel@339
|
73 |
ActivateSensor(writeAmplification);
|
moel@339
|
74 |
}
|
moel@339
|
75 |
}
|
moel@324
|
76 |
}
|
moel@324
|
77 |
}
|