OXYGENHUB
◆ main openmsx / src / ide / SCSIHD.hh
2.1 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
/* Ported from:
2
** Source: /cvsroot/bluemsx/blueMSX/Src/IoDevice/ScsiDevice.h,v
3
** Revision: 1.6
4
** Date: 2007-05-22 20:05:38 +0200 (Tue, 22 May 2007)
5
**
6
** More info: http://www.bluemsx.com
7
**
8
** Copyright (C) 2003-2007 Daniel Vik, white cat
9
*/
10
#ifndef SCSIHD_HH
11
#define SCSIHD_HH
12
13
#include "HD.hh"
14
#include "SCSIDevice.hh"
15
#include <array>
16
17
namespace openmsx {
18
19
class DeviceConfig;
20
21
class SCSIHD final : public HD, public SCSIDevice
22
{
23
public:
24
	SCSIHD(const DeviceConfig& targetConfig,
25
	       AlignedBuffer& buf, unsigned mode);
26
	SCSIHD(const SCSIHD&) = delete;
27
	SCSIHD(SCSIHD&&) = delete;
28
	SCSIHD& operator=(const SCSIHD&) = delete;
29
	SCSIHD& operator=(SCSIHD&&) = delete;
30
	~SCSIHD() override = default;
31
32
	template<typename Archive>
33
	void serialize(Archive& ar, unsigned version);
34
35
private:
36
	// SCSI Device
37
	void reset() override;
38
	bool isSelected() override;
39
	[[nodiscard]] unsigned executeCmd(std::span<const uint8_t, 12> cdb, SCSI::Phase& phase,
40
	                                  unsigned& blocks) override;
41
	[[nodiscard]] unsigned executingCmd(SCSI::Phase& phase, unsigned& blocks) override;
42
	[[nodiscard]] uint8_t getStatusCode() override;
43
	int msgOut(uint8_t value) override;
44
	uint8_t msgIn() override;
45
	void disconnect() override;
46
	void busReset() override;
47
48
	[[nodiscard]] unsigned dataIn(unsigned& blocks) override;
49
	[[nodiscard]] unsigned dataOut(unsigned& blocks) override;
50
51
	[[nodiscard]] unsigned inquiry();
52
	[[nodiscard]] unsigned modeSense();
53
	[[nodiscard]] unsigned requestSense();
54
	[[nodiscard]] bool checkReadOnly();
55
	[[nodiscard]] unsigned readCapacity();
56
	[[nodiscard]] bool checkAddress();
57
	[[nodiscard]] unsigned readSectors(unsigned& blocks);
58
	[[nodiscard]] unsigned writeSectors(unsigned& blocks);
59
	void formatUnit();
60
61
private:
62
	AlignedBuffer& buffer;
63
64
	const unsigned mode;
65
66
	unsigned keycode;      // Sense key, ASC, ASCQ
67
	unsigned currentSector;
68
	unsigned currentLength;
69
70
	const uint8_t scsiId;  // SCSI ID 0..7
71
	bool unitAttention;    // Unit Attention (was: reset)
72
	uint8_t message = 0;
73
	uint8_t lun = 0;
74
	std::array<uint8_t, 12> cdb; // Command Descriptor Block
75
};
76
77
} // namespace openmsx
78
79
#endif