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 "SCSIDevice.hh"
14
15#include "DiskContainer.hh"
16#include "File.hh"
17#include "MSXMotherBoard.hh"
18#include "RecordedCommand.hh"
20
21#include <array>
22#include <bitset>
23#include <optional>
24
25namespace openmsx {
26
27class DeviceConfig;
28class SCSILS120;
29
30class LSXCommand final : public RecordedCommand
31{
32public:
33 LSXCommand(CommandController& commandController,
34 StateChangeDistributor& stateChangeDistributor,
35 Scheduler& scheduler, SCSILS120& ls);
36 void execute(std::span<const TclObject> tokens,
37 TclObject& result, EmuTime::param time) override;
38 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
39 void tabCompletion(std::vector<std::string>& tokens) const override;
40private:
41 SCSILS120& ls;
42};
43
44class SCSILS120 final : public SCSIDevice, public SectorAccessibleDisk
45 , public DiskContainer, public MediaInfoProvider
46{
47public:
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;
54 ~SCSILS120() override;
55
56 // MediaInfoProvider
57 void getMediaInfo(TclObject& result) override;
58
59 template<typename Archive>
60 void serialize(Archive& ar, unsigned version);
61
62private:
63 // SectorAccessibleDisk:
64 void readSectorsImpl(
65 std::span<SectorBuffer> buffers, size_t startSector) override;
66 void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
67 [[nodiscard]] size_t getNbSectorsImpl() const override;
68 [[nodiscard]] bool isWriteProtectedImpl() const override;
69 [[nodiscard]] Sha1Sum getSha1SumImpl(FilePool& filePool) override;
70
71 // DiskContainer:
72 [[nodiscard]] SectorAccessibleDisk* getSectorAccessibleDisk() override;
73 [[nodiscard]] std::string_view getContainerName() const override;
74 [[nodiscard]] bool diskChanged() override;
75 int insertDisk(const std::string& filename) override;
76
77 // SCSI Device
78 void reset() override;
79 [[nodiscard]] bool isSelected() override;
80 [[nodiscard]] unsigned executeCmd(std::span<const uint8_t, 12> cdb, SCSI::Phase& phase, unsigned& blocks) override;
81 [[nodiscard]] unsigned executingCmd(SCSI::Phase& phase, unsigned& blocks) override;
82 [[nodiscard]] uint8_t getStatusCode() override;
83 int msgOut(uint8_t value) override;
84 uint8_t msgIn() override;
85 void disconnect() override;
86 void busReset() override;
87 [[nodiscard]] unsigned dataIn(unsigned& blocks) override;
88 [[nodiscard]] unsigned dataOut(unsigned& blocks) override;
89
90 void eject();
91 void insert(const std::string& filename);
92
93 [[nodiscard]] bool getReady();
94 void testUnitReady();
95 void startStopUnit();
96 [[nodiscard]] unsigned inquiry();
97 [[nodiscard]] unsigned modeSense();
98 [[nodiscard]] unsigned requestSense();
99 [[nodiscard]] bool checkReadOnly();
100 [[nodiscard]] unsigned readCapacity();
101 [[nodiscard]] bool checkAddress();
102 [[nodiscard]] unsigned readSector(unsigned& blocks);
103 [[nodiscard]] unsigned writeSector(unsigned& blocks);
104 void formatUnit();
105
106private:
107 MSXMotherBoard& motherBoard;
108 AlignedBuffer& buffer;
109 File file;
110 std::optional<LSXCommand> lsxCommand; // delayed init
111 std::string name;
112 const unsigned mode;
113 unsigned keycode; // Sense key, ASC, ASCQ
114 unsigned currentSector;
115 unsigned currentLength;
116 const uint8_t scsiId; // SCSI ID 0..7
117 bool unitAttention; // Unit Attention (was: reset)
118 bool mediaChanged; // Enhanced change flag for MEGA-SCSI driver
119 uint8_t message;
120 uint8_t lun;
121 std::array<uint8_t, 12> cdb; // Command Descriptor Block
122
123 static constexpr unsigned MAX_LS = 26;
124 using LSInUse = std::bitset<MAX_LS>;
125 std::shared_ptr<LSInUse> lsInUse;
126
127 friend class LSXCommand;
128};
129
130} // namespace openmsx
131
132#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:765
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
Definition SCSILS120.cc:811
std::string help(std::span< const TclObject > tokens) const override
Print help for this command.
Definition SCSILS120.cc:802
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:117
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:128
SCSILS120(const SCSILS120 &)=delete
SCSILS120(SCSILS120 &&)=delete
void serialize(Archive &ar, unsigned version)
Definition SCSILS120.cc:820
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