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 SCSILS120&) = delete;
47 SCSILS120 operator=(const SCSILS120&) = delete;
48
49 SCSILS120(const DeviceConfig& targetConfig,
50 AlignedBuffer& buf, unsigned mode);
51 ~SCSILS120() override;
52
53 // MediaInfoProvider
54 void getMediaInfo(TclObject& result) override;
55
56 template<typename Archive>
57 void serialize(Archive& ar, unsigned version);
58
59private:
60 // SectorAccessibleDisk:
61 void readSectorsImpl(
62 std::span<SectorBuffer> buffers, size_t startSector) override;
63 void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
64 [[nodiscard]] size_t getNbSectorsImpl() const override;
65 [[nodiscard]] bool isWriteProtectedImpl() const override;
66 [[nodiscard]] Sha1Sum getSha1SumImpl(FilePool& filePool) override;
67
68 // DiskContainer:
69 [[nodiscard]] SectorAccessibleDisk* getSectorAccessibleDisk() override;
70 [[nodiscard]] std::string_view getContainerName() const override;
71 [[nodiscard]] bool diskChanged() override;
72 int insertDisk(const std::string& filename) override;
73
74 // SCSI Device
75 void reset() override;
76 [[nodiscard]] bool isSelected() override;
77 [[nodiscard]] unsigned executeCmd(std::span<const uint8_t, 12> cdb, SCSI::Phase& phase, unsigned& blocks) override;
78 [[nodiscard]] unsigned executingCmd(SCSI::Phase& phase, unsigned& blocks) override;
79 [[nodiscard]] uint8_t getStatusCode() override;
80 int msgOut(uint8_t value) override;
81 uint8_t msgIn() override;
82 void disconnect() override;
83 void busReset() override;
84 [[nodiscard]] unsigned dataIn(unsigned& blocks) override;
85 [[nodiscard]] unsigned dataOut(unsigned& blocks) override;
86
87 void eject();
88 void insert(const std::string& filename);
89
90 [[nodiscard]] bool getReady();
91 void testUnitReady();
92 void startStopUnit();
93 [[nodiscard]] unsigned inquiry();
94 [[nodiscard]] unsigned modeSense();
95 [[nodiscard]] unsigned requestSense();
96 [[nodiscard]] bool checkReadOnly();
97 [[nodiscard]] unsigned readCapacity();
98 [[nodiscard]] bool checkAddress();
99 [[nodiscard]] unsigned readSector(unsigned& blocks);
100 [[nodiscard]] unsigned writeSector(unsigned& blocks);
101 void formatUnit();
102
103private:
104 MSXMotherBoard& motherBoard;
105 AlignedBuffer& buffer;
106 File file;
107 std::optional<LSXCommand> lsxCommand; // delayed init
108 std::string name;
109 const unsigned mode;
110 unsigned keycode; // Sense key, ASC, ASCQ
111 unsigned currentSector;
112 unsigned currentLength;
113 const uint8_t scsiId; // SCSI ID 0..7
114 bool unitAttention; // Unit Attention (was: reset)
115 bool mediaChanged; // Enhanced change flag for MEGA-SCSI driver
116 uint8_t message;
117 uint8_t lun;
118 std::array<uint8_t, 12> cdb; // Command Descriptor Block
119
120 static constexpr unsigned MAX_LS = 26;
121 using LSInUse = std::bitset<MAX_LS>;
122 std::shared_ptr<LSInUse> lsInUse;
123
124 friend class LSXCommand;
125};
126
127} // namespace openmsx
128
129#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:759
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
Definition: SCSILS120.cc:805
LSXCommand(CommandController &commandController, StateChangeDistributor &stateChangeDistributor, Scheduler &scheduler, SCSILS120 &ls)
Definition: SCSILS120.cc:750
std::string help(std::span< const TclObject > tokens) const override
Print help for this command.
Definition: SCSILS120.cc:796
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:113
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:124
SCSILS120(const SCSILS120 &)=delete
void serialize(Archive &ar, unsigned version)
Definition: SCSILS120.cc:814
This class represents the result of a sha1 calculation (a 160-bit value).
Definition: sha1.hh:23
This file implemented 3 utility functions:
Definition: Autofire.cc:9