mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-22 15:30:09 +00:00
621cc7d5a2
* Unit test updates * Lambda syntax cleanup * Use new-style casts * Use std::none_of when saving the cache * Use to_integer instead of casts * Use accessors for getting CDB data * Made ctrl_t private * Improved encapsulation * Replaced pointers by references * Removed all remaining occurrences of DWORD and BYTE, making os.h obsolete
71 lines
2.5 KiB
C++
71 lines
2.5 KiB
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator RaSCSI Reloaded
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2021-2022 Uwe Seimet
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "protobuf_serializer.h"
|
|
|
|
class RascsiResponse;
|
|
class RascsiImage;
|
|
class DeviceFactory;
|
|
class ControllerManager;
|
|
class PrimaryDevice;
|
|
class CommandContext;
|
|
|
|
class RascsiExecutor
|
|
{
|
|
RascsiResponse& rascsi_response;
|
|
|
|
RascsiImage& rascsi_image;
|
|
|
|
DeviceFactory& device_factory;
|
|
|
|
ControllerManager& controller_manager;
|
|
|
|
ProtobufSerializer serializer;
|
|
|
|
unordered_set<int> reserved_ids;
|
|
|
|
public:
|
|
|
|
RascsiExecutor(RascsiResponse& rascsi_response, RascsiImage& rascsi_image, DeviceFactory& device_factory,
|
|
ControllerManager& controller_manager)
|
|
: rascsi_response(rascsi_response), rascsi_image(rascsi_image), device_factory(device_factory),
|
|
controller_manager(controller_manager) {}
|
|
~RascsiExecutor() = default;
|
|
|
|
unordered_set<int> GetReservedIds() const { return reserved_ids; }
|
|
|
|
bool ProcessDeviceCmd(const CommandContext&, const PbDeviceDefinition&, const PbCommand&, bool);
|
|
bool ProcessCmd(const CommandContext&, const PbCommand&);
|
|
bool SetLogLevel(const string&) const;
|
|
bool Start(PrimaryDevice&, bool) const;
|
|
bool Stop(PrimaryDevice&, bool) const;
|
|
bool Eject(PrimaryDevice&, bool) const;
|
|
bool Protect(PrimaryDevice&, bool) const;
|
|
bool Unprotect(PrimaryDevice&, bool) const;
|
|
bool Attach(const CommandContext&, const PbDeviceDefinition&, bool);
|
|
bool Insert(const CommandContext&, const PbDeviceDefinition&, const shared_ptr<PrimaryDevice>&, bool) const;
|
|
bool Detach(const CommandContext&, const shared_ptr<PrimaryDevice>&, bool) const;
|
|
void DetachAll();
|
|
bool ShutDown(const CommandContext&, const string&);
|
|
string SetReservedIds(string_view);
|
|
bool ValidateImageFile(const CommandContext&, StorageDevice&, const string&, string&) const;
|
|
void PrintCommand(const PbCommand&, const PbDeviceDefinition&, bool) const;
|
|
string ValidateLunSetup(const PbCommand&) const;
|
|
bool VerifyExistingIdAndLun(const CommandContext&, int, int) const;
|
|
shared_ptr<PrimaryDevice> CreateDevice(const CommandContext&, const PbDeviceType, int, const string&) const;
|
|
bool SetSectorSize(const CommandContext&, shared_ptr<PrimaryDevice>, int) const;
|
|
|
|
static bool ValidateOperationAgainstDevice(const CommandContext&, const PrimaryDevice&, const PbOperation&);
|
|
static bool ValidateIdAndLun(const CommandContext&, int, int);
|
|
static bool SetProductData(const CommandContext&, const PbDeviceDefinition&, PrimaryDevice&);
|
|
|
|
};
|