diff --git a/src/raspberrypi/devices/host_services.cpp b/src/raspberrypi/devices/host_services.cpp index 844870c6..f5dd0d75 100644 --- a/src/raspberrypi/devices/host_services.cpp +++ b/src/raspberrypi/devices/host_services.cpp @@ -59,8 +59,7 @@ void HostServices::TestUnitReady(SCSIDEV *controller) vector HostServices::Inquiry() const { - // Processor device, SPC-5, not removable - return PrimaryDevice::Inquiry(3, 7, false); + return PrimaryDevice::Inquiry(device_type::PROCESSOR, scsi_level::SPC_5, false); } void HostServices::StartStopUnit(SCSIDEV *controller) diff --git a/src/raspberrypi/devices/primary_device.cpp b/src/raspberrypi/devices/primary_device.cpp index 1a15e332..cd9a1742 100644 --- a/src/raspberrypi/devices/primary_device.cpp +++ b/src/raspberrypi/devices/primary_device.cpp @@ -111,7 +111,6 @@ void PrimaryDevice::RequestSense(SASIDEV *controller) controller->Error(sense_key::ILLEGAL_REQUEST, asc::INVALID_LUN); ctrl->status = 0x00; - return; } size_t allocation_length = ctrl->cmd[4]; @@ -161,21 +160,20 @@ bool PrimaryDevice::CheckReady() return true; } -vector PrimaryDevice::Inquiry(int type, int scsi_level, bool is_removable) const +vector PrimaryDevice::Inquiry(device_type type, scsi_level level, bool is_removable) const { vector buf = vector(0x1F + 5); // Basic data - // buf[0] ... SCSI Device type + // buf[0] ... SCSI device type // buf[1] ... Bit 7: Removable/not removable - // buf[2] ... SCSI-2 compliant command system - // buf[3] ... SCSI-2 compliant Inquiry response + // buf[2] ... SCSI compliance level of command system + // buf[3] ... SCSI compliance level of Inquiry response // buf[4] ... Inquiry additional data buf[0] = type; buf[1] = is_removable ? 0x80 : 0x00; - buf[2] = scsi_level; - // Response data format is SCSI-2 for devices supporting SCSI-2 or newer, otherwise it is SCSI-1-CCS - buf[3] = scsi_level >= 2 ? 2 : 1; + buf[2] = level; + buf[3] = level >= scsi_level::SCSI_2 ? scsi_level::SCSI_2 : scsi_level::SCSI_1_CCS; buf[4] = 0x1F; // Padded vendor, product, revision diff --git a/src/raspberrypi/devices/primary_device.h b/src/raspberrypi/devices/primary_device.h index 30fff210..4ba6661a 100644 --- a/src/raspberrypi/devices/primary_device.h +++ b/src/raspberrypi/devices/primary_device.h @@ -41,7 +41,7 @@ public: protected: - vector Inquiry(int, int, bool) const; + vector Inquiry(scsi_defs::device_type, scsi_level, bool) const; SASIDEV::ctrl_t *ctrl; diff --git a/src/raspberrypi/devices/scsi_daynaport.cpp b/src/raspberrypi/devices/scsi_daynaport.cpp index 5b77fc1c..5d3b9625 100644 --- a/src/raspberrypi/devices/scsi_daynaport.cpp +++ b/src/raspberrypi/devices/scsi_daynaport.cpp @@ -114,8 +114,7 @@ void SCSIDaynaPort::Open(const Filepath& path) vector SCSIDaynaPort::Inquiry() const { - // Processor device, SCSI-2, not removable - return PrimaryDevice::Inquiry(3, 2, false); + return PrimaryDevice::Inquiry(device_type::PROCESSOR, scsi_level::SCSI_2, false); } //--------------------------------------------------------------------------- diff --git a/src/raspberrypi/devices/scsi_host_bridge.cpp b/src/raspberrypi/devices/scsi_host_bridge.cpp index 3f055f63..bb84e8de 100644 --- a/src/raspberrypi/devices/scsi_host_bridge.cpp +++ b/src/raspberrypi/devices/scsi_host_bridge.cpp @@ -101,8 +101,7 @@ bool SCSIBR::Dispatch(SCSIDEV *controller) vector SCSIBR::Inquiry() const { - // Communications device, SCSI-2, not removable - vector b = PrimaryDevice::Inquiry(9, 2, false); + vector b = PrimaryDevice::Inquiry(device_type::COMMUNICATIONS, scsi_level::SCSI_2, false); // The bridge returns 6 more additional bytes than the other devices vector buf = vector(0x1F + 8 + 5); diff --git a/src/raspberrypi/devices/scsi_printer.cpp b/src/raspberrypi/devices/scsi_printer.cpp index c3eb6e5b..3445fcfc 100644 --- a/src/raspberrypi/devices/scsi_printer.cpp +++ b/src/raspberrypi/devices/scsi_printer.cpp @@ -105,8 +105,7 @@ void SCSIPrinter::TestUnitReady(SCSIDEV *controller) vector SCSIPrinter::Inquiry() const { - // Printer device, SCSI-2, not removable - return PrimaryDevice::Inquiry(2, 2, false); + return PrimaryDevice::Inquiry(device_type::PRINTER, scsi_level::SCSI_2, false); } void SCSIPrinter::ReserveUnit(SCSIDEV *controller) diff --git a/src/raspberrypi/devices/scsicd.cpp b/src/raspberrypi/devices/scsicd.cpp index 694be96f..65f9c933 100644 --- a/src/raspberrypi/devices/scsicd.cpp +++ b/src/raspberrypi/devices/scsicd.cpp @@ -399,8 +399,7 @@ void SCSICD::ReadToc(SASIDEV *controller) vector SCSICD::Inquiry() const { - // CD-ROM device, SCSI-2, removable - return PrimaryDevice::Inquiry(5, 2, true); + return PrimaryDevice::Inquiry(device_type::CD_ROM, scsi_level::SCSI_2, true); // // The following code worked with the modified Apple CD-ROM drivers. Need to diff --git a/src/raspberrypi/devices/scsihd.cpp b/src/raspberrypi/devices/scsihd.cpp index d4204736..b066d2b7 100644 --- a/src/raspberrypi/devices/scsihd.cpp +++ b/src/raspberrypi/devices/scsihd.cpp @@ -100,8 +100,7 @@ void SCSIHD::Open(const Filepath& path) vector SCSIHD::Inquiry() const { - // Direct access device, SCSI-2 - return PrimaryDevice::Inquiry(0, 2, IsRemovable()); + return PrimaryDevice::Inquiry(device_type::DIRECT_ACCESS, scsi_level::SCSI_2, IsRemovable()); } bool SCSIHD::ModeSelect(const DWORD *cdb, const BYTE *buf, int length) diff --git a/src/raspberrypi/devices/scsihd_nec.cpp b/src/raspberrypi/devices/scsihd_nec.cpp index e4653638..f7af9bbe 100644 --- a/src/raspberrypi/devices/scsihd_nec.cpp +++ b/src/raspberrypi/devices/scsihd_nec.cpp @@ -137,8 +137,7 @@ void SCSIHD_NEC::Open(const Filepath& path) vector SCSIHD_NEC::Inquiry() const { - // Direct access device, SCSI-1-CCS, not removable - return PrimaryDevice::Inquiry(0, 1, false); + return PrimaryDevice::Inquiry(device_type::DIRECT_ACCESS, scsi_level::SCSI_1_CCS, false); } void SCSIHD_NEC::AddErrorPage(map>& pages, bool) const diff --git a/src/raspberrypi/devices/scsimo.cpp b/src/raspberrypi/devices/scsimo.cpp index 8a3c2237..ea8b909f 100644 --- a/src/raspberrypi/devices/scsimo.cpp +++ b/src/raspberrypi/devices/scsimo.cpp @@ -65,8 +65,7 @@ void SCSIMO::Open(const Filepath& path) vector SCSIMO::Inquiry() const { - // Optical memory device, SCSI-2, removable - return PrimaryDevice::Inquiry(7, 2, true); + return PrimaryDevice::Inquiry(device_type::OPTICAL_MEMORY, scsi_level::SCSI_2, true); } void SCSIMO::SetDeviceParameters(BYTE *buf) diff --git a/src/raspberrypi/scsi.h b/src/raspberrypi/scsi.h index d51ee671..e5f1ac20 100644 --- a/src/raspberrypi/scsi.h +++ b/src/raspberrypi/scsi.h @@ -124,6 +124,21 @@ private: // //=========================================================================== namespace scsi_defs { + enum scsi_level : int { + SCSI_1_CCS = 1, + SCSI_2 = 2, + SPC_5 = 7 + }; + + enum device_type : int { + DIRECT_ACCESS = 0, + PRINTER = 2, + PROCESSOR = 3, + CD_ROM = 5, + OPTICAL_MEMORY = 7, + COMMUNICATIONS = 9 + }; + enum scsi_command : int { eCmdTestUnitReady = 0x00, eCmdRezero = 0x01,