os/kernelhwsrv/userlibandfileserver/fileserver/sfat32/sl_fatcache.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // f32\sfat\sl_fatcache.inl
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20 */
    21 
    22 #ifndef SL_FAT_CACHE_INL
    23 #define SL_FAT_CACHE_INL
    24 
    25 
    26 
    27 
    28 //-----------------------------------------------------------------------------
    29 
    30 TUint32 CFatCacheBase::FatStartPos() const 
    31     {
    32     return iFatStartPos;
    33     }
    34 
    35 TUint32 CFatCacheBase::FatSize() const 
    36     {
    37     return iFatSize;
    38     }
    39 
    40 TFatType CFatCacheBase::FatType() const 
    41     {
    42     return iFatType;
    43     }
    44 
    45 TBool CFatCacheBase::IsDirty() const 
    46     {
    47     return iDirty;
    48     }
    49 
    50 void CFatCacheBase::SetDirty(TBool aDirty) 
    51     {
    52     iDirty = aDirty;
    53     }
    54 
    55 TUint CFatCacheBase::NumFATs() const 
    56     {
    57     return iNumFATs;
    58     }
    59 
    60 TUint CFatCacheBase::FAT_SectorSzLog2() const 
    61     {
    62     return iFatSecSzLog2;
    63     }
    64 
    65 TUint CFatCacheBase::FAT_SectorSz() const 
    66     {
    67     return 1 << iFatSecSzLog2;
    68     }
    69 
    70 TUint CFatCacheBase::FAT_ClusterSzLog2() const 
    71     {
    72     return iFatClustSzLog2;
    73     }
    74     
    75 
    76 //-----------------------------------------------------------------------------
    77 
    78 /** @return number of FAT cache sectors in this fixed cache */
    79 TUint32 CFat12Cache::NumSectors() const   
    80     {
    81     return iSectorsInCache;
    82     }
    83 
    84 
    85 //-----------------------------------------------------------------------------
    86 
    87 
    88 /** @return Log2(page size in bytes) */
    89 TUint CFatPagedCacheBase::PageSizeLog2() const 
    90     {
    91     return iPageSizeLog2;
    92     }
    93 
    94 /** @return page size in bytes */
    95 TUint CFatPagedCacheBase::PageSize() const 
    96     {
    97     return Pow2(iPageSizeLog2);
    98     }
    99 
   100 /** @return Log2(size of the logical sector of the page in bytes) */    
   101 TUint CFatPagedCacheBase::SectorSizeLog2() const 
   102     {
   103     return iSectorSizeLog2;
   104     }
   105 
   106 /** @return number of the logical sector in the page */
   107 TUint CFatPagedCacheBase::SectorsInPage() const 
   108     {
   109     return Pow2(iPageSizeLog2 - iSectorSizeLog2);
   110     }
   111 
   112 
   113 //-----------------------------------------------------------------------------
   114 
   115 TUint CFat16FixedCache::NumPages() const 
   116     {
   117     return (TUint)iPages.Count();
   118     } 
   119 
   120 //-----------------------------------------------------------------------------
   121 
   122 
   123 /** @return  the index in the FAT table this page starts from */
   124 TUint32 CFatCachePageBase::StartFatIndex() const 
   125     {
   126     return iStartIndexInFAT;
   127     }
   128 
   129 /** @return number of FAT entries in the page */
   130 TUint32 CFatCachePageBase::EntriesInPage() const 
   131     {
   132     return iFatEntriesInPage;
   133     }
   134 
   135 /** @return page state */
   136 CFatCachePageBase::TState CFatCachePageBase::State() const
   137     {
   138     return iState;
   139     }
   140 
   141 /** sets the state of the page */
   142 void CFatCachePageBase::SetState(TState aState)
   143     {
   144     iState = aState;
   145     }
   146 
   147 /** @return ETrue if the page is dirty, i.e. contains non-flushed dirty sectors */
   148 TBool CFatCachePageBase::IsDirty() const
   149     {
   150     if(State() == EDirty)
   151         {
   152         ASSERT(iDirtySectors.HasBitsSet());
   153         return ETrue;
   154         }
   155     else
   156         {
   157         ASSERT(!iDirtySectors.HasBitsSet());
   158         return EFalse;
   159         }
   160     }
   161 
   162 /** @return  ETrue if the page data are valid */
   163 TBool CFatCachePageBase::IsValid() const
   164     {
   165     return (State() == EClean || State() == EDirty);
   166     }
   167 
   168 /** force the page to the clean state */
   169 void CFatCachePageBase::SetClean()
   170     {
   171     iDirtySectors.Clear(); //-- clear dirty sectors bitmap
   172     SetState(EClean);
   173     }
   174 
   175 /** @return page size in bytes */
   176 TUint32 CFatCachePageBase::PageSize() const 
   177     {
   178     return iCache.PageSize();
   179     }
   180 
   181 /** @return number of logical sectors in the page */
   182 TUint32 CFatCachePageBase::NumSectors() const 
   183     {
   184     return iCache.SectorsInPage();
   185     }
   186 
   187 /** @return ETrue if the entry at aFatIndex belongs to this page */
   188 TBool CFatCachePageBase::IsEntryCached(TUint32 aFatIndex) const
   189     {
   190     return (aFatIndex >= iStartIndexInFAT && aFatIndex < iStartIndexInFAT+EntriesInPage());
   191     } 
   192 
   193 
   194 //---------------------------------------------------------------------------------------------------------------------------------
   195 
   196 
   197 
   198 
   199 
   200 
   201 #endif //SL_FAT_CACHE_INL
   202 
   203 
   204 
   205 
   206 
   207 
   208 
   209 
   210 
   211 
   212 
   213 
   214 
   215 
   216 
   217 
   218 
   219 
   220 
   221 
   222 
   223 
   224