author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 19 Aug 2010 11:14:22 +0300 | |
branch | RCL_3 |
changeset 42 | a179b74831c9 |
parent 39 | 2bb754abd467 |
child 43 | c1f20ce4abcf |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2005-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 |
// |
|
15 |
||
16 |
/** |
|
17 |
@file |
|
18 |
@internalComponent |
|
19 |
*/ |
|
20 |
||
21 |
#ifndef MPAGER_H |
|
22 |
#define MPAGER_H |
|
23 |
||
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
24 |
#include "mmu.h" |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
25 |
#include <kern_priv.h> |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
26 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
27 |
/** |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
28 |
Maximum number of pages to attempt to clean in one go. |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
29 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
30 |
If a paging device sets a preferred write size greater than this then it will fail to install with |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
31 |
KErrArgument. |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
32 |
*/ |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
33 |
const TUint KMaxPagesToClean = 16; |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
34 |
|
0 | 35 |
struct SVMCacheInfo; |
36 |
class DMemModelThread; |
|
37 |
class DMemoryMappingBase; |
|
38 |
||
39 |
class DPager |
|
40 |
{ |
|
41 |
public: |
|
42 |
DPager(); |
|
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
void InitCache(); |
0 | 44 |
void Init3(); |
45 |
||
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
FORCE_INLINE TBool CacheInitialised() |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
48 |
return iYoungOldRatio && iMinimumPageLimit; |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
49 |
} |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
50 |
|
0 | 51 |
FORCE_INLINE TUint NumberOfFreePages() |
52 |
{ |
|
53 |
return iNumberOfFreePages; |
|
54 |
} |
|
55 |
||
56 |
FORCE_INLINE TUint NumberOfDirtyPages() |
|
57 |
{ |
|
58 |
TUint ret; |
|
59 |
MmuLock::Lock(); |
|
60 |
ret = iNumberOfDirtyPages; |
|
61 |
MmuLock::Unlock(); |
|
62 |
return ret; |
|
63 |
} |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
64 |
|
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
65 |
FORCE_INLINE TUint MinimumPageCount() |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
66 |
{ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
67 |
return iMinimumPageCount; |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
68 |
} |
0 | 69 |
|
70 |
FORCE_INLINE void SetWritable(SPageInfo& aPageInfo) |
|
71 |
{ |
|
72 |
if (!aPageInfo.IsDirty()) |
|
73 |
{// This is the first mapping to write to the page so increase the |
|
74 |
// dirty page count. |
|
75 |
iNumberOfDirtyPages++; |
|
76 |
} |
|
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
77 |
aPageInfo.SetWritable(); |
0 | 78 |
} |
79 |
||
80 |
FORCE_INLINE void SetClean(SPageInfo& aPageInfo) |
|
81 |
{ |
|
82 |
__NK_ASSERT_DEBUG(iNumberOfDirtyPages); |
|
83 |
__NK_ASSERT_DEBUG(aPageInfo.IsDirty()); |
|
84 |
aPageInfo.SetClean(); |
|
85 |
iNumberOfDirtyPages--; |
|
86 |
} |
|
87 |
||
88 |
/** |
|
89 |
Remove RAM pages from the cache and return them to the system's free pool. |
|
90 |
(Free them.) |
|
91 |
||
92 |
This is called by class Mmu when it requires more free RAM to meet an |
|
93 |
allocation request. |
|
94 |
||
95 |
@param aNumPages The number of pages to free up. |
|
96 |
@return True if all pages could be freed, false otherwise |
|
97 |
@pre RamAlloc mutex held. |
|
98 |
*/ |
|
99 |
TBool GetFreePages(TInt aNumPages); |
|
100 |
||
101 |
||
102 |
/** |
|
103 |
Attempts to rejuvenate or page in the page to the mapping that took the page fault. |
|
104 |
||
105 |
@param aPc Address of instruction causing the fault. |
|
106 |
@param aFaultAddress Address of memory access which faulted. |
|
107 |
@param aFaultAsid The asid of the faulting thread's process. |
|
108 |
@param aAccessPermissions Bitmask of values from enum TAccessPermissions, which |
|
109 |
indicates the permissions required by faulting memory access. |
|
110 |
@param aMapInstanceCount The instance count of the mapping when it took the page fault. |
|
111 |
@param aThread The thread that took the page fault. |
|
112 |
@param aExceptionInfo The processor specific exception info. |
|
113 |
||
114 |
@return KErrNone if the page is now accessable, otherwise one of the system wide error codes. |
|
115 |
*/ |
|
116 |
TInt HandlePageFault( TLinAddr aPc, TLinAddr aFaultAddress, TUint aFaultAsid, TUint aFaultIndex, |
|
117 |
TUint aAccessPermissions, DMemoryObject* aMemory, DMemoryMapping* aMapping, |
|
118 |
TUint aMapInstanceCount, DThread* aThread, TAny* aExceptionInfo); |
|
119 |
||
120 |
||
121 |
/** |
|
122 |
Fault enumeration |
|
123 |
*/ |
|
124 |
enum TFault |
|
125 |
{ |
|
126 |
}; |
|
127 |
||
128 |
/** |
|
129 |
Fault the system. |
|
130 |
*/ |
|
131 |
static void Fault(TFault aFault); |
|
132 |
||
133 |
/** |
|
134 |
Get state of live page list. |
|
135 |
*/ |
|
136 |
void GetLiveListInfo(SVMCacheInfo& aInfo); |
|
137 |
||
138 |
/** |
|
139 |
Resize the live page list. |
|
140 |
*/ |
|
141 |
TInt ResizeLiveList(TUint aMinimumPageCount, TUint aMaximumPageCount); |
|
142 |
||
143 |
/** |
|
144 |
Recalculate live list size. |
|
145 |
*/ |
|
146 |
TInt ResizeLiveList(); |
|
147 |
||
148 |
/** |
|
149 |
Flush (unmap) all memory which is demand paged. |
|
150 |
This reduces the live page list to a minimum. |
|
151 |
*/ |
|
152 |
void FlushAll(); |
|
153 |
||
154 |
/** |
|
155 |
Give pages to paging system for managing. |
|
156 |
*/ |
|
157 |
void DonatePages(TUint aCount, TPhysAddr* aPages); |
|
158 |
||
159 |
/** |
|
160 |
Reclaim pages from paging system which were previously donated with DonatePages. |
|
161 |
||
162 |
@param aCount Number of pages. |
|
163 |
@param aPages Array of pages (as stored in an RPageArray). |
|
164 |
||
165 |
@return KErrNone if successful. |
|
166 |
KErrNoMemory if paging system doesn't have enough spare pages. This will leave some or all of the pages still managed by the pager. |
|
167 |
KErrNotFound if some of the pages were not actually being managed by the pager. |
|
168 |
*/ |
|
169 |
TInt ReclaimPages(TUint aCount, TPhysAddr* aPages); |
|
170 |
||
171 |
/** |
|
172 |
Called by class Mmu whenever a page of RAM is freed. The page state will be EUnused. |
|
173 |
If the page was being used by the pager then this gives it the opportunity to update |
|
174 |
any internal state. If the pager wishes to retain ownership of the page the it must |
|
175 |
return the result KErrNone, any other value will cause the page to be returned to the |
|
176 |
systems free pool. |
|
177 |
*/ |
|
178 |
TInt PageFreed(SPageInfo* aPageInfo); |
|
179 |
||
180 |
// |
|
181 |
// following public members for use by memory managers... |
|
182 |
// |
|
183 |
||
184 |
/** |
|
185 |
Allocate a number of RAM pages to store demand paged content. |
|
186 |
These pages are obtained from... |
|
187 |
||
188 |
1. An unused page in the live page list. |
|
189 |
2. The systems free pool. |
|
190 |
3. The oldest page from the live page list. |
|
191 |
*/ |
|
192 |
TInt PageInAllocPages(TPhysAddr* aPages, TUint aCount, Mmu::TRamAllocFlags aAllocFlags); |
|
193 |
||
194 |
/** |
|
195 |
Free a number of RAM pages allocated by PageInAllocPages. |
|
196 |
*/ |
|
197 |
void PageInFreePages(TPhysAddr* aPages, TUint aCount); |
|
198 |
||
199 |
/** |
|
200 |
Called to add a new page to the live list after a fault has occurred. |
|
201 |
||
202 |
@param aPageInfo The page. |
|
203 |
||
204 |
@pre MmuLock held |
|
205 |
@post MmuLock held (but may have been released by this function) |
|
206 |
*/ |
|
207 |
void PagedIn(SPageInfo* aPageInfo); |
|
208 |
||
209 |
/** |
|
210 |
@param aPageInfo The page. |
|
211 |
@param aPinArgs Owner of a replacement page which will be used to substitute for the pinned page. |
|
212 |
||
213 |
@pre MmuLock held |
|
214 |
@post MmuLock held (but may have been released by this function) |
|
215 |
*/ |
|
216 |
void PagedInPinned(SPageInfo* aPageInfo, TPinArgs& aPinArgs); |
|
217 |
||
218 |
/** |
|
219 |
@pre MmuLock held |
|
220 |
@post MmuLock left unchanged. |
|
221 |
*/ |
|
222 |
void PagedInUnneeded(SPageInfo* aPageInfo); |
|
223 |
||
224 |
/** |
|
225 |
@param aPageInfo The page to unpin. |
|
226 |
@param aPinArgs The resources used for pinning. The replacement pages allocated |
|
227 |
to this will be increased for each page which was became completely |
|
228 |
unpinned. |
|
229 |
||
230 |
@pre MmuLock held |
|
231 |
@post MmuLock held (but may have been released by this function) |
|
232 |
*/ |
|
233 |
void Unpin(SPageInfo* aPageInfo, TPinArgs& aPinArgs); |
|
234 |
||
235 |
/** |
|
236 |
@param aPageInfo The page to pin. Must be page being demand paged. |
|
237 |
@param aPinArgs Owner of a replacement page which will be used to substitute for the pinned page. |
|
238 |
||
239 |
@pre MmuLock held |
|
240 |
@post MmuLock held (but may have been released by this function) |
|
241 |
*/ |
|
242 |
void Pin(SPageInfo* aPageInfo, TPinArgs& aPinArgs); |
|
243 |
||
244 |
||
245 |
/** |
|
246 |
@pre MmuLock held |
|
247 |
@post MmuLock held (but may have been released by this function) |
|
248 |
*/ |
|
249 |
void RejuvenatePageTable(TPte* aPt); |
|
250 |
||
251 |
/** |
|
252 |
*/ |
|
253 |
TBool ReservePages(TUint aRequiredCount, TUint& aCount); |
|
254 |
||
255 |
/** |
|
256 |
*/ |
|
257 |
void UnreservePages(TUint& aCount); |
|
258 |
||
259 |
/** |
|
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
260 |
Indicates whether there are any dirty pages available to be cleaned by #CleanSomePages. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
261 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
262 |
This is called by the page cleaner to work out whether it has any work to do. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
263 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
264 |
@return Whether there are any dirty pages in the oldest section of the live list. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
265 |
*/ |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
266 |
TBool HasPagesToClean(); |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
267 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
268 |
/** |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
269 |
Attempt to clean one or more dirty pages in one go. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
270 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
271 |
Called by the page cleaner to clean pages and by PageInAllocPage when needs to steal a page from |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
272 |
the live list, but the oldest clean list is empty. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
273 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
274 |
May or may not succeed in acually cleaning any pages. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
275 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
276 |
@param aBackground Whether the activity should be ignored when determining whether the paging |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
277 |
device is busy. This is used by the page cleaner. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
278 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
279 |
@return The number of pages this method attempted to clean. If it returns zero, there were no |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
280 |
pages eligible to be cleaned. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
281 |
*/ |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
282 |
TInt CleanSomePages(TBool aBackground); |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
283 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
284 |
/** |
0 | 285 |
Enumeration of instrumented paging events which only require the |
286 |
SPageInfo object as an argument. |
|
287 |
*/ |
|
288 |
enum TEventSimple |
|
289 |
{ |
|
290 |
EEventPageInNew, |
|
291 |
EEventPageInAgain, |
|
292 |
EEventPageInUnneeded, |
|
293 |
EEventPageInFree, |
|
294 |
EEventPageOut, |
|
295 |
EEventPageAged, |
|
296 |
EEventPagePin, |
|
297 |
EEventPageUnpin, |
|
298 |
EEventPageDonate, |
|
299 |
EEventPageReclaim, |
|
300 |
EEventPageAgedClean, |
|
301 |
EEventPageAgedDirty, |
|
302 |
EEventPagePageTableAlloc |
|
303 |
}; |
|
304 |
||
305 |
/** |
|
306 |
Signal the occurrence of an event of type TEventSimple. |
|
307 |
*/ |
|
308 |
void Event(TEventSimple aEvent, SPageInfo* aPageInfo); |
|
309 |
||
310 |
/** |
|
311 |
Enumeration of instrumented paging events which require the faulting address |
|
312 |
and program counter as arguments. |
|
313 |
*/ |
|
314 |
enum TEventWithAddresses |
|
315 |
{ |
|
316 |
EEventPageInStart, |
|
317 |
EEventPageRejuvenate |
|
318 |
}; |
|
319 |
||
320 |
/** |
|
321 |
Signal the occurrence of an event of type TEventWithAddresses. |
|
322 |
*/ |
|
323 |
void Event(TEventWithAddresses aEvent, SPageInfo* aPageInfo, TLinAddr aPc, TLinAddr aFaultAddress, TUint aAccessPermissions); |
|
324 |
||
325 |
/** |
|
326 |
Get the pager's event info data. |
|
327 |
*/ |
|
328 |
void GetEventInfo(SVMEventInfo& aInfoOut); |
|
329 |
||
330 |
/** |
|
331 |
Reset the pager's event info data. |
|
332 |
*/ |
|
333 |
void ResetEventInfo(); |
|
334 |
||
335 |
/** |
|
336 |
Attempt to discard the specified page. |
|
337 |
||
338 |
@param aOldPageInfo The page info of the page to discard. |
|
339 |
@param aBlockZoneId The ID of the RAM zone not to allocate any required new page into. |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
340 |
@param aMoveDisFlags Flags that control the discarding of the page, should be a mask of |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
341 |
values from M::TMoveDiscardFlags |
0 | 342 |
*/ |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
343 |
TInt DiscardPage(SPageInfo* aOldPageInfo, TUint aBlockZoneId, TUint aMoveDisFlags); |
0 | 344 |
|
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
345 |
/** |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
346 |
Attempt to discard the specified page and then allocate a page of type aPageType |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
347 |
in its place. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
348 |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
349 |
Note - This will always attempt to move dirty pages rather than write them to swap. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
350 |
|
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
351 |
@param aPageInfo The page info of the page to discard. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
352 |
@param aPageType The new page type to allocate into aPageInfo's physical address. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
353 |
*/ |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
354 |
TInt DiscardAndAllocPage(SPageInfo* aPageInfo, TZonePageType aPageType); |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
355 |
|
0 | 356 |
|
357 |
/** |
|
358 |
Update any live list links to replace the old page with the new page. |
|
359 |
This is to be used when a page has been moved. |
|
360 |
||
361 |
@param aOldPageInfo The page info of the page to replace. |
|
362 |
@param aNewPageInfo The page info of the page to be used instead of the old page. |
|
363 |
*/ |
|
364 |
void ReplacePage(SPageInfo& aOldPageInfo, SPageInfo& aNewPageInfo); |
|
365 |
||
366 |
||
367 |
// |
|
368 |
// following public members for use by TPinArgs... |
|
369 |
// |
|
370 |
||
371 |
/** |
|
372 |
*/ |
|
373 |
TBool AllocPinReplacementPages(TUint aNumPages); |
|
374 |
||
375 |
/** |
|
376 |
*/ |
|
377 |
void FreePinReplacementPages(TUint aNumPages); |
|
378 |
||
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
379 |
// |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
380 |
// following public members for use by DDataPagedMemoryManager... |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
381 |
// |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
382 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
383 |
/** |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
384 |
Called by the data paged memory manager to set the number of pages the pager should attempt to |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
385 |
clean at once. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
386 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
387 |
This also adjusts the maximum size of the oldest list if it is too small to contain the |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
388 |
specified number of pages. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
389 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
390 |
@param aPagesToClean Number of pages the pager should attempt to clean in one go |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
391 |
*/ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
392 |
void SetPagesToClean(TUint aPagesToClean); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
393 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
394 |
/** |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
395 |
Get the number of pages the pager attempts to clean at once. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
396 |
*/ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
397 |
TUint PagesToClean(); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
398 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
399 |
/** |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
400 |
Called by the data paged memory manager to set whether pages cleaned must have sequential page |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
401 |
colour. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
402 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
403 |
@param aCleanInSequence Whether pages must have sequential page colour |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
404 |
*/ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
405 |
void SetCleanInSequence(TBool aCleanInSequence); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
406 |
|
0 | 407 |
private: |
408 |
/** |
|
409 |
Add a page to the head of the live page list. I.e. make it the 'youngest' page. |
|
410 |
||
411 |
@pre MmuLock held |
|
412 |
@post MmuLock left unchanged. |
|
413 |
*/ |
|
414 |
void AddAsYoungestPage(SPageInfo* aPageInfo); |
|
415 |
||
416 |
/** |
|
417 |
Mark a page as type EUnused and add it to the end of the live page list. |
|
418 |
I.e. make it the 'oldest' page, so that it is the first page to be reused. |
|
419 |
||
420 |
@pre MmuLock held |
|
421 |
@post MmuLock left unchanged. |
|
422 |
*/ |
|
423 |
void AddAsFreePage(SPageInfo* aPageInfo); |
|
424 |
||
425 |
/** |
|
426 |
Remove a page from live page list. |
|
427 |
It paged state is set to EUnpaged. |
|
428 |
||
429 |
@pre MmuLock held |
|
430 |
@post MmuLock left unchanged. |
|
431 |
*/ |
|
432 |
void RemovePage(SPageInfo* aPageInfo); |
|
433 |
||
434 |
/** |
|
36
bbf8bed59bcb
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
435 |
Get a page, either by stealing one from the live list or allocating one from the system. |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
436 |
|
36
bbf8bed59bcb
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
437 |
|
bbf8bed59bcb
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
438 |
|
bbf8bed59bcb
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
439 |
If the oldest page is an oldest dirty page, this may attempt to clean multiple pages by calling |
bbf8bed59bcb
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
440 |
#CleanSomePages. |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
441 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
442 |
If the oldest page is on any other list (i.e. is an old or young page) this will steal it, |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
443 |
aquiring the page cleaning mutex first if it is dirty. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
444 |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
445 |
Called from #PageInAllocPage, #TryReturnOldestPageToSystem, #AllowAddFreePage and |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
446 |
#AllowAddFreePages. |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
447 |
|
36
bbf8bed59bcb
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
448 |
@param aAllowAlloc Indicates whether the method should try to allocate a page from the system |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
449 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
450 |
@return KErrNone on success, KErrInUse if stealing failed or 1 to indicate the the oldest page |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
451 |
was dirty and the PageCleaning mutex was not held. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
452 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
453 |
@pre MmuLock held |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
454 |
@post MmuLock left unchanged. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
455 |
*/ |
36
bbf8bed59bcb
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
456 |
SPageInfo* StealOrAllocPage(TBool aAllowAlloc, Mmu::TRamAllocFlags aAllocFlags); |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
457 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
458 |
/** |
0 | 459 |
Steal a page from the memory object (if any) which is using the page. |
460 |
If successful the returned page will be in the EUnknown state and the |
|
461 |
cache state for the page is indeterminate. This is the same state as |
|
462 |
if the page had been allocated by Mmu::AllocRam. |
|
463 |
||
464 |
@pre RamAlloc mutex held |
|
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
465 |
@pre If the page is dirty the PageCleaning lock must be held. |
0 | 466 |
@pre MmuLock held |
467 |
@post MmuLock held (but may have been released by this function) |
|
468 |
*/ |
|
469 |
TInt StealPage(SPageInfo* aPageInfo); |
|
470 |
||
471 |
/** |
|
472 |
Restrict the access permissions for a page. |
|
473 |
||
474 |
@param aPageInfo The page. |
|
475 |
@param aRestriction The restriction type to apply. |
|
476 |
*/ |
|
477 |
TInt RestrictPage(SPageInfo* aPageInfo, TRestrictPagesType aRestriction); |
|
478 |
||
479 |
/** |
|
480 |
Get a RAM page from the system's free pool and add it to the live list as a free page. |
|
481 |
||
482 |
@return False if out of memory; |
|
483 |
true otherwise, though new free page may still have already been used. |
|
484 |
||
485 |
@pre MmuLock held |
|
486 |
@post MmuLock held (but may have been released by this function) |
|
487 |
*/ |
|
488 |
TBool TryGrowLiveList(); |
|
489 |
||
490 |
/** |
|
491 |
Get a RAM page from the system's free pool. |
|
492 |
||
493 |
@pre RamAllocLock held. |
|
494 |
||
495 |
@return The page or NULL if no page is available. |
|
496 |
*/ |
|
497 |
SPageInfo* GetPageFromSystem(Mmu::TRamAllocFlags aAllocFlags, TUint aBlockZoneId=KRamZoneInvalidId, TBool aBlockRest=EFalse); |
|
498 |
||
499 |
/** |
|
500 |
Put a page back on the system's free pool. |
|
501 |
||
502 |
@pre RamAllocLock held. |
|
503 |
*/ |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
504 |
TBool TryReturnOldestPageToSystem(); |
0 | 505 |
|
506 |
/** |
|
39
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
507 |
Ensure adding a page to the paging cache will be within the maximum size. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
508 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
509 |
@param aPageInfo On return this is set to the SPageInfo of a page that must be returned |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
510 |
to the system before a page can be added to the paging cache, or |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
511 |
NULL if no page must be returned to the system. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
512 |
*/ |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
513 |
void AllowAddFreePage(SPageInfo*& aPageInfo); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
514 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
515 |
/** |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
516 |
Ensure adding aNumPages pages to the paging cache will be within the maximum size. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
517 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
518 |
@param aPageInfo On return this is set to the SPageInfo of a page that must be returned |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
519 |
to the system before any more pages can be added to the paging cache, or |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
520 |
NULL if no page must be returned to the system. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
521 |
@param aNumPages The number of pages the caller wishes to add to the paging cache. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
522 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
523 |
@return If aPageInfo == NULL on return, this is the number of pages it is possible to |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
524 |
add to the paging cache or 1 if aPageInfo != NULL, i.e. a page will need |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
525 |
to be returned to the system. |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
526 |
*/ |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
527 |
TUint AllowAddFreePages(SPageInfo*& aPageInfo, TUint aNumPages); |
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
528 |
|
2bb754abd467
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
529 |
/** |
0 | 530 |
Put a specific page back on the system's free pool. |
531 |
||
532 |
@pre RamAllocLock held. |
|
533 |
*/ |
|
534 |
void ReturnPageToSystem(SPageInfo& aPageInfo); |
|
535 |
||
536 |
/** |
|
537 |
Allocate a RAM page to store demand paged content. |
|
538 |
This tries to obtain a RAM from the following places: |
|
539 |
1. An unused page in the live page list. |
|
540 |
2. The systems free pool. |
|
541 |
3. The oldest page from the live page list. |
|
542 |
*/ |
|
543 |
SPageInfo* PageInAllocPage(Mmu::TRamAllocFlags aAllocFlags); |
|
544 |
||
545 |
/** |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
546 |
Called by CleanSomePages() to select the pages be cleaned. |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
547 |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
548 |
This function finds a set of pages that can be mapped sequentially in memory when page colouring |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
549 |
restrictions are in effect. It is only called on systems with page colouring restrictions where |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
550 |
the paging media driver does not support writing by phyiscal address. |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
551 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
552 |
@pre MmuLock held |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
553 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
554 |
@param aPageInfosOut Pointer to an array of SPageInfo pointers, which must be at least |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
555 |
KMaxPagesToClean long. This will be filled in to indicate the pages to clean. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
556 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
557 |
@return The numnber of pages to clean. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
558 |
*/ |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
559 |
TInt SelectSequentialPagesToClean(SPageInfo** aPageInfosOut); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
560 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
561 |
/** |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
562 |
Called by CleanSomePages() to select the pages be cleaned. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
563 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
564 |
This funciton selects the oldest dirty pages. It is called on systems without page colouring |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
565 |
restrictions or where the paging media driver supports writing by phyiscal address. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
566 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
567 |
@pre MmuLock held |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
568 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
569 |
@param aPageInfosOut Pointer to an array of SPageInfo pointers, which must be at least |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
570 |
KMaxPagesToClean long. This will be filled in to indicate the pages to clean. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
571 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
572 |
@return The numnber of pages to clean. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
573 |
*/ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
574 |
TInt SelectOldestPagesToClean(SPageInfo** aPageInfosOut); |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
575 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
576 |
/** |
0 | 577 |
If the number of young pages exceeds that specified by iYoungOldRatio then a |
578 |
single page is made 'old'. Call this after adding a new 'young' page. |
|
579 |
||
580 |
@pre MmuLock held |
|
581 |
@post MmuLock held (but may have been released by this function) |
|
582 |
*/ |
|
583 |
void BalanceAges(); |
|
584 |
||
585 |
/** |
|
586 |
If HaveTooManyPages() then return them to the system. |
|
587 |
*/ |
|
588 |
void RemoveExcessPages(); |
|
589 |
||
590 |
/** |
|
591 |
@return True if pager has too many pages, false otherwise. |
|
592 |
*/ |
|
593 |
TBool HaveTooManyPages(); |
|
594 |
||
595 |
/** |
|
596 |
@return True if pager has its maximum number of pages, false otherwise. |
|
597 |
*/ |
|
598 |
TBool HaveMaximumPages(); |
|
599 |
||
600 |
/** |
|
601 |
Attempt to rejuvenate a page in which a page fault occurred. |
|
602 |
||
603 |
@param aOsAsid Address space ID in which fault occurred. |
|
604 |
@param aAddress Address of memory access which faulted. |
|
605 |
@param aAccessPermissions Bitmask of values from enum TAccessPermissions, which |
|
606 |
indicates the permissions required by faulting memory access. |
|
607 |
@param aPc Address of instruction causing the fault. (Used for tracing.) |
|
608 |
@param aMapping The mapping that maps the page that took the fault. |
|
609 |
@param aMapInstanceCount The instance count of the mappig when the page fault occurred. |
|
610 |
@param aThread The thread that took the page fault. |
|
611 |
@param aExceptionInfo The processor specific exception info. |
|
612 |
||
613 |
@return KErrNone if the page was remapped, KErrAbort if the mapping has be reused or detached, |
|
614 |
KErrNotFound if it may be possible to page in the page. |
|
615 |
*/ |
|
616 |
TInt TryRejuvenate( TInt aOsAsid, TLinAddr aAddress, TUint aAccessPermissions, TLinAddr aPc, |
|
617 |
DMemoryMappingBase* aMapping, TUint aMapInstanceCount, DThread* aThread, |
|
618 |
TAny* aExceptionInfo); |
|
619 |
||
620 |
/** |
|
621 |
Reserve one page for guaranteed locking use. |
|
622 |
Increments iReservePageCount if successful. |
|
623 |
||
624 |
@return True if operation was successful. |
|
625 |
*/ |
|
626 |
TBool ReservePage(); |
|
627 |
||
628 |
/** |
|
629 |
Called when a realtime thread takes a paging fault. |
|
630 |
Checks whether it's OK for the thread to take to fault. |
|
631 |
@return KErrNone if the paging fault should be further processed |
|
632 |
*/ |
|
633 |
TInt CheckRealtimeThreadFault(DThread* aThread, TAny* aExceptionInfo); |
|
634 |
||
635 |
/** |
|
636 |
Attempt to find the page table entry and page info for a page in the specified mapping. |
|
637 |
||
638 |
@param aOsAsid The OsAsid of the process that owns the mapping. |
|
639 |
@param aAddress The linear address of the page. |
|
640 |
@param aMapping The mapping that maps the linear address. |
|
641 |
@param aMapInstanceCount The instance count of the mapping. |
|
642 |
@param[out] aPte Will return a pointer to the page table entry for the page. |
|
643 |
@param[out] aPageInfo Will return a pointer to the page info for the page. |
|
644 |
||
645 |
@return KErrNone on success, KErrAbort when the mapping is now invalid, KErrNotFound when |
|
646 |
the page table or page info can't be found. |
|
647 |
*/ |
|
648 |
TInt PteAndInfoFromLinAddr( TInt aOsAsid, TLinAddr aAddress, DMemoryMappingBase* aMapping, |
|
649 |
TUint aMapInstanceCount, TPte*& aPte, SPageInfo*& aPageInfo); |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
650 |
|
0 | 651 |
#ifdef _DEBUG |
652 |
/** |
|
653 |
Check consistency of live list. |
|
654 |
*/ |
|
655 |
TBool CheckLists(); |
|
656 |
||
657 |
void TraceCounts(); |
|
658 |
#endif |
|
659 |
||
660 |
private: |
|
661 |
TUint iMinYoungPages; ///< Minimum number of young pages in live list required for correct functioning. |
|
662 |
TUint iAbsoluteMinPageCount;///< Absolute minimum number of pages in live to meet algorithm constraints |
|
663 |
private: |
|
664 |
TUint iMinimumPageCount; /**< Minimum size for the live page list, including locked pages */ |
|
665 |
TUint iMaximumPageCount; /**< Maximum size for the live page list, including locked pages */ |
|
666 |
TUint16 iYoungOldRatio; /**< Ratio of young to old pages in the live page list */ |
|
667 |
SDblQue iYoungList; /**< Head of 'young' page list. */ |
|
668 |
TUint iYoungCount; /**< Number of young pages */ |
|
669 |
SDblQue iOldList; /**< Head of 'old' page list. */ |
|
670 |
TUint iOldCount; /**< Number of old pages */ |
|
671 |
SDblQue iOldestCleanList; /**< Head of 'oldestClean' page list. */ |
|
672 |
TUint iOldestCleanCount; /**< Number of 'oldestClean' pages */ |
|
673 |
SDblQue iOldestDirtyList; /**< Head of 'oldestDirty' page list. */ |
|
674 |
TUint iOldestDirtyCount; /**< Number of 'oldestDirty' pages */ |
|
675 |
TUint16 iOldOldestRatio; /**< Ratio of old pages to oldest to clean and dirty in the live page list*/ |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
676 |
TUint iMaxOldestPages; /**< Maximum number of oldest pages. */ |
0 | 677 |
TUint iNumberOfFreePages; |
678 |
TUint iNumberOfDirtyPages; /**< The total number of dirty pages in the paging cache. Protected by MmuLock */ |
|
679 |
TUint iInitMinimumPageCount;/**< Initial value for iMinimumPageCount */ |
|
680 |
TUint iInitMaximumPageCount;/**< Initial value for iMaximumPageCount */ |
|
681 |
TUint iReservePageCount; /**< Number of pages reserved for locking */ |
|
682 |
TUint iMinimumPageLimit; /**< Minimum size for iMinimumPageCount, not including locked pages. |
|
683 |
iMinimumPageCount >= iMinimumPageLimit + iReservePageCount */ |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
684 |
TUint iPagesToClean; /**< Preferred number of pages to attempt to clean in one go. */ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
685 |
TBool iCleanInSequence; /**< Pages to be cleaned must have sequential page colour. */ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
686 |
|
0 | 687 |
SVMEventInfo iEventInfo; |
688 |
||
689 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
690 |
public: |
|
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
691 |
void RecordBenchmarkData(TPagingBenchmark aBm, TUint32 aStartTime, TUint32 aEndTime, TUint aCount); |
0 | 692 |
void ResetBenchmarkData(TPagingBenchmark aBm); |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
693 |
void ReadBenchmarkData(TPagingBenchmark aBm, SPagingBenchmarkInfo& aDataOut); |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
694 |
TSpinLock iBenchmarkLock; |
0 | 695 |
SPagingBenchmarkInfo iBenchmarkInfo[EMaxPagingBm]; |
696 |
#endif //__DEMAND_PAGING_BENCHMARKS__ |
|
697 |
}; |
|
698 |
||
699 |
extern DPager ThePager; |
|
700 |
||
701 |
||
702 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
703 |
||
704 |
#define START_PAGING_BENCHMARK TUint32 _bmStart = NKern::FastCounter() |
|
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
705 |
#define END_PAGING_BENCHMARK(bm) ThePager.RecordBenchmarkData(bm, _bmStart, NKern::FastCounter(), 1) |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
706 |
#define END_PAGING_BENCHMARK_N(bm, n) ThePager.RecordBenchmarkData(bm, _bmStart, NKern::FastCounter(), (n)) |
0 | 707 |
|
708 |
#else |
|
709 |
||
710 |
#define START_PAGING_BENCHMARK |
|
711 |
#define END_PAGING_BENCHMARK(bm) |
|
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
712 |
#define END_PAGING_BENCHMARK_N(bm, n) |
0 | 713 |
#endif // __DEMAND_PAGING_BENCHMARKS__ |
714 |
||
715 |
||
716 |
FORCE_INLINE void DPager::Event(TEventSimple aEvent, SPageInfo* aPageInfo) |
|
717 |
{ |
|
718 |
switch(aEvent) |
|
719 |
{ |
|
720 |
case EEventPageInNew: |
|
721 |
TRACEP(("DP: %O PageIn 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
722 |
#ifdef BTRACE_PAGING |
|
723 |
BTraceContext12(BTrace::EPaging,BTrace::EPagingPageIn,aPageInfo->PhysAddr(),aPageInfo->Owner(),aPageInfo->Index()); |
|
724 |
#endif |
|
725 |
++iEventInfo.iPageInReadCount; |
|
726 |
break; |
|
727 |
||
728 |
case EEventPageInAgain: |
|
729 |
TRACEP(("DP: %O PageIn (again) 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
730 |
#ifdef BTRACE_PAGING |
|
731 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingMapPage,aPageInfo->PhysAddr()); |
|
732 |
#endif |
|
733 |
break; |
|
734 |
||
735 |
case EEventPageInUnneeded: |
|
736 |
TRACEP(("DP: %O PageIn (unneeded) 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
737 |
#ifdef BTRACE_PAGING |
|
738 |
BTraceContext0(BTrace::EPaging,BTrace::EPagingPageInUnneeded); |
|
739 |
#endif |
|
740 |
break; |
|
741 |
||
742 |
case EEventPageInFree: |
|
743 |
TRACEP(("DP: %O PageInFree 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
744 |
#ifdef BTRACE_PAGING |
|
745 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingPageInFree,aPageInfo->PhysAddr()); |
|
746 |
#endif |
|
747 |
break; |
|
748 |
||
749 |
case EEventPageOut: |
|
750 |
TRACEP(("DP: %O PageOut 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
751 |
#ifdef BTRACE_PAGING |
|
752 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingPageOut,aPageInfo->PhysAddr()); |
|
753 |
#endif |
|
754 |
break; |
|
755 |
||
756 |
case EEventPageAged: |
|
757 |
TRACEP(("DP: %O Aged 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
758 |
#ifdef BTRACE_PAGING_VERBOSE |
|
759 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingAged,aPageInfo->PhysAddr()); |
|
760 |
#endif |
|
761 |
break; |
|
762 |
||
763 |
case EEventPagePin: |
|
764 |
TRACEP(("DP: %O Pin 0x%08x count=%d",TheCurrentThread,aPageInfo->PhysAddr(),aPageInfo->PinCount())); |
|
765 |
#ifdef BTRACE_PAGING |
|
766 |
BTraceContext8(BTrace::EPaging,BTrace::EPagingPageLock,aPageInfo->PhysAddr(),aPageInfo->PinCount()); |
|
767 |
#endif |
|
768 |
break; |
|
769 |
||
770 |
case EEventPageUnpin: |
|
771 |
TRACEP(("DP: %O Unpin 0x%08x count=%d",TheCurrentThread,aPageInfo->PhysAddr(),aPageInfo->PinCount())); |
|
772 |
#ifdef BTRACE_PAGING |
|
773 |
BTraceContext8(BTrace::EPaging,BTrace::EPagingPageUnlock,aPageInfo->PhysAddr(),aPageInfo->PinCount()); |
|
774 |
#endif |
|
775 |
break; |
|
776 |
||
777 |
case EEventPageDonate: |
|
778 |
TRACEP(("DP: %O Donate 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
779 |
#ifdef BTRACE_PAGING |
|
780 |
BTraceContext12(BTrace::EPaging,BTrace::EPagingDonatePage,aPageInfo->PhysAddr(),aPageInfo->Owner(),aPageInfo->Index()); |
|
781 |
#endif |
|
782 |
break; |
|
783 |
||
784 |
case EEventPageReclaim: |
|
785 |
TRACEP(("DP: %O Reclaim 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
786 |
#ifdef BTRACE_PAGING |
|
787 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingReclaimPage,aPageInfo->PhysAddr()); |
|
788 |
#endif |
|
789 |
break; |
|
790 |
||
791 |
case EEventPageAgedClean: |
|
792 |
TRACEP(("DP: %O AgedClean 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
793 |
#ifdef BTRACE_PAGING_VERBOSE |
|
794 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingAgedClean,aPageInfo->PhysAddr()); |
|
795 |
#endif |
|
796 |
break; |
|
797 |
||
798 |
case EEventPageAgedDirty: |
|
799 |
TRACEP(("DP: %O AgedDirty 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
800 |
#ifdef BTRACE_PAGING_VERBOSE |
|
801 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingAgedDirty,aPageInfo->PhysAddr()); |
|
802 |
#endif |
|
803 |
break; |
|
804 |
||
805 |
case EEventPagePageTableAlloc: |
|
806 |
TRACEP(("DP: %O PageTableAlloc 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
807 |
#ifdef BTRACE_PAGING |
|
808 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingPageTableAlloc,aPageInfo->PhysAddr()); |
|
809 |
#endif |
|
810 |
break; |
|
811 |
||
812 |
default: |
|
813 |
__NK_ASSERT_DEBUG(0); |
|
814 |
break; |
|
815 |
} |
|
816 |
} |
|
817 |
||
818 |
||
819 |
||
820 |
FORCE_INLINE void DPager::Event(TEventWithAddresses aEvent, SPageInfo* aPageInfo, TLinAddr aPc, TLinAddr aFaultAddress, TUint aAccessPermissions) |
|
821 |
{ |
|
822 |
switch(aEvent) |
|
823 |
{ |
|
824 |
case EEventPageInStart: |
|
825 |
TRACEP(("DP: %O HandlePageFault 0x%08x 0x%08x %d",TheCurrentThread,aFaultAddress,aPc,aAccessPermissions)); |
|
826 |
#ifdef BTRACE_PAGING |
|
827 |
BTraceContext12(BTrace::EPaging,BTrace::EPagingPageInBegin,aFaultAddress,aPc,aAccessPermissions); |
|
828 |
#endif |
|
829 |
++iEventInfo.iPageFaultCount; |
|
830 |
break; |
|
831 |
||
832 |
case EEventPageRejuvenate: |
|
833 |
TRACEP(("DP: %O Rejuvenate 0x%08x 0x%08x 0x%08x %d",TheCurrentThread,aPageInfo->PhysAddr(),aFaultAddress,aPc,aAccessPermissions)); |
|
834 |
#ifdef BTRACE_PAGING |
|
835 |
BTraceContext12(BTrace::EPaging,BTrace::EPagingRejuvenate,aPageInfo->PhysAddr(),aFaultAddress,aPc); |
|
836 |
#endif |
|
837 |
++iEventInfo.iPageFaultCount; |
|
838 |
break; |
|
839 |
||
840 |
default: |
|
841 |
__NK_ASSERT_DEBUG(0); |
|
842 |
break; |
|
843 |
} |
|
844 |
} |
|
845 |
||
846 |
||
847 |
||
848 |
/** |
|
849 |
Multiplier for number of request objects in pool per drive that supports paging. |
|
850 |
*/ |
|
851 |
const TInt KPagingRequestsPerDevice = 2; |
|
852 |
||
853 |
||
854 |
class DPageReadRequest; |
|
855 |
class DPageWriteRequest; |
|
856 |
||
857 |
/** |
|
858 |
A pool of paging requests for use by a single paging device. |
|
859 |
*/ |
|
860 |
class DPagingRequestPool : public DBase |
|
861 |
{ |
|
862 |
public: |
|
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
863 |
DPagingRequestPool(TUint aNumPageReadRequest, TBool aWriteRequest); |
0 | 864 |
DPageReadRequest* AcquirePageReadRequest(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
865 |
DPageWriteRequest* AcquirePageWriteRequest(DMemoryObject** aMemory, TUint* aIndex, TUint aCount); |
0 | 866 |
private: |
867 |
~DPagingRequestPool(); |
|
868 |
private: |
|
869 |
class TGroup |
|
870 |
{ |
|
871 |
public: |
|
872 |
TGroup(TUint aNumRequests); |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
873 |
DPageReadRequest* FindCollisionContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
874 |
DPageReadRequest* GetRequest(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
0 | 875 |
public: |
876 |
TUint iNumRequests; |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
877 |
DPageReadRequest** iRequests; |
0 | 878 |
SDblQue iFreeList; |
879 |
}; |
|
880 |
TGroup iPageReadRequests; |
|
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
881 |
DPageWriteRequest* iPageWriteRequest; |
0 | 882 |
|
883 |
friend class DPageReadRequest; |
|
884 |
}; |
|
885 |
||
886 |
||
887 |
/** |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
888 |
Common resources needed to service a paging request. |
0 | 889 |
*/ |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
890 |
class DPagingRequestBase : public DBase |
0 | 891 |
{ |
892 |
public: |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
893 |
TLinAddr MapPages(TUint aColour, TUint aCount, TPhysAddr* aPages); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
894 |
void UnmapPages(TBool aIMBRequired); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
895 |
public: // for DPagingRequestPool |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
896 |
DMutex* iMutex; /**< A mutex for synchronisation and priority inheritance. */ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
897 |
protected: |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
898 |
Mmu::TTempMapping iTempMapping; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
899 |
}; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
900 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
901 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
902 |
/** |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
903 |
Resources needed to service a page in request. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
904 |
*/ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
905 |
class DPageReadRequest : public DPagingRequestBase |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
906 |
{ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
907 |
public: |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
908 |
static TUint ReservedPagesRequired(); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
909 |
private: |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
910 |
static TInt iAllocNext; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
911 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
912 |
public: |
0 | 913 |
enum |
914 |
{ |
|
915 |
EMaxPages = 4 |
|
916 |
}; |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
917 |
DPageReadRequest(DPagingRequestPool::TGroup& aPoolGroup); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
918 |
TInt Construct(); |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
919 |
void Release(); |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
920 |
void Wait(); |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
921 |
void Signal(); |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
922 |
void SetUseContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
923 |
void ResetUse(); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
924 |
TBool CheckUseContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
925 |
TBool IsCollisionContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
926 |
TLinAddr Buffer() { return iBuffer; } |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
927 |
TUint ThreadsWaiting() { return iUsageCount; } |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
928 |
private: |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
929 |
~DPageReadRequest() { } // can't delete |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
930 |
public: // for DPagingRequestPool |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
931 |
SDblQueLink iLink; /**< Link into list of free requests. */ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
932 |
private: |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
933 |
TInt iUsageCount; /**< How many threads are using or waiting for this object. */ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
934 |
TLinAddr iBuffer; /**< A buffer of size EMaxPages+1 pages to read compressed data into. */ |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
935 |
DPagingRequestPool::TGroup& iPoolGroup; |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
936 |
DMemoryObject* iMemory; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
937 |
TUint iIndex; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
938 |
TUint iCount; |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
939 |
}; |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
940 |
|
0 | 941 |
|
942 |
/** |
|
943 |
Resources needed to service a page out request. |
|
944 |
*/ |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
945 |
class DPageWriteRequest : public DPagingRequestBase |
0 | 946 |
{ |
947 |
public: |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
948 |
enum |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
949 |
{ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
950 |
EMaxPages = KMaxPagesToClean |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
951 |
}; |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
952 |
DPageWriteRequest(); |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
953 |
void Release(); |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
954 |
void SetUseDiscontiguous(DMemoryObject** aMemory, TUint* aIndex, TUint aCount); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
955 |
void ResetUse(); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
956 |
TBool CheckUseContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
957 |
TBool IsCollisionContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
0 | 958 |
private: |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
959 |
~DPageWriteRequest() { } // can't delete |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
960 |
private: |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
961 |
// used to identify the memory the request is used for... |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
962 |
TUint iUseRegionCount; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
963 |
DMemoryObject* iUseRegionMemory[EMaxPages]; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
964 |
TUint iUseRegionIndex[EMaxPages]; |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
965 |
}; |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
966 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
967 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
968 |
/** |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
969 |
Class providing access to the mutex used to protect page cleaning operations; |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
970 |
this is the mutex DPager::iPageCleaningLock. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
971 |
*/ |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
972 |
class PageCleaningLock |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
973 |
{ |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
974 |
public: |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
975 |
/** |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
976 |
Acquire the lock. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
977 |
The lock may be acquired multiple times by a thread, and will remain locked |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
978 |
until #Unlock has been used enough times to balance this. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
979 |
*/ |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
980 |
static void Lock(); |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
981 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
982 |
/** |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
983 |
Release the lock. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
984 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
985 |
@pre The current thread has previously acquired the lock. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
986 |
*/ |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
987 |
static void Unlock(); |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
988 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
989 |
/** |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
990 |
Return true if the current thread holds the lock. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
991 |
This is used for debug checks. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
992 |
*/ |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
993 |
static TBool IsHeld(); |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
994 |
|
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
995 |
/** |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
996 |
Create the lock. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
997 |
Called by DPager::Init3(). |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
998 |
*/ |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
999 |
static void Init(); |
0 | 1000 |
}; |
1001 |
||
1002 |
||
1003 |
#endif |