MityDSP Documentation Index

MityDSP::tcDspStorageCache Class Reference

Instances of this class provide a simple cache between an application or filesystem (or other) driver. More...

#include <core/DspStorageCache.h>

Inheritance diagram for MityDSP::tcDspStorageCache:
MityDSP::tcDspStorageBase

List of all members.

Classes

struct  buf_list
 cache-list header structure More...

Public Member Functions

 tcDspStorageCache (tcDspStorageBase *apDevice, unsigned int anNumSectors)
 This constructor is used to create a read/write cache of the specified number of sectors for a tcDspStorageBase-derived class instance.
 ~tcDspStorageCache ()
 Default destructor.
virtual void reset (void)
 This routine resets all cache entries, without flushing any dirty entries.
virtual int write (void *apAddr, void *apData, int anBytes)
 This routine writes an arbitrary amount of data to an MMC 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 MMC 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.

Protected Types

typedef struct
MityDSP::tcDspStorageCache::buf_list 
tsBufferList
 cache-list header structure

Protected Member Functions

void resetDeviceInfo (void)
 This routine reads sector map information from the underlying device and creates copies of the map and the required cache buffers to match.
tsBufferListgetCacheSector (unsigned int anSector, unsigned int anExpectedSize, bool abLoad)
 This method checks the current cache for the sector in question.
tsBufferListflushCacheSector (tsBufferList *anEntry)
 This method checks the specified cache entry to see if it's "dirty".

Protected Attributes

LCK_Handle mhMutex
 Lock to serialize access.
BUF_Handle mhSectorPool
 Pool of sector buffers.
BUF_Handle mhSectorListPool
 Pool of cache list entries.
tcDspStorageBasempDevice
 Access to the storage device to cache.
unsigned int mnCacheSectors
 Maximum sectors in cache.
unsigned int mnMaxSectorSize
 Largest sector size (bytes).
tsBufferListmpCacheHead
 Head of cache linked list.
bool mbAnyDirty
 Set whenever any cache entries need to be flushed.

Detailed Description

Instances of this class provide a simple cache between an application or filesystem (or other) driver.

See also:
tcDspStorageCache Page

Member Typedef Documentation

cache-list header structure


Constructor & Destructor Documentation

tcDspStorageCache::tcDspStorageCache ( tcDspStorageBase apDevice,
unsigned int  anNumSectors 
)

This constructor is used to create a read/write cache of the specified number of sectors for a tcDspStorageBase-derived class instance.

Parameters:
[in] apDevice Pointer to the underlying tcDspStorageBase device.
[in] anNumSectors Maximum number of sectors to cache.
Returns:
None.
See also:
DspStorageCache.h
tcDspStorageCache::~tcDspStorageCache (  ) 

Default destructor.

Returns:
None.
See also:
DspStorageCache.h

Member Function Documentation

void tcDspStorageCache::reset ( void   )  [virtual]

This routine resets all cache entries, without flushing any dirty entries.

This is necessary when a removable device is removed, and subsequently reinserted (with unknown changes made in the mean time).

Writing out dirty cache entries in this case would be bad... a flush should have been done prior to removal by the application.

Returns:
None.
See also:
DspStorageCache.h
int tcDspStorageCache::write ( void *  apAddr,
void *  apData,
int  anBytes 
) [virtual]

This routine writes an arbitrary amount of data to an MMC 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 MMC 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:
DspStorageCache.h

Implements MityDSP::tcDspStorageBase.

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

Sector-based version of the write method.

Note:
A request to write sector 0xFFFFFFFF is taken to be a request to flush all dirty cache entries.
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:
DspStorageCache.h

Implements MityDSP::tcDspStorageBase.

int tcDspStorageCache::read ( void *  apStartAddr,
void *  apBuffer,
int  anBytes 
) [virtual]

This routine reads an arbitrary amount of data from an MMC device from the specified offset position.

Results of the read are stored in apBuffer.

Parameters:
[in] apStartAddr Pointer to the data offset on the MMC 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:
DspStorageCache.h

Implements MityDSP::tcDspStorageBase.

int tcDspStorageCache::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:
DspStorageCache.h

Implements MityDSP::tcDspStorageBase.

void tcDspStorageCache::resetDeviceInfo ( void   )  [protected]

This routine reads sector map information from the underlying device and creates copies of the map and the required cache buffers to match.

Any outstanding cache buffer should be freed prior to this call.

Returns:
None
See also:
DspStorageCache.h
tcDspStorageCache::tsBufferList * tcDspStorageCache::getCacheSector ( unsigned int  anSector,
unsigned int  anExpectedSize,
bool  abLoad 
) [protected]

This method checks the current cache for the sector in question.

If not found, the sector is loaded (flushing the oldest entry, if necessary). A pointer to the cache entry is returned.

In either case, the sector is moved to the front of the cache list.

Parameters:
[in] anSector The sector to load or retrieve from cache
[in] anExpectedSize The expected sector size
[in] abLoad If false, the entire sector is about to be written, so don't load it from the underlying device.
Returns:
Pointer to the cache entry.
See also:
DspStorageCache.h
tcDspStorageCache::tsBufferList * tcDspStorageCache::flushCacheSector ( tsBufferList anEntry  )  [protected]

This method checks the specified cache entry to see if it's "dirty".

If so, it is written out to the underlying device and marked clean.

Parameters:
[in] anEntry The cache entry to write back to the underlying device.
Returns:
The next cache entry in the list.
See also:
DspStorageCache.h

Member Data Documentation

LCK_Handle MityDSP::tcDspStorageCache::mhMutex [protected]

Lock to serialize access.

Pool of sector buffers.

Pool of cache list entries.

Access to the storage device to cache.

Maximum sectors in cache.

Largest sector size (bytes).

Head of cache linked list.

Set whenever any cache entries need to be flushed.


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