MityDSP Documentation Index

MityDSP::tcDspAta Class Reference

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>

Inheritance diagram for MityDSP::tcDspAta:
MityDSP::tcDspStorageBase

List of all members.

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.

Detailed Description

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.

See also:
tcDspAta Page

Constructor & Destructor Documentation

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.

Parameters:
[in] apAddress Address for the ATA interface.
[in] anDevice Starting device number (0 or 1).
Returns:
None.
See also:
DspAta.h
tcDspAta::~tcDspAta (  )  [virtual]

Default destructor.


Member Function Documentation

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.

Parameters:
[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.
Returns:
The number of bytes successfully written.
See also:
DspAta.h

Implements MityDSP::tcDspStorageBase.

int tcDspAta::write ( unsigned int  anSector,
unsigned int  anOffset,
void *  apData,
int  anBytes 
) [virtual]

Sector-based version of the write method.

Parameters:
[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.
Returns:
The number of bytes successfully written.
See also:
DspAta.h

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.

Parameters:
[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.
Returns:
The number of bytes successfully read.
See also:
DspAta.h

Implements MityDSP::tcDspStorageBase.

int tcDspAta::read ( unsigned int  anSector,
unsigned int  anOffset,
void *  apBuffer,
int  anBytes 
) [virtual]

Sector-based version of the read method.

Parameters:
[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.
Returns:
The number of bytes successfully read.
See also:
DspAta.h

Implements MityDSP::tcDspStorageBase.

bool tcDspAta::reset ( void   )  [virtual]

This routine performs a soft reset of the ATA device.

Returns:
true if reset succedded, false otherwise.
See also:
DspAta.h
tcDspAta::tuAtaSr tcDspAta::get_status ( void   ) 

This routine gets the current value of the ATA status register.

Returns:
contents of the ATA status register as a tuAtaSr struct
See also:
DspAta.h
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.

Returns:
size of the device in KB.
See also:
DspAta.h
tcDspAta::tuAtaErr tcDspAta::get_error ( void   ) 

This routine gets the current value of the ATA error register.

Returns:
contents of the ATA error register as a tuAtaErr struct
See also:
DspAta.h
bool tcDspAta::initialize ( void   )  [protected]

This routine initializes the ATA device, and returns true if successful.

Returns:
True if no errors occurred
See also:
DspAta.h
void tcDspAta::select_device ( int  anDevice  )  [protected]

This routine configures the drive/head register for the specified device (always in LBA mode).

Parameters:
[in] anDevice Device number (0 or 1).
Returns:
None.
See also:
DspAta.h
void tcDspAta::identify ( unsigned short *  apIdBuffer  )  [protected]

This routine reads device identity data into the supplied buffer.

Parameters:
[out] apIdBuffer Buffer for holding identity data
Returns:
None.
See also:
DspAta.h
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.

Note:
Existing mpPageBuffer contents are overwritten. The caller is responsible for providing semaphore locks at a higher level.
Parameters:
[in] anBlock LBA Block to read
Returns:
True if read is successful, false otherwise.
See also:
DspAta.h
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.

Note:
The caller is responsible for filling mpPageBuffer prior to calling this routine. Semaphore locks should be provided at a higher level.
Parameters:
[in] anBlock LBA Block to write to.
Returns:
True if write is successful, false otherwise.
See also:
DspAta.h
void tcDspAta::send_command ( unsigned char  anCmd  )  [protected]

This routine sends a new command to the ATA command register.

Parameters:
[in] anCmd One of the following ATA commands:

  • CMD_CHECK_POWER_MODE
  • CMD_EXECUTE_DRIVE_DIAGNOSTIC
  • CMD_ERASE_SECTORS
  • CMD_FLUSH_CACHE
  • CMD_FORMAT_TRACK
  • CMD_IDENTIFY_DEVICE
  • CMD_IDLE
  • CMD_IDLE_IMMEDIATE
  • CMD_INITIALIZE_DRIVE_PARAMETERS
  • CMD_NOP
  • CMD_READ_BUFFER
  • CMD_READ_DMA
  • CMD_READ_MULTIPLE
  • CMD_READ_SECTORS
  • CMD_READ_VERIFY_SECTORS
  • CMD_RECALIBRATE
  • CMD_REQUEST_SENSE
  • CMD_SEEK
  • CMD_SET_FEATURES
  • CMD_SET_MULTIPLE_MODE
  • CMD_SET_SLEEP_MODE
  • CMD_STANDBY
  • CMD_STANDBY_IMMEDIATE
  • CMD_TRANSLATE_SECTOR
  • CMD_WRITE_BUFFER
  • CMD_WRITE_DMA
  • CMD_WRITE_MULTIPLE
  • CMD_WRITE_MULTIPLE_WO_ERASE
  • CMD_WRITE_SECTORS
  • CMD_WRITE_SECTORS_WO_ERASE
  • CMD_WRITE_VERIFY
Returns:
None.
See also:
DspAta.h
bool tcDspAta::ready ( void   )  [protected]

This routine reads the current ATA status and returns a boolean indicating whether or not the device is ready.

Returns:
True if ready, false otherwise.
See also:
DspAta.h
bool tcDspAta::busy ( void   )  [protected]

This routine reads the current ATA status and returns a boolean indicating whether or not the device is busy.

Returns:
True if busy, false otherwise.
See also:
DspAta.h
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.

Returns:
True if the device is requesting data, false otherwise.
See also:
DspAta.h
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.

Returns:
True if the device is reporting and error, false otherwise.
See also:
DspAta.h
bool tcDspAta::wait_for_drq ( bool  aDrq,
int  aTimeout 
) [protected]

This routine waits till the drq flag is set or a timeout expires.

Parameters:
[in] aDrq drq state we are waiting for
[in] aTimeout number of milliseconds to wait
Returns:
True if drq = aDrq, false otherwise.
See also:
DspAta.h
bool tcDspAta::wait_for_busy ( bool  aBusy,
int  aTimeout 
) [protected]

This routine waits till the busy flag is set or a timeout expires.

Parameters:
[in] aBusy busy state we are waiting for
[in] aTimeout number of milliseconds to wait
Returns:
True if busy = aBusy, false otherwise.
See also:
DspAta.h

Member Data Documentation

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.


  
Generated on Fri Sep 23 16:33:47 2011 for MityDSP Core by  Doxygen Version 1.6.1
Copyright © 2009, Critical Link LLC, All rights reserved.