openMSX
SCSILS120.hh
Go to the documentation of this file.
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 
13 #include "SCSIDevice.hh"
14 #include "SectorAccessibleDisk.hh"
15 #include "DiskContainer.hh"
16 #include "File.hh"
17 #include <bitset>
18 #include <memory>
19 
20 namespace openmsx {
21 
22 class DeviceConfig;
23 class MSXMotherBoard;
24 class LSXCommand;
25 
26 class SCSILS120 final : public SCSIDevice, public SectorAccessibleDisk
27  , public DiskContainer
28 {
29 public:
30  SCSILS120(const SCSILS120&) = delete;
31  SCSILS120 operator=(const SCSILS120&) = delete;
32 
33  SCSILS120(const DeviceConfig& targetconfig,
34  AlignedBuffer& buf, unsigned mode);
35  ~SCSILS120() override;
36 
37  template<typename Archive>
38  void serialize(Archive& ar, unsigned version);
39 
40 private:
41  // SectorAccessibleDisk:
42  void readSectorsImpl(
43  SectorBuffer* buffers, size_t startSector, size_t num) override;
44  void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
45  [[nodiscard]] size_t getNbSectorsImpl() const override;
46  [[nodiscard]] bool isWriteProtectedImpl() const override;
47  [[nodiscard]] Sha1Sum getSha1SumImpl(FilePool& filePool) override;
48 
49  // Diskcontainer:
50  [[nodiscard]] SectorAccessibleDisk* getSectorAccessibleDisk() override;
51  [[nodiscard]] std::string_view getContainerName() const override;
52  [[nodiscard]] bool diskChanged() override;
53  int insertDisk(const std::string& filename) override;
54 
55  // SCSI Device
56  void reset() override;
57  [[nodiscard]] bool isSelected() override;
58  [[nodiscard]] unsigned executeCmd(const byte* cdb, SCSI::Phase& phase, unsigned& blocks) override;
59  [[nodiscard]] unsigned executingCmd(SCSI::Phase& phase, unsigned& blocks) override;
60  [[nodiscard]] byte getStatusCode() override;
61  int msgOut(byte value) override;
62  byte msgIn() override;
63  void disconnect() override;
64  void busReset() override;
65  [[nodiscard]] unsigned dataIn(unsigned& blocks) override;
66  [[nodiscard]] unsigned dataOut(unsigned& blocks) override;
67 
68  void eject();
69  void insert(const std::string& filename);
70 
71  [[nodiscard]] bool getReady();
72  void testUnitReady();
73  void startStopUnit();
74  [[nodiscard]] unsigned inquiry();
75  [[nodiscard]] unsigned modeSense();
76  [[nodiscard]] unsigned requestSense();
77  [[nodiscard]] bool checkReadOnly();
78  [[nodiscard]] unsigned readCapacity();
79  [[nodiscard]] bool checkAddress();
80  [[nodiscard]] unsigned readSector(unsigned& blocks);
81  [[nodiscard]] unsigned writeSector(unsigned& blocks);
82  void formatUnit();
83 
84 private:
85  MSXMotherBoard& motherBoard;
86  AlignedBuffer& buffer;
87  File file;
88  std::unique_ptr<LSXCommand> lsxCommand;
89  std::string name;
90  const int mode;
91  unsigned keycode; // Sense key, ASC, ASCQ
92  unsigned currentSector;
93  unsigned currentLength;
94  const byte scsiId; // SCSI ID 0..7
95  bool unitAttention; // Unit Attention (was: reset)
96  bool mediaChanged; // Enhanced change flag for MEGA-SCSI driver
97  byte message;
98  byte lun;
99  byte cdb[12]; // Command Descriptor Block
100 
101  static constexpr unsigned MAX_LS = 26;
102  using LSInUse = std::bitset<MAX_LS>;
103  std::shared_ptr<LSInUse> lsInUse;
104 
105  friend class LSXCommand;
106 };
107 
108 } // namespace openmsx
109 
110 #endif
SCSILS120 operator=(const SCSILS120 &)=delete
~SCSILS120() override
Definition: SCSILS120.cc:126
SCSILS120(const SCSILS120 &)=delete
void serialize(Archive &ar, unsigned version)
Definition: SCSILS120.cc:821
This class represents the result of a sha1 calculation (a 160-bit value).
Definition: sha1.hh:22
This file implemented 3 utility functions:
Definition: Autofire.cc:5
constexpr const char *const filename