IDECDROM.hh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef IDECDROM_HH
  2. #define IDECDROM_HH
  3. #include "AbstractIDEDevice.hh"
  4. #include "File.hh"
  5. #include <bitset>
  6. #include <memory>
  7. namespace openmsx {
  8. class DeviceConfig;
  9. class CDXCommand;
  10. class IDECDROM final : public AbstractIDEDevice
  11. {
  12. public:
  13. IDECDROM(const IDECDROM&) = delete;
  14. IDECDROM& operator=(const IDECDROM&) = delete;
  15. explicit IDECDROM(const DeviceConfig& config);
  16. ~IDECDROM() override;
  17. void eject();
  18. void insert(const std::string& filename);
  19. template<typename Archive>
  20. void serialize(Archive& ar, unsigned version);
  21. protected:
  22. // AbstractIDEDevice:
  23. bool isPacketDevice() override;
  24. const std::string& getDeviceName() override;
  25. void fillIdentifyBlock (AlignedBuffer& buffer) override;
  26. unsigned readBlockStart(AlignedBuffer& buffer, unsigned count) override;
  27. void readEnd() override;
  28. void writeBlockComplete(AlignedBuffer& buffer, unsigned count) override;
  29. void executeCommand(byte cmd) override;
  30. private:
  31. // Flags for the interrupt reason register:
  32. /** Bus release: 0 = normal, 1 = bus release */
  33. static constexpr byte REL = 0x04;
  34. /** I/O direction: 0 = host->device, 1 = device->host */
  35. static constexpr byte I_O = 0x02;
  36. /** Command/data: 0 = data, 1 = command */
  37. static constexpr byte C_D = 0x01;
  38. /** Indicates the start of a read data transfer performed in packets.
  39. * @param count Total number of bytes to transfer.
  40. */
  41. void startPacketReadTransfer(unsigned count);
  42. void executePacketCommand(AlignedBuffer& packet);
  43. std::string name;
  44. std::unique_ptr<CDXCommand> cdxCommand;
  45. File file;
  46. unsigned byteCountLimit;
  47. unsigned transferOffset;
  48. unsigned senseKey;
  49. bool readSectorData;
  50. // Removable Media Status Notification Feature Set
  51. bool remMedStatNotifEnabled;
  52. bool mediaChanged;
  53. static constexpr unsigned MAX_CD = 26;
  54. using CDInUse = std::bitset<MAX_CD>;
  55. std::shared_ptr<CDInUse> cdInUse;
  56. friend class CDXCommand;
  57. };
  58. } // namespace openmsx
  59. #endif