The tcDspStorageBase class is a base class to define a consistent set of interfaces for all storage devices. More...
#include <core/DspStorageBase.h>
Classes | |
struct | tsSectorMap |
mapping of sectors to addresses More... | |
Public Types | |
typedef void(* | tfIsrCallback )(bool, void *) |
prototype for the ISR callback | |
Public Member Functions | |
tcDspStorageBase () | |
This constructor is used to initialize storage base class. | |
virtual | ~tcDspStorageBase () |
Default Destructor. | |
virtual int | write (void *apAddr, void *apData, int anBytes)=0 |
virtual int | write (unsigned int anSector, unsigned int anOffset, void *apData, int anBytes)=0 |
virtual int | read (void *apStartAddr, void *apBuffer, int anBytes)=0 |
virtual int | read (unsigned int anSector, unsigned int anOffset, void *apBuffer, int anBytes)=0 |
virtual bool | erase (unsigned int anSector) |
This routine provides a default erase method. | |
virtual void | registerISRCallback (tfIsrCallback afCallback, void *apUserArg) |
This method is used to register a callback that is activated whenever the device changes state. | |
virtual void * | getAddress (unsigned int anSector, unsigned int anOffset) |
This routine uses the device's sector map to compute an offset address from a supplied sector and offset. | |
virtual unsigned int | getSize (unsigned int anSector) |
This routine uses the device's sector map to determine the size of the specified sector. | |
virtual unsigned int | getSector (void *apAddr) |
This routine uses the device's sector map to compute a sector from a from a supplied offset address. | |
virtual double | getDeviceSizeKB (void) |
This routine returns the size of the device in kilobytes. | |
const tsSectorMap * | getMap (int &anNumSectors) |
This routine returns a pointer to access the device's sector map. | |
virtual bool | getMediaPresent () |
Static Public Member Functions | |
static int | readDispatch (unsigned int anSector, unsigned int anOffset, char *apBuffer, unsigned int anLength, void *apInstance) |
Static dispatch routine to allow the read method to be registered as a callback. | |
static int | writeDispatch (unsigned int anSector, unsigned int anOffset, char *apData, unsigned int anBytes, void *apInstance) |
Static dispatch routine to allow the write method to be registered as a callback. | |
Public Attributes | |
unsigned int | mnTxBytes |
Count of bytes written (debug). | |
unsigned int | mnRxBytes |
Count of bytes read (debug). | |
Protected Attributes | |
unsigned int | mnNumSectors |
Number of sectors in this device. | |
double | mnDeviceSize |
Overall device size (in bytes). | |
tsSectorMap * | mpSectorInfo |
Map of sectors and sizes. | |
bool | mbMediaPresent |
True if device is loaded. | |
tfIsrCallback | mfIsrCallback |
void * | mpUserArg |
User-supplied argument for ISR callback. |
The tcDspStorageBase class is a base class to define a consistent set of interfaces for all storage devices.
This allows any type of device derived from this class to be used with higher-level classes, such as filesystem drivers.
typedef void(* MityDSP::tcDspStorageBase::tfIsrCallback)(bool, void *) |
prototype for the ISR callback
tcDspStorageBase::tcDspStorageBase | ( | void | ) |
tcDspStorageBase::~tcDspStorageBase | ( | ) | [virtual] |
Default Destructor.
int tcDspStorageBase::readDispatch | ( | unsigned int | anSector, | |
unsigned int | anOffset, | |||
char * | apBuffer, | |||
unsigned int | anLength, | |||
void * | apInstance | |||
) | [static] |
Static dispatch routine to allow the read method to be registered as a callback.
Required because of the hidden this pointer associated with a member function.
[in] | anSector | The device sector to write to. |
[in] | anOffset | The byte offset within the specified sector. |
[in] | apBuffer | A pointer to the destination buffer. |
[in] | anLength | The maximum number of bytes to read. |
[in] | apInstance | The "this->" pointer for the instance of tcDspStorageBase associated with this method. |
int tcDspStorageBase::writeDispatch | ( | unsigned int | anSector, | |
unsigned int | anOffset, | |||
char * | apData, | |||
unsigned int | anBytes, | |||
void * | apInstance | |||
) | [static] |
Static dispatch routine to allow the write method to be registered as a callback.
Required because of the hidden this pointer associated with a member function.
[in] | anSector | The device sector to write to. |
[in] | anOffset | The byte offset within the specified sector. |
[in] | apData | A pointer to the source buffer. |
[in] | anBytes | The number of bytes to write. |
[in] | apInstance | The "this->" pointer for the instance of tcDspStorageBase associated with this method. |
virtual int MityDSP::tcDspStorageBase::write | ( | void * | apAddr, | |
void * | apData, | |||
int | anBytes | |||
) | [pure virtual] |
virtual int MityDSP::tcDspStorageBase::write | ( | unsigned int | anSector, | |
unsigned int | anOffset, | |||
void * | apData, | |||
int | anBytes | |||
) | [pure virtual] |
virtual int MityDSP::tcDspStorageBase::read | ( | void * | apStartAddr, | |
void * | apBuffer, | |||
int | anBytes | |||
) | [pure virtual] |
virtual int MityDSP::tcDspStorageBase::read | ( | unsigned int | anSector, | |
unsigned int | anOffset, | |||
void * | apBuffer, | |||
int | anBytes | |||
) | [pure virtual] |
bool tcDspStorageBase::erase | ( | unsigned int | anSector | ) | [virtual] |
This routine provides a default erase method.
This method assumes that the device does not require erase before writing, and just returns "true". Devices requiring erasure must override this method.
[in] | anSector | The sector to erase. |
Reimplemented in MityDSP::tcDspFlash.
void tcDspStorageBase::registerISRCallback | ( | tfIsrCallback | afCallback, | |
void * | apUserArg | |||
) | [virtual] |
This method is used to register a callback that is activated whenever the device changes state.
The callback a parameter of the apUserArg supplied at time of registration (perhaps a this pointer to a C++ class instance).
[in] | afCallback | The ISR callback to register (NULL for none). |
[in] | apUserArg | An argument to be supplied with the callback. |
void * tcDspStorageBase::getAddress | ( | unsigned int | anSector, | |
unsigned int | anOffset | |||
) | [virtual] |
This routine uses the device's sector map to compute an offset address from a supplied sector and offset.
[in] | anSector | The supplied device sector. |
[in] | anOffset | The offset from the start of the device sector. |
unsigned int tcDspStorageBase::getSize | ( | unsigned int | anSector | ) | [virtual] |
This routine uses the device's sector map to determine the size of the specified sector.
[in] | anSector | The supplied device sector. |
unsigned int tcDspStorageBase::getSector | ( | void * | apAddr | ) | [virtual] |
This routine uses the device's sector map to compute a sector from a from a supplied offset address.
[in] | apAddr | The supplied address relative to the device base. |
double tcDspStorageBase::getDeviceSizeKB | ( | void | ) | [virtual] |
This routine returns the size of the device in kilobytes.
const tcDspStorageBase::tsSectorMap * tcDspStorageBase::getMap | ( | int & | anNumSectors | ) |
This routine returns a pointer to access the device's sector map.
[out] | anNumSectors | A reference to an integer which is filled in with the current device's number of sectors. |
bool tcDspStorageBase::getMediaPresent | ( | ) | [virtual] |
unsigned int MityDSP::tcDspStorageBase::mnTxBytes |
Count of bytes written (debug).
Reimplemented in MityDSP::tcDspFtdiUsbFs.
unsigned int MityDSP::tcDspStorageBase::mnRxBytes |
Count of bytes read (debug).
Reimplemented in MityDSP::tcDspFtdiUsbFs.
unsigned int MityDSP::tcDspStorageBase::mnNumSectors [protected] |
Number of sectors in this device.
double MityDSP::tcDspStorageBase::mnDeviceSize [protected] |
Overall device size (in bytes).
tsSectorMap* MityDSP::tcDspStorageBase::mpSectorInfo [protected] |
Map of sectors and sizes.
bool MityDSP::tcDspStorageBase::mbMediaPresent [protected] |
True if device is loaded.
void* MityDSP::tcDspStorageBase::mpUserArg [protected] |
User-supplied argument for ISR callback.