os/kernelhwsrv/userlibandfileserver/fileserver/sfat/sl_fatcache.inl
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfat/sl_fatcache.inl	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,263 @@
     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 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.26 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.27 +//!!
    1.28 +//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
    1.29 +//!!
    1.30 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.31 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.32 +
    1.33 +
    1.34 +#ifndef SL_FAT_CACHE_INL
    1.35 +#define SL_FAT_CACHE_INL
    1.36 +
    1.37 +
    1.38 +//-----------------------------------------------------------------------------
    1.39 +
    1.40 +/** clear all bits */
    1.41 +void T32Bits::Clear()
    1.42 +    {
    1.43 +    iData = 0;
    1.44 +    }
    1.45 +
    1.46 +/** @return non-0 if at least one of 32 bits is set to '1' */
    1.47 +TBool T32Bits::HasBitsSet() const 
    1.48 +    {
    1.49 +    return iData;
    1.50 +    } 
    1.51 +
    1.52 +/** sets bit number "aIndex" to '1' */
    1.53 +void T32Bits::SetBit(TUint32 aIndex)
    1.54 +    {
    1.55 +    ASSERT(aIndex < 32);
    1.56 +    iData |= (1<<aIndex);
    1.57 +    }
    1.58 +
    1.59 +/** 
    1.60 +    Get value of the bit number "aIndex". 
    1.61 +    @return 0 if the bit aIndex is '0' non-zero otherwise
    1.62 +*/
    1.63 +TBool T32Bits::operator[](TUint32 aIndex) const
    1.64 +    {
    1.65 +    ASSERT(aIndex < 32);
    1.66 +    return (iData & (1<<aIndex));
    1.67 +    }
    1.68 +
    1.69 +
    1.70 +//-----------------------------------------------------------------------------
    1.71 +
    1.72 +TUint32 CFatCacheBase::FatStartPos() const 
    1.73 +    {
    1.74 +    return iFatStartPos;
    1.75 +    }
    1.76 +
    1.77 +TUint32 CFatCacheBase::FatSize() const 
    1.78 +    {
    1.79 +    return iFatSize;
    1.80 +    }
    1.81 +
    1.82 +TFatType CFatCacheBase::FatType() const 
    1.83 +    {
    1.84 +    return iFatType;
    1.85 +    }
    1.86 +
    1.87 +TBool CFatCacheBase::IsDirty() const 
    1.88 +    {
    1.89 +    return iDirty;
    1.90 +    }
    1.91 +
    1.92 +void CFatCacheBase::SetDirty(TBool aDirty) 
    1.93 +    {
    1.94 +    iDirty = aDirty;
    1.95 +    }
    1.96 +
    1.97 +TUint CFatCacheBase::NumFATs() const 
    1.98 +    {
    1.99 +    return iNumFATs;
   1.100 +    }
   1.101 +
   1.102 +TUint CFatCacheBase::FAT_SectorSzLog2() const 
   1.103 +    {
   1.104 +    return iFatSecSzLog2;
   1.105 +    }
   1.106 +
   1.107 +TUint CFatCacheBase::FAT_SectorSz() const 
   1.108 +    {
   1.109 +    return 1 << iFatSecSzLog2;
   1.110 +    }
   1.111 +
   1.112 +TUint CFatCacheBase::FAT_ClusterSzLog2() const 
   1.113 +    {
   1.114 +    return iFatClustSzLog2;
   1.115 +    }
   1.116 +    
   1.117 +
   1.118 +//-----------------------------------------------------------------------------
   1.119 +
   1.120 +/** @return number of FAT cache sectors in this fixed cache */
   1.121 +TUint32 CFat12Cache::NumSectors() const   
   1.122 +    {
   1.123 +    return iSectorsInCache;
   1.124 +    }
   1.125 +
   1.126 +
   1.127 +//-----------------------------------------------------------------------------
   1.128 +
   1.129 +
   1.130 +/** @return Log2(page size in bytes) */
   1.131 +TUint CFatPagedCacheBase::PageSizeLog2() const 
   1.132 +    {
   1.133 +    return iPageSizeLog2;
   1.134 +    }
   1.135 +
   1.136 +/** @return page size in bytes */
   1.137 +TUint CFatPagedCacheBase::PageSize() const 
   1.138 +    {
   1.139 +    return Pow2(iPageSizeLog2);
   1.140 +    }
   1.141 +
   1.142 +/** @return Log2(size of the logical sector of the page in bytes) */    
   1.143 +TUint CFatPagedCacheBase::SectorSizeLog2() const 
   1.144 +    {
   1.145 +    return iSectorSizeLog2;
   1.146 +    }
   1.147 +
   1.148 +/** @return number of the logical sector in the page */
   1.149 +TUint CFatPagedCacheBase::SectorsInPage() const 
   1.150 +    {
   1.151 +    return Pow2(iPageSizeLog2 - iSectorSizeLog2);
   1.152 +    }
   1.153 +
   1.154 +
   1.155 +//-----------------------------------------------------------------------------
   1.156 +
   1.157 +TUint CFat16FixedCache::NumPages() const 
   1.158 +    {
   1.159 +    return (TUint)iPages.Count();
   1.160 +    } 
   1.161 +
   1.162 +//-----------------------------------------------------------------------------
   1.163 +
   1.164 +
   1.165 +/** @return  the index in the FAT table this page starts from */
   1.166 +TUint32 CFatCachePageBase::StartFatIndex() const 
   1.167 +    {
   1.168 +    return iStartIndexInFAT;
   1.169 +    }
   1.170 +
   1.171 +/** @return number of FAT entries in the page */
   1.172 +TUint32 CFatCachePageBase::EntriesInPage() const 
   1.173 +    {
   1.174 +    return iFatEntriesInPage;
   1.175 +    }
   1.176 +
   1.177 +/** @return page state */
   1.178 +CFatCachePageBase::TState CFatCachePageBase::State() const
   1.179 +    {
   1.180 +    return iState;
   1.181 +    }
   1.182 +
   1.183 +/** sets the state of the page */
   1.184 +void CFatCachePageBase::SetState(TState aState)
   1.185 +    {
   1.186 +    iState = aState;
   1.187 +    }
   1.188 +
   1.189 +/** @return ETrue if the page is dirty, i.e. contains non-flushed dirty sectors */
   1.190 +TBool CFatCachePageBase::IsDirty() const
   1.191 +    {
   1.192 +    if(State() == EDirty)
   1.193 +        {
   1.194 +        ASSERT(iDirtySectors.HasBitsSet());
   1.195 +        return ETrue;
   1.196 +        }
   1.197 +    else
   1.198 +        {
   1.199 +        ASSERT(!iDirtySectors.HasBitsSet());
   1.200 +        return EFalse;
   1.201 +        }
   1.202 +    }
   1.203 +
   1.204 +/** @return  ETrue if the page data are valid */
   1.205 +TBool CFatCachePageBase::IsValid() const
   1.206 +    {
   1.207 +    return (State() == EClean || State() == EDirty);
   1.208 +    }
   1.209 +
   1.210 +/** force the page to the clean state */
   1.211 +void CFatCachePageBase::SetClean()
   1.212 +    {
   1.213 +    iDirtySectors.Clear(); //-- clear dirty sectors bitmap
   1.214 +    SetState(EClean);
   1.215 +    }
   1.216 +
   1.217 +/** @return page size in bytes */
   1.218 +TUint32 CFatCachePageBase::PageSize() const 
   1.219 +    {
   1.220 +    return iCache.PageSize();
   1.221 +    }
   1.222 +
   1.223 +/** @return number of logical sectors in the page */
   1.224 +TUint32 CFatCachePageBase::NumSectors() const 
   1.225 +    {
   1.226 +    return iCache.SectorsInPage();
   1.227 +    }
   1.228 +
   1.229 +/** @return ETrue if the entry at aFatIndex belongs to this page */
   1.230 +TBool CFatCachePageBase::IsEntryCached(TUint32 aFatIndex) const
   1.231 +    {
   1.232 +    return (aFatIndex >= iStartIndexInFAT && aFatIndex < iStartIndexInFAT+EntriesInPage());
   1.233 +    } 
   1.234 +
   1.235 +
   1.236 +//---------------------------------------------------------------------------------------------------------------------------------
   1.237 +
   1.238 +
   1.239 +
   1.240 +
   1.241 +
   1.242 +
   1.243 +#endif //SL_FAT_CACHE_INL
   1.244 +
   1.245 +
   1.246 +
   1.247 +
   1.248 +
   1.249 +
   1.250 +
   1.251 +
   1.252 +
   1.253 +
   1.254 +
   1.255 +
   1.256 +
   1.257 +
   1.258 +
   1.259 +
   1.260 +
   1.261 +
   1.262 +
   1.263 +
   1.264 +
   1.265 +
   1.266 +