Use ScsiError constants instead of magic numbers.

This commit is contained in:
Maxim Poliakovski 2024-07-14 17:21:33 +02:00
parent a81156c3e3
commit 7855770ca7
2 changed files with 8 additions and 10 deletions

View File

@ -239,7 +239,7 @@ void ScsiCdrom::mode_sense_6()
LOG_F(WARNING, "%s: unsupported page 0x%02x in MODE_SENSE_6", this->name.c_str(), page_code);
this->status = ScsiStatus::CHECK_CONDITION;
this->sense = ScsiSense::ILLEGAL_REQ;
this->asc = 0x24; // Invalid Field in CDB
this->asc = ScsiError::INVALID_CDB;
this->ascq = 0;
this->sksv = 0xc0; // sksv=1, C/D=Command, BPV=0, BP=0
this->field = 2;
@ -300,7 +300,7 @@ void ScsiCdrom::read_toc()
start_track);
this->status = ScsiStatus::CHECK_CONDITION;
this->sense = ScsiSense::ILLEGAL_REQ;
this->asc = 0x24; // Invalid Field in CDB
this->asc = ScsiError::INVALID_CDB;
this->ascq = 0;
this->sksv = 0xc0; // sksv=1, C/D=Command, BPV=0, BP=0
this->field = 6; // offset of start_track
@ -361,7 +361,7 @@ void ScsiCdrom::read_capacity_10()
LOG_F(ERROR, "%s: non-zero LBA for PMI=0", this->name.c_str());
this->status = ScsiStatus::CHECK_CONDITION;
this->sense = ScsiSense::ILLEGAL_REQ;
this->asc = 0x24; // Invalid Field in CDB
this->asc = ScsiError::INVALID_CDB;
this->ascq = 0;
this->sksv = 0xc0; // sksv=1, C/D=Command, BPV=0, BP=0
this->field = 8;

View File

@ -221,13 +221,12 @@ int ScsiDevice::rcv_data(const uint8_t* src_ptr, const int count)
return count;
}
bool ScsiDevice::check_lun()
{
bool ScsiDevice::check_lun() {
if (this->cmd_buf[1] >> 5 != this->lun) {
LOG_F(ERROR, "%s: non-matching LUN", this->name.c_str());
this->status = ScsiStatus::CHECK_CONDITION;
this->sense = ScsiSense::ILLEGAL_REQ;
this->asc = 0x25; // Logical Unit Not Supported
this->asc = ScsiError::INVALID_LUN;
this->ascq = 0;
this->sksv = 0;
this->field = 0;
@ -237,14 +236,13 @@ bool ScsiDevice::check_lun()
return true;
}
void ScsiDevice::illegal_command(const uint8_t *cmd)
{
void ScsiDevice::illegal_command(const uint8_t *cmd) {
LOG_F(ERROR, "%s: unsupported command: 0x%02x", this->name.c_str(), cmd[0]);
this->status = ScsiStatus::CHECK_CONDITION;
this->sense = ScsiSense::ILLEGAL_REQ;
this->asc = 0x20; // Invalid command operation code
this->asc = ScsiError::INVALID_CMD;
this->ascq = 0;
this->sksv = 0xc0; // sksv=1, C/D=Command, BPV=0, BP=0
this->sksv = 0xC0; // sksv=1, C/D=Command, BPV=0, BP=0
this->field = 0;
this->switch_phase(ScsiPhase::STATUS);
}