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