2022-10-08 17:26:04 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 17:58:23 +00:00
|
|
|
// SCSI Target Emulator PiSCSI
|
2022-10-08 17:26:04 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
2023-10-15 06:38:15 +00:00
|
|
|
// Copyright (C) 2022-2023 Uwe Seimet
|
2022-10-08 17:26:04 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
#include "generated/piscsi_interface.pb.h"
|
2022-12-09 15:50:45 +00:00
|
|
|
#include "shared/scsi.h"
|
2022-10-25 08:29:57 +00:00
|
|
|
#include <filesystem>
|
2022-12-09 15:50:45 +00:00
|
|
|
#include <memory>
|
2023-10-15 06:38:15 +00:00
|
|
|
#include <span>
|
2022-12-09 15:50:45 +00:00
|
|
|
#include <string>
|
2022-10-08 17:26:04 +00:00
|
|
|
|
|
|
|
using namespace std;
|
2022-10-25 08:29:57 +00:00
|
|
|
using namespace filesystem;
|
2022-12-05 17:58:23 +00:00
|
|
|
using namespace piscsi_interface;
|
2022-10-08 17:26:04 +00:00
|
|
|
|
|
|
|
class PrimaryDevice;
|
|
|
|
class MockAbstractController;
|
|
|
|
|
2022-12-03 04:20:27 +00:00
|
|
|
extern const path test_data_temp_path;
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
pair<shared_ptr<MockAbstractController>, shared_ptr<PrimaryDevice>> CreateDevice(PbDeviceType, const string& = "");
|
2022-10-23 19:51:39 +00:00
|
|
|
|
2022-10-25 08:29:57 +00:00
|
|
|
pair<int, path> OpenTempFile();
|
|
|
|
path CreateTempFile(int);
|
2023-10-15 06:38:15 +00:00
|
|
|
path CreateTempFileWithData(span<const byte>);
|
2022-10-23 19:51:39 +00:00
|
|
|
|
2022-12-03 04:20:27 +00:00
|
|
|
// create a file with the specified data
|
2022-12-05 17:58:23 +00:00
|
|
|
void CreateTempFileWithData(const string&, vector<uint8_t>&);
|
2022-12-03 04:20:27 +00:00
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
void DeleteTempFile(const string&);
|
2022-12-03 04:20:27 +00:00
|
|
|
|
2022-12-09 15:50:45 +00:00
|
|
|
string ReadTempFileToString(const string& filename);
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
int GetInt16(const vector<byte>&, int);
|
|
|
|
uint32_t GetInt32(const vector<byte>&, int);
|
2023-10-15 06:38:15 +00:00
|
|
|
|
|
|
|
// This class is needed in order to be declared as friend, required to have access to AbstractController::SetCmdByte
|
|
|
|
class TestInquiry {
|
|
|
|
public:
|
|
|
|
static void Inquiry(PbDeviceType, scsi_defs::device_type, scsi_defs::scsi_level, const string&, int, bool,
|
|
|
|
const string& = "");
|
|
|
|
};
|