os/kernelhwsrv/kerneltest/e32test/defrag/t_ramdefrag.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/defrag/t_ramdefrag.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,325 @@
     1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\defrag\t_ramdefrag.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef _T_RAMDEFRAG_H_
    1.22 +#define _T_RAMDEFRAG_H_
    1.23 +
    1.24 +#include <e32cmn.h>
    1.25 +#ifndef __KERNEL_MODE__
    1.26 +#include <e32std.h>
    1.27 +#endif
    1.28 +
    1.29 +#define DEFRAG_TYPE_GEN 		(1)
    1.30 +#define DEFRAG_TYPE_EMPTY 		(2)
    1.31 +#define DEFRAG_TYPE_CLAIM		(3)
    1.32 +
    1.33 +#define DEFRAG_VER_SYNC 		(1)
    1.34 +#define DEFRAG_VER_SEM	 		(2)
    1.35 +#define DEFRAG_VER_DFC			(3)
    1.36 +
    1.37 +#define NO_FIXED_FLAG			(1)
    1.38 +#define NO_MOVE_FLAG			(2)
    1.39 +#define NO_DISCARD_FLAG			(3)
    1.40 +#define NO_ALLOC_FLAG			(4)
    1.41 +#define ONLY_DISCARD_FLAG		(5)
    1.42 +#define RESET_FLAG				(6)
    1.43 +#define ORIG_FLAG				(7)
    1.44 +
    1.45 +#define FREE_ALL_FIXED			(0)
    1.46 +#define FILL_ALL_FIXED			(-1)
    1.47 +
    1.48 +#define FREE_VALID				(0)
    1.49 +#define FREE_INVALID			(-1)
    1.50 +//#define DEBUG_VER
    1.51 +#ifdef DEBUG_VER
    1.52 +#define TESTDEBUG(a) {a;}
    1.53 +#else
    1.54 +#define TESTDEBUG(a) {}
    1.55 +#endif
    1.56 +
    1.57 +struct SCapsPageMoveV01
    1.58 +	{
    1.59 +	TVersion	iVersion;
    1.60 +	};
    1.61 +	
    1.62 +struct STestRamDefragVars
    1.63 +	{
    1.64 +	TInt iRamSize;
    1.65 +	TInt iFreeRam;
    1.66 +	TInt iPageSize;
    1.67 +	TInt iRamUsed;
    1.68 +	TInt iNumFreePages;
    1.69 +	};
    1.70 +
    1.71 +struct STestUserSidePageCount
    1.72 +	{
    1.73 +	TUint iFreePages;		/**<the number of free pages in the RAM zone*/
    1.74 +	TUint iFixedPages;		/**<the number of fixed pages in the RAM zone*/
    1.75 +	TUint iMovablePages;	/**<the number of movable pages in the RAM zone*/
    1.76 +	TUint iDiscardablePages;/**<the number of discardable pages in the RAM zone*/
    1.77 +	TUint iReserved[4];		/**<@internalAll reserved for internal use only*/
    1.78 +	};
    1.79 +
    1.80 +struct STestPageCount
    1.81 +	{
    1.82 +	TUint iFreePages;
    1.83 +	TUint iUnknownPages;
    1.84 +	TUint iFixedPages;
    1.85 +	TUint iMovablePages;
    1.86 +	TUint iDiscardablePages;
    1.87 +	TUint iOtherPages;
    1.88 +	};
    1.89 +
    1.90 +struct STestFlagParams
    1.91 +	{
    1.92 +	TUint	iZoneID;
    1.93 +	TUint8	iZoneFlag;
    1.94 +	TInt	iSetFlag;
    1.95 +	TUint8	iOptSetFlag;
    1.96 +	};
    1.97 +
    1.98 +
    1.99 +struct STestParameters
   1.100 +	{
   1.101 +	TInt iDefragVersion; 
   1.102 +	TInt iDefragType;
   1.103 +	TInt iPriority;
   1.104 +	TInt iMaxPages;
   1.105 +	TUint iID;
   1.106 +	TRequestStatus* iReqStat;
   1.107 +	TRequestStatus* iReqStat2;
   1.108 +	TRequestStatus* iReqStat3;
   1.109 +	};
   1.110 +
   1.111 +// struct for passing multiple RAM zone IDs to the LDD.
   1.112 +struct SMultiZoneAlloc
   1.113 +	{
   1.114 +	TUint* iZoneId;			/**< An array of RAM zone IDs*/
   1.115 +	TUint iZoneIdSize;		/**< The number of IDs in iZoneId*/
   1.116 +	};
   1.117 +
   1.118 +_LIT(KRamDefragFuncTestLddName,"D_RAMDEFRAG");
   1.119 +
   1.120 +class RRamDefragFuncTestLdd : public RBusLogicalChannel
   1.121 +	{
   1.122 +public:
   1.123 +	enum TControl
   1.124 +		{
   1.125 +		EDoConsumeRamFinish,
   1.126 +		EDoSetDebugFlag,
   1.127 +		EAllocateFixed,
   1.128 +		EAllocFixedArray, 
   1.129 +		EAllocateFixed2,
   1.130 +		EGetAllocDiff,
   1.131 +		EFreeAllFixed,
   1.132 +		EAllocateFixedWrite,
   1.133 +		EFreeAllFixedRead,
   1.134 +		EPageCount,
   1.135 +		EZoneAllocContiguous,
   1.136 +		EMultiZoneAllocContiguous,
   1.137 +		EZoneAllocDiscontiguous,
   1.138 +		EMultiZoneAllocDiscontiguous,
   1.139 +		EZoneAllocDiscontiguous2,
   1.140 +		EZoneAllocToMany,
   1.141 +		EZoneAllocToManyArray,
   1.142 +		EZoneAllocToMany2,
   1.143 +		EAllocContiguous,
   1.144 +		EFreeZone,
   1.145 +		EFreeFromAllZones,
   1.146 +		EFreeFromAddr, 
   1.147 +		ECheckCancel,
   1.148 +		ECheckPriorities,
   1.149 +		ECallDefrag,
   1.150 +		ESetZoneFlag,
   1.151 +		EGetDefragOrder,
   1.152 +		EResetDriver,
   1.153 +		};
   1.154 +
   1.155 +#ifndef __KERNEL_MODE__
   1.156 +public:
   1.157 +	inline TInt Open()
   1.158 +		{ return DoCreate(KRamDefragFuncTestLddName,TVersion(),KNullUnit,NULL,NULL,EOwnerProcess,ETrue); }
   1.159 +
   1.160 +	inline TInt ResetDriver()
   1.161 +		{ return DoControl(EResetDriver,(TAny*)NULL, (TAny*)NULL); }
   1.162 +
   1.163 +	inline TInt DoSetDebugFlag(TInt aState)
   1.164 +		{ return DoControl(EDoSetDebugFlag,(TAny*)aState, (TAny*)NULL); }
   1.165 +
   1.166 +	inline TInt AllocateFixed(TInt aNumOfPages)
   1.167 +		{ return DoControl(EAllocateFixed,(TAny*)aNumOfPages, (TAny*)NULL); }
   1.168 +
   1.169 +	inline TInt AllocFixedArray(TInt aNumOfPages)
   1.170 +		{ return DoControl(EAllocFixedArray,(TAny*)aNumOfPages, (TAny*)NULL); }
   1.171 +
   1.172 +	inline TInt AllocateFixed2(TInt aNumOfPages)
   1.173 +		{ return DoControl(EAllocateFixed2,(TAny*)aNumOfPages, (TAny*)NULL); }
   1.174 +
   1.175 +	inline TInt GetAllocDiff(TInt aNumOfPages)
   1.176 +		{ return DoControl(EGetAllocDiff,(TAny*)aNumOfPages, (TAny*)NULL); }
   1.177 +
   1.178 +	inline TInt FreeAllFixedPages()
   1.179 +		{ return DoControl(EFreeAllFixed); }
   1.180 +
   1.181 +	inline TInt AllocateFixedWrite(TInt aNumOfPages)
   1.182 +		{ return DoControl(EAllocateFixedWrite,(TAny*)aNumOfPages, (TAny*)NULL); }
   1.183 +
   1.184 +	inline TInt FreeAllFixedPagesRead()
   1.185 +		{ return DoControl(EFreeAllFixedRead,(TAny*)NULL, (TAny*)NULL); }
   1.186 +
   1.187 +	inline TInt ZoneAllocContiguous(TUint aZoneID, TInt aSize)
   1.188 +		{ return DoControl(EZoneAllocContiguous,(TAny*)aZoneID, (TAny*)aSize); }
   1.189 +
   1.190 +	inline TInt MultiZoneAllocContiguous(TUint* aZoneId, TUint aZoneIdSize, TInt aSize)
   1.191 +		{ 
   1.192 +		SMultiZoneAlloc multiZoneAlloc;
   1.193 +		multiZoneAlloc.iZoneId = aZoneId;
   1.194 +		multiZoneAlloc.iZoneIdSize = aZoneIdSize;
   1.195 +		return DoControl(EMultiZoneAllocContiguous,(TAny*)&multiZoneAlloc, (TAny*)aSize); 
   1.196 +		}
   1.197 +
   1.198 +	inline TInt ZoneAllocDiscontiguous(TUint aZoneID, TInt aNumPages)
   1.199 +		{ return DoControl(EZoneAllocDiscontiguous,(TAny*)aZoneID, (TAny*)aNumPages); }
   1.200 +
   1.201 +	inline TInt MultiZoneAllocDiscontiguous(TUint* aZoneId, TUint aZoneIdSize, TInt aNumPages)
   1.202 +		{ 
   1.203 +		SMultiZoneAlloc multiZoneAlloc;
   1.204 +		multiZoneAlloc.iZoneId = aZoneId;
   1.205 +		multiZoneAlloc.iZoneIdSize = aZoneIdSize;
   1.206 +		return DoControl(EMultiZoneAllocDiscontiguous,(TAny*)&multiZoneAlloc, (TAny*)aNumPages);
   1.207 +		}
   1.208 +
   1.209 +	inline TInt ZoneAllocDiscontiguous2(TUint aZoneID, TInt aNumPages)
   1.210 +		{ return DoControl(EZoneAllocDiscontiguous2,(TAny*)aZoneID, (TAny*)aNumPages); }
   1.211 +
   1.212 +	inline TInt ZoneAllocToMany(TInt aZoneIndex, TInt aNumPages)
   1.213 +		{ return DoControl(EZoneAllocToMany,(TAny*)aZoneIndex, (TAny*)aNumPages); }
   1.214 +
   1.215 +	inline TInt ZoneAllocToManyArray(TInt aZoneIndex, TInt aNumPages)
   1.216 +		{ return DoControl(EZoneAllocToManyArray,(TAny*)aZoneIndex, (TAny*)aNumPages); }
   1.217 +
   1.218 +	inline TInt ZoneAllocToMany2(TInt aZoneIndex, TInt aNumPages)
   1.219 +		{ return DoControl(EZoneAllocToMany2,(TAny*)aZoneIndex, (TAny*)aNumPages); }
   1.220 +	
   1.221 +	inline TInt AllocContiguous(TInt aSize)
   1.222 +		{ return DoControl(EAllocContiguous,(TAny*)aSize, (TAny*)NULL); }
   1.223 +
   1.224 +	inline TInt FreeZone(TInt aNumPages)
   1.225 +		{ return DoControl(EFreeZone,(TAny*)aNumPages, (TAny*)NULL); }
   1.226 +
   1.227 +	inline TInt FreeFromAllZones()
   1.228 +		{ return DoControl(EFreeFromAllZones,(TAny*)NULL, (TAny*)NULL); }
   1.229 +
   1.230 +
   1.231 +	inline TInt CheckCancel(TInt aDefragType, TUint aID = 0)
   1.232 +		{ 
   1.233 +		STestParameters params;
   1.234 +		
   1.235 +		params.iDefragType = aDefragType;
   1.236 +		params.iDefragVersion = 0;
   1.237 +		params.iID = aID;
   1.238 +		params.iPriority = 0;
   1.239 +		params.iMaxPages = 0;
   1.240 +		params.iReqStat = NULL; 
   1.241 +		params.iReqStat2 = NULL; 
   1.242 +		params.iReqStat3 = NULL; 
   1.243 +		return DoControl(ECheckCancel,(TAny*)&params); 
   1.244 +		}
   1.245 +
   1.246 +	inline TInt FreeFromAddr(TInt aNumPages, TUint32 aAddr)
   1.247 +		{ return DoControl(EFreeFromAddr,(TAny*)aNumPages, (TAny*)aAddr); }
   1.248 +
   1.249 +	inline TInt PageCount(TUint aID, STestUserSidePageCount* aPageData)
   1.250 +		{ return DoControl(EPageCount,(TAny*)aID, (TAny*)aPageData); }
   1.251 +
   1.252 +	inline TInt CallDefrag(TInt aDefragType, TInt aDefragVersion, TUint aID = 0, TInt aMaxPages = 0, TInt aPriority = -1, TRequestStatus* aReqStat = NULL)
   1.253 +		{ 
   1.254 +		STestParameters params;
   1.255 +		
   1.256 +		params.iDefragType = aDefragType;
   1.257 +		params.iDefragVersion = aDefragVersion;
   1.258 +		params.iID = aID;
   1.259 +		params.iPriority = aPriority;
   1.260 +		params.iMaxPages = aMaxPages;
   1.261 +		params.iReqStat = aReqStat;
   1.262 +		if (aReqStat)
   1.263 +			{
   1.264 +			*aReqStat = KRequestPending;
   1.265 +			}
   1.266 +		params.iReqStat2 = NULL; 
   1.267 +		params.iReqStat3 = NULL; 
   1.268 +		TInt ret = DoControl(ECallDefrag,(TAny*)&params); 
   1.269 +		return ret;
   1.270 +		}
   1.271 +
   1.272 +	/**
   1.273 +	@param aZoneID		The ID of the RAM zone to modify
   1.274 +	@param aZoneFlag	The flags to clear, if want only aSetFlags to be enabled after this then
   1.275 +						aZoneFlag should be the current flags sets on the RAM zone.
   1.276 +	@param aSetFlag		The flags to set
   1.277 +	@param aOptSetFlag	If aSetFlag==ORIG_FLAG then aOptSetFlag will be the flags to set 
   1.278 +						on the RAM zone.
   1.279 +	*/
   1.280 +	inline TInt SetZoneFlag(TUint aZoneID, TUint8 aZoneFlag, TInt aSetFlag, TUint8 aOptSetFlag = 0x00)
   1.281 +		{ 
   1.282 +		STestFlagParams flagParams;
   1.283 +		
   1.284 +		flagParams.iZoneID = aZoneID;
   1.285 +		flagParams.iZoneFlag = aZoneFlag;
   1.286 +		flagParams.iSetFlag = aSetFlag;
   1.287 +		flagParams.iOptSetFlag = aOptSetFlag;
   1.288 +		
   1.289 +		return DoControl(ESetZoneFlag,(TAny*)&flagParams, (TAny*)NULL); 
   1.290 +		}
   1.291 +
   1.292 +	inline TInt CheckPriorities(TInt aDefragType, TUint aID = 0, TRequestStatus* aReqStat = NULL, TRequestStatus* aReqStat2 = NULL, TRequestStatus* aReqStat3 = NULL)
   1.293 +		{ 
   1.294 +		STestParameters params;
   1.295 +		
   1.296 +		params.iDefragType = aDefragType;
   1.297 +		params.iDefragVersion = 0;
   1.298 +		params.iID = aID;
   1.299 +		params.iPriority = 0;
   1.300 +		params.iMaxPages = 0;
   1.301 +		params.iReqStat = aReqStat;
   1.302 +		if (aReqStat)
   1.303 +			{
   1.304 +			*aReqStat = KRequestPending;
   1.305 +			}
   1.306 +		params.iReqStat2 = aReqStat2; 
   1.307 +		if (aReqStat2)
   1.308 +			{
   1.309 +			*aReqStat2 = KRequestPending;
   1.310 +			}
   1.311 +		params.iReqStat3 = aReqStat3;  
   1.312 +		if (aReqStat3)
   1.313 +			{
   1.314 +			*aReqStat3 = KRequestPending;
   1.315 +			}
   1.316 +
   1.317 +		return DoControl(ECheckPriorities,(TAny*)&params); 
   1.318 +		}
   1.319 +
   1.320 +	inline TInt GetDefragOrder()
   1.321 +		{ return DoControl(EGetDefragOrder,(TAny*)NULL, (TAny*)NULL); }
   1.322 +
   1.323 +
   1.324 +#endif
   1.325 +	};
   1.326 +
   1.327 +
   1.328 +#endif //_T_RAMDEFRAG_H_