0
|
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 |
/** clear all bits */
|
|
29 |
void T32Bits::Clear()
|
|
30 |
{
|
|
31 |
iData = 0;
|
|
32 |
}
|
|
33 |
|
|
34 |
/** @return non-0 if at least one of 32 bits is set to '1' */
|
|
35 |
TBool T32Bits::HasBitsSet() const
|
|
36 |
{
|
|
37 |
return iData;
|
|
38 |
}
|
|
39 |
|
|
40 |
/** sets bit number "aIndex" to '1' */
|
|
41 |
void T32Bits::SetBit(TUint32 aIndex)
|
|
42 |
{
|
|
43 |
ASSERT(aIndex < 32);
|
|
44 |
iData |= (1<<aIndex);
|
|
45 |
}
|
|
46 |
|
|
47 |
/**
|
|
48 |
Get value of the bit number "aIndex".
|
|
49 |
@return 0 if the bit aIndex is '0' non-zero otherwise
|
|
50 |
*/
|
|
51 |
TBool T32Bits::operator[](TUint32 aIndex) const
|
|
52 |
{
|
|
53 |
ASSERT(aIndex < 32);
|
|
54 |
return (iData & (1<<aIndex));
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
//-----------------------------------------------------------------------------
|
|
59 |
|
|
60 |
TUint32 CFatCacheBase::FatStartPos() const
|
|
61 |
{
|
|
62 |
return iFatStartPos;
|
|
63 |
}
|
|
64 |
|
|
65 |
TUint32 CFatCacheBase::FatSize() const
|
|
66 |
{
|
|
67 |
return iFatSize;
|
|
68 |
}
|
|
69 |
|
|
70 |
TFatType CFatCacheBase::FatType() const
|
|
71 |
{
|
|
72 |
return iFatType;
|
|
73 |
}
|
|
74 |
|
|
75 |
TBool CFatCacheBase::IsDirty() const
|
|
76 |
{
|
|
77 |
return iDirty;
|
|
78 |
}
|
|
79 |
|
|
80 |
void CFatCacheBase::SetDirty(TBool aDirty)
|
|
81 |
{
|
|
82 |
iDirty = aDirty;
|
|
83 |
}
|
|
84 |
|
|
85 |
TUint CFatCacheBase::NumFATs() const
|
|
86 |
{
|
|
87 |
return iNumFATs;
|
|
88 |
}
|
|
89 |
|
|
90 |
TUint CFatCacheBase::FAT_SectorSzLog2() const
|
|
91 |
{
|
|
92 |
return iFatSecSzLog2;
|
|
93 |
}
|
|
94 |
|
|
95 |
TUint CFatCacheBase::FAT_SectorSz() const
|
|
96 |
{
|
|
97 |
return 1 << iFatSecSzLog2;
|
|
98 |
}
|
|
99 |
|
|
100 |
TUint CFatCacheBase::FAT_ClusterSzLog2() const
|
|
101 |
{
|
|
102 |
return iFatClustSzLog2;
|
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
//-----------------------------------------------------------------------------
|
|
107 |
|
|
108 |
/** @return number of FAT cache sectors in this fixed cache */
|
|
109 |
TUint32 CFat12Cache::NumSectors() const
|
|
110 |
{
|
|
111 |
return iSectorsInCache;
|
|
112 |
}
|
|
113 |
|
|
114 |
|
|
115 |
//-----------------------------------------------------------------------------
|
|
116 |
|
|
117 |
|
|
118 |
/** @return Log2(page size in bytes) */
|
|
119 |
TUint CFatPagedCacheBase::PageSizeLog2() const
|
|
120 |
{
|
|
121 |
return iPageSizeLog2;
|
|
122 |
}
|
|
123 |
|
|
124 |
/** @return page size in bytes */
|
|
125 |
TUint CFatPagedCacheBase::PageSize() const
|
|
126 |
{
|
|
127 |
return Pow2(iPageSizeLog2);
|
|
128 |
}
|
|
129 |
|
|
130 |
/** @return Log2(size of the logical sector of the page in bytes) */
|
|
131 |
TUint CFatPagedCacheBase::SectorSizeLog2() const
|
|
132 |
{
|
|
133 |
return iSectorSizeLog2;
|
|
134 |
}
|
|
135 |
|
|
136 |
/** @return number of the logical sector in the page */
|
|
137 |
TUint CFatPagedCacheBase::SectorsInPage() const
|
|
138 |
{
|
|
139 |
return Pow2(iPageSizeLog2 - iSectorSizeLog2);
|
|
140 |
}
|
|
141 |
|
|
142 |
|
|
143 |
//-----------------------------------------------------------------------------
|
|
144 |
|
|
145 |
TUint CFat16FixedCache::NumPages() const
|
|
146 |
{
|
|
147 |
return (TUint)iPages.Count();
|
|
148 |
}
|
|
149 |
|
|
150 |
//-----------------------------------------------------------------------------
|
|
151 |
|
|
152 |
|
|
153 |
/** @return the index in the FAT table this page starts from */
|
|
154 |
TUint32 CFatCachePageBase::StartFatIndex() const
|
|
155 |
{
|
|
156 |
return iStartIndexInFAT;
|
|
157 |
}
|
|
158 |
|
|
159 |
/** @return number of FAT entries in the page */
|
|
160 |
TUint32 CFatCachePageBase::EntriesInPage() const
|
|
161 |
{
|
|
162 |
return iFatEntriesInPage;
|
|
163 |
}
|
|
164 |
|
|
165 |
/** @return page state */
|
|
166 |
CFatCachePageBase::TState CFatCachePageBase::State() const
|
|
167 |
{
|
|
168 |
return iState;
|
|
169 |
}
|
|
170 |
|
|
171 |
/** sets the state of the page */
|
|
172 |
void CFatCachePageBase::SetState(TState aState)
|
|
173 |
{
|
|
174 |
iState = aState;
|
|
175 |
}
|
|
176 |
|
|
177 |
/** @return ETrue if the page is dirty, i.e. contains non-flushed dirty sectors */
|
|
178 |
TBool CFatCachePageBase::IsDirty() const
|
|
179 |
{
|
|
180 |
if(State() == EDirty)
|
|
181 |
{
|
|
182 |
ASSERT(iDirtySectors.HasBitsSet());
|
|
183 |
return ETrue;
|
|
184 |
}
|
|
185 |
else
|
|
186 |
{
|
|
187 |
ASSERT(!iDirtySectors.HasBitsSet());
|
|
188 |
return EFalse;
|
|
189 |
}
|
|
190 |
}
|
|
191 |
|
|
192 |
/** @return ETrue if the page data are valid */
|
|
193 |
TBool CFatCachePageBase::IsValid() const
|
|
194 |
{
|
|
195 |
return (State() == EClean || State() == EDirty);
|
|
196 |
}
|
|
197 |
|
|
198 |
/** force the page to the clean state */
|
|
199 |
void CFatCachePageBase::SetClean()
|
|
200 |
{
|
|
201 |
iDirtySectors.Clear(); //-- clear dirty sectors bitmap
|
|
202 |
SetState(EClean);
|
|
203 |
}
|
|
204 |
|
|
205 |
/** @return page size in bytes */
|
|
206 |
TUint32 CFatCachePageBase::PageSize() const
|
|
207 |
{
|
|
208 |
return iCache.PageSize();
|
|
209 |
}
|
|
210 |
|
|
211 |
/** @return number of logical sectors in the page */
|
|
212 |
TUint32 CFatCachePageBase::NumSectors() const
|
|
213 |
{
|
|
214 |
return iCache.SectorsInPage();
|
|
215 |
}
|
|
216 |
|
|
217 |
/** @return ETrue if the entry at aFatIndex belongs to this page */
|
|
218 |
TBool CFatCachePageBase::IsEntryCached(TUint32 aFatIndex) const
|
|
219 |
{
|
|
220 |
return (aFatIndex >= iStartIndexInFAT && aFatIndex < iStartIndexInFAT+EntriesInPage());
|
|
221 |
}
|
|
222 |
|
|
223 |
|
|
224 |
//---------------------------------------------------------------------------------------------------------------------------------
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
#endif //SL_FAT_CACHE_INL
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|