userlibandfileserver/fileserver/sfat32/inc/sl_fatcache32.inl
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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\sfat32\inc\sl_facache32.h
       
    15 // FAT32 various cache classes definition
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology
       
    22 */
       
    23 
       
    24 #ifndef SL_FAT_CACHE_32_INL
       
    25 #define SL_FAT_CACHE_32_INL
       
    26 
       
    27 
       
    28 //-----------------------------------------------------------------------------
       
    29 
       
    30 
       
    31 void CFatBitCache::SetState(CFatBitCache::TState aState) 
       
    32     {
       
    33     iState = aState;
       
    34     }
       
    35 
       
    36 /**
       
    37     Converts FAT index to the corresponding bit array bit number (or FAT cache sector number).
       
    38     @param  aFatIndex index in the FAT 
       
    39     @return corresponding index in the FAT bit array
       
    40 */
       
    41 TUint32 CFatBitCache::FatIndexToCacheSectorNumber(TUint32 aFatIndex) const
       
    42     {
       
    43     ASSERT(aFatIndex >= KFatFirstSearchCluster);
       
    44     return (aFatIndex >> iFatIdxToSecCoeff);
       
    45     }
       
    46 
       
    47 /**
       
    48     Converts FAT32 cache sector number to the FAT32 entry index (in the beginning of this cache sector)
       
    49     @param  aCacheSecNum index in the FAT bit array (or FAT cache sector number)
       
    50     @return corresponding index in the FAT 
       
    51 
       
    52 */
       
    53 TUint32 CFatBitCache::CacheSectorNumberToFatIndex(TUint32 aCacheSecNum) const
       
    54     {
       
    55     ASSERT(aCacheSecNum < iBitCache.Size());
       
    56     return (aCacheSecNum << iFatIdxToSecCoeff);
       
    57     }
       
    58 
       
    59 /** @return state of the cache*/
       
    60 CFatBitCache::TState CFatBitCache::State() const 
       
    61     {
       
    62     return iState;
       
    63     }
       
    64 
       
    65 /** 
       
    66     @return ETrue if the cache can be used, i.e. is fully populated
       
    67 */
       
    68 TBool CFatBitCache::UsableState() const
       
    69     {
       
    70     return State() == EPopulated;
       
    71     }
       
    72 
       
    73 
       
    74 /**
       
    75     @return ETrue if the FAT cache sector number "aFatSectorNum" is marked as having at least one free FAT entry.
       
    76     N.B. The cache must be in consistent state, i.e. fully populated.
       
    77 */
       
    78 TBool CFatBitCache::FatSectorHasFreeEntry(TUint32 aFatSectorNum) const
       
    79     {
       
    80     ASSERT(UsableState());
       
    81     return iBitCache[aFatSectorNum];
       
    82     }
       
    83 
       
    84 /**
       
    85     Mark FAT cache sector number "aFatSectorNum" is as having/not having free FAT entry.
       
    86     N.B. The cache must be in consistent state, i.e. fully populated.
       
    87 
       
    88     @param  aFatSectorNum FAT32 cache sector number [index in a bit vector] 
       
    89     @param  aHasFreeEntry ETrue  if we want to mark this sector as having free FAT entries; 
       
    90                           EFalse if we want to mark this sector as NOT having free FAT entries; 
       
    91 */
       
    92 void CFatBitCache::SetFreeEntryInFatSector(TUint32 aFatSectorNum, TBool aHasFreeEntry)
       
    93     {
       
    94     ASSERT(UsableState());
       
    95     iBitCache.SetBitVal(aFatSectorNum, aHasFreeEntry);
       
    96     }
       
    97 
       
    98 
       
    99 #endif //SL_FAT_CACHE_32_INL
       
   100 
       
   101 
       
   102 
       
   103 
       
   104 
       
   105 
       
   106 
       
   107 
       
   108 
       
   109 
       
   110 
       
   111 
       
   112 
       
   113 
       
   114 
       
   115 
       
   116 
       
   117 
       
   118 
       
   119 
       
   120 
       
   121 
       
   122