openMSX
MB89352.hh
Go to the documentation of this file.
1 /* Ported from:
2 ** Source: /cvsroot/bluemsx/blueMSX/Src/IoDevice/MB89352.h,v
3 ** Revision: 1.4
4 ** Date: 2007/03/28 17:35:35
5 **
6 ** More info: http://www.bluemsx.com
7 **
8 ** Copyright (C) 2003-2007 Daniel Vik, white cat
9 */
10 
11 #ifndef MB89352_HH
12 #define MB89352_HH
13 
14 #include "SCSI.hh"
15 #include "SCSIDevice.hh"
16 #include "AlignedBuffer.hh"
17 #include <memory>
18 
19 namespace openmsx {
20 
21 class DeviceConfig;
22 
23 class MB89352
24 {
25 public:
26  explicit MB89352(const DeviceConfig& config);
27 
28  void reset(bool scsireset);
29  [[nodiscard]] byte readRegister(byte reg);
30  [[nodiscard]] byte peekRegister(byte reg) const;
31  [[nodiscard]] byte readDREG();
32  [[nodiscard]] byte peekDREG() const;
33  void writeRegister(byte reg, byte value);
34  void writeDREG(byte value);
35 
36  template<typename Archive>
37  void serialize(Archive& ar, unsigned version);
38 
39 private:
40  void disconnect();
41  void softReset();
42  void setACKREQ(byte& value);
43  void resetACKREQ();
44  [[nodiscard]] byte getSSTS() const;
45 
46 private:
47  static constexpr unsigned MAX_DEV = 8;
48 
49  std::unique_ptr<SCSIDevice> dev[MAX_DEV];
50  AlignedByteArray<SCSIDevice::BUFFER_SIZE> buffer; // buffer for transfer
51  unsigned cdbIdx; // cdb index
52  unsigned bufIdx; // buffer index
53  int msgin; // Message In flag
54  int counter; // read and written number of bytes
55  // within the range in the buffer
56  unsigned blockCounter; // Number of blocks outside buffer
57  // (512bytes / block)
58  int tc; // counter for hardware transfer
59  SCSI::Phase phase; //
60  SCSI::Phase nextPhase; // for message system
61  byte myId; // SPC SCSI ID 0..7
62  byte targetId; // SCSI Device target ID 0..7
63  byte regs[16]; // SPC register
64  bool rst; // SCSI bus reset signal
65  byte atn; // SCSI bus attention signal
66  bool isEnabled; // spc enable flag
67  bool isBusy; // spc now working
68  bool isTransfer; // hardware transfer mode
69  //TODO: bool devBusy; // CD-ROM busy (buffer conflict prevention)
70  byte cdb[12]; // Command Descripter Block
71 };
72 
73 } // namespace openmsx
74 
75 #endif
void writeDREG(byte value)
Definition: MB89352.cc:426
byte peekRegister(byte reg) const
Definition: MB89352.cc:713
void writeRegister(byte reg, byte value)
Definition: MB89352.cc:441
byte readRegister(byte reg)
Definition: MB89352.cc:664
void reset(bool scsireset)
Definition: MB89352.cc:169
void serialize(Archive &ar, unsigned version)
Definition: MB89352.cc:752
byte peekDREG() const
Definition: MB89352.cc:704
MB89352(const DeviceConfig &config)
Definition: MB89352.cc:93
byte readDREG()
Definition: MB89352.cc:408
This file implemented 3 utility functions:
Definition: Autofire.cc:9
constexpr unsigned MAX_DEV
Definition: WD33C93.cc:30