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