Update contrib.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfat\sl_fatcache.inl
22 #ifndef SL_FAT_CACHE_INL
23 #define SL_FAT_CACHE_INL
28 //-----------------------------------------------------------------------------
30 TUint32 CFatCacheBase::FatStartPos() const
35 TUint32 CFatCacheBase::FatSize() const
40 TFatType CFatCacheBase::FatType() const
45 TBool CFatCacheBase::IsDirty() const
50 void CFatCacheBase::SetDirty(TBool aDirty)
55 TUint CFatCacheBase::NumFATs() const
60 TUint CFatCacheBase::FAT_SectorSzLog2() const
65 TUint CFatCacheBase::FAT_SectorSz() const
67 return 1 << iFatSecSzLog2;
70 TUint CFatCacheBase::FAT_ClusterSzLog2() const
72 return iFatClustSzLog2;
76 //-----------------------------------------------------------------------------
78 /** @return number of FAT cache sectors in this fixed cache */
79 TUint32 CFat12Cache::NumSectors() const
81 return iSectorsInCache;
85 //-----------------------------------------------------------------------------
88 /** @return Log2(page size in bytes) */
89 TUint CFatPagedCacheBase::PageSizeLog2() const
94 /** @return page size in bytes */
95 TUint CFatPagedCacheBase::PageSize() const
97 return Pow2(iPageSizeLog2);
100 /** @return Log2(size of the logical sector of the page in bytes) */
101 TUint CFatPagedCacheBase::SectorSizeLog2() const
103 return iSectorSizeLog2;
106 /** @return number of the logical sector in the page */
107 TUint CFatPagedCacheBase::SectorsInPage() const
109 return Pow2(iPageSizeLog2 - iSectorSizeLog2);
113 //-----------------------------------------------------------------------------
115 TUint CFat16FixedCache::NumPages() const
117 return (TUint)iPages.Count();
120 //-----------------------------------------------------------------------------
123 /** @return the index in the FAT table this page starts from */
124 TUint32 CFatCachePageBase::StartFatIndex() const
126 return iStartIndexInFAT;
129 /** @return number of FAT entries in the page */
130 TUint32 CFatCachePageBase::EntriesInPage() const
132 return iFatEntriesInPage;
135 /** @return page state */
136 CFatCachePageBase::TState CFatCachePageBase::State() const
141 /** sets the state of the page */
142 void CFatCachePageBase::SetState(TState aState)
147 /** @return ETrue if the page is dirty, i.e. contains non-flushed dirty sectors */
148 TBool CFatCachePageBase::IsDirty() const
150 if(State() == EDirty)
152 ASSERT(iDirtySectors.HasBitsSet());
157 ASSERT(!iDirtySectors.HasBitsSet());
162 /** @return ETrue if the page data are valid */
163 TBool CFatCachePageBase::IsValid() const
165 return (State() == EClean || State() == EDirty);
168 /** force the page to the clean state */
169 void CFatCachePageBase::SetClean()
171 iDirtySectors.Clear(); //-- clear dirty sectors bitmap
175 /** @return page size in bytes */
176 TUint32 CFatCachePageBase::PageSize() const
178 return iCache.PageSize();
181 /** @return number of logical sectors in the page */
182 TUint32 CFatCachePageBase::NumSectors() const
184 return iCache.SectorsInPage();
187 /** @return ETrue if the entry at aFatIndex belongs to this page */
188 TBool CFatCachePageBase::IsEntryCached(TUint32 aFatIndex) const
190 return (aFatIndex >= iStartIndexInFAT && aFatIndex < iStartIndexInFAT+EntriesInPage());
194 //---------------------------------------------------------------------------------------------------------------------------------
201 #endif //SL_FAT_CACHE_INL