author | sl |
Tue, 10 Jun 2014 14:32:02 +0200 | |
changeset 1 | 260cb5ec6c19 |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 2 |
// All rights reserved. |
sl@0 | 3 |
// This component and the accompanying materials are made available |
sl@0 | 4 |
// under the terms of the License "Eclipse Public License v1.0" |
sl@0 | 5 |
// which accompanies this distribution, and is available |
sl@0 | 6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 7 |
// |
sl@0 | 8 |
// Initial Contributors: |
sl@0 | 9 |
// Nokia Corporation - initial contribution. |
sl@0 | 10 |
// |
sl@0 | 11 |
// Contributors: |
sl@0 | 12 |
// |
sl@0 | 13 |
// Description: |
sl@0 | 14 |
// f32\sfat\sl_fatcache.inl |
sl@0 | 15 |
// |
sl@0 | 16 |
// |
sl@0 | 17 |
|
sl@0 | 18 |
/** |
sl@0 | 19 |
@file |
sl@0 | 20 |
*/ |
sl@0 | 21 |
|
sl@0 | 22 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
sl@0 | 23 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
sl@0 | 24 |
//!! |
sl@0 | 25 |
//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it |
sl@0 | 26 |
//!! |
sl@0 | 27 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
sl@0 | 28 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
sl@0 | 29 |
|
sl@0 | 30 |
|
sl@0 | 31 |
#ifndef SL_FAT_CACHE_INL |
sl@0 | 32 |
#define SL_FAT_CACHE_INL |
sl@0 | 33 |
|
sl@0 | 34 |
|
sl@0 | 35 |
//----------------------------------------------------------------------------- |
sl@0 | 36 |
|
sl@0 | 37 |
/** clear all bits */ |
sl@0 | 38 |
void T32Bits::Clear() |
sl@0 | 39 |
{ |
sl@0 | 40 |
iData = 0; |
sl@0 | 41 |
} |
sl@0 | 42 |
|
sl@0 | 43 |
/** @return non-0 if at least one of 32 bits is set to '1' */ |
sl@0 | 44 |
TBool T32Bits::HasBitsSet() const |
sl@0 | 45 |
{ |
sl@0 | 46 |
return iData; |
sl@0 | 47 |
} |
sl@0 | 48 |
|
sl@0 | 49 |
/** sets bit number "aIndex" to '1' */ |
sl@0 | 50 |
void T32Bits::SetBit(TUint32 aIndex) |
sl@0 | 51 |
{ |
sl@0 | 52 |
ASSERT(aIndex < 32); |
sl@0 | 53 |
iData |= (1<<aIndex); |
sl@0 | 54 |
} |
sl@0 | 55 |
|
sl@0 | 56 |
/** |
sl@0 | 57 |
Get value of the bit number "aIndex". |
sl@0 | 58 |
@return 0 if the bit aIndex is '0' non-zero otherwise |
sl@0 | 59 |
*/ |
sl@0 | 60 |
TBool T32Bits::operator[](TUint32 aIndex) const |
sl@0 | 61 |
{ |
sl@0 | 62 |
ASSERT(aIndex < 32); |
sl@0 | 63 |
return (iData & (1<<aIndex)); |
sl@0 | 64 |
} |
sl@0 | 65 |
|
sl@0 | 66 |
|
sl@0 | 67 |
//----------------------------------------------------------------------------- |
sl@0 | 68 |
|
sl@0 | 69 |
TUint32 CFatCacheBase::FatStartPos() const |
sl@0 | 70 |
{ |
sl@0 | 71 |
return iFatStartPos; |
sl@0 | 72 |
} |
sl@0 | 73 |
|
sl@0 | 74 |
TUint32 CFatCacheBase::FatSize() const |
sl@0 | 75 |
{ |
sl@0 | 76 |
return iFatSize; |
sl@0 | 77 |
} |
sl@0 | 78 |
|
sl@0 | 79 |
TFatType CFatCacheBase::FatType() const |
sl@0 | 80 |
{ |
sl@0 | 81 |
return iFatType; |
sl@0 | 82 |
} |
sl@0 | 83 |
|
sl@0 | 84 |
TBool CFatCacheBase::IsDirty() const |
sl@0 | 85 |
{ |
sl@0 | 86 |
return iDirty; |
sl@0 | 87 |
} |
sl@0 | 88 |
|
sl@0 | 89 |
void CFatCacheBase::SetDirty(TBool aDirty) |
sl@0 | 90 |
{ |
sl@0 | 91 |
iDirty = aDirty; |
sl@0 | 92 |
} |
sl@0 | 93 |
|
sl@0 | 94 |
TUint CFatCacheBase::NumFATs() const |
sl@0 | 95 |
{ |
sl@0 | 96 |
return iNumFATs; |
sl@0 | 97 |
} |
sl@0 | 98 |
|
sl@0 | 99 |
TUint CFatCacheBase::FAT_SectorSzLog2() const |
sl@0 | 100 |
{ |
sl@0 | 101 |
return iFatSecSzLog2; |
sl@0 | 102 |
} |
sl@0 | 103 |
|
sl@0 | 104 |
TUint CFatCacheBase::FAT_SectorSz() const |
sl@0 | 105 |
{ |
sl@0 | 106 |
return 1 << iFatSecSzLog2; |
sl@0 | 107 |
} |
sl@0 | 108 |
|
sl@0 | 109 |
TUint CFatCacheBase::FAT_ClusterSzLog2() const |
sl@0 | 110 |
{ |
sl@0 | 111 |
return iFatClustSzLog2; |
sl@0 | 112 |
} |
sl@0 | 113 |
|
sl@0 | 114 |
|
sl@0 | 115 |
//----------------------------------------------------------------------------- |
sl@0 | 116 |
|
sl@0 | 117 |
/** @return number of FAT cache sectors in this fixed cache */ |
sl@0 | 118 |
TUint32 CFat12Cache::NumSectors() const |
sl@0 | 119 |
{ |
sl@0 | 120 |
return iSectorsInCache; |
sl@0 | 121 |
} |
sl@0 | 122 |
|
sl@0 | 123 |
|
sl@0 | 124 |
//----------------------------------------------------------------------------- |
sl@0 | 125 |
|
sl@0 | 126 |
|
sl@0 | 127 |
/** @return Log2(page size in bytes) */ |
sl@0 | 128 |
TUint CFatPagedCacheBase::PageSizeLog2() const |
sl@0 | 129 |
{ |
sl@0 | 130 |
return iPageSizeLog2; |
sl@0 | 131 |
} |
sl@0 | 132 |
|
sl@0 | 133 |
/** @return page size in bytes */ |
sl@0 | 134 |
TUint CFatPagedCacheBase::PageSize() const |
sl@0 | 135 |
{ |
sl@0 | 136 |
return Pow2(iPageSizeLog2); |
sl@0 | 137 |
} |
sl@0 | 138 |
|
sl@0 | 139 |
/** @return Log2(size of the logical sector of the page in bytes) */ |
sl@0 | 140 |
TUint CFatPagedCacheBase::SectorSizeLog2() const |
sl@0 | 141 |
{ |
sl@0 | 142 |
return iSectorSizeLog2; |
sl@0 | 143 |
} |
sl@0 | 144 |
|
sl@0 | 145 |
/** @return number of the logical sector in the page */ |
sl@0 | 146 |
TUint CFatPagedCacheBase::SectorsInPage() const |
sl@0 | 147 |
{ |
sl@0 | 148 |
return Pow2(iPageSizeLog2 - iSectorSizeLog2); |
sl@0 | 149 |
} |
sl@0 | 150 |
|
sl@0 | 151 |
|
sl@0 | 152 |
//----------------------------------------------------------------------------- |
sl@0 | 153 |
|
sl@0 | 154 |
TUint CFat16FixedCache::NumPages() const |
sl@0 | 155 |
{ |
sl@0 | 156 |
return (TUint)iPages.Count(); |
sl@0 | 157 |
} |
sl@0 | 158 |
|
sl@0 | 159 |
//----------------------------------------------------------------------------- |
sl@0 | 160 |
|
sl@0 | 161 |
|
sl@0 | 162 |
/** @return the index in the FAT table this page starts from */ |
sl@0 | 163 |
TUint32 CFatCachePageBase::StartFatIndex() const |
sl@0 | 164 |
{ |
sl@0 | 165 |
return iStartIndexInFAT; |
sl@0 | 166 |
} |
sl@0 | 167 |
|
sl@0 | 168 |
/** @return number of FAT entries in the page */ |
sl@0 | 169 |
TUint32 CFatCachePageBase::EntriesInPage() const |
sl@0 | 170 |
{ |
sl@0 | 171 |
return iFatEntriesInPage; |
sl@0 | 172 |
} |
sl@0 | 173 |
|
sl@0 | 174 |
/** @return page state */ |
sl@0 | 175 |
CFatCachePageBase::TState CFatCachePageBase::State() const |
sl@0 | 176 |
{ |
sl@0 | 177 |
return iState; |
sl@0 | 178 |
} |
sl@0 | 179 |
|
sl@0 | 180 |
/** sets the state of the page */ |
sl@0 | 181 |
void CFatCachePageBase::SetState(TState aState) |
sl@0 | 182 |
{ |
sl@0 | 183 |
iState = aState; |
sl@0 | 184 |
} |
sl@0 | 185 |
|
sl@0 | 186 |
/** @return ETrue if the page is dirty, i.e. contains non-flushed dirty sectors */ |
sl@0 | 187 |
TBool CFatCachePageBase::IsDirty() const |
sl@0 | 188 |
{ |
sl@0 | 189 |
if(State() == EDirty) |
sl@0 | 190 |
{ |
sl@0 | 191 |
ASSERT(iDirtySectors.HasBitsSet()); |
sl@0 | 192 |
return ETrue; |
sl@0 | 193 |
} |
sl@0 | 194 |
else |
sl@0 | 195 |
{ |
sl@0 | 196 |
ASSERT(!iDirtySectors.HasBitsSet()); |
sl@0 | 197 |
return EFalse; |
sl@0 | 198 |
} |
sl@0 | 199 |
} |
sl@0 | 200 |
|
sl@0 | 201 |
/** @return ETrue if the page data are valid */ |
sl@0 | 202 |
TBool CFatCachePageBase::IsValid() const |
sl@0 | 203 |
{ |
sl@0 | 204 |
return (State() == EClean || State() == EDirty); |
sl@0 | 205 |
} |
sl@0 | 206 |
|
sl@0 | 207 |
/** force the page to the clean state */ |
sl@0 | 208 |
void CFatCachePageBase::SetClean() |
sl@0 | 209 |
{ |
sl@0 | 210 |
iDirtySectors.Clear(); //-- clear dirty sectors bitmap |
sl@0 | 211 |
SetState(EClean); |
sl@0 | 212 |
} |
sl@0 | 213 |
|
sl@0 | 214 |
/** @return page size in bytes */ |
sl@0 | 215 |
TUint32 CFatCachePageBase::PageSize() const |
sl@0 | 216 |
{ |
sl@0 | 217 |
return iCache.PageSize(); |
sl@0 | 218 |
} |
sl@0 | 219 |
|
sl@0 | 220 |
/** @return number of logical sectors in the page */ |
sl@0 | 221 |
TUint32 CFatCachePageBase::NumSectors() const |
sl@0 | 222 |
{ |
sl@0 | 223 |
return iCache.SectorsInPage(); |
sl@0 | 224 |
} |
sl@0 | 225 |
|
sl@0 | 226 |
/** @return ETrue if the entry at aFatIndex belongs to this page */ |
sl@0 | 227 |
TBool CFatCachePageBase::IsEntryCached(TUint32 aFatIndex) const |
sl@0 | 228 |
{ |
sl@0 | 229 |
return (aFatIndex >= iStartIndexInFAT && aFatIndex < iStartIndexInFAT+EntriesInPage()); |
sl@0 | 230 |
} |
sl@0 | 231 |
|
sl@0 | 232 |
|
sl@0 | 233 |
//--------------------------------------------------------------------------------------------------------------------------------- |
sl@0 | 234 |
|
sl@0 | 235 |
|
sl@0 | 236 |
|
sl@0 | 237 |
|
sl@0 | 238 |
|
sl@0 | 239 |
|
sl@0 | 240 |
#endif //SL_FAT_CACHE_INL |
sl@0 | 241 |
|
sl@0 | 242 |
|
sl@0 | 243 |
|
sl@0 | 244 |
|
sl@0 | 245 |
|
sl@0 | 246 |
|
sl@0 | 247 |
|
sl@0 | 248 |
|
sl@0 | 249 |
|
sl@0 | 250 |
|
sl@0 | 251 |
|
sl@0 | 252 |
|
sl@0 | 253 |
|
sl@0 | 254 |
|
sl@0 | 255 |
|
sl@0 | 256 |
|
sl@0 | 257 |
|
sl@0 | 258 |
|
sl@0 | 259 |
|
sl@0 | 260 |
|
sl@0 | 261 |
|
sl@0 | 262 |
|
sl@0 | 263 |