mirror of
https://github.com/akuker/RASCSI.git
synced 2025-02-26 09:29:16 +00:00
Use enums for device type and scsi level (#718)
* Use enums for device type and scsi level * Renaming * Use new enum instead of magic values * Comment update * Fixed REQUEST SENSE regression
This commit is contained in:
parent
0297fe856a
commit
305a7fb99d
@ -59,8 +59,7 @@ void HostServices::TestUnitReady(SCSIDEV *controller)
|
|||||||
|
|
||||||
vector<BYTE> HostServices::Inquiry() const
|
vector<BYTE> HostServices::Inquiry() const
|
||||||
{
|
{
|
||||||
// Processor device, SPC-5, not removable
|
return PrimaryDevice::Inquiry(device_type::PROCESSOR, scsi_level::SPC_5, false);
|
||||||
return PrimaryDevice::Inquiry(3, 7, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostServices::StartStopUnit(SCSIDEV *controller)
|
void HostServices::StartStopUnit(SCSIDEV *controller)
|
||||||
|
@ -111,7 +111,6 @@ void PrimaryDevice::RequestSense(SASIDEV *controller)
|
|||||||
|
|
||||||
controller->Error(sense_key::ILLEGAL_REQUEST, asc::INVALID_LUN);
|
controller->Error(sense_key::ILLEGAL_REQUEST, asc::INVALID_LUN);
|
||||||
ctrl->status = 0x00;
|
ctrl->status = 0x00;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t allocation_length = ctrl->cmd[4];
|
size_t allocation_length = ctrl->cmd[4];
|
||||||
@ -161,21 +160,20 @@ bool PrimaryDevice::CheckReady()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<BYTE> PrimaryDevice::Inquiry(int type, int scsi_level, bool is_removable) const
|
vector<BYTE> PrimaryDevice::Inquiry(device_type type, scsi_level level, bool is_removable) const
|
||||||
{
|
{
|
||||||
vector<BYTE> buf = vector<BYTE>(0x1F + 5);
|
vector<BYTE> buf = vector<BYTE>(0x1F + 5);
|
||||||
|
|
||||||
// Basic data
|
// Basic data
|
||||||
// buf[0] ... SCSI Device type
|
// buf[0] ... SCSI device type
|
||||||
// buf[1] ... Bit 7: Removable/not removable
|
// buf[1] ... Bit 7: Removable/not removable
|
||||||
// buf[2] ... SCSI-2 compliant command system
|
// buf[2] ... SCSI compliance level of command system
|
||||||
// buf[3] ... SCSI-2 compliant Inquiry response
|
// buf[3] ... SCSI compliance level of Inquiry response
|
||||||
// buf[4] ... Inquiry additional data
|
// buf[4] ... Inquiry additional data
|
||||||
buf[0] = type;
|
buf[0] = type;
|
||||||
buf[1] = is_removable ? 0x80 : 0x00;
|
buf[1] = is_removable ? 0x80 : 0x00;
|
||||||
buf[2] = scsi_level;
|
buf[2] = level;
|
||||||
// Response data format is SCSI-2 for devices supporting SCSI-2 or newer, otherwise it is SCSI-1-CCS
|
buf[3] = level >= scsi_level::SCSI_2 ? scsi_level::SCSI_2 : scsi_level::SCSI_1_CCS;
|
||||||
buf[3] = scsi_level >= 2 ? 2 : 1;
|
|
||||||
buf[4] = 0x1F;
|
buf[4] = 0x1F;
|
||||||
|
|
||||||
// Padded vendor, product, revision
|
// Padded vendor, product, revision
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
vector<BYTE> Inquiry(int, int, bool) const;
|
vector<BYTE> Inquiry(scsi_defs::device_type, scsi_level, bool) const;
|
||||||
|
|
||||||
SASIDEV::ctrl_t *ctrl;
|
SASIDEV::ctrl_t *ctrl;
|
||||||
|
|
||||||
|
@ -114,8 +114,7 @@ void SCSIDaynaPort::Open(const Filepath& path)
|
|||||||
|
|
||||||
vector<BYTE> SCSIDaynaPort::Inquiry() const
|
vector<BYTE> SCSIDaynaPort::Inquiry() const
|
||||||
{
|
{
|
||||||
// Processor device, SCSI-2, not removable
|
return PrimaryDevice::Inquiry(device_type::PROCESSOR, scsi_level::SCSI_2, false);
|
||||||
return PrimaryDevice::Inquiry(3, 2, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -101,8 +101,7 @@ bool SCSIBR::Dispatch(SCSIDEV *controller)
|
|||||||
|
|
||||||
vector<BYTE> SCSIBR::Inquiry() const
|
vector<BYTE> SCSIBR::Inquiry() const
|
||||||
{
|
{
|
||||||
// Communications device, SCSI-2, not removable
|
vector<BYTE> b = PrimaryDevice::Inquiry(device_type::COMMUNICATIONS, scsi_level::SCSI_2, false);
|
||||||
vector<BYTE> b = PrimaryDevice::Inquiry(9, 2, false);
|
|
||||||
|
|
||||||
// The bridge returns 6 more additional bytes than the other devices
|
// The bridge returns 6 more additional bytes than the other devices
|
||||||
vector<BYTE> buf = vector<BYTE>(0x1F + 8 + 5);
|
vector<BYTE> buf = vector<BYTE>(0x1F + 8 + 5);
|
||||||
|
@ -105,8 +105,7 @@ void SCSIPrinter::TestUnitReady(SCSIDEV *controller)
|
|||||||
|
|
||||||
vector<BYTE> SCSIPrinter::Inquiry() const
|
vector<BYTE> SCSIPrinter::Inquiry() const
|
||||||
{
|
{
|
||||||
// Printer device, SCSI-2, not removable
|
return PrimaryDevice::Inquiry(device_type::PRINTER, scsi_level::SCSI_2, false);
|
||||||
return PrimaryDevice::Inquiry(2, 2, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCSIPrinter::ReserveUnit(SCSIDEV *controller)
|
void SCSIPrinter::ReserveUnit(SCSIDEV *controller)
|
||||||
|
@ -399,8 +399,7 @@ void SCSICD::ReadToc(SASIDEV *controller)
|
|||||||
|
|
||||||
vector<BYTE> SCSICD::Inquiry() const
|
vector<BYTE> SCSICD::Inquiry() const
|
||||||
{
|
{
|
||||||
// CD-ROM device, SCSI-2, removable
|
return PrimaryDevice::Inquiry(device_type::CD_ROM, scsi_level::SCSI_2, true);
|
||||||
return PrimaryDevice::Inquiry(5, 2, true);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The following code worked with the modified Apple CD-ROM drivers. Need to
|
// The following code worked with the modified Apple CD-ROM drivers. Need to
|
||||||
|
@ -100,8 +100,7 @@ void SCSIHD::Open(const Filepath& path)
|
|||||||
|
|
||||||
vector<BYTE> SCSIHD::Inquiry() const
|
vector<BYTE> SCSIHD::Inquiry() const
|
||||||
{
|
{
|
||||||
// Direct access device, SCSI-2
|
return PrimaryDevice::Inquiry(device_type::DIRECT_ACCESS, scsi_level::SCSI_2, IsRemovable());
|
||||||
return PrimaryDevice::Inquiry(0, 2, IsRemovable());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SCSIHD::ModeSelect(const DWORD *cdb, const BYTE *buf, int length)
|
bool SCSIHD::ModeSelect(const DWORD *cdb, const BYTE *buf, int length)
|
||||||
|
@ -137,8 +137,7 @@ void SCSIHD_NEC::Open(const Filepath& path)
|
|||||||
|
|
||||||
vector<BYTE> SCSIHD_NEC::Inquiry() const
|
vector<BYTE> SCSIHD_NEC::Inquiry() const
|
||||||
{
|
{
|
||||||
// Direct access device, SCSI-1-CCS, not removable
|
return PrimaryDevice::Inquiry(device_type::DIRECT_ACCESS, scsi_level::SCSI_1_CCS, false);
|
||||||
return PrimaryDevice::Inquiry(0, 1, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCSIHD_NEC::AddErrorPage(map<int, vector<BYTE>>& pages, bool) const
|
void SCSIHD_NEC::AddErrorPage(map<int, vector<BYTE>>& pages, bool) const
|
||||||
|
@ -65,8 +65,7 @@ void SCSIMO::Open(const Filepath& path)
|
|||||||
|
|
||||||
vector<BYTE> SCSIMO::Inquiry() const
|
vector<BYTE> SCSIMO::Inquiry() const
|
||||||
{
|
{
|
||||||
// Optical memory device, SCSI-2, removable
|
return PrimaryDevice::Inquiry(device_type::OPTICAL_MEMORY, scsi_level::SCSI_2, true);
|
||||||
return PrimaryDevice::Inquiry(7, 2, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCSIMO::SetDeviceParameters(BYTE *buf)
|
void SCSIMO::SetDeviceParameters(BYTE *buf)
|
||||||
|
@ -124,6 +124,21 @@ private:
|
|||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
namespace scsi_defs {
|
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 {
|
enum scsi_command : int {
|
||||||
eCmdTestUnitReady = 0x00,
|
eCmdTestUnitReady = 0x00,
|
||||||
eCmdRezero = 0x01,
|
eCmdRezero = 0x01,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user