author | mikek |
Wed, 16 Jun 2010 12:59:18 +0100 | |
branch | GCC_SURGE |
changeset 160 | 30e086416910 |
parent 102 | ef2a444a7410 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2006-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 |
// e32test\defrag\t_ramdefrag.h |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#ifndef _T_RAMDEFRAG_H_ |
|
19 |
#define _T_RAMDEFRAG_H_ |
|
20 |
||
21 |
#include <e32cmn.h> |
|
22 |
#ifndef __KERNEL_MODE__ |
|
23 |
#include <e32std.h> |
|
24 |
#endif |
|
25 |
||
26 |
#define DEFRAG_TYPE_GEN (1) |
|
27 |
#define DEFRAG_TYPE_EMPTY (2) |
|
28 |
#define DEFRAG_TYPE_CLAIM (3) |
|
29 |
||
30 |
#define DEFRAG_VER_SYNC (1) |
|
31 |
#define DEFRAG_VER_SEM (2) |
|
32 |
#define DEFRAG_VER_DFC (3) |
|
33 |
||
34 |
#define NO_FIXED_FLAG (1) |
|
35 |
#define NO_MOVE_FLAG (2) |
|
36 |
#define NO_DISCARD_FLAG (3) |
|
37 |
#define NO_ALLOC_FLAG (4) |
|
38 |
#define ONLY_DISCARD_FLAG (5) |
|
39 |
#define RESET_FLAG (6) |
|
40 |
#define ORIG_FLAG (7) |
|
41 |
||
42 |
#define FREE_ALL_FIXED (0) |
|
43 |
#define FILL_ALL_FIXED (-1) |
|
44 |
||
45 |
#define FREE_VALID (0) |
|
46 |
#define FREE_INVALID (-1) |
|
47 |
//#define DEBUG_VER |
|
48 |
#ifdef DEBUG_VER |
|
49 |
#define TESTDEBUG(a) {a;} |
|
50 |
#else |
|
51 |
#define TESTDEBUG(a) {} |
|
52 |
#endif |
|
53 |
||
54 |
struct SCapsPageMoveV01 |
|
55 |
{ |
|
56 |
TVersion iVersion; |
|
57 |
}; |
|
58 |
||
59 |
struct STestRamDefragVars |
|
60 |
{ |
|
61 |
TInt iRamSize; |
|
62 |
TInt iFreeRam; |
|
63 |
TInt iPageSize; |
|
64 |
TInt iRamUsed; |
|
65 |
TInt iNumFreePages; |
|
66 |
}; |
|
67 |
||
68 |
struct STestUserSidePageCount |
|
69 |
{ |
|
70 |
TUint iFreePages; /**<the number of free pages in the RAM zone*/ |
|
71 |
TUint iFixedPages; /**<the number of fixed pages in the RAM zone*/ |
|
72 |
TUint iMovablePages; /**<the number of movable pages in the RAM zone*/ |
|
73 |
TUint iDiscardablePages;/**<the number of discardable pages in the RAM zone*/ |
|
74 |
TUint iReserved[4]; /**<@internalAll reserved for internal use only*/ |
|
75 |
}; |
|
76 |
||
77 |
struct STestPageCount |
|
78 |
{ |
|
79 |
TUint iFreePages; |
|
80 |
TUint iUnknownPages; |
|
81 |
TUint iFixedPages; |
|
82 |
TUint iMovablePages; |
|
83 |
TUint iDiscardablePages; |
|
84 |
TUint iOtherPages; |
|
85 |
}; |
|
86 |
||
87 |
struct STestFlagParams |
|
88 |
{ |
|
89 |
TUint iZoneID; |
|
90 |
TUint8 iZoneFlag; |
|
91 |
TInt iSetFlag; |
|
92 |
TUint8 iOptSetFlag; |
|
93 |
}; |
|
94 |
||
95 |
||
96 |
struct STestParameters |
|
97 |
{ |
|
98 |
TInt iDefragVersion; |
|
99 |
TInt iDefragType; |
|
100 |
TInt iPriority; |
|
101 |
TInt iMaxPages; |
|
102 |
TUint iID; |
|
103 |
TRequestStatus* iReqStat; |
|
104 |
TRequestStatus* iReqStat2; |
|
105 |
TRequestStatus* iReqStat3; |
|
106 |
}; |
|
107 |
||
108 |
// struct for passing multiple RAM zone IDs to the LDD. |
|
109 |
struct SMultiZoneAlloc |
|
110 |
{ |
|
111 |
TUint* iZoneId; /**< An array of RAM zone IDs*/ |
|
112 |
TUint iZoneIdSize; /**< The number of IDs in iZoneId*/ |
|
113 |
}; |
|
114 |
||
115 |
_LIT(KRamDefragFuncTestLddName,"D_RAMDEFRAG"); |
|
116 |
||
117 |
class RRamDefragFuncTestLdd : public RBusLogicalChannel |
|
118 |
{ |
|
119 |
public: |
|
120 |
enum TControl |
|
121 |
{ |
|
122 |
EDoConsumeRamFinish, |
|
123 |
EDoSetDebugFlag, |
|
124 |
EAllocateFixed, |
|
125 |
EAllocFixedArray, |
|
126 |
EAllocateFixed2, |
|
127 |
EGetAllocDiff, |
|
128 |
EFreeAllFixed, |
|
129 |
EAllocateFixedWrite, |
|
130 |
EFreeAllFixedRead, |
|
131 |
EPageCount, |
|
132 |
EZoneAllocContiguous, |
|
133 |
EMultiZoneAllocContiguous, |
|
134 |
EZoneAllocDiscontiguous, |
|
135 |
EMultiZoneAllocDiscontiguous, |
|
136 |
EZoneAllocDiscontiguous2, |
|
137 |
EZoneAllocToMany, |
|
138 |
EZoneAllocToManyArray, |
|
139 |
EZoneAllocToMany2, |
|
140 |
EAllocContiguous, |
|
141 |
EFreeZone, |
|
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
EFreeZoneId, |
0 | 143 |
EFreeFromAllZones, |
144 |
EFreeFromAddr, |
|
145 |
ECheckCancel, |
|
146 |
ECheckPriorities, |
|
147 |
ECallDefrag, |
|
148 |
ESetZoneFlag, |
|
149 |
EGetDefragOrder, |
|
150 |
EResetDriver, |
|
151 |
}; |
|
152 |
||
153 |
#ifndef __KERNEL_MODE__ |
|
154 |
public: |
|
155 |
inline TInt Open() |
|
156 |
{ return DoCreate(KRamDefragFuncTestLddName,TVersion(),KNullUnit,NULL,NULL,EOwnerProcess,ETrue); } |
|
157 |
||
158 |
inline TInt ResetDriver() |
|
159 |
{ return DoControl(EResetDriver,(TAny*)NULL, (TAny*)NULL); } |
|
160 |
||
161 |
inline TInt DoSetDebugFlag(TInt aState) |
|
162 |
{ return DoControl(EDoSetDebugFlag,(TAny*)aState, (TAny*)NULL); } |
|
163 |
||
164 |
inline TInt AllocateFixed(TInt aNumOfPages) |
|
165 |
{ return DoControl(EAllocateFixed,(TAny*)aNumOfPages, (TAny*)NULL); } |
|
166 |
||
167 |
inline TInt AllocFixedArray(TInt aNumOfPages) |
|
168 |
{ return DoControl(EAllocFixedArray,(TAny*)aNumOfPages, (TAny*)NULL); } |
|
169 |
||
170 |
inline TInt AllocateFixed2(TInt aNumOfPages) |
|
171 |
{ return DoControl(EAllocateFixed2,(TAny*)aNumOfPages, (TAny*)NULL); } |
|
172 |
||
173 |
inline TInt GetAllocDiff(TInt aNumOfPages) |
|
174 |
{ return DoControl(EGetAllocDiff,(TAny*)aNumOfPages, (TAny*)NULL); } |
|
175 |
||
176 |
inline TInt FreeAllFixedPages() |
|
177 |
{ return DoControl(EFreeAllFixed); } |
|
178 |
||
179 |
inline TInt AllocateFixedWrite(TInt aNumOfPages) |
|
180 |
{ return DoControl(EAllocateFixedWrite,(TAny*)aNumOfPages, (TAny*)NULL); } |
|
181 |
||
182 |
inline TInt FreeAllFixedPagesRead() |
|
183 |
{ return DoControl(EFreeAllFixedRead,(TAny*)NULL, (TAny*)NULL); } |
|
184 |
||
185 |
inline TInt ZoneAllocContiguous(TUint aZoneID, TInt aSize) |
|
186 |
{ return DoControl(EZoneAllocContiguous,(TAny*)aZoneID, (TAny*)aSize); } |
|
187 |
||
188 |
inline TInt MultiZoneAllocContiguous(TUint* aZoneId, TUint aZoneIdSize, TInt aSize) |
|
189 |
{ |
|
190 |
SMultiZoneAlloc multiZoneAlloc; |
|
191 |
multiZoneAlloc.iZoneId = aZoneId; |
|
192 |
multiZoneAlloc.iZoneIdSize = aZoneIdSize; |
|
193 |
return DoControl(EMultiZoneAllocContiguous,(TAny*)&multiZoneAlloc, (TAny*)aSize); |
|
194 |
} |
|
195 |
||
196 |
inline TInt ZoneAllocDiscontiguous(TUint aZoneID, TInt aNumPages) |
|
197 |
{ return DoControl(EZoneAllocDiscontiguous,(TAny*)aZoneID, (TAny*)aNumPages); } |
|
198 |
||
199 |
inline TInt MultiZoneAllocDiscontiguous(TUint* aZoneId, TUint aZoneIdSize, TInt aNumPages) |
|
200 |
{ |
|
201 |
SMultiZoneAlloc multiZoneAlloc; |
|
202 |
multiZoneAlloc.iZoneId = aZoneId; |
|
203 |
multiZoneAlloc.iZoneIdSize = aZoneIdSize; |
|
204 |
return DoControl(EMultiZoneAllocDiscontiguous,(TAny*)&multiZoneAlloc, (TAny*)aNumPages); |
|
205 |
} |
|
206 |
||
207 |
inline TInt ZoneAllocDiscontiguous2(TUint aZoneID, TInt aNumPages) |
|
208 |
{ return DoControl(EZoneAllocDiscontiguous2,(TAny*)aZoneID, (TAny*)aNumPages); } |
|
209 |
||
210 |
inline TInt ZoneAllocToMany(TInt aZoneIndex, TInt aNumPages) |
|
211 |
{ return DoControl(EZoneAllocToMany,(TAny*)aZoneIndex, (TAny*)aNumPages); } |
|
212 |
||
213 |
inline TInt ZoneAllocToManyArray(TInt aZoneIndex, TInt aNumPages) |
|
214 |
{ return DoControl(EZoneAllocToManyArray,(TAny*)aZoneIndex, (TAny*)aNumPages); } |
|
215 |
||
216 |
inline TInt ZoneAllocToMany2(TInt aZoneIndex, TInt aNumPages) |
|
217 |
{ return DoControl(EZoneAllocToMany2,(TAny*)aZoneIndex, (TAny*)aNumPages); } |
|
218 |
||
219 |
inline TInt AllocContiguous(TInt aSize) |
|
220 |
{ return DoControl(EAllocContiguous,(TAny*)aSize, (TAny*)NULL); } |
|
221 |
||
222 |
inline TInt FreeZone(TInt aNumPages) |
|
223 |
{ return DoControl(EFreeZone,(TAny*)aNumPages, (TAny*)NULL); } |
|
224 |
||
225 |
inline TInt FreeFromAllZones() |
|
226 |
{ return DoControl(EFreeFromAllZones,(TAny*)NULL, (TAny*)NULL); } |
|
227 |
||
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
228 |
inline TInt FreeZoneId(TUint aZoneId) |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
229 |
{ return DoControl(EFreeZoneId, (TAny*)aZoneId); } |
0 | 230 |
|
231 |
inline TInt CheckCancel(TInt aDefragType, TUint aID = 0) |
|
232 |
{ |
|
233 |
STestParameters params; |
|
234 |
||
235 |
params.iDefragType = aDefragType; |
|
236 |
params.iDefragVersion = 0; |
|
237 |
params.iID = aID; |
|
238 |
params.iPriority = 0; |
|
239 |
params.iMaxPages = 0; |
|
240 |
params.iReqStat = NULL; |
|
241 |
params.iReqStat2 = NULL; |
|
242 |
params.iReqStat3 = NULL; |
|
243 |
return DoControl(ECheckCancel,(TAny*)¶ms); |
|
244 |
} |
|
245 |
||
246 |
inline TInt FreeFromAddr(TInt aNumPages, TUint32 aAddr) |
|
247 |
{ return DoControl(EFreeFromAddr,(TAny*)aNumPages, (TAny*)aAddr); } |
|
248 |
||
249 |
inline TInt PageCount(TUint aID, STestUserSidePageCount* aPageData) |
|
250 |
{ return DoControl(EPageCount,(TAny*)aID, (TAny*)aPageData); } |
|
251 |
||
252 |
inline TInt CallDefrag(TInt aDefragType, TInt aDefragVersion, TUint aID = 0, TInt aMaxPages = 0, TInt aPriority = -1, TRequestStatus* aReqStat = NULL) |
|
253 |
{ |
|
254 |
STestParameters params; |
|
255 |
||
256 |
params.iDefragType = aDefragType; |
|
257 |
params.iDefragVersion = aDefragVersion; |
|
258 |
params.iID = aID; |
|
259 |
params.iPriority = aPriority; |
|
260 |
params.iMaxPages = aMaxPages; |
|
261 |
params.iReqStat = aReqStat; |
|
262 |
if (aReqStat) |
|
263 |
{ |
|
264 |
*aReqStat = KRequestPending; |
|
265 |
} |
|
266 |
params.iReqStat2 = NULL; |
|
267 |
params.iReqStat3 = NULL; |
|
268 |
TInt ret = DoControl(ECallDefrag,(TAny*)¶ms); |
|
269 |
return ret; |
|
270 |
} |
|
271 |
||
272 |
/** |
|
273 |
@param aZoneID The ID of the RAM zone to modify |
|
274 |
@param aZoneFlag The flags to clear, if want only aSetFlags to be enabled after this then |
|
275 |
aZoneFlag should be the current flags sets on the RAM zone. |
|
276 |
@param aSetFlag The flags to set |
|
277 |
@param aOptSetFlag If aSetFlag==ORIG_FLAG then aOptSetFlag will be the flags to set |
|
278 |
on the RAM zone. |
|
279 |
*/ |
|
280 |
inline TInt SetZoneFlag(TUint aZoneID, TUint8 aZoneFlag, TInt aSetFlag, TUint8 aOptSetFlag = 0x00) |
|
281 |
{ |
|
282 |
STestFlagParams flagParams; |
|
283 |
||
284 |
flagParams.iZoneID = aZoneID; |
|
285 |
flagParams.iZoneFlag = aZoneFlag; |
|
286 |
flagParams.iSetFlag = aSetFlag; |
|
287 |
flagParams.iOptSetFlag = aOptSetFlag; |
|
288 |
||
289 |
return DoControl(ESetZoneFlag,(TAny*)&flagParams, (TAny*)NULL); |
|
290 |
} |
|
291 |
||
292 |
inline TInt CheckPriorities(TInt aDefragType, TUint aID = 0, TRequestStatus* aReqStat = NULL, TRequestStatus* aReqStat2 = NULL, TRequestStatus* aReqStat3 = NULL) |
|
293 |
{ |
|
294 |
STestParameters params; |
|
295 |
||
296 |
params.iDefragType = aDefragType; |
|
297 |
params.iDefragVersion = 0; |
|
298 |
params.iID = aID; |
|
299 |
params.iPriority = 0; |
|
300 |
params.iMaxPages = 0; |
|
301 |
params.iReqStat = aReqStat; |
|
302 |
if (aReqStat) |
|
303 |
{ |
|
304 |
*aReqStat = KRequestPending; |
|
305 |
} |
|
306 |
params.iReqStat2 = aReqStat2; |
|
307 |
if (aReqStat2) |
|
308 |
{ |
|
309 |
*aReqStat2 = KRequestPending; |
|
310 |
} |
|
311 |
params.iReqStat3 = aReqStat3; |
|
312 |
if (aReqStat3) |
|
313 |
{ |
|
314 |
*aReqStat3 = KRequestPending; |
|
315 |
} |
|
316 |
||
317 |
return DoControl(ECheckPriorities,(TAny*)¶ms); |
|
318 |
} |
|
319 |
||
320 |
inline TInt GetDefragOrder() |
|
321 |
{ return DoControl(EGetDefragOrder,(TAny*)NULL, (TAny*)NULL); } |
|
322 |
||
323 |
||
324 |
#endif |
|
325 |
}; |
|
326 |
||
327 |
||
328 |
#endif //_T_RAMDEFRAG_H_ |