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

#include <AbstractIDEDevice.hh>

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

Public Member Functions

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

Protected Member Functions

 AbstractIDEDevice (MSXMotherBoard &motherBoard)
virtual ~AbstractIDEDevice ()
virtual bool isPacketDevice ()=0
 Is this device a packet (ATAPI) device?
virtual const std::string & getDeviceName ()=0
 Gets the device name to insert as "model number" into the identify block.
virtual void fillIdentifyBlock (byte *buffer)=0
 Tells a subclass to fill the device specific parts of the identify block located in the buffer.
virtual unsigned readBlockStart (byte *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 (byte *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 ()
 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.
bytestartShortReadTransfer (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)

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 12 of file AbstractIDEDevice.hh.

Constructor & Destructor Documentation

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

Definition at line 13 of file AbstractIDEDevice.cc.

openmsx::AbstractIDEDevice::~AbstractIDEDevice ( )
protectedvirtual

Definition at line 26 of file AbstractIDEDevice.cc.

Member Function Documentation

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

Aborts the read transfer in progress.

Definition at line 372 of file AbstractIDEDevice.cc.

References ABORT, and setError().

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

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

Aborts the write transfer in progress.

Definition at line 386 of file AbstractIDEDevice.cc.

References ABORT, and setError().

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.

Definition at line 287 of file AbstractIDEDevice.cc.

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

Referenced by writeReg().

virtual void openmsx::AbstractIDEDevice::fillIdentifyBlock ( byte 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.
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 264 of file AbstractIDEDevice.cc.

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

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.
byte openmsx::AbstractIDEDevice::getFeatureReg ( ) const
inlineprotected

Definition at line 153 of file AbstractIDEDevice.hh.

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

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

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

Definition at line 254 of file AbstractIDEDevice.cc.

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

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

Is this device a packet (ATAPI) device?

Returns
True iff this device supports the packet commands.

Referenced by executeCommand().

virtual unsigned openmsx::AbstractIDEDevice::readBlockStart ( byte 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).
word openmsx::AbstractIDEDevice::readData ( EmuTime::param  time)
virtual

Implements openmsx::IDEDevice.

Definition at line 167 of file AbstractIDEDevice.cc.

References DRQ, and readEnd().

void openmsx::AbstractIDEDevice::readEnd ( )
protectedvirtual

Called when a read transfer completes.

The default implementation does nothing.

Definition at line 283 of file AbstractIDEDevice.cc.

Referenced by readData().

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

Implements openmsx::IDEDevice.

Definition at line 71 of file AbstractIDEDevice.cc.

References UNREACHABLE.

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

Implements openmsx::IDEDevice.

Definition at line 61 of file AbstractIDEDevice.cc.

References DRDY, and DSC.

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

Definition at line 448 of file AbstractIDEDevice.cc.

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

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

References DRQ, and ERR.

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

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

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

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

Definition at line 156 of file AbstractIDEDevice.hh.

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

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

Definition at line 154 of file AbstractIDEDevice.hh.

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

Definition at line 155 of file AbstractIDEDevice.hh.

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

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

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

byte * 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 345 of file AbstractIDEDevice.cc.

Referenced by executeCommand().

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

References DRQ.

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

virtual void openmsx::AbstractIDEDevice::writeBlockComplete ( byte 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.

Referenced by writeData().

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

Implements openmsx::IDEDevice.

Definition at line 201 of file AbstractIDEDevice.cc.

References DRQ, and writeBlockComplete().

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

Implements openmsx::IDEDevice.

Definition at line 113 of file AbstractIDEDevice.cc.

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

Member Data Documentation

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

Definition at line 36 of file AbstractIDEDevice.hh.

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

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

Definition at line 28 of file AbstractIDEDevice.hh.

Referenced by executeCommand(), and reset().

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

Definition at line 30 of file AbstractIDEDevice.hh.

Referenced by readData(), setError(), startWriteTransfer(), writeData(), and writeReg().

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

Definition at line 29 of file AbstractIDEDevice.hh.

Referenced by executeCommand(), and reset().

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

Definition at line 31 of file AbstractIDEDevice.hh.

Referenced by setError(), and writeReg().

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

Definition at line 35 of file AbstractIDEDevice.hh.

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

Definition at line 34 of file AbstractIDEDevice.hh.


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