openMSX
IDECDROM.hh
Go to the documentation of this file.
1 #ifndef IDECDROM_HH
2 #define IDECDROM_HH
3 
4 #include "AbstractIDEDevice.hh"
5 #include "File.hh"
6 #include <bitset>
7 #include <memory>
8 
9 namespace openmsx {
10 
11 class DeviceConfig;
12 class CDXCommand;
13 
14 class IDECDROM final : public AbstractIDEDevice
15 {
16 public:
17  IDECDROM(const IDECDROM&) = delete;
18  IDECDROM& operator=(const IDECDROM&) = delete;
19 
20  explicit IDECDROM(const DeviceConfig& config);
21  ~IDECDROM() override;
22 
23  void eject();
24  void insert(const std::string& filename);
25 
26  template<typename Archive>
27  void serialize(Archive& ar, unsigned version);
28 
29 protected:
30  // AbstractIDEDevice:
31  bool isPacketDevice() override;
32  const std::string& getDeviceName() override;
33  void fillIdentifyBlock (AlignedBuffer& buffer) override;
34  unsigned readBlockStart(AlignedBuffer& buffer, unsigned count) override;
35  void readEnd() override;
36  void writeBlockComplete(AlignedBuffer& buffer, unsigned count) override;
37  void executeCommand(byte cmd) override;
38 
39 private:
40  // Flags for the interrupt reason register:
42  static constexpr byte REL = 0x04;
44  static constexpr byte I_O = 0x02;
46  static constexpr byte C_D = 0x01;
47 
51  void startPacketReadTransfer(unsigned count);
52 
53  void executePacketCommand(AlignedBuffer& packet);
54 
55  std::string name;
56  std::unique_ptr<CDXCommand> cdxCommand;
57  File file;
58  unsigned byteCountLimit;
59  unsigned transferOffset;
60 
61  unsigned senseKey;
62 
63  bool readSectorData;
64 
65  // Removable Media Status Notification Feature Set
66  bool remMedStatNotifEnabled;
67  bool mediaChanged;
68 
69  static constexpr unsigned MAX_CD = 26;
70  using CDInUse = std::bitset<MAX_CD>;
71  std::shared_ptr<CDInUse> cdInUse;
72 
73  friend class CDXCommand;
74 };
75 
76 } // namespace openmsx
77 
78 #endif
void executeCommand(byte cmd) override
Starts execution of an IDE command.
Definition: IDECDROM.cc:139
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:89
bool isPacketDevice() override
Is this device a packet (ATAPI) device?
Definition: IDECDROM.cc:78
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
void insert(const std::string &filename)
Definition: IDECDROM.cc:318
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:131
constexpr const char *const filename
ALWAYS_INLINE unsigned count(const uint8_t *pIn, const uint8_t *pMatch, const uint8_t *pInLimit)
Definition: lz4.cc:207
const std::string & getDeviceName() override
Gets the device name to insert as "model number" into the identify block.
Definition: IDECDROM.cc:83
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
IDECDROM & operator=(const IDECDROM &)=delete
void readEnd() override
Called when a read transfer completes.
Definition: IDECDROM.cc:126
~IDECDROM() override
Definition: IDECDROM.cc:69
IDECDROM(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:109
void serialize(Archive &ar, unsigned version)
Definition: IDECDROM.cc:396