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  byte readRegister(byte reg);
30  byte peekRegister(byte reg) const;
31  byte readDREG();
32  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  byte getSSTS() const;
45 
46  std::unique_ptr<SCSIDevice> dev[8];
47  AlignedByteArray<SCSIDevice::BUFFER_SIZE> buffer; // buffer for transfer
48  unsigned cdbIdx; // cdb index
49  unsigned bufIdx; // buffer index
50  int msgin; // Message In flag
51  int counter; // read and written number of bytes
52  // within the range in the buffer
53  unsigned blockCounter; // Number of blocks outside buffer
54  // (512bytes / block)
55  int tc; // counter for hardware transfer
56  SCSI::Phase phase; //
57  SCSI::Phase nextPhase; // for message system
58  byte myId; // SPC SCSI ID 0..7
59  byte targetId; // SCSI Device target ID 0..7
60  byte regs[16]; // SPC register
61  bool rst; // SCSI bus reset signal
62  byte atn; // SCSI bus attention signal
63  bool isEnabled; // spc enable flag
64  bool isBusy; // spc now working
65  bool isTransfer; // hardware transfer mode
66  //TODO: bool devBusy; // CDROM busy (buffer conflict prevention)
67  byte cdb[12]; // Command Descripter Block
68 };
69 
70 } // namespace openmsx
71 
72 #endif
void serialize(Archive &ar, unsigned version)
Definition: MB89352.cc:752
byte readDREG()
Definition: MB89352.cc:408
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
void writeDREG(byte value)
Definition: MB89352.cc:426
void writeRegister(byte reg, byte value)
Definition: MB89352.cc:441
byte peekRegister(byte reg) const
Definition: MB89352.cc:713
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void reset(bool scsireset)
Definition: MB89352.cc:169
MB89352(const DeviceConfig &config)
Definition: MB89352.cc:93
byte peekDREG() const
Definition: MB89352.cc:704
byte readRegister(byte reg)
Definition: MB89352.cc:664