diff --git a/src/raspberrypi/controllers/sasidev_ctrl.cpp b/src/raspberrypi/controllers/sasidev_ctrl.cpp index 2ad6a38f..fb2e9a6c 100644 --- a/src/raspberrypi/controllers/sasidev_ctrl.cpp +++ b/src/raspberrypi/controllers/sasidev_ctrl.cpp @@ -18,7 +18,6 @@ #include "gpiobus.h" #include "devices/scsi_host_bridge.h" #include "devices/scsi_daynaport.h" -#include "exceptions.h" #include //=========================================================================== @@ -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(); } } diff --git a/src/raspberrypi/controllers/scsidev_ctrl.cpp b/src/raspberrypi/controllers/scsidev_ctrl.cpp index 8c976a10..5fa0a9de 100644 --- a/src/raspberrypi/controllers/scsidev_ctrl.cpp +++ b/src/raspberrypi/controllers/scsidev_ctrl.cpp @@ -17,7 +17,6 @@ #include "controllers/scsidev_ctrl.h" #include "gpiobus.h" #include "devices/scsi_daynaport.h" -#include "exceptions.h" #include //=========================================================================== @@ -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; -} - diff --git a/src/raspberrypi/controllers/scsidev_ctrl.h b/src/raspberrypi/controllers/scsidev_ctrl.h index 85a89d4b..a54725ce 100644 --- a/src/raspberrypi/controllers/scsidev_ctrl.h +++ b/src/raspberrypi/controllers/scsidev_ctrl.h @@ -119,8 +119,6 @@ private: void Receive(); // Receive data bool XferMsg(DWORD msg); // Data transfer message - DWORD GetLun() const; - scsi_t scsi; // Internal data }; diff --git a/src/raspberrypi/devices/device.cpp b/src/raspberrypi/devices/device.cpp index 1e7f83cd..04350246 100644 --- a/src/raspberrypi/devices/device.cpp +++ b/src/raspberrypi/devices/device.cpp @@ -36,6 +36,7 @@ Device::Device(const string& type) removed = false; lockable = false; locked = false; + block_size_configurable = false; id = 0; lun = 0; diff --git a/src/raspberrypi/devices/disk.cpp b/src/raspberrypi/devices/disk.cpp index 2ccd9475..7d42b6e0 100644 --- a/src/raspberrypi/devices/disk.cpp +++ b/src/raspberrypi/devices/disk.cpp @@ -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); diff --git a/src/raspberrypi/exceptions.h b/src/raspberrypi/exceptions.h index efeaa78c..a078a45d 100644 --- a/src/raspberrypi/exceptions.h +++ b/src/raspberrypi/exceptions.h @@ -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;