Skip to content

Commit 4931bcb

Browse files
scsiblockcmds: allow setting density code from outside.
1 parent 9c003a8 commit 4931bcb

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

devices/common/scsi/scsiblockcmds.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ ScsiBlockCmds::ScsiBlockCmds() {
3838
&ScsiBlockCmds::get_error_recovery_page);
3939
}
4040

41-
void ScsiBlockCmds::init_block_device(uint8_t medium_type, uint8_t dev_flags) {
41+
void ScsiBlockCmds::init_block_device(uint8_t medium_type, uint8_t dev_flags,
42+
uint8_t density_code)
43+
{
4244
this->medium_type = medium_type;
4345
this->device_flags = dev_flags;
4446

@@ -215,13 +217,11 @@ int ScsiBlockCmds::read_capacity() {
215217
}
216218

217219
int ScsiBlockCmds::format_block_descriptors(uint8_t* out_ptr) {
218-
uint8_t density_code = 0;
219-
220220
uint32_t nblocks = std::min((int64_t)this->blk_dev->get_size_in_blocks(),
221221
(int64_t)0xFFFFFFFFUL);
222222

223223
WRITE_DWORD_BE_A(&out_ptr[0], nblocks);
224-
WRITE_DWORD_BE_A(&out_ptr[4], (density_code << 24) |
224+
WRITE_DWORD_BE_A(&out_ptr[4], (this->density_code << 24) |
225225
(this->blk_dev->get_block_size() & 0xFFFFFF));
226226

227227
return 8;

devices/common/scsi/scsiblockcmds.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ScsiBlockCmds : public ScsiCommonCmds {
3838
this->blk_dev = blk_dev_obj;
3939
}
4040

41-
void init_block_device(uint8_t medium_type, uint8_t dev_flags);
41+
void init_block_device(uint8_t medium_type, uint8_t dev_flags, uint8_t density_code);
4242

4343
virtual int read_new();
4444
virtual int write_new();
@@ -64,6 +64,7 @@ class ScsiBlockCmds : public ScsiCommonCmds {
6464

6565
uint8_t medium_type = 0;
6666
uint8_t device_flags = 0;
67+
uint8_t density_code = 0;
6768
};
6869

6970
#endif // SCSI_BLOCK_COMMANDS_H

devices/common/scsi/scsihd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void ScsiHardDisk::insert_image(std::string filename) {
6565

6666
this->is_writeable = true;
6767

68-
this->init_block_device(0, 0);
68+
this->init_block_device(0, 0, 0);
6969
}
7070

7171
void ScsiHardDisk::process_command() {

0 commit comments

Comments
 (0)