@@ -105,13 +105,13 @@ int AtaHardDisk::perform_command() {
105
105
uint64_t offset = this ->get_lba () * ATA_HD_SEC_SIZE;
106
106
uint32_t ints_size = ATA_HD_SEC_SIZE;
107
107
if (this ->r_command == READ_MULTIPLE) {
108
- if (this ->sec_per_block == 0 ) {
109
- LOG_F (ERROR, " %s: cannot do a READ_MULTIPLE with unset sec_per_block " , this ->name .c_str ());
108
+ if (! this ->sectors_per_int ) {
109
+ LOG_F (ERROR, " %s: READ_MULTIPLE disabled " , this ->name .c_str ());
110
110
this ->r_status |= ERR;
111
111
this ->r_status &= ~BSY;
112
112
break ;
113
113
}
114
- ints_size *= this ->sec_per_block ;
114
+ ints_size *= this ->sectors_per_int ;
115
115
}
116
116
hdd_img.read (buffer, offset, xfer_size);
117
117
this ->data_ptr = (uint16_t *)this ->buffer ;
@@ -130,13 +130,13 @@ int AtaHardDisk::perform_command() {
130
130
uint32_t xfer_size = sec_count * ATA_HD_SEC_SIZE;
131
131
uint32_t ints_size = ATA_HD_SEC_SIZE;
132
132
if (this ->r_command == WRITE_MULTIPLE) {
133
- if (this ->sec_per_block == 0 ) {
134
- LOG_F (ERROR, " %s: cannot do a WRITE_MULTIPLE with unset sec_per_block " , this ->name .c_str ());
133
+ if (! this ->sectors_per_int ) {
134
+ LOG_F (ERROR, " %s: WRITE_MULTIPLE disabled " , this ->name .c_str ());
135
135
this ->r_status |= ERR;
136
136
this ->r_status &= ~BSY;
137
137
break ;
138
138
}
139
- ints_size *= this ->sec_per_block ;
139
+ ints_size *= this ->sectors_per_int ;
140
140
}
141
141
this ->prepare_xfer (xfer_size, ints_size);
142
142
this ->post_xfer_action = [this ]() {
@@ -154,8 +154,7 @@ int AtaHardDisk::perform_command() {
154
154
this ->r_status &= ~BSY;
155
155
this ->update_intrq (1 );
156
156
break ;
157
- case READ_VERIFY:
158
- // verify sectors are readable, just no-op
157
+ case READ_VERIFY: // verify sectors are readable, just no-op
159
158
this ->r_status &= ~BSY;
160
159
this ->update_intrq (1 );
161
160
break ;
@@ -167,16 +166,16 @@ int AtaHardDisk::perform_command() {
167
166
this ->update_intrq (1 );
168
167
break ;
169
168
case SET_MULTIPLE_MODE: // this command is mandatory for ATA devices
170
- if (!this ->r_sect_count || this ->r_sect_count > 128 ||
169
+ if (!this ->r_sect_count || this ->r_sect_count > SECTORS_PER_INT ||
171
170
std::bitset<8 >(this ->r_sect_count ).count () != 1 ) { // power of two?
172
- LOG_F (ERROR, " %s: SET_MULTIPLE_MODE not suported, invalid r_sect_count (%d) " , this -> name . c_str (), this -> r_sect_count );
173
- this ->multiple_enabled = false ;
171
+ LOG_F (ERROR, " %s: invalid parameter %d for SET_MULTIPLE_MODE " ,
172
+ this ->name . c_str (), this -> r_sect_count ) ;
174
173
this ->r_error |= ABRT;
175
174
this ->r_status |= ERR;
176
175
} else {
177
- LOG_F (INFO , " %s: SET_MULTIPLE_MODE, r_sect_count=%d" , this ->name .c_str (), this -> r_sect_count );
178
- this -> sec_per_block = this ->r_sect_count ;
179
- this ->multiple_enabled = true ;
176
+ LOG_F (9 , " %s: SET_MULTIPLE_MODE, r_sect_count=%d" , this ->name .c_str (),
177
+ this ->r_sect_count ) ;
178
+ this ->sectors_per_int = this -> r_sect_count ;
180
179
}
181
180
this ->r_status &= ~BSY;
182
181
this ->update_intrq (1 );
@@ -242,16 +241,13 @@ void AtaHardDisk::prepare_identify_info() {
242
241
243
242
// Maximum number of logical sectors per data block that the device supports
244
243
// for READ_MULTIPLE/WRITE_MULTIPLE commands.
245
- const int max_sec_per_block = 8 ;
246
- if (max_sec_per_block > 1 ) {
247
- buf_ptr[47 ] = 0x8000 | max_sec_per_block;
248
- }
244
+ buf_ptr[47 ] = 0x8000 | SECTORS_PER_INT;
245
+
249
246
// If bit 8 of word 59 is set to one, then bits 7:0 indicate the number of
250
247
// logical sectors that shall be transferred per data block for
251
248
// READ_MULTIPLE/WRITE_MULTIPLE commands.
252
- if (this ->sec_per_block ) {
253
- buf_ptr[59 ] = 0x100 | this ->sec_per_block ;
254
- }
249
+ if (this ->sectors_per_int )
250
+ buf_ptr[59 ] = 0x100 | this ->sectors_per_int ;
255
251
256
252
buf_ptr[ 1 ] = this ->cylinders ;
257
253
buf_ptr[ 3 ] = this ->heads ;
0 commit comments