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