103 TDynamicDirCachePage* iPage; |
103 TDynamicDirCachePage* iPage; |
104 }; |
104 }; |
105 |
105 |
106 //--------------------------------------------------------------------------------------------------------------------------------- |
106 //--------------------------------------------------------------------------------------------------------------------------------- |
107 typedef TDblQue<TDynamicDirCachePage> TCachePageList; |
107 typedef TDblQue<TDynamicDirCachePage> TCachePageList; |
|
108 |
108 /** |
109 /** |
109 Dynamic directory cache. |
110 Dynamic directory cache. |
110 For now it is directly derived from MWTCacheInterface. |
111 For now it is directly derived from MWTCacheInterface. |
111 Provides caching FAT directory data. |
112 Provides caching FAT directory data. |
112 */ |
113 */ |
113 class CDynamicDirCache : public CBase, public MWTCacheInterface |
114 class CDynamicDirCache : public CBase, public MWTCacheInterface |
114 { |
115 { |
115 public: |
116 public: |
116 ~CDynamicDirCache(); |
117 ~CDynamicDirCache(); |
117 static CDynamicDirCache* NewL(TDriveInterface& aDrive, TUint32 aMinPageNum, TUint32 aMaxPageNum, TUint32 aPageSizeLog2, const TDesC& aClientName); |
118 static CDynamicDirCache* NewL(TDriveInterface& aDrive, TUint32 aMinPageNum, TUint32 aMaxPageNum, TUint32 aPageSizeLog2, TUint32 aWrGranularityLog2, const TDesC& aClientName); |
118 |
119 |
119 //-- overloads from the base class |
120 //-- overloads from the base class |
120 void ReadL (TInt64 aPos, TInt aLength, TDes8& aDes); |
121 void ReadL (TInt64 aPos, TInt aLength, TDes8& aDes); |
121 void WriteL(TInt64 aPos, const TDesC8& aDes); |
122 void WriteL(TInt64 aPos, const TDesC8& aDes); |
122 void InvalidateCache(void); |
123 void InvalidateCache(void); |
123 void InvalidateCachePage(TUint64 aPos); |
124 void InvalidateCachePage(TUint64 aPos); |
124 |
125 |
125 TUint32 PosCached(const TInt64& aPosToSearch, TInt64& aCachedPosStart); |
126 TUint32 PosCached(TInt64 aPosToSearch); |
126 TUint32 CacheSizeInBytes() const; |
127 TUint32 CacheSizeInBytes() const; |
127 TInt Control(TUint32 aFunction, TUint32 aParam1, TAny* aParam2); |
128 TInt Control(TUint32 aFunction, TUint32 aParam1, TAny* aParam2); |
128 void SetCacheBasePos(TInt64 aBasePos); |
129 void SetCacheBasePos(TInt64 aBasePos); |
129 void MakePageMRU(TInt64 aPos); |
130 void MakePageMRU(TInt64 aPos); |
130 TUint32 PageSizeInBytesLog2() const; |
131 TUint32 PageSizeInBytesLog2() const; |
134 // Debugging functions |
135 // Debugging functions |
135 void Dump(); |
136 void Dump(); |
136 void Info() const; |
137 void Info() const; |
137 |
138 |
138 protected: |
139 protected: |
139 CDynamicDirCache(TDriveInterface& aDrive, TUint32 aMinSizeInBytes, TUint32 aMaxSizeInBytes, TUint32 aPageSizeInBytesLog2); |
140 CDynamicDirCache(TDriveInterface& aDrive, TUint32 aMinSizeInBytes, TUint32 aMaxSizeInBytes, TUint32 aPageSizeInBytesLog2, TUint32 aWrGranularityLog2); |
140 void ConstructL(const TDesC& aClientName); |
141 void ConstructL(const TDesC& aClientName); |
141 |
142 |
142 void ReadDataFromSinglePageL(TInt64 aPos, TInt aLength, TDes8& aDes); |
143 void ReadDataFromSinglePageL(TInt64 aPos, TInt aLength, TDes8& aDes); |
143 void WriteDataOntoSinglePageL(TInt64 aPos, const TUint8* aData, TUint32 aDataLen); |
144 TDynamicDirCachePage* WriteDataOntoSinglePageL(TInt64 aPos, const TUint8* aData, TUint32 aDataLen); |
|
145 |
144 TDynamicDirCachePage* FindPageByPos(TInt64 aPos); |
146 TDynamicDirCachePage* FindPageByPos(TInt64 aPos); |
145 TDynamicDirCachePage* UpdateActivePageL(TInt64 aPos); |
147 TDynamicDirCachePage* UpdateActivePageL(TInt64 aPos); |
146 TDynamicDirCachePage* AllocateAndLockNewPageL(TInt64 aStartMedPos); |
148 TDynamicDirCachePage* AllocateAndLockNewPageL(TInt64 aStartMedPos); |
147 TUint8* LockPage(TDynamicDirCachePage* aPage); |
149 TUint8* LockPage(TDynamicDirCachePage* aPage); |
148 TInt UnlockPage(TDynamicDirCachePage* aPage); |
150 TInt UnlockPage(TDynamicDirCachePage* aPage); |
160 void MakePageLastLocked(TDynamicDirCachePage* aPage); |
162 void MakePageLastLocked(TDynamicDirCachePage* aPage); |
161 void DoMakePageMRU(TInt64 aPos); |
163 void DoMakePageMRU(TInt64 aPos); |
162 void DoInvalidateCache(void); |
164 void DoInvalidateCache(void); |
163 |
165 |
164 private: |
166 private: |
165 TUint32 iPageSizeLog2; ///< log2 value of cache pages size in bytes |
167 TUint32 iPageSizeLog2; ///< Log2(cache page size or read granularity unit) |
|
168 TUint32 iWrGranularityLog2; ///< Log2(cache write granularity unit). Can't be > iPageSizeLog2. '0' has a special meaning - "don't use write granularity" |
|
169 |
166 TUint32 iMinCacheSizeInBytes; ///< minimum cache data size |
170 TUint32 iMinCacheSizeInBytes; ///< minimum cache data size |
167 TUint32 iMaxCacheSizeInBytes; ///< maximum cache data size |
171 TUint32 iMaxCacheSizeInBytes; ///< maximum cache data size |
168 TUint32 iMinSizeInPages; ///< minimum cache page number |
172 TUint32 iMinSizeInPages; ///< minimum cache page number |
169 TUint32 iMaxSizeInPages; ///< maximum cache page number |
173 TUint32 iMaxSizeInPages; ///< maximum cache page number |
170 TUint32 iPageSizeInBytes; ///< cache page size in bytes |
174 TUint32 iPageSizeInBytes; ///< cache page size in bytes |