Refactoring

This commit is contained in:
Uwe Seimet
2021-08-30 13:44:25 +02:00
parent 5880ddc05d
commit 3814c242a3
3 changed files with 10 additions and 39 deletions

View File

@@ -844,7 +844,7 @@ void SASIDEV::CmdAssign()
LOGTRACE("%s ASSIGN Command ", __PRETTY_FUNCTION__); LOGTRACE("%s ASSIGN Command ", __PRETTY_FUNCTION__);
// Command processing on drive // Command processing on drive
bool status = ctrl.device->Assign(ctrl.cmd); bool status = ctrl.device->CheckReady();
if (!status) { if (!status) {
// Failure (Error) // Failure (Error)
Error(); Error();
@@ -868,7 +868,7 @@ void SASIDEV::CmdSpecify()
LOGTRACE("%s SPECIFY Command ", __PRETTY_FUNCTION__); LOGTRACE("%s SPECIFY Command ", __PRETTY_FUNCTION__);
// Command processing on drive // Command processing on drive
bool status = ctrl.device->Assign(ctrl.cmd); bool status = ctrl.device->CheckReady();
if (!status) { if (!status) {
// Failure (Error) // Failure (Error)
Error(); Error();

View File

@@ -394,7 +394,7 @@ void Disk::Inquiry(SASIDEV *controller)
void Disk::ModeSelect6(SASIDEV *controller) void Disk::ModeSelect6(SASIDEV *controller)
{ {
LOGTRACE("MODE SELECT (6) for unsupported page %d", ctrl->buffer[0]); LOGTRACE("MODE SELECT(6) for unsupported page %d", ctrl->buffer[0]);
ctrl->length = ModeSelectCheck6(ctrl->cmd); ctrl->length = ModeSelectCheck6(ctrl->cmd);
if (ctrl->length <= 0) { if (ctrl->length <= 0) {
@@ -407,7 +407,7 @@ void Disk::ModeSelect6(SASIDEV *controller)
void Disk::ModeSelect10(SASIDEV *controller) void Disk::ModeSelect10(SASIDEV *controller)
{ {
LOGTRACE("MODE SELECT (10) for unsupported page %d", ctrl->buffer[0]); LOGTRACE("MODE SELECT(10) for unsupported page %d", ctrl->buffer[0]);
ctrl->length = ModeSelectCheck10(ctrl->cmd); ctrl->length = ModeSelectCheck10(ctrl->cmd);
if (ctrl->length <= 0) { if (ctrl->length <= 0) {
@@ -466,11 +466,14 @@ void Disk::SendDiagnostic(SASIDEV *controller)
void Disk::PreventAllowMediumRemoval(SASIDEV *controller) void Disk::PreventAllowMediumRemoval(SASIDEV *controller)
{ {
if (!Removal(ctrl->cmd)) { if (!CheckReady()) {
controller->Error(); controller->Error();
return; return;
} }
// Set Lock flag
SetLocked(ctrl->cmd[4] & 0x01);
controller->Status(); controller->Status();
} }
@@ -1304,16 +1307,6 @@ void Disk::Seek10(SASIDEV *controller)
Seek(controller); Seek(controller);
} }
//---------------------------------------------------------------------------
//
// ASSIGN
//
//---------------------------------------------------------------------------
bool Disk::Assign(const DWORD* /*cdb*/)
{
return CheckReady();
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// START STOP UNIT // START STOP UNIT
@@ -1362,26 +1355,6 @@ bool Disk::SendDiag(const DWORD *cdb)
return true; return true;
} }
//---------------------------------------------------------------------------
//
// PREVENT/ALLOW MEDIUM REMOVAL
//
//---------------------------------------------------------------------------
bool Disk::Removal(const DWORD *cdb)
{
ASSERT(cdb);
if (!CheckReady()) {
return false;
}
// Set Lock flag
SetLocked(cdb[4] & 0x01);
// REMOVAL Success
return true;
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// READ CAPACITY // READ CAPACITY
@@ -1558,7 +1531,7 @@ void Disk::Release10(SASIDEV *controller)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// Get start sector and sector count for a READ/WRITE(10/16) operation // Get start sector and sector count for a READ/WRITE operation
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool Disk::GetStartAndCount(SASIDEV *controller, uint64_t& start, uint32_t& count, access_mode mode) bool Disk::GetStartAndCount(SASIDEV *controller, uint64_t& start, uint32_t& count, access_mode mode)

View File

@@ -120,10 +120,8 @@ public:
virtual int Inquiry(const DWORD *cdb, BYTE *buf) = 0; // INQUIRY command virtual int Inquiry(const DWORD *cdb, BYTE *buf) = 0; // INQUIRY command
virtual int WriteCheck(DWORD block); // WRITE check virtual int WriteCheck(DWORD block); // WRITE check
virtual bool Write(const DWORD *cdb, const BYTE *buf, DWORD block); // WRITE command virtual bool Write(const DWORD *cdb, const BYTE *buf, DWORD block); // WRITE command
bool Assign(const DWORD *cdb); // ASSIGN command
bool StartStop(const DWORD *cdb); // START STOP UNIT command bool StartStop(const DWORD *cdb); // START STOP UNIT command
bool SendDiag(const DWORD *cdb); // SEND DIAGNOSTIC command bool SendDiag(const DWORD *cdb); // SEND DIAGNOSTIC command
bool Removal(const DWORD *cdb); // PREVENT/ALLOW MEDIUM REMOVAL command
virtual int Read(const DWORD *cdb, BYTE *buf, uint64_t block); virtual int Read(const DWORD *cdb, BYTE *buf, uint64_t block);
int ReadDefectData10(const DWORD *cdb, BYTE *buf); // READ DEFECT DATA(10) command int ReadDefectData10(const DWORD *cdb, BYTE *buf); // READ DEFECT DATA(10) command
@@ -141,6 +139,7 @@ public:
uint64_t GetBlockCount() const; uint64_t GetBlockCount() const;
void SetBlockCount(uint32_t); void SetBlockCount(uint32_t);
bool GetStartAndCount(SASIDEV *, uint64_t&, uint32_t&, access_mode); bool GetStartAndCount(SASIDEV *, uint64_t&, uint32_t&, access_mode);
bool CheckReady();
// TODO This method should not be called by SASIDEV // TODO This method should not be called by SASIDEV
virtual bool ModeSelect(const DWORD *cdb, const BYTE *buf, int length); virtual bool ModeSelect(const DWORD *cdb, const BYTE *buf, int length);
@@ -155,7 +154,6 @@ protected:
int AddCDROM(bool change, BYTE *buf); // Add CD-ROM int AddCDROM(bool change, BYTE *buf); // Add CD-ROM
int AddCDDA(bool, BYTE *buf); // Add CD_DA int AddCDDA(bool, BYTE *buf); // Add CD_DA
virtual int AddVendor(int page, bool change, BYTE *buf); // Add vendor special info virtual int AddVendor(int page, bool change, BYTE *buf); // Add vendor special info
bool CheckReady(); // Check if ready
virtual int RequestSense(const DWORD *cdb, BYTE *buf); // REQUEST SENSE command virtual int RequestSense(const DWORD *cdb, BYTE *buf); // REQUEST SENSE command
// Internal data // Internal data