RASCSI/src/raspberrypi/devices/primary_device.h
Uwe Seimet 9099d7249c
SASI FORMAT opcode fix, SASI segfault fix, added SASI INQUIRY/READ CAPACITY, 512 bytes per sector SASI drives (#724)
* Fixed opcode

* Fixed segfault

* Re-added 0x06 as additional SASI FORMAT opcode

* Added support of SASI drives with 512 bytes

* SASI LUN must always be taken from CDB and must be 0 or 1

* Fixed typo

* Fixed one more SASI segfault

* Removed duplicate code

* Updated error handling

* Updated error handling

* Logging update

* Added enum value for SPC-6

* Comment update

* Added support for SASI Inquiry

* Updated SASI LUN check

* Updated SASI LUN handling

* Comment update

* Revert "Comment update"

This reverts commit c6adbde25c.

* Updated logging

* Implemented SASI READ CAPACITY

* Validate SASI block count

* Do not support ICD semantics for SASI drives

* SASI READ CAPACITY is a group 1 command with 10 bytes

* Comment update
2022-03-06 09:17:23 -06:00

55 lines
1.3 KiB
C++

//---------------------------------------------------------------------------
//
// SCSI Target Emulator RaSCSI (*^..^*)
// for Raspberry Pi
//
// Copyright (C) 2022 Uwe Seimet
//
// A device implementing mandatory SCSI primary commands, to be used for subclassing
//
//---------------------------------------------------------------------------
#pragma once
#include "controllers/scsidev_ctrl.h"
#include "interfaces/scsi_primary_commands.h"
#include "device.h"
#include "dispatcher.h"
#include <string>
using namespace std;
class PrimaryDevice: public Device, virtual public ScsiPrimaryCommands
{
public:
PrimaryDevice(const string&);
virtual ~PrimaryDevice() {}
virtual bool Dispatch(SCSIDEV *);
void TestUnitReady(SASIDEV *);
void RequestSense(SASIDEV *);
virtual void Inquiry(SASIDEV *);
void SetCtrl(SASIDEV::ctrl_t *ctrl) { this->ctrl = ctrl; }
bool CheckReady();
virtual vector<BYTE> Inquiry() const = 0;
virtual vector<BYTE> RequestSense(int);
virtual bool WriteBytes(BYTE *, uint32_t);
virtual int GetSendDelay() const { return BUS::SEND_NO_DELAY; }
protected:
vector<BYTE> Inquiry(scsi_defs::device_type, scsi_level, bool) const;
SASIDEV::ctrl_t *ctrl;
private:
Dispatcher<PrimaryDevice, SASIDEV> dispatcher;
void ReportLuns(SASIDEV *);
};