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

Static Protected Attributes

static const byte DRDY = 0x40
 
static const byte DSC = 0x10
 
static const byte DRQ = 0x08
 
static const byte ERR = 0x01
 
static const byte UNC = 0x40
 
static const byte IDNF = 0x10
 
static const 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 13 of file AbstractIDEDevice.cc.

References isPacketDevice().

◆ ~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 368 of file AbstractIDEDevice.cc.

Referenced by openmsx::IDECDROM::readBlockStart(), and openmsx::IDEHD::~IDEHD().

◆ abortWriteTransfer()

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

Aborts the write transfer in progress.

Definition at line 382 of file AbstractIDEDevice.cc.

Referenced by openmsx::IDEHD::~IDEHD().

◆ 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 283 of file AbstractIDEDevice.cc.

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

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

◆ 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 ( )
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 260 of file AbstractIDEDevice.cc.

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

◆ getDeviceName()

virtual const std::string& 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 openmsx::IDECDROM::executeCommand(), and 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 250 of file AbstractIDEDevice.cc.

Referenced by openmsx::IDEHD::~IDEHD().

◆ 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 244 of file AbstractIDEDevice.cc.

Referenced by openmsx::IDEHD::~IDEHD().

◆ 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 AbstractIDEDevice(), and 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.

Referenced by readData().

◆ readData()

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

Implements openmsx::IDEDevice.

Definition at line 163 of file AbstractIDEDevice.cc.

References DRQ, readBlockStart(), and 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 279 of file AbstractIDEDevice.cc.

Referenced by readData().

◆ readReg()

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

Implements openmsx::IDEDevice.

Definition at line 67 of file AbstractIDEDevice.cc.

References UNREACHABLE.

◆ reset()

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

Implements openmsx::IDEDevice.

Definition at line 57 of file AbstractIDEDevice.cc.

References DRDY, and DSC.

◆ serialize()

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

Definition at line 445 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 265 of file AbstractIDEDevice.cc.

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

◆ 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 231 of file AbstractIDEDevice.cc.

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

◆ 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 255 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 271 of file AbstractIDEDevice.cc.

Referenced by openmsx::IDEHD::~IDEHD().

◆ 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 354 of file AbstractIDEDevice.cc.

References ranges::count(), and DRQ.

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

◆ 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 341 of file AbstractIDEDevice.cc.

References ranges::count().

Referenced by openmsx::IDECDROM::executeCommand(), and 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 374 of file AbstractIDEDevice.cc.

References ranges::count(), and DRQ.

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

◆ 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 197 of file AbstractIDEDevice.cc.

References DRQ, and writeBlockComplete().

◆ writeReg()

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

Implements openmsx::IDEDevice.

Definition at line 109 of file AbstractIDEDevice.cc.

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

Member Data Documentation

◆ ABORT

const byte openmsx::AbstractIDEDevice::ABORT = 0x04
staticprotected

Definition at line 37 of file AbstractIDEDevice.hh.

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

◆ DRDY

const byte openmsx::AbstractIDEDevice::DRDY = 0x40
staticprotected

Definition at line 29 of file AbstractIDEDevice.hh.

Referenced by executeCommand(), and reset().

◆ DRQ

const byte openmsx::AbstractIDEDevice::DRQ = 0x08
staticprotected

◆ DSC

const byte openmsx::AbstractIDEDevice::DSC = 0x10
staticprotected

Definition at line 30 of file AbstractIDEDevice.hh.

Referenced by executeCommand(), and reset().

◆ ERR

const byte openmsx::AbstractIDEDevice::ERR = 0x01
staticprotected

Definition at line 32 of file AbstractIDEDevice.hh.

Referenced by writeReg().

◆ IDNF

const byte openmsx::AbstractIDEDevice::IDNF = 0x10
staticprotected

Definition at line 36 of file AbstractIDEDevice.hh.

Referenced by openmsx::IDEHD::~IDEHD().

◆ UNC

const byte openmsx::AbstractIDEDevice::UNC = 0x40
staticprotected

Definition at line 35 of file AbstractIDEDevice.hh.

Referenced by openmsx::IDEHD::~IDEHD().


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