4 * Home page of code is: http://smartmontools.sourceforge.net
6 * Copyright (C) 2002-8 Bruce Allen <smartmontools-support@lists.sourceforge.net>
7 * Copyright (C) 1999-2000 Michael Cornwell <cornwell@acm.org>
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)
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.
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/
28 #define ATACMDS_H_CVSID "$Id: atacmds.h,v 1.90 2008/03/04 22:09:47 ballen4705 Exp $\n"
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
35 #define ASSERT_SIZEOF_STRUCT(s, n) \
36 typedef char assert_sizeof_struct_##s[(sizeof(struct s) == (n)) ? 1 : -1]
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))
47 // returns no data, just succeeds or fails
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:
61 // returns 1 byte of data
63 // writes 512 bytes of data:
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
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
88 #define ATA_SMART_AUTO_OFFLINE 0xdb
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)
103 // Maximum allowed number of SMART Attributes
104 #define NUMBER_ATA_SMART_ATTRIBUTES 30
106 // Needed parts of the ATA DRIVE IDENTIFY Structure. Those labeled
107 // word* are NOT used.
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];
127 ASSERT_SIZEOF_STRUCT(ata_identify_device
, 512);
129 /* ata_smart_attribute is the vendor specific in SFF-8035 spec */
131 struct ata_smart_attribute
{
133 // meaning of flag bits: see MACROS just below
134 // WARNING: MISALIGNED!
135 unsigned short flags
;
136 unsigned char current
;
138 unsigned char raw
[6];
139 unsigned char reserv
;
142 ASSERT_SIZEOF_STRUCT(ata_smart_attribute
, 12);
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.
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)
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)
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)
176 // 3: Errorrate type bit
177 #define ATTRIBUTE_FLAGS_ERRORRATE(x) (x & 0x08)
180 #define ATTRIBUTE_FLAGS_EVENTCOUNT(x) (x & 0x10)
182 // 5: Selfpereserving bit
183 #define ATTRIBUTE_FLAGS_SELFPRESERVING(x) (x & 0x20)
186 // Last ten bits are reserved for future use
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 */
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
;
210 ASSERT_SIZEOF_STRUCT(ata_smart_values
, 512);
212 /* Maxtor, IBM: self-test failure checkpoint byte meaning:
221 /* Vendor attribute of SMART Threshold (compare to ata_smart_attribute above) */
223 struct ata_smart_threshold_entry
{
225 unsigned char threshold
;
226 unsigned char reserved
[10];
229 ASSERT_SIZEOF_STRUCT(ata_smart_threshold_entry
, 12);
231 /* Format of Read SMART THreshold Command */
232 /* Compare to ata_smart_values above */
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
;
241 ASSERT_SIZEOF_STRUCT(ata_smart_thresholds_pvt
, 512);
244 // Table 42 of T13/1321D Rev 1 spec (Error Data Structure)
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];
257 unsigned short timestamp
;
260 ASSERT_SIZEOF_STRUCT(ata_smart_errorlog_error_struct
, 30);
263 // Table 41 of T13/1321D Rev 1 spec (Command Data Structure)
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
;
277 ASSERT_SIZEOF_STRUCT(ata_smart_errorlog_command_struct
, 12);
279 // Table 40 of T13/1321D Rev 1 spec (Error log data structure)
281 struct ata_smart_errorlog_struct
{
282 struct ata_smart_errorlog_command_struct commands
[5];
283 struct ata_smart_errorlog_error_struct error_struct
;
286 ASSERT_SIZEOF_STRUCT(ata_smart_errorlog_struct
, 90);
288 // Table 39 of T13/1321D Rev 1 spec (SMART error log sector)
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
;
299 ASSERT_SIZEOF_STRUCT(ata_smart_errorlog
, 512);
301 // Table 45 of T13/1321D Rev 1 spec (Self-test log descriptor entry)
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];
312 ASSERT_SIZEOF_STRUCT(ata_smart_selftestlog_struct
, 24);
314 // Table 44 of T13/1321D Rev 1 spec (Self-test log data structure)
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
;
325 ASSERT_SIZEOF_STRUCT(ata_smart_selftestlog
, 512);
327 // SMART LOG DIRECTORY Table 52 of T13/1532D Vol 1 Rev 1a
329 struct ata_smart_log_entry
{
330 unsigned char numsectors
;
331 unsigned char reserved
;
334 ASSERT_SIZEOF_STRUCT(ata_smart_log_entry
, 2);
337 struct ata_smart_log_directory
{
338 unsigned short int logversion
;
339 struct ata_smart_log_entry entry
[255];
342 ASSERT_SIZEOF_STRUCT(ata_smart_log_directory
, 512);
344 // SMART SELECTIVE SELF-TEST LOG Table 61 of T13/1532D Volume 1
352 ASSERT_SIZEOF_STRUCT(test_span
, 16);
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];
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
;
369 ASSERT_SIZEOF_STRUCT(ata_selective_self_test_log
, 512);
371 #define SELECTIVE_FLAG_DOSCAN (0x0002)
372 #define SELECTIVE_FLAG_PENDING (0x0008)
373 #define SELECTIVE_FLAG_ACTIVE (0x0010)
376 // SCT (SMART Command Transport) data structures
377 // See Sections 8.2 and 8.3 of:
378 // AT Attachment 8 - ATA/ATAPI Command Set (ATA8-ACS)
379 // T13/1699-D Revision 3f (Working Draft), December 11, 2006.
381 // SCT Status response (read with SMART_READ_LOG page 0xe0)
382 // Table 60 of T13/1699-D Revision 3f
384 struct ata_sct_status_response
386 unsigned short format_version
; // 0-1: Status response format version number (2, 3)
387 unsigned short sct_version
; // 2-3: Vendor specific version number
388 unsigned short sct_spec
; // 4-5: SCT level supported (1)
389 unsigned int status_flags
; // 6-9: Status flags (Bit 0: Segment initialized, Bits 1-31: reserved)
390 unsigned char device_state
; // 10: Device State (0-5)
391 unsigned char bytes011_013
[3]; // 11-13: reserved
392 unsigned short ext_status_code
; // 14-15: Status of last SCT command (0xffff if executing)
393 unsigned short action_code
; // 16-17: Action code of last SCT command
394 unsigned short function_code
; // 18-19: Function code of last SCT command
395 unsigned char bytes020_039
[20]; // 20-39: reserved
396 uint64_t lba_current
; // 40-47: LBA of SCT command executing in background
397 unsigned char bytes048_199
[152]; // 48-199: reserved
398 signed char hda_temp
; // 200: Current temperature in Celsius (0x80 = invalid)
399 signed char min_temp
; // 201: Minimum temperature this power cycle
400 signed char max_temp
; // 202: Maximum temperature this power cycle
401 signed char life_min_temp
; // 203: Minimum lifetime temperature
402 signed char life_max_temp
; // 204: Maximum lifetime temperature
403 unsigned char byte205
; // 205: reserved (T13/e06152r0-2: Average lifetime temperature)
404 unsigned int over_limit_count
; // 206-209: # intervals since last reset with temperature > Max Op Limit
405 unsigned int under_limit_count
; // 210-213: # intervals since last reset with temperature < Min Op Limit
406 unsigned char bytes214_479
[266]; // 214-479: reserved
407 unsigned char vendor_specific
[32];// 480-511: vendor specific
410 ASSERT_SIZEOF_STRUCT(ata_sct_status_response
, 512);
412 // SCT Feature Control command (send with SMART_WRITE_LOG page 0xe0)
413 // Table 72 of T13/1699-D Revision 3f
415 struct ata_sct_feature_control_command
417 unsigned short action_code
; // 4 = Feature Control
418 unsigned short function_code
; // 1 = Set, 2 = Return, 3 = Return options
419 unsigned short feature_code
; // 3 = Temperature logging interval
420 unsigned short state
; // Interval
421 unsigned short option_flags
; // Bit 0: persistent, Bits 1-31: reserved
422 unsigned short words005_255
[251]; // reserved
425 ASSERT_SIZEOF_STRUCT(ata_sct_feature_control_command
, 512);
427 // SCT Data Table command (send with SMART_WRITE_LOG page 0xe0)
428 // Table 73 of T13/1699-D Revision 3f
430 struct ata_sct_data_table_command
432 unsigned short action_code
; // 5 = Data Table
433 unsigned short function_code
; // 1 = Read Table
434 unsigned short table_id
; // 2 = Temperature History
435 unsigned short words003_255
[253]; // reserved
438 ASSERT_SIZEOF_STRUCT(ata_sct_data_table_command
, 512);
440 // SCT Temperature History Table (read with SMART_READ_LOG page 0xe1)
441 // Table 75 of T13/1699-D Revision 3f
443 struct ata_sct_temperature_history_table
445 unsigned short format_version
; // 0-1: Data table format version number (2)
446 unsigned short sampling_period
; // 2-3: Temperature sampling period in minutes
447 unsigned short interval
; // 4-5: Timer interval between history entries
448 signed char max_op_limit
; // 6: Maximum recommended continuous operating temperature
449 signed char over_limit
; // 7: Maximum temperature limit
450 signed char min_op_limit
; // 8: Minimum recommended continuous operating limit
451 signed char under_limit
; // 9: Minimum temperature limit
452 unsigned char bytes010_029
[20]; // 10-29: reserved
453 unsigned short cb_size
; // 30-31: Number of history entries (range 128-478)
454 unsigned short cb_index
; // 32-33: Index of last updated entry (zero-based)
455 signed char cb
[478]; // 34-(34+cb_size-1): Circular buffer of temperature values
458 ASSERT_SIZEOF_STRUCT(ata_sct_temperature_history_table
, 512);
461 // Get information from drive
462 int ataReadHDIdentity(int device
, struct ata_identify_device
*buf
);
463 int ataCheckPowerMode(int device
);
465 /* Read S.M.A.R.T information from drive */
466 int ataReadSmartValues(int device
,struct ata_smart_values
*);
467 int ataReadSmartThresholds(int device
, struct ata_smart_thresholds_pvt
*);
468 int ataReadErrorLog(int device
, struct ata_smart_errorlog
*);
469 int ataReadSelfTestLog(int device
, struct ata_smart_selftestlog
*);
470 int ataReadSelectiveSelfTestLog(int device
, struct ata_selective_self_test_log
*data
);
471 int ataSmartStatus(int device
);
472 int ataSetSmartThresholds(int device
, struct ata_smart_thresholds_pvt
*);
473 int ataReadLogDirectory(int device
, struct ata_smart_log_directory
*);
475 // Read SCT information
476 int ataReadSCTStatus(int device
, ata_sct_status_response
* sts
);
477 int ataReadSCTTempHist(int device
, ata_sct_temperature_history_table
* tmh
,
478 ata_sct_status_response
* sts
);
479 // Set SCT temperature logging interval
480 int ataSetSCTTempInterval(int device
, unsigned interval
, bool persistent
);
483 /* Enable/Disable SMART on device */
484 int ataEnableSmart ( int device
);
485 int ataDisableSmart (int device
);
486 int ataEnableAutoSave(int device
);
487 int ataDisableAutoSave(int device
);
489 /* Automatic Offline Testing */
490 int ataEnableAutoOffline ( int device
);
491 int ataDisableAutoOffline (int device
);
493 /* S.M.A.R.T. test commands */
494 int ataSmartOfflineTest (int device
);
495 int ataSmartExtendSelfTest (int device
);
496 int ataSmartShortSelfTest (int device
);
497 int ataSmartShortCapSelfTest (int device
);
498 int ataSmartExtendCapSelfTest (int device
);
499 int ataSmartSelfTestAbort (int device
);
501 // Returns the latest compatibility of ATA/ATAPI Version the device
502 // supports. Returns -1 if Version command is not supported
503 int ataVersionInfo (const char **description
, struct ata_identify_device
*drive
, unsigned short *minor
);
505 // If SMART supported, this is guaranteed to return 1 if SMART is enabled, else 0.
506 int ataDoesSmartWork(int device
);
508 // returns 1 if SMART supported, 0 if not supported or can't tell
509 int ataSmartSupport ( struct ata_identify_device
*drive
);
514 // -1: can't tell if SMART is enabled -- try issuing ataDoesSmartWork command to see
515 int ataIsSmartEnabled(struct ata_identify_device
*drive
);
517 /* Check SMART for Threshold failure */
518 // onlyfailed=0 : are or were any age or prefailure attributes <= threshold
519 // onlyfailed=1: are any prefailure attributes <= threshold now
520 int ataCheckSmart ( struct ata_smart_values
*data
, struct ata_smart_thresholds_pvt
*thresholds
, int onlyfailed
);
522 int ataSmartStatus2(int device
);
524 // int isOfflineTestTime ( struct ata_smart_values data)
525 // returns S.M.A.R.T. Offline Test Time in seconds
526 int isOfflineTestTime ( struct ata_smart_values
*data
);
528 int isShortSelfTestTime ( struct ata_smart_values
*data
);
530 int isExtendedSelfTestTime ( struct ata_smart_values
*data
);
532 int isSmartErrorLogCapable(struct ata_smart_values
*data
, struct ata_identify_device
*identity
);
534 int isSmartTestLogCapable(struct ata_smart_values
*data
, struct ata_identify_device
*identity
);
536 int isGeneralPurposeLoggingCapable(struct ata_identify_device
*identity
);
538 int isSupportExecuteOfflineImmediate ( struct ata_smart_values
*data
);
540 int isSupportAutomaticTimer ( struct ata_smart_values
*data
);
542 int isSupportOfflineAbort ( struct ata_smart_values
*data
);
544 int isSupportOfflineSurfaceScan ( struct ata_smart_values
*data
);
546 int isSupportSelfTest (struct ata_smart_values
*data
);
548 int isSupportConveyanceSelfTest(struct ata_smart_values
*data
);
550 int isSupportSelectiveSelfTest(struct ata_smart_values
*data
);
552 inline bool isSCTCapable(const ata_identify_device
*drive
)
553 { return !!(drive
->words088_255
[206-88] & 0x01); } // 0x01 = SCT support
555 inline bool isSCTFeatureControlCapable(const ata_identify_device
*drive
)
556 { return ((drive
->words088_255
[206-88] & 0x11) == 0x11); } // 0x10 = SCT Feature Control support
558 inline bool isSCTDataTableCapable(const ata_identify_device
*drive
)
559 { return ((drive
->words088_255
[206-88] & 0x21) == 0x21); } // 0x20 = SCT Data Table support
561 int ataSmartTest(int device
, int testtype
, struct ata_smart_values
*data
, uint64_t num_sectors
);
563 int TestTime(struct ata_smart_values
*data
,int testtype
);
565 // Prints the raw value (with appropriate formatting) into the
566 // character string out.
567 int64_t ataPrintSmartAttribRawValue(char *out
,
568 struct ata_smart_attribute
*attribute
,
569 unsigned char *defs
);
571 // Prints Attribute Name for standard SMART attributes. Writes a
572 // 30 byte string with attribute name into output
573 void ataPrintSmartAttribName(char *output
, unsigned char id
, unsigned char *definitions
);
575 // This checks the n'th attribute in the attribute list, NOT the
576 // attribute with id==n. If the attribute does not exist, or the
577 // attribute is > threshold, then returns zero. If the attribute is
578 // <= threshold (failing) then we the attribute number if it is a
579 // prefail attribute. Else we return minus the attribute number if it
580 // is a usage attribute.
581 int ataCheckAttribute(struct ata_smart_values
*data
,
582 struct ata_smart_thresholds_pvt
*thresholds
,
585 // External handler function, for when a checksum is not correct. Can
586 // simply return if no action is desired, or can print error messages
587 // as needed, or exit. Is passed a string with the name of the Data
588 // Structure with the incorrect checksum.
589 void checksumwarning(const char *string
);
591 // Returns raw value of Attribute with ID==id. This will be in the
592 // range 0 to 2^48-1 inclusive. If the Attribute does not exist,
594 int64_t ATAReturnAttributeRawValue(unsigned char id
, struct ata_smart_values
*data
);
596 // Return Temperature Attribute raw value selected according to possible
597 // non-default interpretations. If the Attribute does not exist, return 0
598 unsigned char ATAReturnTemperatureValue(/*const*/ struct ata_smart_values
*data
, const unsigned char *defs
);
601 // This are the meanings of the Self-test failure checkpoint byte.
602 // This is in the self-test log at offset 4 bytes into the self-test
603 // descriptor and in the SMART READ DATA structure at byte offset
604 // 371. These codes are not well documented. The meanings returned by
605 // this routine are used (at least) by Maxtor and IBM. Returns NULL if
607 const char *SelfTestFailureCodeName(unsigned char which
);
610 #define MAX_ATTRIBUTE_NUM 256
612 extern const char *vendorattributeargs
[];
614 // function to parse pairs like "9,minutes" or "220,temp". See end of
615 // extern.h for definition of defs[]. Returns 0 if pair recognized,
616 // else 1 if there is a problem. Allocates memory for array if the
617 // array address is *defs==NULL.
618 int parse_attribute_def(char *pair
, unsigned char **defs
);
620 // Function to return a string containing a list of the arguments in
621 // vendorattributeargs[]. Returns NULL if the required memory can't
623 char *create_vendor_attribute_arg_list(void);
626 // These are two of the functions that are defined in os_*.c and need
627 // to be ported to get smartmontools onto another OS.
628 int ata_command_interface(int device
, smart_command_set command
, int select
, char *data
);
629 int escalade_command_interface(int fd
, int escalade_port
, int escalade_type
, smart_command_set command
, int select
, char *data
);
630 int marvell_command_interface(int device
, smart_command_set command
, int select
, char *data
);
631 int highpoint_command_interface(int device
, smart_command_set command
, int select
, char *data
);
633 // "smartctl -r ataioctl,2 ..." output parser pseudo-device
634 int parsedev_open(const char * name
);
635 void parsedev_close(int fd
);
637 // Optional functions of os_*.c
638 #ifdef HAVE_ATA_IDENTIFY_IS_CACHED
639 // Return true if OS caches the ATA identify sector
640 int ata_identify_is_cached(int fd
);
643 // This function is exported to give low-level capability
644 int smartcommandhandler(int device
, smart_command_set command
, int select
, char *data
);
647 void swap2(char *location
);
648 void swap4(char *location
);
649 void swap8(char *location
);
650 // Typesafe variants using overloading
651 inline void swapx(unsigned short * p
)
653 inline void swapx(unsigned int * p
)
655 inline void swapx(uint64_t * p
)
658 #endif /* ATACMDS_H_ */