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
openmsx::IDECDROM::IDECDROM
IDECDROM(const IDECDROM &)=delete
AbstractIDEDevice.hh
openmsx::IDECDROM::fillIdentifyBlock
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:90
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::IDECDROM::isPacketDevice
bool isPacketDevice() override
Is this device a packet (ATAPI) device?
Definition: IDECDROM.cc:79
LZ4::count
ALWAYS_INLINE unsigned count(const uint8_t *pIn, const uint8_t *pMatch, const uint8_t *pInLimit)
Definition: lz4.cc:207
openmsx::IDECDROM::~IDECDROM
~IDECDROM() override
Definition: IDECDROM.cc:70
openmsx::IDECDROM::readBlockStart
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:110
openmsx::CDXCommand
Definition: IDECDROM.cc:23
openmsx::IDECDROM::serialize
void serialize(Archive &ar, unsigned version)
Definition: IDECDROM.cc:396
openmsx::IDECDROM::executeCommand
void executeCommand(byte cmd) override
Starts execution of an IDE command.
Definition: IDECDROM.cc:140
File.hh
openmsx::IDECDROM
Definition: IDECDROM.hh:14
openmsx::filename
constexpr const char *const filename
Definition: FirmwareSwitch.cc:10
openmsx::AlignedBuffer
Definition: AlignedBuffer.hh:27
openmsx::IDECDROM::writeBlockComplete
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:132
openmsx::IDECDROM::eject
void eject()
Definition: IDECDROM.cc:311
openmsx::File
Definition: File.hh:15
openmsx::AbstractIDEDevice
Definition: AbstractIDEDevice.hh:13
openmsx::IDECDROM::getDeviceName
const std::string & getDeviceName() override
Gets the device name to insert as "model number" into the identify block.
Definition: IDECDROM.cc:84
openmsx::IDECDROM::insert
void insert(const std::string &filename)
Definition: IDECDROM.cc:319
openmsx::IDECDROM::readEnd
void readEnd() override
Called when a read transfer completes.
Definition: IDECDROM.cc:127
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::IDECDROM::operator=
IDECDROM & operator=(const IDECDROM &)=delete