openMSX
SCSILS120.hh
Go to the documentation of this file.
1/* Ported from:
2** Source: /cvsroot/bluemsx/blueMSX/Src/IoDevice/ScsiDevice.h,v
3** Revision: 1.6
4** Date: 2007-05-22 20:05:38 +0200 (Tue, 22 May 2007)
5**
6** More info: http://www.bluemsx.com
7**
8** Copyright (C) 2003-2007 Daniel Vik, white cat
9*/
10#ifndef SCSILS120_HH
11#define SCSILS120_HH
12
13#include "RecordedCommand.hh"
14#include "SCSIDevice.hh"
16#include "DiskContainer.hh"
17#include "MSXMotherBoard.hh"
18#include "File.hh"
19#include <array>
20#include <bitset>
21#include <optional>
22
23namespace openmsx {
24
25class DeviceConfig;
26class SCSILS120;
27
28class LSXCommand final : public RecordedCommand
29{
30public:
31 LSXCommand(CommandController& commandController,
32 StateChangeDistributor& stateChangeDistributor,
33 Scheduler& scheduler, SCSILS120& ls);
34 void execute(std::span<const TclObject> tokens,
35 TclObject& result, EmuTime::param time) override;
36 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
37 void tabCompletion(std::vector<std::string>& tokens) const override;
38private:
39 SCSILS120& ls;
40};
41
42class SCSILS120 final : public SCSIDevice, public SectorAccessibleDisk
43 , public DiskContainer, public MediaInfoProvider
44{
45public:
46 SCSILS120(const DeviceConfig& targetConfig,
47 AlignedBuffer& buf, unsigned mode);
48 SCSILS120(const SCSILS120&) = delete;
49 SCSILS120(SCSILS120&&) = delete;
50 SCSILS120 operator=(const SCSILS120&) = delete;
52 ~SCSILS120() override;
53
54 // MediaInfoProvider
55 void getMediaInfo(TclObject& result) override;
56
57 template<typename Archive>
58 void serialize(Archive& ar, unsigned version);
59
60private:
61 // SectorAccessibleDisk:
62 void readSectorsImpl(
63 std::span<SectorBuffer> buffers, size_t startSector) override;
64 void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
65 [[nodiscard]] size_t getNbSectorsImpl() const override;
66 [[nodiscard]] bool isWriteProtectedImpl() const override;
67 [[nodiscard]] Sha1Sum getSha1SumImpl(FilePool& filePool) override;
68
69 // DiskContainer:
70 [[nodiscard]] SectorAccessibleDisk* getSectorAccessibleDisk() override;
71 [[nodiscard]] std::string_view getContainerName() const override;
72 [[nodiscard]] bool diskChanged() override;
73 int insertDisk(const std::string& filename) override;
74
75 // SCSI Device
76 void reset() override;
77 [[nodiscard]] bool isSelected() override;
78 [[nodiscard]] unsigned executeCmd(std::span<const uint8_t, 12> cdb, SCSI::Phase& phase, unsigned& blocks) override;
79 [[nodiscard]] unsigned executingCmd(SCSI::Phase& phase, unsigned& blocks) override;
80 [[nodiscard]] uint8_t getStatusCode() override;
81 int msgOut(uint8_t value) override;
82 uint8_t msgIn() override;
83 void disconnect() override;
84 void busReset() override;
85 [[nodiscard]] unsigned dataIn(unsigned& blocks) override;
86 [[nodiscard]] unsigned dataOut(unsigned& blocks) override;
87
88 void eject();
89 void insert(const std::string& filename);
90
91 [[nodiscard]] bool getReady();
92 void testUnitReady();
93 void startStopUnit();
94 [[nodiscard]] unsigned inquiry();
95 [[nodiscard]] unsigned modeSense();
96 [[nodiscard]] unsigned requestSense();
97 [[nodiscard]] bool checkReadOnly();
98 [[nodiscard]] unsigned readCapacity();
99 [[nodiscard]] bool checkAddress();
100 [[nodiscard]] unsigned readSector(unsigned& blocks);
101 [[nodiscard]] unsigned writeSector(unsigned& blocks);
102 void formatUnit();
103
104private:
105 MSXMotherBoard& motherBoard;
106 AlignedBuffer& buffer;
107 File file;
108 std::optional<LSXCommand> lsxCommand; // delayed init
109 std::string name;
110 const unsigned mode;
111 unsigned keycode; // Sense key, ASC, ASCQ
112 unsigned currentSector;
113 unsigned currentLength;
114 const uint8_t scsiId; // SCSI ID 0..7
115 bool unitAttention; // Unit Attention (was: reset)
116 bool mediaChanged; // Enhanced change flag for MEGA-SCSI driver
117 uint8_t message;
118 uint8_t lun;
119 std::array<uint8_t, 12> cdb; // Command Descriptor Block
120
121 static constexpr unsigned MAX_LS = 26;
122 using LSInUse = std::bitset<MAX_LS>;
123 std::shared_ptr<LSInUse> lsInUse;
124
125 friend class LSXCommand;
126};
127
128} // namespace openmsx
129
130#endif
void execute(std::span< const TclObject > tokens, TclObject &result, EmuTime::param time) override
This is like the execute() method of the Command class, it only has an extra time parameter.
Definition SCSILS120.cc:760
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
Definition SCSILS120.cc:806
std::string help(std::span< const TclObject > tokens) const override
Print help for this command.
Definition SCSILS120.cc:797
Commands that directly influence the MSX state should send and events so that they can be recorded by...
SCSILS120 operator=(const SCSILS120 &)=delete
~SCSILS120() override
Definition SCSILS120.cc:114
SCSILS120 operator=(SCSILS120 &&)=delete
void getMediaInfo(TclObject &result) override
This method gets called when information is required on the media inserted in the media slot of the p...
Definition SCSILS120.cc:125
SCSILS120(const SCSILS120 &)=delete
SCSILS120(SCSILS120 &&)=delete
void serialize(Archive &ar, unsigned version)
Definition SCSILS120.cc:815
This class represents the result of a sha1 calculation (a 160-bit value).
Definition sha1.hh:24
This file implemented 3 utility functions:
Definition Autofire.cc:11