openMSX
Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
openmsx::AbstractIDEDevice Class Referenceabstract

#include <AbstractIDEDevice.hh>

Inheritance diagram for openmsx::AbstractIDEDevice:
Inheritance graph
[legend]
Collaboration diagram for openmsx::AbstractIDEDevice:
Collaboration graph
[legend]

Public Member Functions

void reset (EmuTime::param time) override
 
word readData (EmuTime::param time) override
 
byte readReg (nibble reg, EmuTime::param time) override
 
void writeData (word value, EmuTime::param time) override
 
void writeReg (nibble reg, byte value, EmuTime::param time) override
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 
- Public Member Functions inherited from openmsx::IDEDevice
virtual ~IDEDevice ()=default
 

Protected Member Functions

 AbstractIDEDevice (MSXMotherBoard &motherBoard)
 
 ~AbstractIDEDevice () override=default
 
virtual bool isPacketDevice ()=0
 Is this device a packet (ATAPI) device?
 
virtual std::string_view getDeviceName ()=0
 Gets the device name to insert as "model number" into the identify block.
 
virtual void fillIdentifyBlock (AlignedBuffer &buffer)=0
 Tells a subclass to fill the device specific parts of the identify block located in the buffer.
 
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 the start of the transfer.
 
virtual void readEnd ()
 Called when a read transfer completes.
 
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 at the end of the transfer.
 
virtual void executeCommand (byte cmd)
 Starts execution of an IDE command.
 
void setError (byte error)
 Indicates an error: sets error register, error flag, aborts transfers.
 
unsigned getSectorNumber () const
 Creates an LBA sector address from the contents of the sectorNumReg, cylinderLowReg, cylinderHighReg and devHeadReg registers.
 
unsigned getNumSectors () const
 Gets the number of sectors indicated by the sector count register.
 
void setInterruptReason (byte value)
 Writes the interrupt reason register.
 
unsigned getByteCount () const
 Reads the byte count limit of a packet transfer in the registers.
 
void setByteCount (unsigned count)
 Writes the byte count of a packet transfer in the registers.
 
void setSectorNumber (unsigned lba)
 Writes a 28-bit LBA sector number in the registers.
 
void startLongReadTransfer (unsigned count)
 Indicates the start of a read data transfer which uses blocks.
 
AlignedBufferstartShortReadTransfer (unsigned count)
 Indicates the start of a read data transfer where all data fits into the buffer at once.
 
void abortReadTransfer (byte error)
 Aborts the read transfer in progress.
 
void startWriteTransfer (unsigned count)
 Indicates the start of a write data transfer.
 
void abortWriteTransfer (byte error)
 Aborts the write transfer in progress.
 
byte getFeatureReg () const
 
void setLBALow (byte value)
 
void setLBAMid (byte value)
 
void setLBAHigh (byte value)
 
MSXMotherBoardgetMotherBoard () const
 

Static Protected Attributes

static constexpr byte DRDY = 0x40
 
static constexpr byte DSC = 0x10
 
static constexpr byte DRQ = 0x08
 
static constexpr byte ERR = 0x01
 
static constexpr byte UNC = 0x40
 
static constexpr byte IDNF = 0x10
 
static constexpr byte ABORT = 0x04
 

Detailed Description

Definition at line 13 of file AbstractIDEDevice.hh.

Constructor & Destructor Documentation

◆ AbstractIDEDevice()

openmsx::AbstractIDEDevice::AbstractIDEDevice ( MSXMotherBoard motherBoard)
explicitprotected

Definition at line 14 of file AbstractIDEDevice.cc.

References ranges::fill().

◆ ~AbstractIDEDevice()

openmsx::AbstractIDEDevice::~AbstractIDEDevice ( )
overrideprotecteddefault

Member Function Documentation

◆ abortReadTransfer()

void openmsx::AbstractIDEDevice::abortReadTransfer ( byte  error)
protected

Aborts the read transfer in progress.

Definition at line 362 of file AbstractIDEDevice.cc.

References ABORT, and setError().

Referenced by openmsx::IDECDROM::readBlockStart().

◆ abortWriteTransfer()

void openmsx::AbstractIDEDevice::abortWriteTransfer ( byte  error)
protected

Aborts the write transfer in progress.

Definition at line 376 of file AbstractIDEDevice.cc.

References ABORT, and setError().

◆ executeCommand()

void openmsx::AbstractIDEDevice::executeCommand ( byte  cmd)
protectedvirtual

Starts execution of an IDE command.

Override this to implement additional commands and make sure you call the superclass implementation for all commands that you don't handle.

Reimplemented in openmsx::IDECDROM.

Definition at line 277 of file AbstractIDEDevice.cc.

References ABORT, DRDY, DSC, getFeatureReg(), isPacketDevice(), setError(), and startShortReadTransfer().

Referenced by openmsx::IDECDROM::executeCommand(), and writeReg().

◆ fillIdentifyBlock()

virtual void openmsx::AbstractIDEDevice::fillIdentifyBlock ( AlignedBuffer buffer)
protectedpure virtual

Tells a subclass to fill the device specific parts of the identify block located in the buffer.

The generic part is already written there.

Parameters
bufferArray of 512 bytes.

Implemented in openmsx::IDECDROM.

◆ getByteCount()

unsigned openmsx::AbstractIDEDevice::getByteCount ( ) const
protected

Reads the byte count limit of a packet transfer in the registers.

The cylinder low/high registers are used for this.

Definition at line 254 of file AbstractIDEDevice.cc.

Referenced by openmsx::IDECDROM::executeCommand().

◆ getDeviceName()

virtual std::string_view openmsx::AbstractIDEDevice::getDeviceName ( )
protectedpure virtual

Gets the device name to insert as "model number" into the identify block.

Returns
An ASCII string, up to 40 characters long.

Implemented in openmsx::IDECDROM.

◆ getFeatureReg()

byte openmsx::AbstractIDEDevice::getFeatureReg ( ) const
inlineprotected

Definition at line 154 of file AbstractIDEDevice.hh.

Referenced by executeCommand(), and openmsx::IDECDROM::executeCommand().

◆ getMotherBoard()

MSXMotherBoard & openmsx::AbstractIDEDevice::getMotherBoard ( ) const
inlineprotected

◆ getNumSectors()

unsigned openmsx::AbstractIDEDevice::getNumSectors ( ) const
protected

Gets the number of sectors indicated by the sector count register.

Definition at line 244 of file AbstractIDEDevice.cc.

◆ getSectorNumber()

unsigned openmsx::AbstractIDEDevice::getSectorNumber ( ) const
protected

Creates an LBA sector address from the contents of the sectorNumReg, cylinderLowReg, cylinderHighReg and devHeadReg registers.

Definition at line 238 of file AbstractIDEDevice.cc.

◆ isPacketDevice()

virtual bool openmsx::AbstractIDEDevice::isPacketDevice ( )
protectedpure virtual

Is this device a packet (ATAPI) device?

Returns
True iff this device supports the packet commands.

Implemented in openmsx::IDECDROM.

Referenced by executeCommand().

◆ readBlockStart()

virtual unsigned openmsx::AbstractIDEDevice::readBlockStart ( AlignedBuffer buffer,
unsigned  count 
)
protectedpure virtual

Called when a block of read data should be buffered by the controller: when the buffer is empty or at the start of the transfer.

Parameters
bufferPointer to the start of a byte array.
countNumber of bytes to be filled by this method. This number will not exceed the array size nor the transfer length.
Returns
The number of bytes that was added to the array, or 0 if the transfer was aborted (the implementation of this method must set the relevant error flags as well).

Implemented in openmsx::IDECDROM.

◆ readData()

word openmsx::AbstractIDEDevice::readData ( EmuTime::param  time)
overridevirtual

Implements openmsx::IDEDevice.

Definition at line 157 of file AbstractIDEDevice.cc.

References readEnd().

◆ readEnd()

void openmsx::AbstractIDEDevice::readEnd ( )
protectedvirtual

Called when a read transfer completes.

The default implementation does nothing.

Reimplemented in openmsx::IDECDROM.

Definition at line 273 of file AbstractIDEDevice.cc.

Referenced by readData().

◆ readReg()

byte openmsx::AbstractIDEDevice::readReg ( nibble  reg,
EmuTime::param  time 
)
overridevirtual

Implements openmsx::IDEDevice.

Definition at line 61 of file AbstractIDEDevice.cc.

References UNREACHABLE.

◆ reset()

void openmsx::AbstractIDEDevice::reset ( EmuTime::param  time)
overridevirtual

Implements openmsx::IDEDevice.

Definition at line 51 of file AbstractIDEDevice.cc.

References DRDY, and DSC.

◆ serialize()

template<typename Archive >
void openmsx::AbstractIDEDevice::serialize ( Archive &  ar,
unsigned  version 
)

Definition at line 439 of file AbstractIDEDevice.cc.

◆ setByteCount()

void openmsx::AbstractIDEDevice::setByteCount ( unsigned  count)
protected

Writes the byte count of a packet transfer in the registers.

The cylinder low/high registers are used for this.

Definition at line 259 of file AbstractIDEDevice.cc.

◆ setError()

void openmsx::AbstractIDEDevice::setError ( byte  error)
protected

Indicates an error: sets error register, error flag, aborts transfers.

Parameters
errorValue to be written to the error register.

Definition at line 225 of file AbstractIDEDevice.cc.

References ERR.

Referenced by abortReadTransfer(), abortWriteTransfer(), executeCommand(), and openmsx::IDECDROM::executeCommand().

◆ setInterruptReason()

void openmsx::AbstractIDEDevice::setInterruptReason ( byte  value)
protected

Writes the interrupt reason register.

This is the same as register as sector count, but serves a different purpose.

Definition at line 249 of file AbstractIDEDevice.cc.

Referenced by openmsx::IDECDROM::executeCommand(), and openmsx::IDECDROM::readEnd().

◆ setLBAHigh()

void openmsx::AbstractIDEDevice::setLBAHigh ( byte  value)
inlineprotected

Definition at line 157 of file AbstractIDEDevice.hh.

Referenced by openmsx::IDECDROM::executeCommand().

◆ setLBALow()

void openmsx::AbstractIDEDevice::setLBALow ( byte  value)
inlineprotected

Definition at line 155 of file AbstractIDEDevice.hh.

◆ setLBAMid()

void openmsx::AbstractIDEDevice::setLBAMid ( byte  value)
inlineprotected

Definition at line 156 of file AbstractIDEDevice.hh.

Referenced by openmsx::IDECDROM::executeCommand().

◆ setSectorNumber()

void openmsx::AbstractIDEDevice::setSectorNumber ( unsigned  lba)
protected

Writes a 28-bit LBA sector number in the registers.

The cylinder low/high registers are used for this.

Definition at line 265 of file AbstractIDEDevice.cc.

◆ startLongReadTransfer()

void openmsx::AbstractIDEDevice::startLongReadTransfer ( unsigned  count)
protected

Indicates the start of a read data transfer which uses blocks.

The readBlockStart() method is called at the start of each block. The first block will be read immediately, so make sure you initialise all variables needed by readBlockStart() before calling this method.

Parameters
countTotal number of bytes to transfer.

Definition at line 348 of file AbstractIDEDevice.cc.

◆ startShortReadTransfer()

AlignedBuffer & openmsx::AbstractIDEDevice::startShortReadTransfer ( unsigned  count)
protected

Indicates the start of a read data transfer where all data fits into the buffer at once.

Parameters
countTotal number of bytes to transfer.
Returns
Pointer to the start of the buffer. The caller should write the data there. The relevant part of the buffer contains zeroes.

Definition at line 335 of file AbstractIDEDevice.cc.

References openmsx::AlignedByteArray< N >::data(), and ranges::fill().

Referenced by executeCommand().

◆ startWriteTransfer()

void openmsx::AbstractIDEDevice::startWriteTransfer ( unsigned  count)
protected

Indicates the start of a write data transfer.

Parameters
countTotal number of bytes to transfer.

Definition at line 368 of file AbstractIDEDevice.cc.

References DRQ.

Referenced by openmsx::IDECDROM::executeCommand().

◆ writeBlockComplete()

virtual void openmsx::AbstractIDEDevice::writeBlockComplete ( AlignedBuffer buffer,
unsigned  count 
)
protectedpure virtual

Called when a block of written data has been buffered by the controller: when the buffer is full or at the end of the transfer.

Parameters
bufferPointer to the start of a byte array.
countNumber of data bytes in the array.

Implemented in openmsx::IDECDROM.

Referenced by writeData().

◆ writeData()

void openmsx::AbstractIDEDevice::writeData ( word  value,
EmuTime::param  time 
)
overridevirtual

Implements openmsx::IDEDevice.

Definition at line 191 of file AbstractIDEDevice.cc.

References writeBlockComplete().

◆ writeReg()

void openmsx::AbstractIDEDevice::writeReg ( nibble  reg,
byte  value,
EmuTime::param  time 
)
overridevirtual

Implements openmsx::IDEDevice.

Definition at line 103 of file AbstractIDEDevice.cc.

References DRQ, ERR, executeCommand(), and UNREACHABLE.

Member Data Documentation

◆ ABORT

constexpr byte openmsx::AbstractIDEDevice::ABORT = 0x04
staticconstexprprotected

Definition at line 37 of file AbstractIDEDevice.hh.

Referenced by abortReadTransfer(), abortWriteTransfer(), and executeCommand().

◆ DRDY

constexpr byte openmsx::AbstractIDEDevice::DRDY = 0x40
staticconstexprprotected

Definition at line 29 of file AbstractIDEDevice.hh.

Referenced by executeCommand(), and reset().

◆ DRQ

constexpr byte openmsx::AbstractIDEDevice::DRQ = 0x08
staticconstexprprotected

Definition at line 31 of file AbstractIDEDevice.hh.

Referenced by startWriteTransfer(), and writeReg().

◆ DSC

constexpr byte openmsx::AbstractIDEDevice::DSC = 0x10
staticconstexprprotected

Definition at line 30 of file AbstractIDEDevice.hh.

Referenced by executeCommand(), and reset().

◆ ERR

constexpr byte openmsx::AbstractIDEDevice::ERR = 0x01
staticconstexprprotected

Definition at line 32 of file AbstractIDEDevice.hh.

Referenced by setError(), and writeReg().

◆ IDNF

constexpr byte openmsx::AbstractIDEDevice::IDNF = 0x10
staticconstexprprotected

Definition at line 36 of file AbstractIDEDevice.hh.

◆ UNC

constexpr byte openmsx::AbstractIDEDevice::UNC = 0x40
staticconstexprprotected

Definition at line 35 of file AbstractIDEDevice.hh.


The documentation for this class was generated from the following files: