16#define ATACMDS_H_CVSID "$Id: atacmds.h 5166 2021-01-15 18:02:19Z chrfranke $"
23#ifdef HAVE_ATTR_PACKED
24#define ATTR_PACKED __attribute__((packed))
52#define ATA_CHECK_POWER_MODE 0xe5
53#define ATA_IDENTIFY_DEVICE 0xec
54#define ATA_IDENTIFY_PACKET_DEVICE 0xa1
56#define ATA_SMART_CMD 0xb0
57#define ATA_SECURITY_FREEZE_LOCK 0xf5
58#ifndef ATA_SET_FEATURES
59#define ATA_SET_FEATURES 0xef
61#define ATA_STANDBY 0xe2
62#define ATA_STANDBY_IMMEDIATE 0xe0
65#define ATA_DISABLE_AAM 0xc2
66#define ATA_DISABLE_APM 0x85
67#define ATA_DISABLE_WRITE_CACHE 0x82
68#define ATA_DISABLE_READ_LOOK_AHEAD 0x55
69#define ATA_ENABLE_AAM 0x42
70#define ATA_ENABLE_APM 0x05
71#define ATA_ENABLE_WRITE_CACHE 0x02
72#define ATA_ENABLE_READ_LOOK_AHEAD 0xaa
73#define ATA_ENABLE_DISABLE_DSN 0x63
76#define ATA_READ_LOG_EXT 0x2F
77#define ATA_WRITE_LOG_EXT 0x3f
81#define ATA_SMART_READ_VALUES 0xd0
82#define ATA_SMART_READ_THRESHOLDS 0xd1
83#define ATA_SMART_AUTOSAVE 0xd2
84#define ATA_SMART_SAVE 0xd3
85#define ATA_SMART_IMMEDIATE_OFFLINE 0xd4
86#define ATA_SMART_READ_LOG_SECTOR 0xd5
87#define ATA_SMART_WRITE_LOG_SECTOR 0xd6
88#define ATA_SMART_WRITE_THRESHOLDS 0xd7
89#define ATA_SMART_ENABLE 0xd8
90#define ATA_SMART_DISABLE 0xd9
91#define ATA_SMART_STATUS 0xda
94#define ATA_SMART_AUTO_OFFLINE 0xdb
97#define OFFLINE_FULL_SCAN 0
98#define SHORT_SELF_TEST 1
99#define EXTEND_SELF_TEST 2
100#define CONVEYANCE_SELF_TEST 3
101#define SELECTIVE_SELF_TEST 4
102#define ABORT_SELF_TEST 127
103#define SHORT_CAPTIVE_SELF_TEST 129
104#define EXTEND_CAPTIVE_SELF_TEST 130
105#define CONVEYANCE_CAPTIVE_SELF_TEST 131
106#define SELECTIVE_CAPTIVE_SELF_TEST 132
107#define CAPTIVE_MASK (0x01<<7)
110#define NUMBER_ATA_SMART_ATTRIBUTES 30
164#define ATTRIBUTE_FLAGS_PREFAILURE(x) (x & 0x01)
174#define ATTRIBUTE_FLAGS_ONLINE(x) (x & 0x02)
180#define ATTRIBUTE_FLAGS_PERFORMANCE(x) (x & 0x04)
183#define ATTRIBUTE_FLAGS_ERRORRATE(x) (x & 0x08)
186#define ATTRIBUTE_FLAGS_EVENTCOUNT(x) (x & 0x10)
189#define ATTRIBUTE_FLAGS_SELFPRESERVING(x) (x & 0x20)
192#define ATTRIBUTE_FLAGS_OTHER(x) ((x) & 0xffc0)
499#define SELECTIVE_FLAG_DOSCAN (0x0002)
500#define SELECTIVE_FLAG_PENDING (0x0008)
501#define SELECTIVE_FLAG_ACTIVE (0x0010)
729 {
return !!(
m_bugs & (1 << bug)); }
750 unsigned char * raw_buf = 0);
771 unsigned page,
void *
data,
unsigned nsectors);
775 unsigned char features,
unsigned page,
776 void *
data,
unsigned nsectors);
779 void *
data,
unsigned nsectors);
863 {
return !!(
data->offline_data_collection_capability & 0x01); }
869 {
return !!(
data->offline_data_collection_capability & 0x02); }
872 {
return !!(
data->offline_data_collection_capability & 0x04); }
875 {
return !!(
data->offline_data_collection_capability & 0x08); }
878 {
return !!(
data->offline_data_collection_capability & 0x10); }
881 {
return !!(
data->offline_data_collection_capability & 0x20); }
884 {
return !!(
data->offline_data_collection_capability & 0x40); }
890 {
return ((drive->
words088_255[206-88] & 0x09) == 0x09); }
893 {
return ((drive->
words088_255[206-88] & 0x11) == 0x11); }
896 {
return ((drive->
words088_255[206-88] & 0x21) == 0x21); }
916 unsigned char * threshval = 0);
945#define MAX_ATTRIBUTE_NUM 256
int ataDisableAutoOffline(ata_device *device)
unsigned char ata_return_temperature_value(const ata_smart_values *data, const ata_vendor_attr_defs &defs)
bool isSmartErrorLogCapable(const ata_smart_values *data, const ata_identify_device *identity)
int ataGetSCTErrorRecoveryControltime(ata_device *device, unsigned type, unsigned short &time_limit, bool power_on)
bool ataReadSmartLog(ata_device *device, unsigned char logaddr, void *data, unsigned nsectors)
int ata_get_wwn(const ata_identify_device *id, unsigned &oui, uint64_t &unique_id)
bool isSupportSelfTest(const ata_smart_values *data)
int ataSmartTest(ata_device *device, int testtype, bool force, const ata_selective_selftest_args &args, const ata_smart_values *sv, uint64_t num_sectors)
ata_device * get_parsed_ata_device(smart_interface *intf, const char *dev_name)
int ataEnableAutoOffline(ata_device *device)
bool isSCTErrorRecoveryControlCapable(const ata_identify_device *drive)
int ataSmartStatus2(ata_device *device)
int ataReadLogDirectory(ata_device *device, ata_smart_log_directory *, bool gpl)
bool isSupportOfflineSurfaceScan(const ata_smart_values *data)
int ataSmartSupport(const ata_identify_device *drive)
int ataDisableAutoSave(ata_device *device)
int ata_get_rotation_rate(const ata_identify_device *id)
unsigned char get_unc_attr_id(bool offline, const ata_vendor_attr_defs &defs, bool &increase)
bool ataWriteLogExt(ata_device *device, unsigned char logaddr, unsigned page, void *data, unsigned nsectors)
bool ataReadLogExt(ata_device *device, unsigned char logaddr, unsigned char features, unsigned page, void *data, unsigned nsectors)
bool parse_attribute_def(const char *opt, ata_vendor_attr_defs &defs, ata_vendor_def_prior priority)
int ataEnableAutoSave(ata_device *device)
int ataReadSelfTestLog(ata_device *device, ata_smart_selftestlog *data, firmwarebug_defs firmwarebugs)
bool isSupportConveyanceSelfTest(const ata_smart_values *data)
std::string ata_format_attr_raw_value(const ata_smart_attribute &attr, const ata_vendor_attr_defs &defs)
int ataReadSCTTempHist(ata_device *device, ata_sct_temperature_history_table *tmh, ata_sct_status_response *sts)
std::string ata_get_smart_attr_name(unsigned char id, const ata_vendor_attr_defs &defs, int rpm=0)
int ata_find_attr_index(unsigned char id, const ata_smart_values &smartval)
void checksumwarning(const char *string)
int ataReadErrorLog(ata_device *device, ata_smart_errorlog *data, firmwarebug_defs firmwarebugs)
void ata_get_size_info(const ata_identify_device *id, ata_size_info &sizes)
int ataReadSmartThresholds(ata_device *device, struct ata_smart_thresholds_pvt *)
int TestTime(const ata_smart_values *data, int testtype)
int ataEnableSmart(ata_device *device)
int smartcommandhandler(ata_device *device, smart_command_set command, int select, char *data)
bool isGeneralPurposeLoggingCapable(const ata_identify_device *identity)
int ataCheckPowerMode(ata_device *device)
int ataReadSmartValues(ata_device *device, struct ata_smart_values *)
bool ata_nodata_command(ata_device *device, unsigned char command, int sector_count=-1)
int ataGetSetSCTWriteCacheReordering(ata_device *device, bool enable, bool persistent, bool set)
unsigned char checksum(const void *data)
bool ataReadExtSelfTestLog(ata_device *device, ata_smart_extselftestlog *log, unsigned nsectors)
bool isSupportAutomaticTimer(const ata_smart_values *data)
int ataReadSelectiveSelfTestLog(ata_device *device, struct ata_selective_self_test_log *data)
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)
std::string create_vendor_attribute_arg_list()
bool isSmartTestLogCapable(const ata_smart_values *data, const ata_identify_device *identity)
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)
bool parse_firmwarebug_def(const char *opt, firmwarebug_defs &firmwarebugs)
bool isSupportSelectiveSelfTest(const ata_smart_values *data)
bool isSCTDataTableCapable(const ata_identify_device *drive)
int ataSetSCTErrorRecoveryControltime(ata_device *device, unsigned type, unsigned short time_limit, bool power_on, bool mfg_default)
bool isSupportExecuteOfflineImmediate(const ata_smart_values *data)
unsigned char ata_debugmode
int ataDoesSmartWork(ata_device *device)
bool isSupportOfflineAbort(const ata_smart_values *data)
const char * get_valid_firmwarebug_args()
uint64_t ata_get_attr_raw_value(const ata_smart_attribute &attr, const ata_vendor_attr_defs &defs)
bool dont_print_serial_number
int ataReadSCTStatus(ata_device *device, ata_sct_status_response *sts)
bool ataReadExtErrorLog(ata_device *device, ata_smart_exterrlog *log, unsigned page, unsigned nsectors, firmwarebug_defs firmwarebugs)
int ataDisableSmart(ata_device *device)
int ataSetSCTTempInterval(ata_device *device, unsigned interval, bool persistent)
int ataGetSetSCTWriteCache(ata_device *device, unsigned short state, bool persistent, bool set)
#define NUMBER_ATA_SMART_ATTRIBUTES
int ataIsSmartEnabled(const ata_identify_device *drive)
void ata_format_id_string(char *out, const unsigned char *in, int n)
bool isSCTFeatureControlCapable(const ata_identify_device *drive)
int ata_read_identity(ata_device *device, ata_identify_device *buf, bool fix_swapped_id, unsigned char *raw_buf=0)
bool isSCTCapable(const ata_identify_device *drive)
bool ata_set_features(ata_device *device, unsigned char features, int sector_count=-1)
const entry & operator[](unsigned char id) const
entry & operator[](unsigned char id)
void set(firmwarebug_t bug)
void set(firmwarebug_defs bugs)
bool is_set(firmwarebug_t bug) const
The platform interface abstraction.
const bool fix_swapped_id
unsigned short minor_rev_num
unsigned short major_rev_num
unsigned short words047_079[33]
unsigned short cfs_enable_1
unsigned short words088_255[168]
unsigned short csf_default
unsigned short words000_009[10]
unsigned short command_set_2
unsigned short command_set_1
unsigned char serial_no[20]
unsigned short command_set_extension
unsigned short words020_022[3]
unsigned short words003_255[253]
unsigned short action_code
unsigned short function_code
unsigned short action_code
unsigned short time_limit
unsigned short selection_code
unsigned short function_code
unsigned short words004_255[252]
unsigned short action_code
unsigned short option_flags
unsigned short feature_code
unsigned short function_code
unsigned short words005_255[251]
unsigned int over_limit_count
unsigned char bytes011_013[3]
unsigned short action_code
unsigned short min_erc_time
unsigned short sct_version
unsigned short format_version
signed char life_max_temp
unsigned short ext_status_code
unsigned char vendor_specific[32]
unsigned int status_flags
unsigned char bytes216_479[479-218+1]
unsigned short function_code
unsigned char device_state
unsigned char bytes048_199[152]
unsigned char bytes020_039[20]
unsigned int under_limit_count
signed char life_min_temp
unsigned short smart_status
unsigned short sampling_period
unsigned char bytes010_029[20]
unsigned short format_version
unsigned char vendor_specific1[491-338+1]
unsigned short pendingtime
unsigned short logversion
unsigned char vendor_specific2[507-504+1]
unsigned short currentspan
unsigned char reserved1[337-82+1]
ata_selective_selftest_args()
unsigned log_sector_offset
unsigned char devicecontrolreg
unsigned char cylinder_high
unsigned char cylinder_low
unsigned char featuresreg
unsigned char sector_count
unsigned char sector_number
unsigned char cylinder_low
unsigned char extended_error[19]
unsigned char sector_count
unsigned char sector_number
unsigned char cylinder_high
unsigned char error_register
struct ata_smart_errorlog_command_struct commands[5]
struct ata_smart_errorlog_error_struct error_struct
unsigned short int ata_error_count
unsigned char error_log_pointer
unsigned char reserved[57]
struct ata_smart_errorlog_struct errorlog_struct[5]
unsigned char count_register_hi
unsigned char device_register
unsigned char lba_low_register
unsigned char lba_high_register
unsigned char lba_mid_register_hi
unsigned char device_control_register
unsigned char command_register
unsigned char lba_mid_register
unsigned char count_register
unsigned char features_register
unsigned char lba_low_register_hi
unsigned char lba_high_register_hi
unsigned char features_register_hi
ata_smart_exterrlog_command commands[5]
ata_smart_exterrlog_error error
unsigned char device_control_register
unsigned char lba_low_register_hi
unsigned char lba_low_register
unsigned char count_register
unsigned char error_register
unsigned char count_register_hi
unsigned char extended_error[19]
unsigned char lba_high_register_hi
unsigned char device_register
unsigned char status_register
unsigned char lba_mid_register
unsigned char lba_mid_register_hi
unsigned char lba_high_register
unsigned short error_log_index
ata_smart_exterrlog_error_log error_logs[4]
unsigned char reserved2[9]
unsigned short device_error_count
unsigned char self_test_type
unsigned char failing_lba[6]
unsigned char vendorspecific[15]
unsigned char self_test_status
unsigned char vendor_specifc[2]
unsigned char reserved2[11]
struct ata_smart_extselftestlog_desc log_descs[19]
unsigned short log_desc_index
struct ata_smart_log_entry entry[255]
unsigned short int logversion
unsigned int lbafirstfailure
unsigned char vendorspecific[15]
unsigned char selftestnumber
unsigned char selftestfailurecheckpoint
unsigned char selfteststatus
unsigned short int timestamp
unsigned char reserved[2]
unsigned char mostrecenttest
struct ata_smart_selftestlog_struct selftest_struct[21]
unsigned char vendorspecific[2]
unsigned short int revnumber
unsigned char reserved[10]
unsigned short int revnumber
struct ata_smart_threshold_entry thres_entries[NUMBER_ATA_SMART_ATTRIBUTES]
unsigned char reserved[149]
unsigned short extend_test_completion_time_w
unsigned char errorlog_capability
unsigned char extend_test_completion_time_b
unsigned char self_test_exec_status
unsigned short int smart_capability
unsigned char vendor_specific_371
unsigned char short_test_completion_time
unsigned char vendor_specific_386_510[125]
unsigned char vendor_specific_366
unsigned char offline_data_collection_capability
unsigned char conveyance_test_completion_time
unsigned char offline_data_collection_status
unsigned char reserved_377_385[9]
unsigned short int total_time_to_complete_off_line
unsigned short int revnumber
struct ata_smart_attribute vendor_attributes[NUMBER_ATA_SMART_ATTRIBUTES]
ata_attr_raw_format raw_format
ata_vendor_def_prior priority