1
0
mirror of https://github.com/akuker/RASCSI.git synced 2025-01-22 05:30:50 +00:00

No need anymore for lun_exception

This commit is contained in:
Uwe Seimet 2021-08-23 09:44:03 +02:00
parent edc3bab07a
commit aefcf462cb
6 changed files with 21 additions and 71 deletions

@ -18,7 +18,6 @@
#include "gpiobus.h"
#include "devices/scsi_host_bridge.h"
#include "devices/scsi_daynaport.h"
#include "exceptions.h"
#include <sstream>
//===========================================================================
@ -345,14 +344,7 @@ void SASIDEV::Command()
ctrl.blocks = 0;
// Execution Phase
try {
Execute();
}
catch (const lun_exception& e) {
LOGINFO("%s Invalid LUN %d for ID %d", __PRETTY_FUNCTION__, e.getlun(), GetSCSIID());
Error(ERROR_CODES::sense_key::ILLEGAL_REQUEST, ERROR_CODES::asc::INVALID_LUN);
}
Execute();
}
}

@ -17,7 +17,6 @@
#include "controllers/scsidev_ctrl.h"
#include "gpiobus.h"
#include "devices/scsi_daynaport.h"
#include "exceptions.h"
#include <sstream>
//===========================================================================
@ -248,20 +247,18 @@ void SCSIDEV::Execute()
LOGDEBUG("++++ CMD ++++ %s Executing command $%02X", __PRETTY_FUNCTION__, (unsigned int)ctrl.cmd[0]);
int lun;
try {
if ((SCSIDEV::scsi_command)ctrl.cmd[0] == eCmdInquiry) {
// Use LUN0 for INQUIRY because LUN0 is assumed to be always available
lun = 0;
}
else {
lun = GetLun();
}
if ((SCSIDEV::scsi_command)ctrl.cmd[0] == eCmdInquiry) {
// Use LUN0 for INQUIRY because LUN0 is assumed to be always available
lun = 0;
}
catch (const lun_exception& e) {
LOGINFO("Invalid LUN %d for ID %d", e.getlun(), GetSCSIID());
else {
lun = (ctrl.cmd[1] >> 5) & 0x07;
if (!ctrl.unit[lun]) {
LOGINFO("Invalid LUN %d for ID %d", lun, GetSCSIID());
Error(ERROR_CODES::sense_key::ILLEGAL_REQUEST, ERROR_CODES::asc::INVALID_LUN);
return;
Error(ERROR_CODES::sense_key::ILLEGAL_REQUEST, ERROR_CODES::asc::INVALID_LUN);
return;
}
}
ctrl.device = ctrl.unit[lun];
@ -584,14 +581,7 @@ void SCSIDEV::Receive()
}
// Execution Phase
try {
Execute();
}
catch (const lun_exception& e) {
LOGINFO("%s Invalid LUN %d for ID %d", __PRETTY_FUNCTION__, e.getlun(), GetSCSIID());
Error(ERROR_CODES::sense_key::ILLEGAL_REQUEST, ERROR_CODES::asc::INVALID_LUN);
}
Execute();
break;
// Message out phase
@ -716,18 +706,3 @@ bool SCSIDEV::XferMsg(DWORD msg)
return true;
}
//---------------------------------------------------------------------------
//
// Validate and get LUN
//
//---------------------------------------------------------------------------
DWORD SCSIDEV::GetLun() const
{
DWORD lun = (ctrl.cmd[1] >> 5) & 0x07;
if (!ctrl.unit[lun]) {
throw lun_exception(lun);
}
return lun;
}

@ -119,8 +119,6 @@ private:
void Receive(); // Receive data
bool XferMsg(DWORD msg); // Data transfer message
DWORD GetLun() const;
scsi_t scsi; // Internal data
};

@ -36,6 +36,7 @@ Device::Device(const string& type)
removed = false;
lockable = false;
locked = false;
block_size_configurable = false;
id = 0;
lun = 0;

@ -381,20 +381,17 @@ void Disk::Rezero(SASIDEV *controller)
void Disk::RequestSense(SASIDEV *controller)
{
DWORD lun;
try {
lun = GetLun();
}
catch(const lun_exception& e) {
// Note: According to the SCSI specs the LUN handling for REQUEST SENSE is special.
// Non-existing LUNs do *not* result in CHECK CONDITION.
// Only the Sense Key and ASC are set in order to signal the non-existing LUN.
DWORD lun = (ctrl->cmd[1] >> 5) & 0x07;
// Note: According to the SCSI specs the LUN handling for REQUEST SENSE is special.
// Non-existing LUNs do *not* result in CHECK CONDITION.
// Only the Sense Key and ASC are set in order to signal the non-existing LUN.
if (!ctrl->unit[lun]) {
// LUN 0 can be assumed to be present (required to call RequestSense() below)
lun = 0;
lun = 0;
controller->Error(ERROR_CODES::sense_key::ILLEGAL_REQUEST, ERROR_CODES::asc::INVALID_LUN);
}
controller->Error(ERROR_CODES::sense_key::ILLEGAL_REQUEST, ERROR_CODES::asc::INVALID_LUN);
}
ctrl->length = ctrl->unit[lun]->RequestSense(ctrl->cmd, ctrl->buffer);
ASSERT(ctrl->length > 0);

@ -29,19 +29,6 @@ public:
}
};
class lun_exception final : public exception {
private:
int lun;
public:
lun_exception(int _lun) : lun(_lun) {}
~lun_exception() {}
int getlun() const {
return lun;
}
};
class io_exception : public exception {
private:
string msg;