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
17#include "AlignedBuffer.hh"
18
19#include <array>
20#include <memory>
21
22namespace openmsx {
23
24class DeviceConfig;
25
27{
28public:
29 explicit MB89352(const 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
42private:
43 void disconnect();
44 void softReset();
45 void setACKREQ(uint8_t& value);
46 void resetACKREQ();
47 [[nodiscard]] uint8_t getSSTS() const;
48
49private:
50 static constexpr unsigned MAX_DEV = 8;
51
52 std::array<std::unique_ptr<SCSIDevice>, MAX_DEV> dev;
53 AlignedByteArray<SCSIDevice::BUFFER_SIZE> buffer; // buffer for transfer
54 unsigned cdbIdx; // cdb index
55 unsigned bufIdx; // buffer index
56 int msgin = 0; // Message In flag
57 int counter; // read and written number of bytes
58 // within the range in the buffer
59 unsigned blockCounter = 0; // Number of blocks outside buffer
60 // (512bytes / block)
61 int tc; // counter for hardware transfer
62 SCSI::Phase phase; //
63 SCSI::Phase nextPhase = SCSI::Phase::UNDEFINED; // for message system
64 uint8_t myId; // SPC SCSI ID 0..7
65 uint8_t targetId = 0; // SCSI Device target ID 0..7
66 std::array<uint8_t, 16> regs; // SPC register
67 bool rst; // SCSI bus reset signal
68 uint8_t atn; // SCSI bus attention signal
69 bool isEnabled; // spc enable flag
70 bool isBusy; // spc now working
71 bool isTransfer; // hardware transfer mode
72 //TODO: bool devBusy; // CD-ROM busy (buffer conflict prevention)
73 std::array<uint8_t, 12> cdb; // Command Descriptor Block
74};
75
76} // namespace openmsx
77
78#endif
uint8_t peekRegister(uint8_t reg) const
Definition MB89352.cc:711
void reset(bool scsiReset)
Definition MB89352.cc:166
void writeRegister(uint8_t reg, uint8_t value)
Definition MB89352.cc:440
uint8_t readRegister(uint8_t reg)
Definition MB89352.cc:661
void serialize(Archive &ar, unsigned version)
Definition MB89352.cc:750
void writeDREG(uint8_t value)
Definition MB89352.cc:425
uint8_t peekDREG() const
Definition MB89352.cc:702
uint8_t readDREG()
Definition MB89352.cc:407
This file implemented 3 utility functions:
Definition Autofire.cc:11