1#ifndef ABSTRACTIDEDEVICE_HH
2#define ABSTRACTIDEDEVICE_HH
16 void reset(EmuTime::param time)
override;
18 [[nodiscard]]
word readData(EmuTime::param time)
override;
19 [[nodiscard]]
byte readReg(
nibble reg, EmuTime::param time)
override;
22 void writeReg(
nibble reg,
byte value, EmuTime::param time)
override;
24 template<
typename Archive>
25 void serialize(Archive& ar,
unsigned version);
29 static constexpr byte DRDY = 0x40;
30 static constexpr byte DSC = 0x10;
31 static constexpr byte DRQ = 0x08;
32 static constexpr byte ERR = 0x01;
35 static constexpr byte UNC = 0x40;
36 static constexpr byte IDNF = 0x10;
37 static constexpr byte ABORT = 0x04;
165 [[nodiscard]]
byte diagnostic()
const;
172 void createSignature(
bool preserveDevice =
false);
182 void startReadTransfer();
187 void readNextBlock();
191 void setTransferRead(
bool status);
196 void writeNextBlock();
200 void setTransferWrite(
bool status);
214 unsigned transferIdx = 0;
218 unsigned bufferLeft = 0;
223 unsigned transferCount = 0;
230 byte cylinderHighReg;
235 bool transferRead =
false;
236 bool transferWrite =
false;
void writeData(word value, EmuTime::param time) override
void startWriteTransfer(unsigned count)
Indicates the start of a write data transfer.
byte getFeatureReg() const
AlignedBuffer & startShortReadTransfer(unsigned count)
Indicates the start of a read data transfer where all data fits into the buffer at once.
~AbstractIDEDevice() override=default
virtual bool isPacketDevice()=0
Is this device a packet (ATAPI) device?
static constexpr byte DRDY
static constexpr byte UNC
void startLongReadTransfer(unsigned count)
Indicates the start of a read data transfer which uses blocks.
void serialize(Archive &ar, unsigned version)
virtual void executeCommand(byte cmd)
Starts execution of an IDE command.
void writeReg(nibble reg, byte value, EmuTime::param time) override
static constexpr byte DRQ
static constexpr byte ERR
virtual void fillIdentifyBlock(AlignedBuffer &buffer)=0
Tells a subclass to fill the device specific parts of the identify block located in the buffer.
void setSectorNumber(unsigned lba)
Writes a 28-bit LBA sector number in the registers.
void setByteCount(unsigned count)
Writes the byte count of a packet transfer in the registers.
MSXMotherBoard & getMotherBoard() const
virtual std::string_view getDeviceName()=0
Gets the device name to insert as "model number" into the identify block.
static constexpr byte DSC
virtual unsigned readBlockStart(AlignedBuffer &buffer, unsigned count)=0
Called when a block of read data should be buffered by the controller: when the buffer is empty or at...
unsigned getNumSectors() const
Gets the number of sectors indicated by the sector count register.
void abortReadTransfer(byte error)
Aborts the read transfer in progress.
unsigned getByteCount() const
Reads the byte count limit of a packet transfer in the registers.
void setLBAMid(byte value)
void setError(byte error)
Indicates an error: sets error register, error flag, aborts transfers.
byte readReg(nibble reg, EmuTime::param time) override
void abortWriteTransfer(byte error)
Aborts the write transfer in progress.
void reset(EmuTime::param time) override
static constexpr byte IDNF
void setLBAHigh(byte value)
void setLBALow(byte value)
unsigned getSectorNumber() const
Creates an LBA sector address from the contents of the sectorNumReg, cylinderLowReg,...
void setInterruptReason(byte value)
Writes the interrupt reason register.
virtual void writeBlockComplete(AlignedBuffer &buffer, unsigned count)=0
Called when a block of written data has been buffered by the controller: when the buffer is full or a...
word readData(EmuTime::param time) override
virtual void readEnd()
Called when a read transfer completes.
static constexpr byte ABORT
This file implemented 3 utility functions:
uint8_t nibble
4 bit integer
uint16_t word
16 bit unsigned integer