The tcDspStorageBase class is a base class to define a consistent set of interfaces for all storage devices.
More...
#include <core/DspStorageBase.h>
List of all members.
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)
|
Detailed Description
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.
- See also:
- tcDspStorageBase Page
Member Typedef Documentation
typedef void(* MityDSP::tcDspStorageBase::tfIsrCallback)(bool, void *) |
prototype for the ISR callback
Constructor & Destructor Documentation
tcDspStorageBase::tcDspStorageBase |
( |
void |
| ) |
|
This constructor is used to initialize storage base class.
- Returns:
- None.
- See also:
- DspStorageBase.h
tcDspStorageBase::~tcDspStorageBase |
( |
| ) |
|
|
virtual |
Member Function Documentation
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.
- Parameters:
-
[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. |
- Returns:
- Bytes read, or an error code less than zero.
- See also:
- DspStorageBase.h
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.
- Parameters:
-
[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. |
- Returns:
- Bytes written, or an error code less than zero.
- See also:
- DspStorageBase.h
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.
- Parameters:
-
[in] | anSector | The sector to erase. |
- Returns:
- True to indicate success.
- See also:
- DspStorageBase.h
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).
- Note:
- The registered function is run in ISR space and therefore must not call any DSP/BIOS functions that can cause a context switch.
- Parameters:
-
[in] | afCallback | The ISR callback to register (NULL for none). |
[in] | apUserArg | An argument to be supplied with the callback. |
- Returns:
- None.
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.
- Parameters:
-
[in] | anSector | The supplied device sector. |
[in] | anOffset | The offset from the start of the device sector. |
- Returns:
- Pointer to offset from start of device.
- See also:
- DspStorageBase.h
unsigned int tcDspStorageBase::getSize |
( |
unsigned int |
anSector | ) |
|
|
virtual |
This routine uses the device's sector map to determine the size of the specified sector.
- Parameters:
-
[in] | anSector | The supplied device sector. |
- Returns:
- Size of the sector in bytes (0 for an error).
- See also:
- DspStorageBase.h
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.
- Parameters:
-
[in] | apAddr | The supplied address relative to the device base. |
- Returns:
- Flash sector in which the address falls (-1 if error).
- See also:
- DspStorageBase.h
double tcDspStorageBase::getDeviceSizeKB |
( |
void |
| ) |
|
|
virtual |
This routine returns the size of the device in kilobytes.
- Note:
- 1 kilobyte = 1024 bytes
- Returns:
- Size of the device in KB.
- See also:
- DspStorageBase.h
This routine returns a pointer to access the device's sector map.
- Parameters:
-
[out] | anNumSectors | A reference to an integer which is filled in with the current device's number of sectors. |
- Returns:
- Pointer to the device sector map.
bool tcDspStorageBase::getMediaPresent |
( |
| ) |
|
|
virtual |
- Returns:
- true if media is loaded and ready to be accessed.
- See also:
- DspStorageBase.h
Member Data Documentation
unsigned int MityDSP::tcDspStorageBase::mnTxBytes |
unsigned int MityDSP::tcDspStorageBase::mnRxBytes |
unsigned int MityDSP::tcDspStorageBase::mnNumSectors |
|
protected |
Number of sectors in this device.
double MityDSP::tcDspStorageBase::mnDeviceSize |
|
protected |
Overall device size (in bytes)
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.