| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef MB89352_HH |
| 12 |
#define MB89352_HH |
| 13 |
|
| 14 |
#include "SCSI.hh" |
| 15 |
#include "SCSIDevice.hh" |
| 16 |
|
| 17 |
#include "AlignedBuffer.hh" |
| 18 |
|
| 19 |
#include <array> |
| 20 |
#include <memory> |
| 21 |
|
| 22 |
namespace openmsx { |
| 23 |
|
| 24 |
class DeviceConfig; |
| 25 |
|
| 26 |
class MB89352 |
| 27 |
{ |
| 28 |
public: |
| 29 |
explicit MB89352(DeviceConfig& config); |
| 30 |
|
| 31 |
void reset(bool scsiReset); |
| 32 |
[[nodiscard]] uint8_t readRegister(uint8_t reg); |
| 33 |
[[nodiscard]] uint8_t peekRegister(uint8_t reg) const; |
| 34 |
[[nodiscard]] uint8_t readDREG(); |
| 35 |
[[nodiscard]] uint8_t peekDREG() const; |
| 36 |
void writeRegister(uint8_t reg, uint8_t value); |
| 37 |
void writeDREG(uint8_t value); |
| 38 |
|
| 39 |
template<typename Archive> |
| 40 |
void serialize(Archive& ar, unsigned version); |
| 41 |
|
| 42 |
private: |
| 43 |
void disconnect(); |
| 44 |
void softReset(); |
| 45 |
void setACKREQ(uint8_t& value); |
| 46 |
void resetACKREQ(); |
| 47 |
[[nodiscard]] uint8_t getSSTS() const; |
| 48 |
|
| 49 |
private: |
| 50 |
static constexpr unsigned MAX_DEV = 8; |
| 51 |
|
| 52 |
std::array<std::unique_ptr<SCSIDevice>, MAX_DEV> dev; |
| 53 |
AlignedByteArray<SCSIDevice::BUFFER_SIZE> buffer; |
| 54 |
unsigned cdbIdx; |
| 55 |
unsigned bufIdx; |
| 56 |
int msgin = 0; |
| 57 |
int counter; |
| 58 |
|
| 59 |
unsigned blockCounter = 0; |
| 60 |
|
| 61 |
int tc; |
| 62 |
SCSI::Phase phase; |
| 63 |
SCSI::Phase nextPhase = SCSI::Phase::UNDEFINED; |
| 64 |
uint8_t myId; |
| 65 |
uint8_t targetId = 0; |
| 66 |
std::array<uint8_t, 16> regs; |
| 67 |
bool rst; |
| 68 |
uint8_t atn; |
| 69 |
bool isEnabled; |
| 70 |
bool isBusy; |
| 71 |
bool isTransfer; |
| 72 |
|
| 73 |
std::array<uint8_t, 12> cdb; |
| 74 |
}; |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
#endif |