Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\defrag\t_ramdefrag.h
18 #ifndef _T_RAMDEFRAG_H_
19 #define _T_RAMDEFRAG_H_
22 #ifndef __KERNEL_MODE__
26 #define DEFRAG_TYPE_GEN (1)
27 #define DEFRAG_TYPE_EMPTY (2)
28 #define DEFRAG_TYPE_CLAIM (3)
30 #define DEFRAG_VER_SYNC (1)
31 #define DEFRAG_VER_SEM (2)
32 #define DEFRAG_VER_DFC (3)
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)
42 #define FREE_ALL_FIXED (0)
43 #define FILL_ALL_FIXED (-1)
45 #define FREE_VALID (0)
46 #define FREE_INVALID (-1)
49 #define TESTDEBUG(a) {a;}
51 #define TESTDEBUG(a) {}
54 struct SCapsPageMoveV01
59 struct STestRamDefragVars
68 struct STestUserSidePageCount
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*/
83 TUint iDiscardablePages;
87 struct STestFlagParams
96 struct STestParameters
103 TRequestStatus* iReqStat;
104 TRequestStatus* iReqStat2;
105 TRequestStatus* iReqStat3;
108 // struct for passing multiple RAM zone IDs to the LDD.
109 struct SMultiZoneAlloc
111 TUint* iZoneId; /**< An array of RAM zone IDs*/
112 TUint iZoneIdSize; /**< The number of IDs in iZoneId*/
115 _LIT(KRamDefragFuncTestLddName,"D_RAMDEFRAG");
117 class RRamDefragFuncTestLdd : public RBusLogicalChannel
132 EZoneAllocContiguous,
133 EMultiZoneAllocContiguous,
134 EZoneAllocDiscontiguous,
135 EMultiZoneAllocDiscontiguous,
136 EZoneAllocDiscontiguous2,
138 EZoneAllocToManyArray,
152 #ifndef __KERNEL_MODE__
155 { return DoCreate(KRamDefragFuncTestLddName,TVersion(),KNullUnit,NULL,NULL,EOwnerProcess,ETrue); }
157 inline TInt ResetDriver()
158 { return DoControl(EResetDriver,(TAny*)NULL, (TAny*)NULL); }
160 inline TInt DoSetDebugFlag(TInt aState)
161 { return DoControl(EDoSetDebugFlag,(TAny*)aState, (TAny*)NULL); }
163 inline TInt AllocateFixed(TInt aNumOfPages)
164 { return DoControl(EAllocateFixed,(TAny*)aNumOfPages, (TAny*)NULL); }
166 inline TInt AllocFixedArray(TInt aNumOfPages)
167 { return DoControl(EAllocFixedArray,(TAny*)aNumOfPages, (TAny*)NULL); }
169 inline TInt AllocateFixed2(TInt aNumOfPages)
170 { return DoControl(EAllocateFixed2,(TAny*)aNumOfPages, (TAny*)NULL); }
172 inline TInt GetAllocDiff(TInt aNumOfPages)
173 { return DoControl(EGetAllocDiff,(TAny*)aNumOfPages, (TAny*)NULL); }
175 inline TInt FreeAllFixedPages()
176 { return DoControl(EFreeAllFixed); }
178 inline TInt AllocateFixedWrite(TInt aNumOfPages)
179 { return DoControl(EAllocateFixedWrite,(TAny*)aNumOfPages, (TAny*)NULL); }
181 inline TInt FreeAllFixedPagesRead()
182 { return DoControl(EFreeAllFixedRead,(TAny*)NULL, (TAny*)NULL); }
184 inline TInt ZoneAllocContiguous(TUint aZoneID, TInt aSize)
185 { return DoControl(EZoneAllocContiguous,(TAny*)aZoneID, (TAny*)aSize); }
187 inline TInt MultiZoneAllocContiguous(TUint* aZoneId, TUint aZoneIdSize, TInt aSize)
189 SMultiZoneAlloc multiZoneAlloc;
190 multiZoneAlloc.iZoneId = aZoneId;
191 multiZoneAlloc.iZoneIdSize = aZoneIdSize;
192 return DoControl(EMultiZoneAllocContiguous,(TAny*)&multiZoneAlloc, (TAny*)aSize);
195 inline TInt ZoneAllocDiscontiguous(TUint aZoneID, TInt aNumPages)
196 { return DoControl(EZoneAllocDiscontiguous,(TAny*)aZoneID, (TAny*)aNumPages); }
198 inline TInt MultiZoneAllocDiscontiguous(TUint* aZoneId, TUint aZoneIdSize, TInt aNumPages)
200 SMultiZoneAlloc multiZoneAlloc;
201 multiZoneAlloc.iZoneId = aZoneId;
202 multiZoneAlloc.iZoneIdSize = aZoneIdSize;
203 return DoControl(EMultiZoneAllocDiscontiguous,(TAny*)&multiZoneAlloc, (TAny*)aNumPages);
206 inline TInt ZoneAllocDiscontiguous2(TUint aZoneID, TInt aNumPages)
207 { return DoControl(EZoneAllocDiscontiguous2,(TAny*)aZoneID, (TAny*)aNumPages); }
209 inline TInt ZoneAllocToMany(TInt aZoneIndex, TInt aNumPages)
210 { return DoControl(EZoneAllocToMany,(TAny*)aZoneIndex, (TAny*)aNumPages); }
212 inline TInt ZoneAllocToManyArray(TInt aZoneIndex, TInt aNumPages)
213 { return DoControl(EZoneAllocToManyArray,(TAny*)aZoneIndex, (TAny*)aNumPages); }
215 inline TInt ZoneAllocToMany2(TInt aZoneIndex, TInt aNumPages)
216 { return DoControl(EZoneAllocToMany2,(TAny*)aZoneIndex, (TAny*)aNumPages); }
218 inline TInt AllocContiguous(TInt aSize)
219 { return DoControl(EAllocContiguous,(TAny*)aSize, (TAny*)NULL); }
221 inline TInt FreeZone(TInt aNumPages)
222 { return DoControl(EFreeZone,(TAny*)aNumPages, (TAny*)NULL); }
224 inline TInt FreeFromAllZones()
225 { return DoControl(EFreeFromAllZones,(TAny*)NULL, (TAny*)NULL); }
228 inline TInt CheckCancel(TInt aDefragType, TUint aID = 0)
230 STestParameters params;
232 params.iDefragType = aDefragType;
233 params.iDefragVersion = 0;
235 params.iPriority = 0;
236 params.iMaxPages = 0;
237 params.iReqStat = NULL;
238 params.iReqStat2 = NULL;
239 params.iReqStat3 = NULL;
240 return DoControl(ECheckCancel,(TAny*)¶ms);
243 inline TInt FreeFromAddr(TInt aNumPages, TUint32 aAddr)
244 { return DoControl(EFreeFromAddr,(TAny*)aNumPages, (TAny*)aAddr); }
246 inline TInt PageCount(TUint aID, STestUserSidePageCount* aPageData)
247 { return DoControl(EPageCount,(TAny*)aID, (TAny*)aPageData); }
249 inline TInt CallDefrag(TInt aDefragType, TInt aDefragVersion, TUint aID = 0, TInt aMaxPages = 0, TInt aPriority = -1, TRequestStatus* aReqStat = NULL)
251 STestParameters params;
253 params.iDefragType = aDefragType;
254 params.iDefragVersion = aDefragVersion;
256 params.iPriority = aPriority;
257 params.iMaxPages = aMaxPages;
258 params.iReqStat = aReqStat;
261 *aReqStat = KRequestPending;
263 params.iReqStat2 = NULL;
264 params.iReqStat3 = NULL;
265 TInt ret = DoControl(ECallDefrag,(TAny*)¶ms);
270 @param aZoneID The ID of the RAM zone to modify
271 @param aZoneFlag The flags to clear, if want only aSetFlags to be enabled after this then
272 aZoneFlag should be the current flags sets on the RAM zone.
273 @param aSetFlag The flags to set
274 @param aOptSetFlag If aSetFlag==ORIG_FLAG then aOptSetFlag will be the flags to set
277 inline TInt SetZoneFlag(TUint aZoneID, TUint8 aZoneFlag, TInt aSetFlag, TUint8 aOptSetFlag = 0x00)
279 STestFlagParams flagParams;
281 flagParams.iZoneID = aZoneID;
282 flagParams.iZoneFlag = aZoneFlag;
283 flagParams.iSetFlag = aSetFlag;
284 flagParams.iOptSetFlag = aOptSetFlag;
286 return DoControl(ESetZoneFlag,(TAny*)&flagParams, (TAny*)NULL);
289 inline TInt CheckPriorities(TInt aDefragType, TUint aID = 0, TRequestStatus* aReqStat = NULL, TRequestStatus* aReqStat2 = NULL, TRequestStatus* aReqStat3 = NULL)
291 STestParameters params;
293 params.iDefragType = aDefragType;
294 params.iDefragVersion = 0;
296 params.iPriority = 0;
297 params.iMaxPages = 0;
298 params.iReqStat = aReqStat;
301 *aReqStat = KRequestPending;
303 params.iReqStat2 = aReqStat2;
306 *aReqStat2 = KRequestPending;
308 params.iReqStat3 = aReqStat3;
311 *aReqStat3 = KRequestPending;
314 return DoControl(ECheckPriorities,(TAny*)¶ms);
317 inline TInt GetDefragOrder()
318 { return DoControl(EGetDefragOrder,(TAny*)NULL, (TAny*)NULL); }
325 #endif //_T_RAMDEFRAG_H_