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 readSectorImpl (size_t sector, SectorBuffer& buf) override;
43  void writeSectorImpl(size_t sector, const SectorBuffer& buf) override;
44  size_t getNbSectorsImpl() const override;
45  bool isWriteProtectedImpl() const override;
46  Sha1Sum getSha1SumImpl(FilePool& filePool) override;
47 
48  // Diskcontainer:
49  SectorAccessibleDisk* getSectorAccessibleDisk() override;
50  const std::string& getContainerName() const override;
51  bool diskChanged() override;
52  int insertDisk(std::string_view filename) override;
53 
54  // SCSI Device
55  void reset() override;
56  bool isSelected() override;
57  unsigned executeCmd(const byte* cdb, SCSI::Phase& phase, unsigned& blocks) override;
58  unsigned executingCmd(SCSI::Phase& phase, unsigned& blocks) override;
59  byte getStatusCode() override;
60  int msgOut(byte value) override;
61  byte msgIn() override;
62  void disconnect() override;
63  void busReset() override;
64  unsigned dataIn(unsigned& blocks) override;
65  unsigned dataOut(unsigned& blocks) override;
66 
67  void eject();
68  void insert(std::string_view filename);
69 
70  bool getReady();
71  void testUnitReady();
72  void startStopUnit();
73  unsigned inquiry();
74  unsigned modeSense();
75  unsigned requestSense();
76  bool checkReadOnly();
77  unsigned readCapacity();
78  bool checkAddress();
79  unsigned readSector(unsigned& blocks);
80  unsigned writeSector(unsigned& blocks);
81  void formatUnit();
82 
83  MSXMotherBoard& motherBoard;
84  AlignedBuffer& buffer;
85  File file;
86  std::unique_ptr<LSXCommand> lsxCommand;
87  std::string name;
88  const int mode;
89  unsigned keycode; // Sense key, ASC, ASCQ
90  unsigned currentSector;
91  unsigned currentLength;
92  const byte scsiId; // SCSI ID 0..7
93  bool unitAttention; // Unit Attention (was: reset)
94  bool mediaChanged; // Enhanced change flag for MEGA-SCSI driver
95  byte message;
96  byte lun;
97  byte cdb[12]; // Command Descriptor Block
98 
99  static constexpr unsigned MAX_LS = 26;
100  using LSInUse = std::bitset<MAX_LS>;
101  std::shared_ptr<LSInUse> lsInUse;
102 
103  friend class LSXCommand;
104 };
105 
106 } // namespace openmsx
107 
108 #endif
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
void serialize(Archive &ar, unsigned version)
Definition: SCSILS120.cc:822
This class represents the result of a sha1 calculation (a 160-bit value).
Definition: sha1.hh:19
constexpr const char *const filename
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
SCSILS120 operator=(const SCSILS120 &)=delete
SCSILS120(const SCSILS120 &)=delete
~SCSILS120() override
Definition: SCSILS120.cc:125