mirror of
https://github.com/akuker/RASCSI.git
synced 2025-02-03 10:31:52 +00:00
Simplified controller/device interface
This commit is contained in:
parent
f1f2f4a84f
commit
ff88ce9602
@ -1028,7 +1028,7 @@ void SASIDEV::CmdSeek6()
|
||||
LOGTRACE("%s SEEK(6) Command ", __PRETTY_FUNCTION__);
|
||||
|
||||
// Command processing on drive
|
||||
ctrl.device->Seek6(this, &ctrl);
|
||||
ctrl.device->Seek6(this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -106,7 +106,7 @@ void SCSIDEV::SetUpControllerCommand(scsi_command opcode, const char* name, void
|
||||
controller_commands[opcode] = new controller_command_t(name, execute);
|
||||
}
|
||||
|
||||
void SCSIDEV::SetUpDeviceCommand(scsi_command opcode, const char* name, void (Disk::*execute)(SASIDEV *, SASIDEV::ctrl_t *))
|
||||
void SCSIDEV::SetUpDeviceCommand(scsi_command opcode, const char* name, void (Disk::*execute)(SASIDEV *))
|
||||
{
|
||||
device_commands[opcode] = new device_command_t(name, execute);
|
||||
}
|
||||
@ -317,7 +317,7 @@ void SCSIDEV::Execute()
|
||||
|
||||
LOGDEBUG("++++ CMD ++++ %s ID %d received %s ($%02X)", __PRETTY_FUNCTION__, GetSCSIID(), command->name, (unsigned int)ctrl.cmd[0]);
|
||||
|
||||
(ctrl.device->*command->execute)(this, &ctrl);
|
||||
(ctrl.device->*command->execute)(this);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -752,7 +752,7 @@ void SCSIDEV::CmdVerify()
|
||||
// if BytChk=0
|
||||
if ((ctrl.cmd[1] & 0x02) == 0) {
|
||||
// Command processing on drive
|
||||
ctrl.device->Seek(this, &ctrl);
|
||||
ctrl.device->Seek(this);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -778,7 +778,7 @@ void SCSIDEV::CmdVerify()
|
||||
//---------------------------------------------------------------------------
|
||||
void SCSIDEV::CmdSynchronizeCache()
|
||||
{
|
||||
// Make it do something (not implemented)...
|
||||
// Nothing to do
|
||||
|
||||
// status phase
|
||||
Status();
|
||||
|
@ -50,9 +50,9 @@ public:
|
||||
|
||||
typedef struct _device_command_t {
|
||||
const char* name;
|
||||
void (Disk::*execute)(SASIDEV *, SASIDEV::ctrl_t *);
|
||||
void (Disk::*execute)(SASIDEV *);
|
||||
|
||||
_device_command_t(const char* _name, void (Disk::*_execute)(SASIDEV *, SASIDEV::ctrl_t *)) : name(_name), execute(_execute) { };
|
||||
_device_command_t(const char* _name, void (Disk::*_execute)(SASIDEV *)) : name(_name), execute(_execute) { };
|
||||
} device_command_t;
|
||||
std::map<scsi_command, device_command_t*> device_commands;
|
||||
|
||||
@ -77,7 +77,7 @@ public:
|
||||
|
||||
private:
|
||||
void SetUpControllerCommand(scsi_command, const char*, void (SCSIDEV::*)(void));
|
||||
void SetUpDeviceCommand(scsi_command, const char*, void (Disk::*)(SASIDEV *, SASIDEV::ctrl_t *));
|
||||
void SetUpDeviceCommand(scsi_command, const char*, void (Disk::*)(SASIDEV *));
|
||||
|
||||
// Phase
|
||||
void BusFree(); // Bus free phase
|
||||
|
@ -11,9 +11,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "controllers/sasidev_ctrl.h"
|
||||
#include "primary_device.h"
|
||||
|
||||
class SASIDEV;
|
||||
|
||||
class BlockDevice : public PrimaryDevice
|
||||
{
|
||||
public:
|
||||
@ -24,14 +25,14 @@ public:
|
||||
// Mandatory commands
|
||||
virtual bool TestUnitReady(const DWORD *cdb) override = 0;
|
||||
virtual int Inquiry(const DWORD *cdb, BYTE *buf) override = 0;
|
||||
virtual void ReportLuns(SASIDEV *, SASIDEV::ctrl_t *) override = 0;
|
||||
virtual void ReportLuns(SASIDEV *) override = 0;
|
||||
virtual bool Format(const DWORD *cdb) = 0;
|
||||
// READ(6), READ(10)
|
||||
virtual int Read(const DWORD *cdb, BYTE *buf, DWORD block) = 0;
|
||||
// WRITE(6), WRITE(10)
|
||||
virtual bool Write(const DWORD *cdb, const BYTE *buf, DWORD block) = 0;
|
||||
virtual void ReadCapacity10(SASIDEV *, SASIDEV::ctrl_t *) = 0;
|
||||
virtual void ReadCapacity16(SASIDEV *, SASIDEV::ctrl_t *) = 0;
|
||||
virtual void ReadCapacity10(SASIDEV *) = 0;
|
||||
virtual void ReadCapacity16(SASIDEV *) = 0;
|
||||
// TODO Uncomment as soon as there is a clean separation between controllers and devices
|
||||
//virtual int Read16(const DWORD *cdb, BYTE *buf, DWORD block) = 0;
|
||||
//virtual int Write16(const DWORD *cdb, BYTE *buf, DWORD block) = 0;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "gpiobus.h"
|
||||
#include "ctapdriver.h"
|
||||
#include "cfilesystem.h"
|
||||
#include "controllers/sasidev_ctrl.h"
|
||||
#include "disk.h"
|
||||
|
||||
//===========================================================================
|
||||
@ -1661,7 +1662,7 @@ bool Disk::Write(const DWORD *cdb, const BYTE *buf, DWORD block)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Disk::Seek(SASIDEV *controller, SASIDEV::ctrl_t *)
|
||||
void Disk::Seek(SASIDEV *controller)
|
||||
{
|
||||
// Status check
|
||||
if (!CheckReady()) {
|
||||
@ -1679,11 +1680,11 @@ void Disk::Seek(SASIDEV *controller, SASIDEV::ctrl_t *)
|
||||
// Does not check LBA (SASI IOCS)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void Disk::Seek6(SASIDEV *controller, SASIDEV::ctrl_t *ctrl)
|
||||
void Disk::Seek6(SASIDEV *controller)
|
||||
{
|
||||
LOGTRACE( "%s SEEK(6) Command ", __PRETTY_FUNCTION__);
|
||||
|
||||
Seek(controller, ctrl);
|
||||
Seek(controller);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@ -1691,11 +1692,11 @@ void Disk::Seek6(SASIDEV *controller, SASIDEV::ctrl_t *ctrl)
|
||||
// SEEK(10)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void Disk::Seek10(SASIDEV *controller, SASIDEV::ctrl_t *ctrl)
|
||||
void Disk::Seek10(SASIDEV *controller)
|
||||
{
|
||||
LOGTRACE( "%s SEEK(10) Command ", __PRETTY_FUNCTION__);
|
||||
|
||||
Seek(controller, ctrl);
|
||||
Seek(controller);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@ -1801,10 +1802,11 @@ bool Disk::Removal(const DWORD *cdb)
|
||||
// READ CAPACITY
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void Disk::ReadCapacity10(SASIDEV *controller, SASIDEV::ctrl_t *ctrl)
|
||||
void Disk::ReadCapacity10(SASIDEV *controller)
|
||||
{
|
||||
LOGTRACE( "%s READ CAPACITY(10) Command ", __PRETTY_FUNCTION__);
|
||||
|
||||
SASIDEV::ctrl_t *ctrl = controller->GetWorkAddr();
|
||||
BYTE *buf = ctrl->buffer;
|
||||
|
||||
ASSERT(buf);
|
||||
@ -1847,10 +1849,11 @@ void Disk::ReadCapacity10(SASIDEV *controller, SASIDEV::ctrl_t *ctrl)
|
||||
controller->DataIn();
|
||||
}
|
||||
|
||||
void Disk::ReadCapacity16(SASIDEV *controller, SASIDEV::ctrl_t *ctrl)
|
||||
void Disk::ReadCapacity16(SASIDEV *controller)
|
||||
{
|
||||
LOGTRACE( "%s READ CAPACITY(16) Command ", __PRETTY_FUNCTION__);
|
||||
|
||||
SASIDEV::ctrl_t *ctrl = controller->GetWorkAddr();
|
||||
BYTE *buf = ctrl->buffer;
|
||||
|
||||
ASSERT(buf);
|
||||
@ -1902,8 +1905,9 @@ void Disk::ReadCapacity16(SASIDEV *controller, SASIDEV::ctrl_t *ctrl)
|
||||
// REPORT LUNS
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void Disk::ReportLuns(SASIDEV *controller, SASIDEV::ctrl_t *ctrl)
|
||||
void Disk::ReportLuns(SASIDEV *controller)
|
||||
{
|
||||
SASIDEV::ctrl_t *ctrl = controller->GetWorkAddr();
|
||||
BYTE *buf = ctrl->buffer;
|
||||
|
||||
ASSERT(buf);
|
||||
@ -1975,7 +1979,7 @@ bool Disk::Verify(const DWORD *cdb)
|
||||
// just respond with an OK status.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void Disk::Reserve6(SASIDEV *controller, SASIDEV::ctrl_t *)
|
||||
void Disk::Reserve6(SASIDEV *controller)
|
||||
{
|
||||
LOGTRACE( "%s Reserve(6) Command", __PRETTY_FUNCTION__);
|
||||
|
||||
@ -1993,7 +1997,7 @@ void Disk::Reserve6(SASIDEV *controller, SASIDEV::ctrl_t *)
|
||||
// just respond with an OK status.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void Disk::Reserve10(SASIDEV *controller, SASIDEV::ctrl_t *)
|
||||
void Disk::Reserve10(SASIDEV *controller)
|
||||
{
|
||||
LOGTRACE( "%s Reserve(10) Command", __PRETTY_FUNCTION__);
|
||||
|
||||
@ -2011,7 +2015,7 @@ void Disk::Reserve10(SASIDEV *controller, SASIDEV::ctrl_t *)
|
||||
// just respond with an OK status.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void Disk::Release6(SASIDEV *controller, SASIDEV::ctrl_t *)
|
||||
void Disk::Release6(SASIDEV *controller)
|
||||
{
|
||||
LOGTRACE( "%s Release(6) Command", __PRETTY_FUNCTION__);
|
||||
|
||||
@ -2029,7 +2033,7 @@ void Disk::Release6(SASIDEV *controller, SASIDEV::ctrl_t *)
|
||||
// just respond with an OK status.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void Disk::Release10(SASIDEV *controller, SASIDEV::ctrl_t *)
|
||||
void Disk::Release10(SASIDEV *controller)
|
||||
{
|
||||
LOGTRACE( "%s Release(10) Command", __PRETTY_FUNCTION__);
|
||||
|
||||
|
@ -165,21 +165,21 @@ public:
|
||||
virtual int Read(const DWORD *cdb, BYTE *buf, DWORD block) override; // READ command
|
||||
virtual int WriteCheck(DWORD block); // WRITE check
|
||||
virtual bool Write(const DWORD *cdb, const BYTE *buf, DWORD block) override; // WRITE command
|
||||
void Seek(SASIDEV *, SASIDEV::ctrl_t *);
|
||||
void Seek6(SASIDEV *, SASIDEV::ctrl_t *);
|
||||
void Seek10(SASIDEV *, SASIDEV::ctrl_t *);
|
||||
void Seek(SASIDEV *);
|
||||
void Seek6(SASIDEV *);
|
||||
void Seek10(SASIDEV *);
|
||||
bool Assign(const DWORD *cdb); // ASSIGN command
|
||||
bool Specify(const DWORD *cdb); // SPECIFY command
|
||||
bool StartStop(const DWORD *cdb); // START STOP UNIT command
|
||||
bool SendDiag(const DWORD *cdb); // SEND DIAGNOSTIC command
|
||||
bool Removal(const DWORD *cdb); // PREVENT/ALLOW MEDIUM REMOVAL command
|
||||
void ReadCapacity10(SASIDEV *, SASIDEV::ctrl_t *) override; // READ CAPACITY(10) command
|
||||
void ReadCapacity16(SASIDEV *, SASIDEV::ctrl_t *) override; // READ CAPACITY(16) command
|
||||
void ReportLuns(SASIDEV *, SASIDEV::ctrl_t *) override;
|
||||
void Reserve6(SASIDEV *, SASIDEV::ctrl_t *);
|
||||
void Reserve10(SASIDEV *, SASIDEV::ctrl_t *);
|
||||
void Release6(SASIDEV *, SASIDEV::ctrl_t *);
|
||||
void Release10(SASIDEV *, SASIDEV::ctrl_t *);
|
||||
void ReadCapacity10(SASIDEV *) override; // READ CAPACITY(10) command
|
||||
void ReadCapacity16(SASIDEV *) override; // READ CAPACITY(16) command
|
||||
void ReportLuns(SASIDEV *) override;
|
||||
void Reserve6(SASIDEV *);
|
||||
void Reserve10(SASIDEV *);
|
||||
void Release6(SASIDEV *);
|
||||
void Release10(SASIDEV *);
|
||||
int GetSectorSize() const;
|
||||
void SetSectorSize(int);
|
||||
bool IsSectorSizeConfigurable() const;
|
||||
|
@ -11,9 +11,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "controllers/sasidev_ctrl.h"
|
||||
#include "device.h"
|
||||
|
||||
class SASIDEV;
|
||||
|
||||
class PrimaryDevice : public Device
|
||||
{
|
||||
public:
|
||||
@ -24,7 +25,7 @@ public:
|
||||
// Mandatory commands
|
||||
virtual bool TestUnitReady(const DWORD *cdb) = 0;
|
||||
virtual int Inquiry(const DWORD *cdb, BYTE *buf) = 0;
|
||||
virtual void ReportLuns(SASIDEV *, SASIDEV::ctrl_t *) = 0;
|
||||
virtual void ReportLuns(SASIDEV *) = 0;
|
||||
|
||||
// Implemented optional commands
|
||||
virtual int RequestSense(const DWORD *cdb, BYTE *buf) = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user