--- a/userlibandfileserver/fileserver/sfat/sl_dir_cache.h Mon Oct 19 15:55:17 2009 +0100
+++ b/userlibandfileserver/fileserver/sfat/sl_dir_cache.h Mon Dec 21 16:14:42 2009 +0000
@@ -20,6 +20,15 @@
@internalTechnology
*/
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//!!
+//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
+//!!
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
#ifndef SL_DIR_CACHE_H
#define SL_DIR_CACHE_H
@@ -29,7 +38,7 @@
#include <e32hashtab.h>
//---------------------------------------------------------------------------------------------------------------------------------
-class CDynamicDirCache;
+class CDynamicDirCache;
/**
@@ -38,71 +47,71 @@
class TDynamicDirCachePage
{
public:
- enum TPageType
- {
- EUnknown,
- ELocked,
- EUnlocked,
- EActivePage,
- };
+ enum TPageType
+ {
+ EUnknown,
+ ELocked,
+ EUnlocked,
+ EActivePage,
+ };
public:
- ~TDynamicDirCachePage();
- static TDynamicDirCachePage* NewL(CDynamicDirCache* aOwnerCache, TInt64 aStartMedPos, TUint8* aStartRamAddr);
-
- inline void SetLocked(TBool);
- inline TBool IsLocked() const;
- inline TUint8* StartPtr() const;
- inline void SetStartPtr(TUint8* aPtr);
- inline void SetValid(TBool aIsValid);
- inline TBool IsValid() const;
- inline void SetPageType(TPageType aType);
- inline TPageType PageType();
+ ~TDynamicDirCachePage();
+ static TDynamicDirCachePage* NewL(CDynamicDirCache* aOwnerCache, TInt64 aStartMedPos, TUint8* aStartRamAddr);
+
+ inline void SetLocked(TBool);
+ inline TBool IsLocked() const;
+ inline TUint8* StartPtr() const;
+ inline void SetStartPtr(TUint8* aPtr);
+ inline void SetValid(TBool aIsValid);
+ inline TBool IsValid() const;
+ inline void SetPageType(TPageType aType);
+ inline TPageType PageType();
- inline TUint32 PageSizeInBytes() const;
- inline TUint32 PageSizeInSegs() const;
+ inline TUint32 PageSizeInBytes() const;
+ inline TUint32 PageSizeInSegs() const;
- inline void SetPos(TInt64 aPos);
- inline void ResetPos();
- inline TInt64 StartPos() const;
+ inline void SetPos(TInt64 aPos);
+ inline void ResetPos();
+ inline TInt64 StartPos() const;
- inline TUint8* PtrInPage(TInt64 aPos) const;
- inline TBool PosCachedInPage(TInt64 aPos) const;
+ inline TUint8* PtrInPage(TInt64 aPos) const;
+ inline TBool PosCachedInPage(TInt64 aPos) const;
- inline void Deque();
+ inline void Deque();
private:
- // declared to disable copying and assignment
- TDynamicDirCachePage& operator=(const TDynamicDirCachePage&);
- TDynamicDirCachePage(const TDynamicDirCachePage&);
+ // declared to disable copying and assignment
+ TDynamicDirCachePage& operator=(const TDynamicDirCachePage&);
+ TDynamicDirCachePage(const TDynamicDirCachePage&);
- // private constructor, as this class is not supposed to be created on stack
- TDynamicDirCachePage(CDynamicDirCache* aOwnerCache, TInt64 aStartMedPos, TUint8* aStartRamAddr);
+ // private constructor, as this class is not supposed to be created on stack
+ TDynamicDirCachePage(CDynamicDirCache* aOwnerCache, TInt64 aStartMedPos, TUint8* aStartRamAddr);
public:
- TDblQueLink iLink; ///< the embedded link object, see TCachePageList
- TInt64 iStartMedPos; ///< the starting media address that this page caches
- TUint8* iStartRamAddr; ///< the starting ram address that thsi page lives
- CDynamicDirCache* iOwnerCache; ///< pointer to the cache that owns this page
- TBool iValid :1; ///< flag to indicate the validity of the page content
- TBool iLocked :1; ///< flag to indicate if the page is locked or not
- TPageType iType; ///< page type, see TPageType
+ TDblQueLink iLink; ///< the embedded link object, see TCachePageList
+ TInt64 iStartMedPos; ///< the starting media address that this page caches
+ TUint8* iStartRamAddr; ///< the starting ram address that thsi page lives
+ CDynamicDirCache* iOwnerCache; ///< pointer to the cache that owns this page
+ TBool iValid :1; ///< flag to indicate the validity of the page content
+ TBool iLocked :1; ///< flag to indicate if the page is locked or not
+ TPageType iType; ///< page type, see TPageType
};
/**
The lookup table entry class
-@see CDynamicDirCache
+@see CDynamicDirCache
*/
class TLookupEntry
- {
- public:
- TLookupEntry(): iPos(0), iRange(0), iPage(NULL) {};
- TLookupEntry(TInt64 aPos, TUint32 aRange, TDynamicDirCachePage* aPage): iPos(aPos), iRange(aRange), iPage(aPage) {};
- public:
- TInt64 iPos;
- TUint32 iRange;
- TDynamicDirCachePage* iPage;
- };
+ {
+ public:
+ TLookupEntry(): iPos(0), iRange(0), iPage(NULL) {};
+ TLookupEntry(TInt64 aPos, TUint32 aRange, TDynamicDirCachePage* aPage): iPos(aPos), iRange(aRange), iPage(aPage) {};
+ public:
+ TInt64 iPos;
+ TUint32 iRange;
+ TDynamicDirCachePage* iPage;
+ };
//---------------------------------------------------------------------------------------------------------------------------------
typedef TDblQue<TDynamicDirCachePage> TCachePageList;
@@ -114,78 +123,78 @@
class CDynamicDirCache : public CBase, public MWTCacheInterface
{
public:
- ~CDynamicDirCache();
- static CDynamicDirCache* NewL(TFatDriveInterface& aDrive, TUint32 aMinPageNum, TUint32 aMaxPageNum, TUint32 aPageSizeLog2, const TDesC& aClientName);
+ ~CDynamicDirCache();
+ static CDynamicDirCache* NewL(TFatDriveInterface& aDrive, TUint32 aMinPageNum, TUint32 aMaxPageNum, TUint32 aPageSizeLog2, const TDesC& aClientName);
- //-- overloads from the base class
- void ReadL (TInt64 aPos, TInt aLength, TDes8& aDes);
- void WriteL(TInt64 aPos, const TDesC8& aDes);
- void InvalidateCache(void);
+ //-- overloads from the base class
+ void ReadL (TInt64 aPos, TInt aLength, TDes8& aDes);
+ void WriteL(TInt64 aPos, const TDesC8& aDes);
+ void InvalidateCache(void);
void InvalidateCachePage(TUint64 aPos);
- TUint32 PosCached(const TInt64& aPosToSearch, TInt64& aCachedPosStart);
- TUint32 CacheSizeInBytes() const;
- TInt Control(TUint32 aFunction, TUint32 aParam1, TAny* aParam2);
- void SetCacheBasePos(TInt64 aBasePos);
- void MakePageMRU(TInt64 aPos);
- TUint32 PageSizeInBytesLog2() const;
-
- TUint32 PageSizeInSegs() const;
+ TUint32 PosCached(const TInt64& aPosToSearch, TInt64& aCachedPosStart);
+ TUint32 CacheSizeInBytes() const;
+ TInt Control(TUint32 aFunction, TUint32 aParam1, TAny* aParam2);
+ void SetCacheBasePos(TInt64 aBasePos);
+ void MakePageMRU(TInt64 aPos);
+ TUint32 PageSizeInBytesLog2() const;
+
+ TUint32 PageSizeInSegs() const;
// Debugging functions
- void Dump();
- void Info() const;
+ void Dump();
+ void Info() const;
protected:
- CDynamicDirCache(TFatDriveInterface& aDrive, TUint32 aMinSizeInBytes, TUint32 aMaxSizeInBytes, TUint32 aPageSizeInBytesLog2);
- void ConstructL(const TDesC& aClientName);
+ CDynamicDirCache(TFatDriveInterface& aDrive, TUint32 aMinSizeInBytes, TUint32 aMaxSizeInBytes, TUint32 aPageSizeInBytesLog2);
+ void ConstructL(const TDesC& aClientName);
- void ReadDataFromSinglePageL(TInt64 aPos, TInt aLength, TDes8& aDes);
- void WriteDataOntoSinglePageL(TInt64 aPos, const TUint8* aData, TUint32 aDataLen);
- TDynamicDirCachePage* FindPageByPos(TInt64 aPos);
- TDynamicDirCachePage* UpdateActivePageL(TInt64 aPos);
- TDynamicDirCachePage* AllocateAndLockNewPageL(TInt64 aStartMedPos);
- TUint8* LockPage(TDynamicDirCachePage* aPage);
- TInt UnlockPage(TDynamicDirCachePage* aPage);
- TInt DecommitPage(TDynamicDirCachePage* aPage);
- inline TInt64 CalcPageStartPos(TInt64 aPos) const;
- void CheckThresholds();
- inline TBool CacheIsFull() const;
- inline TUint32 MaxCacheSizeInPages() const;
- TInt DeQueue(TDynamicDirCachePage* aPage);
- TInt AddFirstOntoQueue(TDynamicDirCachePage* aPage, TDynamicDirCachePage::TPageType aType);
- TInt LookupTblRemove(TInt64 aPagePos);
- TInt LookupTblAdd(TDynamicDirCachePage* aPage);
- TDynamicDirCachePage* LookupTblFind(TInt64 aPos);
- TInt ResetPagePos(TDynamicDirCachePage* aPage);
- void MakePageLastLocked(TDynamicDirCachePage* aPage);
-
+ void ReadDataFromSinglePageL(TInt64 aPos, TInt aLength, TDes8& aDes);
+ void WriteDataOntoSinglePageL(TInt64 aPos, const TUint8* aData, TUint32 aDataLen);
+ TDynamicDirCachePage* FindPageByPos(TInt64 aPos);
+ TDynamicDirCachePage* UpdateActivePageL(TInt64 aPos);
+ TDynamicDirCachePage* AllocateAndLockNewPageL(TInt64 aStartMedPos);
+ TUint8* LockPage(TDynamicDirCachePage* aPage);
+ TInt UnlockPage(TDynamicDirCachePage* aPage);
+ TInt DecommitPage(TDynamicDirCachePage* aPage);
+ inline TInt64 CalcPageStartPos(TInt64 aPos) const;
+ void CheckThresholds();
+ inline TBool CacheIsFull() const;
+ inline TUint32 MaxCacheSizeInPages() const;
+ TInt DeQueue(TDynamicDirCachePage* aPage);
+ TInt AddFirstOntoQueue(TDynamicDirCachePage* aPage, TDynamicDirCachePage::TPageType aType);
+ TInt LookupTblRemove(TInt64 aPagePos);
+ TInt LookupTblAdd(TDynamicDirCachePage* aPage);
+ TDynamicDirCachePage* LookupTblFind(TInt64 aPos);
+ TInt ResetPagePos(TDynamicDirCachePage* aPage);
+ void MakePageLastLocked(TDynamicDirCachePage* aPage);
+
private:
- TUint32 iPageSizeLog2; ///< log2 value of cache pages size in bytes
- TUint32 iMinCacheSizeInBytes; ///< minimum cache data size
- TUint32 iMaxCacheSizeInBytes; ///< maximum cache data size
- TUint32 iMinSizeInPages; ///< minimum cache page number
- TUint32 iMaxSizeInPages; ///< maximum cache page number
- TUint32 iPageSizeInBytes; ///< cache page size in bytes
- TInt64 iCacheBasePos; ///< cache pages base position, used to align them at cluster size
+ TUint32 iPageSizeLog2; ///< log2 value of cache pages size in bytes
+ TUint32 iMinCacheSizeInBytes; ///< minimum cache data size
+ TUint32 iMaxCacheSizeInBytes; ///< maximum cache data size
+ TUint32 iMinSizeInPages; ///< minimum cache page number
+ TUint32 iMaxSizeInPages; ///< maximum cache page number
+ TUint32 iPageSizeInBytes; ///< cache page size in bytes
+ TInt64 iCacheBasePos; ///< cache pages base position, used to align them at cluster size
- TFatDriveInterface& iDrive; ///< reference to the driver for media access
- TUint32 iCacheDisabled : 1; ///< if not 0 the cache is disabled totally and all reads and writes go via TFatDriveInterface directly
+ TFatDriveInterface& iDrive; ///< reference to the driver for media access
+ TUint32 iCacheDisabled : 1; ///< if not 0 the cache is disabled totally and all reads and writes go via TFatDriveInterface directly
- TDynamicDirCachePage* iActivePage; ///< a unique page in cache, used to read new page before make it MRU or have it replaced
-
- // data structures for LRU page list
- TCachePageList iLockedQ; ///< the locked queue that manages all locked pages, limited by minimum page number
- TCachePageList iUnlockedQ; ///< the unlocked queue that manages all locked pages, limited by maximum page number - minimum page number
- TUint32 iLockedQCount;
- TUint32 iUnlockedQCount;
+ TDynamicDirCachePage* iActivePage; ///< a unique page in cache, used to read new page before make it MRU or have it replaced
+
+ // data structures for LRU page list
+ TCachePageList iLockedQ; ///< the locked queue that manages all locked pages, limited by minimum page number
+ TCachePageList iUnlockedQ; ///< the unlocked queue that manages all locked pages, limited by maximum page number - minimum page number
+ TUint32 iLockedQCount;
+ TUint32 iUnlockedQCount;
- // data structures for look up table
- THashFunction32<TLookupEntry> iHashFunction;
- TIdentityRelation<TLookupEntry> iIdentityFunction;
- RHashSet<TLookupEntry> iLookupTable; ///< a lookup table that used to speed up page look up
+ // data structures for look up table
+ THashFunction32<TLookupEntry> iHashFunction;
+ TIdentityRelation<TLookupEntry> iIdentityFunction;
+ RHashSet<TLookupEntry> iLookupTable; ///< a lookup table that used to speed up page look up
- CCacheMemoryClient* iCacheMemoryClient; ///< interface to cache memory manager
+ CCacheMemoryClient* iCacheMemoryClient; ///< interface to cache memory manager
};
#include"sl_dir_cache.inl"