RASCSI/src/raspberrypi/devices/scsimo.h
Uwe Seimet f3553c5480
Resolved issues 772, 827, 909; added numerous unit tests; code cleanup (#915)
* Resolved issues 772, 827, 909

* Added numerous unit tests

* Code cleanup

* Improved type safety by using PbDeviceType instead of string

* Do not flush cache on failed STOP UNIT

* Error message and error handling updates

* Removed duplicate code

* Use map for mapping shift counts

* Reject read/write access if the drive has 0 sectors

* Updated logging configuration for tests
2022-10-23 21:51:39 +02:00

50 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//---------------------------------------------------------------------------
//
// SCSI Target Emulator RaSCSI Reloaded
// for Raspberry Pi
//
// Copyright (C) 2001-2006 (ytanaka@ipc-tokai.or.jp)
// Copyright (C) 2014-2020 GIMONS
// Copyright (C) akuker
//
// Licensed under the BSD 3-Clause License.
// See LICENSE file in the project root folder.
//
//---------------------------------------------------------------------------
#pragma once
#include "disk.h"
using Geometry = pair<uint32_t, uint32_t>;
class SCSIMO : public Disk
{
public:
SCSIMO(int, const unordered_set<uint32_t>&);
~SCSIMO() override = default;
void Open() override;
vector<byte> InquiryInternal() const override;
void ModeSelect(scsi_defs::scsi_command, const vector<int>&, const vector<BYTE>&, int) const override;
protected:
void SetUpModePages(map<int, vector<byte>>&, int, bool) const override;
void AddFormatPage(map<int, vector<byte>>&, bool) const override;
void AddVendorPage(map<int, vector<byte>>&, int, bool) const override;
private:
using super = Disk;
void AddOptionPage(map<int, vector<byte>>&, bool) const;
bool SetGeometryForCapacity(uint64_t);
// The mapping of supported capacities to block sizes and block counts, empty if there is no capacity restriction
unordered_map<uint64_t, Geometry> geometries;
};