1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfat32/sl_fatcache.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,224 @@
1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32\sfat\sl_fatcache.inl
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 +*/
1.24 +
1.25 +#ifndef SL_FAT_CACHE_INL
1.26 +#define SL_FAT_CACHE_INL
1.27 +
1.28 +
1.29 +
1.30 +
1.31 +//-----------------------------------------------------------------------------
1.32 +
1.33 +TUint32 CFatCacheBase::FatStartPos() const
1.34 + {
1.35 + return iFatStartPos;
1.36 + }
1.37 +
1.38 +TUint32 CFatCacheBase::FatSize() const
1.39 + {
1.40 + return iFatSize;
1.41 + }
1.42 +
1.43 +TFatType CFatCacheBase::FatType() const
1.44 + {
1.45 + return iFatType;
1.46 + }
1.47 +
1.48 +TBool CFatCacheBase::IsDirty() const
1.49 + {
1.50 + return iDirty;
1.51 + }
1.52 +
1.53 +void CFatCacheBase::SetDirty(TBool aDirty)
1.54 + {
1.55 + iDirty = aDirty;
1.56 + }
1.57 +
1.58 +TUint CFatCacheBase::NumFATs() const
1.59 + {
1.60 + return iNumFATs;
1.61 + }
1.62 +
1.63 +TUint CFatCacheBase::FAT_SectorSzLog2() const
1.64 + {
1.65 + return iFatSecSzLog2;
1.66 + }
1.67 +
1.68 +TUint CFatCacheBase::FAT_SectorSz() const
1.69 + {
1.70 + return 1 << iFatSecSzLog2;
1.71 + }
1.72 +
1.73 +TUint CFatCacheBase::FAT_ClusterSzLog2() const
1.74 + {
1.75 + return iFatClustSzLog2;
1.76 + }
1.77 +
1.78 +
1.79 +//-----------------------------------------------------------------------------
1.80 +
1.81 +/** @return number of FAT cache sectors in this fixed cache */
1.82 +TUint32 CFat12Cache::NumSectors() const
1.83 + {
1.84 + return iSectorsInCache;
1.85 + }
1.86 +
1.87 +
1.88 +//-----------------------------------------------------------------------------
1.89 +
1.90 +
1.91 +/** @return Log2(page size in bytes) */
1.92 +TUint CFatPagedCacheBase::PageSizeLog2() const
1.93 + {
1.94 + return iPageSizeLog2;
1.95 + }
1.96 +
1.97 +/** @return page size in bytes */
1.98 +TUint CFatPagedCacheBase::PageSize() const
1.99 + {
1.100 + return Pow2(iPageSizeLog2);
1.101 + }
1.102 +
1.103 +/** @return Log2(size of the logical sector of the page in bytes) */
1.104 +TUint CFatPagedCacheBase::SectorSizeLog2() const
1.105 + {
1.106 + return iSectorSizeLog2;
1.107 + }
1.108 +
1.109 +/** @return number of the logical sector in the page */
1.110 +TUint CFatPagedCacheBase::SectorsInPage() const
1.111 + {
1.112 + return Pow2(iPageSizeLog2 - iSectorSizeLog2);
1.113 + }
1.114 +
1.115 +
1.116 +//-----------------------------------------------------------------------------
1.117 +
1.118 +TUint CFat16FixedCache::NumPages() const
1.119 + {
1.120 + return (TUint)iPages.Count();
1.121 + }
1.122 +
1.123 +//-----------------------------------------------------------------------------
1.124 +
1.125 +
1.126 +/** @return the index in the FAT table this page starts from */
1.127 +TUint32 CFatCachePageBase::StartFatIndex() const
1.128 + {
1.129 + return iStartIndexInFAT;
1.130 + }
1.131 +
1.132 +/** @return number of FAT entries in the page */
1.133 +TUint32 CFatCachePageBase::EntriesInPage() const
1.134 + {
1.135 + return iFatEntriesInPage;
1.136 + }
1.137 +
1.138 +/** @return page state */
1.139 +CFatCachePageBase::TState CFatCachePageBase::State() const
1.140 + {
1.141 + return iState;
1.142 + }
1.143 +
1.144 +/** sets the state of the page */
1.145 +void CFatCachePageBase::SetState(TState aState)
1.146 + {
1.147 + iState = aState;
1.148 + }
1.149 +
1.150 +/** @return ETrue if the page is dirty, i.e. contains non-flushed dirty sectors */
1.151 +TBool CFatCachePageBase::IsDirty() const
1.152 + {
1.153 + if(State() == EDirty)
1.154 + {
1.155 + ASSERT(iDirtySectors.HasBitsSet());
1.156 + return ETrue;
1.157 + }
1.158 + else
1.159 + {
1.160 + ASSERT(!iDirtySectors.HasBitsSet());
1.161 + return EFalse;
1.162 + }
1.163 + }
1.164 +
1.165 +/** @return ETrue if the page data are valid */
1.166 +TBool CFatCachePageBase::IsValid() const
1.167 + {
1.168 + return (State() == EClean || State() == EDirty);
1.169 + }
1.170 +
1.171 +/** force the page to the clean state */
1.172 +void CFatCachePageBase::SetClean()
1.173 + {
1.174 + iDirtySectors.Clear(); //-- clear dirty sectors bitmap
1.175 + SetState(EClean);
1.176 + }
1.177 +
1.178 +/** @return page size in bytes */
1.179 +TUint32 CFatCachePageBase::PageSize() const
1.180 + {
1.181 + return iCache.PageSize();
1.182 + }
1.183 +
1.184 +/** @return number of logical sectors in the page */
1.185 +TUint32 CFatCachePageBase::NumSectors() const
1.186 + {
1.187 + return iCache.SectorsInPage();
1.188 + }
1.189 +
1.190 +/** @return ETrue if the entry at aFatIndex belongs to this page */
1.191 +TBool CFatCachePageBase::IsEntryCached(TUint32 aFatIndex) const
1.192 + {
1.193 + return (aFatIndex >= iStartIndexInFAT && aFatIndex < iStartIndexInFAT+EntriesInPage());
1.194 + }
1.195 +
1.196 +
1.197 +//---------------------------------------------------------------------------------------------------------------------------------
1.198 +
1.199 +
1.200 +
1.201 +
1.202 +
1.203 +
1.204 +#endif //SL_FAT_CACHE_INL
1.205 +
1.206 +
1.207 +
1.208 +
1.209 +
1.210 +
1.211 +
1.212 +
1.213 +
1.214 +
1.215 +
1.216 +
1.217 +
1.218 +
1.219 +
1.220 +
1.221 +
1.222 +
1.223 +
1.224 +
1.225 +
1.226 +
1.227 +