smartmontools  SVN Rev 4856
Utility to control and monitor storage systems with "S.M.A.R.T."
atacmds.h
Go to the documentation of this file.
1 /*
2  * atacmds.h
3  *
4  * Home page of code is: http://www.smartmontools.org
5  *
6  * Copyright (C) 2002-11 Bruce Allen
7  * Copyright (C) 2008-17 Christian Franke
8  * Copyright (C) 1999-2000 Michael Cornwell <cornwell@acm.org>
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11  */
12 
13 #ifndef ATACMDS_H_
14 #define ATACMDS_H_
15 
16 #define ATACMDS_H_CVSID "$Id: atacmds.h 4848 2018-12-05 18:30:46Z chrfranke $"
17 
18 #include "dev_interface.h" // ata_device
19 
20 // Macro to check expected size of struct at compile time using a
21 // dummy typedef. On size mismatch, compiler reports a negative array
22 // size. If you see an error message of this form, it means that the
23 // #pragma pack(1) pragma below is not having the desired effect on
24 // your compiler.
25 #define ASSERT_SIZEOF_STRUCT(s, n) \
26  typedef char assert_sizeof_struct_##s[(sizeof(struct s) == (n)) ? 1 : -1]
27 
28 // Add __attribute__((packed)) if compiler supports it
29 // because some gcc versions (at least ARM) lack support of #pragma pack()
30 #ifdef HAVE_ATTR_PACKED
31 #define ATTR_PACKED __attribute__((packed))
32 #else
33 #define ATTR_PACKED
34 #endif
35 
36 typedef enum {
37  // returns no data, just succeeds or fails
43  STATUS, // just says if SMART is working or not
44  STATUS_CHECK, // says if disk's SMART status is healthy, or failing
45  // return 512 bytes of data:
51  // returns 1 byte of data
53  // writes 512 bytes of data:
56 
57 
58 // ATA Specification Command Register Values (Commands)
59 #define ATA_CHECK_POWER_MODE 0xe5
60 #define ATA_IDENTIFY_DEVICE 0xec
61 #define ATA_IDENTIFY_PACKET_DEVICE 0xa1
62 #define ATA_IDLE 0xe3
63 #define ATA_SMART_CMD 0xb0
64 #define ATA_SECURITY_FREEZE_LOCK 0xf5
65 #ifndef ATA_SET_FEATURES
66 #define ATA_SET_FEATURES 0xef
67 #endif
68 #define ATA_STANDBY 0xe2
69 #define ATA_STANDBY_IMMEDIATE 0xe0
70 
71 // SET_FEATURES subcommands
72 #define ATA_DISABLE_AAM 0xc2
73 #define ATA_DISABLE_APM 0x85
74 #define ATA_DISABLE_WRITE_CACHE 0x82
75 #define ATA_DISABLE_READ_LOOK_AHEAD 0x55
76 #define ATA_ENABLE_AAM 0x42
77 #define ATA_ENABLE_APM 0x05
78 #define ATA_ENABLE_WRITE_CACHE 0x02
79 #define ATA_ENABLE_READ_LOOK_AHEAD 0xaa
80 #define ATA_ENABLE_DISABLE_DSN 0x63
81 
82 // 48-bit commands
83 #define ATA_READ_LOG_EXT 0x2F
84 #define ATA_WRITE_LOG_EXT 0x3f
85 
86 // ATA Specification Feature Register Values (SMART Subcommands).
87 // Note that some are obsolete as of ATA-7.
88 #define ATA_SMART_READ_VALUES 0xd0
89 #define ATA_SMART_READ_THRESHOLDS 0xd1
90 #define ATA_SMART_AUTOSAVE 0xd2
91 #define ATA_SMART_SAVE 0xd3
92 #define ATA_SMART_IMMEDIATE_OFFLINE 0xd4
93 #define ATA_SMART_READ_LOG_SECTOR 0xd5
94 #define ATA_SMART_WRITE_LOG_SECTOR 0xd6
95 #define ATA_SMART_WRITE_THRESHOLDS 0xd7
96 #define ATA_SMART_ENABLE 0xd8
97 #define ATA_SMART_DISABLE 0xd9
98 #define ATA_SMART_STATUS 0xda
99 // SFF 8035i Revision 2 Specification Feature Register Value (SMART
100 // Subcommand)
101 #define ATA_SMART_AUTO_OFFLINE 0xdb
102 
103 // Sector Number values for ATA_SMART_IMMEDIATE_OFFLINE Subcommand
104 #define OFFLINE_FULL_SCAN 0
105 #define SHORT_SELF_TEST 1
106 #define EXTEND_SELF_TEST 2
107 #define CONVEYANCE_SELF_TEST 3
108 #define SELECTIVE_SELF_TEST 4
109 #define ABORT_SELF_TEST 127
110 #define SHORT_CAPTIVE_SELF_TEST 129
111 #define EXTEND_CAPTIVE_SELF_TEST 130
112 #define CONVEYANCE_CAPTIVE_SELF_TEST 131
113 #define SELECTIVE_CAPTIVE_SELF_TEST 132
114 #define CAPTIVE_MASK (0x01<<7)
115 
116 // Maximum allowed number of SMART Attributes
117 #define NUMBER_ATA_SMART_ATTRIBUTES 30
118 
119 // Needed parts of the ATA DRIVE IDENTIFY Structure. Those labeled
120 // word* are NOT used.
121 #pragma pack(1)
123  unsigned short words000_009[10];
124  unsigned char serial_no[20];
125  unsigned short words020_022[3];
126  unsigned char fw_rev[8];
127  unsigned char model[40];
128  unsigned short words047_079[33];
129  unsigned short major_rev_num;
130  unsigned short minor_rev_num;
131  unsigned short command_set_1;
132  unsigned short command_set_2;
133  unsigned short command_set_extension;
134  unsigned short cfs_enable_1;
135  unsigned short word086;
136  unsigned short csf_default;
137  unsigned short words088_255[168];
138 } ATTR_PACKED;
139 #pragma pack()
141 
142 /* ata_smart_attribute is the vendor specific in SFF-8035 spec */
143 #pragma pack(1)
145  unsigned char id;
146  // meaning of flag bits: see MACROS just below
147  // WARNING: MISALIGNED!
148  unsigned short flags;
149  unsigned char current;
150  unsigned char worst;
151  unsigned char raw[6];
152  unsigned char reserv;
153 } ATTR_PACKED;
154 #pragma pack()
156 
157 // MACROS to interpret the flags bits in the previous structure.
158 // These have not been implemented using bitflags and a union, to make
159 // it portable across bit/little endian and different platforms.
160 
161 // 0: Prefailure bit
162 
163 // From SFF 8035i Revision 2 page 19: Bit 0 (pre-failure/advisory bit)
164 // - If the value of this bit equals zero, an attribute value less
165 // than or equal to its corresponding attribute threshold indicates an
166 // advisory condition where the usage or age of the device has
167 // exceeded its intended design life period. If the value of this bit
168 // equals one, an attribute value less than or equal to its
169 // corresponding attribute threshold indicates a prefailure condition
170 // where imminent loss of data is being predicted.
171 #define ATTRIBUTE_FLAGS_PREFAILURE(x) (x & 0x01)
172 
173 // 1: Online bit
174 
175 // From SFF 8035i Revision 2 page 19: Bit 1 (on-line data collection
176 // bit) - If the value of this bit equals zero, then the attribute
177 // value is updated only during off-line data collection
178 // activities. If the value of this bit equals one, then the attribute
179 // value is updated during normal operation of the device or during
180 // both normal operation and off-line testing.
181 #define ATTRIBUTE_FLAGS_ONLINE(x) (x & 0x02)
182 
183 
184 // The following are (probably) IBM's, Maxtors and Quantum's definitions for the
185 // vendor-specific bits:
186 // 2: Performance type bit
187 #define ATTRIBUTE_FLAGS_PERFORMANCE(x) (x & 0x04)
188 
189 // 3: Errorrate type bit
190 #define ATTRIBUTE_FLAGS_ERRORRATE(x) (x & 0x08)
191 
192 // 4: Eventcount bit
193 #define ATTRIBUTE_FLAGS_EVENTCOUNT(x) (x & 0x10)
194 
195 // 5: Selfpereserving bit
196 #define ATTRIBUTE_FLAGS_SELFPRESERVING(x) (x & 0x20)
197 
198 // 6-15: Reserved for future use
199 #define ATTRIBUTE_FLAGS_OTHER(x) ((x) & 0xffc0)
200 
201 
202 // Format of data returned by SMART READ DATA
203 // Table 62 of T13/1699-D (ATA8-ACS) Revision 6a, September 2008
204 #pragma pack(1)
206  unsigned short int revnumber;
209  unsigned char self_test_exec_status; //IBM # segments for offline collection
210  unsigned short int total_time_to_complete_off_line; // IBM different
211  unsigned char vendor_specific_366; // Maxtor & IBM current segment pointer
213  unsigned short int smart_capability;
214  unsigned char errorlog_capability;
215  unsigned char vendor_specific_371; // Maxtor, IBM: self-test failure checkpoint see below!
217  unsigned char extend_test_completion_time_b; // If 0xff, use 16-bit value below
219  unsigned short extend_test_completion_time_w; // e04130r2, added to T13/1699-D Revision 1c, April 2005
220  unsigned char reserved_377_385[9];
221  unsigned char vendor_specific_386_510[125]; // Maxtor bytes 508-509 Attribute/Threshold Revision #
222  unsigned char chksum;
223 } ATTR_PACKED;
224 #pragma pack()
226 
227 /* Maxtor, IBM: self-test failure checkpoint byte meaning:
228  00 - write test
229  01 - servo basic
230  02 - servo random
231  03 - G-list scan
232  04 - Handling damage
233  05 - Read scan
234 */
235 
236 /* Vendor attribute of SMART Threshold (compare to ata_smart_attribute above) */
237 #pragma pack(1)
239  unsigned char id;
240  unsigned char threshold;
241  unsigned char reserved[10];
242 } ATTR_PACKED;
243 #pragma pack()
245 
246 /* Format of Read SMART THreshold Command */
247 /* Compare to ata_smart_values above */
248 #pragma pack(1)
250  unsigned short int revnumber;
252  unsigned char reserved[149];
253  unsigned char chksum;
254 } ATTR_PACKED;
255 #pragma pack()
257 
258 
259 // Table 42 of T13/1321D Rev 1 spec (Error Data Structure)
260 #pragma pack(1)
262  unsigned char reserved;
263  unsigned char error_register;
264  unsigned char sector_count;
265  unsigned char sector_number;
266  unsigned char cylinder_low;
267  unsigned char cylinder_high;
268  unsigned char drive_head;
269  unsigned char status;
270  unsigned char extended_error[19];
271  unsigned char state;
272  unsigned short timestamp;
273 } ATTR_PACKED;
274 #pragma pack()
276 
277 
278 // Table 41 of T13/1321D Rev 1 spec (Command Data Structure)
279 #pragma pack(1)
281  unsigned char devicecontrolreg;
282  unsigned char featuresreg;
283  unsigned char sector_count;
284  unsigned char sector_number;
285  unsigned char cylinder_low;
286  unsigned char cylinder_high;
287  unsigned char drive_head;
288  unsigned char commandreg;
289  unsigned int timestamp;
290 } ATTR_PACKED;
291 #pragma pack()
293 
294 // Table 40 of T13/1321D Rev 1 spec (Error log data structure)
295 #pragma pack(1)
299 } ATTR_PACKED;
300 #pragma pack()
302 
303 // Table 39 of T13/1321D Rev 1 spec (SMART error log sector)
304 #pragma pack(1)
306  unsigned char revnumber;
307  unsigned char error_log_pointer;
309  unsigned short int ata_error_count;
310  unsigned char reserved[57];
311  unsigned char checksum;
312 } ATTR_PACKED;
313 #pragma pack()
315 
316 
317 // Extended Comprehensive SMART Error Log data structures
318 // See Section A.7 of
319 // AT Attachment 8 - ATA/ATAPI Command Set (ATA8-ACS)
320 // T13/1699-D Revision 6a (Working Draft), September 6, 2008.
321 
322 // Command data structure
323 // Table A.9 of T13/1699-D Revision 6a
324 #pragma pack(1)
326 {
327  unsigned char device_control_register;
328  unsigned char features_register;
329  unsigned char features_register_hi;
330  unsigned char count_register;
331  unsigned char count_register_hi;
332  unsigned char lba_low_register;
333  unsigned char lba_low_register_hi;
334  unsigned char lba_mid_register;
335  unsigned char lba_mid_register_hi;
336  unsigned char lba_high_register;
337  unsigned char lba_high_register_hi;
338  unsigned char device_register;
339  unsigned char command_register;
340 
341  unsigned char reserved;
342  unsigned int timestamp;
343 } ATTR_PACKED;
344 #pragma pack()
346 
347 // Error data structure
348 // Table A.10 T13/1699-D Revision 6a
349 #pragma pack(1)
351 {
352  unsigned char device_control_register;
353  unsigned char error_register;
354  unsigned char count_register;
355  unsigned char count_register_hi;
356  unsigned char lba_low_register;
357  unsigned char lba_low_register_hi;
358  unsigned char lba_mid_register;
359  unsigned char lba_mid_register_hi;
360  unsigned char lba_high_register;
361  unsigned char lba_high_register_hi;
362  unsigned char device_register;
363  unsigned char status_register;
364 
365  unsigned char extended_error[19];
366  unsigned char state;
367  unsigned short timestamp;
368 } ATTR_PACKED;
369 #pragma pack()
371 
372 // Error log data structure
373 // Table A.8 of T13/1699-D Revision 6a
374 #pragma pack(1)
376 {
379 } ATTR_PACKED;
380 #pragma pack()
382 
383 // Ext. Comprehensive SMART error log
384 // Table A.7 of T13/1699-D Revision 6a
385 #pragma pack(1)
387 {
388  unsigned char version;
389  unsigned char reserved1;
390  unsigned short error_log_index;
392  unsigned short device_error_count;
393  unsigned char reserved2[9];
394  unsigned char checksum;
395 } ATTR_PACKED;
396 #pragma pack()
398 
399 
400 // Table 45 of T13/1321D Rev 1 spec (Self-test log descriptor entry)
401 #pragma pack(1)
403  unsigned char selftestnumber; // Sector number register
404  unsigned char selfteststatus;
405  unsigned short int timestamp;
407  unsigned int lbafirstfailure;
408  unsigned char vendorspecific[15];
409 } ATTR_PACKED;
410 #pragma pack()
412 
413 // Table 44 of T13/1321D Rev 1 spec (Self-test log data structure)
414 #pragma pack(1)
416  unsigned short int revnumber;
418  unsigned char vendorspecific[2];
419  unsigned char mostrecenttest;
420  unsigned char reserved[2];
421  unsigned char chksum;
422 } ATTR_PACKED;
423 #pragma pack()
425 
426 // Extended SMART Self-test log data structures
427 // See Section A.8 of
428 // AT Attachment 8 - ATA/ATAPI Command Set (ATA8-ACS)
429 // T13/1699-D Revision 6a (Working Draft), September 6, 2008.
430 
431 // Extended Self-test log descriptor entry
432 // Table A.13 of T13/1699-D Revision 6a
433 #pragma pack(1)
435 {
436  unsigned char self_test_type;
437  unsigned char self_test_status;
438  unsigned short timestamp;
439  unsigned char checkpoint;
440  unsigned char failing_lba[6];
441  unsigned char vendorspecific[15];
442 } ATTR_PACKED;
443 #pragma pack()
445 
446 // Extended Self-test log data structure
447 // Table A.12 of T13/1699-D Revision 6a
448 #pragma pack(1)
450 {
451  unsigned char version;
452  unsigned char reserved1;
453  unsigned short log_desc_index;
455  unsigned char vendor_specifc[2];
456  unsigned char reserved2[11];
457  unsigned char chksum;
458 } ATTR_PACKED;
459 #pragma pack()
461 
462 // SMART LOG DIRECTORY Table 52 of T13/1532D Vol 1 Rev 1a
463 #pragma pack(1)
465  unsigned char numsectors;
466  unsigned char reserved;
467 } ATTR_PACKED;
468 #pragma pack()
470 
471 #pragma pack(1)
473  unsigned short int logversion;
475 } ATTR_PACKED;
476 #pragma pack()
478 
479 // SMART SELECTIVE SELF-TEST LOG Table 61 of T13/1532D Volume 1
480 // Revision 3
481 #pragma pack(1)
482 struct test_span {
483  uint64_t start;
484  uint64_t end;
485 } ATTR_PACKED;
486 #pragma pack()
488 
489 #pragma pack(1)
491  unsigned short logversion;
492  struct test_span span[5];
493  unsigned char reserved1[337-82+1];
494  unsigned char vendor_specific1[491-338+1];
495  uint64_t currentlba;
496  unsigned short currentspan;
497  unsigned short flags;
498  unsigned char vendor_specific2[507-504+1];
499  unsigned short pendingtime;
500  unsigned char reserved2;
501  unsigned char checksum;
502 } ATTR_PACKED;
503 #pragma pack()
505 
506 #define SELECTIVE_FLAG_DOSCAN (0x0002)
507 #define SELECTIVE_FLAG_PENDING (0x0008)
508 #define SELECTIVE_FLAG_ACTIVE (0x0010)
509 
510 
511 // SCT (SMART Command Transport) data structures
512 // See Sections 8.2 and 8.3 of:
513 // AT Attachment 8 - ATA/ATAPI Command Set (ATA8-ACS)
514 // T13/1699-D Revision 3f (Working Draft), December 11, 2006.
515 
516 // SCT Status response (read with SMART_READ_LOG page 0xe0)
517 // Table 194 of T13/BSR INCITS 529 (ACS-4) Revision 20, October 26, 2017
518 #pragma pack(1)
520 {
521  unsigned short format_version; // 0-1: Status response format version number (2, 3)
522  unsigned short sct_version; // 2-3: Vendor specific version number
523  unsigned short sct_spec; // 4-5: SCT level supported (1)
524  unsigned int status_flags; // 6-9: Status flags (Bit 0: Segment initialized, Bits 1-31: reserved)
525  unsigned char device_state; // 10: Device State (0-5)
526  unsigned char bytes011_013[3]; // 11-13: reserved
527  unsigned short ext_status_code; // 14-15: Status of last SCT command (0xffff if executing)
528  unsigned short action_code; // 16-17: Action code of last SCT command
529  unsigned short function_code; // 18-19: Function code of last SCT command
530  unsigned char bytes020_039[20]; // 20-39: reserved
531  uint64_t lba_current; // 40-47: LBA of SCT command executing in background
532  unsigned char bytes048_199[152]; // 48-199: reserved
533  signed char hda_temp; // 200: Current temperature in Celsius (0x80 = invalid)
534  signed char min_temp; // 201: Minimum temperature this power cycle
535  signed char max_temp; // 202: Maximum temperature this power cycle
536  signed char life_min_temp; // 203: Minimum lifetime temperature
537  signed char life_max_temp; // 204: Maximum lifetime temperature
538  signed char max_op_limit; // 205: Specified maximum operating temperature (ACS-4)
539  unsigned int over_limit_count; // 206-209: # intervals since last reset with temperature > Max Op Limit
540  unsigned int under_limit_count; // 210-213: # intervals since last reset with temperature < Min Op Limit
541  unsigned short smart_status; // 214-215: LBA(32:8) of SMART RETURN STATUS (0, 0x2cf4, 0xc24f) (ACS-4)
542  unsigned short min_erc_time; // 216-217: Minimum supported value for ERC (ACS-4)
543  unsigned char bytes216_479[479-218+1]; // 218-479: reserved
544  unsigned char vendor_specific[32];// 480-511: vendor specific
545 } ATTR_PACKED;
546 #pragma pack()
548 
549 // SCT Error Recovery Control command (send with SMART_WRITE_LOG page 0xe0)
550 // Table 88 of T13/1699-D Revision 6a
551 #pragma pack(1)
553 {
554  unsigned short action_code; // 3 = Error Recovery Control
555  unsigned short function_code; // 1 = Set, 2 = Return
556  unsigned short selection_code; // 1 = Read Timer, 2 = Write Timer
557  unsigned short time_limit; // If set: Recovery time limit in 100ms units
558  unsigned short words004_255[252]; // reserved
559 } ATTR_PACKED;
560 #pragma pack()
562 
563 // SCT Feature Control command (send with SMART_WRITE_LOG page 0xe0)
564 // Table 72 of T13/1699-D Revision 3f
565 #pragma pack(1)
567 {
568  unsigned short action_code; // 4 = Feature Control
569  unsigned short function_code; // 1 = Set, 2 = Return, 3 = Return options
570  unsigned short feature_code; // 3 = Temperature logging interval
571  unsigned short state; // Interval
572  unsigned short option_flags; // Bit 0: persistent, Bits 1-15: reserved
573  unsigned short words005_255[251]; // reserved
574 } ATTR_PACKED;
575 #pragma pack()
577 
578 // SCT Data Table command (send with SMART_WRITE_LOG page 0xe0)
579 // Table 73 of T13/1699-D Revision 3f
580 #pragma pack(1)
582 {
583  unsigned short action_code; // 5 = Data Table
584  unsigned short function_code; // 1 = Read Table
585  unsigned short table_id; // 2 = Temperature History
586  unsigned short words003_255[253]; // reserved
587 } ATTR_PACKED;
588 #pragma pack()
590 
591 // SCT Temperature History Table (read with SMART_READ_LOG page 0xe1)
592 // Table 75 of T13/1699-D Revision 3f
593 #pragma pack(1)
595 {
596  unsigned short format_version; // 0-1: Data table format version number (2)
597  unsigned short sampling_period; // 2-3: Temperature sampling period in minutes
598  unsigned short interval; // 4-5: Timer interval between history entries
599  signed char max_op_limit; // 6: Maximum recommended continuous operating temperature
600  signed char over_limit; // 7: Maximum temperature limit
601  signed char min_op_limit; // 8: Minimum recommended continuous operating limit
602  signed char under_limit; // 9: Minimum temperature limit
603  unsigned char bytes010_029[20]; // 10-29: reserved
604  unsigned short cb_size; // 30-31: Number of history entries (range 128-478)
605  unsigned short cb_index; // 32-33: Index of last updated entry (zero-based)
606  signed char cb[478]; // 34-(34+cb_size-1): Circular buffer of temperature values
607 } ATTR_PACKED;
608 #pragma pack()
610 
611 // Possible values for span_args.mode
612 enum {
613  SEL_RANGE, // MIN-MAX
614  SEL_REDO, // redo this
615  SEL_NEXT, // do next range
616  SEL_CONT // redo or next depending of last test status
617 };
618 
619 // Arguments for selective self-test
621 {
622  // Arguments for each span
623  struct span_args
624  {
625  uint64_t start; // First block
626  uint64_t end; // Last block
627  int mode; // SEL_*, see above
628 
630  : start(0), end(0), mode(SEL_RANGE) { }
631  };
632 
633  span_args span[5]; // Range and mode for 5 spans
634  int num_spans; // Number of spans
635  int pending_time; // One plus time in minutes to wait after powerup before restarting
636  // interrupted offline scan after selective self-test.
637  int scan_after_select; // Run offline scan after selective self-test:
638  // 0: don't change,
639  // 1: turn off scan after selective self-test,
640  // 2: turn on scan after selective self-test.
641 
643  : num_spans(0), pending_time(0), scan_after_select(0) { }
644 };
645 
646 // Priority for vendor attribute defs
648 {
652 };
653 
654 // Raw attribute value print formats
656 {
677 };
678 
679 // Attribute flags
680 enum {
681  ATTRFLAG_INCREASING = 0x01, // Value not reset (for reallocated/pending counts)
682  ATTRFLAG_NO_NORMVAL = 0x02, // Normalized value not valid
683  ATTRFLAG_NO_WORSTVAL = 0x04, // Worst value not valid
684  ATTRFLAG_HDD_ONLY = 0x08, // DEFAULT setting for HDD only
685  ATTRFLAG_SSD_ONLY = 0x10, // DEFAULT setting for SSD only
686 };
687 
688 // Vendor attribute display defs for all attribute ids
690 {
691 public:
692  struct entry
693  {
694  std::string name; // Attribute name, empty for default
695  ata_attr_raw_format raw_format; // Raw value print format
696  ata_vendor_def_prior priority; // Setting priority
697  unsigned flags; // ATTRFLAG_*
698  char byteorder[8+1]; // String [012345rvwz] to define byte order
699 
701  : raw_format(RAWFMT_DEFAULT),
702  priority(PRIOR_DEFAULT),
703  flags(0)
704  { byteorder[0] = 0; }
705  };
706 
707  entry & operator[](unsigned char id)
708  { return m_defs[id]; }
709 
710  const entry & operator[](unsigned char id) const
711  { return m_defs[id]; }
712 
713 private:
714  entry m_defs[256];
715 };
716 
717 
718 // Possible values for firmwarebugs
720  BUG_NONE = 0,
726 };
727 
728 // Set of firmware bugs
730 {
731 public:
733  : m_bugs(0) { }
734 
735  bool is_set(firmwarebug_t bug) const
736  { return !!(m_bugs & (1 << bug)); }
737 
738  void set(firmwarebug_t bug)
739  { m_bugs |= (1 << bug); }
740 
742  { m_bugs |= bugs.m_bugs; }
743 
744 private:
745  unsigned m_bugs;
746 };
747 
748 
749 // Print ATA debug messages?
750 extern unsigned char ata_debugmode;
751 
752 // Suppress serial number?
753 extern bool dont_print_serial_number;
754 
755 // Get information from drive
757  unsigned char * raw_buf = 0);
758 int ataCheckPowerMode(ata_device * device);
759 
760 // Issue a no-data ATA command with optional sector count register value
761 bool ata_nodata_command(ata_device * device, unsigned char command, int sector_count = -1);
762 
763 // Issue SET FEATURES command with optional sector count register value
764 bool ata_set_features(ata_device * device, unsigned char features, int sector_count = -1);
765 
766 /* Read S.M.A.R.T information from drive */
767 int ataReadSmartValues(ata_device * device,struct ata_smart_values *);
770  firmwarebug_defs firmwarebugs);
772  firmwarebug_defs firmwarebugs);
774 int ataReadLogDirectory(ata_device * device, ata_smart_log_directory *, bool gpl);
775 
776 // Write GP Log page(s)
777 bool ataWriteLogExt(ata_device * device, unsigned char logaddr,
778  unsigned page, void * data, unsigned nsectors);
779 
780 // Read GP Log page(s)
781 bool ataReadLogExt(ata_device * device, unsigned char logaddr,
782  unsigned char features, unsigned page,
783  void * data, unsigned nsectors);
784 // Read SMART Log page(s)
785 bool ataReadSmartLog(ata_device * device, unsigned char logaddr,
786  void * data, unsigned nsectors);
787 // Read SMART Extended Comprehensive Error Log
789  unsigned page, unsigned nsectors, firmwarebug_defs firmwarebugs);
790 // Read SMART Extended Self-test Log
792  unsigned nsectors);
793 
794 // Read SCT information
798 // Set SCT temperature logging interval
799 int ataSetSCTTempInterval(ata_device * device, unsigned interval, bool persistent);
800 
801 // Get/Set SCT Error Recovery Control
802 int ataGetSCTErrorRecoveryControltime(ata_device * device, unsigned type, unsigned short & time_limit);
803 int ataSetSCTErrorRecoveryControltime(ata_device * device, unsigned type, unsigned short time_limit);
804 
805 
806 /* Enable/Disable SMART on device */
807 int ataEnableSmart (ata_device * device);
808 int ataDisableSmart (ata_device * device);
809 int ataEnableAutoSave(ata_device * device);
810 int ataDisableAutoSave(ata_device * device);
811 
812 /* Automatic Offline Testing */
813 int ataEnableAutoOffline (ata_device * device);
814 int ataDisableAutoOffline (ata_device * device);
815 
816 /* S.M.A.R.T. test commands */
817 int ataSmartTest(ata_device * device, int testtype, bool force,
818  const ata_selective_selftest_args & args,
819  const ata_smart_values * sv, uint64_t num_sectors);
820 
822  const ata_smart_values * sv, uint64_t num_sectors,
823  const ata_selective_selftest_args * prev_spans = 0);
824 
825 // Get World Wide Name (WWN) fields.
826 // Return NAA field or -1 if WWN is unsupported.
827 int ata_get_wwn(const ata_identify_device * id, unsigned & oui, uint64_t & unique_id);
828 
829 // Get nominal media rotation rate.
830 // Returns: 0 = not reported, 1 = SSD, >1 = HDD rpm, < 0 = -(Unknown value)
832 
833 // If SMART supported, this is guaranteed to return 1 if SMART is enabled, else 0.
834 int ataDoesSmartWork(ata_device * device);
835 
836 // returns 1 if SMART supported, 0 if not supported or can't tell
837 int ataSmartSupport(const ata_identify_device * drive);
838 
839 // Return values:
840 // 1: Write Cache Reordering enabled
841 // 2: Write Cache Reordering disabled
842 // -1: error
843 int ataGetSetSCTWriteCacheReordering(ata_device * device, bool enable, bool persistent, bool set);
844 
845 // Return values:
846 // 1: Write cache controlled by ATA Set Features command
847 // 2: Force enable write cache
848 // 3: Force disable write cache
849 int ataGetSetSCTWriteCache(ata_device * device, unsigned short state, bool persistent, bool set);
850 
851 // Return values:
852 // 1: SMART enabled
853 // 0: SMART disabled
854 // -1: can't tell if SMART is enabled -- try issuing ataDoesSmartWork command to see
855 int ataIsSmartEnabled(const ata_identify_device * drive);
856 
857 int ataSmartStatus2(ata_device * device);
858 
859 bool isSmartErrorLogCapable(const ata_smart_values * data, const ata_identify_device * identity);
860 
861 bool isSmartTestLogCapable(const ata_smart_values * data, const ata_identify_device * identity);
862 
864 
865 // SMART self-test capability is also indicated in bit 1 of DEVICE
866 // IDENTIFY word 87 (if top two bits of word 87 match pattern 01).
867 // However this was only introduced in ATA-6 (but self-test log was in
868 // ATA-5).
870  { return !!(data->offline_data_collection_capability & 0x01); }
871 
872 // TODO: Remove uses of this check. Bit 1 is vendor specific since ATA-4.
873 // Automatic timer support was only documented for very old IBM drives
874 // (for example IBM Travelstar 40GNX).
876  { return !!(data->offline_data_collection_capability & 0x02); }
877 
879  { return !!(data->offline_data_collection_capability & 0x04); }
880 
882  { return !!(data->offline_data_collection_capability & 0x08); }
883 
885  { return !!(data->offline_data_collection_capability & 0x10); }
886 
888  { return !!(data->offline_data_collection_capability & 0x20); }
889 
891  { return !!(data->offline_data_collection_capability & 0x40); }
892 
893 inline bool isSCTCapable(const ata_identify_device *drive)
894  { return !!(drive->words088_255[206-88] & 0x01); } // 0x01 = SCT support
895 
897  { return ((drive->words088_255[206-88] & 0x09) == 0x09); } // 0x08 = SCT Error Recovery Control support
898 
900  { return ((drive->words088_255[206-88] & 0x11) == 0x11); } // 0x10 = SCT Feature Control support
901 
903  { return ((drive->words088_255[206-88] & 0x21) == 0x21); } // 0x20 = SCT Data Table support
904 
905 int TestTime(const ata_smart_values * data, int testtype);
906 
907 // Attribute state
909 {
910  ATTRSTATE_NON_EXISTING, // No such Attribute
911  ATTRSTATE_NO_NORMVAL, // Normalized value not valid
912  ATTRSTATE_NO_THRESHOLD, // Unknown or no threshold
913  ATTRSTATE_OK, // Never failed
914  ATTRSTATE_FAILED_PAST, // Failed in the past
915  ATTRSTATE_FAILED_NOW // Failed now
916 };
917 
918 // Get attribute state
920  int attridx,
921  const ata_smart_threshold_entry * thresholds,
922  const ata_vendor_attr_defs & defs,
923  unsigned char * threshval = 0);
924 
925 // Get attribute raw value.
926 uint64_t ata_get_attr_raw_value(const ata_smart_attribute & attr,
927  const ata_vendor_attr_defs & defs);
928 
929 // Format attribute raw value.
930 std::string ata_format_attr_raw_value(const ata_smart_attribute & attr,
931  const ata_vendor_attr_defs & defs);
932 
933 // Get attribute name
934 std::string ata_get_smart_attr_name(unsigned char id,
935  const ata_vendor_attr_defs & defs,
936  int rpm = 0);
937 
938 // External handler function, for when a checksum is not correct. Can
939 // simply return if no action is desired, or can print error messages
940 // as needed, or exit. Is passed a string with the name of the Data
941 // Structure with the incorrect checksum.
942 void checksumwarning(const char *string);
943 
944 // Find attribute index for attribute id, -1 if not found.
945 int ata_find_attr_index(unsigned char id, const ata_smart_values & smartval);
946 
947 // Return Temperature Attribute raw value selected according to possible
948 // non-default interpretations. If the Attribute does not exist, return 0
949 unsigned char ata_return_temperature_value(const ata_smart_values * data, const ata_vendor_attr_defs & defs);
950 
951 
952 #define MAX_ATTRIBUTE_NUM 256
953 
954 // Parse vendor attribute display def (-v option).
955 // Return false on error.
956 bool parse_attribute_def(const char * opt, ata_vendor_attr_defs & defs,
957  ata_vendor_def_prior priority);
958 
959 // Get ID and increase flag of current pending or offline
960 // uncorrectable attribute.
961 unsigned char get_unc_attr_id(bool offline, const ata_vendor_attr_defs & defs,
962  bool & increase);
963 
964 // Return a multiline string containing a list of valid arguments for
965 // parse_attribute_def().
967 
968 // Parse firmwarebug def (-F option).
969 // Return false on error.
970 bool parse_firmwarebug_def(const char * opt, firmwarebug_defs & firmwarebugs);
971 
972 // Return a string of valid argument words for parse_firmwarebug_def()
973 const char * get_valid_firmwarebug_args();
974 
975 
976 // These are two of the functions that are defined in os_*.c and need
977 // to be ported to get smartmontools onto another OS.
978 // Moved to C++ interface
979 //int ata_command_interface(int device, smart_command_set command, int select, char *data);
980 //int escalade_command_interface(int fd, int escalade_port, int escalade_type, smart_command_set command, int select, char *data);
981 //int marvell_command_interface(int device, smart_command_set command, int select, char *data);
982 //int highpoint_command_interface(int device, smart_command_set command, int select, char *data);
983 //int areca_command_interface(int fd, int disknum, smart_command_set command, int select, char *data);
984 
985 
986 // This function is exported to give low-level capability
987 int smartcommandhandler(ata_device * device, smart_command_set command, int select, char *data);
988 
989 // Get capacity and sector sizes from IDENTIFY data
991 {
992  uint64_t sectors;
993  uint64_t capacity;
994  unsigned log_sector_size;
995  unsigned phy_sector_size;
997 };
998 
999 void ata_get_size_info(const ata_identify_device * id, ata_size_info & sizes);
1000 
1001 // Convenience function for formatting strings from ata_identify_device.
1002 void ata_format_id_string(char * out, const unsigned char * in, int n);
1003 
1004 // Utility routines.
1005 unsigned char checksum(const void * data);
1006 
1007 // Return pseudo-device to parse "smartctl -r ataioctl,2 ..." output
1008 // and simulate an ATA device with same behaviour
1009 ata_device * get_parsed_ata_device(smart_interface * intf, const char * dev_name);
1010 
1011 #endif /* ATACMDS_H_ */
unsigned short int timestamp
Definition: atacmds.h:405
bool isSmartTestLogCapable(const ata_smart_values *data, const ata_identify_device *identity)
Definition: atacmds.cpp:1752
unsigned short command_set_extension
Definition: atacmds.h:133
int ataSetSCTErrorRecoveryControltime(ata_device *device, unsigned type, unsigned short time_limit)
Definition: atacmds.cpp:2507
unsigned short minor_rev_num
Definition: atacmds.h:130
unsigned char self_test_status
Definition: atacmds.h:437
unsigned char vendor_specific_371
Definition: atacmds.h:215
unsigned char errorlog_capability
Definition: atacmds.h:214
entry & operator[](unsigned char id)
Definition: atacmds.h:707
unsigned short words047_079[33]
Definition: atacmds.h:128
unsigned char reserved[57]
Definition: atacmds.h:310
int ataEnableSmart(ata_device *device)
Definition: atacmds.cpp:1538
unsigned char reserved[10]
Definition: atacmds.h:241
Definition: atacmds.h:464
bool ataReadExtErrorLog(ata_device *device, ata_smart_exterrlog *log, unsigned page, unsigned nsectors, firmwarebug_defs firmwarebugs)
Definition: atacmds.cpp:1493
unsigned char vendor_specific2[507-504+1]
Definition: atacmds.h:498
bool isSupportSelfTest(const ata_smart_values *data)
Definition: atacmds.h:884
unsigned phy_sector_size
Definition: atacmds.h:995
uint64_t end
Definition: atacmds.h:484
int TestTime(const ata_smart_values *data, int testtype)
Definition: atacmds.cpp:1702
#define NUMBER_ATA_SMART_ATTRIBUTES
Definition: atacmds.h:117
unsigned char reserved1
Definition: atacmds.h:452
unsigned short function_code
Definition: atacmds.h:569
unsigned char features_register
Definition: atacmds.h:328
struct test_span span[5]
Definition: atacmds.h:492
int smartcommandhandler(ata_device *device, smart_command_set command, int select, char *data)
Definition: atacmds.cpp:431
unsigned char extended_error[19]
Definition: atacmds.h:270
#define ASSERT_SIZEOF_STRUCT(s, n)
Definition: atacmds.h:25
unsigned char current
Definition: atacmds.h:149
unsigned short currentspan
Definition: atacmds.h:496
unsigned char checksum
Definition: atacmds.h:394
bool ata_set_features(ata_device *device, unsigned char features, int sector_count=-1)
Definition: atacmds.cpp:801
void ata_format_id_string(char *out, const unsigned char *in, int n)
Definition: atacmds.cpp:764
unsigned char reserved[2]
Definition: atacmds.h:420
ata_smart_exterrlog_error error
Definition: atacmds.h:378
unsigned char self_test_type
Definition: atacmds.h:436
unsigned short format_version
Definition: atacmds.h:521
unsigned short csf_default
Definition: atacmds.h:136
int ataSmartSupport(const ata_identify_device *drive)
Definition: atacmds.cpp:938
unsigned short int ata_error_count
Definition: atacmds.h:309
unsigned char device_state
Definition: atacmds.h:525
unsigned char lba_mid_register_hi
Definition: atacmds.h:359
int ataSmartTest(ata_device *device, int testtype, bool force, const ata_selective_selftest_args &args, const ata_smart_values *sv, uint64_t num_sectors)
Definition: atacmds.cpp:1613
unsigned short smart_status
Definition: atacmds.h:541
unsigned char lba_low_register_hi
Definition: atacmds.h:333
unsigned short error_log_index
Definition: atacmds.h:390
unsigned short word086
Definition: atacmds.h:135
bool ataReadExtSelfTestLog(ata_device *device, ata_smart_extselftestlog *log, unsigned nsectors)
Definition: atacmds.cpp:1063
ata_smart_exterrlog_error_log error_logs[4]
Definition: atacmds.h:391
bool isSmartErrorLogCapable(const ata_smart_values *data, const ata_identify_device *identity)
Definition: atacmds.cpp:1733
unsigned char vendor_specific_366
Definition: atacmds.h:211
unsigned char device_control_register
Definition: atacmds.h:327
int ataDisableAutoOffline(ata_device *device)
Definition: atacmds.cpp:1583
unsigned short words020_022[3]
Definition: atacmds.h:125
unsigned char lba_high_register_hi
Definition: atacmds.h:361
unsigned char reserved2[9]
Definition: atacmds.h:393
int ataGetSetSCTWriteCache(ata_device *device, unsigned short state, bool persistent, bool set)
Definition: atacmds.cpp:2358
unsigned char raw[6]
Definition: atacmds.h:151
struct ata_smart_log_entry entry[255]
Definition: atacmds.h:474
unsigned char extend_test_completion_time_b
Definition: atacmds.h:217
unsigned char count_register
Definition: atacmds.h:330
unsigned char lba_low_register_hi
Definition: atacmds.h:357
int ataEnableAutoOffline(ata_device *device)
Definition: atacmds.cpp:1572
unsigned char vendor_specific1[491-338+1]
Definition: atacmds.h:494
unsigned char reserv
Definition: atacmds.h:152
signed char max_temp
Definition: atacmds.h:535
unsigned char vendorspecific[2]
Definition: atacmds.h:418
unsigned char ata_return_temperature_value(const ata_smart_values *data, const ata_vendor_attr_defs &defs)
Definition: atacmds.cpp:2161
entry m_defs[256]
Definition: atacmds.h:714
int ataGetSCTErrorRecoveryControltime(ata_device *device, unsigned type, unsigned short &time_limit)
Definition: atacmds.cpp:2501
bool dont_print_serial_number
Definition: atacmds.cpp:37
int ataWriteSelectiveSelfTestLog(ata_device *device, ata_selective_selftest_args &args, const ata_smart_values *sv, uint64_t num_sectors, const ata_selective_selftest_args *prev_spans=0)
Definition: atacmds.cpp:1215
unsigned char self_test_exec_status
Definition: atacmds.h:209
ata_attr_raw_format
Definition: atacmds.h:655
int ata_get_wwn(const ata_identify_device *id, unsigned &oui, uint64_t &unique_id)
Definition: atacmds.cpp:902
ata_smart_exterrlog_command commands[5]
Definition: atacmds.h:377
uint64_t sectors
Definition: atacmds.h:992
const bool fix_swapped_id
Definition: smartd.cpp:1903
unsigned char offline_data_collection_status
Definition: atacmds.h:208
bool is_set(firmwarebug_t bug) const
Definition: atacmds.h:735
unsigned char get_unc_attr_id(bool offline, const ata_vendor_attr_defs &defs, bool &increase)
Definition: atacmds.cpp:53
unsigned char lba_high_register_hi
Definition: atacmds.h:337
unsigned int lbafirstfailure
Definition: atacmds.h:407
unsigned short function_code
Definition: atacmds.h:584
struct ata_smart_extselftestlog_desc log_descs[19]
Definition: atacmds.h:454
unsigned short log_desc_index
Definition: atacmds.h:453
unsigned char selftestfailurecheckpoint
Definition: atacmds.h:406
int ataReadSCTTempHist(ata_device *device, ata_sct_temperature_history_table *tmh, ata_sct_status_response *sts)
Definition: atacmds.cpp:2222
unsigned char device_register
Definition: atacmds.h:338
unsigned char bytes020_039[20]
Definition: atacmds.h:530
unsigned short sampling_period
Definition: atacmds.h:597
unsigned char chksum
Definition: atacmds.h:253
ata_attr_raw_format raw_format
Definition: atacmds.h:695
uint8_t id
struct ata_smart_attribute vendor_attributes[NUMBER_ATA_SMART_ATTRIBUTES]
Definition: atacmds.h:207
unsigned short command_set_1
Definition: atacmds.h:131
unsigned short action_code
Definition: atacmds.h:568
int ataCheckPowerMode(ata_device *device)
Definition: atacmds.cpp:779
unsigned char count_register_hi
Definition: atacmds.h:331
unsigned short flags
Definition: atacmds.h:148
ptr_t data
Definition: megaraid.h:104
Definition: atacmds.h:238
unsigned short function_code
Definition: atacmds.h:529
unsigned char device_register
Definition: atacmds.h:362
unsigned short command_set_2
Definition: atacmds.h:132
unsigned char vendor_specific_386_510[125]
Definition: atacmds.h:221
int ata_find_attr_index(unsigned char id, const ata_smart_values &smartval)
Definition: atacmds.cpp:2148
bool isGeneralPurposeLoggingCapable(const ata_identify_device *identity)
Definition: atacmds.cpp:1771
int ataReadLogDirectory(ata_device *device, ata_smart_log_directory *, bool gpl)
Definition: atacmds.cpp:1166
unsigned short pendingtime
Definition: atacmds.h:499
uint64_t start
Definition: atacmds.h:483
unsigned char checkpoint
Definition: atacmds.h:439
unsigned short timestamp
Definition: atacmds.h:367
unsigned short ext_status_code
Definition: atacmds.h:527
#define ATTR_PACKED
Definition: atacmds.h:33
const char * get_valid_firmwarebug_args()
Definition: atacmds.cpp:297
unsigned char lba_mid_register
Definition: atacmds.h:334
The platform interface abstraction.
bool isSupportSelectiveSelfTest(const ata_smart_values *data)
Definition: atacmds.h:890
unsigned char reserved
Definition: atacmds.h:466
unsigned short int smart_capability
Definition: atacmds.h:213
unsigned char vendorspecific[15]
Definition: atacmds.h:408
unsigned log_sector_offset
Definition: atacmds.h:996
int ataDisableSmart(ata_device *device)
Definition: atacmds.cpp:1545
unsigned short words088_255[168]
Definition: atacmds.h:137
bool parse_firmwarebug_def(const char *opt, firmwarebug_defs &firmwarebugs)
Definition: atacmds.cpp:277
unsigned char bytes010_029[20]
Definition: atacmds.h:603
unsigned short sct_spec
Definition: atacmds.h:523
unsigned int over_limit_count
Definition: atacmds.h:539
unsigned log_sector_size
Definition: atacmds.h:994
unsigned short device_error_count
Definition: atacmds.h:392
ata_attr_state
Definition: atacmds.h:908
unsigned char extended_error[19]
Definition: atacmds.h:365
unsigned char bytes048_199[152]
Definition: atacmds.h:532
int ataIsSmartEnabled(const ata_identify_device *drive)
Definition: atacmds.cpp:953
bool isSCTCapable(const ata_identify_device *drive)
Definition: atacmds.h:893
ata_vendor_def_prior priority
Definition: atacmds.h:696
unsigned char lba_low_register
Definition: atacmds.h:356
unsigned char lba_low_register
Definition: atacmds.h:332
int ataEnableAutoSave(ata_device *device)
Definition: atacmds.cpp:1553
unsigned char id
Definition: atacmds.h:145
firmwarebug_t
Definition: atacmds.h:719
unsigned short words003_255[253]
Definition: atacmds.h:586
unsigned char numsectors
Definition: atacmds.h:465
bool ataReadSmartLog(ata_device *device, unsigned char logaddr, void *data, unsigned nsectors)
Definition: atacmds.cpp:1145
unsigned char bytes216_479[479-218+1]
Definition: atacmds.h:543
struct ata_smart_errorlog_struct errorlog_struct[5]
Definition: atacmds.h:308
bool ataWriteLogExt(ata_device *device, unsigned char logaddr, unsigned page, void *data, unsigned nsectors)
Definition: atacmds.cpp:1082
int ataGetSetSCTWriteCacheReordering(ata_device *device, bool enable, bool persistent, bool set)
Definition: atacmds.cpp:2351
ata_device * get_parsed_ata_device(smart_interface *intf, const char *dev_name)
Definition: atacmds.cpp:2828
unsigned char revnumber
Definition: atacmds.h:306
unsigned short int total_time_to_complete_off_line
Definition: atacmds.h:210
struct ata_smart_selftestlog_struct selftest_struct[21]
Definition: atacmds.h:417
int ataSmartStatus2(ata_device *device)
Definition: atacmds.cpp:1606
signed char max_op_limit
Definition: atacmds.h:538
unsigned short action_code
Definition: atacmds.h:528
unsigned int timestamp
Definition: atacmds.h:342
int ataReadSCTStatus(ata_device *device, ata_sct_status_response *sts)
Definition: atacmds.cpp:2190
int ataReadSelectiveSelfTestLog(ata_device *device, struct ata_selective_self_test_log *data)
Definition: atacmds.cpp:1186
unsigned char checksum(const void *data)
Definition: atacmds.cpp:718
unsigned char fw_rev[8]
Definition: atacmds.h:126
unsigned char lba_high_register
Definition: atacmds.h:360
int ataSetSCTTempInterval(ata_device *device, unsigned interval, bool persistent)
Definition: atacmds.cpp:2365
std::string ata_get_smart_attr_name(unsigned char id, const ata_vendor_attr_defs &defs, int rpm=0)
Definition: atacmds.cpp:2129
struct ata_smart_errorlog_command_struct commands[5]
Definition: atacmds.h:297
bool ata_nodata_command(ata_device *device, unsigned char command, int sector_count=-1)
Definition: atacmds.cpp:789
unsigned m_bugs
Definition: atacmds.h:745
std::string create_vendor_attribute_arg_list()
Definition: atacmds.cpp:262
void set(firmwarebug_defs bugs)
Definition: atacmds.h:741
unsigned short option_flags
Definition: atacmds.h:572
bool isSupportAutomaticTimer(const ata_smart_values *data)
Definition: atacmds.h:875
bool isSupportExecuteOfflineImmediate(const ata_smart_values *data)
Definition: atacmds.h:869
unsigned char error_register
Definition: atacmds.h:263
Definition: atacmds.h:43
unsigned short cfs_enable_1
Definition: atacmds.h:134
unsigned char reserved_377_385[9]
Definition: atacmds.h:220
unsigned short major_rev_num
Definition: atacmds.h:129
smart_command_set
Definition: atacmds.h:36
void checksumwarning(const char *string)
Definition: smartctl.cpp:1428
unsigned short table_id
Definition: atacmds.h:585
bool isSCTDataTableCapable(const ata_identify_device *drive)
Definition: atacmds.h:902
int ata_read_identity(ata_device *device, ata_identify_device *buf, bool fix_swapped_id, unsigned char *raw_buf=0)
Definition: atacmds.cpp:819
unsigned char chksum
Definition: atacmds.h:421
unsigned char short_test_completion_time
Definition: atacmds.h:216
bool isSupportConveyanceSelfTest(const ata_smart_values *data)
Definition: atacmds.h:887
unsigned char mostrecenttest
Definition: atacmds.h:419
unsigned short sct_version
Definition: atacmds.h:522
unsigned char lba_mid_register
Definition: atacmds.h:358
unsigned char device_control_register
Definition: atacmds.h:352
unsigned short extend_test_completion_time_w
Definition: atacmds.h:219
unsigned char failing_lba[6]
Definition: atacmds.h:440
signed char min_temp
Definition: atacmds.h:534
unsigned short action_code
Definition: atacmds.h:583
unsigned char version
Definition: atacmds.h:388
unsigned short words005_255[251]
Definition: atacmds.h:573
unsigned short words000_009[10]
Definition: atacmds.h:123
unsigned char reserved1[337-82+1]
Definition: atacmds.h:493
unsigned char version
Definition: atacmds.h:451
unsigned char reserved[149]
Definition: atacmds.h:252
ATA device access.
int ataDisableAutoSave(ata_device *device)
Definition: atacmds.cpp:1560
const entry & operator[](unsigned char id) const
Definition: atacmds.h:710
signed char life_min_temp
Definition: atacmds.h:536
unsigned char state
Definition: atacmds.h:366
unsigned char serial_no[20]
Definition: atacmds.h:124
unsigned char bytes011_013[3]
Definition: atacmds.h:526
unsigned short timestamp
Definition: atacmds.h:438
bool isSupportOfflineAbort(const ata_smart_values *data)
Definition: atacmds.h:878
unsigned short int logversion
Definition: atacmds.h:473
int ata_get_rotation_rate(const ata_identify_device *id)
Definition: atacmds.cpp:922
int ataDoesSmartWork(ata_device *device)
Definition: atacmds.cpp:1595
unsigned char conveyance_test_completion_time
Definition: atacmds.h:218
unsigned char chksum
Definition: atacmds.h:222
unsigned char reserved1
Definition: atacmds.h:389
unsigned short feature_code
Definition: atacmds.h:570
struct ata_smart_threshold_entry thres_entries[NUMBER_ATA_SMART_ATTRIBUTES]
Definition: atacmds.h:251
unsigned char selfteststatus
Definition: atacmds.h:404
unsigned char selftestnumber
Definition: atacmds.h:403
unsigned char id
Definition: atacmds.h:239
bool isSCTErrorRecoveryControlCapable(const ata_identify_device *drive)
Definition: atacmds.h:896
unsigned short words004_255[252]
Definition: atacmds.h:558
bool isSupportOfflineSurfaceScan(const ata_smart_values *data)
Definition: atacmds.h:881
unsigned int under_limit_count
Definition: atacmds.h:540
unsigned char offline_data_collection_capability
Definition: atacmds.h:212
signed char life_max_temp
Definition: atacmds.h:537
unsigned short int revnumber
Definition: atacmds.h:416
int ataReadSmartValues(ata_device *device, struct ata_smart_values *)
Definition: atacmds.cpp:969
unsigned char checksum
Definition: atacmds.h:501
unsigned char threshold
Definition: atacmds.h:240
unsigned char ata_debugmode
Definition: atacmds.cpp:33
unsigned char status_register
Definition: atacmds.h:363
unsigned short flags
Definition: atacmds.h:497
const char va_list ap char buf[512+EBUFLEN]
Definition: smartd.cpp:1310
void set(firmwarebug_t bug)
Definition: atacmds.h:738
unsigned char reserved2
Definition: atacmds.h:500
int ataReadSmartThresholds(ata_device *device, struct ata_smart_thresholds_pvt *)
Definition: atacmds.cpp:1520
void ata_get_size_info(const ata_identify_device *id, ata_size_info &sizes)
Definition: atacmds.cpp:660
unsigned short int revnumber
Definition: atacmds.h:206
uint64_t capacity
Definition: atacmds.h:993
ata_attr_state ata_get_attr_state(const ata_smart_attribute &attr, int attridx, const ata_smart_threshold_entry *thresholds, const ata_vendor_attr_defs &defs, unsigned char *threshval=0)
Definition: atacmds.cpp:1798
unsigned char vendor_specific[32]
Definition: atacmds.h:544
unsigned char model[40]
Definition: atacmds.h:127
bool parse_attribute_def(const char *opt, ata_vendor_attr_defs &defs, ata_vendor_def_prior priority)
Definition: atacmds.cpp:149
ata_vendor_def_prior
Definition: atacmds.h:647
unsigned char chksum
Definition: atacmds.h:457
std::string ata_format_attr_raw_value(const ata_smart_attribute &attr, const ata_vendor_attr_defs &defs)
Definition: atacmds.cpp:1922
unsigned char worst
Definition: atacmds.h:150
unsigned int status_flags
Definition: atacmds.h:524
unsigned char error_log_pointer
Definition: atacmds.h:307
unsigned short min_erc_time
Definition: atacmds.h:542
unsigned char lba_mid_register_hi
Definition: atacmds.h:335
Definition: atacmds.h:38
unsigned char checksum
Definition: atacmds.h:311
int ataReadSelfTestLog(ata_device *device, ata_smart_selftestlog *data, firmwarebug_defs firmwarebugs)
Definition: atacmds.cpp:1015
int ataReadErrorLog(ata_device *device, ata_smart_errorlog *data, firmwarebug_defs firmwarebugs)
Definition: atacmds.cpp:1426
unsigned char features_register_hi
Definition: atacmds.h:329
uint64_t ata_get_attr_raw_value(const ata_smart_attribute &attr, const ata_vendor_attr_defs &defs)
Definition: atacmds.cpp:1848
bool isSCTFeatureControlCapable(const ata_identify_device *drive)
Definition: atacmds.h:899
signed char hda_temp
Definition: atacmds.h:533
unsigned char reserved
Definition: atacmds.h:341
unsigned char count_register_hi
Definition: atacmds.h:355
bool ataReadLogExt(ata_device *device, unsigned char logaddr, unsigned char features, unsigned page, void *data, unsigned nsectors)
Definition: atacmds.cpp:1113
struct ata_smart_errorlog_error_struct error_struct
Definition: atacmds.h:298
unsigned char reserved2[11]
Definition: atacmds.h:456
unsigned char command_register
Definition: atacmds.h:339
unsigned char count_register
Definition: atacmds.h:354
unsigned short logversion
Definition: atacmds.h:491
unsigned char vendor_specifc[2]
Definition: atacmds.h:455
unsigned char vendorspecific[15]
Definition: atacmds.h:441
unsigned char error_register
Definition: atacmds.h:353
unsigned char lba_high_register
Definition: atacmds.h:336
unsigned short int revnumber
Definition: atacmds.h:250