| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#ifndef SCSILS120_HH |
| 11 |
#define SCSILS120_HH |
| 12 |
|
| 13 |
#include "SCSIDevice.hh" |
| 14 |
|
| 15 |
#include "DiskContainer.hh" |
| 16 |
#include "File.hh" |
| 17 |
#include "MSXMotherBoard.hh" |
| 18 |
#include "RecordedCommand.hh" |
| 19 |
#include "SectorAccessibleDisk.hh" |
| 20 |
|
| 21 |
#include <array> |
| 22 |
#include <bitset> |
| 23 |
#include <optional> |
| 24 |
|
| 25 |
namespace openmsx { |
| 26 |
|
| 27 |
class DeviceConfig; |
| 28 |
class SCSILS120; |
| 29 |
|
| 30 |
class LSXCommand final : public RecordedCommand |
| 31 |
{ |
| 32 |
public: |
| 33 |
LSXCommand(CommandController& commandController, |
| 34 |
StateChangeDistributor& stateChangeDistributor, |
| 35 |
Scheduler& scheduler, SCSILS120& ls); |
| 36 |
void execute(std::span<const TclObject> tokens, |
| 37 |
TclObject& result, EmuTime time) override; |
| 38 |
[[nodiscard]] std::string help(std::span<const TclObject> tokens) const override; |
| 39 |
void tabCompletion(std::vector<std::string>& tokens) const override; |
| 40 |
private: |
| 41 |
SCSILS120& ls; |
| 42 |
}; |
| 43 |
|
| 44 |
class SCSILS120 final : public SCSIDevice, public SectorAccessibleDisk |
| 45 |
, public DiskContainer, public MediaProvider |
| 46 |
{ |
| 47 |
public: |
| 48 |
SCSILS120(const DeviceConfig& targetConfig, |
| 49 |
AlignedBuffer& buf, unsigned mode); |
| 50 |
SCSILS120(const SCSILS120&) = delete; |
| 51 |
SCSILS120(SCSILS120&&) = delete; |
| 52 |
SCSILS120 operator=(const SCSILS120&) = delete; |
| 53 |
SCSILS120 operator=(SCSILS120&&) = delete; |
| 54 |
~SCSILS120() override; |
| 55 |
|
| 56 |
|
| 57 |
void getMediaInfo(TclObject& result) override; |
| 58 |
void setMedia(const TclObject& info, EmuTime time) override; |
| 59 |
|
| 60 |
template<typename Archive> |
| 61 |
void serialize(Archive& ar, unsigned version); |
| 62 |
|
| 63 |
private: |
| 64 |
|
| 65 |
void readSectorsImpl( |
| 66 |
std::span<SectorBuffer> buffers, size_t startSector) override; |
| 67 |
void writeSectorImpl(size_t sector, const SectorBuffer& buf) override; |
| 68 |
[[nodiscard]] size_t getNbSectorsImpl() override; |
| 69 |
[[nodiscard]] bool isWriteProtectedImpl() const override; |
| 70 |
[[nodiscard]] Sha1Sum getSha1SumImpl(FilePool& filePool) override; |
| 71 |
|
| 72 |
|
| 73 |
[[nodiscard]] SectorAccessibleDisk* getSectorAccessibleDisk() override; |
| 74 |
[[nodiscard]] std::string_view getContainerName() const override; |
| 75 |
[[nodiscard]] bool diskChanged() override; |
| 76 |
int insertDisk(const std::string& filename) override; |
| 77 |
|
| 78 |
|
| 79 |
void reset() override; |
| 80 |
[[nodiscard]] bool isSelected() override; |
| 81 |
[[nodiscard]] unsigned executeCmd(std::span<const uint8_t, 12> cdb, SCSI::Phase& phase, unsigned& blocks) override; |
| 82 |
[[nodiscard]] unsigned executingCmd(SCSI::Phase& phase, unsigned& blocks) override; |
| 83 |
[[nodiscard]] uint8_t getStatusCode() override; |
| 84 |
int msgOut(uint8_t value) override; |
| 85 |
uint8_t msgIn() override; |
| 86 |
void disconnect() override; |
| 87 |
void busReset() override; |
| 88 |
[[nodiscard]] unsigned dataIn(unsigned& blocks) override; |
| 89 |
[[nodiscard]] unsigned dataOut(unsigned& blocks) override; |
| 90 |
|
| 91 |
void eject(); |
| 92 |
void insert(zstring_view filename); |
| 93 |
|
| 94 |
[[nodiscard]] bool getReady(); |
| 95 |
void testUnitReady(); |
| 96 |
void startStopUnit(); |
| 97 |
[[nodiscard]] unsigned inquiry(); |
| 98 |
[[nodiscard]] unsigned modeSense(); |
| 99 |
[[nodiscard]] unsigned requestSense(); |
| 100 |
[[nodiscard]] bool checkReadOnly(); |
| 101 |
[[nodiscard]] unsigned readCapacity(); |
| 102 |
[[nodiscard]] bool checkAddress(); |
| 103 |
[[nodiscard]] unsigned readSector(unsigned& blocks); |
| 104 |
[[nodiscard]] unsigned writeSector(unsigned& blocks); |
| 105 |
void formatUnit(); |
| 106 |
|
| 107 |
private: |
| 108 |
MSXMotherBoard& motherBoard; |
| 109 |
AlignedBuffer& buffer; |
| 110 |
File file; |
| 111 |
std::string filename; |
| 112 |
std::optional<LSXCommand> lsxCommand; |
| 113 |
std::string name; |
| 114 |
const unsigned mode; |
| 115 |
unsigned keycode; |
| 116 |
unsigned currentSector; |
| 117 |
unsigned currentLength; |
| 118 |
const uint8_t scsiId; |
| 119 |
bool unitAttention; |
| 120 |
bool mediaChanged; |
| 121 |
uint8_t message; |
| 122 |
uint8_t lun; |
| 123 |
std::array<uint8_t, 12> cdb; |
| 124 |
|
| 125 |
static constexpr unsigned MAX_LS = 26; |
| 126 |
using LSInUse = std::bitset<MAX_LS>; |
| 127 |
std::shared_ptr<LSInUse> lsInUse; |
| 128 |
|
| 129 |
friend class LSXCommand; |
| 130 |
}; |
| 131 |
|
| 132 |
} |
| 133 |
|
| 134 |
#endif |