diff options
Diffstat (limited to 'firmware/export/ata.h')
-rw-r--r-- | firmware/export/ata.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/firmware/export/ata.h b/firmware/export/ata.h index 0bcb144e63..6f0d0b699f 100644 --- a/firmware/export/ata.h +++ b/firmware/export/ata.h | |||
@@ -25,6 +25,107 @@ | |||
25 | #include "config.h" /* for HAVE_MULTIVOLUME or not */ | 25 | #include "config.h" /* for HAVE_MULTIVOLUME or not */ |
26 | #include "mv.h" /* for IF_MV() and friends */ | 26 | #include "mv.h" /* for IF_MV() and friends */ |
27 | 27 | ||
28 | #ifdef HAVE_ATA_SMART | ||
29 | /* S.M.A.R.T. headers from smartmontools-5.42 */ | ||
30 | #define NUMBER_ATA_SMART_ATTRIBUTES 30 | ||
31 | |||
32 | struct ata_smart_attribute { | ||
33 | unsigned char id; | ||
34 | /* meaning of flag bits: see MACROS just below */ | ||
35 | /* WARNING: MISALIGNED! */ | ||
36 | unsigned short flags; | ||
37 | unsigned char current; | ||
38 | unsigned char worst; | ||
39 | unsigned char raw[6]; | ||
40 | unsigned char reserv; | ||
41 | } __attribute__((packed)); | ||
42 | |||
43 | /* MACROS to interpret the flags bits in the previous structure. */ | ||
44 | /* These have not been implemented using bitflags and a union, to make */ | ||
45 | /* it portable across bit/little endian and different platforms. */ | ||
46 | |||
47 | /* 0: Prefailure bit */ | ||
48 | |||
49 | /* From SFF 8035i Revision 2 page 19: Bit 0 (pre-failure/advisory bit) */ | ||
50 | /* - If the value of this bit equals zero, an attribute value less */ | ||
51 | /* than or equal to its corresponding attribute threshold indicates an */ | ||
52 | /* advisory condition where the usage or age of the device has */ | ||
53 | /* exceeded its intended design life period. If the value of this bit */ | ||
54 | /* equals one, an attribute value less than or equal to its */ | ||
55 | /* corresponding attribute threshold indicates a prefailure condition */ | ||
56 | /* where imminent loss of data is being predicted. */ | ||
57 | #define ATTRIBUTE_FLAGS_PREFAILURE(x) (x & 0x01) | ||
58 | |||
59 | /* 1: Online bit */ | ||
60 | |||
61 | /* From SFF 8035i Revision 2 page 19: Bit 1 (on-line data collection */ | ||
62 | /* bit) - If the value of this bit equals zero, then the attribute */ | ||
63 | /* value is updated only during off-line data collection */ | ||
64 | /* activities. If the value of this bit equals one, then the attribute */ | ||
65 | /* value is updated during normal operation of the device or during */ | ||
66 | /* both normal operation and off-line testing. */ | ||
67 | #define ATTRIBUTE_FLAGS_ONLINE(x) (x & 0x02) | ||
68 | |||
69 | /* The following are (probably) IBM's, Maxtors and Quantum's definitions for the */ | ||
70 | /* vendor-specific bits: */ | ||
71 | /* 2: Performance type bit */ | ||
72 | #define ATTRIBUTE_FLAGS_PERFORMANCE(x) (x & 0x04) | ||
73 | |||
74 | /* 3: Errorrate type bit */ | ||
75 | #define ATTRIBUTE_FLAGS_ERRORRATE(x) (x & 0x08) | ||
76 | |||
77 | /* 4: Eventcount bit */ | ||
78 | #define ATTRIBUTE_FLAGS_EVENTCOUNT(x) (x & 0x10) | ||
79 | |||
80 | /* 5: Selfpereserving bit */ | ||
81 | #define ATTRIBUTE_FLAGS_SELFPRESERVING(x) (x & 0x20) | ||
82 | |||
83 | /* 6-15: Reserved for future use */ | ||
84 | #define ATTRIBUTE_FLAGS_OTHER(x) ((x) & 0xffc0) | ||
85 | |||
86 | struct ata_smart_values | ||
87 | { | ||
88 | unsigned short int revnumber; | ||
89 | struct ata_smart_attribute vendor_attributes [NUMBER_ATA_SMART_ATTRIBUTES]; | ||
90 | unsigned char offline_data_collection_status; | ||
91 | unsigned char self_test_exec_status; | ||
92 | unsigned short int total_time_to_complete_off_line; | ||
93 | unsigned char vendor_specific_366; | ||
94 | unsigned char offline_data_collection_capability; | ||
95 | unsigned short int smart_capability; | ||
96 | unsigned char errorlog_capability; | ||
97 | unsigned char vendor_specific_371; | ||
98 | unsigned char short_test_completion_time; | ||
99 | unsigned char extend_test_completion_time; | ||
100 | unsigned char conveyance_test_completion_time; | ||
101 | unsigned char reserved_375_385[11]; | ||
102 | unsigned char vendor_specific_386_510[125]; | ||
103 | unsigned char chksum; | ||
104 | } __attribute__((packed)); | ||
105 | |||
106 | /* Raw attribute value print formats */ | ||
107 | enum ata_attr_raw_format | ||
108 | { | ||
109 | RAWFMT_DEFAULT, | ||
110 | RAWFMT_RAW8, | ||
111 | RAWFMT_RAW16, | ||
112 | RAWFMT_RAW48, | ||
113 | RAWFMT_HEX48, | ||
114 | RAWFMT_RAW64, | ||
115 | RAWFMT_HEX64, | ||
116 | RAWFMT_RAW16_OPT_RAW16, | ||
117 | RAWFMT_RAW16_OPT_AVG16, | ||
118 | RAWFMT_RAW24_DIV_RAW24, | ||
119 | RAWFMT_RAW24_DIV_RAW32, | ||
120 | RAWFMT_SEC2HOUR, | ||
121 | RAWFMT_MIN2HOUR, | ||
122 | RAWFMT_HALFMIN2HOUR, | ||
123 | RAWFMT_MSEC24_HOUR32, | ||
124 | RAWFMT_TEMPMINMAX, | ||
125 | RAWFMT_TEMP10X, | ||
126 | }; | ||
127 | #endif /* HAVE_ATA_SMART */ | ||
128 | |||
28 | struct storage_info; | 129 | struct storage_info; |
29 | 130 | ||
30 | void ata_enable(bool on); | 131 | void ata_enable(bool on); |
@@ -69,4 +170,9 @@ int ata_spinup_time(void); /* ticks */ | |||
69 | int ata_get_dma_mode(void); | 170 | int ata_get_dma_mode(void); |
70 | #endif /* HAVE_ATA_DMA */ | 171 | #endif /* HAVE_ATA_DMA */ |
71 | 172 | ||
173 | #ifdef HAVE_ATA_SMART | ||
174 | /* Returns current S.M.A.R.T. data */ | ||
175 | void* ata_read_smart(void); | ||
176 | #endif | ||
177 | |||
72 | #endif /* __ATA_H__ */ | 178 | #endif /* __ATA_H__ */ |