1 #ifndef DEVICES_SMART_H
2 #define DEVICES_SMART_H
6 ** $VER: smart.h 1.1 (24.02.2019)
8 ** S.M.A.R.T. definitions (V1)
14 /* SMART ATA sub-commands */
15 /* (passed in io_Reserved1 && io_Reserved2) */
16 # define SMARTC_TEST_AVAIL ATAFEATURE_TEST_AVAIL
18 #define SMARTC_READ_VALUES 0xD0
19 #define SMARTC_READ_THRESHOLDS 0xD1
20 #define SMARTC_AUTOSAVE 0xD2
21 #define SMARTC_SAVE 0xD3
22 #define SMARTC_IMMEDIATE_OFFLINE 0xD4
23 #define SMARTC_READ_LOG_SECTOR 0xD5
24 #define SMARTC_WRITE_LOG_SECTOR 0xD6
25 #define SMARTC_WRITE_THRESHOLDS 0xD7
26 #define SMARTC_ENABLE 0xD8
27 #define SMARTC_DISABLE 0xD9
28 #define SMARTC_STATUS 0xDA
29 #define SMARTC_AUTO_OFFLINE 0xDB
31 /* Legacy attributes */
32 #define SMARTA_RAW_READ_ERROR_RATE 0x01
33 #define SMARTA_THROUGHPUT_PERFORMANCE 0x02
34 #define SMARTA_SPINUP_TIME 0x03
35 #define SMARTA_START_STOP_COUNT 0x04
36 #define SMARTA_REALLOCATED_SECTOR_COUNT 0x05
37 #define SMARTA_READ_CHANNEL_MARGIN 0x06
38 #define SMARTA_SEEK_ERROR_RATE 0x07
39 #define SMARTA_SEEK_TIMER_PERFORMANCE 0x08
40 #define SMARTA_POWERON_HOURS_COUNT 0x09
41 #define SMARTA_SPINUP_RETRY_COUNT 0x0A
42 #define SMARTA_CALIBRATION_RETRY_COUNT 0x0B
43 #define SMARTA_POWER_CYCLE_COUNT 0x0C
44 #define SMARTA_SOFT_READ_ERROR_RATE 0x0D
45 #define SMARTA_G_SENSE_ERROR_RATE 0xBF
46 #define SMARTA_POWEROFF_RETRACT_COUNT 0xC0
47 #define SMARTA_LOAD_UNLOAD_CYCLE_COUNT 0xC1
48 #define SMARTA_HDA_TEMPERATURE 0xC2
49 #define SMARTA_HARDWARE_ECC_RECOVERED 0xC3
50 #define SMARTA_REALLOCATION_COUNT 0xC4
51 #define SMARTA_CURRENT_PENDING_SECTOR_COUNT 0xC5
52 #define SMARTA_OFFLINE_SCAN_UNCORRECTABLE_COUNT 0xC6
53 #define SMARTA_UDMA_CRC_ERROR_RATE 0xC7
54 #define SMARTA_WRITE_ERROR_RATE 0xC8
55 #define SMARTA_SOFT_READ_ERROR_RATE_2 0xC9
56 #define SMARTA_DATA_ADDRESS_MARK_ERRORS 0xCa
57 #define SMARTA_RUN_OUT_CANCEL 0xCB
58 #define SMARTA_SOFT_ECC_CORRECTION 0xCC
59 #define SMARTA_THERMAL_ASPERITY_RATE 0xCD
60 #define SMARTA_FLYING_HEIGHT 0xCE
61 #define SMARTA_SPIN_HIGH_CURRENT 0xCF
62 #define SMARTA_SPIN_BUZZ 0xD0
63 #define SMARTA_OFFLINE_SEEK_PERFORMANCE 0xD1
64 #define SMARTA_DISK_SHIFT 0xDC
65 #define SMARTA_G_SENSE_ERROR_RATE_2 0xDD
66 #define SMARTA_LOADED_HOURS 0xDE
67 #define SMARTA_LOAD_UNLOAD_RETRY_COUNT 0xDF
68 #define SMARTA_LOAD_FRICTION 0xE0
69 #define SMARTA_LOAD_UNLOAD_CYCLE_COUNT_2 0xE1
70 #define SMARTA_LOAD_IN_TIME 0xE2
71 #define SMARTA_TORQUE_AMPLIFICATION_COUNT 0xE3
72 #define SMARTA_POWER_OFF_RETRACT_COUNT 0xE4
73 #define SMARTA_GMR_HEAD_AMPLITUDE 0xE6
74 #define SMARTA_TEMPERATURE 0xE7
75 #define SMARTA_HEAD_FLYING_HOURS 0xF0
76 #define SMARTA_READ_ERROR_RETRY_RATE 0xFA
79 #define SMARTF_PREFAILURE 0x01
80 #define SMARTF_ONLINE 0x02
82 #define SMARTF_PERFORMANCE 0x04
83 #define SMARTF_ERRORRATE 0x08
84 #define SMARTF_EVENTCOUNT 0x10
85 #define SMARTF_SELFPRESERVING 0x20
86 #define SMARTF_OTHER 0xffc0
88 /* struct SMARTAttributes and SMARTThresholds */
89 #define SMART_DATA_LENGTH 512
91 /* Maximum entries in the table */
92 #define SMART_MAX_ATTRIBUTES 30
94 /* Validate an attribute-id */
95 #define SMART_ATTRIBUTE_ID_VALID(id) ((id)>0 && (id)<0xFF)
97 struct SMARTAttributeEntry
105 } __attribute__((packed
));
107 struct SMARTThresholdEntry
111 UBYTE ste_Reserved
[10];
112 } __attribute__((packed
));
114 /* The following structures are 512 bytes each */
115 struct SMARTAttributes
118 struct SMARTAttributeEntry sa_Attribute
[SMART_MAX_ATTRIBUTES
];
119 UBYTE sa_Reserved
[6];
121 UBYTE sa_Reserved2
[16];
122 UBYTE sa_VendorSpecific
[125];
124 } __attribute__((packed
));
126 struct SMARTThresholds
129 struct SMARTThresholdEntry st_Threshold
[SMART_MAX_ATTRIBUTES
];
130 UBYTE st_Reserved
[18];
131 UBYTE st_VendorSpecific
[131];
133 } __attribute__((packed
));
135 #endif /* DEVICES_SMART_H */