SCSILS120.hh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* Ported from:
  2. ** Source: /cvsroot/bluemsx/blueMSX/Src/IoDevice/ScsiDevice.h,v
  3. ** Revision: 1.6
  4. ** Date: 2007-05-22 20:05:38 +0200 (Tue, 22 May 2007)
  5. **
  6. ** More info: http://www.bluemsx.com
  7. **
  8. ** Copyright (C) 2003-2007 Daniel Vik, white cat
  9. */
  10. #ifndef SCSILS120_HH
  11. #define SCSILS120_HH
  12. #include "SCSIDevice.hh"
  13. #include "SectorAccessibleDisk.hh"
  14. #include "DiskContainer.hh"
  15. #include "File.hh"
  16. #include <bitset>
  17. #include <memory>
  18. namespace openmsx {
  19. class DeviceConfig;
  20. class MSXMotherBoard;
  21. class LSXCommand;
  22. class SCSILS120 final : public SCSIDevice, public SectorAccessibleDisk
  23. , public DiskContainer
  24. {
  25. public:
  26. SCSILS120(const SCSILS120&) = delete;
  27. SCSILS120 operator=(const SCSILS120&) = delete;
  28. SCSILS120(const DeviceConfig& targetconfig,
  29. AlignedBuffer& buf, unsigned mode);
  30. ~SCSILS120() override;
  31. template<typename Archive>
  32. void serialize(Archive& ar, unsigned version);
  33. private:
  34. // SectorAccessibleDisk:
  35. void readSectorImpl (size_t sector, SectorBuffer& buf) override;
  36. void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
  37. size_t getNbSectorsImpl() const override;
  38. bool isWriteProtectedImpl() const override;
  39. Sha1Sum getSha1SumImpl(FilePool& filePool) override;
  40. // Diskcontainer:
  41. SectorAccessibleDisk* getSectorAccessibleDisk() override;
  42. const std::string& getContainerName() const override;
  43. bool diskChanged() override;
  44. int insertDisk(std::string_view filename) override;
  45. // SCSI Device
  46. void reset() override;
  47. bool isSelected() override;
  48. unsigned executeCmd(const byte* cdb, SCSI::Phase& phase, unsigned& blocks) override;
  49. unsigned executingCmd(SCSI::Phase& phase, unsigned& blocks) override;
  50. byte getStatusCode() override;
  51. int msgOut(byte value) override;
  52. byte msgIn() override;
  53. void disconnect() override;
  54. void busReset() override;
  55. unsigned dataIn(unsigned& blocks) override;
  56. unsigned dataOut(unsigned& blocks) override;
  57. void eject();
  58. void insert(std::string_view filename);
  59. bool getReady();
  60. void testUnitReady();
  61. void startStopUnit();
  62. unsigned inquiry();
  63. unsigned modeSense();
  64. unsigned requestSense();
  65. bool checkReadOnly();
  66. unsigned readCapacity();
  67. bool checkAddress();
  68. unsigned readSector(unsigned& blocks);
  69. unsigned writeSector(unsigned& blocks);
  70. void formatUnit();
  71. MSXMotherBoard& motherBoard;
  72. AlignedBuffer& buffer;
  73. File file;
  74. std::unique_ptr<LSXCommand> lsxCommand;
  75. std::string name;
  76. const int mode;
  77. unsigned keycode; // Sense key, ASC, ASCQ
  78. unsigned currentSector;
  79. unsigned currentLength;
  80. const byte scsiId; // SCSI ID 0..7
  81. bool unitAttention; // Unit Attention (was: reset)
  82. bool mediaChanged; // Enhanced change flag for MEGA-SCSI driver
  83. byte message;
  84. byte lun;
  85. byte cdb[12]; // Command Descriptor Block
  86. static constexpr unsigned MAX_LS = 26;
  87. using LSInUse = std::bitset<MAX_LS>;
  88. std::shared_ptr<LSInUse> lsInUse;
  89. friend class LSXCommand;
  90. };
  91. } // namespace openmsx
  92. #endif