The tcDspAta class is used for low-level reading and writing to ATA storage devices such as disk drives or CompactFlash cards. More...
#include <core/DspAta.h>
Classes | |
union | tuAtaErr |
ATA Error Register. More... | |
union | tuAtaSr |
ATA Status Register. More... | |
Public Member Functions | |
tcDspAta (void *apAddress, int anDevice) | |
This constructor is used to open an ATA interface at the specified address. | |
virtual | ~tcDspAta () |
Default destructor. | |
virtual int | write (void *apAddr, void *apData, int anBytes) |
This routine writes an arbitrary amount of data to an ATA device at a specified offset from the start of the device. | |
virtual int | write (unsigned int anSector, unsigned int anOffset, void *apData, int anBytes) |
Sector-based version of the write method. | |
virtual int | read (void *apStartAddr, void *apBuffer, int anBytes) |
This routine reads an arbitrary amount of data from an ATA device from the specified offset position. | |
virtual int | read (unsigned int anSector, unsigned int anOffset, void *apBuffer, int anBytes) |
Sector-based version of the read method. | |
virtual bool | reset (void) |
This routine performs a soft reset of the ATA device. | |
tuAtaSr | get_status (void) |
This routine gets the current value of the ATA status register. | |
double | get_size (void) |
This routine returns the size of the device in KB (using the getSizeKB method in the tcDspStorageBase base class). | |
tuAtaErr | get_error (void) |
This routine gets the current value of the ATA error register. | |
Protected Member Functions | |
bool | initialize (void) |
This routine initializes the ATA device, and returns true if successful. | |
void | select_device (int anDevice) |
This routine configures the drive/head register for the specified device (always in LBA mode). | |
void | identify (unsigned short *apIdBuffer) |
This routine reads device identity data into the supplied buffer. | |
bool | read_sector (unsigned int anBlock) |
This routine reads the specified LBA block of the device into the page buffer. | |
bool | write_sector (unsigned int anBlock) |
This routine writes the current contents of the page buffer to the specified LBA block of the device. | |
void | send_command (unsigned char anCmd) |
This routine sends a new command to the ATA command register. | |
bool | ready (void) |
This routine reads the current ATA status and returns a boolean indicating whether or not the device is ready. | |
bool | busy (void) |
This routine reads the current ATA status and returns a boolean indicating whether or not the device is busy. | |
bool | drq (void) |
This routine reads the current ATA status and returns a boolean indicating whether or not the device is requesting data. | |
bool | ata_err (void) |
This routine reads the current ATA status and returns a boolean indicating whether or not the device is reporting an error. | |
bool | wait_for_drq (bool aDrq, int aTimeout) |
This routine waits till the drq flag is set or a timeout expires. | |
bool | wait_for_busy (bool aBusy, int aTimeout) |
This routine waits till the busy flag is set or a timeout expires. | |
Protected Attributes | |
volatile unsigned char * | mpBaseAddr |
int | mnDevice |
SEM_Handle | mhSemaphore |
unsigned int | mnSectorSize |
Sector size (bytes). | |
unsigned short * | mpPageBuffer |
Buffer for a sector of data. | |
volatile unsigned short * | mpAtaData |
Pointer to the device data FIFO. |
The tcDspAta class is used for low-level reading and writing to ATA storage devices such as disk drives or CompactFlash cards.
Filesystems and data cache must be provided at a higher level, although these routines may be used for simple read/write access to a device.
tcDspAta::tcDspAta | ( | void * | apAddress, | |
int | anDevice | |||
) |
This constructor is used to open an ATA interface at the specified address.
Each interface may handle up to two devices.
[in] | apAddress | Address for the ATA interface. |
[in] | anDevice | Starting device number (0 or 1). |
tcDspAta::~tcDspAta | ( | ) | [virtual] |
Default destructor.
int tcDspAta::write | ( | void * | apAddr, | |
void * | apData, | |||
int | anBytes | |||
) | [virtual] |
This routine writes an arbitrary amount of data to an ATA device at a specified offset from the start of the device.
The routine handles preservation of data when only a partial sector is written. The data does not have to be sector aligned, although writing aligned, full sectors is most efficient.
[in] | apAddr | Pointer to the offset position on the ATA device. |
[in] | apData | A buffer containing the data to be written. |
[in] | anBytes | Size of the data to be written in bytes. |
Implements MityDSP::tcDspStorageBase.
int tcDspAta::write | ( | unsigned int | anSector, | |
unsigned int | anOffset, | |||
void * | apData, | |||
int | anBytes | |||
) | [virtual] |
Sector-based version of the write method.
[in] | anSector | The sector to write to. |
[in] | anOffset | The offset from the start of the sector. |
[in] | apData | A buffer containing the data to be written. |
[in] | anBytes | Size of the data to be written in bytes. |
Implements MityDSP::tcDspStorageBase.
int tcDspAta::read | ( | void * | apStartAddr, | |
void * | apBuffer, | |||
int | anBytes | |||
) | [virtual] |
This routine reads an arbitrary amount of data from an ATA device from the specified offset position.
Results of the read are stored in apBuffer.
[in] | apStartAddr | Pointer to the data offset on the ATA device. |
[out] | apBuffer | A buffer to hold the data that is read. |
[in] | anBytes | Size of the data to be read in bytes. |
Implements MityDSP::tcDspStorageBase.
int tcDspAta::read | ( | unsigned int | anSector, | |
unsigned int | anOffset, | |||
void * | apBuffer, | |||
int | anBytes | |||
) | [virtual] |
Sector-based version of the read method.
[in] | anSector | The sector to copy from. |
[in] | anOffset | The offset from the start of the sector. |
[out] | apBuffer | A buffer to hold the data that is read. |
[in] | anBytes | Size of the data to be read in bytes. |
Implements MityDSP::tcDspStorageBase.
bool tcDspAta::reset | ( | void | ) | [virtual] |
This routine performs a soft reset of the ATA device.
tcDspAta::tuAtaSr tcDspAta::get_status | ( | void | ) |
double tcDspAta::get_size | ( | void | ) |
This routine returns the size of the device in KB (using the getSizeKB method in the tcDspStorageBase base class).
It is provide for backwards compatibility.
tcDspAta::tuAtaErr tcDspAta::get_error | ( | void | ) |
bool tcDspAta::initialize | ( | void | ) | [protected] |
This routine initializes the ATA device, and returns true if successful.
void tcDspAta::select_device | ( | int | anDevice | ) | [protected] |
This routine configures the drive/head register for the specified device (always in LBA mode).
[in] | anDevice | Device number (0 or 1). |
void tcDspAta::identify | ( | unsigned short * | apIdBuffer | ) | [protected] |
This routine reads device identity data into the supplied buffer.
[out] | apIdBuffer | Buffer for holding identity data |
bool tcDspAta::read_sector | ( | unsigned int | anBlock | ) | [protected] |
This routine reads the specified LBA block of the device into the page buffer.
The routine returns true if the read is successful.
[in] | anBlock | LBA Block to read |
bool tcDspAta::write_sector | ( | unsigned int | anBlock | ) | [protected] |
This routine writes the current contents of the page buffer to the specified LBA block of the device.
The routine returns true if the write is successful.
[in] | anBlock | LBA Block to write to. |
void tcDspAta::send_command | ( | unsigned char | anCmd | ) | [protected] |
This routine sends a new command to the ATA command register.
[in] | anCmd | One of the following ATA commands:
|
bool tcDspAta::ready | ( | void | ) | [protected] |
This routine reads the current ATA status and returns a boolean indicating whether or not the device is ready.
bool tcDspAta::busy | ( | void | ) | [protected] |
This routine reads the current ATA status and returns a boolean indicating whether or not the device is busy.
bool tcDspAta::drq | ( | void | ) | [protected] |
This routine reads the current ATA status and returns a boolean indicating whether or not the device is requesting data.
bool tcDspAta::ata_err | ( | void | ) | [protected] |
This routine reads the current ATA status and returns a boolean indicating whether or not the device is reporting an error.
bool tcDspAta::wait_for_drq | ( | bool | aDrq, | |
int | aTimeout | |||
) | [protected] |
This routine waits till the drq flag is set or a timeout expires.
[in] | aDrq | drq state we are waiting for |
[in] | aTimeout | number of milliseconds to wait |
bool tcDspAta::wait_for_busy | ( | bool | aBusy, | |
int | aTimeout | |||
) | [protected] |
This routine waits till the busy flag is set or a timeout expires.
[in] | aBusy | busy state we are waiting for |
[in] | aTimeout | number of milliseconds to wait |
volatile unsigned char* MityDSP::tcDspAta::mpBaseAddr [protected] |
int MityDSP::tcDspAta::mnDevice [protected] |
SEM_Handle MityDSP::tcDspAta::mhSemaphore [protected] |
unsigned int MityDSP::tcDspAta::mnSectorSize [protected] |
Sector size (bytes).
unsigned short* MityDSP::tcDspAta::mpPageBuffer [protected] |
Buffer for a sector of data.
volatile unsigned short* MityDSP::tcDspAta::mpAtaData [protected] |
Pointer to the device data FIFO.