MB89352.hh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #ifndef MB89352_HH
  11. #define MB89352_HH
  12. #include "SCSI.hh"
  13. #include "SCSIDevice.hh"
  14. #include "AlignedBuffer.hh"
  15. #include <memory>
  16. namespace openmsx {
  17. class DeviceConfig;
  18. class MB89352
  19. {
  20. public:
  21. explicit MB89352(const DeviceConfig& config);
  22. void reset(bool scsireset);
  23. byte readRegister(byte reg);
  24. byte peekRegister(byte reg) const;
  25. byte readDREG();
  26. byte peekDREG() const;
  27. void writeRegister(byte reg, byte value);
  28. void writeDREG(byte value);
  29. template<typename Archive>
  30. void serialize(Archive& ar, unsigned version);
  31. private:
  32. void disconnect();
  33. void softReset();
  34. void setACKREQ(byte& value);
  35. void resetACKREQ();
  36. byte getSSTS() const;
  37. std::unique_ptr<SCSIDevice> dev[8];
  38. AlignedByteArray<SCSIDevice::BUFFER_SIZE> buffer; // buffer for transfer
  39. unsigned cdbIdx; // cdb index
  40. unsigned bufIdx; // buffer index
  41. int msgin; // Message In flag
  42. int counter; // read and written number of bytes
  43. // within the range in the buffer
  44. unsigned blockCounter; // Number of blocks outside buffer
  45. // (512bytes / block)
  46. int tc; // counter for hardware transfer
  47. SCSI::Phase phase; //
  48. SCSI::Phase nextPhase; // for message system
  49. byte myId; // SPC SCSI ID 0..7
  50. byte targetId; // SCSI Device target ID 0..7
  51. byte regs[16]; // SPC register
  52. bool rst; // SCSI bus reset signal
  53. byte atn; // SCSI bus attention signal
  54. bool isEnabled; // spc enable flag
  55. bool isBusy; // spc now working
  56. bool isTransfer; // hardware transfer mode
  57. //TODO: bool devBusy; // CDROM busy (buffer conflict prevention)
  58. byte cdb[12]; // Command Descripter Block
  59. };
  60. } // namespace openmsx
  61. #endif