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