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