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