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 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
23 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
27 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31 #ifndef SL_FAT_CACHE_INL
32 #define SL_FAT_CACHE_INL
35 //-----------------------------------------------------------------------------
43 /** @return non-0 if at least one of 32 bits is set to '1' */
44 TBool T32Bits::HasBitsSet() const
49 /** sets bit number "aIndex" to '1' */
50 void T32Bits::SetBit(TUint32 aIndex)
57 Get value of the bit number "aIndex".
58 @return 0 if the bit aIndex is '0' non-zero otherwise
60 TBool T32Bits::operator[](TUint32 aIndex) const
63 return (iData & (1<<aIndex));
67 //-----------------------------------------------------------------------------
69 TUint32 CFatCacheBase::FatStartPos() const
74 TUint32 CFatCacheBase::FatSize() const
79 TFatType CFatCacheBase::FatType() const
84 TBool CFatCacheBase::IsDirty() const
89 void CFatCacheBase::SetDirty(TBool aDirty)
94 TUint CFatCacheBase::NumFATs() const
99 TUint CFatCacheBase::FAT_SectorSzLog2() const
101 return iFatSecSzLog2;
104 TUint CFatCacheBase::FAT_SectorSz() const
106 return 1 << iFatSecSzLog2;
109 TUint CFatCacheBase::FAT_ClusterSzLog2() const
111 return iFatClustSzLog2;
115 //-----------------------------------------------------------------------------
117 /** @return number of FAT cache sectors in this fixed cache */
118 TUint32 CFat12Cache::NumSectors() const
120 return iSectorsInCache;
124 //-----------------------------------------------------------------------------
127 /** @return Log2(page size in bytes) */
128 TUint CFatPagedCacheBase::PageSizeLog2() const
130 return iPageSizeLog2;
133 /** @return page size in bytes */
134 TUint CFatPagedCacheBase::PageSize() const
136 return Pow2(iPageSizeLog2);
139 /** @return Log2(size of the logical sector of the page in bytes) */
140 TUint CFatPagedCacheBase::SectorSizeLog2() const
142 return iSectorSizeLog2;
145 /** @return number of the logical sector in the page */
146 TUint CFatPagedCacheBase::SectorsInPage() const
148 return Pow2(iPageSizeLog2 - iSectorSizeLog2);
152 //-----------------------------------------------------------------------------
154 TUint CFat16FixedCache::NumPages() const
156 return (TUint)iPages.Count();
159 //-----------------------------------------------------------------------------
162 /** @return the index in the FAT table this page starts from */
163 TUint32 CFatCachePageBase::StartFatIndex() const
165 return iStartIndexInFAT;
168 /** @return number of FAT entries in the page */
169 TUint32 CFatCachePageBase::EntriesInPage() const
171 return iFatEntriesInPage;
174 /** @return page state */
175 CFatCachePageBase::TState CFatCachePageBase::State() const
180 /** sets the state of the page */
181 void CFatCachePageBase::SetState(TState aState)
186 /** @return ETrue if the page is dirty, i.e. contains non-flushed dirty sectors */
187 TBool CFatCachePageBase::IsDirty() const
189 if(State() == EDirty)
191 ASSERT(iDirtySectors.HasBitsSet());
196 ASSERT(!iDirtySectors.HasBitsSet());
201 /** @return ETrue if the page data are valid */
202 TBool CFatCachePageBase::IsValid() const
204 return (State() == EClean || State() == EDirty);
207 /** force the page to the clean state */
208 void CFatCachePageBase::SetClean()
210 iDirtySectors.Clear(); //-- clear dirty sectors bitmap
214 /** @return page size in bytes */
215 TUint32 CFatCachePageBase::PageSize() const
217 return iCache.PageSize();
220 /** @return number of logical sectors in the page */
221 TUint32 CFatCachePageBase::NumSectors() const
223 return iCache.SectorsInPage();
226 /** @return ETrue if the entry at aFatIndex belongs to this page */
227 TBool CFatCachePageBase::IsEntryCached(TUint32 aFatIndex) const
229 return (aFatIndex >= iStartIndexInFAT && aFatIndex < iStartIndexInFAT+EntriesInPage());
233 //---------------------------------------------------------------------------------------------------------------------------------
240 #endif //SL_FAT_CACHE_INL