ScsiDevice: fix process_command() signature.

This commit is contained in:
Maxim Poliakovski 2022-10-27 14:07:20 +02:00
parent f3cd5b8b36
commit a58c9b1a62
5 changed files with 13 additions and 8 deletions

View File

@ -143,6 +143,7 @@ public:
// ScsiDevice methods
void notify(ScsiBus* bus_obj, ScsiMsg msg_type, int param);
bool send_bytes(uint8_t* dst_ptr, int count);
void process_command() {};
protected:
void reset_device();

View File

@ -142,11 +142,13 @@ public:
virtual bool send_bytes(uint8_t* dst_ptr, int count) = 0;
virtual void process_command(uint8_t* cmd) = 0;
virtual void process_command() = 0;
protected:
uint8_t cmd_buf[16] = {};
private:
int scsi_id;
uint8_t cmd_buf[16] = {};
};
/** This class provides a higher level abstraction for the SCSI bus. */

View File

@ -54,7 +54,7 @@ ScsiHardDisk::ScsiHardDisk(int my_id) : ScsiDevice(my_id)
this->hdd_img.seekg(0, std::ios_base::beg);
}
void ScsiHardDisk::process_command(uint8_t* cmd) {
void ScsiHardDisk::process_command() {
uint32_t lba = 0;
uint16_t transfer_len = 0;
uint16_t alloc_len = 0;
@ -63,7 +63,9 @@ void ScsiHardDisk::process_command(uint8_t* cmd) {
uint8_t page_code = 0;
uint8_t subpage_code = 0;
switch (cmd[0]) {
uint8_t* cmd = this->cmd_buf;
switch (cmd[0]) {
case ScsiCommand::TEST_UNIT_READY:
test_unit_ready();
case ScsiCommand::REWIND:
@ -135,7 +137,7 @@ void ScsiHardDisk::inquiry(uint16_t alloc_len) {
memcpy(img_buffer + 16, prod_info, 16);
memcpy(img_buffer + 32, rev_info, 8);
memcpy(img_buffer + 40, serial_info, 8);
}
}
else {
LOG_F(WARNING, "Inappropriate Allocation Length: %d", alloc_len);
}
@ -148,7 +150,7 @@ int ScsiHardDisk::send_diagnostic() {
int ScsiHardDisk::mode_select_6(uint8_t param_len) {
if (param_len == 0) {
return 0x0;
}
}
else {
LOG_F(WARNING, "Mode Select calling for param length of: %d", param_len);
return param_len;

View File

@ -35,7 +35,7 @@ public:
ScsiHardDisk(int my_id);
~ScsiHardDisk() = default;
void process_command(uint8_t* cmd);
void process_command();
bool send_bytes(uint8_t* dst_ptr, int count) { return true; };
int test_unit_ready();

View File

@ -48,7 +48,7 @@ void ScsiDevice::notify(ScsiBus* bus_obj, ScsiMsg msg_type, int param)
LOG_F(WARNING, "ScsiDevice: MESSAGE_OUT isn't supported yet");
}
bus_obj->transfer_command(this->cmd_buf);
//this->process_command();
this->process_command();
bus_obj->switch_phase(this->scsi_id, ScsiPhase::DATA_IN);
});
}