Removed duplicate code

This commit is contained in:
Uwe Seimet 2021-08-30 13:11:17 +02:00
parent d46013934a
commit 4859c17ee3
4 changed files with 26 additions and 36 deletions

View File

@ -141,8 +141,8 @@ public:
virtual bool Eject(bool);
bool IsSASI() const { return type == "SAHD"; }
bool IsSCSI() const { return type == "SCHD" || type == "SCRM"; }
bool IsSASIHD() const { return type == "SAHD"; }
bool IsSCSIHD() const { return type == "SCHD" || type == "SCRM"; }
bool IsCdRom() const { return type == "SCCD"; }
bool IsMo() const { return type == "SCMO"; }
bool IsBridge() const { return type == "SCBR"; }

View File

@ -397,7 +397,7 @@ void Disk::ModeSelect6(SASIDEV *controller)
{
LOGTRACE("MODE SELECT for unsupported page %d", ctrl->buffer[0]);
ctrl->length = SelectCheck(ctrl->cmd);
ctrl->length = SelectCheck6(ctrl->cmd);
if (ctrl->length <= 0) {
controller->Error();
return;
@ -619,29 +619,28 @@ int Disk::RequestSense(const DWORD *cdb, BYTE *buf)
return size;
}
//---------------------------------------------------------------------------
//
// MODE SELECT check
//
//---------------------------------------------------------------------------
int Disk::SelectCheck(const DWORD *cdb)
int Disk::SelectCheck(const DWORD *cdb, int length)
{
ASSERT(cdb);
// Error if save parameters are set instead of SCSIHD or SCSIRM
if (!IsSCSI()) {
// Error if save parameters are set
if (cdb[1] & 0x01) {
SetStatusCode(STATUS_INVALIDCDB);
return 0;
}
// Error if save parameters are set for other types than of SCHD or SCRM
if (!IsSCSIHD() && (cdb[1] & 0x01)) {
SetStatusCode(STATUS_INVALIDCDB);
return 0;
}
// Receive the data specified by the parameter length
int length = (int)cdb[4];
return length;
}
//---------------------------------------------------------------------------
//
// MODE SELECT(6) check
//
//---------------------------------------------------------------------------
int Disk::SelectCheck6(const DWORD *cdb)
{
// Receive the data specified by the parameter length
return SelectCheck(cdb, cdb[4]);
}
//---------------------------------------------------------------------------
//
// MODE SELECT(10) check
@ -649,25 +648,15 @@ int Disk::SelectCheck(const DWORD *cdb)
//---------------------------------------------------------------------------
int Disk::SelectCheck10(const DWORD *cdb)
{
ASSERT(cdb);
// Error if save parameters are set instead of SCSIHD or SCSIRM
if (!IsSCSI()) {
if (cdb[1] & 0x01) {
SetStatusCode(STATUS_INVALIDCDB);
return 0;
}
}
// Receive the data specified by the parameter length
DWORD length = cdb[7];
int length = cdb[7];
length <<= 8;
length |= cdb[8];
if (length > 0x800) {
length = 0x800;
}
return (int)length;
return SelectCheck(cdb, length);
}
//---------------------------------------------------------------------------
@ -1723,7 +1712,7 @@ bool Disk::SetConfiguredSectorSize(uint32_t configured_sector_size)
{
const DeviceFactory& device_factory = DeviceFactory::instance();
set<uint32_t> sector_sizes = IsSCSI() ? device_factory.GetScsiSectorSizes() : device_factory.GetSasiSectorSizes();
set<uint32_t> sector_sizes = IsSCSIHD() ? device_factory.GetScsiSectorSizes() : device_factory.GetSasiSectorSizes();
if (sector_sizes.find(configured_sector_size) == sector_sizes.end()) {
return false;
}

View File

@ -126,8 +126,6 @@ public:
virtual int Read(const DWORD *cdb, BYTE *buf, uint64_t block);
int ReadDefectData10(const DWORD *cdb, BYTE *buf); // READ DEFECT DATA(10) command
int SelectCheck(const DWORD *cdb); // SELECT check
int SelectCheck10(const DWORD *cdb); // SELECT(10) check
uint32_t GetSectorSizeInBytes() const;
void SetSectorSizeInBytes(uint32_t, bool);
@ -171,4 +169,7 @@ private:
bool Format(const DWORD *cdb);
int ModeSense6(const DWORD *cdb, BYTE *buf);
int ModeSense10(const DWORD *cdb, BYTE *buf);
int SelectCheck(const DWORD *cdb, int length);
int SelectCheck6(const DWORD *cdb);
int SelectCheck10(const DWORD *cdb);
};

View File

@ -372,7 +372,7 @@ bool MapController(Device **map)
int unitno = i * UnitNum + j;
// branch by unit type
if (devices[unitno]) {
if (devices[unitno]->IsSASI()) {
if (devices[unitno]->IsSASIHD()) {
// Drive is SASI, so increment SASI count
sasi_num++;
} else {