84 uint16_t crc_final = 0;
90 for (uint32_t ii = 0; ii < 16; ii++) {
96 total_len = check_crc ? len : len + 2;
99 for (uint32_t ii = 0; ii < total_len; ii++) {
103 for (uint32_t jj = 0; jj < 8; jj++) {
105 data_msb = (
data >> (8 - jj - 1)) & 1;
107 crc[15] = crc[14] ^ crc_msb;
111 crc[11] = crc[10] ^ crc_msb;
113 crc[9] = crc[8] ^ crc_msb;
114 crc[8] = crc[7] ^ crc_msb;
115 crc[7] = crc[6] ^ crc_msb;
117 crc[5] = crc[4] ^ crc_msb;
118 crc[4] = crc[3] ^ crc_msb;
120 crc[2] = crc[1] ^ crc_msb;
121 crc[1] = crc[0] ^ crc_msb;
122 crc[0] = data_msb ^ crc_msb;
127 for (uint32_t ii = 0; ii < 16; ii++) {
129 crc_final |= (1 << ii);
131 crc_final &= ~(1 << ii);
140 pout(
"Dumping LOG Structure:\n");
148 pout(
" variant: \"");
149 for (
int ii = 0; ii < 8; ii++) {
168 pout(
" crc: 0x%04x\n", log->
crc);
177 return device->
set_err(EIO,
"intelliprop: Initial Read Log failed: %s", device->
get_errmsg());
180 uint16_t
const crc_check =
iprop_crc16_1((uint8_t *)&write_payload,
187 if (crc_check != 0) {
189 pout(
"Intelliprop WARNING: Received log crc(0x%04X) is invalid!\n", crc_check);
206 uint16_t
const crc_new =
iprop_crc16_1((uint8_t *)&write_payload,
209 write_payload.
crc = (crc_new >> 8) | (crc_new << 8);
212 uint16_t
const crc_check2 =
iprop_crc16_1((uint8_t *)&write_payload,
216 return device->
set_err(EIO,
"intelliprop: Re-calculated log crc(0x%04X) is invalid!", crc_check2);
220 return device->
set_err(EIO,
"intelliprop: Write Log failed: %s", device->
get_errmsg());
225 return device->
set_err(EIO,
"intelliprop: Secondary Read Log failed: %s", device->
get_errmsg());
230 return device->
set_err(EIO,
"intelliprop: Current drive select val(0x%08X) is not expected(0x%08X)",
251 virtual bool open()
override;
261:
smart_device(intf, atadev->get_dev_name(),
"intelliprop",
"intelliprop"),
297 unsigned phydrive = ~0;
int n = -1;
298 sscanf(type,
"intelliprop,%u,force%n", &phydrive, &n);
300 if (n != (
int)strlen(type))
302 "The device type 'intelliprop' is deprecated and will be removed in a\n"
303 "future version of smartmontools. If this device type is still needed, please\n"
304 "use '-d intelliprop,N,force' and inform " PACKAGE_BUGREPORT );
306 return set_err_np(EINVAL,
"Option '-d intelliprop,N,force' must have 0 <= N <= 3");
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)
unsigned char ata_debugmode
Smart pointer class for device pointers.
device_type * release()
Return the pointer and release ownership.
virtual bool ata_pass_through(const ata_cmd_in &in, ata_cmd_out &out)=0
ATA pass through.
intelliprop_device(smart_interface *intf, unsigned phydrive, ata_device *atadev)
virtual bool open() override
Open device, return false on error.
virtual bool ata_pass_through(const ata_cmd_in &in, ata_cmd_out &out) override
ATA pass through.
virtual ~intelliprop_device()
Base class for all devices.
const error_info & get_err() const
Get last error info struct.
const char * get_errmsg() const
Get last error message.
bool set_err(int no, const char *msg,...) __attribute_format_printf(3
Set last error number and message.
const char * get_info_name() const
Get informal name.
device_info & set_info()
R/W access to device info struct.
The platform interface abstraction.
virtual ata_device * get_intelliprop_device(const char *type, ata_device *atadev)
Return filter for Intelliprop controllers.
bool decltype(nullptr) set_err_np(int no, const char *msg,...) __attribute_format_printf(3
Set last error number and message.
virtual bool close() override
Close device, return false on error.
Implement a device by tunneling through another device.
tunnel_device_type * get_tunnel_dev()
const char * dev_intelliprop_cpp_cvsid
static bool iprop_switch_routed_drive(ata_device *device, int drive_select)
@ IPROP_VS_LOG_PORT_TX_VOD_MASK
@ IPROP_VS_LOG_PORT_TX_PREEMP_SHIFT
@ IPROP_VS_LOG_PORT_TX_PREEMP_MASK
@ IPROP_VS_LOG_PORT_RX_EQ_SHIFT
@ IPROP_VS_LOG_PORT_WRITE_ENABLE_VALID
@ IPROP_VS_LOG_PORT_WRITE_ENABLE_MASK
@ IPROP_VS_LOG_PORT_RX_DC_GAIN_MASK
@ IPROP_VS_LOG_PORT_RX_EQ_MASK
@ IPROP_VS_LOG_PORT_RX_DC_GAIN_SHIFT
@ IPROP_VS_LOG_PORT_TX_VOD_SHIFT
static void iprop_dump_log_structure(struct iprop_internal_log const *const log)
@ IPROP_VS_LOG_MODE_CTL_AUTO_ENABLED
@ IPROP_VS_LOG_MODE_CTL_MANUAL_ENABLED
@ IPROP_VS_LOG_MODE_CTL_MANUAL_SUPPORTED
@ IPROP_VS_LOG_MODE_CTL_AUTO_SUPPORTED
static uint16_t iprop_crc16_1(uint8_t *buffer, uint32_t len, bool check_crc)
buffer is a pointer to a buffer of bytes, which should include data and also CRC if the function is b...
struct iprop_internal_log ATTR_PACKED
void pout(const char *fmt,...)
ATA pass through input parameters.
ATA pass through output parameters.
uint16_t port_1_settings[3]
uint16_t port_0_settings[3]
uint16_t port_3_settings[3]
uint16_t port_2_settings[3]
uint16_t port_4_settings[3]
std::string info_name
Informal name.
std::string strprintf(const char *fmt,...)