mirror of
https://github.com/akuker/RASCSI.git
synced 2024-06-26 22:29:45 +00:00
- Memory management updates, more fixed Sonar issues * Replaced macros, fixed other sonar issues * Added const, replaced enum with a single value by constant * Updated object initializations * Fixed potential strncpy overflow reported by gcc 8.3
62 lines
1.6 KiB
C++
62 lines
1.6 KiB
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator RaSCSI Reloaded
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
//
|
|
// A device implementing mandatory SCSI primary commands, to be used for subclassing
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "interfaces/scsi_primary_commands.h"
|
|
#include "controllers/scsi_controller.h"
|
|
#include "device.h"
|
|
#include "dispatcher.h"
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
|
|
class PrimaryDevice: public ScsiPrimaryCommands, public Device
|
|
{
|
|
|
|
public:
|
|
|
|
explicit PrimaryDevice(const string&);
|
|
~PrimaryDevice() override = default;
|
|
PrimaryDevice(PrimaryDevice&) = delete;
|
|
PrimaryDevice& operator=(const PrimaryDevice&) = delete;
|
|
|
|
bool Dispatch() override;
|
|
|
|
void SetController(AbstractController *);
|
|
virtual bool WriteByteSequence(BYTE *, uint32_t);
|
|
virtual int GetSendDelay() const { return BUS::SEND_NO_DELAY; }
|
|
|
|
protected:
|
|
|
|
vector<BYTE> HandleInquiry(scsi_defs::device_type, scsi_level, bool) const;
|
|
virtual vector<BYTE> InquiryInternal() const = 0;
|
|
void CheckReady();
|
|
|
|
void EnterStatusPhase() { controller->Status(); }
|
|
void EnterDataInPhase() { controller->DataIn(); }
|
|
void EnterDataOutPhase() { controller->DataOut(); }
|
|
|
|
AbstractController *controller = nullptr;
|
|
AbstractController::ctrl_t *ctrl = nullptr;
|
|
|
|
private:
|
|
|
|
void TestUnitReady() override;
|
|
void RequestSense() override;
|
|
void ReportLuns() override;
|
|
void Inquiry() override;
|
|
|
|
vector<BYTE> HandleRequestSense() const;
|
|
|
|
Dispatcher<PrimaryDevice> dispatcher;
|
|
};
|