openMSX
IDECDROM.hh
Go to the documentation of this file.
1#ifndef IDECDROM_HH
2#define IDECDROM_HH
3
5#include "MSXMotherBoard.hh"
6#include "File.hh"
7#include "RecordedCommand.hh"
8#include <bitset>
9#include <memory>
10#include <optional>
11
12namespace openmsx {
13
14class DeviceConfig;
15class IDECDROM;
16
17class CDXCommand final : public RecordedCommand
18{
19public:
20 CDXCommand(CommandController& commandController,
21 StateChangeDistributor& stateChangeDistributor,
22 Scheduler& scheduler, IDECDROM& cd);
23 void execute(std::span<const TclObject> tokens,
24 TclObject& result, EmuTime::param time) override;
25 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
26 void tabCompletion(std::vector<std::string>& tokens) const override;
27private:
28 IDECDROM& cd;
29};
30
31class IDECDROM final : public AbstractIDEDevice, public MediaInfoProvider
32{
33public:
34 IDECDROM(const IDECDROM&) = delete;
35 IDECDROM& operator=(const IDECDROM&) = delete;
36
37 explicit IDECDROM(const DeviceConfig& config);
38 ~IDECDROM() override;
39
40 void eject();
41 void insert(const std::string& filename);
42
43 // MediaInfoProvider
44 void getMediaInfo(TclObject& result) override;
45
46 template<typename Archive>
47 void serialize(Archive& ar, unsigned version);
48
49protected:
50 // AbstractIDEDevice:
51 [[nodiscard]] bool isPacketDevice() override;
52 [[nodiscard]] std::string_view getDeviceName() override;
53 void fillIdentifyBlock (AlignedBuffer& buffer) override;
54 [[nodiscard]] unsigned readBlockStart(AlignedBuffer& buffer, unsigned count) override;
55 void readEnd() override;
56 void writeBlockComplete(AlignedBuffer& buffer, unsigned count) override;
57 void executeCommand(byte cmd) override;
58
59private:
60 // Flags for the interrupt reason register:
62 static constexpr byte REL = 0x04;
64 static constexpr byte I_O = 0x02;
66 static constexpr byte C_D = 0x01;
67
71 void startPacketReadTransfer(unsigned count);
72
73 void executePacketCommand(AlignedBuffer& packet);
74
75 std::string name;
76 std::optional<CDXCommand> cdxCommand; // delayed init
77 File file;
78 unsigned byteCountLimit;
79 unsigned transferOffset;
80
81 unsigned senseKey;
82
83 bool readSectorData;
84
85 // Removable Media Status Notification Feature Set
86 bool remMedStatNotifEnabled;
87 bool mediaChanged;
88
89 static constexpr unsigned MAX_CD = 26;
90 using CDInUse = std::bitset<MAX_CD>;
91 std::shared_ptr<CDInUse> cdInUse;
92
93 friend class CDXCommand;
94};
95
96} // namespace openmsx
97
98#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: IDECDROM.cc:330
std::string help(std::span< const TclObject > tokens) const override
Print help for this command.
Definition: IDECDROM.cc:370
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
Definition: IDECDROM.cc:379
CDXCommand(CommandController &commandController, StateChangeDistributor &stateChangeDistributor, Scheduler &scheduler, IDECDROM &cd)
Definition: IDECDROM.cc:321
IDECDROM(const IDECDROM &)=delete
std::string_view getDeviceName() override
Gets the device name to insert as "model number" into the identify block.
Definition: IDECDROM.cc:76
void serialize(Archive &ar, unsigned version)
Definition: IDECDROM.cc:388
IDECDROM & operator=(const IDECDROM &)=delete
unsigned readBlockStart(AlignedBuffer &buffer, unsigned count) override
Called when a block of read data should be buffered by the controller: when the buffer is empty or at...
Definition: IDECDROM.cc:101
void writeBlockComplete(AlignedBuffer &buffer, unsigned count) override
Called when a block of written data has been buffered by the controller: when the buffer is full or a...
Definition: IDECDROM.cc:123
~IDECDROM() override
Definition: IDECDROM.cc:56
void readEnd() override
Called when a read transfer completes.
Definition: IDECDROM.cc:118
void fillIdentifyBlock(AlignedBuffer &buffer) override
Tells a subclass to fill the device specific parts of the identify block located in the buffer.
Definition: IDECDROM.cc:81
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: IDECDROM.cc:66
void executeCommand(byte cmd) override
Starts execution of an IDE command.
Definition: IDECDROM.cc:131
bool isPacketDevice() override
Is this device a packet (ATAPI) device?
Definition: IDECDROM.cc:71
void insert(const std::string &filename)
Definition: IDECDROM.cc:310
Commands that directly influence the MSX state should send and events so that they can be recorded by...
ALWAYS_INLINE unsigned count(const uint8_t *pIn, const uint8_t *pMatch, const uint8_t *pInLimit)
Definition: lz4.cc:147
This file implemented 3 utility functions:
Definition: Autofire.cc:9