]>
Commit | Line | Data |
---|---|---|
832b75ed GG |
1 | /* |
2 | * atacmds.h | |
3 | * | |
4 | * Home page of code is: http://smartmontools.sourceforge.net | |
5 | * | |
6 | * Copyright (C) 2002-6 Bruce Allen <smartmontools-support@lists.sourceforge.net> | |
7 | * Copyright (C) 1999-2000 Michael Cornwell <cornwell@acm.org> | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2, or (at your option) | |
12 | * any later version. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * (for example COPYING); if not, write to the Free | |
16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
17 | * | |
18 | * This code was originally developed as a Senior Thesis by Michael Cornwell | |
19 | * at the Concurrent Systems Laboratory (now part of the Storage Systems | |
20 | * Research Center), Jack Baskin School of Engineering, University of | |
21 | * California, Santa Cruz. http://ssrc.soe.ucsc.edu/ | |
22 | * | |
23 | */ | |
24 | ||
25 | #ifndef ATACMDS_H_ | |
26 | #define ATACMDS_H_ | |
27 | ||
28 | #define ATACMDS_H_CVSID "$Id: atacmds.h,v 1.81 2006/04/12 14:54:28 ballen4705 Exp $\n" | |
29 | ||
30 | // Macro to check expected size of struct at compile time using a | |
31 | // dummy typedef. On size mismatch, compiler reports a negative array | |
32 | // size. If you see an error message of this form, it means that the | |
33 | // #pragma pack(1) pragma below is not having the desired effect on | |
34 | // your compiler. | |
35 | #define ASSERT_SIZEOF_STRUCT(s, n) \ | |
36 | typedef char assert_sizeof_struct_##s[(sizeof(struct s) == (n)) ? 1 : -1] | |
37 | ||
38 | // Add __attribute__((packed)) if compiler supports it | |
39 | // because some gcc versions (at least ARM) lack support of #pragma pack() | |
40 | #ifdef HAVE_ATTR_PACKED | |
41 | #define ATTR_PACKED __attribute__((packed)) | |
42 | #else | |
43 | #define ATTR_PACKED | |
44 | #endif | |
45 | ||
46 | typedef enum { | |
47 | // returns no data, just succeeds or fails | |
48 | ENABLE, | |
49 | DISABLE, | |
50 | AUTOSAVE, | |
51 | IMMEDIATE_OFFLINE, | |
52 | AUTO_OFFLINE, | |
53 | STATUS, // just says if SMART is working or not | |
54 | STATUS_CHECK, // says if disk's SMART status is healthy, or failing | |
55 | // return 512 bytes of data: | |
56 | READ_VALUES, | |
57 | READ_THRESHOLDS, | |
58 | READ_LOG, | |
59 | IDENTIFY, | |
60 | PIDENTIFY, | |
61 | // returns 1 byte of data | |
62 | CHECK_POWER_MODE, | |
63 | // writes 512 bytes of data: | |
64 | WRITE_LOG | |
65 | } smart_command_set; | |
66 | ||
67 | // ATA Specification Command Register Values (Commands) | |
68 | #define ATA_IDENTIFY_DEVICE 0xec | |
69 | #define ATA_IDENTIFY_PACKET_DEVICE 0xa1 | |
70 | #define ATA_SMART_CMD 0xb0 | |
71 | #define ATA_CHECK_POWER_MODE 0xe5 | |
72 | ||
73 | // ATA Specification Feature Register Values (SMART Subcommands). | |
74 | // Note that some are obsolete as of ATA-7. | |
75 | #define ATA_SMART_READ_VALUES 0xd0 | |
76 | #define ATA_SMART_READ_THRESHOLDS 0xd1 | |
77 | #define ATA_SMART_AUTOSAVE 0xd2 | |
78 | #define ATA_SMART_SAVE 0xd3 | |
79 | #define ATA_SMART_IMMEDIATE_OFFLINE 0xd4 | |
80 | #define ATA_SMART_READ_LOG_SECTOR 0xd5 | |
81 | #define ATA_SMART_WRITE_LOG_SECTOR 0xd6 | |
82 | #define ATA_SMART_WRITE_THRESHOLDS 0xd7 | |
83 | #define ATA_SMART_ENABLE 0xd8 | |
84 | #define ATA_SMART_DISABLE 0xd9 | |
85 | #define ATA_SMART_STATUS 0xda | |
86 | // SFF 8035i Revision 2 Specification Feature Register Value (SMART | |
87 | // Subcommand) | |
88 | #define ATA_SMART_AUTO_OFFLINE 0xdb | |
89 | ||
90 | // Sector Number values for ATA_SMART_IMMEDIATE_OFFLINE Subcommand | |
91 | #define OFFLINE_FULL_SCAN 0 | |
92 | #define SHORT_SELF_TEST 1 | |
93 | #define EXTEND_SELF_TEST 2 | |
94 | #define CONVEYANCE_SELF_TEST 3 | |
95 | #define SELECTIVE_SELF_TEST 4 | |
96 | #define ABORT_SELF_TEST 127 | |
97 | #define SHORT_CAPTIVE_SELF_TEST 129 | |
98 | #define EXTEND_CAPTIVE_SELF_TEST 130 | |
99 | #define CONVEYANCE_CAPTIVE_SELF_TEST 131 | |
100 | #define SELECTIVE_CAPTIVE_SELF_TEST 132 | |
101 | #define CAPTIVE_MASK (0x01<<7) | |
102 | ||
103 | // Maximum allowed number of SMART Attributes | |
104 | #define NUMBER_ATA_SMART_ATTRIBUTES 30 | |
105 | ||
106 | // Needed parts of the ATA DRIVE IDENTIFY Structure. Those labeled | |
107 | // word* are NOT used. | |
108 | #pragma pack(1) | |
109 | struct ata_identify_device { | |
110 | unsigned short words000_009[10]; | |
111 | unsigned char serial_no[20]; | |
112 | unsigned short words020_022[3]; | |
113 | unsigned char fw_rev[8]; | |
114 | unsigned char model[40]; | |
115 | unsigned short words047_079[33]; | |
116 | unsigned short major_rev_num; | |
117 | unsigned short minor_rev_num; | |
118 | unsigned short command_set_1; | |
119 | unsigned short command_set_2; | |
120 | unsigned short command_set_extension; | |
121 | unsigned short cfs_enable_1; | |
122 | unsigned short word086; | |
123 | unsigned short csf_default; | |
124 | unsigned short words088_255[168]; | |
125 | } ATTR_PACKED; | |
126 | #pragma pack() | |
127 | ASSERT_SIZEOF_STRUCT(ata_identify_device, 512); | |
128 | ||
129 | /* ata_smart_attribute is the vendor specific in SFF-8035 spec */ | |
130 | #pragma pack(1) | |
131 | struct ata_smart_attribute { | |
132 | unsigned char id; | |
133 | // meaning of flag bits: see MACROS just below | |
134 | // WARNING: MISALIGNED! | |
135 | unsigned short flags; | |
136 | unsigned char current; | |
137 | unsigned char worst; | |
138 | unsigned char raw[6]; | |
139 | unsigned char reserv; | |
140 | } ATTR_PACKED; | |
141 | #pragma pack() | |
142 | ASSERT_SIZEOF_STRUCT(ata_smart_attribute, 12); | |
143 | ||
144 | // MACROS to interpret the flags bits in the previous structure. | |
145 | // These have not been implemented using bitflags and a union, to make | |
146 | // it portable across bit/little endian and different platforms. | |
147 | ||
148 | // 0: Prefailure bit | |
149 | ||
150 | // From SFF 8035i Revision 2 page 19: Bit 0 (pre-failure/advisory bit) | |
151 | // - If the value of this bit equals zero, an attribute value less | |
152 | // than or equal to its corresponding attribute threshold indicates an | |
153 | // advisory condition where the usage or age of the device has | |
154 | // exceeded its intended design life period. If the value of this bit | |
155 | // equals one, an attribute value less than or equal to its | |
156 | // corresponding attribute threshold indicates a prefailure condition | |
157 | // where imminent loss of data is being predicted. | |
158 | #define ATTRIBUTE_FLAGS_PREFAILURE(x) (x & 0x01) | |
159 | ||
160 | // 1: Online bit | |
161 | ||
162 | // From SFF 8035i Revision 2 page 19: Bit 1 (on-line data collection | |
163 | // bit) - If the value of this bit equals zero, then the attribute | |
164 | // value is updated only during off-line data collection | |
165 | // activities. If the value of this bit equals one, then the attribute | |
166 | // value is updated during normal operation of the device or during | |
167 | // both normal operation and off-line testing. | |
168 | #define ATTRIBUTE_FLAGS_ONLINE(x) (x & 0x02) | |
169 | ||
170 | ||
171 | // The following are (probably) IBM's, Maxtors and Quantum's definitions for the | |
172 | // vendor-specific bits: | |
173 | // 2: Performance type bit | |
174 | #define ATTRIBUTE_FLAGS_PERFORMANCE(x) (x & 0x04) | |
175 | ||
176 | // 3: Errorrate type bit | |
177 | #define ATTRIBUTE_FLAGS_ERRORRATE(x) (x & 0x08) | |
178 | ||
179 | // 4: Eventcount bit | |
180 | #define ATTRIBUTE_FLAGS_EVENTCOUNT(x) (x & 0x10) | |
181 | ||
182 | // 5: Selfpereserving bit | |
183 | #define ATTRIBUTE_FLAGS_SELFPRESERVING(x) (x & 0x20) | |
184 | ||
185 | ||
186 | // Last ten bits are reserved for future use | |
187 | ||
188 | /* ata_smart_values is format of the read drive Attribute command */ | |
189 | /* see Table 34 of T13/1321D Rev 1 spec (Device SMART data structure) for *some* info */ | |
190 | #pragma pack(1) | |
191 | struct ata_smart_values { | |
192 | unsigned short int revnumber; | |
193 | struct ata_smart_attribute vendor_attributes [NUMBER_ATA_SMART_ATTRIBUTES]; | |
194 | unsigned char offline_data_collection_status; | |
195 | unsigned char self_test_exec_status; //IBM # segments for offline collection | |
196 | unsigned short int total_time_to_complete_off_line; // IBM different | |
197 | unsigned char vendor_specific_366; // Maxtor & IBM curent segment pointer | |
198 | unsigned char offline_data_collection_capability; | |
199 | unsigned short int smart_capability; | |
200 | unsigned char errorlog_capability; | |
201 | unsigned char vendor_specific_371; // Maxtor, IBM: self-test failure checkpoint see below! | |
202 | unsigned char short_test_completion_time; | |
203 | unsigned char extend_test_completion_time; | |
204 | unsigned char conveyance_test_completion_time; | |
205 | unsigned char reserved_375_385[11]; | |
206 | unsigned char vendor_specific_386_510[125]; // Maxtor bytes 508-509 Attribute/Threshold Revision # | |
207 | unsigned char chksum; | |
208 | } ATTR_PACKED; | |
209 | #pragma pack() | |
210 | ASSERT_SIZEOF_STRUCT(ata_smart_values, 512); | |
211 | ||
212 | /* Maxtor, IBM: self-test failure checkpoint byte meaning: | |
213 | 00 - write test | |
214 | 01 - servo basic | |
215 | 02 - servo random | |
216 | 03 - G-list scan | |
217 | 04 - Handling damage | |
218 | 05 - Read scan | |
219 | */ | |
220 | ||
221 | /* Vendor attribute of SMART Threshold (compare to ata_smart_attribute above) */ | |
222 | #pragma pack(1) | |
223 | struct ata_smart_threshold_entry { | |
224 | unsigned char id; | |
225 | unsigned char threshold; | |
226 | unsigned char reserved[10]; | |
227 | } ATTR_PACKED; | |
228 | #pragma pack() | |
229 | ASSERT_SIZEOF_STRUCT(ata_smart_threshold_entry, 12); | |
230 | ||
231 | /* Format of Read SMART THreshold Command */ | |
232 | /* Compare to ata_smart_values above */ | |
233 | #pragma pack(1) | |
234 | struct ata_smart_thresholds_pvt { | |
235 | unsigned short int revnumber; | |
236 | struct ata_smart_threshold_entry thres_entries[NUMBER_ATA_SMART_ATTRIBUTES]; | |
237 | unsigned char reserved[149]; | |
238 | unsigned char chksum; | |
239 | } ATTR_PACKED; | |
240 | #pragma pack() | |
241 | ASSERT_SIZEOF_STRUCT(ata_smart_thresholds_pvt, 512); | |
242 | ||
243 | ||
244 | // Table 42 of T13/1321D Rev 1 spec (Error Data Structure) | |
245 | #pragma pack(1) | |
246 | struct ata_smart_errorlog_error_struct { | |
247 | unsigned char reserved; | |
248 | unsigned char error_register; | |
249 | unsigned char sector_count; | |
250 | unsigned char sector_number; | |
251 | unsigned char cylinder_low; | |
252 | unsigned char cylinder_high; | |
253 | unsigned char drive_head; | |
254 | unsigned char status; | |
255 | unsigned char extended_error[19]; | |
256 | unsigned char state; | |
257 | unsigned short timestamp; | |
258 | } ATTR_PACKED; | |
259 | #pragma pack() | |
260 | ASSERT_SIZEOF_STRUCT(ata_smart_errorlog_error_struct, 30); | |
261 | ||
262 | ||
263 | // Table 41 of T13/1321D Rev 1 spec (Command Data Structure) | |
264 | #pragma pack(1) | |
265 | struct ata_smart_errorlog_command_struct { | |
266 | unsigned char devicecontrolreg; | |
267 | unsigned char featuresreg; | |
268 | unsigned char sector_count; | |
269 | unsigned char sector_number; | |
270 | unsigned char cylinder_low; | |
271 | unsigned char cylinder_high; | |
272 | unsigned char drive_head; | |
273 | unsigned char commandreg; | |
274 | unsigned int timestamp; | |
275 | } ATTR_PACKED; | |
276 | #pragma pack() | |
277 | ASSERT_SIZEOF_STRUCT(ata_smart_errorlog_command_struct, 12); | |
278 | ||
279 | // Table 40 of T13/1321D Rev 1 spec (Error log data structure) | |
280 | #pragma pack(1) | |
281 | struct ata_smart_errorlog_struct { | |
282 | struct ata_smart_errorlog_command_struct commands[5]; | |
283 | struct ata_smart_errorlog_error_struct error_struct; | |
284 | } ATTR_PACKED; | |
285 | #pragma pack() | |
286 | ASSERT_SIZEOF_STRUCT(ata_smart_errorlog_struct, 90); | |
287 | ||
288 | // Table 39 of T13/1321D Rev 1 spec (SMART error log sector) | |
289 | #pragma pack(1) | |
290 | struct ata_smart_errorlog { | |
291 | unsigned char revnumber; | |
292 | unsigned char error_log_pointer; | |
293 | struct ata_smart_errorlog_struct errorlog_struct[5]; | |
294 | unsigned short int ata_error_count; | |
295 | unsigned char reserved[57]; | |
296 | unsigned char checksum; | |
297 | } ATTR_PACKED; | |
298 | #pragma pack() | |
299 | ASSERT_SIZEOF_STRUCT(ata_smart_errorlog, 512); | |
300 | ||
301 | // Table 45 of T13/1321D Rev 1 spec (Self-test log descriptor entry) | |
302 | #pragma pack(1) | |
303 | struct ata_smart_selftestlog_struct { | |
304 | unsigned char selftestnumber; // Sector number register | |
305 | unsigned char selfteststatus; | |
306 | unsigned short int timestamp; | |
307 | unsigned char selftestfailurecheckpoint; | |
308 | unsigned int lbafirstfailure; | |
309 | unsigned char vendorspecific[15]; | |
310 | } ATTR_PACKED; | |
311 | #pragma pack() | |
312 | ASSERT_SIZEOF_STRUCT(ata_smart_selftestlog_struct, 24); | |
313 | ||
314 | // Table 44 of T13/1321D Rev 1 spec (Self-test log data structure) | |
315 | #pragma pack(1) | |
316 | struct ata_smart_selftestlog { | |
317 | unsigned short int revnumber; | |
318 | struct ata_smart_selftestlog_struct selftest_struct[21]; | |
319 | unsigned char vendorspecific[2]; | |
320 | unsigned char mostrecenttest; | |
321 | unsigned char reserved[2]; | |
322 | unsigned char chksum; | |
323 | } ATTR_PACKED; | |
324 | #pragma pack() | |
325 | ASSERT_SIZEOF_STRUCT(ata_smart_selftestlog, 512); | |
326 | ||
327 | // SMART LOG DIRECTORY Table 52 of T13/1532D Vol 1 Rev 1a | |
328 | #pragma pack(1) | |
329 | struct ata_smart_log_entry { | |
330 | unsigned char numsectors; | |
331 | unsigned char reserved; | |
332 | } ATTR_PACKED; | |
333 | #pragma pack() | |
334 | ASSERT_SIZEOF_STRUCT(ata_smart_log_entry, 2); | |
335 | ||
336 | #pragma pack(1) | |
337 | struct ata_smart_log_directory { | |
338 | unsigned short int logversion; | |
339 | struct ata_smart_log_entry entry[255]; | |
340 | } ATTR_PACKED; | |
341 | #pragma pack() | |
342 | ASSERT_SIZEOF_STRUCT(ata_smart_log_directory, 512); | |
343 | ||
344 | // SMART SELECTIVE SELF-TEST LOG Table 61 of T13/1532D Volume 1 | |
345 | // Revision 3 | |
346 | #pragma pack(1) | |
347 | struct test_span { | |
348 | uint64_t start; | |
349 | uint64_t end; | |
350 | } ATTR_PACKED; | |
351 | #pragma pack() | |
352 | ASSERT_SIZEOF_STRUCT(test_span, 16); | |
353 | ||
354 | #pragma pack(1) | |
355 | struct ata_selective_self_test_log { | |
356 | unsigned short logversion; | |
357 | struct test_span span[5]; | |
358 | unsigned char reserved1[337-82+1]; | |
359 | unsigned char vendor_specific1[491-338+1]; | |
360 | uint64_t currentlba; | |
361 | unsigned short currentspan; | |
362 | unsigned short flags; | |
363 | unsigned char vendor_specific2[507-504+1]; | |
364 | unsigned short pendingtime; | |
365 | unsigned char reserved2; | |
366 | unsigned char checksum; | |
367 | } ATTR_PACKED; | |
368 | #pragma pack() | |
369 | ASSERT_SIZEOF_STRUCT(ata_selective_self_test_log, 512); | |
370 | ||
371 | #define SELECTIVE_FLAG_DOSCAN (0x0002) | |
372 | #define SELECTIVE_FLAG_PENDING (0x0008) | |
373 | #define SELECTIVE_FLAG_ACTIVE (0x0010) | |
374 | ||
375 | // Get information from drive | |
376 | int ataReadHDIdentity(int device, struct ata_identify_device *buf); | |
377 | int ataCheckPowerMode(int device); | |
378 | ||
379 | /* Read S.M.A.R.T information from drive */ | |
380 | int ataReadSmartValues(int device,struct ata_smart_values *); | |
381 | int ataReadSmartThresholds(int device, struct ata_smart_thresholds_pvt *); | |
382 | int ataReadErrorLog(int device, struct ata_smart_errorlog *); | |
383 | int ataReadSelfTestLog(int device, struct ata_smart_selftestlog *); | |
384 | int ataReadSelectiveSelfTestLog(int device, struct ata_selective_self_test_log *data); | |
385 | int ataSmartStatus(int device); | |
386 | int ataSetSmartThresholds(int device, struct ata_smart_thresholds_pvt *); | |
387 | int ataReadLogDirectory(int device, struct ata_smart_log_directory *); | |
388 | ||
389 | /* Enable/Disable SMART on device */ | |
390 | int ataEnableSmart ( int device ); | |
391 | int ataDisableSmart (int device ); | |
392 | int ataEnableAutoSave(int device); | |
393 | int ataDisableAutoSave(int device); | |
394 | ||
395 | /* Automatic Offline Testing */ | |
396 | int ataEnableAutoOffline ( int device ); | |
397 | int ataDisableAutoOffline (int device ); | |
398 | ||
399 | /* S.M.A.R.T. test commands */ | |
400 | int ataSmartOfflineTest (int device); | |
401 | int ataSmartExtendSelfTest (int device); | |
402 | int ataSmartShortSelfTest (int device); | |
403 | int ataSmartShortCapSelfTest (int device); | |
404 | int ataSmartExtendCapSelfTest (int device); | |
405 | int ataSmartSelfTestAbort (int device); | |
406 | ||
407 | // Returns the latest compatibility of ATA/ATAPI Version the device | |
408 | // supports. Returns -1 if Version command is not supported | |
409 | int ataVersionInfo (const char **description, struct ata_identify_device *drive, unsigned short *minor); | |
410 | ||
411 | // If SMART supported, this is guaranteed to return 1 if SMART is enabled, else 0. | |
412 | int ataDoesSmartWork(int device); | |
413 | ||
414 | // returns 1 if SMART supported, 0 if not supported or can't tell | |
415 | int ataSmartSupport ( struct ata_identify_device *drive); | |
416 | ||
417 | // Return values: | |
418 | // 1: SMART enabled | |
419 | // 0: SMART disabled | |
420 | // -1: can't tell if SMART is enabled -- try issuing ataDoesSmartWork command to see | |
421 | int ataIsSmartEnabled(struct ata_identify_device *drive); | |
422 | ||
423 | /* Check SMART for Threshold failure */ | |
424 | // onlyfailed=0 : are or were any age or prefailure attributes <= threshold | |
425 | // onlyfailed=1: are any prefailure attributes <= threshold now | |
426 | int ataCheckSmart ( struct ata_smart_values *data, struct ata_smart_thresholds_pvt *thresholds, int onlyfailed); | |
427 | ||
428 | int ataSmartStatus2(int device); | |
429 | ||
430 | // int isOfflineTestTime ( struct ata_smart_values data) | |
431 | // returns S.M.A.R.T. Offline Test Time in seconds | |
432 | int isOfflineTestTime ( struct ata_smart_values *data); | |
433 | ||
434 | int isShortSelfTestTime ( struct ata_smart_values *data); | |
435 | ||
436 | int isExtendedSelfTestTime ( struct ata_smart_values *data); | |
437 | ||
438 | int isSmartErrorLogCapable(struct ata_smart_values *data, struct ata_identify_device *identity); | |
439 | ||
440 | int isSmartTestLogCapable(struct ata_smart_values *data, struct ata_identify_device *identity); | |
441 | ||
442 | int isGeneralPurposeLoggingCapable(struct ata_identify_device *identity); | |
443 | ||
444 | int isSupportExecuteOfflineImmediate ( struct ata_smart_values *data); | |
445 | ||
446 | int isSupportAutomaticTimer ( struct ata_smart_values *data); | |
447 | ||
448 | int isSupportOfflineAbort ( struct ata_smart_values *data); | |
449 | ||
450 | int isSupportOfflineSurfaceScan ( struct ata_smart_values *data); | |
451 | ||
452 | int isSupportSelfTest (struct ata_smart_values *data); | |
453 | ||
454 | int isSupportConveyanceSelfTest(struct ata_smart_values *data); | |
455 | ||
456 | int isSupportSelectiveSelfTest(struct ata_smart_values *data); | |
457 | ||
458 | int ataSmartTest(int device, int testtype, struct ata_smart_values *data); | |
459 | ||
460 | int TestTime(struct ata_smart_values *data,int testtype); | |
461 | ||
462 | // Prints the raw value (with appropriate formatting) into the | |
463 | // character string out. | |
464 | int64_t ataPrintSmartAttribRawValue(char *out, | |
465 | struct ata_smart_attribute *attribute, | |
466 | unsigned char *defs); | |
467 | ||
468 | // Prints Attribute Name for standard SMART attributes. Writes a | |
469 | // 30 byte string with attribute name into output | |
470 | void ataPrintSmartAttribName(char *output, unsigned char id, unsigned char *definitions); | |
471 | ||
472 | // This checks the n'th attribute in the attribute list, NOT the | |
473 | // attribute with id==n. If the attribute does not exist, or the | |
474 | // attribute is > threshold, then returns zero. If the attribute is | |
475 | // <= threshold (failing) then we the attribute number if it is a | |
476 | // prefail attribute. Else we return minus the attribute number if it | |
477 | // is a usage attribute. | |
478 | int ataCheckAttribute(struct ata_smart_values *data, | |
479 | struct ata_smart_thresholds_pvt *thresholds, | |
480 | int n); | |
481 | ||
482 | // External handler function, for when a checksum is not correct. Can | |
483 | // simply return if no action is desired, or can print error messages | |
484 | // as needed, or exit. Is passed a string with the name of the Data | |
485 | // Structure with the incorrect checksum. | |
486 | void checksumwarning(const char *string); | |
487 | ||
488 | // Returns raw value of Attribute with ID==id. This will be in the | |
489 | // range 0 to 2^48-1 inclusive. If the Attribute does not exist, | |
490 | // return -1. | |
491 | int64_t ATAReturnAttributeRawValue(unsigned char id, struct ata_smart_values *data); | |
492 | ||
493 | ||
494 | // This are the meanings of the Self-test failure checkpoint byte. | |
495 | // This is in the self-test log at offset 4 bytes into the self-test | |
496 | // descriptor and in the SMART READ DATA structure at byte offset | |
497 | // 371. These codes are not well documented. The meanings returned by | |
498 | // this routine are used (at least) by Maxtor and IBM. Returns NULL if | |
499 | // not recognized. | |
500 | const char *SelfTestFailureCodeName(unsigned char which); | |
501 | ||
502 | ||
503 | #define MAX_ATTRIBUTE_NUM 256 | |
504 | ||
505 | extern const char *vendorattributeargs[]; | |
506 | ||
507 | // function to parse pairs like "9,minutes" or "220,temp". See end of | |
508 | // extern.h for definition of defs[]. Returns 0 if pair recognized, | |
509 | // else 1 if there is a problem. Allocates memory for array if the | |
510 | // array address is *defs==NULL. | |
511 | int parse_attribute_def(char *pair, unsigned char **defs); | |
512 | ||
513 | // Function to return a string containing a list of the arguments in | |
514 | // vendorattributeargs[]. Returns NULL if the required memory can't | |
515 | // be allocated. | |
516 | char *create_vendor_attribute_arg_list(void); | |
517 | ||
518 | ||
519 | // These are two of the functions that are defined in os_*.c and need | |
520 | // to be ported to get smartmontools onto another OS. | |
521 | int ata_command_interface(int device, smart_command_set command, int select, char *data); | |
522 | int escalade_command_interface(int fd, int escalade_port, int escalade_type, smart_command_set command, int select, char *data); | |
523 | int marvell_command_interface(int device, smart_command_set command, int select, char *data); | |
524 | // Optional functions of os_*.c | |
525 | #ifdef HAVE_ATA_IDENTIFY_IS_CACHED | |
526 | // Return true if OS caches the ATA identify sector | |
527 | int ata_identify_is_cached(int fd); | |
528 | #endif | |
529 | ||
530 | // This function is exported to give low-level capability | |
531 | int smartcommandhandler(int device, smart_command_set command, int select, char *data); | |
532 | ||
533 | // Utility routines. | |
534 | void swap2(char *location); | |
535 | void swap4(char *location); | |
536 | void swap8(char *location); | |
537 | #endif /* ATACMDS_H_ */ |