2022-02-10 18:54:48 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-08-26 01:01:39 +00:00
|
|
|
// SCSI Target Emulator RaSCSI Reloaded
|
2022-02-10 18:54:48 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "primary_device.h"
|
|
|
|
#include <string>
|
2022-02-27 21:58:01 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
2022-02-10 18:54:48 +00:00
|
|
|
|
2022-11-02 14:36:19 +00:00
|
|
|
// TODO Maybe this should better be a mixin class because not all storage devicess have mode pages
|
|
|
|
class ModePageDevice : public PrimaryDevice
|
2022-02-10 18:54:48 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2022-11-02 14:36:19 +00:00
|
|
|
using PrimaryDevice::PrimaryDevice;
|
2022-02-10 18:54:48 +00:00
|
|
|
|
2022-11-02 14:36:19 +00:00
|
|
|
bool Init(const unordered_map<string, string>&) override;
|
2022-09-07 14:38:42 +00:00
|
|
|
|
2022-11-02 06:36:25 +00:00
|
|
|
virtual void ModeSelect(scsi_defs::scsi_command, const vector<int>&, const vector<uint8_t>&, int) const;
|
2022-02-10 18:54:48 +00:00
|
|
|
|
2022-02-27 21:58:01 +00:00
|
|
|
protected:
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
bool SupportsSaveParameters() const { return supports_save_parameters; }
|
|
|
|
void SupportsSaveParameters(bool b) { supports_save_parameters = b; }
|
2022-11-02 06:36:25 +00:00
|
|
|
int AddModePages(const vector<int>&, vector<uint8_t>&, int, int, int) const;
|
2022-09-25 21:49:24 +00:00
|
|
|
virtual void SetUpModePages(map<int, vector<byte>>&, int, bool) const = 0;
|
2022-10-23 19:51:39 +00:00
|
|
|
virtual void AddVendorPage(map<int, vector<byte>>&, int, bool) const {
|
|
|
|
// Nothing to add by default
|
|
|
|
}
|
2022-02-27 21:58:01 +00:00
|
|
|
|
2022-02-10 18:54:48 +00:00
|
|
|
private:
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
bool supports_save_parameters = false;
|
|
|
|
|
2022-11-02 06:36:25 +00:00
|
|
|
virtual int ModeSense6(const vector<int>&, vector<uint8_t>&) const = 0;
|
|
|
|
virtual int ModeSense10(const vector<int>&, vector<uint8_t>&) const = 0;
|
2022-02-10 18:54:48 +00:00
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
void ModeSense6() const;
|
|
|
|
void ModeSense10() const;
|
|
|
|
void ModeSelect6() const;
|
|
|
|
void ModeSelect10() const;
|
2022-02-10 18:54:48 +00:00
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
void SaveParametersCheck(int) const;
|
2022-02-10 18:54:48 +00:00
|
|
|
};
|