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 static constexpr unsigned MAX_CD = 26;
35 using CDInUse = std::bitset<MAX_CD>;
36 static std::shared_ptr<CDInUse> getDrivesInUse(MSXMotherBoard& motherBoard);
37
38public:
39 explicit IDECDROM(const DeviceConfig& config);
40 IDECDROM(const IDECDROM&) = delete;
41 IDECDROM(IDECDROM&&) = delete;
42 IDECDROM& operator=(const IDECDROM&) = delete;
44 ~IDECDROM() override;
45
46 void eject();
47 void insert(const std::string& filename);
48
49 // MediaInfoProvider
50 void getMediaInfo(TclObject& result) override;
51
52 template<typename Archive>
53 void serialize(Archive& ar, unsigned version);
54
55protected:
56 // AbstractIDEDevice:
57 [[nodiscard]] bool isPacketDevice() override;
58 [[nodiscard]] std::string_view getDeviceName() override;
59 void fillIdentifyBlock (AlignedBuffer& buffer) override;
60 [[nodiscard]] unsigned readBlockStart(AlignedBuffer& buffer, unsigned count) override;
61 void readEnd() override;
62 void writeBlockComplete(AlignedBuffer& buffer, unsigned count) override;
63 void executeCommand(byte cmd) override;
64
65private:
66 // Flags for the interrupt reason register:
68 static constexpr byte REL = 0x04;
70 static constexpr byte I_O = 0x02;
72 static constexpr byte C_D = 0x01;
73
77 void startPacketReadTransfer(unsigned count);
78
79 void executePacketCommand(AlignedBuffer& packet);
80
81 std::string name;
82 std::optional<CDXCommand> cdxCommand; // delayed init
83 File file;
84 unsigned byteCountLimit;
85 unsigned transferOffset;
86
87 unsigned senseKey;
88
89 bool readSectorData;
90
91 // Removable Media Status Notification Feature Set
92 bool remMedStatNotifEnabled;
93 bool mediaChanged;
94
95 std::shared_ptr<CDInUse> cdInUse;
96
97 friend class CDXCommand;
98};
99
100} // namespace openmsx
101
102#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:335
std::string help(std::span< const TclObject > tokens) const override
Print help for this command.
Definition IDECDROM.cc:374
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
Definition IDECDROM.cc:383
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:81
void serialize(Archive &ar, unsigned version)
Definition IDECDROM.cc:392
std::bitset< MAX_CD > CDInUse
Definition IDECDROM.hh:35
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:106
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:128
~IDECDROM() override
Definition IDECDROM.cc:61
void readEnd() override
Called when a read transfer completes.
Definition IDECDROM.cc:123
IDECDROM(IDECDROM &&)=delete
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:86
static constexpr unsigned MAX_CD
Definition IDECDROM.hh:34
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:71
void executeCommand(byte cmd) override
Starts execution of an IDE command.
Definition IDECDROM.cc:136
IDECDROM & operator=(IDECDROM &&)=delete
bool isPacketDevice() override
Is this device a packet (ATAPI) device?
Definition IDECDROM.cc:76
static std::shared_ptr< CDInUse > getDrivesInUse(MSXMotherBoard &motherBoard)
Definition IDECDROM.cc:23
void insert(const std::string &filename)
Definition IDECDROM.cc:315
Commands that directly influence the MSX state should send and events so that they can be recorded by...
This file implemented 3 utility functions:
Definition Autofire.cc:11